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.
Regression introduced by https://github.com/dlang/dmd/pull/2826
Also happens for deeply nested templates without overload resolution: template bar() { template bar() { void bar()() if (true) // Comment this constraint to make it pass {} } }
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