-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
Consider the following:
def foo() -> int:
return 1 + "hello"
def main() -> None:
foo()
Currently, we get this error:
❯ spy /tmp/x.spy
TypeError: cannot do `i32` + `str`
--> /tmp/x.spy:2:12
2 | return 1 + "hello"
| ^ this is `i32`
--> /tmp/x.spy:2:16
2 | return 1 + "hello"
| |_____| this is `str`
--> /tmp/x.spy:2:12
2 | return 1 + "hello"
| |_________| operator::ADD called here

I think it would be nice to include the function name (or even better, the FQN) in the error message. Something like this:
❯ spy /tmp/x.spy
TypeError: cannot do `i32` + `str`
In function `x::foo`:
--> /tmp/x.spy:2:12
2 | return 1 + "hello"
| ^ this is `i32`
--> /tmp/x.spy:2:16
2 | return 1 + "hello"
| |_____| this is `str`
--> /tmp/x.spy:2:12
2 | return 1 + "hello"
| |_________| operator::ADD called here
I honestly don't know what is the best way to present/format it, I'm open to suggestion. I think it would be good to see what other "modern" compilers do in similar cases (e.g. rust, zig, go).
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed