[Issue 6737] New: Make alias to expression an error even if it's not used

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Sep 27 17:19:40 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6737

           Summary: Make alias to expression an error even if it's not
                    used
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2011-09-27 17:19:05 PDT ---
This will rightly not compile:

struct Foo { int x; }
struct Bar
{
    Foo foo;
    alias foo.x x;
}

void main()
{
    Bar bar;
    bar.x = 5;
}

However, if you comment out the "bar.x = 5" line you won't get a compile error.
My main problem with this is that I could easily create an invalid alias by
accident (due to generic programming) and I won't spot this until I try using
an aliased field later down the road. By then I'll end up getting compilation
errors which are hard to figure out (due to e.g. multiple aliasing). And yes,
that has just happened to me. :)

So I'd like this to be a compilation error regardless if that alias is used or
not by client code. As far as I know expression aliases are illegal, unless
that changes it would be great if this was enforced right away.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list