[Issue 10578] New: Postfix AA increment not considered side-effect

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 8 18:48:29 PDT 2013


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

           Summary: Postfix AA increment not considered side-effect
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: hsteoh at quickfur.ath.cx


--- Comment #0 from hsteoh at quickfur.ath.cx 2013-07-08 18:48:28 PDT ---
CODE:

----SNIP----
import std.stdio;

struct S {
    int x;

    ref S opUnary(string op)() if (op=="++") {
        x++;
        return this;
    }
}

void main() {
    S[int] aa;
    aa[0]++; // this is line 14
    writeln(aa[0]);
}
----SNIP----

DMD git HEAD (88b794d0) output:

test.d(14): Error: var has no effect in expression (__pitmp1583)

Changing aa[0]++ to ++aa[0] makes the problem go away. The error is wrong,
since postfix ++ is a side-effect.

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