Skip to content

Commit 6f73b33

Browse files
committed
Fix opIndex kind definition
1 parent 2b0c0ce commit 6f73b33

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

source/mir/ndslice/slice.d

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,13 @@ struct Slice(SliceKind kind, size_t[] packs, Iterator)
14281428
return DeepElemType(_lengths[packs[0] .. $], _strides, c);
14291429
else
14301430
{
1431-
alias Ret = Slice!(kind, (packs[0] - I) ~ packs[1 .. $], Iterator);
1431+
enum size_t diff = packs[0] - I;
1432+
alias Ret = Slice!(
1433+
diff == 1 && kind == Canonical ?
1434+
Contiguous:
1435+
kind,
1436+
diff ~ packs[1 .. $],
1437+
Iterator);
14321438
static if (S)
14331439
return Ret(_lengths[I .. N], _strides[I .. S], c);
14341440
else
@@ -2734,3 +2740,9 @@ unittest
27342740
auto sl = iota(3, 4).universal;
27352741
assert(sl[0 .. $] == sl);
27362742
}
2743+
2744+
unittest
2745+
{
2746+
import mir.ndslice.topology: canonical, iota;
2747+
static assert(kindOf!(typeof(iota([1, 2]).canonical.opIndex(1))) == Contiguous);
2748+
}

0 commit comments

Comments
 (0)