[Issue 11732] New: Ternary operator type unification problems with dstrings

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 12 10:09:15 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11732

           Summary: Ternary operator type unification problems with
                    dstrings
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2013-12-12 10:09:07 PST ---
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)[][]

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list