www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11732] New: Ternary operator type unification problems with dstrings

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: bearophile_hugs eml.cc



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: -------
Dec 12 2013
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11732


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com



First one is similar to issue 9968.

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