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
Why? 0 implicitly converts to both char and dchar.
This is not as important as other changes I have proposed elsewhere. (In reply to comment #1) > 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.
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.
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18738 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB