Commit 5a5799f6 authored by Russ Cox's avatar Russ Cox

gc: more precise handling of import .

Fixes #455.

R=ken2
CC=golang-dev
https://golang.org/cl/186212
parent 07fc1457
......@@ -149,9 +149,14 @@ testdclstack(void)
void
redeclare(Sym *s, char *where)
{
yyerror("%S redeclared %s\n"
"\tprevious declaration at %L",
s, where, s->lastlineno);
if(s->lastlineno == 0)
yyerror("%S redeclared %s\n"
"\tprevious declaration during import",
s, where);
else
yyerror("%S redeclared %s\n"
"\tprevious declaration at %L",
s, where, s->lastlineno);
}
/*
......
......@@ -1470,9 +1470,9 @@ mkpackage(char* pkg)
if(s->def->op == OPACK) {
// throw away top-level package name leftover
// from previous file.
// TODO(rsc): remember that there was a package
// name, so that the name cannot be redeclared
// as a non-package in other files.
// leave s->block set to cause redeclaration
// errors if a conflicting top-level name is
// introduced by a different file.
if(!s->def->used && !nsyntaxerrors)
yyerrorl(s->def->lineno, "imported and not used: %s", s->def->sym->name);
s->def = N;
......
......@@ -353,6 +353,7 @@ importdot(Sym *opkg, Node *pack)
continue;
}
s1->def = s->def;
s1->block = s->block;
s1->def->pack = pack;
n++;
}
......
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