[Issue 22241] Compiler fails to match a more specialized overload

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 11 18:33:49 UTC 2023


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

--- Comment #2 from Max Samukha <maxsamukha at gmail.com> ---
(In reply to RazvanN from comment #1)

> both match equally

That's the problem. They do both match after deduction, but one of the patterns
is still more specific than the other.

Also, in the following, slightly different case, type deduction doesn't seem to
prevent the compiler from selecting the more specific one:

int foo(T: int)(T a)
{
    return 1;
}

int foo(T)(T a)
{
    return 2;
}

void main()
{
    int x;
    assert(foo(x) == 1); // ok
    assert(foo("a") == 2); // ok
}

(Somebody tried to explain to me why this works, but I didn't get it).

> What do you think?

I think that simply closing this as WONTFIX would be an admission of defeat. On
the other hand, I understand that a proper fix would require a significant
redesign/rewrite.

--


More information about the Digitalmars-d-bugs mailing list