diff options
author | Robert Griesemer <gri@golang.org> | 2017-03-06 15:41:56 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2017-03-06 23:48:37 +0000 |
commit | cf710949a98aaac48a3d97660f7f6bb7d14f1ad7 (patch) | |
tree | 0fec9266ae87fede63581903de386346cd60423d /test | |
parent | a6bd42f2630aa8907009a1ec0c35048c20a7afae (diff) | |
download | go-git-cf710949a98aaac48a3d97660f7f6bb7d14f1ad7.tar.gz |
Revert "cmd/compile: improve error message if init is directly invoked"
This reverts commit cb6e0639fb090ea0e129b1ddb956a7e645cff285.
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>
Diffstat (limited to 'test')
-rw-r--r-- | test/fixedbugs/issue8481.go | 14 | ||||
-rw-r--r-- | test/init.go | 4 |
2 files changed, 2 insertions, 16 deletions
diff --git a/test/fixedbugs/issue8481.go b/test/fixedbugs/issue8481.go deleted file mode 100644 index a69296687a..0000000000 --- a/test/fixedbugs/issue8481.go +++ /dev/null @@ -1,14 +0,0 @@ -// errorcheck - -// Copyright 2016 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 main - -func init() { -} - -func main() { - init() // ERROR "cannot refer to init functions" -} diff --git a/test/init.go b/test/init.go index 1855b4ff56..f4689443cf 100644 --- a/test/init.go +++ b/test/init.go @@ -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" } |