cmd/compile: prepend captured args to called-closure params
Old code appended, did not play well with a closure
with a ... param.
Fixes #11075.
Change-Id: Ib7c8590c5c4e576e798837e7499e00f3494efb4a
Reviewed-on: https://go-review.googlesource.com/12580
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: David Chase <drchase@google.com>
diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go
index d89d25e..91c0a47 100644
--- a/src/cmd/compile/internal/gc/walk.go
+++ b/src/cmd/compile/internal/gc/walk.go
@@ -609,8 +609,8 @@
// Transform direct call of a closure to call of a normal function.
// transformclosure already did all preparation work.
- // Append captured variables to argument list.
- n.List = concat(n.List, n.Left.Func.Enter)
+ // Prepend captured variables to argument list.
+ n.List = concat(n.Left.Func.Enter, n.List)
n.Left.Func.Enter = nil