[Issue 4757] New: A forward reference error with return of inner defined struct
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 29 10:36:32 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4757
Summary: A forward reference error with return of inner defined
struct
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2010-08-29 10:36:19 PDT ---
This is a problem with a return of inner defined struct, I don't know if this
specific case is already present in Bugzilla. I think others are already
present.
DMD 2.048 compiles and runs this code with no errors:
static struct Bar(T) {
void spam() {
foo(1);
}
}
Bar!T foo(T)(T) {
return Bar!T();
}
void main() {
foo(1);
}
But if I pull the Bar struct inside foo(), using auto as return type:
auto foo(T)(T) {
static struct Bar(T) {
void spam() {
foo(1);
}
}
return Bar!T();
}
void main() {
foo(1);
}
I receive at compile-time:
test.d(4): Error: forward reference to inferred return type of function call
foo(1)
test.d(7): Error: template instance test.foo!(int).foo.Bar!(int) error
instantiating
test.d(10): instantiated from here: foo!(int)
--
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