mirror of
https://github.com/golang/go
synced 2024-11-11 22:10:22 -07:00
cf710949a9
This reverts commit cb6e0639fb
.
The fix is incorrect as it's perfectly fine to refer to an
identifier 'init' inside a function, and 'init' may even be
a variable of function value. Misspelling 'init' in that
context would lead to an incorrect error message.
Reopened #8481.
Change-Id: I49787fdf7738213370ae6f0cab54013e9e3394a8
Reviewed-on: https://go-review.googlesource.com/37876
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
22 lines
451 B
Go
22 lines
451 B
Go
// errorcheck
|
|
|
|
// 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.
|
|
|
|
// Verify that erroneous use of init is detected.
|
|
// Does not compile.
|
|
|
|
package main
|
|
|
|
import "runtime"
|
|
|
|
func init() {
|
|
}
|
|
|
|
func main() {
|
|
init() // ERROR "undefined.*init"
|
|
runtime.init() // ERROR "unexported.*runtime\.init"
|
|
var _ = init // ERROR "undefined.*init"
|
|
}
|