Closed MrQubo closed 3 years ago
Minimal example:
position token Tok '_' ; Entrypoint . Entrypoint ::= Tok ;
Save this under bug.cf in some temporary directory, run bnfc bug.cf, run runhaskell TestBug.hs. This is the error:
bug.cf
bnfc bug.cf
runhaskell TestBug.hs
AbsBug.hs:18:36: error: Not in scope: type constructor or class ‘String’ | 18 | newtype Tok = Tok ((C.Int, C.Int), String) | ^^^^^^
I've only confirmed this bug with 2.9.1 release (from stackage) and not with master, but after quick look into code it seems like this wasn't fixed.
The cause of this bug is probably that here https://github.com/BNFC/bnfc/blob/94cc0809661ccd415a6e8f525cc56d6443b546c3/source/src/BNFC/Backend/Haskell/CFtoAbstract.hs#L154 hasIdentLike is used, which only includes non-position tokens as described in this comment https://github.com/BNFC/bnfc/blob/94cc0809661ccd415a6e8f525cc56d6443b546c3/source/src/BNFC/CF.hs#L758-L759.
hasIdentLike
Thanks for the report, @MrQubo, I can confirm that this is a regression in 2.9.1.
Minimal example:
Save this under
bug.cf
in some temporary directory, runbnfc bug.cf
, runrunhaskell TestBug.hs
. This is the error:I've only confirmed this bug with 2.9.1 release (from stackage) and not with master, but after quick look into code it seems like this wasn't fixed.
The cause of this bug is probably that here https://github.com/BNFC/bnfc/blob/94cc0809661ccd415a6e8f525cc56d6443b546c3/source/src/BNFC/Backend/Haskell/CFtoAbstract.hs#L154
hasIdentLike
is used, which only includes non-position tokens as described in this comment https://github.com/BNFC/bnfc/blob/94cc0809661ccd415a6e8f525cc56d6443b546c3/source/src/BNFC/CF.hs#L758-L759.