From: Tim King Date: Tue, 19 Dec 2023 18:08:00 +0000 (-0800) Subject: doc/go1.22: document changes to vet loopclosure analyzer X-Git-Tag: go1.22rc2~8^2~25 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=adec22b9f7c9d9cfb95ff6af1c63ec489d6e9bb8;p=gostls13.git doc/go1.22: document changes to vet loopclosure analyzer cmd/vet no longer reports loopclosure bugs within files built at GoVersion>=1.22. For #61422. Change-Id: I6f29373bb236822ece4e7ae35914859538b8d57b Reviewed-on: https://go-review.googlesource.com/c/go/+/551376 LUCI-TryBot-Result: Go LUCI Reviewed-by: Alan Donovan Run-TryBot: Tim King TryBot-Result: Gopher Robot --- diff --git a/doc/go1.22.html b/doc/go1.22.html index 951a8e3160..5aa0a3f54d 100644 --- a/doc/go1.22.html +++ b/doc/go1.22.html @@ -136,9 +136,20 @@ packages that do not have their own test files. Prior to Go 1.22 a

Vet

- - - +

References to loop variables

+ +

+ The behavior of the vet tool has changed to match + the new semantics (see above) of loop variables in Go 1.22. + When analyzing a file that requires Go 1.22 or newer + (due to its go.mod file or a per-file build constraint), + vetcode> no longer reports references to + loop variables from within a function literal that + might outlive the iteration of the loop. + In Go 1.22, loop variables are created anew for each iteration, + so such references are no longer at risk of using a variable + after it has been updated by the loop. +

New warnings for missing values after append