-
Notifications
You must be signed in to change notification settings - Fork 123
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
improvements to source locations for error reporting #1821
base: master
Are you sure you want to change the base?
Conversation
this overrides the provided range to 'recordErrorLoc' if the current range is contained within the given range
retains information about the original number of bind parameters when performing the noPat transformation
needed to add new NamedParams constructor
NamedParams -> PatternParams PatternParams [] -> noParams
Here is the new error output for the example given by #1744:
The first error shows the result of an additional check that the number of parameters to the binding is not greater than the number of arguments implied by the signature, which subsumes the original type error Re-writing
Results in the following error:
In this case we don't report that the number of parameters is unexpected, because the error could also be resolved by changing the body of the function into a lambda. |
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.
All seems plausible, but I've never looked at most of this code before so take it for what it's worth...
let bParams' = case bParams b of | ||
PatternParams _ -> PatternParams pats' | ||
DroppedParams rng i -> DroppedParams rng i |
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'd consider introducing a Rename
instance for BindParams
, as this would allow you to encapsulate the logic of renaming them in that instance.
noParams :: BindParams name | ||
noParams = PatternParams [] | ||
|
||
data BindParams name = |
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.
If I understand, this data type really only exists for the sake of improving error messages. Is that right? If so, it would be worth stating that in a comment.
| TooManyParams Name Type Int Int | ||
-- ^ A binder implies more arguments than | ||
-- its type signature |
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.
Please leave a comment saying what these fields represent. In particular, it's not obvious which Int
is the expected number of arguments, and which Int
is the actual number of arguments.
fix for #1744