Skip to content

Commit 3501a62

Browse files
committed
Merge remote-tracking branch 'origin/nightly-testing' into bump_to_v4.27.0-rc1
# Conflicts: # lean-toolchain
2 parents d64e197 + 0a83ad7 commit 3501a62

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

Qq/Delab.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ namespace Impl
1616

1717
register_option pp.qq : Bool := {
1818
defValue := true
19-
group := "pp"
2019
descr := "(pretty printer) print quotations as q(...) and Q(...)"
2120
}
2221

Qq/Macro.lean

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ meta def removeDollar : Name → Option Name
9191
| anonymous => none
9292
| str anonymous "$" => some anonymous
9393
| str anonymous s =>
94-
if s.startsWith "$" then str anonymous (s.drop 1) else none
94+
if s.startsWith "$" then str anonymous (s.drop 1).copy else none
9595
| str n s => (removeDollar n).map (str . s)
9696
| num n i => (removeDollar n).map (num . i)
9797

@@ -100,8 +100,8 @@ meta def stripDollars : Name → Name
100100
| anonymous => anonymous
101101
| str n "$" => stripDollars n
102102
| str anonymous s =>
103-
let s := s.dropWhile (· = '$')
104-
if s = "" then anonymous else str anonymous s
103+
let s := s.dropWhile '$'
104+
if s.isEmpty then anonymous else str anonymous s.copy
105105
| str n s => str (stripDollars n) s
106106
| num n i => num (stripDollars n) i
107107

@@ -126,7 +126,7 @@ meta def isBad (e : Expr) : Bool := Id.run do
126126
return false
127127

128128
-- https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/How.20to.20WHNF.20without.20exposing.20recursors.3F/near/249743042
129-
meta def whnf (e : Expr) (e0 : Expr := e) : MetaM Expr := do
129+
meta partial def whnf (e : Expr) (e0 : Expr := e) : MetaM Expr := do
130130
let e ← whnfCore e
131131
let e0 := if isBad e then e0 else e
132132
match ← unfoldDefinition? e with
@@ -172,7 +172,7 @@ meta partial def unquoteLevelMVar (mvar : Expr) : UnquoteM Level := do
172172

173173
end
174174

175-
meta def unquoteLevelList (e : Expr) : UnquoteM (List Level) := do
175+
meta partial def unquoteLevelList (e : Expr) : UnquoteM (List Level) := do
176176
let e ← whnf e
177177
if e.isAppOfArity ``List.nil 1 then
178178
pure []
@@ -217,7 +217,7 @@ meta def makeDefEq (a b : Expr) : MetaM (Option LocalContext) := do
217217

218218
mutual
219219

220-
meta def unquoteExprList (e : Expr) : UnquoteM (List Expr) := do
220+
meta partial def unquoteExprList (e : Expr) : UnquoteM (List Expr) := do
221221
let e ← whnf e
222222
if e.isAppOfArity ``List.nil 1 then
223223
pure []
@@ -226,7 +226,7 @@ meta def unquoteExprList (e : Expr) : UnquoteM (List Expr) := do
226226
else
227227
throwFailedToEval e
228228

229-
meta def unquoteExprMVar (mvar : Expr) : UnquoteM Expr := do
229+
meta partial def unquoteExprMVar (mvar : Expr) : UnquoteM Expr := do
230230
let ty ← instantiateMVars (← whnfR (← inferType mvar))
231231
unless ty.isAppOf ``Quoted do throwError "not of type Q(_):{indentExpr ty}"
232232
have et := ty.getArg! 0
@@ -239,7 +239,7 @@ meta def unquoteExprMVar (mvar : Expr) : UnquoteM Expr := do
239239
}
240240
return newMVar
241241

242-
meta def unquoteExpr (e : Expr) : UnquoteM Expr := do
242+
meta partial def unquoteExpr (e : Expr) : UnquoteM Expr := do
243243
if e.isAppOfArity ``Quoted.unsafeMk 2 then return ← unquoteExpr (e.getArg! 1)
244244
if e.isAppOfArity ``toExpr 3 then return e.getArg! 2
245245
let e ← instantiateMVars (← whnf e)
@@ -388,7 +388,7 @@ meta def quoteLevelList : List Level → QuoteM Expr
388388
return mkApp3 (.const ``List.cons [.zero]) (.const ``Level [])
389389
(← quoteLevel l) (← quoteLevelList ls)
390390

391-
meta def quoteExpr : Expr → QuoteM Expr
391+
meta partial def quoteExpr : Expr → QuoteM Expr
392392
| .bvar i => return mkApp (.const ``Expr.bvar []) (toExpr i)
393393
| e@(.fvar ..) => do
394394
let some r := (← read).exprBackSubst[e]? | throwError "unknown free variable {e}"
@@ -511,7 +511,7 @@ meta def Impl.UnquoteState.withLevelNames (s : UnquoteState) (k : TermElabM (α
511511
if let some fvar ← isLevelFVar newLevelName then
512512
if refdLevels.contains newLevelName then
513513
addTermInfo' (← getRef) fvar
514-
else if (← read).autoBoundImplicit then
514+
else if (← read).autoBoundImplicitContext.isSome then
515515
throwAutoBoundImplicitLocal newLevelName
516516
else
517517
throwError "unbound level param {newLevelName}"
@@ -613,7 +613,7 @@ support `Q($(foo) ∨ False)`
613613
private meta def push [Monad m] (i t l : Syntax) : StateT (Array $ Syntax × Syntax × Syntax) m Unit :=
614614
modify fun s => s.push (i, t, l)
615615

616-
meta def floatLevelAntiquot' [Monad m] [MonadQuotation m] (stx : Syntax) :
616+
meta partial def floatLevelAntiquot' [Monad m] [MonadQuotation m] (stx : Syntax) :
617617
StateT (Array $ Syntax × Syntax × Syntax) m Syntax :=
618618
if stx.isAntiquot && !stx.isEscapedAntiquot then
619619
withFreshMacroScope do
@@ -625,7 +625,7 @@ meta def floatLevelAntiquot' [Monad m] [MonadQuotation m] (stx : Syntax) :
625625
| stx => return stx
626626

627627
open TSyntax.Compat in
628-
meta def floatExprAntiquot' [Monad m] [MonadQuotation m] (depth : Nat) :
628+
meta partial def floatExprAntiquot' [Monad m] [MonadQuotation m] (depth : Nat) :
629629
Syntax → StateT (Array $ Syntax × Syntax × Syntax) m Syntax
630630
| `(Q($x)) => do `(Q($(← floatExprAntiquot' (depth + 1) x)))
631631
| `(q($x)) => do `(q($(← floatExprAntiquot' (depth + 1) x)))

0 commit comments

Comments
 (0)