weld icon indicating copy to clipboard operation
weld copied to clipboard

iter with negative step

Open radujica opened this issue 7 years ago • 0 comments

The intent is to reverse a string, i.e. a vec[i8], however iter with negative step seems to be broken (at least on the master branch). Take the following examples:

np.array([1, 2, 3, 4, 5, 6, 7])  # data ~ _inp0: vec[i64]

result(for(iter(_inp0, 1L, 0L, -1L), appender, |b, i, e| merge(b, e)))
// returns [2] = CORRECT
result(for(iter(_inp0, 2L, 0L, -1L), appender, |b, i, e| merge(b, e)))
// returns [<some random number>, <some random number>] = RUBBISH
same for start = 3, 4, 5 returning list of 3, 4, 5 random numbers, respectively

result(for(iter(_inp0, 6L, 0L, -1L), appender, |b, i, e| merge(b, e)))
// throws BadIteratorLength, despite 6 being a valid index for the last value

Some checks:

result(for(iter(_inp0, 0L, 7L, 1L), appender, |b, i, e| merge(b, e)))
// returns the same array, so return type or encoding is not broken

// removing vectorize pass (throwback to a previous issue) does NOT solve this

radujica avatar Dec 11 '18 16:12 radujica