Skip to content

Allow backticks in variables defined through pattern matching #8044

Closed
@scabug

Description

@scabug
scala> trait HasType{ var `type`: String }
defined trait HasType

Would be nice if that compiled:

scala> new HasType{ var Some(`type`) = Some("foo") }
<console>:10: error: stable identifier required, but $anon.this.`type` found.
              new HasType{ var Some(`type`) = Some("foo") }
                                    ^

Workaround:

scala> new HasType{ var Some(t) = Some("foo"); var `type`= t }
res7: HasType{def t: String; def t_=(x$1: String): Unit} = $anon$1@38c60a18

I am programmatically generating Scala code, so the workaround means a corner case in the code generator.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions