Improve an error message when an ability variable can't be solved. #5825
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.
In definitions like:
we end up in a situation where we can't actually solve to the type
'{g} a ->{g} (). The reason is that we make up the existential variable immediately so that we can type check the recursive function with a specified type of'{g} a ->{e} (). Thegthateneeds to be solved to ends up later in the context, so the solution is not allowed.This change introduces a new error message that detects this situation and suggests an ability set for the signature. There was a previous 'pretty' error message that had been disabled for this situation, but it was fairly uninformative, and might have been just as useless as the ugly error message we were currently displaying.
Fixes #5655 and #5025
Note: this problem only occurs with recursive definitions. We actually take steps to avoid this problem in other situations (do
existentializeArrowsafter unbinding the foralls). But this isn't an option for recursive let, because the control flow adds the existentials and type signatures to the context before checking any definitions in the binding group.