Skip to content

gh-159672: Generate keyword typo hints in the parser - #159673

Draft
pablogsal wants to merge 10 commits into
python:mainfrom
pablogsal:keyword-typo-token-replay
Draft

pablogsal wants to merge 10 commits into
python:mainfrom
pablogsal:keyword-typo-token-replay

Conversation

@pablogsal

@pablogsal pablogsal commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Move keyword typo hints into the parser and attach the result to SyntaxError. Replay private token copies through the grammar, with one replacement per trial. Release trial identifiers with their arena. Remove source recompilation and statement-location metadata from traceback.

Search the complete logical statement and count adjacent letter swaps as one edit. Preserve comma diagnostics and support typos that spell another keyword.

Limit the search to 256 KiB, 32,768 tokens, 32 candidates, and 5 million rule entries across all trials. Keep the normal parser's fast stack check.

Fixes #159672.

@pablogsal pablogsal added type-feature A feature request or enhancement interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Oct 18, 2026
@pablogsal
pablogsal force-pushed the keyword-typo-token-replay branch 2 times, most recently from e58bf8d to a39cdf2 Compare October 18, 2026 14:22
@pablogsal
pablogsal force-pushed the keyword-typo-token-replay branch from a39cdf2 to 05fb3a1 Compare October 18, 2026 14:58
Skip immortal interning for replay-only identifiers and dotted names.
The parser can then release those strings after each trial.
Separate candidate collection, trial acceptance, and hint construction.
Keep trial allocation and cleanup together, and restore the original
syntax error through one exit path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move keyword typo suggestions into the parser

1 participant