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
23 changes: 22 additions & 1 deletion src/core/internal/arrayop.d
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ string scalarExp(Args...)()
{
string[] stack;
size_t argsIdx;

static if (is(Args[0] == U[], U))
alias Type = U;
else
alias Type = Args[0];

foreach (i, arg; Args)
{
static if (is(arg == T[], T))
Expand All @@ -271,7 +277,12 @@ string scalarExp(Args...)()
else static if (isUnaryOp(arg))
{
auto op = arg[0] == 'u' ? arg[1 .. $] : arg;
stack[$ - 1] = op ~ "cast(int)"~ stack[$ - 1];
// Explicitly use the old integral promotion rules
// See also: https://dlang.org/changelog/2.078.0.html#fix16997
static if (is(Type : int))
stack[$ - 1] = "cast(typeof(" ~ stack[$ -1] ~ "))" ~ op ~ "cast(int)("~ stack[$ - 1] ~ ")";
else
stack[$ - 1] = op ~ stack[$ - 1];
}
else static if (arg == "=")
{
Expand Down Expand Up @@ -586,3 +597,13 @@ unittest
}
enum x = bug();
}

// https://issues.dlang.org/show_bug.cgi?id=19796
unittest
{
double[] data = [0.5];
double[] result;
result.length = data.length;
result[] = -data[];
assert(result[0] == -0.5);
}