summaryrefslogtreecommitdiff
path: root/src/pkg/reflect/value.go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2012-03-26 16:50:58 +0200
committerOndřej Surý <ondrej@sury.org>2012-03-26 16:50:58 +0200
commit519725bb3c075ee2462c929f5997cb068e18466a (patch)
tree5b162e8488ad147a645048c073577821b4a2bee9 /src/pkg/reflect/value.go
parent842623c5dd2819d980ca9c58048d6bc6ed82475f (diff)
downloadgolang-upstream-weekly/2012.03.22.tar.gz
Imported Upstream version 2012.03.22upstream-weekly/2012.03.22
Diffstat (limited to 'src/pkg/reflect/value.go')
-rw-r--r--src/pkg/reflect/value.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/pkg/reflect/value.go b/src/pkg/reflect/value.go
index f3f7d639a..79476ad22 100644
--- a/src/pkg/reflect/value.go
+++ b/src/pkg/reflect/value.go
@@ -54,6 +54,10 @@ func memmove(adst, asrc unsafe.Pointer, n uintptr) {
// its String method returns "<invalid Value>", and all other methods panic.
// Most functions and methods never return an invalid value.
// If one does, its documentation states the conditions explicitly.
+//
+// A Value can be used concurrently by multiple goroutines provided that
+// the underlying Go value can be used concurrently for the equivalent
+// direct operations.
type Value struct {
// typ holds the type of the value represented by a Value.
typ *commonType
@@ -1628,6 +1632,15 @@ func MakeSlice(typ Type, len, cap int) Value {
if typ.Kind() != Slice {
panic("reflect.MakeSlice of non-slice type")
}
+ if len < 0 {
+ panic("reflect.MakeSlice: negative len")
+ }
+ if cap < 0 {
+ panic("reflect.MakeSlice: negative cap")
+ }
+ if len > cap {
+ panic("reflect.MakeSlice: len > cap")
+ }
// Declare slice so that gc can see the base pointer in it.
var x []byte