Repository navigation
fix: an f-string field may hold an f-string in the same quote - #241
Merged
Merged
Conversation
PEP 701 (Python 3.12): a replacement field holds any expression, so
f"a{f"b{x}c"}d" is one literal. The f-string body in tokens.x is now a
stack of frames (literal text, field, brace, plain string, escape)
instead of the plain body's run to the first quote, and the field
scanner in parse.x skips a nested f-string whole.
The tokenizer copies each character before a frame keeps it: the engine
hands every state one integer object, rewritten per character.
A field holding the outer quote that runs to the end of input takes the
literal to the end, so f"{(1" still reports "f-string: expecting '}'".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonruttan
force-pushed
the
fix/fstring-nested
branch
from
November 19, 2026 20:20
1adcc0b to
b1ca90a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Conformance:
string_fstring_nested_py312.Python 3.12 (PEP 701) lets a replacement field hold any expression, a string in the f-string's own quote included:
f"a{f"b{x}c"}d"is one literal, nested to any depth.f,rfandfrin either case use it;{{stays the literal brace.x-token.c,arg_chr). The body copies the code before a frame keeps it, or a kept quote would already be the next character.f"{(1"givesf-string: expecting '}'rather thaninvalid syntax.{{/}}, raw).The full suite passes locally on x-lang v0.57.0.
🤖 Generated with Claude Code