This commit is contained in:
Leonardo de Moura 2022-09-09 14:29:48 -07:00
parent 16534bacc9
commit 7c3826d3e9
4 changed files with 9 additions and 1 deletions

View file

@ -19,13 +19,15 @@ macro (name := configElab) doc?:(docComment)? "declare_config_elab" elabName:ide
if optConfig.isNone then
return { : $type }
else
let c ← withoutModifyingState <| withLCtx {} {} <| withSaveInfoContext <| Term.withSynthesize do
let c ← withoutModifyingStateWithInfoAndMessages <| withLCtx {} {} <| withSaveInfoContext <| Term.withSynthesize do
let c ← Term.elabTermEnsuringType optConfig[0][3] (Lean.mkConst ``$type)
Term.synthesizeSyntheticMVarsNoPostponing
instantiateMVars c
eval c
)
#check @evalExpr'
open Linter.MissingDocs in
@[builtinMissingDocsHandler Elab.Tactic.configElab]
def checkConfigElab : SimpleHandler := mkSimpleHandler "config elab"

View file

@ -10,6 +10,9 @@ namespace Lean.Meta
unsafe def evalExprCore (α) (value : Expr) (checkType : Expr → MetaM Unit) (safety := DefinitionSafety.safe) : MetaM α :=
withoutModifyingEnv do
let name ← mkFreshUserName `_tmp
let value ← instantiateMVars value
if value.hasMVar then
throwError "failed to evaluate expression, it contains metavariables{indentExpr value}"
let type ← inferType value
checkType type
let decl := Declaration.defnDecl {

1
tests/lean/1576.lean Normal file
View file

@ -0,0 +1 @@
example : True := by rw (config := non / sense) []

View file

@ -0,0 +1,2 @@
1576.lean:1:35-1:38: error: unknown identifier 'non'
1576.lean:1:41-1:46: error: unknown identifier 'sense'