D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21576 - __traits(compile) does not automatically infer to empty parameter function template
Summary: __traits(compile) does not automatically infer to empty parameter function te...
Status: RESOLVED DUPLICATE of issue 21451
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-23 18:31 UTC by João Lourenço
Modified: 2021-01-23 20:10 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description João Lourenço 2021-01-23 18:31:43 UTC
import std;

void foo(TRange ...)(TRange range)
{
	foreach(r; range) bar(r);
}

void foo(TRange ...)()
{
	foreach(T; TRange) bar!T;
}

void bar(T)(T t = T.init)
    if (!is(T == string))
{}


void main()
{
    assert(!__traits(compiles, foo(1, "")));           // ok
    assert(!__traits(compiles, foo!(uint, string)())); // ok
    assert(!__traits(compiles, foo!(uint, string)));   // fails
}
Comment 1 João Lourenço 2021-01-23 20:10:20 UTC

*** This issue has been marked as a duplicate of issue 21451 ***