Skip to content

Commit

Permalink
Add support for complex64/complex128
Browse files Browse the repository at this point in the history
Support for complex64 was accidentally removed in 72666c8, complex128 is new. Now with tests.
  • Loading branch information
bep committed Feb 6, 2025
1 parent 25de947 commit d1ff440
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hashstructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ func (w *walker) visit(v reflect.Value, opts *visitOpts) (uint64, error) {
return w.hashDirect(v.Interface())
}

if v.CanComplex() {
return w.hashDirect(v.Interface())
}

k := v.Kind()

if k == reflect.Bool {
Expand Down
8 changes: 8 additions & 0 deletions hashstructure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,14 @@ func TestHash_golden(t *testing.T) {
In: float64(42),
Expect: 12162027084228238918,
},
{
In: complex64(42),
Expect: 13187391128804187615,
},
{
In: complex128(42),
Expect: 4635205179288363782,
},
{
In: true,
Expect: 12638153115695167454,
Expand Down

0 comments on commit d1ff440

Please sign in to comment.