question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot use unary method taking 2 operators

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
nicolasstuckicommented, Aug 16, 2021

Note that x.unary_! = 10 does get desugared to x.unary_!_=(10). We are probably only missing the parser rule for !x = y syntax.

3reactions
som-snyttcommented, Aug 15, 2021

Those are some great pointers.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found