Skip to content

Incorrect warning on backticked typed pattern #22989

Closed
@som-snytt

Description

@som-snytt

Compiler version

3.7

Minimized code

Per pos/i15784.scala

case `type` : Int => `type`

is not a stable identifier pattern. The variable id happens to be backquoted as required for a keyword.

Output

8 |  case `type` : Int => `type`
  |              ^
  |Type ascriptions after patterns other than:
  |  * variable pattern, e.g. `case x: String =>`
  |  * number literal pattern, e.g. `case 10.5: Double =>`
  |are no longer supported. Remove the type ascription or move it to a separate variable pattern.

It looks like the screws were tightened during a round of syntax torquing. Apparently, the bit to the left of the colon was once taken as a pattern.

Expectation

No warning about good syntax.

The corresponding test on Scala 2 is t8044.scala.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:reportingError reporting including formatting, implicit suggestions, etcitype:bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions