1
0
mirror of https://github.com/golang/go synced 2024-09-30 08:18:40 -06:00

disable "any" except during canned imports.

new flag -A enables it during mkbuiltin.
avoids mysterious errors in programs
that refer to any accidentally.

R=ken
OCL=30763
CL=30763
This commit is contained in:
Russ Cox 2009-06-25 16:22:46 -07:00
parent ae11e9eb88
commit 30f2799f88
2 changed files with 14 additions and 1 deletions

View File

@ -9,6 +9,7 @@
#include <ar.h>
extern int yychar;
Sym *anysym;
#define DBG if(!debug['x']);else print
enum
@ -120,6 +121,7 @@ main(int argc, char *argv[])
usage:
print("flags:\n");
// -A is allow use of "any" type, for bootstrapping
print(" -I DIR search for packages in DIR\n");
print(" -d print declarations\n");
print(" -e no limit on number of errors printed\n");
@ -325,6 +327,9 @@ unimportfile(void)
{
linehist(nil, 0, 0);
if(!debug['A'])
anysym->def = nil;
if(curio.bin != nil) {
Bterm(curio.bin);
curio.bin = nil;
@ -341,6 +346,9 @@ cannedimports(char *file, char *cp)
lineno++; // if sys.6 is included on line 1,
linehist(file, 0, 0); // the debugger gets confused
if(!debug['A'])
anysym->def = typenod(types[TANY]);
pushedio = curio;
curio.bin = nil;
curio.peekc = 0;
@ -1296,6 +1304,11 @@ lexinit(void)
types[etype] = t;
}
s->def = typenod(t);
if(etype == TANY) {
anysym = s;
if(!debug['A'])
s->def = nil;
}
continue;
}

View File

@ -15,7 +15,7 @@ gcc -o mkbuiltin1 mkbuiltin1.c
rm -f _builtin.c
for i in sys unsafe
do
$GC $i.go
$GC -A $i.go
./mkbuiltin1 $i >>_builtin.c
done