In the create wrapper phase wrappers are created which group functions by their arity.
So if you have these 4 functions:
int, int foo(int a) {...}
short, short foo(short a) {...}
int foo(int a, int a) {...}
short foo(short a, short a) {...}
Two wrappers for foo in total will be created. One for the functions with 1 input and 2 outputs and another one for the versions of foo with 2 inputs and 1 output.
This mr improves the errors you get when you try to call a wrapper that does not exist.
The current error is this:
No definition found for a function _MAIN::foo that 3 argument(s) and yields 1 return value(s)
To improve this error message I split it up into 5 cases:
- a. The programmer calls a function that just does not exist anywhere
- The function is sel.
- The function is not sel and a similarly named function exists.
- The function is not sel and a similarly named function does not exists.
- b. The programmer calls a version of a function that does not exist
- Calling the version that returns void, which often does not exist.
- No matching instance with number of return variables and arguments
a
a1
In this case the programmer did something like arr[1]
without having a sel function.
It is not intuitive that the arr[1] syntax requires the sel function.
I decided we should give a special error message for this case.
a2
In this case the whole function just doesn't exist. We can assume that the programmer makes a typo. With a typo there is probably a function that is named similarly. Check all the function names edit distance and make a suggestion based on if a function name has damerau_levenshtein_distance =< EDIT_DISTANCE_TRESHOLD with the ap then we give a hint to use that function.
a3
If there is no function defined with a name that is damerau_levenshtein_distance =< EDIT_DISTANCE_TRESHOLD to the function name being called, give an error that there is no function with this name and also not one that kind of has the same name.
b
b1
I think that b1 is a special case for which we should make a specific error message which explains that you have to assign the result to a variable or define a version that returns void.
As soon as we find out this is the case we should tell them about that not assigning tries to call the void overload.
b2
In this case we say you got both the number of returns and arguments wrong. Show which versions of the function are available.
Initially I had some more cases in b with versions of the error if the programmers spap had a number of arguments that existed but a wrong number of return values but this was actually unhelpful and also more complex.