Skip to content

Conversation

josdejong
Copy link
Owner

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, or 0x, and then try to parse the string into a number. When evaluating 0x1k, 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, and bin, with specific functions isHexDigit, isOctDigit and isBinDigit, 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?

@gwhitney
Copy link
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?

@josdejong
Copy link
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.

@gwhitney
Copy link
Collaborator

That would make sense to me.

@josdejong josdejong merged commit ba88f47 into v15 Jul 11, 2025
8 checks passed
@josdejong josdejong deleted the fix/3421-require-space-after-hex-oct-bin branch July 11, 2025 10:12
@josdejong
Copy link
Owner Author

Published now in v15.0.0.

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