Skip to content

Commit

Permalink
fix: object iadd call with standalone imutable
Browse files Browse the repository at this point in the history
  • Loading branch information
phorward committed Oct 17, 2024
1 parent 287bff3 commit 530a8ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/value/refvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ impl RefValue {
// When a type name was emitted, try to call builtin-function for operation
if let Some(name) = name {
match Builtin::get_method(name, op) {
Ok(builtin) => return Ok(builtin.call(None, vec![self, operand])?.unwrap()),
Ok(builtin) => return Ok(builtin.call(None, vec![self, operand.ref_or_copy()])?.unwrap()),
// default "inline" operation is the non-inline operation assigning the result to itself
Err(_) if op.starts_with("i") => {}
Err(err) => return Err(err),
Expand Down
18 changes: 18 additions & 0 deletions tests/list_add.tok
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ l = (1,)
l + (2, 3)
l

# iadd with imutable object
l = ,
i = 0
l += i
l, ++i

# iadd with mutable object
l = ,
m = 1,2,3
l += m
l += m,
m += 4
l

#---

#(1, 2, 3, 4)
Expand All @@ -33,3 +47,7 @@ l

#(1, 2, 3)
#(1, )

#((0, ), 1)

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

0 comments on commit 530a8ad

Please sign in to comment.