From f310dca44c6aef5f54b0a7a0cd1f0a0a5cc57376 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 27 Jul 2011 19:31:11 -0400 Subject: gc: top-level closure bug Fixes issue 2055. R=ken2 CC=golang-dev http://codereview.appspot.com/4816059 --- src/cmd/gc/closure.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/cmd/gc/closure.c') diff --git a/src/cmd/gc/closure.c b/src/cmd/gc/closure.c index 7e7b40526..1261eefb7 100644 --- a/src/cmd/gc/closure.c +++ b/src/cmd/gc/closure.c @@ -84,6 +84,11 @@ typecheckclosure(Node *func, int top) 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); -- cgit v1.2.1