Skip to content

Commit

Permalink
Fix ty var parsing on class head (#4523)
Browse files Browse the repository at this point in the history
* Fix ty var parsing on class head
  • Loading branch information
JordanMartinez committed Dec 14, 2023
1 parent a915253 commit bff8c57
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.d/fix_fix-class-head-ty-var.md
@@ -0,0 +1 @@
* Fix parsing bug where `@var` was allowed in type class head
2 changes: 1 addition & 1 deletion src/Language/PureScript/CST/Parser.y
Expand Up @@ -722,7 +722,7 @@ classSuper :: { (OneOrDelimited (Constraint ()), SourceToken) }
: constraints '<=' {%^ revert $ pure ($1, $2) }
classNameAndFundeps :: { (Name (N.ProperName 'N.ClassName), [TypeVarBinding ()], Maybe (SourceToken, Separated ClassFundep)) }
: properName manyOrEmpty(typeVarBinding) fundeps {%^ revert $ pure (getProperName $1, $2, $3) }
: properName manyOrEmpty(typeVarBindingPlain) fundeps {%^ revert $ pure (getProperName $1, $2, $3) }

fundeps :: { Maybe (SourceToken, Separated ClassFundep) }
: {- empty -} { Nothing }
Expand Down
10 changes: 10 additions & 0 deletions tests/purs/failing/4522.out
@@ -0,0 +1,10 @@
Error found:
at tests/purs/failing/4522.purs:4:11 - 4:12 (line 4, column 11 - line 4, column 12)

Unable to parse module:
Unexpected token '@'


See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
or to contribute content related to this error.

4 changes: 4 additions & 0 deletions tests/purs/failing/4522.purs
@@ -0,0 +1,4 @@
-- @shouldFailWith ErrorParsingModule
module Main where

class Foo @a

0 comments on commit bff8c57

Please sign in to comment.