Skip to content

perf: parse both erased declaration forms with one doElem parser - #15151

Draft
sgraf812 wants to merge 1 commit into
masterfrom
sg/do-erased-one-parser
Draft

sgraf812 wants to merge 1 commit into
masterfrom
sg/do-erased-one-parser

Conversation

@sgraf812

Copy link
Copy Markdown
Contributor

This PR merges the two erased doElem parsers into one, halving the parse cost the feature added to identifier-headed do elements.

A doElem that starts with an identifier runs every ident-keyed leading parser through the longest-match loop. doErased and doErasedArrow both sat in that set, so every such element paid two failing candidate runs (about 12k instructions together, the bulk of the +0.44% build-instruction report on the erased PR). One parser accepting both the := and the form removes one candidate; on a 2000-element benchmark the added cost drops from +1.80% to +1.04%.

The parseQuotWithCurrentStage options in Lean.Elab.BuiltinDo.Let and Lean.Elab.Do.InferControlInfo stay until the next stage0 update carries the merged grammar.

A doElem that starts with an identifier runs every ident-keyed leading parser through the longest-match loop, so each parser there costs work on every such element. One `doErased` parser accepts both the `:=` and the `←` form, which removes one of the two parsers that the `erased` feature added to that loop.
@sgraf812 sgraf812 added the changelog-language Language features and metaprograms label Sep 14, 2026
@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-language Language features and metaprograms toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant