gc: line number + type checking nits
Fixes #1910.
Fixes #1979.
Fixes #1990.
Fixes #1993.
Fixes #2089.
R=ken2
CC=golang-dev
https://golang.org/cl/4828046
diff --git a/src/cmd/gc/go.y b/src/cmd/gc/go.y
index 36b549d..4c7fe60 100644
--- a/src/cmd/gc/go.y
+++ b/src/cmd/gc/go.y
@@ -1249,7 +1249,10 @@
$$ = closurebody($3);
fixlbrace($2);
}
-
+| fnlitdcl error
+ {
+ $$ = closurebody(nil);
+ }
/*
* lists of things
diff --git a/src/cmd/gc/lex.c b/src/cmd/gc/lex.c
index 24a244e..29b6d27 100644
--- a/src/cmd/gc/lex.c
+++ b/src/cmd/gc/lex.c
@@ -254,7 +254,7 @@
resumetypecopy();
resumecheckwidth();
- for(l=xtop; l; l=l->next)
+ for(l=xtop; l; l=l->next) {
if(l->n->op == ODCLFUNC || l->n->op == OCLOSURE) {
curfn = l->n;
saveerrors();
@@ -262,7 +262,12 @@
if(nerrors != 0)
l->n->nbody = nil; // type errors; do not compile
}
+ }
+
curfn = nil;
+
+ if(nsavederrors+nerrors)
+ errorexit();
for(l=xtop; l; l=l->next)
if(l->n->op == ODCLFUNC)
diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c
index 81b9dd2..78cdb5b 100644
--- a/src/cmd/gc/typecheck.c
+++ b/src/cmd/gc/typecheck.c
@@ -146,17 +146,18 @@
case OPACK:
break;
default:
+ lineno = lno;
return n;
}
}
if(n->typecheck == 2) {
yyerror("typechecking loop");
+ lineno = lno;
return n;
}
n->typecheck = 2;
- lno = setlineno(n);
if(n->sym) {
if(n->op == ONAME && n->etype != 0 && !(top & Ecall)) {
yyerror("use of builtin %S not in function call", n->sym);