[Issue 21576] New: __traits(compile) does not automatically infer to empty parameter template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 23 18:31:43 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=21576

          Issue ID: 21576
           Summary: __traits(compile) does not automatically infer to
                    empty parameter template
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: jlourenco5691 at gmail.com

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
}

--


More information about the Digitalmars-d-bugs mailing list