[Issue 11795] New: DMD allows nested new operator syntax together with anonymous classes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 21 16:18:19 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11795

           Summary: DMD allows nested new operator syntax together with
                    anonymous classes
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bdom.pub+deebugz at gmail.com


--- Comment #0 from Bruno Medeiros <bdom.pub+deebugz at gmail.com> 2013-12-21 16:18:17 PST ---
It seems DMD syntactically allows the new operator nested class instantiation
syntax together with the anonymous class syntax, like this:

  auto outer = new Outer();
  outer.new class Inner { };

This syntax never makes sense, because an anonymous class instantiation always
defines an outer context by itself (by means of the surrounding scope), so it
cannot have another outer scope (ie, the outer class). Using this syntax will
always result in a semantic error, or some compiler internal error. For example
the following code compiles without semantic errors, but the linker fails:

class Outer {
    int foo;
    auto x = new Outer().new class Inner {};

    class Inner {
    }
}

void main() {
}

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


More information about the Digitalmars-d-bugs mailing list