[Issue 23916] New: Non-eponymous template instances have a "type" (void)
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Fri May 12 17:17:07 UTC 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 at puremagic.com
          Reporter: dlang-bugzilla at 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
--
    
    
More information about the Digitalmars-d-bugs
mailing list