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

           Summary: How about to disable ++, --, and assignments to
                    non-lvalues?
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: verylonglogin....@gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin....@gmail.com> 2012-10-30 
18:47:15 MSK ---
Disabling ++, -- and assignments to non-lvalues (opAssign, opOpAssign,
opIndexAssign, opIndexOpAssign, opSliceAssign, opSliceOpAssign) will allow to
define user types with same semantics as build-in types (arithmetic and static
arrays):

---
struct S
{
    void opUnary(string op : "++")() { }
    void opAssign(int) { }
}

int iFunc() { return 0;   }
int[1] sarrFunc() { return [0];   }
S   sFunc() { return S(); }

void main()
{
    ++int.init;  // Error: constant 0 is not an lvalue
    ++iFunc();   // Error: iFunc() is not an lvalue

    ++(int[1]).init;  // Error: [0] is not an lvalue
    ++sarrFunc();     // Error: sarrFunc() is not an lvalue

    // currently compiles, but shouldn't:
    ++S.init;
    ++sFunc();

    S.init = 3;
    sFunc() = 3;
}
---

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

Reply via email to