Cannot use unary method taking 2 operators
See original GitHub issueHey, 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
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
c++ - Why cannot I define a unary operator and then declare a ...
I have found some useful information data here. The problem is that the member operator unary minus hides the global binary subtract.
Read more >How To Use JavaScript Unary Operators | DigitalOcean
A unary operation is an operation with only one operand. This operand comes either before or after the operator. Unary operators are more ......
Read more >No warning when using unary +/- operators on functions and ...
This issue is asking whether people really use unary + or - on non- string and non- number operands in practice enough to...
Read more >Operator overloading - Define unary, arithmetic, equality, and ...
A unary operator has one input parameter. A binary operator has two input parameters. In each case, at least one parameter must have...
Read more >SyntaxError: unparenthesized unary expression can't appear ...
The JavaScript exception "unparenthesized unary expression can't appear on the left-hand side of '**'" occurs when a unary operator (one of ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Note that
x.unary_! = 10
does get desugared tox.unary_!_=(10)
. We are probably only missing the parser rule for!x = y
syntax.Those are some great pointers.