diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c index 08c47d07f83..c63480faa2d 100644 --- a/src/cmd/gc/typecheck.c +++ b/src/cmd/gc/typecheck.c @@ -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 index 00000000000..172b3742e54 --- /dev/null +++ b/test/fixedbugs/bug241.go @@ -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" +