Use original variable names in error messages about Skolem variables #2340
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Each type variable now carries two variable names: one, the original, user-supplied name of the type variable, and another, the (potentially different) current freshly generated name. These can diverge specifically in the case that we skolemize a user-supplied polymorphic type. We use the second name for all comparisons, but the first name when pretty-printing.
For example,
def f : a -> a = \x. 3 end
used to generate an error message saying something like "expected3
to have types1
; it now says "expected3
to have typea
".Closes #2102. That issue also talks about improving the error message that says "skolem variable would escape its scope", but at the moment I can't even find a way to get that error message to be generated at all, so I propose to not worry about it for now.
There is one specific situation where this can be confusing, when one type variable is shadowed by another with the same name. For example:
Not sure whether it's worth doing anything about this; open to suggestions.