Skip to content

Commit 032ffb2

Browse files
committed
gc: more graceful errors during struct definition
Fixes #2110. R=ken2 CC=golang-dev https://golang.org/cl/4823060
1 parent 33a4da8 commit 032ffb2

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/cmd/gc/dcl.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,10 +746,8 @@ stotype(NodeList *l, int et, Type **t, int funarg)
746746
} else {
747747
typecheck(&n->right, Etype);
748748
n->type = n->right->type;
749-
if(n->type == T) {
750-
*t0 = T;
751-
return t0;
752-
}
749+
if(n->type == T)
750+
continue;
753751
if(left != N)
754752
left->type = n->type;
755753
n->right = N;

test/fixedbugs/bug365.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// errchk $G $D/$F.go
2+
3+
// Copyright 2011 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
// check that compiler doesn't stop reading struct def
8+
// after first unknown type.
9+
10+
// Fixes issue 2110.
11+
12+
package main
13+
14+
type S struct {
15+
err os.Error // ERROR "undefined"
16+
Num int
17+
}
18+
19+
func main() {
20+
s := S{}
21+
_ = s.Num // no error here please
22+
}

0 commit comments

Comments
 (0)