Bug 11732 – Ternary operator type unification problems with dstrings

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2013-12-12T10:09:07Z
Last change time
2024-12-13T18:15:08Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: dmd#18737 →

Comments

Comment #0 by bearophile_hugs — 2013-12-12T10:09:07Z
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 by yebblies — 2013-12-12T23:00:06Z
First one is similar to issue 9968.
Comment #2 by robert.schadek — 2024-12-13T18:15:08Z
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