Bug 6936 – type combination is not commutative

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-11-12T04:06:19Z
Last change time
2024-12-13T17:56:54Z
Assigned to
No Owner
Creator
timon.gehr
Moved to GitHub: dmd#18380 →

Comments

Comment #0 by timon.gehr — 2011-11-12T04:06:19Z
Tested with DMD 2.056. const(int[]) x; const(int)[] y; static assert(is(typeof(1?x:y) == typeof(1?y:x))); // fail. Error: static assert (is(const(int)[] == const(int[]))) is false The static assertion should pass. I suggest the common type in this case should be const(int)[]. That is consistent with how type combination works for basic types.
Comment #1 by hsteoh — 2014-07-19T01:44:26Z
Isn't this more a problem with type inference in the ternary '?' operator?
Comment #2 by issues.dlang — 2014-07-19T02:17:22Z
(In reply to hsteoh from comment #1) > Isn't this more a problem with type inference in the ternary '?' operator? Yes. The ternary operator currently, incorrectly uses the type of its last argument rather than the common type of the second and third arguments. It's essentially the same bug as issue# 3543, but this is with arrays, whereas 3543 specifically talks about classes and interfaces, so I'm not sure if it's actually a duplicate.
Comment #3 by hsteoh — 2014-07-22T14:25:21Z
Recently Kenji fixed array type deduction to work correctly with base classes. But I guess it still doesn't work properly with common interfaces, or, in this case, const-ness.
Comment #4 by robert.schadek — 2024-12-13T17:56:54Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18380 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB