int foo(string s) { enum int[string] aa = ["aa":1, "bb":2]; return aa[s]; } enum _ = foo("xx"); // line 5 void main() {} dmd 2.042 gives: test.d(5): Error: cannot evaluate foo("xx") at compile time test.d(5): Error: cannot evaluate foo("xx") at compile time A much better pair of error messages can be: test.d(3): Error: Range violation. Key "xx" not found in associative array 'aa'. test.d(5): Error: cannot evaluate foo("xx") at compile time. Or just (if the symmetry with the run-time error is not considered important): test.d(3): key "xx" not found in associative array 'aa'. test.d(5): Error: cannot evaluate foo("xx") at compile time.
https://github.com/D-Programming-Language/dmd/commit/0835250480c1458cc868b511da7cd0f757f33029
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル