]> Cypherpunks repositories - gostls13.git/commitdiff
gc: bug241
authorRuss Cox <rsc@golang.org>
Fri, 8 Jan 2010 07:20:00 +0000 (23:20 -0800)
committerRuss Cox <rsc@golang.org>
Fri, 8 Jan 2010 07:20:00 +0000 (23:20 -0800)
Fixes #495.

R=ken2
CC=golang-dev
https://golang.org/cl/183156

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

index 08c47d07f83e122bed5bdbe9636c248bfda35b38..c63480faa2dae8ebf46f6b3e2b705155bdea0488 100644 (file)
@@ -446,7 +446,9 @@ reswitch:
                n->op = ODOT;
                // fall through
        case ODOT:
-               l = typecheck(&n->left, Erv|Etype);
+               typecheck(&n->left, Erv|Etype);
+               defaultlit(&n->left, T);
+               l = n->left;
                if((t = l->type) == T)
                        goto error;
                if(n->right->op != ONAME) {
diff --git a/test/fixedbugs/bug241.go b/test/fixedbugs/bug241.go
new file mode 100644 (file)
index 0000000..172b374
--- /dev/null
@@ -0,0 +1,11 @@
+// errchk $G $D/$F.go
+
+// Copyright 2009 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
+
+const c = 3
+var x = c.String()     // ERROR "String"
+