D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4012 - [CTFE][ICE] auto template function, forward reference error
Summary: [CTFE][ICE] auto template function, forward reference error
Status: RESOLVED DUPLICATE of issue 3911
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 regression
Assignee: No Owner
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2010-03-26 13:38 UTC by bearophile_hugs
Modified: 2015-06-09 01:27 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 2010-03-26 13:38:27 UTC
Problem found with dmd 2.042. This code works at runtime if you move the enum line inside the main, but as it is crashes the compiler:


struct Searcher(T) {
    T[] data;
    bool opBinaryRight(string Op:"in")(T item) {
        return false;
    }
}
auto searcher(T)(T[] arr) {
    return Searcher!T(arr);
}
enum bool b = 1 in searcher([1]);
void main() {}


Errors printed:
test.d(10): Error: forward reference to inferred return type of function call searcher([1])
test.d(10): Error: rvalue of in expression must be an associative array, not int


(Please add the latest dmd2 version to drop-down menu, I don't know how to do it).
Comment 1 Don 2010-03-26 17:14:45 UTC
This worked in 2.038, failed in 2.040 and later.
Comment 2 Don 2010-03-29 21:05:56 UTC

*** This issue has been marked as a duplicate of issue 3911 ***