Skip to content

Incorrect warning on backticked typed pattern #22989

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

Closed
som-snytt opened this issue Apr 12, 2025 · 0 comments · Fixed by #23088
Closed

Incorrect warning on backticked typed pattern #22989

som-snytt opened this issue Apr 12, 2025 · 0 comments · Fixed by #23088
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug

Comments

@som-snytt
Copy link
Contributor

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.

@som-snytt som-snytt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 12, 2025
@Gedochao Gedochao added area:reporting Error reporting including formatting, implicit suggestions, etc and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants