www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20509] New: implicit conversions considered before IFTI

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 puremagic.com
          Reporter: elpenguino+D 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.

--
Jan 15