www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19891] New: Confusing error message for auto ref parameters

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

          Issue ID: 19891
           Summary: Confusing error message for auto ref parameters with
                    default values
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: yshuiv7 gmail.com

void fun(R)(auto ref int a, auto ref R r = 1) {}

void main() {
    fun(10, 2); // Error: cannot modify constant `1`
    fun(10); // Error: `auto` can only be used as part of `auto ref` for
template function parameters
}

The error messages make sense in neither of the cases.

--
May 22 2019