[Issue 20509] New: implicit conversions considered before IFTI

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 15 22:40:31 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=20509

          Issue ID: 20509
           Summary: implicit conversions considered before IFTI
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: elpenguino+D at gmail.com

```
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.

--


More information about the Digitalmars-d-bugs mailing list