Commit 535ad8ef authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile: fix check that ensures main.main is a function

The check was previously disallowing package main from even importing
a non-function symbol named "main".

Fixes #24801.

Change-Id: I849b9713890429f0a16860ef16b5dc7e970d04a4
Reviewed-on: https://go-review.googlesource.com/106120
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
parent 80bbad01
......@@ -85,7 +85,7 @@ func declare(n *Node, ctxt Class) {
if s.Name == "init" {
yyerrorl(n.Pos, "cannot declare init - must be func")
}
if s.Name == "main" && localpkg.Name == "main" {
if s.Name == "main" && s.Pkg.Name == "main" {
yyerrorl(n.Pos, "cannot declare main - must be func")
}
externdcl = append(externdcl, n)
......
// Copyright 2018 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 a
type main int
var X main
// Copyright 2018 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
import "./a"
func main() {
a.X = 1
}
// compiledir
// Copyright 2018 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.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment