-
Notifications
You must be signed in to change notification settings - Fork 85
Open
Labels
Description
There is a bug in (the application of) the TailSwitch
logic, which causes certain parsers to compile when they shouldn't:
class Par extends Parser {
def A: Rule1[Any] = ???
def B: PopRule[Int :: HNil] = ???
def C = rule { A ~ B }
}
The problem appears only when the 2nd rule consumes all of the 1st rule's output.
This parser for example correctly doesn't compile:
class Par extends Parser {
def A: Rule2[String, Any] = ???
def B: PopRule[Int :: HNil] = ???
def C: Rule1[String] = rule { A ~ B }
}
I think the reason for this issue is that we currently use two TailSwitch
type logic application for computing the output of the ~
operator, whereby no distinction is made between the application for a contravariant type parameter (the first) and the application for a covariant type parameter (the second).