about summary refs log tree commit diff
path: root/tvix/eval/src/vm.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/vm.rs')
-rw-r--r--tvix/eval/src/vm.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs
index 3afda7a966eb..9a65668caa23 100644
--- a/tvix/eval/src/vm.rs
+++ b/tvix/eval/src/vm.rs
@@ -67,7 +67,19 @@ impl VM {
                     self.push(c);
                 }
 
-                OpCode::OpAdd => arithmetic_op!(self, +),
+                OpCode::OpAdd => {
+                    let b = self.pop();
+                    let a = self.pop();
+
+                    let result = if let (Value::String(s1), Value::String(s2)) = (&a, &b) {
+                        Value::String(s1.concat(s2))
+                    } else {
+                        arithmetic_op!(b, a, +)
+                    };
+
+                    self.push(result)
+                }
+
                 OpCode::OpSub => arithmetic_op!(self, -),
                 OpCode::OpMul => arithmetic_op!(self, *),
                 OpCode::OpDiv => arithmetic_op!(self, /),