digitalmars.D.bugs - [Issue 11733] New: Refuse int indexing of associative arrays with char keys
- d-bugmail puremagic.com (27/27) Dec 12 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11733
- d-bugmail puremagic.com (10/10) Dec 12 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11733
- d-bugmail puremagic.com (17/18) Dec 13 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11733
- d-bugmail puremagic.com (14/14) Dec 13 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11733
https://d.puremagic.com/issues/show_bug.cgi?id=11733 Summary: Refuse int indexing of associative arrays with char keys Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc I think this code should be disallowed: void main() { int[char] aa1; int[dchar] aa2; auto r1 = aa1[0]; auto r2 = aa2[0]; } dmd 2.065alpha compiles it with no errors, and gives at run-time: core.exception.RangeError temp(4): Range violation -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 12 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11733 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yebblies gmail.com Why? 0 implicitly converts to both char and dchar. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 12 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11733 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |minor This is not as important as other changes I have proposed elsewhere.Why? 0 implicitly converts to both char and dchar.Because int and char are two different types. It makes code less clear, and in D there is a simple syntax to express that: auto r1 = aa1['\0']; auto r2 = aa2['\0']; There is no ambiguity here, '\0' is clearly a char for the person that reads the code. Using 0 instead of '\0' seems a weakly typing archaism coming from C. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 13 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11733 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Platform|x86 |All OS/Version|Windows |All Severity|minor |enhancement There is no ambiguity anyway. Asking for int not to convert to char is not new, and I vaguely recall it was rejected on the grounds that char x = 'a'+7; should work. I don't if there is an existing report for that. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 13 2013