summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-06-04 16:18:13 -0700
committerRuss Cox <rsc@golang.org>2009-06-04 16:18:13 -0700
commit5ccfd20a190db8b9c777fdda4731c6debdb6bd36 (patch)
treed0aa2a56924e06182ed45e71ae267671737c38da
parent0c2a8b158d6cdd9c3dd5d47444287c12b6c575c3 (diff)
downloadgolang-5ccfd20a190db8b9c777fdda4731c6debdb6bd36.tar.gz
bug161, fixed
R=ken OCL=29907 CL=29907
-rw-r--r--src/cmd/gc/dcl.c6
-rw-r--r--src/cmd/gc/subr.c2
-rw-r--r--test/fixedbugs/bug161.go17
3 files changed, 24 insertions, 1 deletions
diff --git a/src/cmd/gc/dcl.c b/src/cmd/gc/dcl.c
index e5d6392e6..c5359dc5c 100644
--- a/src/cmd/gc/dcl.c
+++ b/src/cmd/gc/dcl.c
@@ -956,6 +956,8 @@ addvar(Node *n, Type *t, int ctxt)
s->vargen = gen;
s->oname = n;
s->offset = 0;
+ s->oconst = nil;
+ s->otype = nil;
s->lexical = LNAME;
n->funcdepth = funcdepth;
@@ -1003,6 +1005,8 @@ addtyp(Type *n, int ctxt)
redeclare("type", s);
s->otype = n;
+ s->oconst = nil;
+ s->oname = nil;
s->lexical = LATYPE;
d = dcl();
@@ -1056,6 +1060,8 @@ addconst(Node *n, Node *e, int ctxt)
redeclare("constant", s);
s->oconst = e;
+ s->otype = nil;
+ s->oname = nil;
s->lexical = LNAME;
d = dcl();
diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c
index a29f28cd0..0e025072c 100644
--- a/src/cmd/gc/subr.c
+++ b/src/cmd/gc/subr.c
@@ -1045,7 +1045,7 @@ Tpretty(Fmt *fp, Type *t)
else
fmtprint(fp, "%lS", s);
if(strcmp(s->package, package) == 0)
- if(s->otype != t || (!s->export && !s->imported)) {
+ if((s->otype != t || !s->export) && !s->imported) {
fmtprint(fp, "·%s", filename);
if(t->vargen)
fmtprint(fp, "·%d", t->vargen);
diff --git a/test/fixedbugs/bug161.go b/test/fixedbugs/bug161.go
new file mode 100644
index 000000000..e5f25f746
--- /dev/null
+++ b/test/fixedbugs/bug161.go
@@ -0,0 +1,17 @@
+// $G $D/$F.go || echo BUG: should compile
+
+// 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 P
+
+const a = 0;
+
+func f(a int) {
+ a = 0;
+}
+
+/*
+bug161.go:8: operation LITERAL not allowed in assignment context
+*/