]> Cypherpunks repositories - gostls13.git/commitdiff
gc: bug243
authorRuss Cox <rsc@golang.org>
Tue, 19 Jan 2010 00:52:18 +0000 (16:52 -0800)
committerRuss Cox <rsc@golang.org>
Tue, 19 Jan 2010 00:52:18 +0000 (16:52 -0800)
Fixes #481.

R=ken2
CC=golang-dev
https://golang.org/cl/186213

src/cmd/gc/dcl.c
test/fixedbugs/bug243.go [new file with mode: 0644]

index adf8da9bc0dd700344695beb96137f8d9bd19343..e8ca1f1f72c19710f212e9dfa325fc76c345fead 100644 (file)
@@ -325,8 +325,10 @@ variter(NodeList *vl, Node *t, NodeList *el)
                        declare(v, dclcontext);
                        v->ntype = t;
                        v->defn = as2;
+                       if(funcdepth > 0)
+                               init = list(init, nod(ODCL, v, N));
                }
-               return list1(as2);
+               return list(init, as2);
        }
        
        for(; vl; vl=vl->next) {
diff --git a/test/fixedbugs/bug243.go b/test/fixedbugs/bug243.go
new file mode 100644 (file)
index 0000000..01112da
--- /dev/null
@@ -0,0 +1,28 @@
+// $G $D/$F.go && $L $F.$A && ./$A.out
+
+// Copyright 2010 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
+
+import (
+       "fmt"
+       "net"
+       "os"
+)
+
+func main() {
+       os.Stdout.Close()
+       var listen, _ = net.Listen("tcp", ":0")
+
+       go func() {
+               for {
+                       var conn, _ = listen.Accept()
+                       fmt.Println("[SERVER] ", conn)
+               }
+       }()
+
+       var conn, _ = net.Dial("tcp", "", listen.Addr().String())
+       fmt.Println("[CLIENT] ", conn)
+}