Navigation Menu

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

Missing String import with position tokens in Haskell backend #368

Closed
MrQubo opened this issue May 20, 2021 · 1 comment
Closed

Missing String import with position tokens in Haskell backend #368

MrQubo opened this issue May 20, 2021 · 1 comment
Assignees
Labels
AST Concerning the generated abstract syntax bug Haskell regression in 2.9.1
Milestone

Comments

@MrQubo
Copy link

MrQubo commented May 20, 2021

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:

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

|| hasIdentLike && tokenText == StringToken && s == "String")
hasIdentLike is used, which only includes non-position tokens as described in this comment

bnfc/source/src/BNFC/CF.hs

Lines 758 to 759 in 94cc080

-- Excludes position tokens.
hasIdentLikeTokens :: CFG g -> Bool
.

@andreasabel
Copy link
Member

Thanks for the report, @MrQubo, I can confirm that this is a regression in 2.9.1.

@andreasabel andreasabel added the AST Concerning the generated abstract syntax label May 22, 2021
andreasabel added a commit that referenced this issue Jun 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AST Concerning the generated abstract syntax bug Haskell regression in 2.9.1
Projects
None yet
Development

No branches or pull requests

2 participants