• David Lazar's avatar
    cmd/compile: generate code that type checks when inlining variadic functions · 5d1b53a9
    David Lazar authored
    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/33671Reviewed-by: 's avatarKeith Randall <khr@golang.org>
    5d1b53a9
Name
Last commit
Last update
..
addr2line Loading commit data...
api Loading commit data...
asm Loading commit data...
cgo Loading commit data...
compile Loading commit data...
cover Loading commit data...
dist Loading commit data...
doc Loading commit data...
fix Loading commit data...
go Loading commit data...
gofmt Loading commit data...
internal Loading commit data...
link Loading commit data...
nm Loading commit data...
objdump Loading commit data...
pack Loading commit data...
pprof Loading commit data...
trace Loading commit data...
vendor Loading commit data...
vet Loading commit data...