digitalmars.D.bugs - [Issue 12544] New: Differences in ubyte/char enum printing
- d-bugmail puremagic.com (37/37) Apr 08 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12544
- d-bugmail puremagic.com (26/26) Apr 08 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12544
https://d.puremagic.com/issues/show_bug.cgi?id=12544 Summary: Differences in ubyte/char enum printing Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc I am not sure if this is a bug, a regression, or it's working as designed. Currently this code shows a difference in the outputs that perhaps should not exist: void main() { import std.stdio; enum E1 : ubyte { A='a' } E1[10] v1; writeln(v1); enum E2 : char { A='a' } E2[10] v2; writeln(v2); writefln("%-(%c%)", v2); } DMD 2.066alpha output: [A, A, A, A, A, A, A, A, A, A] aaaaaaaaaa aaaaaaaaaa Expected output: [A, A, A, A, A, A, A, A, A, A] [A, A, A, A, A, A, A, A, A, A] aaaaaaaaaa -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 08 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12544 monarchdodra gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |monarchdodra gmail.com The code goes through the "formatRange" branch of `std.format`. In format range, the code checks if it is a range of chars: - range of chars => print string (eg: aaaaaaa...) - range of non-chars => print array (eg: [A, A, A, A, A... The issue is one of determining "what is a char"? Currently, the code uses: is(CharTypeOf!(ElementType!T)) Which mean any type that implicitly casts to char is fair game (including structs with "alias this"). *Arguably*, I think `isSomeChar` would be better, as it only accepts *actual* chars. But even then, it would still accept enums whose base type is char, as technically, they *are* chars. Unfortunately, there is always ambiguity when asking to print an enum of a char or string. I don't know either if this is bug or working as designed. (I don't think it's a regression though... did you test other versions?) -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 08 2014