[phobos] Is this a bug?

Sean Kelly sean at invisibleduck.org
Fri Jun 18 16:13:34 PDT 2010


Seems like it is, but I haven't made enough sense of the Variant code to be sure:

    import std.variant;
    import std.typecons;

    struct Val
    {
        Variant v;
        Object  o;
    }

    void set(T...)( T vals )
    {
        alias Tuple!(Val) Wrap;
        Wrap    wrap;
        Variant data;
    
        wrap.field = vals;
        data = wrap;
    
    }

    void main()
    {
        Val val;
        set( val );
    }

$ dmd test
/usr/local/include/d/std/variant.d(509): Error: template std.typecons.Tuple!(Val).Tuple.__ctor(U...) if (U.length == Types.length) does not match any function template declaration
/usr/local/include/d/std/variant.d(509): Error: template std.typecons.Tuple!(Val).Tuple.__ctor(U...) if (U.length == Types.length) cannot deduce template function from argument types !()()
$ 

It's also weird that if I assign a value containing a variant plus more stuff to a variant it seems to think it can hold it.  In my real code (std.concurrency) I test the value size before assigning, but the test passes for some reason.


More information about the phobos mailing list