Bug 20209 – AA.get() needs to work with inout correctly

Status
NEW
Severity
normal
Priority
P3
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-09-12T16:48:56Z
Last change time
2024-12-07T13:39:37Z
Assigned to
No Owner
Creator
hsteoh
Moved to GitHub: dmd#17389 →

Comments

Comment #0 by hsteoh — 2019-09-12T16:48:56Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17389 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB