[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
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat May 7 00:15:00 PDT 2011
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 at puremagic.com
ReportedBy: kennytm at gmail.com
--- Comment #0 from kennytm at 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: -------
More information about the Digitalmars-d-bugs
mailing list