www.fgks.org   »   [go: up one dir, main page]

Issue 21752 - Template constraint breaks nested eponymeous template
Summary: Template constraint breaks nested eponymeous template
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-23 23:44 UTC by moonlightsentinel
Modified: 2021-03-25 00:57 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 moonlightsentinel 2021-03-23 23:44:28 UTC
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 moonlightsentinel 2021-03-24 00:15:45 UTC
Regression introduced by https://github.com/dlang/dmd/pull/2826
Comment 2 moonlightsentinel 2021-03-24 22:07:35 UTC
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 Dlang Bot 2021-03-25 00:57:15 UTC
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