aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-05-20 15:42:14 -0700
committerRuss Cox <rsc@golang.org>2009-05-20 15:42:14 -0700
commit2d5d4a1b41743ce84a8cc08562d36d27a0a42e19 (patch)
tree401aa5f2a801ba710cd53366f68b9cee8cf8e257 /src/lib
parenta39bae095ae836102c96cbfa0adc2745c6fbbbf6 (diff)
downloadgo-2d5d4a1b41743ce84a8cc08562d36d27a0a42e19.tar.xz
reflect bug: NewZeroValue was refusing to create slices.
as far as I can tell there's no reason not to. the Nillable test was succeeding because NewZeroValue returned the nil interface value and the type guard was letting it through. the only change in the test is more detail in the print. R=r DELTA=8 (0 added, 7 deleted, 1 changed) OCL=29124 CL=29126
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/reflect/all_test.go2
-rw-r--r--src/lib/reflect/value.go7
2 files changed, 1 insertions, 8 deletions
diff --git a/src/lib/reflect/all_test.go b/src/lib/reflect/all_test.go
index 8d4ea48651..ec770078d4 100644
--- a/src/lib/reflect/all_test.go
+++ b/src/lib/reflect/all_test.go
@@ -543,7 +543,7 @@ func TestIsNil(t *testing.T) {
ty := reflect.ParseTypeString("", ts);
v := reflect.NewZeroValue(ty);
if nilable, ok := v.(Nillable); !ok {
- t.Errorf("%s is not nilable; should be", ts)
+ t.Errorf("%s %T is not nilable; should be", ts, v)
}
}
// Check the implementations
diff --git a/src/lib/reflect/value.go b/src/lib/reflect/value.go
index d20d8cbe01..e3258b11f3 100644
--- a/src/lib/reflect/value.go
+++ b/src/lib/reflect/value.go
@@ -876,13 +876,6 @@ func newValueAddr(typ Type, addr Addr) Value {
// NewZeroValue creates a new, zero-initialized Value for the specified Type.
func NewZeroValue(typ Type) Value {
- // Some values cannot be made this way.
- switch typ.Kind() {
- case ArrayKind:
- if typ.(ArrayType).IsSlice() {
- return nil
- }
- }
size := typ.Size();
if size == 0 {
size = 1;