Skip to content

feat: support expected type annotation in doPatDecl#12866

Merged
sgraf812 merged 1 commit intomasterfrom
do-let-arrow-pat-expected-type
Mar 10, 2026
Merged

feat: support expected type annotation in doPatDecl#12866
sgraf812 merged 1 commit intomasterfrom
do-let-arrow-pat-expected-type

Conversation

@sgraf812
Copy link
Copy Markdown
Contributor

This PR adds optType support to the doPatDecl parser, allowing
let ⟨width, height⟩ : Nat × Nat ← action in do-notation. Previously, only
the less ergonomic let ⟨width, height⟩ : Nat × Nat := ← action workaround
was available. The type annotation is propagated to the monadic action as an
expected type, matching doIdDecl's existing behavior.

Both the legacy and new (BuiltinDo) elaborators are updated.

This PR allows `let ⟨width, height⟩ : Nat × Nat ← action` in do-notation,
propagating the expected type to the monadic action. Previously, only
`let ⟨width, height⟩ : Nat × Nat := ← action` was supported, requiring the
less ergonomic `:= ←` workaround. The type annotation is added as `optType`
in the `doPatDecl` parser, matching `doIdDecl`'s existing support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sgraf812 sgraf812 added the changelog-language Language features and metaprograms label Mar 10, 2026
@sgraf812 sgraf812 added this pull request to the merge queue Mar 10, 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 Mar 10, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 85d38cba844f099be186cb7a327e18fc29c0debc --onto e8048291010c815d0d30926924e7ad7afc18b1c0. You can force Mathlib CI using the force-mathlib-ci label. (2026-03-10 12:22:10)

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 85d38cba844f099be186cb7a327e18fc29c0debc --onto a165292462a973c20d3cc8c8b23a3ac2334a2a4a. You can force reference manual CI using the force-manual-ci label. (2026-03-10 12:22:12)

Merged via the queue into master with commit daddac1 Mar 10, 2026
23 checks passed
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.

2 participants