1
0
mirror of https://github.com/golang/go synced 2024-11-11 22:40:22 -07:00

cmd/gc: fix error message for import as 'init'

Fixes #5853.

R=ken2
CC=golang-dev
https://golang.org/cl/11104044
This commit is contained in:
Russ Cox 2013-07-11 22:40:21 -04:00
parent 5930649306
commit 1d4ed0c86b
4 changed files with 349 additions and 323 deletions

View File

@ -197,6 +197,10 @@ import_stmt:
importdot(ipkg, pack);
break;
}
if(strcmp(my->name, "init") == 0) {
yyerror("cannot import package as init - init must be a func");
break;
}
if(my->name[0] == '_' && my->name[1] == '\0')
break;
if(my->def) {

File diff suppressed because it is too large Load Diff

View File

@ -146,7 +146,7 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 28 "go.y"
#line 30 "go.y"
{
Node* node;
NodeList* list;

View File

@ -0,0 +1,9 @@
// errorcheck
// Copyright 2012 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 p
import init "fmt" // ERROR "cannot import package as init - init must be a func"