Repository navigation
json BUGFIX exponent numbers with a leading zero - #2633
Merged
Merged
Conversation
For a number such as 0.xxxEn whose new decimal point falls inside the digits, lyjson_exp_number() placed the point at n - 1 instead of n minus the skipped leading zeros and reserved no byte for it, so the last digit was cut off. 0.25E2 became "2." and 0.5E1 became ".", and 0.0034E3 (3.4) became "34", which an integer leaf accepts. Anydata content kept the converted text, printing -0.00642406E+4 as -642.40.
michalvasko
approved these changes
Nov 16, 2026
Member
|
Thanks, merging but to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
lyjson_exp_number()rewrites JSON numbers that carry an exponent into plain decimal text before the value reaches the type plugins. for the0.xxxEnshape where the new decimal point lands inside the digits, the leading-zero branch put the point atn - 1instead ofnminus the zeros it skips, and didn't reserve a byte for it, so the terminator cut off the last digit:0.25E2turned into2.and0.5E1into a bare., and integer leaves reject them even though2.5E1goes through as 25. the nastier case is when two or more zeros get skipped and the point drops out entirely, so0.0034E3(3.4) comes out as34and a uint8 leaf happily stores 34, same for0.00255E4(25.5) stored as 255. anydata keeps the converted text as well, so{"a":0.5E1,"c":-0.00642406E+4}is printed back as{"a":.,"c":-642.40}, which is neither valid JSON nor the value that was sent. i noticed it while diffing the lexer output against python'sDecimalover random numbers; with the fix 200k of them match, and the new cases intest_numberfail on the current tree. the change stays inside that one branch since the other branches already agreed withDecimal.