Bug 12528 – [CTFE] cannot append elements from one inout array to another inout array

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-06T08:33:00Z
Last change time
2014-04-07T03:18:31Z
Keywords
CTFE, pull, rejects-valid
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2014-04-06T08:33:39Z
cat > bug.d << CODE inout(T)[] dup(T)(inout(T)[] a) { inout(T)[] res; foreach (ref e; a) res ~= e; return res; } enum works = dup([0]); enum trigger = dup([0, 1]); CODE dmd -c bug.d ---- bug.d(5): Error: Cannot interpret res ~= e at compile time bug.d(10): called from here: dup([0, 1]) ---- Probably some issue when reassigning the foreach argument because it's only triggered when the array has more than one element.
Comment #1 by code — 2014-04-06T09:25:29Z
workaround: foreach (ref e; a) res ~= [e];
Comment #2 by k.hara.pg — 2014-04-06T23:53:52Z
Comment #3 by github-bugzilla — 2014-04-07T02:58:40Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b3d3eeb2223fa521b8653ed0a4ef3f749b2b11b7 fix Issue 12528 - [CTFE] cannot append elements from one inout array to another inout array https://github.com/D-Programming-Language/dmd/commit/b3d2ca068a976a6f69447502edb3779d97897642 Merge pull request #3430 from 9rnsr/fix12528 Issue 12528 - [CTFE] cannot append elements from one inout array to another inout array