You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a difference in the last output line with a prefix "defer": i expect to see the same array as in the previous line with a prefix "plain5", because, as i understand, defer must run after all commands and output the latest state of slice (even after append). And it's confusing to see the same pointer address of the slice in all output lines.
defer captures the value of aby value, that is, it makes a copy of a, thus changes to a later on are not reflected in the slice header captured by defer.
Unlike many projects on GitHub, the Go project does not use its bug tracker for general discussion or asking questions. We only use our bug tracker for tracking bugs and tracking proposals going through the Proposal Process. I'm going to close this issue as it is not a bug in Go.
What version of Go are you using (
go version
)?go version go1.8 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?What did you do?
https://play.golang.org/p/Uc6u33BOLjd
What did you expect to see?
I expect to see such output:
There is a difference in the last output line with a prefix "defer": i expect to see the same array as in the previous line with a prefix "plain5", because, as i understand, defer must run after all commands and output the latest state of slice (even after append). And it's confusing to see the same pointer address of the slice in all output lines.
What did you see instead?
In the defer output I see not the last state of the slice, but slice has the same address in all output lines.
The text was updated successfully, but these errors were encountered: