These may be duplicates of other reported tuple bugs. Also, it would be awesome if some info about compile-time expansion of foreach on tuples is added to docs (in ForeachStatement section?). Thanks!
All statements in foreach block below should compile for both CTFE and RTFE:
import std.stdio;
template Foo(Strings...)
{
char[] bar()
{
char[] ret;
foreach (s; Strings)
{
static assert(is(typeof(s) : char[])); //RTFE ok. CTFE fails
pragma(msg, typeof(s).stringof); //RTFE ok. CTFE fails
pragma(msg, s); //Error: string expected for message, not 's'
ret ~= s; //RTFE ok. CTFE fails
}
return ret;
}
}
void main(char[][] args)
{
alias Foo!("eeny", "meeny", "miny", "mo") foo;
static s = foo.bar();
writefln(foo.bar());
}
Comment #1 by samukha — 2007-06-29T10:37:05Z
One more bug:
template Foo(Strings...)
{
const a1 = ["one", "two"]; //ok
const a2 = [Strings]; // Error: cannot implicitly convert expression (tuple("one","two")) of type (char[3], char[3]) to char
}
void main(char[][] args)
{
alias Foo!("one", "two") foo;
}
Comment #2 by clugdbug — 2009-08-25T01:18:12Z
The second bug here does not involve CTFE. I've created a new bug (bug #3263)for it. It is completely unrelated to the first bug.
Please don't append new bugs to existing bug reports. It's easy enough to mark bugs as duplicates, but it's really a pain to split them. Especially once people have voted for the bug, as in this case.
This one fails because it requires slice assignment to char[] arrays, which is not yet implemented.