]> Cypherpunks repositories - gostls13.git/commitdiff
gc: bug278
authorRuss Cox <rsc@golang.org>
Mon, 24 May 2010 21:22:54 +0000 (14:22 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 24 May 2010 21:22:54 +0000 (14:22 -0700)
Fixes #804.

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

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

index b6940d412b756e4f0ac21bac365006fbe55a4fb7..19155f07ba0153201d6c3730b3f58286028fafe7 100644 (file)
@@ -2074,6 +2074,9 @@ islvalue(Node *n)
 {
        switch(n->op) {
        case OINDEX:
+               if(isfixedarray(n->left->type))
+                       return islvalue(n->left);
+               // fall through
        case OIND:
        case ODOTPTR:
                return 1;
diff --git a/test/fixedbugs/bug278.go b/test/fixedbugs/bug278.go
new file mode 100644 (file)
index 0000000..8c804cf
--- /dev/null
@@ -0,0 +1,23 @@
+// errchk $G $D/$F.go
+
+// Copyright 2010 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.
+
+// This is a test case for issue 804.
+
+package main
+
+func f() [10]int {
+       return [10]int{}
+}
+
+var m map[int][10]int
+
+func main() {
+       f()[1] = 2      // ERROR "cannot"
+       f()[2:3][0] = 4 // ERROR "cannot"
+       var x = "abc"
+       x[2] = 3        // ERROR "cannot"
+       m[0][5] = 6  // ERROR "cannot"
+}