diff --git a/src/Lean/Elab/BuiltinCommand.lean b/src/Lean/Elab/BuiltinCommand.lean index 8be3d5563d..455920be4c 100644 --- a/src/Lean/Elab/BuiltinCommand.lean +++ b/src/Lean/Elab/BuiltinCommand.lean @@ -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 diff --git a/tests/lean/run/check_failure.lean b/tests/lean/run/check_failure.lean new file mode 100644 index 0000000000..c71b78ec9b --- /dev/null +++ b/tests/lean/run/check_failure.lean @@ -0,0 +1,2 @@ +-- #check_failure should not ignore stuck TC problems. +#check_failure (inferInstance : Inhabited (Nat × _))