Skip to content

math/big: nat does not play well with reflect.DeepEqual #27379

@zamsden

Description

@zamsden

The underlying problem is that the underlying nat type doesn't allocate a backing slice for the zero value in some initialization sequences, which causes reflect.DeepEqual to return false for equal big.Int values.

Either big.nat needs to be changed to always drop backing slices when setting to zero, always allocate backing slices, or the argument that zero-length slices and zero-length nil slices are different needs more thought. The current default answer is pedantically correct but not programmer friendly.

See #12918

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.10.2 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

x86_64

What did you do?

https://play.golang.org/p/CUcu_oCBILj

What did you expect to see?

true

What did you see instead?

false

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions