digitalmars.D.bugs - [Issue 4556] New: Misbehaving nested function
- d-bugmail puremagic.com (46/46) Aug 01 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4556
- d-bugmail puremagic.com (28/28) Aug 01 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4556
- d-bugmail puremagic.com (14/14) May 19 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4556
- d-bugmail puremagic.com (11/11) Jan 04 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4556
- d-bugmail puremagic.com (10/10) Apr 14 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4556
- d-bugmail puremagic.com (9/9) Apr 19 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4556
http://d.puremagic.com/issues/show_bug.cgi?id=4556 Summary: Misbehaving nested function Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: andrej.mitrovich gmail.com 14:12:59 PDT --- This is the 4th example from the title "Nested Classes" on the page http://www.digitalmars.com/d/2.0/class.html : import std.stdio; class Base { int foo() { return 1; } } Base func() { int m = 3; class Nested : Base { int foo() { return m; } } Base b = new Nested; assert(b.foo() == 3); // Ok, func() is still active return b; } int test() { Base b = func(); return b.foo(); // Error, func().m is undefined } void main() { writeln(test()); // writes 3, there was no error } According to the docs, this should not compile. This looks to me like some kind of automatic closure where foo() becomes a delegate? I'm not sure.. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 01 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4556 14:46:50 PDT --- See also the 8th example under "Nested Functions" on this page http://www.digitalmars.com/d/2.0/function.html. Pasted here: 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; } } } This compiles without errors. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 01 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4556 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|rejects-valid | 22:00:38 PDT --- This was not a rejects-valid. The compiler doesn't reject, it accepts the two code snippets. But I think they're both correct. I've seen code similar to this in TDPL. The compiler does all the work of creating delegates when needed, right? So the docs should be updated to reflect that. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 19 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4556 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Misbehaving nested function |Wrong docs for nested | |functions 07:47:14 PST --- It's the docs that are outdated, changing title and will make a pull shortly. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 04 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4556 Commit pushed to master at https://github.com/D-Programming-Language/d-programming-language.org https://github.com/D-Programming-Language/d-programming-language.org/commit/53476f012be1641d5df7ab35d7420bad065ec00a Fix issue 4556 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 14 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4556 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 19 2012