]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: disallow embed of var inside func
authorRuss Cox <rsc@golang.org>
Fri, 8 Jan 2021 20:35:19 +0000 (15:35 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 15 Jan 2021 20:37:17 +0000 (20:37 +0000)
commit54198b04dbdf424d8aec922c1f8870ce0e9b7332
tree3c39168d2b93a338f172bb91a2ec00e9df9a6ffb
parentb386c735e7582d08a938ce2bc582f931946854b4
cmd/compile: disallow embed of var inside func

Allowing embedding into []byte inside a func creates an
unfortunate problem: either all calls start with the same
underlying data and can see each other's changes to the
underlying data (surprising and racy!) or all calls start
by making their own copy of the underlying data
(surprising and expensive!).

After discussion on #43216, the consensus was to remove
support for all vars embedded inside functions.

Fixes #43216.

Change-Id: I01e62b5f0dcd9e8566c6d2286218e97803f54704
Reviewed-on: https://go-review.googlesource.com/c/go/+/282714
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/compile/internal/gc/embed.go
src/embed/internal/embedtest/embed_test.go
src/embed/internal/embedtest/embedx_test.go