Skip to content

Commit bb88c16

Browse files
committed
Add support for complex64/complex128
Support for complex64 was accidentally removed in 72666c8, complex128 is new. Now with tests.
1 parent 25de947 commit bb88c16

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

hashstructure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func (w *walker) visit(v reflect.Value, opts *visitOpts) (uint64, error) {
196196
return w.hashDirect(v.Interface())
197197
}
198198

199-
if v.CanFloat() {
199+
if v.CanFloat() || v.CanComplex() {
200200
return w.hashDirect(v.Interface())
201201
}
202202

hashstructure_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,14 @@ func TestHash_golden(t *testing.T) {
750750
In: float64(42),
751751
Expect: 12162027084228238918,
752752
},
753+
{
754+
In: complex64(42),
755+
Expect: 13187391128804187615,
756+
},
757+
{
758+
In: complex128(42),
759+
Expect: 4635205179288363782,
760+
},
753761
{
754762
In: true,
755763
Expect: 12638153115695167454,

0 commit comments

Comments
 (0)