j-mie6 / gigaparsec

Refreshed parsec-style library for compatibility with Scala parsley
https://j-mie6.github.io/gigaparsec/
BSD 3-Clause "New" or "Revised" License
14 stars 3 forks source link

[Bug-0.2.4.0] Infinite loop when parsing Token #29

Closed HEIGE-PCloud closed 8 months ago

HEIGE-PCloud commented 8 months ago

To reproduce, in cabal repl

:m +Text.Gigaparsec.Token.Lexer
:m +Text.Gigaparsec.Token.Descriptions
myLexer = mkLexer plain
myLexeme = lexeme myLexer
myInteger = integer myLexeme
myDecimal = decimal myInteger
parseRepl myDecimal "1"
j-mie6 commented 8 months ago

Was this present in 0.2.3.0?

HEIGE-PCloud commented 8 months ago

No

j-mie6 commented 8 months ago

Apparently, forcing unsigned numbers in the definition of signed numbers does it... not entirely sure why actually, but easy fix

j-mie6 commented 8 months ago

Ahhhh of course, order of evaluation in the Lexeme constructor... evil

j-mie6 commented 8 months ago

Basically, the internal Lexeme type is fully strict, and had fields mutually defined in terms of each other (in this case, natural nonlexeme was passed to the definition of integer for nonlexeme. I thought Haskell was fine with that because the record was in-construction, but it was only ok because I left that argument to the mkSigned function lazy. I banged it during my work earlier today, and that causes an infinite loop. It's fixed now, will release 0.2.4.1 shortly.

j-mie6 commented 8 months ago

0.2.4.1 has landed on Hackage