[Issue 21917] Unused default values for IFTI parameters should not be typechecked against the IFTI-inferred type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 23 14:01:06 UTC 2024


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

--- Comment #8 from Max Samukha <maxsamukha at gmail.com> ---
(In reply to Dennis from comment #7)


> 
> This gives an error "foo called with argument types `(string)` matches both
> ...", showing that default arguments are not considered for overload
> resolution.

Thank you for the explanation! The current semantics makes sense to me now. The
fix that strips default arguments doesn't seem the right way to go.

What's the reason for this error:

void foo(T)(T a = T.init); // Error: undefined identifier `T`

void main()
{
    foo(0);
    foo("x");
    foo();
}

?

It works with a default argument for the type parameter:

void foo(T = int)(T a = T.init); // ok

I'd be absolutely happy if this were fixed.

--


More information about the Digitalmars-d-bugs mailing list