Bug 11941 – Errors when appending to aggregate member array in CTFE

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-17T14:39:00Z
Last change time
2014-01-22T16:58:25Z
Keywords
CTFE, pull, rejects-valid
Assigned to
nobody
Creator
nilsbossung

Comments

Comment #0 by nilsbossung — 2014-01-17T14:39:42Z
Works with 2.064.2. Fails with v2.065-devel-2b521dd. --- cat > test.d << code alias E = string; void takeConst(const E[]) {} E[] identity(E[] x) {return x;} static assert({ struct S { E[] a; } S s; takeConst(identity(s.a)); version(A) s.a ~= []; else version(B) { s.a ~= "foo"; /* Error refers to this line (15), */ E[] b = s.a[]; /* but only when this is here. */ } return true; }()); code echo A; dmd -c -version=A test.d echo B; dmd -c -version=B test.d --- A test.d(12): Error: Cannot interpret s.a ~= [] at compile time test.d(20): called from here: (*() => true)() test.d(4): while evaluating: static assert((*() => true)()) B test.d(15): Error: array cast from string to string[] is not supported at compile time test.d(20): called from here: (*() => true)() test.d(4): while evaluating: static assert((*() => true)()) ---
Comment #1 by k.hara.pg — 2014-01-18T06:38:08Z
It's a regression caused by fixing bug 11534. https://github.com/D-Programming-Language/dmd/pull/3112
Comment #2 by github-bugzilla — 2014-01-18T07:16:57Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/a8daf6bb9aac4195640bee70ccb071244c0a9473 fix Issue 11941 - Errors when appending to aggregate member array in CTFE https://github.com/D-Programming-Language/dmd/commit/2b7391235d23aee81d049bafd1fe4aa3b1958623 Merge pull request #3112 from 9rnsr/fix11941 [REG2.065a] Issue 11941 - Errors when appending to aggregate member array in CTFE
Comment #3 by github-bugzilla — 2014-01-22T16:58:25Z
Commit pushed to release at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/ee4af52177e64945c107e17ae647ac22f78fd213 Merge pull request #3112 from 9rnsr/fix11941 [REG2.065a] Issue 11941 - Errors when appending to aggregate member array in CTFE