fix: #check_failure command should succeed if there are stuck TC problems
This commit is contained in:
parent
9a152d2051
commit
4b2fa38cb8
2 changed files with 7 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
2
tests/lean/run/check_failure.lean
Normal file
2
tests/lean/run/check_failure.lean
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
-- #check_failure should not ignore stuck TC problems.
|
||||
#check_failure (inferInstance : Inhabited (Nat × _))
|
||||
Loading…
Add table
Reference in a new issue