From 7fbe2f4cc877a02465f36e10e7547e03bcb6e1af Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 22 Nov 2021 12:21:12 -0800 Subject: [PATCH] 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 Run-TryBot: Robert Griesemer TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- doc/go1.18.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/go1.18.html b/doc/go1.18.html index 61bb8dbbcb..5f94aa86c4 100644 --- a/doc/go1.18.html +++ b/doc/go1.18.html @@ -29,6 +29,20 @@ Do not send CLs removing the interior tags from such phrases. TODO: complete this section

+

Bug fixes

+ +

+ The Go 1.18 compiler now correctly reports declared but not used 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 #8560. 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 _. + Since go vet always pointed out this error, the number of affected + programs is likely very small. +

+

Generics

-- 2.50.0