fix: #3421 require a space or delimiter after hex, bin, and oct values#3463
Merged
fix: #3421 require a space or delimiter after hex, bin, and oct values#3463
Conversation
This was referenced Apr 23, 2025
Closed
Collaborator
|
Hmm, I had hoped we could get a no-breaking-change version of #3423 into v14 (as discussed in #3421 to hold off on addressing it within #3423), as that would make the parsing system much more modular for fixes like this. Or conversely, if we do merge this into v15 now, and then manage to get #3423 done in v14, this commit in v15 will be extremely in conflict with the commit for #3423 in v14, making the rebase of v15 on develop post #3423 more tricky and in need of noticeable manual merging. Thoughts? |
Owner
Author
|
If it's handier we can leave this PR open until after #3423 is merged in v14. After that, we can recreate this PR if needed, it's very small. |
Collaborator
|
That would make sense to me. |
Owner
Author
|
Published now in |
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.
Fixes #3421
A simple solution is to not only parse hex characters, but just parse any alpha and digit character after the prefix
0x,0o, or0x, and then try to parse the string into a number. When evaluating0x1k, this will give an error messate "SyntaxError: String "0x1k" is not a valid number".An alternative solution would be to create separate flows for parsing
hex,oct, andbin, with specific functionsisHexDigit,isOctDigitandisBinDigit, and then we need a separate check to see if the value is followed by an alpha or digit character and then throw an error like "Unexpected character 'k' (char: 3)". I think though that the former is a more informative error message.@gwhitney can you have a brief look at this PR?