[Issue 3966] New: opUnary("++") doesn't work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 15 10:17:48 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3966

           Summary: opUnary("++") doesn't work
           Product: D
           Version: 2.041
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2010-03-15 10:17:47 PDT ---
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)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list