Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contravariance in first Rule type param not always honored #172

Open
sirthias opened this issue Oct 13, 2016 · 0 comments
Open

Contravariance in first Rule type param not always honored #172

sirthias opened this issue Oct 13, 2016 · 0 comments
Labels

Comments

@sirthias
Copy link
Owner

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant