[Issue 20209] New: AA.get() needs to work with inout correctly
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Sep 12 16:48:56 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20209
Issue ID: 20209
Summary: AA.get() needs to work with inout correctly
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: hsteoh at quickfur.ath.cx
Code:
------
struct C {
int[] data;
}
struct S {
private int[][string] aa;
inout(C) func(string key) inout {
return inout(C)(aa[key]);
}
inout(C) gunk(string key) inout {
return inout(C)(aa.get(key, [])); // line 10
}
}
------
Compiler output:
------
test.d(10): Error: cannot implicitly convert expression get(this.aa, key,
delegate const(int[])() pure nothrow @nogc @safe => []) of type const(int[]) to
inout(int[])
------
Expected behaviour: gunk() should compile, because it's doing nothing illegal:
it's looking up a key from S.aa and returning it, just like func() does, except
that gunk() uses aa.get() in order to provide a default value when the key
doesn't exist in the AA.
--
More information about the Digitalmars-d-bugs
mailing list