Explorar o código

Skip scalars when decoding onto unsupported types.

R=
CC=
https://codereview.appspot.com/5505058
Gustavo Niemeyer %!s(int64=14) %!d(string=hai) anos
pai
achega
54c736c86c
Modificáronse 2 ficheiros con 1 adicións e 2 borrados
  1. 0 2
      decode.go
  2. 1 0
      decode_test.go

+ 0 - 2
decode.go

@@ -360,8 +360,6 @@ func (d *decoder) scalar(n *node, out reflect.Value) (good bool) {
 			out.Set(reflect.Zero(out.Type()))
 			out.Set(reflect.Zero(out.Type()))
 			good = true
 			good = true
 		}
 		}
-	default:
-		panic("Can't handle type yet: " + out.Type().String())
 	}
 	}
 	return good
 	return good
 }
 }

+ 1 - 0
decode_test.go

@@ -85,6 +85,7 @@ var unmarshalTests = []struct {
 	{"a: {b: c}", &struct{ A *struct{ B string } }{&struct{ B string }{"c"}}},
 	{"a: {b: c}", &struct{ A *struct{ B string } }{&struct{ B string }{"c"}}},
 	{"a: {b: c}", &struct{ A map[string]string }{map[string]string{"b": "c"}}},
 	{"a: {b: c}", &struct{ A map[string]string }{map[string]string{"b": "c"}}},
 	{"a: {b: c}", &struct{ A *map[string]string }{&map[string]string{"b": "c"}}},
 	{"a: {b: c}", &struct{ A *map[string]string }{&map[string]string{"b": "c"}}},
+	{"a:", &struct{ A map[string]string }{}},
 	{"a: 1", &struct{ A int }{1}},
 	{"a: 1", &struct{ A int }{1}},
 	{"a: [1, 2]", &struct{ A []int }{[]int{1, 2}}},
 	{"a: [1, 2]", &struct{ A []int }{[]int{1, 2}}},
 	{"a: 1", &struct{ B int }{0}},
 	{"a: 1", &struct{ B int }{0}},