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

Pattern parser halts on star #5702

Closed
scabug opened this issue Apr 24, 2012 · 3 comments
Closed

Pattern parser halts on star #5702

scabug opened this issue Apr 24, 2012 · 3 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Apr 24, 2012

The pattern parser halts when it sees stars. This means it does not handle infix notation for a case class named "*". (This is an edgy use case.)

Also, the error reporting around syntax errors could be improved, both to provide helpful hints and for recovery, to report subsequent errors.

This is related to #3189, which no longer crashes, but doesn't yet report nicely.

object Test {
  case class *(a: Int, b: Int)
  type Star = *
  case class P(a: Int, b: Star) // alias still required

  def main(args: Array[String]) {
    val v = new *(6,7)
    val x * y = v   // OK, where sequence pattern not allowed
    printf("%d,%d\n",x,y)
    val p = P(5, v)
    val P(a, b * c) = p  // error
    printf("%d,%d,%d\n",a,b,c)
  }
}

Sample improved message:

t3189.scala:2: error: use _* to match a sequence
  val Array(a,b*) = ("": Any)
                ^
one error found

A patch is forthcoming.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Apr 24, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5702?orig=1
Reporter: @som-snytt
Affected Versions: 2.10.0
Other Milestones: 2.10.0-M3

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Apr 26, 2012

@som-snytt said:
The patch forthcame at
scala/scala#444

The patch tries to honor the history of the code, e.g., #3480, #1764, #1878 and the proximate #3189, by not being too ambitious. As usual, this was a GLE (great learning experience) and hopefully the tests provide adequate coverage (as in cover me).

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Apr 28, 2012

@som-snytt said:
9d925a30c73ee5856c83d3caab124f7dbeaa85a8

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.