Bug 12523 – wrong foreach argument type with ref and inout

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

Comments

Comment #0 by code — 2014-04-05T02:14:56Z
cat > bug.d << CODE inout(T)[] dup(T)(inout(T)[] a) { inout(T)[] res; foreach (ref e; a) // works without ref res ~= e; return res; } struct S { void *p; } void foo() { S[] m; m = dup(m); } CODE dmd -c bug.d ---- Error: cannot append type inout(const(S)) to type inout(S)[] ----
Comment #1 by code — 2014-04-05T02:30:24Z
Comment #2 by code — 2014-04-05T03:09:51Z
Comment #3 by github-bugzilla — 2014-04-05T22:58:50Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b8669836b696742709042aaa1b4cf4c8970bcc57 fix Issue 12523 - wrong type deduced for foreach ref argument - No need to change the storage class because the var type already has inferred modifiers. https://github.com/D-Programming-Language/dmd/commit/6d10394b33fea5e20a946b6f748239ee4a0e5076 Merge pull request #3424 from MartinNowak/fix12523 fix Issue 12523 - wrong type deduced for foreach ref argument
Comment #4 by k.hara.pg — 2015-06-04T08:33:36Z
*** Issue 12478 has been marked as a duplicate of this issue. ***