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

Faulty operator precedence parsing in haskell #341

Open
julian-berbel opened this issue Dec 15, 2021 · 1 comment
Open

Faulty operator precedence parsing in haskell #341

julian-berbel opened this issue Dec 15, 2021 · 1 comment

Comments

@julian-berbel
Copy link
Member

The following piece of code:

foo = (even $ 5) || False

(valid)

Gets parsed to the same ast as:

foo = even $ 5 || False

(type error)

@julian-berbel
Copy link
Member Author

julian-berbel commented Dec 15, 2021

This doesn't seem like an easy fix; the haskell parser is parsing the previous two pieces of code to this:

HsInfixApp 
  (HsParen (HsInfixApp (HsVar (UnQual (HsIdent "even"))) (HsQVarOp (UnQual (HsSymbol "$"))) (HsLit (HsInt 5))))
  (HsQVarOp (UnQual (HsSymbol "||")))
  (HsCon (UnQual (HsIdent "False")))

HsInfixApp 
  (HsInfixApp (HsVar (UnQual (HsIdent "even"))) (HsQVarOp (UnQual (HsSymbol "$"))) (HsLit (HsInt 5)))
  (HsQVarOp (UnQual (HsSymbol "||")))
  (HsCon (UnQual (HsIdent "False")))

The resulting tree hierarchy does not to reflect the operator precedence, it seems that is accounted for at a later stage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant