mirror of
https://github.com/golang/go
synced 2024-11-02 11:50:30 +00:00
cmd/compile: avoid nil-ing out a node's Type in typecheckcomplit() on error
typecheckcomplit nils out node's type, upon finding new errors. This hides new errors in children's node as well as the type info of current node. This change fixes that. Fixes #17645. Change-Id: Ib473291f31c7e8fa0307cb1d494e0c112ddd3583 Reviewed-on: https://go-review.googlesource.com/32324 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
d35dfd405e
commit
9a8bf2d67d
2 changed files with 17 additions and 1 deletions
|
@ -3113,7 +3113,6 @@ func typecheckcomplit(n *Node) *Node {
|
|||
}
|
||||
|
||||
if nerr != nerrors {
|
||||
n.Type = nil
|
||||
return n
|
||||
}
|
||||
|
||||
|
|
17
test/fixedbugs/issue17645.go
Normal file
17
test/fixedbugs/issue17645.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2016 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
|
||||
|
||||
type Foo struct {
|
||||
X int
|
||||
}
|
||||
|
||||
func main() {
|
||||
var s []int
|
||||
var _ string = append(s, Foo{""}) // ERROR "cannot use .. \(type string\) as type int in field value" "cannot use Foo literal \(type Foo\) as type int in append" "cannot use append\(s\, Foo literal\) \(type \[\]int\) as type string in assignment"
|
||||
}
|
||||
|
Loading…
Reference in a new issue