Skip to content

Commit 64e7f66

Browse files
odeke-emgopherbot
authored andcommitted
encoding/json, text/template: use reflect.Value.Equal instead of ==
This change applies a fix for a reflect.Value incorrect comparison using "==" or reflect.DeepEqual. This change is a precursor to the change that'll bring in the static analyzer "reflectvaluecompare", by ensuring that all tests pass beforehand. Updates #43993 Change-Id: I6c47eb0a1de6353ac7495cb8cb49b318b7ebba56 Reviewed-on: https://go-review.googlesource.com/c/go/+/626116 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Run-TryBot: Emmanuel Odeke <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: David Chase <[email protected]>
1 parent 2b33434 commit 64e7f66

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Diff for: src/encoding/json/decode.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ func indirect(v reflect.Value, decodingNull bool) (Unmarshaler, encoding.TextUnm
472472
// Prevent infinite loop if v is an interface pointing to its own address:
473473
// var v any
474474
// v = &v
475-
if v.Elem().Kind() == reflect.Interface && v.Elem().Elem() == v {
475+
if v.Elem().Kind() == reflect.Interface && v.Elem().Elem().Equal(v) {
476476
v = v.Elem()
477477
break
478478
}

Diff for: src/text/template/exec.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ func (s *state) evalCall(dot, fun reflect.Value, isBuiltin bool, node parse.Node
810810
return v
811811
}
812812
}
813-
if final != missingVal {
813+
if !final.Equal(missingVal) {
814814
// The last argument to and/or is coming from
815815
// the pipeline. We didn't short circuit on an earlier
816816
// argument, so we are going to return this one.

0 commit comments

Comments
 (0)