doc/go1.18: document compiler change for "declared but not used" errors

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>
This commit is contained in:
Robert Griesemer 2021-11-22 12:21:12 -08:00
parent 11972353a6
commit 7fbe2f4cc8
1 changed files with 14 additions and 0 deletions

View 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>