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

Bug in type of | rule combinator #171

Open
alexander-myltsev opened this issue Oct 12, 2016 · 0 comments
Open

Bug in type of | rule combinator #171

alexander-myltsev opened this issue Oct 12, 2016 · 0 comments

Comments

@alexander-myltsev
Copy link
Contributor

parboiled2 type system should catch errors in a grammar as follows:

class SomeParser extends Parser {
  def test = rule { push("x") ~ (a | b) }
  def a = rule { str("a") ~> { (i: Int) => push("a") } }  
  def b = rule { str("b") ~> { (i: String) => push("b") } }
}

Currently it fails in runtime:

scala> new org.parboiled2.examples.SomeParser("a").test.run()
res0: scala.util.Try[String] = Failure(java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer)

scala> new org.parboiled2.examples.SomeParser("b").test.run()
res1: scala.util.Try[String] = Success(b)

Mail list discussion.

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

No branches or pull requests

1 participant