Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
May 07, 2011 [Issue 5941] New: Using inner struct which references nested function in a no-attribute or auto-return member function causes "nested function cannot be accessed" error | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5941 Summary: Using inner struct which references nested function in a no-attribute or auto-return member function causes "nested function cannot be accessed" error Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: kennytm@gmail.com --- Comment #0 from kennytm@gmail.com 2011-05-07 00:11:05 PDT --- May or may not be the same as issue 5939. Happens at least since 2.042. Test case: ----------------------------------------------------------------- auto f() { static int h(int x) pure nothrow @safe { return x*x*x-x*x; } struct S { int get() { return h(8); } } return S.init; } void main() { typeof(f()) z; assert(z.get == 448); assert(z.get == 448); } ----------------------------------------------------------------- x.d(11): Error: function x.f is a nested function and cannot be accessed from main ----------------------------------------------------------------- The bug will appear only when the 'get' function - is an auto-return function (e.g. '@property auto get()') - or has no attributes at all (e.g. 'int get()') The bug is gone when you supply at least one attribute to 'get', e.g. '@safe int get()'. I don't know if it is a reject-valid or accept-invalid. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 07, 2011 [Issue 5941] Using inner struct which references nested function in a no-attribute or auto-return member function causes "nested function cannot be accessed" error | ||||
---|---|---|---|---|
| ||||
Posted in reply to kennytm@gmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=5941 --- Comment #1 from kennytm@gmail.com 2011-05-07 00:27:39 PDT --- A slight variant is when 'f' is a template function taking a delegate literal as input, it will generate an ICE: --------------------------------- auto f(alias T)() { static void h(){} struct S { void get() { h(); } } return S(); } void main() { typeof(f!((){})()) z; } --------------------------------- Internal error: backend/cgcs.c 363 --------------------------------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 21, 2011 [Issue 5941] Using inner struct which references nested function in a no-attribute or auto-return member function causes "nested function cannot be accessed" error | ||||
---|---|---|---|---|
| ||||
Posted in reply to kennytm@gmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=5941 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug@yahoo.com.au --- Comment #2 from Don <clugdbug@yahoo.com.au> 2011-12-21 14:35:39 PST --- Reduced test case suggests it's related to typeof(): auto fx() { struct S { void get() {} } return S.init; } void main() { //auto w = fx(); // OK typeof(fx()) z; // fails! } Again, adding any attributes to get() removes the bug -- even though get() is never used. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 22, 2011 [Issue 5941] Using inner struct which references nested function in a no-attribute or auto-return member function causes "nested function cannot be accessed" error | ||||
---|---|---|---|---|
| ||||
Posted in reply to kennytm@gmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=5941 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid --- Comment #3 from Don <clugdbug@yahoo.com.au> 2011-12-21 23:30:26 PST --- In bug 5939, Walter explicitly stated that the test case is comment 2 is not a bug. However, the fact that it compiles if the function 'get' is removed, or if attributes are added to get(), is surely a bug. Based on Walter's comment, it should never compile. So I'm marking as accepts-invalid. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 19, 2012 [Issue 5941] Using inner struct which references nested function in a no-attribute or auto-return member function causes "nested function cannot be accessed" error | ||||
---|---|---|---|---|
| ||||
Posted in reply to kennytm@gmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=5941 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yebblies@gmail.com --- Comment #4 from yebblies <yebblies@gmail.com> 2012-01-19 14:04:52 EST --- In case anyone's wondering about why adding attributes changes anything, the compiler does a scan of all the top level members in a nested struct to determine if it contains any functions, and makes it a static struct otherwise. This is unfortunately done badly/too early and it finds AttributeDeclarations containing functions but doesn't investigate further. Given that, it sounds like the requirement for having no attributes is really just a requirement for a non-static nested struct. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 04, 2013 [Issue 5941] Using inner struct which references nested function in a no-attribute or auto-return member function causes "nested function cannot be accessed" error | ||||
---|---|---|---|---|
| ||||
Posted in reply to kennytm@gmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=5941 Maksim Zholudev <maximzms@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |maximzms@gmail.com --- Comment #5 from Maksim Zholudev <maximzms@gmail.com> 2013-03-04 09:20:24 PST --- Linux, 64-bit DMD from Git head https://github.com/D-Programming-Language/dmd/commit/13b3bdbf3819fec810ebfb077957510612dfa815 0. Compiling code from the description (http://d.puremagic.com/issues/show_bug.cgi?id=5941#c0): -------------------- test.d(11): Error: cannot access frame pointer of test.f.S -------------------- 1. Compiling code from comment 1 (http://d.puremagic.com/issues/show_bug.cgi?id=5941#c1): -------------------- test.d(11): Error: cannot access frame pointer of test.f!(function void() { } ).f.S -------------------- 2. Compiling code from comment 2 (http://d.puremagic.com/issues/show_bug.cgi?id=5941#c1): -------------------- test.d(9): Error: cannot access frame pointer of test.fx.S -------------------- Is this behavior correct? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation