D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3966 - opUnary("++") doesn't work
Summary: opUnary("++") doesn't work
Status: RESOLVED DUPLICATE of issue 4231
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2010-03-15 10:17 UTC by bearophile_hugs
Modified: 2014-02-15 02:43 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2010-03-15 10:17:47 UTC
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 Don 2010-06-09 07:57:13 UTC

*** This issue has been marked as a duplicate of issue 4231 ***