Closed IsaacOscar closed 5 years ago
Obviously, the compiler should not crash. But what should the correct behaviour be? Should we compile code that will always generate a NoSuchMethod
error? Or raise a type error statically — which is not something that minigrace does anywhere else.
The language requires an anonymous function taking a single argument after the keyword case. If a literal block occurs there it seems easy enough to detect syntactically whether or not it has a single parameter and to declare an error immediately. If it is not a literal block, then it is likely undecidable and should just be ignored in the base language.
It seems parallel to the issue of putting curly braces around the condition in a while loop (there it requires a zero-ary function, so a unary function would be an error), so it seems they should both be handled similarly (and I don't know how it is handled for while loops now).
When I forget to put an "->" in my case blocks, e.g. with:
The compiler crashes with the following error:
Naturally I can fix this by writing
But it would be nice to have a more helpful error message.