mirror of
https://github.com/golang/go.git
synced 2025-10-19 19:13:18 +00:00
Revert "cmd/compile: improve error message if init is directly invoked"
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>
This commit is contained in:
parent
a6bd42f263
commit
cf710949a9
3 changed files with 6 additions and 28 deletions
|
@ -15,7 +15,7 @@ func init() {
|
|||
}
|
||||
|
||||
func main() {
|
||||
init() // ERROR "cannot refer to init functions"
|
||||
init() // ERROR "undefined.*init"
|
||||
runtime.init() // ERROR "unexported.*runtime\.init"
|
||||
var _ = init // ERROR "cannot refer to init functions"
|
||||
var _ = init // ERROR "undefined.*init"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue