diff --git a/documentation/source/library-reference/common-dylan/common-extensions.rst b/documentation/source/library-reference/common-dylan/common-extensions.rst index 7bb3fffe6..e5d853c3d 100644 --- a/documentation/source/library-reference/common-dylan/common-extensions.rst +++ b/documentation/source/library-reference/common-dylan/common-extensions.rst @@ -132,7 +132,7 @@ The extensions are: .. generic-function:: condition-to-string :open: - Returns a string representation of a condition object. + Returns a :drm:`` representation of a condition object. :signature: condition-to-string *condition* => *string* @@ -142,9 +142,15 @@ The extensions are: :description: Returns a string representation of a general instance of - :drm:``. There is a method on - :class:`` and method on - :drm:``. + :drm:``. + + Note that it is often not necessary to write a method on this generic + function for your condition classes because you can use the method + provided by :class:``, usually via one of its + subclasses, :drm:``, :drm:``, or + :drm:``. Simply make your condition a subclass of one of + these classes and provide the ``format-string:`` and ``format-arguments:`` + init keywords. .. macro:: debug-assert :statement: diff --git a/sources/common-dylan/format.dylan b/sources/common-dylan/format.dylan index 6860ddcfa..cdf63103f 100644 --- a/sources/common-dylan/format.dylan +++ b/sources/common-dylan/format.dylan @@ -588,13 +588,6 @@ define method condition-to-string condition-format-arguments(condition)) end method condition-to-string; -define method condition-to-string - (error :: ) => (string :: ) - format-to-string("%= is not of type %=", - type-error-value(error), - type-error-expected-type(error)) -end method condition-to-string; - define method print-pretty-name (buffer :: , condition :: ) => () diff --git a/sources/common-dylan/tests/condition-test-utilities.dylan b/sources/common-dylan/tests/condition-test-utilities.dylan index d9ca4d8ec..c47811638 100644 --- a/sources/common-dylan/tests/condition-test-utilities.dylan +++ b/sources/common-dylan/tests/condition-test-utilities.dylan @@ -66,6 +66,12 @@ define method test-condition (condition :: ) => () )) end method test-condition; +define method make-condition (class == ) => (c :: ) + make(, + value: #"type-error-value", + type: ) +end method; + define method test-condition (condition :: ) => () next-method(); do(method (function) function(condition) end, diff --git a/sources/dylan/condition-extras.dylan b/sources/dylan/condition-extras.dylan index 5d9e09fb8..be53f97ff 100644 --- a/sources/dylan/condition-extras.dylan +++ b/sources/dylan/condition-extras.dylan @@ -89,9 +89,13 @@ end method abort; /// TYPE-ERRORS -define open class (, ) // Should be sealed? - constant slot type-error-value, init-keyword: value:; - constant slot type-error-expected-type :: , init-keyword: type:; +// Note that the DRM only mentions as a superclass. Speculation: we +// additionally subclass because there is special support +// for its condition-format-string and condition-format-arguments in the +// debugger manager. +define sealed class (, ) + constant slot type-error-value, required-init-keyword: value:; + constant slot type-error-expected-type :: , required-init-keyword: type:; end class ; define method make diff --git a/sources/dylan/tests/specification.dylan b/sources/dylan/tests/specification.dylan index 81daafbb3..46c50f63d 100644 --- a/sources/dylan/tests/specification.dylan +++ b/sources/dylan/tests/specification.dylan @@ -238,7 +238,7 @@ define interface-specification-suite dylan-conditions-specification-suite () open abstract class (); sealed instantiable class (); sealed instantiable class (); - sealed instantiable class (); + sealed instantiable class (); // make-test-instance method below. open abstract class (); /// Restarts @@ -286,6 +286,12 @@ define interface-specification-suite dylan-conditions-specification-suite () expected-to-fail-reason: "https://github.com/dylan-lang/opendylan/issues/1295"; end dylan-conditions-specification-suite; +define sideways method make-test-instance (class == ) => (err :: ) + make(, + value: #"type-error-value", + type: ) +end method; + //--- Bindings not defined by the DRM //---*** Are there any others?