-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If an identifier is unknown don't print any other error information #517
Comments
Good timing, I was just working on improving the overload errors yesterday! I just added a heuristic that prefers other errors other the unify errors (which I also changed to 'type mismatch' and added more location info. This is another good heuristic, so I will add it as well |
Ah yeah I was going to suggest that too. I assume "unify" is some standard PL theory term, and it's kind of clear from the context what it means but it did confuse me for a second! Type mismatch is much clearer. |
I think maybe the way to go is to do the following when we encounter an overload:
If we checked overloads like that, we'd essentially get this heuristic for free just from the way the typing rule worked. It would also be a performance optimisation, because we would rule out impossible cases earlier and not waste time exploring them. |
Maybe I'm being dumb, but when you get to an identifier and try to figure out what it is and you don't find any definitions for that identifier or any type (variable, function, etc), can't you immediately stop? I wouldn't be surprised if the error is more confusing if that item exists but is the wrong type (e.g. trying to call a variable) but if literally no item exists with the name it seems like you could do an early stop and report that very clearly. I have never written a compiler though (does a WASM to TCL transpiler count? 😄), let alone a fancy dependently typed one so sorry if I am spewing nonsense! |
Yes, in the scheme I described that would cause us to stop immediately on the second bullet point. |
With #526 the following:
now prints:
whereas before it printed:
|
Much better, thanks! |
I've noticed this a few times, but occasionally I get a big confusing error message like this:
This is pretty much big enough that I interpret it as "eh something went wrong; and it's complaining about
bitvector
andbool
a lot so maybe I didsome_bitvector == some_bool
by mistake.Nope. The error is actually
No function type found for is_pte_ptr
. It is in there, but it's kind of hard to spot! Also it's a slightly confusingly worded error - "no function type found..." when really it means there's literally no function at all! I meant to typepte_is_ptr
.I think it would make sense that if any identifier isn't found, it just ignores all other errors and prints that. If it can't find an identifier that is definitely the mistake! Or at least the first mistake you should fix. Something like this:
Btw, it could be worse - with SystemVerilog Assertions, if you have a variable name typo it will just silently create a new variable for you with the value
x
!The text was updated successfully, but these errors were encountered: