Skip to content

Commit

Permalink
Merge branch 'main' into feat-min/max/sum/avg
Browse files Browse the repository at this point in the history
  • Loading branch information
phorward committed Nov 9, 2024
2 parents 5729ab1 + 815b1d3 commit e77b996
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/value/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions tests/list_add.tok
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -39,6 +48,10 @@ l

#(1, 2, 3, 4)

#(1, 2, 3)

#(1, 2, 3)

#(1, 2, 3, 4)
#(1, 2)
#(3, 4)
Expand Down

0 comments on commit e77b996

Please sign in to comment.