Commit afea84fc authored by Kevin Modzelewski's avatar Kevin Modzelewski

List slice-self-assignment is currently buggy

Not sure how hard a requirement it is to match CPython's behavior,
but just assert out for now rather than doing something different.

Also add an assert to copySlice, which could have similar issues.
parent 1b64222a
...@@ -210,6 +210,8 @@ extern "C" Box* listSetitemSlice(BoxedList* self, BoxedSlice* slice, Box* v) { ...@@ -210,6 +210,8 @@ extern "C" Box* listSetitemSlice(BoxedList* self, BoxedSlice* slice, Box* v) {
ASSERT(v->cls == list_cls, "unsupported %s", getTypeName(v)->c_str()); ASSERT(v->cls == list_cls, "unsupported %s", getTypeName(v)->c_str());
BoxedList* lv = static_cast<BoxedList*>(v); BoxedList* lv = static_cast<BoxedList*>(v);
RELEASE_ASSERT(self->elts != lv->elts, "Slice self-assignment currently unsupported");
int delts = lv->size - (stop - start); int delts = lv->size - (stop - start);
int remaining_elts = self->size - stop; int remaining_elts = self->size - stop;
self->ensure(delts); self->ensure(delts);
......
...@@ -24,6 +24,7 @@ class BoxedSlice; ...@@ -24,6 +24,7 @@ class BoxedSlice;
void parseSlice(BoxedSlice* slice, int size, i64* out_start, i64* out_stop, i64* out_end, i64* out_length = nullptr); void parseSlice(BoxedSlice* slice, int size, i64* out_start, i64* out_stop, i64* out_end, i64* out_length = nullptr);
template <typename T> void copySlice(T* __restrict__ dst, const T* __restrict__ src, i64 start, i64 step, i64 length) { template <typename T> void copySlice(T* __restrict__ dst, const T* __restrict__ src, i64 start, i64 step, i64 length) {
assert(dst != src);
if (step == 1) { if (step == 1) {
memcpy(dst, &src[start], length * sizeof(T)); memcpy(dst, &src[start], length * sizeof(T));
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment