]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.regabi] test: add another closure test case
authorMatthew Dempsky <mdempsky@google.com>
Fri, 1 Jan 2021 12:51:22 +0000 (04:51 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 1 Jan 2021 13:44:37 +0000 (13:44 +0000)
commitbfa97ba48fa2924d9c2da1dca01fdb65b44cdb5f
treeb7e8ab044abb36437189853407b521392406cd7f
parent67ad695416fbcdf9d61e5bfc0f9cd9aac313caa4
[dev.regabi] test: add another closure test case

When deciding whether a captured variable can be passed by value, the
compiler is sensitive to the order that the OCLOSURE node is
typechecked relative to the order that the variable is passed to
"checkassign". Today, for an assignment like:

    q, g = 2, func() int { return q }

we get this right because we always typecheck the full RHS expression
list before calling checkassign on any LHS expression.

But I nearly made a change that would interleave this ordering,
causing us to call checkassign on q before typechecking the function
literal. And alarmingly, there weren't any tests that caught this.

So this commit adds one.

Change-Id: I66cacd61066c7a229070861a7d973bcc434904cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/280998
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
test/closure2.go