[Issue 5659] New: Conditional operator, array literal, and std.traits.CommonType return a wrong common type
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Feb 27 07:46:58 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5659
Summary: Conditional operator, array literal, and
std.traits.CommonType return a wrong common type
Product: D
Version: D2
Platform: Other
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: rayerd.wiz at gmail.com
Depends on: 3067
--- Comment #0 from Haruki Shigemori <rayerd.wiz at gmail.com> 2011-02-27 07:44:10 PST ---
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
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list