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:
parent
c96be81229
commit
428e789ddc
1 changed files with 5 additions and 1 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue