Skip to content

Commit 3026329

Browse files
authored
Merge pull request #4820 from 9il/workaround16473
workaround for Issue 16473
2 parents a725dbc + 1c9ff2f commit 3026329

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

std/experimental/ndslice/slice.d

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2478,7 +2478,7 @@ struct Slice(size_t _N, _Range)
24782478
+/
24792479
auto ref opIndexOpAssign(string op, T)(T value, size_t[N] _indexes...)
24802480
{
2481-
mixin (`return _ptr[indexStride(_indexes)] ` ~ op ~ `= value;`);
2481+
return mixin (`_ptr[indexStride(_indexes)] ` ~ op ~ `= value`);
24822482
}
24832483

24842484
static if (doUnittest)
@@ -2727,9 +2727,10 @@ struct Slice(size_t _N, _Range)
27272727
Increment `++` and Decrement `--` operators for a $(B fully defined index).
27282728
+/
27292729
auto ref opIndexUnary(string op)(size_t[N] _indexes...)
2730-
if (op == `++` || op == `--`)
2730+
// @@@workaround@@@ for Issue 16473
2731+
//if (op == `++` || op == `--`)
27312732
{
2732-
mixin (`return ` ~ op ~ `_ptr[indexStride(_indexes)];`);
2733+
return mixin (`` ~ op ~ `_ptr[indexStride(_indexes)]`);
27332734
}
27342735

27352736
static if (doUnittest)
@@ -2742,6 +2743,14 @@ struct Slice(size_t _N, _Range)
27422743
assert(a[1, 2] == 1);
27432744
}
27442745

2746+
// Issue 16473
2747+
static if (doUnittest)
2748+
unittest
2749+
{
2750+
auto sl = slice!double(2, 5);
2751+
auto d = -sl[0, 1];
2752+
}
2753+
27452754
static if (doUnittest)
27462755
pure nothrow unittest
27472756
{

0 commit comments

Comments
 (0)