mirror of
https://github.com/golang/go
synced 2024-11-21 13:44:45 -07:00
gc: more graceful errors during struct definition
Fixes #2110. R=ken2 CC=golang-dev https://golang.org/cl/4823060
This commit is contained in:
parent
33a4da89d3
commit
032ffb2e90
@ -746,10 +746,8 @@ stotype(NodeList *l, int et, Type **t, int funarg)
|
|||||||
} else {
|
} else {
|
||||||
typecheck(&n->right, Etype);
|
typecheck(&n->right, Etype);
|
||||||
n->type = n->right->type;
|
n->type = n->right->type;
|
||||||
if(n->type == T) {
|
if(n->type == T)
|
||||||
*t0 = T;
|
continue;
|
||||||
return t0;
|
|
||||||
}
|
|
||||||
if(left != N)
|
if(left != N)
|
||||||
left->type = n->type;
|
left->type = n->type;
|
||||||
n->right = N;
|
n->right = N;
|
||||||
|
22
test/fixedbugs/bug365.go
Normal file
22
test/fixedbugs/bug365.go
Normal file
@ -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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user