]> Cypherpunks repositories - gostls13.git/commit
reflect: panic when Value.Equal using two non-comparable values
authorhopehook <hopehook.com@gmail.com>
Fri, 7 Oct 2022 14:42:15 +0000 (22:42 +0800)
committerGopher Robot <gobot@golang.org>
Mon, 17 Oct 2022 14:53:58 +0000 (14:53 +0000)
commit7ffc1e47b4e3b163f06fc33c9adbc29cb1622d47
treea12106d1c0daf4b24fedb21a161a2c1f7b8d3401
parent9abcc487f8b04db8fd46eaa429a7eef5a5228241
reflect: panic when Value.Equal using two non-comparable values

Assuming the two values are valid and non-comparable, Equal should panic.

x := reflect.ValueOf([]int{1, 2, 3})
x.Equal(x) // can not report false, should panic

Assuming one of them is non-comparable and the other is invalid, it should
always report false.

x := reflect.ValueOf([]int{1, 2, 3})
y := reflect.ValueOf(nil)
x.Equal(y) // should report false

For #46746.

Change-Id: Ifecd77ca0b3de3019fae2be39048f9277831676c
Reviewed-on: https://go-review.googlesource.com/c/go/+/440037
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/reflect/all_test.go
src/reflect/value.go