-
Notifications
You must be signed in to change notification settings - Fork 214
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
Add hints for type errors where the user might have meant {=}
instead of {}
#2238
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sjakobi
added a commit
that referenced
this pull request
Jul 7, 2021
This bug manifested as an incorrect type error explanation: You supplied this expression as one of the arguments: ↳ { x = 1 } ... which is not a record, but is actually a: ↳ Type ──────────────────────────────────────────────────────────────────────────────── 1│ { x = 1 } /\ {} This issue was reported in #2238.
@timbertson Thanks for the report of the incorrect type error explanation! I have created a fix in #2244. |
sjakobi
reviewed
Jul 7, 2021
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.
I like it! :)
timbertson
force-pushed
the
empty-type-message
branch
from
July 7, 2021 11:10
6c20ed4
to
5c6ece7
Compare
sjakobi
added a commit
that referenced
this pull request
Jul 7, 2021
This bug manifested as an incorrect type error explanation: You supplied this expression as one of the arguments: ↳ { x = 1 } ... which is not a record, but is actually a: ↳ Type ──────────────────────────────────────────────────────────────────────────────── 1│ { x = 1 } /\ {} This issue was reported in #2238.
sjakobi
approved these changes
Jul 7, 2021
Gabriella439
approved these changes
Jul 7, 2021
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.
Thank you for doing this! 🙂
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I thought dhall-lang/dhall-lang#1024 would make for a good first use case of context-specific hints next to errors, much like
rustc
. The idea is that if you have a type error involving{}
, and it's a context where{=}
could work, we include a hint in the error output:This hint appears for the following type errors:
({Type = { x: Natural }, default={ x = 1 }})::{}
{} // { x = 1 }
{} /\ { x = 1 }
(\(x: Natural) -> x + 1) {}
The hint is only shown when the erroneous value in question is literally
{}
so it should have a fairly high relevance. In the final example{=}
would also be the wrong type though, so it's not 100%.The only issue I had is when
{}
is on the right hand side of a combine operation, i.e.{ x = 1 } /\ {}
The
--explain
text for this one actually looks incorrect to me, it ends in:My hint shows up when I reverse the operands, so it seems like maybe the code constructing this error is always passing in the left hand side, rather than the expression matching the non-record type.