www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21069] New: Variant.get!Variant segfault


          Issue ID: 21069
           Summary: Variant.get!Variant segfault
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: schveiguy yahoo.com

By accident, I tried to get a Variant out of a Variant.

The result is a segfault.

Variant v = 1;
auto y = v.get!Variant; // segfault

I don't think this should segfault. I don't know what the code is doing. There
are two options to fix this:

1. get!Variant should be statically disallowed.
2. Preferred: get!Variant should `return this;`.

The second option allows generic code to not have to care about whether the
type requested is gettable. i.e. I don't have to write:

static if(is(T == Variant)) return v;
else return v.get!T;

Jul 23 2020