Skip to content

Commit b7e450b

Browse files
timothy-kingGo LUCI
authored and
Go LUCI
committed
doc/next: document copylock changes
Fixes #66387 Change-Id: Ida9381d1ea83bcceaba460014fac3d0c13ccdbff Reviewed-on: https://go-review.googlesource.com/c/go/+/632315 LUCI-TryBot-Result: Go LUCI <[email protected]> Commit-Queue: Tim King <[email protected]> Reviewed-by: Alan Donovan <[email protected]>
1 parent 2a93bd0 commit b7e450b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

doc/next/3-tools.md

+9
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ with no other arguments. Such calls are nearly always a mistake
4949
as the value of `s` may contain the `%` symbol; use `fmt.Print` instead.
5050
See [#60529](/issue/60529).
5151

52+
<!-- go.dev/issue/66387 -->
53+
The existing `copylock` analyzer now reports a diagnostic when a
54+
variable declared in a 3-clause "for" loop such as
55+
`for i := iter(); done(i); i = next(i) { ... }` contains a `sync.Locker`,
56+
such as a `sync.Mutex`. [Go 1.22](/doc/go1.22#language) changed the behavior
57+
of these loops to create a new variable for each iteration, copying the
58+
value from the previous iteration; this copy operation is not safe for locks.
59+
See [#66387](/issue/66387).
60+
5261
### GOCACHEPROG
5362

5463
<!-- go.dev/issue/64876 -->

0 commit comments

Comments
 (0)