www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10223] New: Variant[] within Variant[] can be accessed, but not assigned to

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

           Summary: Variant[] within Variant[] can be accessed, but not
                    assigned to
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: wyatt.epp gmail.com


--- Comment #0 from Wyatt <wyatt.epp gmail.com> 2013-05-31 23:06:33 PDT ---
I've spent a lot of time trying to get workarounds that don't suck completely,
but in the end I still expect this should "Just Work".

import std.stdio;
import std.variant;

void main(){
    Variant[] top, bottom;
    top = new Variant[](1);
    bottom = new Variant[](1);

    bottom[0] = "bar";
    top[0] = bottom;
    writeln(top[0][0]); // This works
    top[0][0] = "foo"; // This does not
    writeln(top[0][0]);
}

//Output:
bar
std.variant.VariantException std/variant.d(1231): Variant: attempting to use
incompatible types immutable(char)[] and std.variant.VariantN!(32LU).VariantN
----------------
./variantNest( trusted long
std.variant.VariantN!(32uL).VariantN.handler!(std.variant.VariantN!(32uL).VariantN[]).handler(std.variant.VariantN!(32uL).VariantN.OpID,
ubyte[32]*, void*)+0x4e7) [0x44324f]
./variantNest( trusted std.variant.VariantN!(32uL).VariantN
std.variant.VariantN!(32uL).VariantN.opIndexAssign!(immutable(char)[],
int).opIndexAssign(immutable(char)[], int)+0x10f) [0x447757]
./variantNest(_Dmain+0x245) [0x43b40d]
./variantNest(extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).void runMain()+0x18) [0x44d884]
./variantNest(extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).void tryExec(scope void delegate())+0x2a) [0x44d3b6]
./variantNest(extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).void runAll()+0x40) [0x44d8d4]
./variantNest(extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).void tryExec(scope void delegate())+0x2a) [0x44d3b6]
./variantNest(_d_run_main+0x1ae) [0x44d372]
./variantNest(main+0x17) [0x44d1bf]
/lib64/libc.so.6(__libc_start_main+0xfd) [0x7fad4d2a44bd]
----------------

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