www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18545] New: Casting away const with cast() triggers alias


          Issue ID: 18545
           Summary: Casting away const with cast() triggers alias this,
                    but returns the supertype anyway
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

const Nullable!string a;

Nullable!string b = a; /* This works. */

Nullable!string c = cast() a; /* This asserts in get. */

// Alright, so I guess cast() mistakenly follows the alias this?

// No!

static assert(is(typeof(cast() a) == Nullable!string));

// It follows the alias get this in Nullable, but it returns a Nullable anyway.

// Why!!

Mar 01 2018