Skip to content

Commit

Permalink
Fix 24272 - operations.arrayOp is forced @nogc nothrow pure
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorpel authored and dlang-bot committed Dec 7, 2023
1 parent f5de34d commit 18930e0
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions druntime/src/core/internal/array/operations.d
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ version (LDC) version = GNU_OR_LDC;
*
* Returns: the slice containing the result
*/
T[] arrayOp(T : T[], Args...)(T[] res, Filter!(isType, Args) args) @trusted @nogc pure nothrow
T[] arrayOp(T : T[], Args...)(T[] res, Filter!(isType, Args) args) @trusted
{
alias scalarizedExp = staticMap!(toElementType, Args);
alias check = typeCheck!(true, T, scalarizedExp); // must support all scalar ops
Expand Down Expand Up @@ -541,7 +541,7 @@ unittest
}

// test handling of v op= exp
unittest
@nogc nothrow pure @safe unittest
{
uint[32] c;
arrayOp!(uint[], uint, "+=")(c[], 2);
Expand All @@ -556,7 +556,7 @@ unittest
}

// proper error message for UDT lacking certain ops
unittest
@nogc nothrow pure @safe unittest
{
static assert(!is(typeof(&arrayOp!(int[4][], int[4], "+="))));
static assert(!is(typeof(&arrayOp!(int[4][], int[4], "u-", "="))));
Expand Down Expand Up @@ -585,7 +585,7 @@ unittest
}

// test mixed type array op
unittest
@nogc nothrow pure @safe unittest
{
uint[32] a = 0xF;
float[32] res = 2.0f;
Expand All @@ -595,7 +595,7 @@ unittest
}

// test mixed type array op
unittest
@nogc nothrow pure @safe unittest
{
static struct S
{
Expand All @@ -613,7 +613,7 @@ unittest
}

// test scalar after operation argument
unittest
@nogc nothrow pure @safe unittest
{
float[32] res, a = 2, b = 3;
float c = 4;
Expand All @@ -622,7 +622,7 @@ unittest
assert(v == 2 * 3 + 4);
}

unittest
@nogc nothrow pure @safe unittest
{
// https://issues.dlang.org/show_bug.cgi?id=17964
uint bug(){
Expand All @@ -635,7 +635,7 @@ unittest
}

// https://issues.dlang.org/show_bug.cgi?id=19796
unittest
nothrow pure @safe unittest
{
double[] data = [0.5];
double[] result;
Expand All @@ -645,7 +645,7 @@ unittest
}

// https://issues.dlang.org/show_bug.cgi?id=21110
unittest
pure unittest
{
import core.exception;

Expand All @@ -668,3 +668,20 @@ unittest
void func() { dst[] = a[] + b[]; }
assertThrown!AssertError(func(), "Array operations with mismatched lengths must throw an error");
}

// https://issues.dlang.org/show_bug.cgi?id=24272
unittest
{
static struct B
{
B opOpAssign(string op)(B other)
{
static int g;
g++;
throw new Exception("");
}
}

B[] bArr;
bArr[] += B();
}

0 comments on commit 18930e0

Please sign in to comment.