Fix: stop execution when trying to slice an unsupported type (#443)
This commit is contained in:
parent
47062da36a
commit
c461a7fe60
2 changed files with 2 additions and 0 deletions
1
vm.go
1
vm.go
|
@ -536,6 +536,7 @@ func (v *VM) run() {
|
|||
v.sp++
|
||||
default:
|
||||
v.err = fmt.Errorf("not indexable: %s", left.TypeName())
|
||||
return
|
||||
}
|
||||
case parser.OpCall:
|
||||
numArgs := int(v.curInsts[v.ip+1])
|
||||
|
|
|
@ -3638,6 +3638,7 @@ func TestSliceIndex(t *testing.T) {
|
|||
expectError(t, `undefined[:1]`, nil, "Runtime Error: not indexable")
|
||||
expectError(t, `123[-1:2]`, nil, "Runtime Error: not indexable")
|
||||
expectError(t, `{}[:]`, nil, "Runtime Error: not indexable")
|
||||
expectError(t, `a := 123[-1:2] ; a += 1`, nil, "Runtime Error: not indexable")
|
||||
}
|
||||
|
||||
func expectRun(
|
||||
|
|
Loading…
Reference in a new issue