Skip to content

Commit

Permalink
Fix large literals type inference on 32 bits
Browse files Browse the repository at this point in the history
Some tests are failing because some large literal integers are meant to
be stored on 64 bits, but are stored on 32 on 32 bits architectures.
This causes the value to overflow.

This commit fixes this issue by using explicit int64 typing.

Signed-off-by: Julien Rische <jrische@redhat.com>
  • Loading branch information
jrisc committed Jun 7, 2022
1 parent e4f32a2 commit 66e8faa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions decode_test.go
Expand Up @@ -89,7 +89,7 @@ func TestDecoder(t *testing.T) {
},
{
"v: -0b1000000000000000000000000000000000000000000000000000000000000000",
map[string]interface{}{"v": -9223372036854775808},
map[string]interface{}{"v": int64(-9223372036854775808)},
},
{
"v: 0xA",
Expand All @@ -109,7 +109,7 @@ func TestDecoder(t *testing.T) {
},
{
"v: 4294967296\n",
map[string]int{"v": 4294967296},
map[string]int64{"v": int64(4294967296)},
},
{
"v: 0.1\n",
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestDecoder(t *testing.T) {
map[string]uint{"v": 42},
}, {
"v: 4294967296",
map[string]uint64{"v": 4294967296},
map[string]uint64{"v": uint64(4294967296)},
},

// int
Expand Down
2 changes: 1 addition & 1 deletion encode_test.go
Expand Up @@ -65,7 +65,7 @@ func TestEncoder(t *testing.T) {
},
{
"v: 4294967296\n",
map[string]int{"v": 4294967296},
map[string]int64{"v": int64(4294967296)},
nil,
},
{
Expand Down

0 comments on commit 66e8faa

Please sign in to comment.