You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/go1.22.html
+14-3
Original file line number
Diff line number
Diff line change
@@ -136,9 +136,20 @@ <h3 id="trace">Trace</h3>
136
136
137
137
<h3id="vet">Vet</h3>
138
138
139
-
<!-- <p><\!-- CL 539016 -\-> -->
140
-
<!-- TODO: <a href="https://go.dev/cl/539016">https://go.dev/cl/539016</a>: go/analysis/passes/loopclosure: disable checker after go1.22.; loopclosure was modified to only not report in files with GoVersion after 1.22. -->
141
-
<!-- </p> -->
139
+
<h4id="vet-loopclosure">References to loop variables</h4>
140
+
141
+
<p><!-- CL 539016, https://go.dev/issue/63888: cmd/vet: do not report variable capture for loop variables with the new lifetime rules -->
142
+
The behavior of the <code>vet</code> tool has changed to match
143
+
the new semantics (see above) of loop variables in Go 1.22.
144
+
When analyzing a file that requires Go 1.22 or newer
145
+
(due to its go.mod file or a per-file build constraint),
146
+
<code>vet</code>code> no longer reports references to
147
+
loop variables from within a function literal that
148
+
might outlive the iteration of the loop.
149
+
In Go 1.22, loop variables are created anew for each iteration,
150
+
so such references are no longer at risk of using a variable
151
+
after it has been updated by the loop.
152
+
</p>
142
153
143
154
<h4id="vet-appends">New warnings for missing values after append</h4>
0 commit comments