Bug 1713 – foreach index with tuples and templates fails
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2007-12-03T12:58:00Z
Last change time
2015-06-09T01:14:23Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
dhasenan
Comments
Comment #0 by dhasenan — 2007-12-03T12:58:57Z
---
import std.stdio;
import std.traits;
import std.metastrings;
void main () {
pragma(msg, Multi!(Object, "toString")());
}
string Multi (T, string name) () {
foreach (i, method; __traits(getVirtualFunctions, T, name)) {
alias typeof(method) func;
// SingleMethod fails....
Single!(i)();
// but Foo succeeds
Foo!(ParameterTypeTuple!(func))();
}
return ``;
}
string Single (int idx)() { return ``; }
string Foo (U...) () { return ``; }
---
The error message given is:
Error: cannot evaluate Single() at compile time
Obviously the index is a compile-time constant, or I couldn't use it as a template parameter. And the function without the template works, and giving a literal constant works. So I don't know what's going on.