You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Problematic behaviour of #scan_integer(base: 16) when parses "0x" #140
The method #scan_integer called with base: 16 is supposed to parse hexadecimal integer literals. There is an edge case when "0x" is not followed by any hex character (e.g. 0x.!@#). In this case #scan_integer doesn't match an integer literal and returns nil:
Activity
eregon commentedon Feb 19, 2025
cc @byroot
This was found when implementing
scan_integeron TruffleRuby, where the natural way to do it would be usingscan(/[+-]?(0x)?[0-9a-fA-F]+/).byroot commentedon Feb 20, 2025
Do you have a repro?
I'm trying to fix this but if I add a test for it it passes:
byroot commentedon Feb 20, 2025
Nevermind, I kinda misread.
`scan_integer(base: 16)` ignore x suffix if not followed by hexadecimal
byroot commentedon Feb 20, 2025
#141
`scan_integer(base: 16)` ignore x suffix if not followed by hexadecim…
[ruby/strscan] `scan_integer(base: 16)` ignore x suffix if not
[ruby/strscan] `scan_integer(base: 16)` ignore x suffix if not