mirror of
https://github.com/traefik/yaegi.git
synced 2026-06-01 18:37:56 +00:00
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.
18 lines
203 B
Go
18 lines
203 B
Go
package main
|
|
|
|
func f(params ...interface{}) {
|
|
switch params[0].(type) {
|
|
case string:
|
|
println("a string")
|
|
default:
|
|
println("not a string")
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
f("Hello")
|
|
}
|
|
|
|
// Output:
|
|
// a string
|