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

Add real error messages for associativity errors #3315

Merged
merged 4 commits into from Apr 24, 2018

Conversation

garyb
Copy link
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
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
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
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
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.

None yet

2 participants