From b0fb5fb9d9ab7435a461c584c10adb108eef4627 Mon Sep 17 00:00:00 2001 From: Teodor Dutu Date: Thu, 16 Dec 2021 01:38:24 +0200 Subject: [PATCH] Allow `_d_arrayappendT` to call impure functions Signed-off-by: Teodor Dutu --- src/core/internal/array/appending.d | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/core/internal/array/appending.d b/src/core/internal/array/appending.d index 1e58ddc988..c01b6830eb 100644 --- a/src/core/internal/array/appending.d +++ b/src/core/internal/array/appending.d @@ -83,6 +83,13 @@ template _d_arrayappendTImpl(Tarr : T[], T) private enum errorMessage = "Cannot append to array if compiling without support for runtime type information!"; + ref Tarr _d_arrayappendTImpure(return scope ref Tarr x, scope Tarr y) + { + pragma(inline, false); + + mixin(_d_arrayappendTBody); + } + /** * Append array `y` to array `x`. * Params: @@ -98,16 +105,14 @@ template _d_arrayappendTImpl(Tarr : T[], T) static if (isCopyingNothrow!T) ref Tarr _d_arrayappendT(return scope ref Tarr x, scope Tarr y) @trusted pure nothrow { - pragma(inline, false); - - mixin(_d_arrayappendTBody); + alias Type = ref Tarr function(return scope ref Tarr x, scope Tarr y) pure nothrow; + return (cast(Type) &_d_arrayappendTImpure)(x, y); } else ref Tarr _d_arrayappendT(return scope ref Tarr x, scope Tarr y) @trusted pure { - pragma(inline, false); - - mixin(_d_arrayappendTBody); + alias Type = ref Tarr function(return scope ref Tarr x, scope Tarr y) pure; + return (cast(Type) &_d_arrayappendTImpure)(x, y); } private enum _d_arrayappendTBody = q{