Bug 15791 – Cannot get a stored nested struct object from Variant

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-03-12T10:44:00Z
Last change time
2016-03-20T12:58:36Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2016-03-12T10:44:50Z
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
Comment #1 by k.hara.pg — 2016-03-12T10:48:22Z
Comment #2 by github-bugzilla — 2016-03-20T12:58:35Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/22c8065ffdf599f5dcf760d984dc5c309016d46f fix Issue 15791 - Cannot get a stored nested struct object from Variant https://github.com/D-Programming-Language/phobos/commit/7ebdd9354b4ebf723cfb9b86401ead0783c5d003 Merge pull request #4074 from 9rnsr/fix15791 Issue 15791 - Cannot get a stored nested struct object from Variant