[Issue 15791] New: Cannot get a stored nested struct object from Variant
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Mar 12 02:44:50 PST 2016
https://issues.dlang.org/show_bug.cgi?id=15791
Issue ID: 15791
Summary: Cannot get a stored nested struct object from Variant
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: k.hara.pg at gmail.com
Following test case fails to compile.
void main()
{
import std.variant;
int n = 3;
struct NS1 { int foo() { return n + 10; } }
struct NS2 { int foo() { return n * 10; } }
Variant v;
v = NS1();
assert(v.get!NS1.foo() == 13); // Line 11
v = NS2();
assert(v.get!NS2.foo() == 30); // Line 13
}
$ dmd -o- test
DMD v2.070 DEBUG
phobos\std\variant.d(755): Error: cannot access frame pointer of test.main.NS1
test.d(11): Error: template instance
std.variant.VariantN!20u.VariantN.get!(NS1) error instantiating
phobos\std\variant.d(755): Error: cannot access frame pointer of test.main.NS2
test.d(13): Error: template instance
std.variant.VariantN!20u.VariantN.get!(NS2) error instantiating
--
More information about the Digitalmars-d-bugs
mailing list