Fix for parsing floats that don't include . or e#23
Open
zjijz wants to merge 1 commit intowlentz:masterfrom
Open
Fix for parsing floats that don't include . or e#23zjijz wants to merge 1 commit intowlentz:masterfrom
zjijz wants to merge 1 commit intowlentz:masterfrom
Conversation
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.
Rust allows strings of integral values to be parsed to
f32orf64using thestr::parsemethod. I was trying to usescan_fmtto parse an integral value to a floating point, but I was getting the following panic:Code:
Error:
The issue had to do with
scan_dec10_nestpotentially exhausting the input, but thenscan_floatcalledvs.cur()to check for.ore, which would throw the out-of-bounds error since we were at end-of-input. The fix for this was to check if we were at end-of-input before doing the check for.ore.I added a test (
test_integer_for_float) to check for this edge case and ensured none of the other tests failed with the change.I also manually checked the other uses of
scan_dec10_nest(andscan_dec10) and it didn't seem like it was used in a location that assumed end-of-input was not reached already.