mirror of
https://github.com/golang/go
synced 2024-11-21 18:34:44 -07:00
gc, ld: package name main no longer reserved
R=ken2 CC=golang-dev https://golang.org/cl/4128054
This commit is contained in:
parent
eff1952873
commit
c1a695c160
@ -242,14 +242,6 @@ import_package:
|
||||
|
||||
if(safemode && !curio.importsafe)
|
||||
yyerror("cannot import unsafe package %Z", importpkg->path);
|
||||
|
||||
// NOTE(rsc): This is no longer a technical restriction:
|
||||
// the 6g tool chain would work just fine without giving
|
||||
// special meaning to a package being named main.
|
||||
// Other implementations might need the restriction
|
||||
// (gccgo does), so it stays in the language and the compiler.
|
||||
if(strcmp($2->name, "main") == 0)
|
||||
yyerror("cannot import package main");
|
||||
}
|
||||
|
||||
import_safety:
|
||||
|
@ -423,6 +423,15 @@ importfile(Val *f, int line)
|
||||
errorexit();
|
||||
}
|
||||
|
||||
// The package name main is no longer reserved,
|
||||
// but we reserve the import path "main" to identify
|
||||
// the main package, just as we reserve the import
|
||||
// path "math" to identify the standard math package.
|
||||
if(strcmp(f->u.sval->s, "main") == 0) {
|
||||
yyerror("cannot import \"main\"");
|
||||
errorexit();
|
||||
}
|
||||
|
||||
if(strcmp(f->u.sval->s, "unsafe") == 0) {
|
||||
if(safemode) {
|
||||
yyerror("cannot import package unsafe");
|
||||
|
@ -148,8 +148,6 @@ ldpkg(Biobuf *f, char *pkg, int64 len, char *filename, int whence)
|
||||
}
|
||||
if(strcmp(pkg, "main") == 0 && strcmp(name, "main") != 0)
|
||||
fprint(2, "%s: %s: not package main (package %s)\n", argv0, filename, name);
|
||||
else if(strcmp(pkg, "main") != 0 && strcmp(name, "main") == 0)
|
||||
fprint(2, "%s: %s: importing %s, found package main", argv0, filename, pkg);
|
||||
loadpkgdata(filename, pkg, p0, p1 - p0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user