Skip to content

zip does not properly check lengths and strides #59

@jmh530

Description

@jmh530

The key part of the code is

 foreach(i, S; Slices[1 .. $]) { static assert(isSlice!S == packs, "zip: all Slices must have the same shape packs"); assert(slices[i]._lengths == slices[0]._lengths, "zip: all slices must have the same lengths"); static if (sameStrides) assert(slices[i].unpack.strides == slices[0].unpack.strides, "zip: all slices must have the same strides"); } 

note that the last part of the foreach is Slices[1..$], but then slices is indexed at slices[i]. The first iteration of the loop is i=0, so it's just comparing slices[0] to itself. If Slices.length is 1, then this is all that occurs.

There are two options to fix, either change the slices[i] to slices[i+1] or to S.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions