Update dependencies for 1.18.0 release (#1175)
This commit is contained in:
26
vendor/github.com/d5/tengo/v2/vm.go
generated
vendored
26
vendor/github.com/d5/tengo/v2/vm.go
generated
vendored
@@ -537,12 +537,36 @@ func (v *VM) run() {
|
||||
}
|
||||
case parser.OpCall:
|
||||
numArgs := int(v.curInsts[v.ip+1])
|
||||
v.ip++
|
||||
spread := int(v.curInsts[v.ip+2])
|
||||
v.ip += 2
|
||||
|
||||
value := v.stack[v.sp-1-numArgs]
|
||||
if !value.CanCall() {
|
||||
v.err = fmt.Errorf("not callable: %s", value.TypeName())
|
||||
return
|
||||
}
|
||||
|
||||
if spread == 1 {
|
||||
v.sp--
|
||||
switch arr := v.stack[v.sp].(type) {
|
||||
case *Array:
|
||||
for _, item := range arr.Value {
|
||||
v.stack[v.sp] = item
|
||||
v.sp++
|
||||
}
|
||||
numArgs += len(arr.Value) - 1
|
||||
case *ImmutableArray:
|
||||
for _, item := range arr.Value {
|
||||
v.stack[v.sp] = item
|
||||
v.sp++
|
||||
}
|
||||
numArgs += len(arr.Value) - 1
|
||||
default:
|
||||
v.err = fmt.Errorf("not an array: %s", arr.TypeName())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if callee, ok := value.(*CompiledFunction); ok {
|
||||
if callee.VarArgs {
|
||||
// if the closure is variadic,
|
||||
|
||||
Reference in New Issue
Block a user