This is a gofrontend copy of https://golang.org/cl/203282.
From the CL 203282 description:
"declared and not used" is technically correct, but might confuse
the user. Switching "and" to "but" will hopefully create the
contrast for the users: they did one thing (declaration), but
not the other --- actually using the variable.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/273629
-720b8fed93143f284ca04358e1b13c8a3487281e
+6b01f8cdc11d86bd98165c91d6ae101bcf6b9e1a
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
&& !var->type()->is_error()
&& (init == NULL || !init->is_error_expression())
&& !Lex::is_invalid_identifier(named_object->name()))
- go_error_at(var->location(), "%qs declared and not used",
+ go_error_at(var->location(), "%qs declared but not used",
named_object->message_name().c_str());
}
return TRAVERSE_CONTINUE;
}
}
if (!used)
- go_error_at(type_switch.location, "%qs declared and not used",
+ go_error_at(type_switch.location, "%qs declared but not used",
Gogo::message_name(var_name).c_str());
}
return statement;
// errorcheck
-// Copyright 2011 The Go Authors. All rights reserved.
+// Copyright 2011 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.
package foo
func f(x interface{}) {
- switch t := x.(type) { // ERROR "declared and not used"
+ switch t := x.(type) { // ERROR "declared but not used"
case int:
}
}
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Verify that various erroneous type switches are caught be the compiler.
+// Verify that various erroneous type switches are caught by the compiler.
// Does not compile.
package main
w()
}:
return "rw"
- case interface { // GCCGO_ERROR "duplicate"
+ case interface { // ERROR "duplicate"
w()
r()
- }: // GC_ERROR "duplicate"
+ }:
return "wr"
}
return ""
}
-
-func notused(x interface{}) {
- // The first t is in a different scope than the 2nd t; it cannot
- // be accessed (=> declared and not used error); but it is legal
- // to declare it.
- switch t := 0; t := x.(type) { // ERROR "declared and not used"
- case int:
- _ = t // this is using the t of "t := x.(type)"
- }
-}