Bug 20509 – implicit conversions considered before IFTI

Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-01-15T22:40:31Z
Last change time
2022-01-21T11:59:52Z
Assigned to
No Owner
Creator
elpenguino+D

Comments

Comment #0 by elpenguino+D — 2020-01-15T22:40:31Z
``` unittest { assert(x(X())); } struct X { int a; alias a this; } bool x()(int) { return false; } bool x(T)(T) if (!is(T == int)) { return true; } ``` I would not expect x to return false here. That the implicit conversion would be attempted before exhausting all possibilities is quite surprising. This is especially problematic for templated structs. The only way to be considered as a candidate over the implicit conversion is to specify explicit instantiations - ie bool x(SomeStruct!int), bool x(SomeStruct!bool), etc. Works as expected on DMD 2.063 and earlier.
Comment #1 by moonlightsentinel — 2020-01-16T02:43:00Z
Comment #2 by razvan.nitu1305 — 2022-01-21T11:59:52Z
*** This issue has been marked as a duplicate of issue 16484 ***