vm: produce better error for ROLL with wrong index

Current VM implementation doesn't return errors for many operations, so the
only way to handle it here is to check for NULL. Refs. #96.
This commit is contained in:
Roman Khimov 2019-08-31 09:04:59 +03:00
parent c96be81229
commit 428e789ddc

View file

@ -342,7 +342,11 @@ func (v *VM) execute(ctx *Context, op Instruction) {
panic("negative stack item returned")
}
if n > 0 {
v.estack.Push(v.estack.RemoveAt(n))
e := v.estack.RemoveAt(n)
if e == nil {
panic("bad index")
}
v.estack.Push(e)
}
case DROP: