D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11732 - Ternary operator type unification problems with dstrings
Summary: Ternary operator type unification problems with dstrings
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P3 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2013-12-12 10:09 UTC by bearophile_hugs
Modified: 2024-12-13 18:15 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2013-12-12 10:09:07 UTC
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)[][]
Comment 1 yebblies 2013-12-12 23:00:06 UTC
First one is similar to issue 9968.
Comment 2 dlangBugzillaToGithub 2024-12-13 18:15:08 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18737

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB