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)[]
----