www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15209] New: redundant error message on invalid field access

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

          Issue ID: 15209
           Summary: redundant error message on invalid field access
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: k.hara.pg gmail.com

Test case:
----
class C1 { int x; }
struct S1 { alias y = C1.x; }

struct S2 { int x; }
class C2 { alias y = S2.x; }

void main()
{
    S1 s1;
    s1.y = 10;  // Line 10: invalid field variable access

    auto c2 = new C2();
    c2.y = 10;  // Line 13: invalid field variable access
}

Output:
----
test.d(10): Error: struct test.S1 'x' is not a member
test.d(10): Error: need 'this' for 'x' of type 'int'
test.d(13): Error: need 'this' for 'x' of type 'int'

The error "is not a member" at line 10 is redundant.

--
Oct 15 2015