Bug 8111 – [ICE] With templated recursive return-inferred function
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-05-17T02:30:00Z
Last change time
2013-01-16T10:13:07Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2012-05-17T02:30:57Z
Crashes DMD 2.060alpha:
class Foo(T) {
Foo n;
}
auto bar(T)(Foo!T t) pure {
return t ? bar(t.n) : [];
}
void main() {
bar!int(null);
}
Replacing "auto" with "T[]" it compiles.
Maybe it's caused by a forward reference bug.
Removing "pure" it gives:
test.d(5): Error: forward reference to inferred return type of function call bar(t.n)
test.d(8): Error: template instance test.bar!(int) error instantiating
test.d(8): Error: forward reference to bar
Comment #1 by yebblies — 2013-01-16T07:18:24Z
No ice with 2.062
Comment #2 by bearophile_hugs — 2013-01-16T10:13:07Z
Now it gives:
temp.d(5): Error: forward reference to inferred return type of function call bar(t.n)
temp.d(8): Error: template instance temp.bar!(int) error instantiating
temp.d(8): Error: forward reference to bar
Closed.