fix: #check_failure command should succeed if there are stuck TC problems

This commit is contained in:
Leonardo de Moura 2021-11-15 16:56:55 -08:00
parent 9a152d2051
commit 4b2fa38cb8
2 changed files with 7 additions and 3 deletions

View file

@ -209,16 +209,18 @@ private def replaceBinderAnnotation (binder : Syntax) : CommandElabM Bool := do
open Meta
@[builtinCommandElab Lean.Parser.Command.check] def elabCheck : CommandElab
def elabCheckCore (ignoreStuckTC : Bool) : CommandElab
| `(#check%$tk $term) => withoutModifyingEnv $ runTermElabM (some `_check) fun _ => do
let e ← Term.elabTerm term none
Term.synthesizeSyntheticMVarsNoPostponing (ignoreStuckTC := true)
Term.synthesizeSyntheticMVarsNoPostponing (ignoreStuckTC := ignoreStuckTC)
let (e, _) ← Term.levelMVarToParam (← instantiateMVars e)
let type ← inferType e
unless e.isSyntheticSorry do
logInfoAt tk m!"{e} : {type}"
| _ => throwUnsupportedSyntax
@[builtinCommandElab Lean.Parser.Command.check] def elabCheck : CommandElab := elabCheckCore (ignoreStuckTC := true)
@[builtinCommandElab Lean.Parser.Command.reduce] def elabReduce : CommandElab
| `(#reduce%$tk $term) => withoutModifyingEnv <| runTermElabM (some `_check) fun _ => do
let e ← Term.elabTerm term none
@ -256,7 +258,7 @@ def failIfSucceeds (x : CommandElabM Unit) : CommandElabM Unit := do
@[builtinCommandElab «check_failure»] def elabCheckFailure : CommandElab
| `(#check_failure $term) => do
failIfSucceeds <| elabCheck (← `(#check $term))
failIfSucceeds <| elabCheckCore (ignoreStuckTC := false) (← `(#check $term))
| _ => throwUnsupportedSyntax
private def mkEvalInstCore (evalClassName : Name) (e : Expr) : MetaM Expr := do

View file

@ -0,0 +1,2 @@
-- #check_failure should not ignore stuck TC problems.
#check_failure (inferInstance : Inhabited (Nat × _))