Summary: opUnary!"++" rejects valid, claiming "var has no
                    effect in expression"
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Zach the Mystic <> 2012-02-08 15:40:51 
PST ---
struct Arc {
   int I = 0;
   // This is void, but the error appears under all return types
   void opUnary(string op)() if( op == "++" ) {

struct HasArc {
    Arc myArc;

void main() {
   import std.stdio;
   HasArc has;
   writefln(" Arc.I = %s", has.myArc.I); // Arc.I = 0

   has.myArc++; // Error: var has no effect in expression (__pitmp1481)

   // Okay, try this instead:
   auto UselessVar = has.myArc++; // Works fine

   writefln(" Arc.I = %s", has.myArc.I); // Arc.I = 1

Obviously the expression has an effect. I was informed by Timon Gehr that
"This is indeed a bug. The expression is rewritten internally into (pseudo
(auto __pitmp1481 = has.myArc, has.myArc.opUnary!"++"(), __pitmp1481);

It turns out the work around is so easy, "++has.myArc;". 
Hopefully the bug fix won't be much harder!
Thank you,

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to