Simple example no longer runs on scala 3.5.1
import fastparse._ object TestFastParse { def parseA[$: P] = P("a")
val Parsed.Success(value, successIndex) = parse("a", parseA(_))
assert(value == (), successIndex == 1) }
. /home/tim/repos/untitled/src/main/scala/TestFastParse.scala:5:56 Context bounds will map to context parameters. A
usingclause is needed to pass explicit arguments to them. This code can be rewritten automatically under -rewrite -source 3.4-migration. val Parsed.Success(value, successIndex) = parse("a", parseA(_))
This can be manually worked around by replacing parse("a", parseA(_)) with parse("a", c => parseA(using c)) since a using keyword now appears to be required.
also applies to 3.6. Tho the error message is now No given instance of type fastparse.ParsingRun[$]
The change I applied is:
parse("a", parseA(using _))
which is easier than creating the lambda explicitly. Also: TIL about using _.
Ow man I was so frustrated to make it work. Thx for this. I can confirm that examples do not work on Scala 3.6.3. But what is the solution I have to write using all the time? Will there be a fix for this?
Ok I have kinda create a wrapper function so I don't need to write those using keywords all the time. If any of you have suggestions but this worked for me:
def parseAlternative[T](input: ParserInputSource,
parser: P[?] ?=> P[T],
verboseFailures: Boolean = false,
startIndex: Int = 0,
instrument: Instrument = null): Parsed[T] = {
parse[T](
input,
parser = v => parser(using v),
verboseFailures,
startIndex,
instrument
)
}
Example code:
def parseA[$: P] = P("a")
val Parsed.Success(value, successIndex) =
parseAlternative("a", parseA)