From d042ab2aa9e6c4f1382385fc51b53305d0dd7171 Mon Sep 17 00:00:00 2001 From: HyeockJinKim Date: Sun, 8 Sep 2019 04:26:04 +0900 Subject: [PATCH] Clone other to prevent borrow error Clone other to prevent borrow error when self iadd to itself from list Fixes #1351 --- vm/src/obj/objlist.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vm/src/obj/objlist.rs b/vm/src/obj/objlist.rs index eb141991a..1f3b1c953 100644 --- a/vm/src/obj/objlist.rs +++ b/vm/src/obj/objlist.rs @@ -146,9 +146,8 @@ impl PyListRef { fn iadd(self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult { if objtype::isinstance(&other, &vm.ctx.list_type()) { - self.elements - .borrow_mut() - .extend_from_slice(&get_elements_list(&other)); + let e = get_elements_list(&other).clone(); + self.elements.borrow_mut().extend_from_slice(&e); Ok(self.into_object()) } else { Ok(vm.ctx.not_implemented())