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
This task is automatically imported from the old Task Issue Board and it was originally created by Radosław Waśko.
Original issue is here.
To illustrate the issue, run the following program:
from Standard.Base import all
foo arg1=42 arg2=30 =
arg1+arg2+100
main =
IO.println foo
IO.println (foo 10)
IO.println (foo arg2=44)
IO.println (foo arg3=45)
It currently produces:
172
140
186
Execution finished with an error: Type error: expected a function, but got 172 (Integer).
at <enso> mismatch.main<arg-1>(mismatch.enso:10:17-27)
at <enso> mismatch.main(mismatch.enso:10:5-28)
The error produced is quite unintuitive - in bigger codebases it's much harder to track down what went wrong - why is the method not invokable, I'm calling a function. Of course it makes sense from the point of view of Enso's semantics (if we do not match any named argument, we apply all defaulted ones in the hope that once we call that function, it will return yet another function that may then have an argument that will match; then it returns not a function we were looking for but an Integer which is not invokable).
Still, it could be great if we could improve this error handling to get some more user-friendly message like:
Unexpected_Named_Argument: A named argument `arg3` was provided, but the method does not expect any arguments with that name.
Of course, if I'd do 100 (arg3=10), I should still get Not_Invokable_Error. The new Unexpected_Named_Argument should only apply if I'm calling something callable and there is no match.
Even more ideally, we must know at the callsite what are the possible argument names (this is how we match it against the provided argument name). Thus we could 'browse' these matches and see if any of the arguments have some low edit distance to the provided one (we should set some sane threshold for that, maybe 5 differences? Or depending on the length, 20% of the length diffference?). Then we could suggest similar argument names in the error message (as 90% cases I'm currently getting Not_Invokable_Error is due to typos that would be tremendous help):
Unexpected_Named_Argument: A named argument `arg3` was provided, but the method does not expect any arguments with that name. Did you mean: `arg1`, `arg2`?
The text was updated successfully, but these errors were encountered:
This task is automatically imported from the old Task Issue Board and it was originally created by Radosław Waśko.
Original issue is here.
To illustrate the issue, run the following program:
It currently produces:
The error produced is quite unintuitive - in bigger codebases it's much harder to track down what went wrong - why is the method not invokable, I'm calling a function. Of course it makes sense from the point of view of Enso's semantics (if we do not match any named argument, we apply all defaulted ones in the hope that once we call that function, it will return yet another function that may then have an argument that will match; then it returns not a function we were looking for but an Integer which is not invokable).
Still, it could be great if we could improve this error handling to get some more user-friendly message like:
Of course, if I'd do
100 (arg3=10)
, I should still getNot_Invokable_Error
. The newUnexpected_Named_Argument
should only apply if I'm calling something callable and there is no match.Even more ideally, we must know at the callsite what are the possible argument names (this is how we match it against the provided argument name). Thus we could 'browse' these matches and see if any of the arguments have some low edit distance to the provided one (we should set some sane threshold for that, maybe 5 differences? Or depending on the length, 20% of the length diffference?). Then we could suggest similar argument names in the error message (as 90% cases I'm currently getting
Not_Invokable_Error
is due to typos that would be tremendous help):The text was updated successfully, but these errors were encountered: