From afb8ae0018a5947d5e33c9f59d31c5009028e79d Mon Sep 17 00:00:00 2001 From: Mel Date: Mon, 29 Aug 2022 23:50:06 +0000 Subject: Clone element when pushing to array --- pkg/lang/modules/core/natives.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'pkg/lang/modules/core') diff --git a/pkg/lang/modules/core/natives.go b/pkg/lang/modules/core/natives.go index 8a24663..7fc9a01 100644 --- a/pkg/lang/modules/core/natives.go +++ b/pkg/lang/modules/core/natives.go @@ -90,6 +90,11 @@ var Natives = []any{ } element := args[1] + element, err = element.Clone(exe.Mem()) + if err != nil { + return value.Value{}, err + } + return value.Value{}, array.Push(exe.Mem(), element) }), n(":core:Array:pop", 1, func(exe executor.Exectutor, args []value.Value) (value.Value, error) { -- cgit 1.4.1