]> Cypherpunks repositories - gostls13.git/commitdiff
doc/go1.18: document compiler change for "declared but not used" errors
authorRobert Griesemer <gri@golang.org>
Mon, 22 Nov 2021 20:21:12 +0000 (12:21 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 22 Nov 2021 22:35:57 +0000 (22:35 +0000)
Fixes #49214.
For #47694.

Change-Id: Iba68ed17bfd81890309b6a6732087f87a03e1350
Reviewed-on: https://go-review.googlesource.com/c/go/+/366274
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
doc/go1.18.html

index 61bb8dbbcba315a43300fbd78fa887c8bcc77036..5f94aa86c4141c8dd887be12759cf49cd663a2a5 100644 (file)
@@ -29,6 +29,20 @@ Do not send CLs removing the interior tags from such phrases.
   TODO: complete this section
 </p>
 
+<h3 id="bug_fixes">Bug fixes</h3>
+
+<p>
+  The Go 1.18 compiler now correctly reports <code>declared but not used</code> errors
+  for variables that are set inside a function literal but are never used. Before Go 1.18,
+  the compiler did not report an error in such cases. This fixes long-outstanding compiler
+  issue <a href="https://golang.org/issue/8560">#8560</a>. As a result of this change,
+  (possibly incorrect) programs may not compile anymore. The necessary fix is
+  straightforward: fix the program if it was in fact incorrect, or use the offending
+  variable, for instance by assigning it to the blank identifier <code>_</code>.
+  Since <code>go vet</code> always pointed out this error, the number of affected
+  programs is likely very small.
+</p>
+
 <h3 id="generics">Generics</h3>
 
 <p>