Skip to content

Fix incorrect regex for integer literals#563

Open
ef3d0c3e wants to merge 1 commit into42school:masterfrom
ef3d0c3e:fix-integer-literals
Open

Fix incorrect regex for integer literals#563
ef3d0c3e wants to merge 1 commit into42school:masterfrom
ef3d0c3e:fix-integer-literals

Conversation

@ef3d0c3e
Copy link

@ef3d0c3e ef3d0c3e commented Jun 23, 2025

I recently noticed that the regex responsible for parsing integer literals doesn't work as expected.
The prefix part of the regex matches for [bBxX]* which caused any combination of bBxX to be matched, instead of only matching repeating sequences: https://regex101.com/r/5lUQ0U/1

In cases like 0xb0b; 0xb is considered the prefix of the integer literal, causing the last b to be matched as an invalid suffix.

In the modified regex combinations can no longer match, only repetitions are allowed: https://regex101.com/r/nWkXWv/1

I'm not sure about how to run tests. The tests seems to fail on the current master branch. With more information, I might be able to add tests for this modified regex.

Verification Steps

Please ensure the following steps have been completed:

  • Added new tests to cover the changes.
  • Fixed all broken tests.
  • Ran poetry run flake8 to check for linting issues.
  • Verified that all unit tests are passing:
    • Ran poetry run pytest to ensure unit tests pass.
    • Ran poetry run tox to validate compatibility across Python versions.

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.

1 participant

Comments