Consider the following code: ``` void foo (T) (const auto ref T arg = T.init) {} void bar (T) (const ref T arg = T.init) {} void main () { int i; foo!int(); bar!int(i); } ``` This will produce the following error message: ``` autoref.d(2): Error: cannot modify constant `0` autoref.d(8): Error: template instance `autoref.bar!int` error instantiating ``` Compiled with or without `-preview=rvaluerefparam`, DMD 2.091. Now there's a few problem with this: 1) The error message is wrong: there's no modification taking place, the parameter is `const`; 2) It should work with the `-preview` switch; 3) Should the error message happens if the default parameter is not used ? It triggers on the definition ATM.
@nordlow created dlang/dmd pull request #12413 "Fix issue 20704" fixing this issue: - Fix issue 20704 https://github.com/dlang/dmd/pull/12413
dlang/dmd pull request #12413 "Fix issue 20704 - -preview=rvaluerefparam does not work with init as default parameter" was merged into master: - 9a2042425a1e3161012f34b1c140c3a7d41b849a by nordlow: Fix issue 20704 https://github.com/dlang/dmd/pull/12413