Skip to content

feat: add letConfig support to do block let/have#13215

Closed
sgraf812 wants to merge 2 commits into
masterfrom
sg/do-let-config
Closed

feat: add letConfig support to do block let/have#13215
sgraf812 wants to merge 2 commits into
masterfrom
sg/do-let-config

Conversation

@sgraf812
Copy link
Copy Markdown
Contributor

This PR adds support for let configuration options ((eq := h), +nondep, +usedOnly, +zeta) in do block let and have declarations, matching the behavior available in term-level let/have. Configuration options are rejected with let mut since they are incompatible with mutable bindings. +postponeValue and +generalize are also rejected in do blocks.

Parser changes add letConfig to doLet, doLetElse, doLetArrow, and doHave. Both the legacy and new do elaborators are updated with backward-compatible index handling (stage0 macros may produce old-shape syntax without letConfig).

Example usage:

do
  let (eq := h) x := "hello"
  -- h : x = "hello" is available
  have : x = "hello" := h
  return x

🤖 Generated with Claude Code

This PR adds support for let configuration options (`(eq := h)`, `+nondep`,
`+usedOnly`, `+zeta`) in `do` block `let` and `have` declarations, matching
the behavior available in term-level `let`/`have`. Configuration options are
rejected with `let mut` since they are incompatible with mutable bindings.
`+postponeValue` and `+generalize` are also rejected in `do` blocks.

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

Mathlib CI status (docs):

  • ❗ Mathlib CI can not be attempted yet, as the nightly-testing-2026-03-31 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Mathlib CI should run now. You can force Mathlib CI using the force-mathlib-ci label. (2026-03-31 14:46:46)

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-03-31 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-03-31 14:46:48)

Use trace.Elab.definition.body to verify +zeta and +usedOnly effects.
Remove legacy do elaborator tests. Set backward.do.legacy false at module level.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sgraf812
Copy link
Copy Markdown
Contributor Author

sgraf812 commented Apr 2, 2026

#13255

@sgraf812 sgraf812 closed this Apr 2, 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.

2 participants