Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix large literals type inference on 32 bits #293

Merged
merged 1 commit into from Aug 22, 2022

Conversation

jrisc
Copy link
Contributor

@jrisc jrisc commented Apr 29, 2022

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:

# github.com/goccy/go-yaml_test [github.com/goccy/go-yaml.test]
./decode_test.go:92:32: cannot use -9223372036854775808 (untyped int constant) as int value in map literal (overflows)
./decode_test.go:112:24: cannot use 4294967296 (untyped int constant) as int value in map literal (overflows)
./encode_test.go:68:24: cannot use 4294967296 (untyped int constant) as int value in map literal (overflows)

This commit fixes this issue by using explicit int64 typing.

@goccy
Copy link
Owner

goccy commented May 1, 2022

Could you fix it with a type cast without using temporary variables ?

@codecov-commenter
Copy link

Codecov Report

Merging #293 (b4fe0c2) into master (e4f32a2) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #293   +/-   ##
=======================================
  Coverage   75.93%   75.93%           
=======================================
  Files          13       13           
  Lines        4305     4305           
=======================================
  Hits         3269     3269           
  Misses        799      799           
  Partials      237      237           

@goccy goccy self-requested a review May 6, 2022 18:56
Copy link
Owner

@goccy goccy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you fix it with a type cast without using temporary variables ?

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>
@jrisc
Copy link
Contributor Author

jrisc commented Jun 7, 2022

Sorry about the delay. I replaced variables by type casts.

@goccy goccy merged commit ecececd into goccy:master Aug 22, 2022
@goccy
Copy link
Owner

goccy commented Aug 22, 2022

Thank you for the fixing ! Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants