www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12711] New: Ternary operator turns a character into an integral

https://issues.dlang.org/show_bug.cgi?id=12711

          Issue ID: 12711
           Summary: Ternary operator turns a character into an integral
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich gmail.com

-----
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. --
May 06 2014