digitalmars.D.bugs - [Issue 10315] New: Conditional triple operator unifies a char and a dchar as a unit
- d-bugmail puremagic.com (37/37) Jun 09 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10315
- d-bugmail puremagic.com (6/6) Aug 30 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10315
- d-bugmail puremagic.com (19/19) Sep 02 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10315
http://d.puremagic.com/issues/show_bug.cgi?id=10315 Summary: Conditional triple operator unifies a char and a dchar as a unit Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: wrong-code Severity: major Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc void main() { dchar c; pragma(msg, typeof(true ? c : ' ')); } DMD 2.064alpha prints: uint Expected: dchar That bad type unification causes situations like: import std.stdio: writeln; import std.algorithm: map; void main() { "just 1256 some text" .map!(c => true ? c : ' ') .writeln; } That prints: [106, 117, 115, 116, 32, 49, 50, 53, 54, 32, 115, 111, 109, 101, 32, 116, 101, 120, 116] -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 09 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10315 See also Issue 10926 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 30 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10315 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Conditional triple operator |Conditional triple operator |unifies a char and a dchar |unifies a char and a dchar |as a unit |as a uint If you have char c; dchar d; I agree that (true ? d : ' ') should be a dchar, but only because ' ' can be implicitly converted to dchar by applying value range propagation. But (true ? d : c) should not. It's reasonable for it to be a uint. Because c might be a UTF8 code point, not a character, so casting it to a dchar would be incorrect. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 02 2013