mirror of
https://github.com/hanzoai/yaegi.git
synced 2026-10-01 00:49:47 +00:00
* interp: fix handling of redeclaration in multi-assign expression In a statement like `a, b := f()` if `a` was previously declared, its symbol must be reused, a new symbol must not override its previous value. This is now fixed. * In case of redeclaration, reuse the existing only if the redeclared variable has the same type. Add _test/var16.go to check this use case. Fixes #1365.
19 lines
208 B
Go
19 lines
208 B
Go
package main
|
|
|
|
func genInt() (int, error) { return 3, nil }
|
|
|
|
func getInt() (value int) {
|
|
value, err := genInt()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return
|
|
}
|
|
|
|
func main() {
|
|
println(getInt())
|
|
}
|
|
|
|
// Output:
|
|
// 3
|