chore: fix failing mk*Sorry in bootstrapping contexts (#9950)
This commit is contained in:
parent
6f7dba167a
commit
81a4b0ca99
4 changed files with 18 additions and 2 deletions
|
|
@ -1188,9 +1188,8 @@ private def mkSyntheticSorryFor (expectedType? : Option Expr) : TermElabM Expr :
|
|||
elaboration step with exception `ex`.
|
||||
-/
|
||||
def exceptionToSorry (ex : Exception) (expectedType? : Option Expr) : TermElabM Expr := do
|
||||
let syntheticSorry ← mkSyntheticSorryFor expectedType?
|
||||
logException ex
|
||||
pure syntheticSorry
|
||||
mkSyntheticSorryFor expectedType?
|
||||
|
||||
/-- If `mayPostpone == true`, throw `Exception.postpone`. -/
|
||||
def tryPostpone : TermElabM Unit := do
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ Returns `sorryAx type synthetic`. Recall that `synthetic` is true if this sorry
|
|||
See also `Lean.Meta.mkLabeledSorry`, for creating a `sorry` that is labeled or unique.
|
||||
-/
|
||||
def mkSorry (type : Expr) (synthetic : Bool) : MetaM Expr := do
|
||||
if !(← hasConst ``sorryAx) then
|
||||
-- Abort if we are not ready yet to generate `sorry`s in bootstrapping contexts.
|
||||
Elab.throwAbortCommand
|
||||
let u ← getLevel type
|
||||
return mkApp2 (mkConst ``sorryAx [u]) type (toExpr synthetic)
|
||||
|
||||
|
|
@ -77,6 +80,9 @@ Constructs a `sorryAx`.
|
|||
* If `unique` is true, the `sorry` is unique, in the sense that it is not defeq to any other `sorry` created by `mkLabeledSorry`.
|
||||
-/
|
||||
def mkLabeledSorry (type : Expr) (synthetic : Bool) (unique : Bool) : MetaM Expr := do
|
||||
if !(← hasConst ``Lean.Name) then
|
||||
-- Abort if we are not ready yet to generate `sorry`s in bootstrapping contexts.
|
||||
Elab.throwAbortCommand
|
||||
let tag ←
|
||||
if let (some startSPos, some endSPos) := ((← getRef).getPos?, (← getRef).getTailPos?) then
|
||||
let fileMap ← getFileMap
|
||||
|
|
|
|||
8
tests/lean/bootstrapSorry.lean
Normal file
8
tests/lean/bootstrapSorry.lean
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
module
|
||||
|
||||
prelude
|
||||
import Init.Prelude
|
||||
|
||||
/-! Trying to generate a `sorry` should not itself lead to errors in bootstrapping contexts. -/
|
||||
|
||||
public abbrev Foo := Nat
|
||||
3
tests/lean/bootstrapSorry.lean.expected.out
Normal file
3
tests/lean/bootstrapSorry.lean.expected.out
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
bootstrapSorry.lean:8:21-8:24: error(lean.unknownIdentifier): Unknown identifier `Nat`
|
||||
|
||||
Note: A private declaration `Nat` exists but is not accessible in the current context.
|
||||
Loading…
Add table
Reference in a new issue