fix: #3421 require a space or delimiter after hex, bin, and oct values
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?
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?
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.
That would make sense to me.
Published now in v15.0.0.