Repository navigation
Conversation
…th master Upstream master bumped the toolchain past this branch (v4.36.0-rc2 -> v4.36.0 -> v4.37.0-rc1 in leanprover-community#179/leanprover-community#180), conflicting with the rc1->rc2 bump this branch carried from the fork's merge-base. Setting the branch's toolchain to master's makes the merge clean; the PR diff relative to the merge result is unchanged. Verified locally on leanprover/lean4:v4.37.0-rc1 (upstream master ad0c9f8 + this branch, toolchain conflict resolved to master's version): `lake build --wfail` passes (31 jobs, no warnings) and `lake test` passes (exit 0, incl. QqTest.ifLetMut).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #36.
Problem
The issue's MWE failed in both
if letbranches withVariable x cannot be mutated:_qq_matchelaborates the successful branch inside the continuation of its generatedBind.bind. Lean'sdoelaborator does not permit mutation of an outerlet mutvariable inside that generated lambda.Fix
For a whole-pattern, capture-free
if let ~q(...), evaluate the quotation match before choosing a branch, then use an ordinarydomatch on the result:mkIsDefEqOptionreturnsnoneon failure, or the match result paired with itsmatch_eqproof on success._qq_match_optionelaborator reuses the existing pattern elaboration and lifts the result to the enclosing monad.doIfexpansion uses a monadic discriminant (match ← test with), so branch bodies are handled directly by Lean's ordinarydoelaborator rather than by the matcher's continuation lambda. This preserveslet mutand branch control flow.Scope: this intentionally covers capture-free patterns, including the issue's MWE. Capture-bearing patterns continue through the existing continuation-based matcher unchanged; returning their dependent pattern variables and
match_eqproof is a larger change and is not attempted here.Tests
New
QqTest/ifLetMut.leancovers:2versus3);elsebranches, including the fall-through result;TacticMas well asMetaM;Verification
On the pinned
leanprover/lean4:v4.36.0-rc2toolchain:masterwith the issue's mutation errors.lake build --wfail— passes (30 jobs, no warnings).lake test— passes (exit 0; fullQqTestsuite, 59 jobs).sorryoradmitintroduced.git hash-object) to the locally built and tested sources.Branch note: my fork's sync commit means the PR diff may also show the one-line
lean-toolchainchange from #170, which upstream already has; merging is content-neutral for that file. The intended change is exactlyQq/Match.leanand the newQqTest/ifLetMut.lean.