Bug 3966 – opUnary("++") doesn't work

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-03-15T10:17:00Z
Last change time
2014-02-15T02:43:57Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2010-03-15T10:17:47Z
According to the specs of the new operator overloading this program is correct, but it currently doesn't compile: struct Foo { int x; Foo opUnary(string op:"++")() { this.x++; return this; } } void main() { Foo f = Foo(5); f++; // line 10 } The compiler gives: test.d(10): Error: var has no effect in expression (__tmp1)
Comment #1 by clugdbug — 2010-06-09T07:57:13Z
*** This issue has been marked as a duplicate of issue 4231 ***