Compare commits

...

3 Commits

Author SHA1 Message Date
Kim Morrison
696ac46afd . 2024-08-19 19:47:03 +10:00
Kim Morrison
2ae0980314 test 2024-08-19 19:40:51 +10:00
Kim Morrison
48f61a2977 add debug.sorryProps 2024-08-19 19:40:38 +10:00
2 changed files with 13 additions and 0 deletions

View File

@@ -1667,6 +1667,12 @@ def addDotCompletionInfo (stx : Syntax) (e : Expr) (expectedType? : Option Expr)
def elabTerm (stx : Syntax) (expectedType? : Option Expr) (catchExPostpone := true) (implicitLambda := true) : TermElabM Expr :=
withRef stx <| elabTermAux expectedType? catchExPostpone implicitLambda stx
register_builtin_option debug.sorryProps : Bool := {
defValue := false
group := "debug"
descr := "replace elaboration of any term with a propositional type with no metavariables with `sorry`"
}
/--
Similar to `Lean.Elab.Term.elabTerm`, but ensures that the type of the elaborated term is `expectedType?`
by inserting coercions if necessary.
@@ -1675,6 +1681,9 @@ If `errToSorry` is true, then if coercion insertion fails, this function returns
Otherwise, it throws the error.
-/
def elabTermEnsuringType (stx : Syntax) (expectedType? : Option Expr) (catchExPostpone := true) (implicitLambda := true) (errorMsgHeader? : Option String := none) : TermElabM Expr := do
if let some expectedType := expectedType? then
if ( pure (debug.sorryProps.get ( getOptions))) && !expectedType.hasMVar && ( isProp expectedType) then
return mkSorry expectedType false
let e elabTerm stx expectedType? catchExPostpone implicitLambda
try
withRef stx <| ensureHasType expectedType? e errorMsgHeader?

View File

@@ -0,0 +1,4 @@
/-- warning: declaration uses 'sorry' -/
#guard_msgs in
set_option debug.sorryProps true in
example : 1 = 2 := rfl