Fix boolean-like dictionary keys being converted to booleans#8
Fix boolean-like dictionary keys being converted to booleans#8P6rguVyrst wants to merge 1 commit into
Conversation
The encoder now quotes keys that match boolean/null keywords (t, f, true,
false, null, none, nil) to prevent the decoder from misinterpreting them.
The decoder now uses a new parse_key() function for dictionary keys that
preserves them as strings, unlike parse_value() which converts keywords.
This fixes a critical round-trip bug where {"f": 1} would decode as
{False: 1}.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe changes introduce specialized handling for dictionary keys that resemble boolean or null literals. A new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
sorry-- meant to do this to my own copy first & validate. |
|
@P6rguVyrst Please make sure you are running tests on your machine. There are multiple edge cases. A single black space can lead to a token increase. Thanks for looking into internal bugs ❤️ |
The tests that failed on me on accuracy: #9 |
Changes:
The encoder now quotes keys that match boolean/null keywords (t, f, true, false, null, none, nil) to prevent the decoder from misinterpreting them.
The decoder now uses a new parse_key() function for dictionary keys that preserves them as strings, unlike parse_value() which converts keywords.
This fixes a critical round-trip bug where {"f": 1} would decode as
{False: 1}.
Summary by CodeRabbit
Bug Fixes
Tests