Comment #0 by moonlightsentinel — 2021-03-23T23:44:28Z
A template constraint for a nested template breaks overload resolution in the following example (even though the constraint is satisfied). Commenting the constraint or moving it into a `static assert` fixes the problem.
------------------------------------------------------------
void foo(A)(A a)
{}
template foo()
{
void foo()()
if (true) // Comment this constraint to make it pass
{}
}
void main()
{
foo!()();
}
------------------------------------------------------------
The original code used nested templates to create two variadic parameters but those are not required to trigger this bug.
Comment #1 by moonlightsentinel — 2021-03-24T00:15:45Z
Comment #2 by moonlightsentinel — 2021-03-24T22:07:35Z
Also happens for deeply nested templates without overload resolution:
template bar()
{
template bar()
{
void bar()()
if (true) // Comment this constraint to make it pass
{}
}
}
Comment #3 by dlang-bot — 2021-03-25T00:57:15Z
dlang/dmd pull request #12306 "Fix 21752 - Template constraint breaks nested eponymeous template" was merged into master:
- b843e5236079e3866b903241e68e42bdfaad5160 by MoonlightSentinel:
Fix 21752 - Template constraint breaks nested eponymeous template
The `callsc` can be identical for deeply nested eponymeous templates or
while doing overload resolution, so ignore the failure if it's the first
checked scope.
https://github.com/dlang/dmd/pull/12306