traefik / yaegi

Yaegi is Another Elegant Go Interpreter
https://pkg.go.dev/github.com/traefik/yaegi
Apache License 2.0
7.1k stars 351 forks source link

interp: fix type switch on arbitrary expressions #1445

Closed mvertes closed 2 years ago

mvertes commented 2 years ago

If the value on which to type-switch was already set (i.e. a variable), there was no problem. But if it had to be obtained through a complex expression (func call, array index, etc...), then the code to retrieve the value prior type-switch was not scheduled. This is now fixed.

This issue is nasty because the behavior is silently changed, leading potentially to further unrelated issues or runtime panics.

Fixes #1444.