2084 – operator ?: does not compute the tightest type

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2084 - operator ?: does not compute the tightest type
Summary: operator ?: does not compute the tightest type
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Linux
: P2 normal
Assignee: Walter Bright
URL:
Keywords:
Depends on:
Blocks:
Reported: 2008年05月09日 01:15 UTC by Andrei Alexandrescu
Modified: 2015年06月09日 05:15 UTC (History)
0 users

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Andrei Alexandrescu 2008年05月09日 01:15:55 UTC
Consider:
#!/home/andrei/bin/rdmd -w
import std.stdio;
class Base {}
class D1 : Base {}
class D2 : Base {}
void main(string[] args)
{
 auto b = args ? new D1 : new D2;
}
This program should compile and run, deducing Base as b's type. It fails to compile as written. Replacing "auto" with "Base" still doesn't help.
Comment 1 Walter Bright 2008年05月22日 05:05:44 UTC
Fixed dmd 1.030 and 2.014


AltStyle によって変換されたページ (->オリジナル) /