APrioriInvestments / typed_python

An llvm-based framework for generating and calling into high-performance native code from Python.
Apache License 2.0
197 stars 8 forks source link

Improve error message when we don't match a Function's overloads #407

Open braxtonmckee opened 1 year ago

braxtonmckee commented 1 year ago

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.