Skip to content

Cannot use unary method taking 2 operators #13282

Closed
@WojciechMazur

Description

@WojciechMazur

Hey, I've probably found a bug inside parser. This code would work without problems in Scala 2. It's a blocker for allowing to compile Scala Native with Scala 3. If it's not a bug, but expected behaviour we would need to change our syntax for Scala 3 users.

Compiler version 3.0.1

Minimized code

class Ptr[T](var value: T):
   def `unary_!` : T = value
   def `unary_!_=`(value: T): Unit = this.value = value
end Ptr

println(!x)
!x = 10                                                                                          

Output

1 |!x = 10
  |   ^
  |   end of statement expected but '=' found

Expectation

Should not fail, since it works in Scala 2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions