Bug 5659 – Conditional operator, array literal, and std.traits.CommonType return a wrong common type

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-02-27T07:44:00Z
Last change time
2017-04-28T19:48:42Z
Assigned to
nobody
Creator
rayerd.wiz
Depends on
3067
See also
https://issues.dlang.org/show_bug.cgi?id=17141

Comments

Comment #0 by rayerd.wiz — 2011-02-27T07:44:10Z
Because summary of issue 3067 was wrong, I report on this problem again. import std.stdio : writeln; import std.traits : CommonType; void main() { auto a = ("a".dup)[0]; auto b = "b"[0]; auto c = true ? a : b; auto d = [a, b][0]; writeln(typeof(a).stringof);//char writeln(typeof(b).stringof);//immutable(char) writeln(typeof(c).stringof);//int, but it should be char. writeln(CommonType!(typeof(a), typeof(b)).stringof);//ditto writeln(typeof(d).stringof);//ditto }
Comment #1 by rayerd.wiz — 2011-02-27T07:45:37Z
*** Issue 3067 has been marked as a duplicate of this issue. ***
Comment #2 by k.hara.pg — 2011-06-20T01:49:44Z
Mostly agreed to this issue, but I have one question. Is the common type of 'char' and 'immutable(char)' 'char'? I guess it is 'const(char)' from implicit const conversion.
Comment #3 by bugzilla — 2011-06-20T21:27:08Z