Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ternary operator turns a character into an integral #18825

Open
dlangBugzillaToGithub opened this issue May 6, 2014 · 2 comments
Open

Ternary operator turns a character into an integral #18825

dlangBugzillaToGithub opened this issue May 6, 2014 · 2 comments

Comments

@dlangBugzillaToGithub
Copy link

Andrej Mitrovic (@AndrejMitrovic) reported this on 2014-05-06T19:22:40Z

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

CC List

Description

-----
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.
@dlangBugzillaToGithub
Copy link
Author

bearophile_hugs commented on 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.

@dlangBugzillaToGithub
Copy link
Author

andrej.mitrovich (@AndrejMitrovic) commented on 2014-05-06T20:57:54Z

Seems like a dupe or another case of https://issues.dlang.org/show_bug.cgi?id=11732

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant