Skip to content

Parse scoped inline-flag groups instead of crashing - #60

Merged
thatch merged 1 commit into
thatch:masterfrom
jvoisin:crsh
Jul 31, 2026
Merged

Parse scoped inline-flag groups instead of crashing#60
thatch merged 1 commit into
thatch:masterfrom
jvoisin:crsh

Conversation

@jvoisin

@jvoisin jvoisin commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

(?i:abc) and friends ((?i-s:...), (?-i:...), (?ims:...)) matched no group-opening rule, so the lexer fell through to '(' as a capturing group and then treated the trailing '?' as a quantifier with nothing to bind, raising "IndexError: pop from empty list" in get_parse_tree before any checker could run.

Add a tokenizer rule for scoped inline flags. It is placed after the plain (?:...) rule so ordinary non-capturing groups are unaffected, and it uses a dedicated Other.Open.NonCapturingFlags type rather than Other.Open.NonCapturing: a flag-scoped group is not interchangeable with a bare (?:...) group, so keeping it a distinct type stops checks such as redundant-group from suggesting a removal that would silently drop the flags.

Add the flag-scoped forms to SAMPLE_PATTERNS so the existing reconstruct round-trip test covers both parsing and byte-exact output.

(?i:abc) and friends ((?i-s:...), (?-i:...), (?ims:...)) matched no
group-opening rule, so the lexer fell through to '(' as a capturing
group and then treated the trailing '?' as a quantifier with nothing
to bind, raising "IndexError: pop from empty list" in get_parse_tree
before any checker could run.

Add a tokenizer rule for scoped inline flags. It is placed after the
plain (?:...) rule so ordinary non-capturing groups are unaffected, and
it uses a dedicated Other.Open.NonCapturingFlags type rather than
Other.Open.NonCapturing: a flag-scoped group is not interchangeable with
a bare (?:...) group, so keeping it a distinct type stops checks such as
redundant-group from suggesting a removal that would silently drop the
flags.

Add the flag-scoped forms to SAMPLE_PATTERNS so the existing
reconstruct round-trip test covers both parsing and byte-exact output.
@thatch
thatch merged commit 8bb2697 into thatch:master Jul 31, 2026
15 checks passed
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