]> Cypherpunks repositories - gostls13.git/commitdiff
go/token, syscall: annotate if blocks that defeat vet's unreachable pass
authorDmitri Shuralyov <dmitshur@golang.org>
Wed, 10 Sep 2025 14:55:19 +0000 (10:55 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 10 Sep 2025 15:29:00 +0000 (08:29 -0700)
Since putting code in an "if true" block is unusual, make it easier
for readers to understand the purpose of doing this.

For #73998.

Change-Id: I3fd8d65130211c7c01d424366a3c662482d80add
Reviewed-on: https://go-review.googlesource.com/c/go/+/702416
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/go/token/tree.go
src/syscall/env_unix_test.go

index 2354ad0f330e1fa38e0ae96208b8d8da8c14352f..7ba927c6060e194bfda3fe313056035b5e367c54 100644 (file)
@@ -325,7 +325,7 @@ func (t *tree) set(file *File, pos **node, parent *node) {
                // This code path isn't currently needed
                // because FileSet never updates an existing entry.
                // Remove this assertion if things change.
-               if true {
+               if true { // defeat vet's unreachable pass
                        panic("unreachable according to current FileSet requirements")
                }
                x.file = file
@@ -346,7 +346,7 @@ func (t *tree) delete(pos **node) {
                // This code path isn't currently needed because FileSet
                // only calls delete after a positive locate.
                // Remove this assertion if things change.
-               if true {
+               if true { // defeat vet's unreachable pass
                        panic("unreachable according to current FileSet requirements")
                }
                return
index de9935a40ad7f0f1b8dbcaf01de5c763e8ea44b6..b44b5b1e178d3ac9f930cfa7f62b7fa8fb321e28 100644 (file)
@@ -96,7 +96,7 @@ func TestClearenv(t *testing.T) {
                        defer func() {
                                ret = recover()
                        }()
-                       if true {
+                       if true { // defeat vet's unreachable pass
                                panic(nil)
                        }
                        return "should not return"