diff options
author | Russ Cox <rsc@golang.org> | 2009-05-21 14:06:24 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-05-21 14:06:24 -0700 |
commit | 8b6b3806059aa7d74322cd0f59c9a3fb4f9919dd (patch) | |
tree | bff0c3c2d35540b4df50dbcfa32ee45f7c871639 /test/assign.go | |
parent | b9159722dd874c9ef64dd16af49084077d7a9bb8 (diff) | |
download | go-8b6b3806059aa7d74322cd0f59c9a3fb4f9919dd.tar.gz go-8b6b3806059aa7d74322cd0f59c9a3fb4f9919dd.zip |
stricter rules for assignment.
when assigning a multifield object
(structs or arrays of structs) they
must not contain any fields that could
not be assigned individually.
R=ken
OCL=29192
CL=29194
Diffstat (limited to 'test/assign.go')
-rw-r--r-- | test/assign.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/assign.go b/test/assign.go new file mode 100644 index 0000000000..a98b7b75a0 --- /dev/null +++ b/test/assign.go @@ -0,0 +1,33 @@ +// 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 + +import "sync" + +type T struct { + int; + sync.Mutex; +} + +func main() { + { + var x, y sync.Mutex; + x = y; // ERROR "assignment.*Mutex" + } + { + var x, y T; + x = y; // ERROR "assignment.*Mutex" + } + { + var x, y [2]sync.Mutex; + x = y; // ERROR "assignment.*Mutex" + } + { + var x, y [2]T; + x = y; // ERROR "assignment.*Mutex" + } +} |