diff --git a/src/value/list.rs b/src/value/list.rs index 5b915bd..eb95f2d 100644 --- a/src/value/list.rs +++ b/src/value/list.rs @@ -165,7 +165,11 @@ impl List { // In case list is not a list, make it a list. if !list.is("list") { let item = RefValue::from(list.borrow().clone()); - list = Self::list(vec![item], None)?; + if item.is_void() { + *(list.borrow_mut()) = Self::list(vec![], None)?.into(); + } else { + *(list.borrow_mut()) = Self::list(vec![item], None)?.into(); + } } // Extend in-place when possible. diff --git a/tests/list_add.tok b/tests/list_add.tok index 19761a5..9659523 100644 --- a/tests/list_add.tok +++ b/tests/list_add.tok @@ -6,6 +6,15 @@ l += 2 l += (3, 4) l +# iadd with void +x += (1,2,3) +x + +# iadd with int +i = 1 +i += (2,3) +i + # iadd to itself a = (1,2) b = (3,4) @@ -39,6 +48,10 @@ l #(1, 2, 3, 4) +#(1, 2, 3) + +#(1, 2, 3) + #(1, 2, 3, 4) #(1, 2) #(3, 4)