May 12, 2023
https://issues.dlang.org/show_bug.cgi?id=23916

          Issue ID: 23916
           Summary: Non-eponymous template instances have a "type" (void)
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid, diagnostic
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: dlang-bugzilla@thecybershadow.net

This code is meaningless, and should not compile:

//// test.d ////
template X() {}

void fun()
{
    return X!();
}
////////////////

Template instances having a type when they shouldn't can be misleading and confusing to diagnose. For example, consider:

///// test.d /////
template X()
{
}

void fun(int i) {}

void main()
{
    fun(X!());
}
//////////////////

Currently, this produces:

test.d(9): Error: function `test.fun(int i)` is not callable using argument
types `(void)`
test.d(9):        cannot pass argument `X!()` of type `void` to parameter `int
i`

A better error would be:

test.d(9): Error: cannot pass template instance `X!()` as a function argument

--