D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3486 - [tdpl] Incorrect result type of binary operators applied to typedef'd types
Summary: [tdpl] Incorrect result type of binary operators applied to typedef'd types
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-07 10:11 UTC by Andrei Alexandrescu
Modified: 2015-06-09 05:14 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrei Alexandrescu 2009-11-07 10:11:09 UTC
unittest {
    Mass m;
    Velocity v;
    pragma(msg, typeof(m * v).stringof);
    pragma(msg, typeof(v * m).stringof);
    static assert(is(typeof(m * v) == double));
    static assert(is(typeof(v * m) == double));
}

Currently the type of m * v is Velocity, and the type of v * m is Mass. The only reasonable type of an operation (if it compiles at all) should be double, obtained after both operands are converted to their supertype.
Comment 1 Walter Bright 2009-11-18 10:54:09 UTC
Dropping typedef, so won't fix.