Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/core/internal/array/operations.d
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ T[] arrayOp(T : T[], Args...)(T[] res, Filter!(isType, Args) args) @trusted @nog
alias scalarizedExp = staticMap!(toElementType, Args);
alias check = typeCheck!(true, T, scalarizedExp); // must support all scalar ops

foreach (argsIdx, arg; typeof(args))
{
static if (is(arg == U[], U))
{
assert(res.length == args[argsIdx].length, "Mismatched array lengths for vector operation");
}
}

size_t pos;
static if (vectorizeable!(T[], Args))
{
Expand Down Expand Up @@ -635,3 +643,28 @@ unittest
result[] = -data[];
assert(result[0] == -0.5);
}

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

static void assertThrown(T : Throwable, E)(lazy E expression, string msg)
{
try
expression;
catch (T)
return;
assert(0, "msg");
}

int[] dst;
int[] a;
int[] b;
a.length = 3;
b.length = 3;
dst.length = 4;

void func() { dst[] = a[] + b[]; }
assertThrown!AssertError(func(), "Array operations with mismatched lengths must throw an error");
}