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.
Comment #1 by hsteoh — 2022-10-28T20:38:34Z
Tested on git master g92299d818, problem still persists.
Comment #2 by robert.schadek — 2024-12-07T13:39:37Z