Issue 24831 - IFTI fails for a function template with a default function argument
Summary: IFTI fails for a function template with a default function argument
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 All
: P1 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2024-10-24 07:01 UTC by Max Samukha
Modified: 2024-10-24 07:01 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Max Samukha 2024-10-24 07:01:34 UTC
This renders default arguments in generic functions unusable.

void foo(U, T = int)(T v = T.init)
{
}

void main()
{
    foo!int(); // ok
    foo!int("x"); // fail
}

Error: function `foo` is not callable using argument types `(string)`

The second call tries to reuse the previous instantiation instead of creating a new one. An explicit instantiation works but defeats the purpose of using default arguments.