Skip to content

Commit bff8c57

Browse files
Fix ty var parsing on class head (purescript#4523)
* Fix ty var parsing on class head
1 parent a915253 commit bff8c57

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Fix parsing bug where `@var` was allowed in type class head

src/Language/PureScript/CST/Parser.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ classSuper :: { (OneOrDelimited (Constraint ()), SourceToken) }
722722
: constraints '<=' {%^ revert $ pure ($1, $2) }
723723
724724
classNameAndFundeps :: { (Name (N.ProperName 'N.ClassName), [TypeVarBinding ()], Maybe (SourceToken, Separated ClassFundep)) }
725-
: properName manyOrEmpty(typeVarBinding) fundeps {%^ revert $ pure (getProperName $1, $2, $3) }
725+
: properName manyOrEmpty(typeVarBindingPlain) fundeps {%^ revert $ pure (getProperName $1, $2, $3) }
726726

727727
fundeps :: { Maybe (SourceToken, Separated ClassFundep) }
728728
: {- empty -} { Nothing }

tests/purs/failing/4522.out

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Error found:
2+
at tests/purs/failing/4522.purs:4:11 - 4:12 (line 4, column 11 - line 4, column 12)
3+
4+
Unable to parse module:
5+
Unexpected token '@'
6+
7+
8+
See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
9+
or to contribute content related to this error.
10+

tests/purs/failing/4522.purs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- @shouldFailWith ErrorParsingModule
2+
module Main where
3+
4+
class Foo @a

0 commit comments

Comments
 (0)