Skip to content

fix(eb_parse): balance nested braces in f-string fields - #75

Merged
HaoZeke merged 1 commit into
developfrom
fix/eb-parse-nested-fstrings-r2
Nov 24, 2026
Merged

HaoZeke merged 1 commit into
developfrom
fix/eb-parse-nested-fstrings-r2

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Fixes f-string fields that hold an inline dict lookup or a quoted closing brace, such as f"{ {'x86_64': 'amd64'}[ARCH] }" and f"{v.replace('.', '}')}". The scan for the end of a field stopped at the first }.

find_fstring_field_end balances nested braces and skips quoted strings. string_prefix replaces starts_prefixed_string as the single classifier for raw and formatted prefixes.

Raw and rf literals already parse on the parent, because #70 merged that handling. The raw-string test pins that behaviour and passes on the parent. Only fstring_fields_support_nested_dicts_and_quoted_braces fails there.

Stacks on the parity-ready line.

Scanning for the first closing brace with `find` truncated any
f-string field holding an inline dict literal or a quoted closing
brace, so `f"{ {'a': 1}[k] }"` and `f"{v.replace('.', '}')}"` failed
to parse.

Add `find_fstring_field_end` to balance nested braces while skipping
quoted strings when locating the end of a field.

Replace `starts_prefixed_string` with `string_prefix`, one classifier
for raw and formatted prefixes shared by expression and f-string
parsing. Raw and rf literals already parse on the parent; the added
test pins that behaviour and passes there.
@HaoZeke
HaoZeke changed the base branch from stack/parity-ready to develop November 24, 2026 09:42
@HaoZeke
HaoZeke force-pushed the fix/eb-parse-nested-fstrings-r2 branch from d76fd40 to 2b38138 Compare November 24, 2026 09:42
@HaoZeke
HaoZeke merged commit 063ebe4 into develop Nov 24, 2026
23 checks passed
@HaoZeke
HaoZeke deleted the fix/eb-parse-nested-fstrings-r2 branch November 24, 2026 15:04
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