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 type unification problems with dstrings #18737

Open
dlangBugzillaToGithub opened this issue Dec 12, 2013 · 1 comment
Open

Comments

@dlangBugzillaToGithub
Copy link

bearophile_hugs reported this on 2013-12-12T10:09:07Z

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

CC List

  • yebblies

Description

Title: 
Component: dmd
Severity: 
Code number: 
Keywords: 
Outcome: 
Is done: no
See also: 


I am not sure this is a but, it seems like one:


void main() {
    bool test;
     string   s1 = test ? ""    : null; // OK
    dstring   s2 = test ? ""d   : null; // OK
    dstring   s3 = test ? ""    : "";   // OK
    dstring   s4 = test ? ""    : null; // error
    dstring[]  a = test ? [""d] : null; // OK
    dstring[]  b = test ? [""]  : null; // error
}

dmd 2.065alpha gives:

temp.d(6): Error: cannot implicitly convert expression (test ? "" : null) of type string to immutable(dchar)[]
temp.d(8): Error: cannot implicitly convert expression (test ? [""] : null) of type string[] to immutable(dchar)[][]
@dlangBugzillaToGithub
Copy link
Author

yebblies commented on 2013-12-12T23:00:06Z

First one is similar to issue 9968.

@thewilsonator thewilsonator removed OS:Windows Arch:x86 Issues specific to x86 P3 labels Dec 16, 2024
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

2 participants