compiler: emit error for non-byte subslices

They are not supported for now, as VM has only
`SUBSTR` opcode for Buffers (`[]byte` in Go).
This commit is contained in:
Evgenii Stratonikov 2020-09-15 09:52:56 +03:00
parent 3f27cf5901
commit 78948ef7af
2 changed files with 15 additions and 0 deletions

View file

@ -316,6 +316,17 @@ func TestSliceOperations(t *testing.T) {
runTestCases(t, sliceTestCases)
}
func TestSubsliceCompound(t *testing.T) {
src := `package foo
func Main() []int {
a := []int{0, 1, 2, 3}
b := a[1:3]
return b
}`
_, err := compiler.Compile("", strings.NewReader(src))
require.Error(t, err)
}
func TestJumps(t *testing.T) {
src := `
package foo