Details

      Description

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

        Issue Links

          Activity

          Hide
          A. P. Marki added a comment -

          The patch forthcame at
          https://github.com/scala/scala/pull/444

          The patch tries to honor the history of the code, e.g., SI-3480, SI-1764, SI-1878 and the proximate SI-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).

          Show
          A. P. Marki added a comment - The patch forthcame at https://github.com/scala/scala/pull/444 The patch tries to honor the history of the code, e.g., SI-3480 , SI-1764 , SI-1878 and the proximate SI-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).
          Hide
          A. P. Marki added a comment -

          9d925a30c73ee5856c83d3caab124f7dbeaa85a8

          Show
          A. P. Marki added a comment - 9d925a30c73ee5856c83d3caab124f7dbeaa85a8

            People

            • Assignee:
              A. P. Marki
              Reporter:
              A. P. Marki
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development