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()); }
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; }
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.
fixed dmd 1.056 and 2.040
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル