Bug 9901 – string return from inner template function error
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-04-07T15:31:00Z
Last change time
2015-06-17T21:03:42Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2013-04-07T15:31:41Z
template isGood(T) {
enum isGood = true;
}
void main() {
string foo(R)(R data) if (isGood!R) {
return "";
}
foo(1);
}
DMD 2.063alpha:
temp.d(5): Error: found 'foo' when expecting ';' following statement
temp.d(5): Error: found 'data' when expecting ')'
temp.d(5): Error: C style cast illegal, use cast(R)R
temp.d(5): Error: found ')' when expecting ';' following statement
While this very similar program compiles with no errors:
template isGood(T) {
enum isGood = true;
}
void main() {
immutable(char)[] foo(R)(R data) if (isGood!R) {
return "";
}
foo(1);
}