oldfn = curfn;
typecheck(&func->ntype, Etype);
func->type = func->ntype->type;
+ if(curfn == nil) {
+ xtop = list(xtop, func);
+ return;
+ }
+
if(func->type != T) {
curfn = func;
typechecklist(func->nbody, Etop);
resumecheckwidth();
for(l=xtop; l; l=l->next)
- if(l->n->op == ODCLFUNC) {
+ if(l->n->op == ODCLFUNC || l->n->op == OCLOSURE) {
curfn = l->n;
saveerrors();
typechecklist(l->n->nbody, Etop);
while(closures) {
l = closures;
closures = nil;
- for(; l; l=l->next)
+ for(; l; l=l->next) {
funccompile(l->n, 1);
+ }
}
for(l=externdcl; l; l=l->next)
--- /dev/null
+// $G $D/$F.go && $L $F.$A && ./$A.out
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+var f = func() int {
+ type S int
+ return 42
+}
+
+func main() {
+ if f() != 42 {
+ panic("BUG: bug355")
+ }
+}