]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: fix confusing error when using variable as type.
authorDaniel Morsing <daniel.morsing@gmail.com>
Sun, 21 Oct 2012 18:50:31 +0000 (20:50 +0200)
committerDaniel Morsing <daniel.morsing@gmail.com>
Sun, 21 Oct 2012 18:50:31 +0000 (20:50 +0200)
Fixes #3783.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6737053

src/cmd/gc/typecheck.c
test/fixedbugs/issue3783.go [new file with mode: 0644]

index 9869d560cb92516798a50d8270de69744d7880ad..e5bcabca0d3c4b9795edcf070c90af41cf762ba3 100644 (file)
@@ -476,7 +476,7 @@ reswitch:
                        n->left = N;
                        goto ret;
                }
-               if(!isptr[t->etype]) {
+               if((top & Erv) && !isptr[t->etype]) {
                        yyerror("invalid indirect of %lN", n->left);
                        goto error;
                }
diff --git a/test/fixedbugs/issue3783.go b/test/fixedbugs/issue3783.go
new file mode 100644 (file)
index 0000000..35df5d8
--- /dev/null
@@ -0,0 +1,12 @@
+// errorcheck
+
+// Copyright 2012 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 foo
+
+var i int
+
+func (*i) bar() // ERROR "not a type"
+