www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19533] New: "alias this" prevents "cast(void*)"


          Issue ID: 19533
           Summary: "alias this" prevents "cast(void*)"
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P3
         Component: dlang.org
          Assignee: nobody puremagic.com
          Reporter: porton narod.ru

The following program does not compile. I assume it should compile.

struct BNode { }

class UserObject {
    BNode record;
    alias record this;
    void* context() { return cast(void*)this; }

$ dlang.dmd -c test.d
test.d(5): Error: cannot cast expression this.record of type BNode to void*
$ dlang.dmd --version
DMD64 D Compiler v2.083.1

Dec 31 2018