about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkg/lang/compiler/compiler.go3
-rw-r--r--pkg/lang/compiler/compiler_test.go8
2 files changed, 11 insertions, 0 deletions
diff --git a/pkg/lang/compiler/compiler.go b/pkg/lang/compiler/compiler.go
index 631dfec..d1b98da 100644
--- a/pkg/lang/compiler/compiler.go
+++ b/pkg/lang/compiler/compiler.go
@@ -870,6 +870,9 @@ func (comp *Compiler) compileArrayLitExpr(t *code.Builder, expr ast.ExprArrayLit
 
 		t.AppendOp(code.OpCall)
 		t.AppendInt(1)
+
+		t.AppendOp(code.OpDrop)
+		t.AppendInt(1)
 	}
 
 	return nil
diff --git a/pkg/lang/compiler/compiler_test.go b/pkg/lang/compiler/compiler_test.go
index 9e05230..e40d98e 100644
--- a/pkg/lang/compiler/compiler_test.go
+++ b/pkg/lang/compiler/compiler_test.go
@@ -127,16 +127,20 @@ func TestArrayLit(t *testing.T) {
 	get_member "push"
 	push_int 1
 	call 1
+	drop 1
 
 	get_local 0
 	get_member "push"
 	push_int 2
 	call 1
+	drop 1
 
 	get_local 0
 	get_member "push"
 	push_int 3
 	call 1
+	drop 1
+
 	halt
 	`
 
@@ -372,21 +376,25 @@ func TestForIn(t *testing.T) {
 	get_member "push"
 	push_int 1
 	call 1
+	drop 1
 
 	get_local 0
 	get_member "push"
 	push_int 2
 	call 1
+	drop 1
 
 	get_local 0
 	get_member "push"
 	push_int 3
 	call 1
+	drop 1
 
 	get_local 0
 	get_member "push"
 	push_string "oops"
 	call 1
+	drop 1
 
 	push_int 0
 	push_null