digitalmars.D.bugs - [Issue 23531] New: [DIP1000] scope variable can be assigned as AA key
- d-bugmail puremagic.com (34/34) Dec 01 2022 https://issues.dlang.org/show_bug.cgi?id=23531
https://issues.dlang.org/show_bug.cgi?id=23531 Issue ID: 23531 Summary: [DIP1000] scope variable can be assigned as AA key Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: pro.mathias.lang gmail.com ``` void main () safe { auto r = bar(); assert(r["foo!"] == "oi"); } string[string] bar () safe { immutable(char)[4] s = "foo!"; return foo(s); } string[string] foo (scope string f) safe { string[string] aa; aa[f] = "oi"; return aa; } ``` Results in RangeError because the key is garbage. Funny thing is that assigning `f` as the value of the AA (e.g. `aa[f] = f;`) is correctly detected. --
Dec 01 2022