www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10578] New: Postfix AA increment not considered side-effect


           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 puremagic.com
        ReportedBy: hsteoh quickfur.ath.cx

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

import std.stdio;

struct S {
    int x;

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

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

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: -------
Jul 08 2013