Commit 1d4ed0c8 authored by Russ Cox's avatar Russ Cox

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

Fixes #5853.

R=ken2
CC=golang-dev
https://golang.org/cl/11104044
parent 59306493
...@@ -197,6 +197,10 @@ import_stmt: ...@@ -197,6 +197,10 @@ import_stmt:
importdot(ipkg, pack); importdot(ipkg, pack);
break; 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') if(my->name[0] == '_' && my->name[1] == '\0')
break; break;
if(my->def) { if(my->def) {
......
This diff is collapsed.
...@@ -146,7 +146,7 @@ ...@@ -146,7 +146,7 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE
#line 28 "go.y" #line 30 "go.y"
{ {
Node* node; Node* node;
NodeList* list; NodeList* list;
......
// 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"
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