Thread overview | |||||
---|---|---|---|---|---|
|
September 24, 2011 [Issue 6722] New: Can't remove a char[] key from an AA with immutable(char)[] key type. | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=6722 Summary: Can't remove a char[] key from an AA with immutable(char)[] key type. Product: D Version: D2 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: siegelords_abode@yahoo.com --- Comment #0 from siegelords_abode@yahoo.com 2011-09-23 20:58:23 PDT --- int[char[]] a; int[immutable(char)[]] b; char[] s; int v1 = a[s]; // Fine int v2 = b[s]; // Fine a.remove(s); // Fine b.remove(s); // Error: cannot implicitly convert expression (s) of type char[] to string Can we be done with the compiler magic for the AA's? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 24, 2011 [Issue 6722] Can't remove a char[] key from an AA with immutable(char)[] key type. | ||||
---|---|---|---|---|
| ||||
Posted in reply to siegelords_abode@yahoo.com | http://d.puremagic.com/issues/show_bug.cgi?id=6722 Jonathan M Davis <jmdavisProg@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jmdavisProg@gmx.com --- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-09-23 21:15:55 PDT --- The simplest solution is to just make it so that it's illegal to declare an AA with a key which isn't either a value type or immutable and make it so that _all_ functions or operators which take the key must take a type which is implicitly convertible to the key type (including its immutability). It _would_ break a fair bit of code though, I suspect. Still, it would be a fairly simple change to make in any code that it breaks, and it could be grandfathered in by making it a warning first. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 12, 2012 [Issue 6722] Can't remove a char[] key from an AA with immutable(char)[] key type. | ||||
---|---|---|---|---|
| ||||
Posted in reply to siegelords_abode@yahoo.com | http://d.puremagic.com/issues/show_bug.cgi?id=6722 Stewart Gordon <smjg@iname.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rejects-valid CC| |smjg@iname.com Platform|Other |All OS/Version|Linux |All --- Comment #2 from Stewart Gordon <smjg@iname.com> 2012-02-12 12:35:58 PST --- A char[] can be safely compared with an immutable(char)[], so the code should be valid. Putting a value into an AA is another matter though. (In reply to comment #1) > The simplest solution is to just make it so that it's illegal to declare an AA with a key which isn't either a value type or immutable Agreed. > and make it so that _all_ functions or operators which take the key must take a type which is implicitly convertible to the key type (including its immutability). For functions that put data into an AA, yes. For lookup functions (retrieval and removal), it should be sufficient that it's a type that is implicitly convertible to the const version of the key type. (Just having an == operator with the key type isn't sufficient, as it needs to check the hash first.) For foreach, the only requirement should be that the key variable is of a type to which the key type can be implicitly converted. But this is a distinct matter from this bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation