]> Cypherpunks repositories - gostls13.git/commitdiff
gc: more graceful errors during struct definition
authorRuss Cox <rsc@golang.org>
Fri, 29 Jul 2011 00:41:18 +0000 (20:41 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 29 Jul 2011 00:41:18 +0000 (20:41 -0400)
Fixes #2110.

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

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

index ba1aa83888f2c456572b58bd24182fbec06680ec..5bfeeb97aa5d9abbdabecee86fa677623be12abc 100644 (file)
@@ -746,10 +746,8 @@ stotype(NodeList *l, int et, Type **t, int funarg)
                        } else {
                                typecheck(&n->right, Etype);
                                n->type = n->right->type;
-                               if(n->type == T) {
-                                       *t0 = T;
-                                       return t0;
-                               }
+                               if(n->type == T)
+                                       continue;
                                if(left != N)
                                        left->type = n->type;
                                n->right = N;
diff --git a/test/fixedbugs/bug365.go b/test/fixedbugs/bug365.go
new file mode 100644 (file)
index 0000000..7ec19b0
--- /dev/null
@@ -0,0 +1,22 @@
+// errchk $G $D/$F.go
+
+// 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.
+
+// check that compiler doesn't stop reading struct def
+// after first unknown type.
+
+// Fixes issue 2110.
+
+package main
+
+type S struct {
+       err os.Error  // ERROR "undefined"
+       Num int
+}
+
+func main() {
+       s := S{}
+       _ = s.Num  // no error here please
+}