Skip to content

Commit

Permalink
fix runtime not enough arguments to return
Browse files Browse the repository at this point in the history
  • Loading branch information
scottafk committed Dec 31, 2021
1 parent 6ad7155 commit 3d1730b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/script/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,16 @@ main:
rt.blocks = rt.blocks[:len(rt.blocks)-1]
if status == statusReturn {
if last.Block.Type == ObjectType_Func {
for count := len(last.Block.Info.(*FuncInfo).Results); count > 0; count-- {
lastResults := last.Block.Info.(*FuncInfo).Results
if len(lastResults) > len(rt.stack) {
var keyNames []string
for i := 0; i < len(lastResults); i++ {
keyNames = append(keyNames, lastResults[i].String())
}
err = fmt.Errorf("not enough arguments to return, need [%s]", strings.Join(keyNames, "|"))
return
}
for count := len(lastResults); count > 0; count-- {
rt.stack[start] = rt.stack[len(rt.stack)-count]
start++
}
Expand Down

0 comments on commit 3d1730b

Please sign in to comment.