mirror of
https://github.com/golang/go
synced 2024-11-23 05:10:09 -07:00
ffc0573b85
The error message is now positioned at the statement position (which is an identifing token, such as the '=' for assignments); and in case of assignments it emphasizes the assignment by putting the Lhs and Rhs in parentheses. Finally, the wording is changed from "use of * as value" to the stronger "cannot use * as value" (for which there is precedent elsewhere in the parser). Fixes #36858. Change-Id: Ic3f101bba50f58e3a1d9b29645066634631f2d61 Reviewed-on: https://go-review.googlesource.com/c/go/+/218337 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
22 lines
477 B
Go
22 lines
477 B
Go
// errorcheck
|
|
|
|
// Copyright 2017 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Make sure error message for invalid conditions
|
|
// or tags are consistent with earlier Go versions.
|
|
|
|
package p
|
|
|
|
func _() {
|
|
if a := 10 { // ERROR "cannot use a := 10 as value"
|
|
}
|
|
|
|
for b := 10 { // ERROR "cannot use b := 10 as value"
|
|
}
|
|
|
|
switch c := 10 { // ERROR "cannot use c := 10 as value"
|
|
}
|
|
}
|