(This is derived from Issue 8996 ) import std.typecons; Tuple!T foo(T)(T x) { return tuple(x); } void main() { import std.bigint; foo(BigInt(1)); } DMD 2.061alpha gives: ...\dmd2\src\phobos\std\internal\math\biguintcore.d(92): Error: non-constant expression ZERO
Reduced test case shows it is related to the local import. Looks as though semantic isn't being run on the array literal. In the first case, it segfaults because the array literal type is still NULL. ------------------ struct Bug9057(T) { T x; } void test9507() { import thug; Bug9057!(BugInt) xxx; } ------------------ thug.d, case 1. Segfault struct BugInt { uint[] data = [0]; } ------------------ thug.d, case 2: "Non-constant expression ZEROX" struct BugInt { uint[] data = ZEROX; } enum uint [] ZEROX = [0];
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/af2c21b58e357a214da2bc1cf959c322f8ad1cd4 fix issue 9057 - Regression(Beta): Segfault or 'Non-constant expression' error with local import
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/069f570005c1e571f23cd046b0e89503e2553f70 Add workaround for issue 9057, which is equivalent with the before This is not a new workaround. In previous, the forward reference of struct instance fields had been resolved implicitly in `sd->fields[i].getConstInitializer()`, via `sd->fill()`.
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/f1e54366b7650665a820a27069d2f5a17ecae69b Remove workaround for issue 9057 In https://github.com/dlang/dmd/pull/5500, issue 14666 has been properly fixed by adding mechanism of deferred semantic2 running for imported modules. Now, the workaround for issue 9057 in `todt.c` is unnecessary anymore. https://github.com/dlang/dmd/commit/17aab68d6dfd8df39d50a8bd2851dafc820b3049 Merge pull request #5700 from 9rnsr/fix14666 Remove workaround for issue 9057
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/f1e54366b7650665a820a27069d2f5a17ecae69b Remove workaround for issue 9057 https://github.com/dlang/dmd/commit/17aab68d6dfd8df39d50a8bd2851dafc820b3049 Merge pull request #5700 from 9rnsr/fix14666