]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: allow embed into any string or byte slice type
authorRuss Cox <rsc@golang.org>
Fri, 8 Jan 2021 19:27:00 +0000 (14:27 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 15 Jan 2021 20:37:59 +0000 (20:37 +0000)
commitec9470162f26819abd7b7bb86dd36cfe87f7f5bc
tree329c105fd6c4ea87246b0d7475cdff0340f9e17b
parent54198b04dbdf424d8aec922c1f8870ce0e9b7332
cmd/compile: allow embed into any string or byte slice type

The current implementation requires saying "string" or "[]byte"
and disallows aliases, defined types, and even "[]uint8".
This was not 100% intended and mostly just fell out of when
the checks were being done in the implementation (too early,
before typechecking).

After discussion on #43217 (forked into #43602),
the consensus was to allow all string and byte slice types,
same as we do for string conversions in the language itself.
This CL does that.

It's more code than you'd expect because the decision has
to be delayed until after typechecking.

But it also more closely aligns with the version that's
already on dev.regabi.

Fixes #43602.

Change-Id: Iba919cfadfbd5d7116f2bf47e2512fb1d5c36731
Reviewed-on: https://go-review.googlesource.com/c/go/+/282715
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/compile/internal/gc/embed.go
src/cmd/compile/internal/gc/noder.go
src/cmd/compile/internal/gc/syntax.go