j-mie6 / parsley

A fast and modern parser combinator library for Scala
https://j-mie6.github.io/parsley/
BSD 3-Clause "New" or "Revised" License
173 stars 15 forks source link

[BUG] Behaviour mismatch between optimised and unoptimised `keyword` #192

Closed j-mie6 closed 1 year ago

j-mie6 commented 1 year ago

Description

Seems like there is a small discrepancy with the output of optimised and unoptimised keyword, but the shrinking makes it a little tricky to see what's going on because of that null character.

Reproduction Steps

Trace from scalacheck, though the seed was not reproducible locally, I suspect an ordering issue.

reading keywords should not vary based on optimisations *** FAILED ***
      TestFailedException was thrown during property evaluation.
        Message: Failure("(line 1, column 1):
        unexpected "b"
        expected b
        >b
         ^") was not equal to Failure("(line 1, column 2):
        unexpected end of input
        expected unprintable character (\u0000)
        >b
          ^")
        Location: (SymbolSemanticPreservationSpec.scala:30)
        Occurred when passed generated values (
          name description = NameDesc(Basic(parsley.token.predicate$implicits$Basic$$$Lambda$8194/0x000000010237d040@74b96212),
                                      Unicode(parsley.token.descriptions.DescGen$$$Lambda$8193/0x000000010237c040@21d67279),
                                      Unicode(Set(128579, 36, 163, 128578)), Unicode(Set(42, 43, 97, 47))),
          symbol description = SymbolDesc(Set("if", "a", "key", "bar7", "while", "foo"), Set("ba", "*", "*:*", "::", "**", "+", "***"), false),
          keyword = "b\u0000", // 8 shrinks
          input = "b" // 5 shrinks
        )
      Init Seed: -2377829016531027677

Expected behavior

These should have matched up: the optimised one is the correct one here as far as the message goes, so this may be pointing to a bug somewhere else in the system.

Additional context

Parsley Version: 4.2.11 Scala Version: 2.13.10

It might be work trying to write a shrinker for string that does not inject unprintables, though in this case the unprintable character might be to blame for the error?