[Issue 7458] New: documentation claims non-existent limitation of nested aggregate member functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 7 10:57:54 PST 2012


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

           Summary: documentation claims non-existent limitation of nested
                    aggregate member functions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P2
         Component: websites
        AssignedTo: nobody at puremagic.com
        ReportedBy: timon.gehr at gmx.ch


--- Comment #0 from timon.gehr at gmx.ch 2012-02-07 10:57:52 PST ---
d-programming-language.org/function claims:

Member functions of nested classes and structs do not have access to the stack
variables of the enclosing function, but do have access to the other symbols:

void test() {
  int j;
  static int s;

  struct Foo {
    int a;

    int bar() {
      int c = s;  // ok, s is static
      int d = j;  // error, no access to frame of test()

      int foo() {
        int e = s;    // ok, s is static
        int f = j;    // error, no access to frame of test()
        return c + a; // ok, frame of bar() is accessible,
                      // so are members of Foo accessible via
                      // the 'this' pointer to Foo.bar()
      }

      return 0;
    }
  }
}

However, this is wrong. DMD compiles the code fine.

-- 
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