www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17684] New: `static alias this` bug or incomplete

https://issues.dlang.org/show_bug.cgi?id=17684

          Issue ID: 17684
           Summary: `static alias this` bug or incomplete implementation?
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: slavo5150 yahoo.com

Consider the following code:

import std.stdio;

struct StaticStruct
{
    static int X;
    static alias X this;
}

struct InstanceStruct
{
    int X;
    alias X this;
}

void main()
{
    StaticStruct = 5;     // Exhibit A: No Error
    int V = StaticStruct; // Exhibit B: Error: type StaticStruct has no value

    InstanceStruct s;
    s = 5;
    int v = s;
}

`static alias this` does not work in the same manner as `alias this`, only with
static members.

If you believe `static alias this` is not a valid feature, then Exhibit A
should not compile.

If you believe `static alias this` is a valid feature, then Exhibit B should
compile and work.

Either way it's a bug.

--
Jul 25