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
Expand the "Unexpected existential" error message #1733
Conversation
This looks like a clear improvement. One case that's not handled correctly yet: existential types are not allowed in let Any _ = Any ()
and () = ()
in () and with this PR, the error is misreported as a problem with a toplevel binding:
|
This is a great point, thanks for pointing the issue. I have fixed the error message in all case where existentials are not allowed inside a local let-binding, e.g. let () =
let Any x = Any () and () = () in
()
but also let () =
let rec Any x = Any () in
()
let () =
let[@attribute] Any x = Any () in
()
and class c = let Any _x = () in object end
|
Nitpicking, I don't like "unnamed existential types", I think you should just say "existential types" when you cannot get a specific name. |
I will remove the |
I have removed the offending adjective. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved in principle. Could you fix the conflict and rebase?
cc @Armael: there is no need for you to work on this PR, but it is similar to work that you did adding explanation markers, so I thought you may be interested. |
9a08a6f
to
ce7ce2a
Compare
The conflict has been solved and the reviewers have been credited. |
I had a look at the code again and I realize only now that I have an implementation question: why are we exposing this somewhat-weird |
Do you mean expanding the (Replacing the |
Currently when the type-checker encounters unexpected existentially quantified types, e.g.
it emits the following errror message
If this terse message is clear from the perspective of the type-checker, it may seem mysterious from an user perspective.
This PR proposes thus to focus on the user perspective in this error message by making clear in which contexts existential types are not allowed and from where the problematic existential types come from:
The error message directly refers to an existential type name if one is available, otherwise it names the constructor itself: