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:
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");
}
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);
}