www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6737] New: Make alias to expression an error even if it's not used

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



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: -------
Sep 27 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6737


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
                 CC|                            |yebblies gmail.com
           Platform|Other                       |All
         OS/Version|Windows                     |All
           Severity|enhancement                 |normal



Basically the complement of issue 4206.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 29 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6737


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
           See Also|                            |http://d.puremagic.com/issu
                   |                            |es/show_bug.cgi?id=6842
         Resolution|                            |WONTFIX



14:11:59 PDT ---
I'd prefer this to actually become a valid feature. This is covered by Issue
6842.

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