Skip to content

feat: generalize withSetOptionIn to arbitrary result types - #14581

Merged
wkrozowski merged 1 commit into
leanprover:masterfrom
marcelolynch:generalize-withSetOptionIn
Jul 29, 2026
Merged

feat: generalize withSetOptionIn to arbitrary result types#14581
wkrozowski merged 1 commit into
leanprover:masterfrom
marcelolynch:generalize-withSetOptionIn

Conversation

@marcelolynch

@marcelolynch marcelolynch commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

This PR generalizes withSetOptionIn over the result type of the wrapped function. The previous signature only accepted a CommandElab, which returns Unit. The phases of a stateful linter (#14357) return values, so they could not use the helper (see for example leanprover-community/mathlib4#42186). All existing call sites instantiate the result type with Unit and do not change.

A new resultType section in tests/elab/withSetOptionIn.lean checks the generalized signature.

The change preserves behavior. Type inference changes in one corner case: a first-class use with no expected type, where the wrapped function does not determine its result type, now needs a type ascription. Core, Batteries, and Mathlib contain no such use.

🤖 Generated with Claude Code

@marcelolynch
marcelolynch marked this pull request as ready for review July 28, 2026 14:11
@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 Jul 28, 2026
@mathlib-lean-pr-testing

mathlib-lean-pr-testing Bot commented Jul 28, 2026

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 a39eab69e1eee9ad38f4efe507907b1026a77808 --onto 0bfc3acaef4ed0576307a77fbaa0c6e1a5dca402. You can force Mathlib CI using the force-mathlib-ci label. (2026-07-28 14:30:27)
  • ✅ Mathlib branch lean-pr-testing-14581 has successfully built against this PR. (2026-07-29 14:24:19) View Log

@leanprover-bot

leanprover-bot commented Jul 28, 2026

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 a39eab69e1eee9ad38f4efe507907b1026a77808 --onto aa89d2777fb4342ff3084502e8f2d5a01aa17222. You can force reference manual CI using the force-manual-ci label. (2026-07-28 14:30:29)
  • ✅ Reference manual branch lean-pr-testing-14581 has successfully built against this PR. (2026-07-29 13:34:57) View Log
  • 🟡 Reference manual branch lean-pr-testing-14581 build against this PR didn't complete normally. (2026-07-29 13:36:54) View Log

The phases of a stateful linter (leanprover#14357) return values, so they cannot
use the CommandElab-only signature. All existing call sites instantiate
the result type with Unit and do not change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@wkrozowski
wkrozowski force-pushed the generalize-withSetOptionIn branch from 907fc08 to 47b10a0 Compare July 29, 2026 13:02
@github-actions github-actions Bot added the mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN label Jul 29, 2026
@leanprover-bot leanprover-bot added the builds-manual CI has verified that the Lean Language Reference builds against this PR label Jul 29, 2026
@wkrozowski

Copy link
Copy Markdown
Contributor

LGTM

@wkrozowski
wkrozowski added this pull request to the merge queue Jul 29, 2026
@mathlib-lean-pr-testing mathlib-lean-pr-testing Bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Jul 29, 2026
Merged via the queue into leanprover:master with commit 7830144 Jul 29, 2026
36 checks passed
robsimmons pushed a commit that referenced this pull request Jul 29, 2026
This PR generalizes `withSetOptionIn` over the result type of the
wrapped function. The previous signature only accepted a `CommandElab`,
which returns `Unit`. The phases of a stateful linter (#14357) return
values, so they could not use the helper (see for example
leanprover-community/mathlib4#42186). All existing call sites
instantiate the result type with `Unit` and do not change.

A new `resultType` section in `tests/elab/withSetOptionIn.lean` checks
the generalized signature.

The change preserves behavior. Type inference changes in one corner
case: a first-class use with no expected type, where the wrapped
function does not determine its result type, now needs a type
ascription. Core, Batteries, and Mathlib contain no such use.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-manual CI has verified that the Lean Language Reference builds against this PR builds-mathlib CI has verified that Mathlib builds against this PR changelog-language Language features and metaprograms mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN 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.

3 participants