sirthias / parboiled2

A macro-based PEG parser generator for Scala 2.10+
Other
717 stars 86 forks source link

Error in the "zeroOrMore" documentation #143

Closed anatoliykmetyuk closed 9 years ago

anatoliykmetyuk commented 9 years ago

In the README.rst documentation, section about oneOrMore, it is said in the table that if type of a is Rule[I, O <: I] then type of oneOrMore(a) is Rule[I, O]. This is not true, however, the type of oneOrMore(a) is Rule[I, I].

To check this, compile the following code:

  type A
  type B <: A

  def R1: Rule[A :: HNil, B :: HNil]
  def R2: Rule[A :: HNil, B :: HNil] = rule {zeroOrMore(R1)}

You will get an error:

[error]  type mismatch;
[error]  found   : org.parboiled2.Rule[shapeless.::[A,shapeless.HNil],shapeless.::[A,shapeless.HNil]] with org.parboiled2.Repeated
[error]  required: org.parboiled2.Rule[shapeless.::[A,shapeless.HNil],shapeless.::[B,shapeless.HNil]]
[error]   def R2: Rule[A :: HNil, B :: HNil] = rule {zeroOrMore(R1)}
sirthias commented 9 years ago

Yes, right. Thanks for the report. Would you like to put in a PR with a fix for the README?

anatoliykmetyuk commented 9 years ago

Ok, I did so.