typed_python
typed_python copied to clipboard
Improve error message when we don't match a Function's overloads
Right now if you have f(x: int)
and you call it with 'str' you get a very confusing and unhelpful error message - it simply tells you that the pattern doesn't match.
Instead, we should try to tell our users more about why its not matching - for instance, if you only have a single overload (which is the majority of cases), you could indicate which terms are not matching, or make a clear indication if you have the wrong number of arguments.
This change needs to be made in both PyFunctionInstance.cpp (see calls to argTupleTypeDescription) and also in python_typed_function_wrapper.py, which currently implements a bunch of different ways of producing this error message that leak compiler details and are not consistent. Ideally, the compiler always produces the same message as the interpreter.