www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21917] New: Unused default values for IFTI parameters should


          Issue ID: 21917
           Summary: Unused default values for IFTI parameters should not
                    be typechecked against the IFTI-inferred type
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net

This should work:

////////// test.d /////////
void fun(T)(T value = "hi")

void main()
    fun();        // OK
    fun("hello"); // OK
    fun(42);      // Error

The reason for why it should work is that e.g. we can't pass a range as a `fun`
argument. A workaround is to declare an overload, but that doesn't scale well
with the number of parameters.

May 12 2021