You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The standard library and the compiler together raise NotImplementedError in 141 places, and their message is almost always the fully qualified type name followed by the method name. That calls for a refactor:
macronot_implemented!
::raise(::NotImplementedError.new(\{{ "#{@type}##{@def.name}" }}))
end
Then we can write things such as:
classProcess::Statusdefexit_signal : Signal
{%if flag?(:unix) %}
Signal.from_value(signal_code)
{%else%}
not_implemented!
{%end%}
endend# on Windows:$?.exit_signal # Unhandled exception: Not Implemented: Process::Status#exit_signal (NotImplementedError)
A more robust macro should at least also check for class methods and top-level defs when producing that exception message, such as WinError.value and the string_build_via_utf16 spec helper. (Yet other things, like file-private defs, #11764, and methods on Class itself are also possible.)
The above defines not_implemented! as a public, top-level macro, since third-party libraries may write platform-specific checks similar to the ones we have in the standard library. If we keep this internally it would be Crystal.not_implemented! instead.
The text was updated successfully, but these errors were encountered:
A more robust macro should at least also check for class methods and top-level defs when producing that exception message
I figure the compiler should probably provide a method to get the fully qualified name of a method. Basically exposing something like Def#short_reference, optionally with arguments maybe.
The standard library and the compiler together raise
NotImplementedError
in 141 places, and their message is almost always the fully qualified type name followed by the method name. That calls for a refactor:Then we can write things such as:
A more robust macro should at least also check for class methods and top-level defs when producing that exception message, such as
WinError.value
and thestring_build_via_utf16
spec helper. (Yet other things, like file-private defs, #11764, and methods onClass
itself are also possible.)The above defines
not_implemented!
as a public, top-level macro, since third-party libraries may write platform-specific checks similar to the ones we have in the standard library. If we keep this internally it would beCrystal.not_implemented!
instead.The text was updated successfully, but these errors were encountered: