From f327a05419860a782c81a0d57a2e8fb9c517a1d1 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Wed, 10 Sep 2025 10:55:19 -0400 Subject: [PATCH] go/token, syscall: annotate if blocks that defeat vet's unreachable pass 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 Auto-Submit: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov LUCI-TryBot-Result: Go LUCI --- src/go/token/tree.go | 4 ++-- src/syscall/env_unix_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/go/token/tree.go b/src/go/token/tree.go index 2354ad0f33..7ba927c606 100644 --- a/src/go/token/tree.go +++ b/src/go/token/tree.go @@ -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 diff --git a/src/syscall/env_unix_test.go b/src/syscall/env_unix_test.go index de9935a40a..b44b5b1e17 100644 --- a/src/syscall/env_unix_test.go +++ b/src/syscall/env_unix_test.go @@ -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" -- 2.52.0