]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: avoid nil-ing out a node's Type in typecheckcomplit() on error
authorDhananjay Nakrani <dhananjaynakrani@gmail.com>
Sat, 29 Oct 2016 19:10:21 +0000 (12:10 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 31 Oct 2016 22:29:40 +0000 (22:29 +0000)
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>

src/cmd/compile/internal/gc/typecheck.go
test/fixedbugs/issue17645.go [new file with mode: 0644]

index 6f0f4f58e34c15b1955c80dabfab12cda77be38d..23c60fa0d08260975c871994a73e67139f1047e8 100644 (file)
@@ -3113,7 +3113,6 @@ func typecheckcomplit(n *Node) *Node {
        }
 
        if nerr != nerrors {
-               n.Type = nil
                return n
        }
 
diff --git a/test/fixedbugs/issue17645.go b/test/fixedbugs/issue17645.go
new file mode 100644 (file)
index 0000000..ed92c54
--- /dev/null
@@ -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"
+}
+