chore: fix mutable variable shadowing
This commit is contained in:
parent
5d22752b10
commit
8b4cdcfddd
9 changed files with 33 additions and 33 deletions
|
|
@ -292,10 +292,10 @@ where
|
|||
|
||||
@[builtinTermElab stateRefT] def elabStateRefT : TermElab := fun stx _ => do
|
||||
let σ ← elabType stx[1]
|
||||
let mut m := stx[2]
|
||||
if m.getKind == `Lean.Parser.Term.macroDollarArg then
|
||||
m := m[1]
|
||||
let m ← elabTerm m (← mkArrow (mkSort levelOne) (mkSort levelOne))
|
||||
let mut mStx := stx[2]
|
||||
if mStx.getKind == `Lean.Parser.Term.macroDollarArg then
|
||||
mStx := mStx[1]
|
||||
let m ← elabTerm mStx (← mkArrow (mkSort levelOne) (mkSort levelOne))
|
||||
let ω ← mkFreshExprMVar (mkSort levelOne)
|
||||
let stWorld ← mkAppM `STWorld #[ω, m]
|
||||
discard <| mkInstMVar stWorld
|
||||
|
|
|
|||
|
|
@ -469,14 +469,14 @@ private def mkInductiveDecl (vars : Array Expr) (views : Array InductiveView) :
|
|||
let rs ← elabHeader views
|
||||
withInductiveLocalDecls rs fun params indFVars => do
|
||||
let numExplicitParams := params.size
|
||||
let mut indTypes := #[]
|
||||
let mut indTypesArray := #[]
|
||||
for i in [:views.size] do
|
||||
let indFVar := indFVars[i]
|
||||
let r := rs[i]
|
||||
let type ← mkForallFVars params r.type
|
||||
let ctors ← elabCtors indFVars indFVar params r
|
||||
indTypes := indTypes.push { name := r.view.declName, type := type, ctors := ctors : InductiveType }
|
||||
let indTypes := indTypes.toList
|
||||
indTypesArray := indTypesArray.push { name := r.view.declName, type := type, ctors := ctors : InductiveType }
|
||||
let indTypes := indTypesArray.toList
|
||||
Term.synthesizeSyntheticMVarsNoPostponing
|
||||
let u ← getResultingUniverse indTypes
|
||||
let inferLevel ← shouldInferResultUniverse u
|
||||
|
|
|
|||
|
|
@ -448,23 +448,23 @@ private partial def compileStxMatch (discrs : List Syntax) (alts : List Alt) : T
|
|||
for alt in alts do
|
||||
let mut alt := alt
|
||||
match alt with
|
||||
| (covered f exh, alt) =>
|
||||
| (covered f exh, alt') =>
|
||||
-- we can only factor out a common check if there are no undecided patterns in between;
|
||||
-- otherwise we would change the order of alternatives
|
||||
if undecidedAlts.isEmpty then
|
||||
yesAlts ← yesAlts.push <$> f (alt.1.tail!, alt.2)
|
||||
yesAlts ← yesAlts.push <$> f (alt'.1.tail!, alt'.2)
|
||||
if !exh then
|
||||
nonExhaustiveAlts := nonExhaustiveAlts.push alt
|
||||
nonExhaustiveAlts := nonExhaustiveAlts.push alt'
|
||||
else
|
||||
(floatedLetDecls, alt) ← deduplicate floatedLetDecls alt
|
||||
(floatedLetDecls, alt) ← deduplicate floatedLetDecls alt'
|
||||
undecidedAlts := undecidedAlts.push alt
|
||||
nonExhaustiveAlts := nonExhaustiveAlts.push alt
|
||||
| (undecided, alt) =>
|
||||
(floatedLetDecls, alt) ← deduplicate floatedLetDecls alt
|
||||
| (undecided, alt') =>
|
||||
(floatedLetDecls, alt) ← deduplicate floatedLetDecls alt'
|
||||
undecidedAlts := undecidedAlts.push alt
|
||||
nonExhaustiveAlts := nonExhaustiveAlts.push alt
|
||||
| (uncovered, alt) =>
|
||||
nonExhaustiveAlts := nonExhaustiveAlts.push alt
|
||||
| (uncovered, alt') =>
|
||||
nonExhaustiveAlts := nonExhaustiveAlts.push alt'
|
||||
let mut stx ← info.doMatch
|
||||
(yes := fun newDiscrs => do
|
||||
let mut yesAlts := yesAlts
|
||||
|
|
|
|||
|
|
@ -208,8 +208,8 @@ where
|
|||
let mut (_, altMVarId) ← introN altMVarId numFields
|
||||
match (← Cases.unifyEqs numEqs altMVarId {}) with
|
||||
| none => pure () -- alternative is not reachable
|
||||
| some (altMVarId, _) =>
|
||||
let (_, altMVarId) ← introNP altMVarId numGeneralized
|
||||
| some (altMVarId', _) =>
|
||||
(_, altMVarId) ← introNP altMVarId' numGeneralized
|
||||
for fvarId in toClear do
|
||||
altMVarId ← tryClear altMVarId fvarId
|
||||
let altMVarIds ← applyPreTac altMVarId
|
||||
|
|
@ -234,8 +234,8 @@ where
|
|||
let mut (_, altMVarId) ← introN altMVarId numFields altVarNames.toList (useNamesForExplicitOnly := !altHasExplicitModifier altStx)
|
||||
match (← Cases.unifyEqs numEqs altMVarId {}) with
|
||||
| none => unusedAlt
|
||||
| some (altMVarId, _) =>
|
||||
let (_, altMVarId) ← introNP altMVarId numGeneralized
|
||||
| some (altMVarId', _) =>
|
||||
(_, altMVarId) ← introNP altMVarId' numGeneralized
|
||||
for fvarId in toClear do
|
||||
altMVarId ← tryClear altMVarId fvarId
|
||||
let altMVarIds ← applyPreTac altMVarId
|
||||
|
|
@ -243,8 +243,8 @@ where
|
|||
unusedAlt
|
||||
else
|
||||
let mut subgoals := subgoals
|
||||
for altMVarId in altMVarIds do
|
||||
subgoals ← evalAlt altMVarId altStx subgoals
|
||||
for altMVarId' in altMVarIds do
|
||||
subgoals ← evalAlt altMVarId' altStx subgoals
|
||||
pure (subgoals, usedWildcard || isWildcard)
|
||||
if usedWildcard then
|
||||
altsSyntax := altsSyntax.filter fun alt => getAltName alt != `_
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ private def getFunInfoAux (fn : Expr) (maxArgs? : Option Nat) : MetaM FunInfo :=
|
|||
instImplicit := decl.binderInfo == BinderInfo.instImplicit
|
||||
}
|
||||
let resultDeps := collectDeps fvars type
|
||||
let pinfo := updateHasFwdDeps pinfo resultDeps
|
||||
pinfo := updateHasFwdDeps pinfo resultDeps
|
||||
pure { resultDeps := resultDeps, paramInfo := pinfo }
|
||||
|
||||
def getFunInfo (fn : Expr) : MetaM FunInfo :=
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ private def reduceRec (recVal : RecursorVal) (recLvls : List Level) (recArgs : A
|
|||
if recVal.k then
|
||||
let newMajor ← toCtorWhenK recVal major
|
||||
major := newMajor.getD major
|
||||
let major := toCtorIfLit major
|
||||
major := toCtorIfLit major
|
||||
match getRecRuleFor recVal major with
|
||||
| some rule =>
|
||||
let majorArgs := major.getAppArgs
|
||||
|
|
|
|||
|
|
@ -637,19 +637,19 @@ private partial def sepByFnAux (p : ParserFn) (sep : ParserFn) (allowTrailingSep
|
|||
if s.pos > pos then
|
||||
return s.mkNode nullKind iniSz
|
||||
else if pOpt then
|
||||
let s := s.restore sz pos
|
||||
s := s.restore sz pos
|
||||
return s.mkNode nullKind iniSz
|
||||
else
|
||||
-- append `Syntax.missing` to make clear that List is incomplete
|
||||
let s := s.pushSyntax Syntax.missing
|
||||
s := s.pushSyntax Syntax.missing
|
||||
return s.mkNode nullKind iniSz
|
||||
if s.stackSize > sz + 1 then
|
||||
s := s.mkNode nullKind sz
|
||||
let sz := s.stackSize
|
||||
let pos := s.pos
|
||||
let s := sep c s
|
||||
s := sep c s
|
||||
if s.hasError then
|
||||
let s := s.restore sz pos
|
||||
s := s.restore sz pos
|
||||
return s.mkNode nullKind iniSz
|
||||
if s.stackSize > sz + 1 then
|
||||
s := s.mkNode nullKind sz
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ partial instance : ForIn m TopDown Syntax where
|
|||
for arg in args do
|
||||
match ← loop arg b with
|
||||
| ForInStep.yield b' => b := b'
|
||||
| ForInStep.done b => return ForInStep.done b
|
||||
| ForInStep.done b' => return ForInStep.done b'
|
||||
return ForInStep.yield b
|
||||
| ForInStep.done b => return ForInStep.done b
|
||||
match ← @loop stx init ⟨init⟩ with
|
||||
|
|
@ -213,10 +213,10 @@ partial def reprint (stx : Syntax) : Option String :=
|
|||
if kind == choiceKind then
|
||||
-- this visit the first arg twice, but that should hardly be a problem
|
||||
-- given that choice nodes are quite rare and small
|
||||
let s ← reprint args[0]
|
||||
let s0 ← reprint args[0]
|
||||
for arg in args[1:] do
|
||||
let s' ← reprint stx
|
||||
guard (s == s')
|
||||
guard (s0 == s')
|
||||
| _ => pure ()
|
||||
return s
|
||||
where
|
||||
|
|
|
|||
|
|
@ -213,13 +213,13 @@ partial def forInAux {α : Type u} {β : Type v} {m : Type v → Type w} [Monad
|
|||
| leaf vs =>
|
||||
for v in vs do
|
||||
match (← f v b) with
|
||||
| r@(ForInStep.done b) => return r
|
||||
| r@(ForInStep.done _) => return r
|
||||
| ForInStep.yield bNew => b := bNew
|
||||
return ForInStep.yield b
|
||||
| node cs =>
|
||||
for c in cs do
|
||||
match (← forInAux f c b) with
|
||||
| r@(ForInStep.done b) => return r
|
||||
| r@(ForInStep.done _) => return r
|
||||
| ForInStep.yield bNew => b := bNew
|
||||
return ForInStep.yield b
|
||||
|
||||
|
|
@ -230,7 +230,7 @@ partial def forInAux {α : Type u} {β : Type v} {m : Type v → Type w} [Monad
|
|||
let mut b := b
|
||||
for v in t.tail do
|
||||
match (← f v b) with
|
||||
| ForInStep.done b => return b
|
||||
| ForInStep.done r => return r
|
||||
| ForInStep.yield bNew => b := bNew
|
||||
return b
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue