Bug 12711 – Ternary operator turns a character into an integral

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-05-06T19:22:40Z
Last change time
2024-12-13T18:20:24Z
Assigned to
No Owner
Creator
Andrej Mitrovic
Moved to GitHub: dmd#18825 →

Comments

Comment #0 by andrej.mitrovich — 2014-05-06T19:22:40Z
----- import std.ascii; import std.algorithm; import std.stdio; void main() { writeln( "foo-bar-doo".map!(a => a.isAlphaNum ? a : '_') ); writeln( "foo-bar-doo".map!(a => a.isAlphaNum ? a : cast(dchar)'_') ); } ----- $ dmd -run test.d > [102, 111, 111, 95, 98, 97, 114, 95, 100, 111, 111] > foo_bar_doo This is very ugly. I'm not sure whether it's a DMD bug or a Phobos bug though.
Comment #1 by bearophile_hugs — 2014-05-06T19:52:03Z
(In reply to Andrej Mitrovic from comment #0) > This is very ugly. I'm not sure whether it's a DMD bug or a Phobos bug > though. It's an ugly dmd bug: void main() { pragma(msg, typeof(true ? char('x') : '_')); pragma(msg, typeof(true ? wchar('x') : '_')); pragma(msg, typeof(true ? dchar('x') : '_')); } Output: char int uint But perhaps I already reported this issue, please search it in Bugzilla.
Comment #2 by andrej.mitrovich — 2014-05-06T20:57:54Z
Seems like a dupe or another case of https://issues.dlang.org/show_bug.cgi?id=11732
Comment #3 by robert.schadek — 2024-12-13T18:20:24Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18825 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB