]> Cypherpunks repositories - gostls13.git/commitdiff
gc: fix error for +string
authorRuss Cox <rsc@golang.org>
Wed, 20 Apr 2011 20:12:47 +0000 (16:12 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 20 Apr 2011 20:12:47 +0000 (16:12 -0400)
Fixes #1710.

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

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

index a01e2ea46b0fb9854d354deaf5f65a26fca37cd4..4303bbd0f18846867693f6a2b559efd0beceaf0f 100644 (file)
@@ -530,7 +530,7 @@ typeinit(void)
        okfor[OCOM] = okforand;
        okfor[OMINUS] = okforarith;
        okfor[ONOT] = okforbool;
-       okfor[OPLUS] = okforadd;
+       okfor[OPLUS] = okforarith;
 
        // special
        okfor[OCAP] = okforcap;
diff --git a/test/fixedbugs/bug330.go b/test/fixedbugs/bug330.go
new file mode 100644 (file)
index 0000000..cf1d6cc
--- /dev/null
@@ -0,0 +1,13 @@
+// errchk $G -e $D/$F.go
+
+// Copyright 2011 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
+
+func main() {
+       x := ""
+       x = +"hello"  // ERROR "invalid operation.*string"
+       x = +x  // ERROR "invalid operation.*string"
+}