Bug 4012 – [CTFE][ICE] auto template function, forward reference error
Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-03-26T13:38:00Z
Last change time
2015-06-09T01:27:40Z
Keywords
ice-on-invalid-code
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2010-03-26T13:38:27Z
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 by clugdbug — 2010-03-26T17:14:45Z
This worked in 2.038, failed in 2.040 and later.
Comment #2 by clugdbug — 2010-03-29T21:05:56Z
*** This issue has been marked as a duplicate of issue 3911 ***