[Issue 2641] New: std.variant Variant's check for "can append" is wrong

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 1 18:44:50 PST 2009


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

           Summary: std.variant Variant's check for "can append" is wrong
           Product: D
           Version: 2.023
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: wbaxter at gmail.com


The code below used in std.variant seems to be assuming that if a type can be
indexed, then it can also be appended to:
-----
        case OpID.catAssign:
            auto me = cast(A*) pStore;
            static if (is(typeof((*me)[0])) && !is(typeof(me.keys)))
            {
                // array type; parm is the element to append
                auto arg = cast(VariantN*) parm;
                alias typeof((*me)[0]) E;
                if (arg[0].convertsTo!(E))
                {
                    // append one element to the array
                    (*me) ~= [ arg[0].get!(E) ];
                }
                else
                {
                    // append a whole array to the array
                    (*me) ~= arg[0].get!(A);
                }
---

This causes it to fail when trying to use a fixed-length struct, like a fixed
vec3 that provides an opIndex but no opCatAssign.


-- 



More information about the Digitalmars-d-bugs mailing list