Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment statement compile panic #1606

Open
chikaku opened this issue Jan 25, 2024 · 0 comments · May be fixed by #1607
Open

Assignment statement compile panic #1606

chikaku opened this issue Jan 25, 2024 · 0 comments · May be fixed by #1607

Comments

@chikaku
Copy link

chikaku commented Jan 25, 2024

The following program sample.go triggers an unexpected result

package main

import "github.com/traefik/yaegi/interp"

const code = `
package main

func main() {
	a, b, c := 1, 2
	_, _, _ = a, b, c
}
`

func main() {
	i := interp.New(interp.Options{})
	_, err := i.Compile(code)
	println("err:", err.Error())
}

Expected result

err: cannot assign 2 values to 3 variables

Got

panic: runtime error: index out of range [5] with length 5 [recovered]
        panic: 5:2: CFG post-order panic: runtime error: index out of range [5] with length 5

goroutine 1 [running]:
github.com/traefik/yaegi/interp.(*Interpreter).cfg.func2.1()
        /gopath/pkg/mod/github.com/traefik/yaegi@v0.15.1/interp/cfg.go:601 +0x74
panic({0x12b0620?, 0xc0000a8090?})
        /usr/local/go/src/runtime/panic.go:920 +0x270
github.com/traefik/yaegi/interp.(*Interpreter).cfg.func2(0xc0000eb040)
        /gopath/pkg/mod/github.com/traefik/yaegi@v0.15.1/interp/cfg.go:642 +0x9bc5
github.com/traefik/yaegi/interp.(*node).Walk(0xc0000eb040, 0xc0000f5cc8, 0xc0000f5d10)

Yaegi Version

v0.15.1

Additional Notes

No response

chikaku added a commit to chikaku/yaegi that referenced this issue Jan 25, 2024
@ldez ldez linked a pull request Apr 2, 2024 that will close this issue
ldez pushed a commit to chikaku/yaegi that referenced this issue Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant