Skip to content

Conversation

@itchyny
Copy link
Contributor

@itchyny itchyny commented Oct 2, 2025

Currently, decoding v: -1.0 into map[string]uint64 results into map[string]uint64{"v": 0} (should be an empty map like overflow case) because it does not check underflow.

Copilot AI review requested due to automatic review settings October 2, 2025 04:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an underflow check for float to int conversion in YAML decoding. Currently, negative float values like -1.0 being decoded into unsigned integer maps incorrectly result in zero values instead of being rejected as underflow errors.

  • Added underflow bounds checking for float64 to signed and unsigned integer conversions
  • Added comprehensive test cases for float overflow/underflow scenarios
  • Fixed a minor issue with duration type checking logic

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
decode.go Added underflow checks for float64 conversions to int64 and uint64 types
decode_test.go Added test cases covering float overflow/underflow scenarios for integer types

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@itchyny itchyny force-pushed the fix-underflow-float branch from 3c8dccf to 85ca580 Compare October 15, 2025 02:53
@itchyny itchyny force-pushed the fix-underflow-float branch from 85ca580 to 9906fd5 Compare October 28, 2025 02:07
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.

2 participants