reflect: Value.Seq iteration value types should match

Implementation of https://github.com/golang/go/issues/71905

194696f1d1f6e5609f96d0fb0192595e7e0f5b90
This commit is contained in:
Randy Reddig
2025-03-09 09:04:47 -07:00
committed by Ron Evans
parent b6c3d142db
commit 64651115c2
2 changed files with 29 additions and 19 deletions
+5 -4
View File
@@ -197,10 +197,11 @@ func TestValueSeq(t *testing.T) {
t.Fatalf("got %d, want %d", v.Int(), i)
}
i++
// TODO: iteration should produce the same type
// if v.Type() != reflect.TypeOf(i) {
// t.Fatalf("got %s, want %s", v.Type(), reflect.TypeOf(i))
// }
if v.Type() != reflect.TypeOf(i) {
j := ValueOf(i)
t.Logf("ValueOf(j): %s", j.Type())
t.Fatalf("got %s, want %s", v.Type(), reflect.TypeOf(i))
}
}
if i != 4 {
t.Fatalf("should loop four times")