aboutsummaryrefslogtreecommitdiff
path: root/test/init.go
diff options
context:
space:
mode:
authorEmmanuel Odeke <emm.odeke@gmail.com>2017-01-01 03:08:48 -0700
committerMatthew Dempsky <mdempsky@google.com>2017-02-02 05:55:03 +0000
commitcb6e0639fb090ea0e129b1ddb956a7e645cff285 (patch)
tree085ff7b4b7e603a3f35601a9dd04b02ed2d9dad0 /test/init.go
parentdbd51ce99c140766808c17b334b8795b8040c0b3 (diff)
downloadgo-cb6e0639fb090ea0e129b1ddb956a7e645cff285.tar.gz
go-cb6e0639fb090ea0e129b1ddb956a7e645cff285.zip
cmd/compile: improve error message if init is directly invoked
Fixes #8481. Inform the user that init functions cannot be directly invoked in user code, as mandated by the spec at: http://golang.org/ref/spec#Program_initialization_and_execution. Change-Id: Ib12c0c08718ffd48b76b6f9b13c76bb6612d2e7b Reviewed-on: https://go-review.googlesource.com/34790 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'test/init.go')
-rw-r--r--test/init.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/init.go b/test/init.go
index f4689443cf..1855b4ff56 100644
--- a/test/init.go
+++ b/test/init.go
@@ -15,7 +15,7 @@ func init() {
}
func main() {
- init() // ERROR "undefined.*init"
+ init() // ERROR "cannot refer to init functions"
runtime.init() // ERROR "unexported.*runtime\.init"
- var _ = init // ERROR "undefined.*init"
+ var _ = init // ERROR "cannot refer to init functions"
}