digitalmars.D.bugs - [Issue 12420] New: [AA] Can't set associative array with array as key value using key type
- d-bugmail puremagic.com (34/34) Mar 20 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12420
- d-bugmail puremagic.com (10/21) Mar 29 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12420
- d-bugmail puremagic.com (10/10) Mar 29 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12420
- d-bugmail puremagic.com (12/17) Mar 30 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12420
https://d.puremagic.com/issues/show_bug.cgi?id=12420 Summary: [AA] Can't set associative array with array as key value using key type Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: regression Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: verylonglogin.reg gmail.com 14:02:44 MSK --- This code should compile: --- void main() { int[char[]] aa; aa[new char[1]] = 5; // line 4 } --- main.d(4): Error: associative arrays can only be assigned values with immutable keys, not char[] --- Also the error message is wrong. The compiler expects an array of not-mutable elements (yes, `cast(const)` will work). This incorrect compiler hack [1] was introduced trying to fix Issue 2954 (see Comment 8 of that issue). I propose to remove the hack. And yes, it's a regression from 2010. ) [1] http://www.dsource.org/projects/dmd/changeset/749 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 20 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12420This code should compile: --- void main() { int[char[]] aa; aa[new char[1]] = 5; // line 4 } --- main.d(4): Error: associative arrays can only be assigned values with immutable keys, not char[] ---I agree with the conclusion, the reason in my thought is: `new char[1]` makes unique data and have no foreign reference, so it can be implicitly convertible to immutable(char[]). Therefore directly using it in the index part of the AA element setting will be allowed. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 29 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12420 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull https://github.com/D-Programming-Language/dmd/pull/3408 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 29 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12420 12:27:43 MSK ---I agree with the conclusion, the reason in my thought is: `new char[1]` makes unique data and have no foreign reference, so it can be implicitly convertible to immutable(char[]). Therefore directly using it in the index part of the AA element setting will be allowed.Looks like you misunderstood me. The word `immutable` shouldn't be here, it's just an incorrect error message. Currently we have no rules disallowing non-`immutable` associative array keys. I filed Issue 12491 for this. This issue will be auto-fixed if Issue 2954 will be fixed by applying a correct check to ensure key expression can be implicitly converted to AA key type in case of setting AA value. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 30 2014