Skip to content
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

Error reporting for list element types happens after substitution #230

Closed
ocharles opened this Issue Jan 23, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@ocharles
Copy link
Collaborator

ocharles commented Jan 23, 2018

Apologies for the brevity but let me just vomit out my current context. We have this in a Dhall file:

...
      , library            =
          [   ./dhall/defaults/Library.dhall 
            ⫽ { build-dependencies =
                  [ bounded "base" [ +4, +9, +0, +0 ] [ +5 ]
                  , before "ansi-wl-pprint" [ +0, +7 ]
                  , before "base16-bytestring" [ +0, +2 ]
                  , before "bytestring" [ +0, +11 ]
                  , before "case-insensitive" [ +1, +3 ]
...

build-dependencies goes on for a while

Yet when I type check this:

    Your first ❰List❱ element has this type:                                        
                                                                                    
    ↳ { bounds : VersionRange, package : Text }                                                                
                                                                                    
    ... but the following element at index 18:                          
                                                                                    
    ↳ (λ(package : Text) → λ(min : List Natural) → λ(max : List Natural) → { bounds = intersectVersionRanges (orLaterVersion min) (earlierVersion max), package = package }) "text-format" [+0, +4]                                                                
                                                                                    
    ... has this type instead:                                                      
                                                                                    
    ↳ ∀(max : List Natural) → { bounds : VersionRange, package : Text }                                                                

The 18th element is just some function application though:

                  , bounded "text-format" [ +0, +4 ]
@Gabriel439

This comment has been minimized.

Copy link
Collaborator

Gabriel439 commented Jan 27, 2018

Yeah, the only reason that this line of the error message is displayed at all:

 ↳ (λ(package : Text) → λ(min : List ...

... is because I had not yet improved Dhall's error messages for lists to narrow the source span to the offending list element. What I propose is fixing the source span so that the error message becomes:

    Your first ❰List❱ element has this type:                                        
                                                                                    
    ↳ { bounds : VersionRange, package : Text }                                                                
                                                                                    
    ... but the following element at index 18 has this type instead:                                                      
                                                                                    
    ↳ ∀(max : List Natural) → { bounds : VersionRange, package : Text }  

...

bounded "text-format" [ +0, +4 ]

Would that work for you?

@ocharles

This comment has been minimized.

Copy link
Collaborator Author

ocharles commented Jan 27, 2018

Gabriel439 added a commit that referenced this issue Jan 28, 2018

Improve error messages for list elements with the wrong type
Fixes #230

The type error for the list now returns the expression for the mismatched
element instead of the entire list.  This improves the source span
displayed to the user to focus on the invalid element.

Since the source span now matches the invalid element, there is no need
to redisplay the same element in the detailed error message.

Gabriel439 added a commit that referenced this issue Jan 28, 2018

Improve error messages for list elements with the wrong type (#236)
Fixes #230

The type error for the list now returns the expression for the mismatched
element instead of the entire list.  This improves the source span
displayed to the user to focus on the invalid element.

Since the source span now matches the invalid element, there is no need
to redisplay the same element in the detailed error message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.