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

[BUG] hide combinator revives dead hints #30

Closed
HEIGE-PCloud opened this issue Feb 7, 2024 · 3 comments · Fixed by #31
Closed

[BUG] hide combinator revives dead hints #30

HEIGE-PCloud opened this issue Feb 7, 2024 · 3 comments · Fixed by #31
Assignees
Labels
bug Something isn't working

Comments

@HEIGE-PCloud
Copy link

To reproduce, run cabal repl, then

:m +Text.Gigaparsec.Char
:m +Text.Gigaparsec.Token.Descriptions
:m +Text.Gigaparsec.Token.Lexer
lexer' = mkLexer plain
lexeme' = lexeme lexer'
sym' = sym lexeme'
fully' = fully $ mkLexer plain
p2 = many (char '1')
p1 = sym' "[" *> p2 <* sym' "]"
parseRepl (fully' p1) "[11]1"

Observe output

(line 1, column 5):
  unexpected "1"
  expected "1" or end of input
  >[11]1

Expected output should not contain expected "1".

Seems to related to how whiteSpace is handled, after replacing

where apply p = p <* whiteSpace space

with apply = id, the issue disappears.

@j-mie6
Copy link
Owner

j-mie6 commented Feb 7, 2024

Actually, this isn't to do with the lexer at all. It feels reminiscent of j-mie6/parsley#167, which also materialised with whitespace, and also with square brackets. But with an entirely different parsing architecture, that's rather surprising!

I'll take a look shortly and minimise it to something that doesn't involve the lexer

@j-mie6
Copy link
Owner

j-mie6 commented Feb 7, 2024

Ok:

ghci> parseRepl (optional digit <* char ']' <* hide (optional letter) <* eof) "]1"
(line 1, column 2):
  unexpected "1"
  expected digit or end of input
  >]1
    ^

Turns out the hide combinator is the required bit to make this break; thanks!

@j-mie6 j-mie6 changed the title [Bug?] Incorrect "expected" when using "sym" [BUG] hide combinator revives dead hints Feb 7, 2024
@j-mie6 j-mie6 added the bug Something isn't working label Feb 7, 2024
@j-mie6 j-mie6 self-assigned this Feb 7, 2024
@j-mie6
Copy link
Owner

j-mie6 commented Feb 7, 2024

good' x st' = good x st' { Internal.hints = Internal.hints st } -- TODO: should this change valid offset?

I believe the answer is categorically: yes, lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants