From 5a94100e8edff582f433f2f1cf8c285a7234c9da Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Tue, 13 Aug 2024 17:29:17 +0800 Subject: [PATCH 1/2] enable `-preview= rvaluefefparam` by default --- compiler/src/dmd/globals.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/src/dmd/globals.d b/compiler/src/dmd/globals.d index 2bdc1856e189..79c1671282f1 100644 --- a/compiler/src/dmd/globals.d +++ b/compiler/src/dmd/globals.d @@ -183,7 +183,8 @@ extern (C++) struct Param bool useDIP1021; // implement https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1021.md FeatureState fieldwise; // do struct equality testing field-wise rather than by memcmp() bool fixAliasThis; // if the current scope has an alias this, check it before searching upper scopes - FeatureState rvalueRefParam; // allow rvalues to be arguments to ref parameters + FeatureState rvalueRefParam = FeatureState.enabled; + // allow rvalues to be arguments to ref parameters // https://dconf.org/2019/talks/alexandrescu.html // https://gist.github.com/andralex/e5405a5d773f07f73196c05f8339435a // https://digitalmars.com/d/archives/digitalmars/D/Binding_rvalues_to_ref_parameters_redux_325087.html From 7375b28c49e4ae98b0233355fc05c13b8a6904d8 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Tue, 13 Aug 2024 17:51:10 +0800 Subject: [PATCH 2/2] don't match `ref void` --- compiler/src/dmd/templatesem.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dmd/templatesem.d b/compiler/src/dmd/templatesem.d index afd0add44889..87c4ee7e0ec5 100644 --- a/compiler/src/dmd/templatesem.d +++ b/compiler/src/dmd/templatesem.d @@ -1357,7 +1357,7 @@ extern (D) MATCHpair deduceFunctionTemplateMatch(TemplateDeclaration td, Templat { // Allow conversion from T[lwr .. upr] to ref T[upr-lwr] } - else if (global.params.rvalueRefParam == FeatureState.enabled) + else if (global.params.rvalueRefParam == FeatureState.enabled && prmtype.ty != Tvoid) { // Allow implicit conversion to ref }