Open scabug opened 10 years ago
Imported From: https://issues.scala-lang.org/browse/SI-8080?orig=1 Reporter: David Carlton (davidcarltonsumo) Affected Versions: 2.10.2
I started getting the similar error just after updating to Scala 3 and scala-parser-combinators 1.2.0-M2. - My (working for me) local fix is https://github.com/ilya-klyuchnikov/tapl-scala/pull/10/commits/8045d83aa05e5822559a00aebbbc00b3a69bc024
We have a parser that inherits from both
JavaTokenParsers
andPackratParsers
; and it turns out that the.parse()
method that the former provides (viaRegexParsers
) is incompatible with the latter. And, to make matters worse, that incompatibility only shows up very rarely; I'm filing this bug so that at least there will be some google hit out there if somebody else runs into this error.Basically, the situation is this: I'm calling
And, depending on the details of what I'm trying to parse and what the input is, I'll occasionally get this:
The problem is that
RegexParsersers.parse(Parser, CharSequence)
constructs aCharSequenceReader
, whilePackratParsers
assumes that it's passed aPackratReader
. (But it doesn't actually use that assumption much of the time.)It's easy to work around once you know the problem: wrap it like this:
And quite possibly it's the case that we shouldn't inherit from
PackratParsers
at all, I'm honestly not sure why we are. Still, it seems a little unfortunate thatPackratParsers
has a type restriction that is documented in the Scaladoc but not enforced in the underlying code.