www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13354] New: Algebraic.opIndex/opIndexAssign makes wrong

https://issues.dlang.org/show_bug.cgi?id=13354

          Issue ID: 13354
           Summary: Algebraic.opIndex/opIndexAssign makes wrong
                    assumptions on the index/value type
           Product: D
           Version: D2
          Hardware: Other
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: sludwig outerproduct.org

Currently both, the index and the value type for VariantN.opIndex(Assign) must 
be allowed!T. This is an unreasonable assumption for Algebraic and examples 
such as the following do not work because of this:

---
alias T = Algebraic!(int[string], int[]);
T v = ["a": 1, "b": 2];
assert(v["a"] == 1); // error
v["a"] = 0; // error
---

--
Aug 22 2014