asteroid icon indicating copy to clipboard operation
asteroid copied to clipboard

Locational error reporting

Open olwmc opened this issue 4 years ago • 3 comments

Consider the program:

function foo 
    with x:%integer do
        return 1.
    end

foo "string!".

Running this would return the error Error: <path>: 2: none of the function bodies unified with actual parameters

A nicer way of displaying errors would be something like this:

Error: <path>: 2: none of the function bodies unified with actual parameters

foo "string!".
^ 

olwmc avatar Feb 25 '22 17:02 olwmc

Yes! Actually even better,

Error: <path>: 2: none of the function bodies unified with actual parameters

foo "string!".
 .....^

where it points to the offending token or structure.

I really don't like that error message, only folks who know about our semantics can understand that message. What would be a could general error message to post here? Something like,

Error: <path>: 2: actual argument not recognized.

foo "string!".
.....^

Any other suggestions?

lutzhamel avatar Feb 25 '22 19:02 lutzhamel

I think that works well! While writing this issue I was thinking the same thing. I'll add it to #126

olwmc avatar Feb 25 '22 20:02 olwmc

in 1.1.4 the generated error message reads

lutz$ asteroid loc.ast
traceback (most recent call last):
loc.ast: 1: calling <toplevel>
loc.ast: 6: calling foo
error: loc.ast: 2: actual argument 'string!' not recognized by function 'foo'
lutz$ 

which is an improvement.

However, because recognizing an actual argument is pattern matching and therefore computation the error message is pointing into the function code rather than to the call site. Should we fix that?

lutzhamel avatar Dec 06 '22 13:12 lutzhamel