aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-07-28 20:41:18 -0400
committerRuss Cox <rsc@golang.org>2011-07-28 20:41:18 -0400
commit032ffb2e90b71b340684fe2b75abbd23f04352f1 (patch)
treecaf257f9c7598d3c2bf247a483558a9c746a8e8b
parent33a4da89d38b97cdbb860caa5ec9790bf35a7b93 (diff)
downloadgo-032ffb2e90b71b340684fe2b75abbd23f04352f1.tar.gz
go-032ffb2e90b71b340684fe2b75abbd23f04352f1.zip
gc: more graceful errors during struct definition
Fixes #2110. R=ken2 CC=golang-dev https://golang.org/cl/4823060
-rw-r--r--src/cmd/gc/dcl.c6
-rw-r--r--test/fixedbugs/bug365.go22
2 files changed, 24 insertions, 4 deletions
diff --git a/src/cmd/gc/dcl.c b/src/cmd/gc/dcl.c
index ba1aa83888..5bfeeb97aa 100644
--- a/src/cmd/gc/dcl.c
+++ b/src/cmd/gc/dcl.c
@@ -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
index 0000000000..7ec19b0c8b
--- /dev/null
+++ b/test/fixedbugs/bug365.go
@@ -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
+}