Skip to content

Add real error messages for associativity errors#3315

Merged
garyb merged 4 commits intopurescript:masterfrom
garyb:3310-associativity-errors
Apr 24, 2018
Merged

Add real error messages for associativity errors#3315
garyb merged 4 commits intopurescript:masterfrom
garyb:3310-associativity-errors

Conversation

@garyb
Copy link
Copy Markdown
Member

@garyb garyb commented Apr 22, 2018

Resolves #3310

The code for generating the errors is kinda absurd as it's more complicated than the actual rebracketing code (since using parsec hides a bunch of that), but whatyagonnado.


import Prelude

feq f x y = f <$> x == f <$> y
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case was a little surprising, but GHC has an error for it too:

Prelude> let f x y = f <$> x == f <$> y

<interactive>:10:13:
    Precedence parsing error
        cannot mix ‘<$>’ [infixl 4] and ‘==’ [infix 4] in the same infix expression

<interactive>:10:13:
    Precedence parsing error
        cannot mix ‘==’ [infix 4] and ‘<$>’ [infixl 4] in the same infix expression


import Prelude

a = true == true == true
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GHC again:

Prelude> True == True == True

<interactive>:11:1:
    Precedence parsing error
        cannot mix ‘==’ [infix 4] and ‘==’ [infix 4] in the same infix expression

@garyb garyb merged commit 3d62184 into purescript:master Apr 24, 2018
@garyb garyb deleted the 3310-associativity-errors branch April 24, 2018 12:59
@hdgarrood
Copy link
Copy Markdown
Contributor

I think we’ll need to update the docs for fixities now - it sounds to me like the docs I wrote might not all still apply, and there might be cases where the examples in the docs now produce these errors.

@garyb
Copy link
Copy Markdown
Member Author

garyb commented Apr 24, 2018

Ah ok, I'll open an issue over there as a reminder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants