Skip to content

Commit bccbf59

Browse files
ALTreeandybons
authored andcommitted
doc/go1.11: explain new vet typechecking behaviour in release notes
Since Go1.10, go test runs vet on the tests before executing them. Moreover, the vet tool typechecks the package under analysis with go/types before running. In Go1.10, a typechecking failure just caused a warning to be printed. In Go1.11, a typechecking failure will cause vet to exit with a fatal error (see Issue #21287). This means that starting with Go1.11, tests that don't typecheck will fail immediately. This would not normally be an issue, since a test that doesn't typecheck shouldn't even compile, and it should already be broken. Unfortunately, there's a bug in gc that makes it accept programs with unused variables inside a closure (Issue #3059). This means that a test with an unused variable inside a closure, that compiled and passed in Go1.10, will fail in the typechecking step of vet starting with Go1.11. Explain this in the 1.11 release notes. Fixes #26109 Change-Id: I970c1033ab6bc985d8c64bd24f56e854af155f96 Reviewed-on: https://go-review.googlesource.com/121455 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 57b5a71 commit bccbf59

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

doc/go1.11.html

+29
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,35 @@ <h3 id="gocache">Build cache requirement</h2>
157157
please <a href="https://golang.org/issue/new">file an issue</a> to let us know about them.
158158
</p>
159159

160+
<h2 id="tools">Tools</h2>
161+
162+
<h3 id="test">Test</h3>
163+
164+
<p>
165+
Since Go1.10, the <code>go</code>&nbsp;<code>test</code> command runs
166+
<code>go</code>&nbsp;<code>vet</code> on the package being tested,
167+
to identify problems before running the test. Since <code>vet</code>
168+
typechecks the code with <a href="/pkg/go/types/">go/types</a>
169+
before running, tests that do not typecheck will now fail.
170+
171+
In particular, tests that contain an unused variable inside a
172+
closure compiled with Go1.10, because the Go compiler incorrectly
173+
accepted them (<a href="https://golang.org/issues/3059">Issue #3059</a>),
174+
but will now fail, since <code>go/types</code> correctly reports an
175+
"unused variable" error in this case.
176+
</p>
177+
178+
179+
<h3 id="vet">Vet</h3>
180+
181+
<p><!-- CL 108555 -->
182+
The <a href="/cmd/vet/"><code>go</code>&nbsp;<code>vet</code></a>
183+
command now reports a fatal error when the package under analysis
184+
does not typecheck. Previously, a type checking error simply caused
185+
a warning to be printed, and <code>vet</code> to exit with status 1.
186+
</p>
187+
188+
160189
<h2 id="library">Core library</h2>
161190

162191
<p>

0 commit comments

Comments
 (0)