Invalid behaviour with complex variables
Closed this issue · 2 comments
gazerro commented
The following program prints
x: (0+3i)
y: (0+3i)
instead of
x: (0+0i)
y: (0+3i)
package main
import "fmt"
var x complex128
func main() {
x = 3i
y := x
x = 0
fmt.Printf("x: %#v\n", x)
fmt.Printf("y: %#v\n", y)
}
zapateo commented
The problem also applies to variables declared into a function scope:
package main
func main() {
x := 3i
x = 0
println(x)
}
should print:
(+0.000000e+000+0.000000e+000i)
but it prints:
(+0.000000e+000+3.000000e+000i)
gazerro commented
See also:
package main
func main() {
var x int
x = 10 + 0i
println(x)
}