www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15827] New: std.variant.Variant can not be initialized with

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

          Issue ID: 15827
           Summary: std.variant.Variant can not be initialized with some
                    struct
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: maximzms gmail.com

Test:
--------------------
import std.variant;

struct Foo
{
    Variant v;
    this(Foo v) {}
}

void main()
{
    Variant v = Foo.init;
}
--------------------

Output:
--------------------
../import/std/variant.d(571): Error: variable
std.variant.VariantN!32LU.VariantN.opAssign!(Foo).opAssign.rhs has scoped
destruction, cannot build closure
--------------------

The error message is referring to line [std.variant:571] but is triggered by
line [std.variant:615].
Foo must have both member of type Variant and constructor accepting Foo in
order to produce the error.

It seems to be related to Issue 5730.

[std.variant:571]:
https://github.com/D-Programming-Language/phobos/blob/708c5d8e6ddd9245f793e4b8761382672225f271/std/variant.d#L571
[std.variant:615]:
https://github.com/D-Programming-Language/phobos/blob/708c5d8e6ddd9245f793e4b8761382672225f271/std/variant.d#L615
[Issue 5730]: https://issues.dlang.org/show_bug.cgi?id=5730

--
Mar 24 2016