In the following code, I think A, B, C, and D should work, but only A works. If B, C, or D is uncommented, an error is reported during compilation. I'm not sure if this is one or more bugs, but at the moment the CFTE stuff seems to require the called function to take parameters and also to be called from a template. (I'm guessing this has to do with constant folding working differently in different contexts.) Kevin //--------------- char[] one(char[] hi) { return "abc "~hi; } char[] two() { return "xyz"; } struct A(T) { const char[] z = one("x"); } /+ //dmd: interpret.c:96: Expression* //FuncDeclaration::interpret(Expressions*): Assertion `parameters && //parameters->dim == dim' failed. struct B(T) { const char[] z = two(); } +/ /+ // t1.d(28): Error: cannot evaluate (one)("x") at compile time struct C { const char[] z = one("x"); } +/ /+ //t1.d(25): Error: cannot evaluate (two)() at compile time struct D { const char[] z = two(); } +/ int main() { A!(int) a; //B!(int) b; //C c; //D d; return 0; }
Fixed in DMD 1.007
Added to DStress as http://destress.kuehne.cn/run/b/bug_interpret_96_A.d http://destress.kuehne.cn/run/b/bug_interpret_96_B.d http://destress.kuehne.cn/run/b/bug_interpret_96_C.d http://destress.kuehne.cn/run/b/bug_interpret_96_D.d http://destress.kuehne.cn/run/b/bug_interpret_96_E.d
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル