vm: don't panic if there is no result in PopResult()

This function is intended to be ran outside of the execute's panic recovery
mechanism, so it shouldn't panic if there is no result.
This commit is contained in:
Roman Khimov 2019-10-03 16:02:15 +03:00
parent a357d99624
commit 705c7f106f

View file

@ -187,7 +187,11 @@ func (v *VM) Context() *Context {
// PopResult is used to pop the first item of the evaluation stack. This allows
// us to test compiler and vm in a bi-directional way.
func (v *VM) PopResult() interface{} {
return v.estack.Pop().value.Value()
e := v.estack.Pop()
if e != nil {
return e.Value()
}
return nil
}
// Stack returns json formatted representation of the given stack.