diff options
| author | David Lazar <lazard@golang.org> | 2016-11-28 17:39:31 -0500 |
|---|---|---|
| committer | David Lazar <lazard@golang.org> | 2016-11-30 19:46:00 +0000 |
| commit | 5d1b53a944a415205a945f4ddd89a0af8e9f114f (patch) | |
| tree | 5f380bad916b6ecd619e2c819b7015c76c0b588a /src/encoding/binary/binary.go | |
| parent | 01dda422520e05e26ed98629b735038d7f22678c (diff) | |
| download | go-5d1b53a944a415205a945f4ddd89a0af8e9f114f.tar.xz | |
cmd/compile: generate code that type checks when inlining variadic functions
This fixes a bug in -l=3 or higher.
To inline a variadic function, the compiler generates code that constructs
a slice of arguments for the variadic parameter. Consider the function
func Foo(xs ...string)
and the call Foo("hello", "world"). To inline the call to Foo, the
compiler used to generate
xs := [2]string{"hello", "world"}[:]
which doesn't type check:
invalid operation [2]string literal[:] (slice of unaddressable value).
Now, the compiler generates
xs := []string{"hello", "world"}
which does type check.
Fixes #18116.
Change-Id: I0ee531ef2e6cc276db6fb12602b25a46d6d5db21
Reviewed-on: https://go-review.googlesource.com/33671
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/encoding/binary/binary.go')
0 files changed, 0 insertions, 0 deletions
