Bug 9057 – Regression(Beta): Segfault or "Non-constant expression" error with local import

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-11-22T14:20:00Z
Last change time
2016-10-01T11:46:27Z
Keywords
ice, rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-11-22T14:20:52Z
(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
Comment #1 by clugdbug — 2012-11-28T00:42:42Z
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];
Comment #2 by github-bugzilla — 2012-12-10T03:56:00Z
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
Comment #3 by github-bugzilla — 2015-09-13T08:35:47Z
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()`.
Comment #4 by github-bugzilla — 2016-04-26T04:54:47Z
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
Comment #5 by github-bugzilla — 2016-10-01T11:46:27Z