D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8111 - [ICE] With templated recursive return-inferred function
Summary: [ICE] With templated recursive return-inferred function
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2012-05-17 02:30 UTC by bearophile_hugs
Modified: 2013-01-16 10:13 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2012-05-17 02:30:57 UTC
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 yebblies 2013-01-16 07:18:24 UTC
No ice with 2.062
Comment 2 bearophile_hugs 2013-01-16 10:13:07 UTC
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.