Let's try appending just one more item before redoing ^ that example, where they all shared the same data: https://go.dev/play/p/5JneXHMeUjx
[a b c]
[z b c x x2]
[a b c y y2]
Notice that in all of these examples, I haven't explicitly declared a length or capacity. There's nothing "funny looking" or clearly intentionally allowing these different behaviors, it's just simple, very-common slice use.
.... so yeah. This is a source of a number of hard-to-track-down bugs.
It does exactly that, yes: https://go.dev/play/p/rs2FeK_QUjs
But maybe it doesn't: https://go.dev/play/p/Na-eL0sOV9e So... maybe they share the same backing array? Lets try setting s2[0] to "z" after appending with the original code: https://go.dev/play/p/mAB-gUb0shB Apparently not. But also apparently yes? https://go.dev/play/p/k1ciGzyS2gc Let's try appending just one more item before redoing ^ that example, where they all shared the same data: https://go.dev/play/p/5JneXHMeUjx Notice that in all of these examples, I haven't explicitly declared a length or capacity. There's nothing "funny looking" or clearly intentionally allowing these different behaviors, it's just simple, very-common slice use..... so yeah. This is a source of a number of hard-to-track-down bugs.