diff --git a/src/Lean/AddDecl.lean b/src/Lean/AddDecl.lean index c67a1152e8..d56aec5aa4 100644 --- a/src/Lean/AddDecl.lean +++ b/src/Lean/AddDecl.lean @@ -9,6 +9,7 @@ prelude public import Lean.Meta.Sorry public import Lean.Util.CollectAxioms public import Lean.OriginalConstKind +import Lean.Compiler.MetaAttr import all Lean.OriginalConstKind -- for accessing `privateConstKindsExt` public section @@ -208,8 +209,12 @@ where catch _ => pure () -def addAndCompile (decl : Declaration) (logCompileErrors : Bool := true) : CoreM Unit := do +def addAndCompile (decl : Declaration) (logCompileErrors : Bool := true) + (markMeta : Bool := false) : CoreM Unit := do addDecl decl + if markMeta then + for n in decl.getNames do + modifyEnv (Lean.markMeta · n) compileDecl decl (logErrors := logCompileErrors) end Lean diff --git a/src/Lean/ParserCompiler.lean b/src/Lean/ParserCompiler.lean index 01f647bedb..8c80c6a996 100644 --- a/src/Lean/ParserCompiler.lean +++ b/src/Lean/ParserCompiler.lean @@ -110,9 +110,7 @@ partial def compileParserExpr (e : Expr) : MetaM Expr := do } -- usually `meta` is inferred during compilation for auxiliary definitions, but as -- `ctx.combinatorAttr` may enforce correct use of the modifier, infer now. - if isMarkedMeta (← getEnv) c then - modifyEnv (markMeta · c') - addAndCompile decl + addAndCompile decl (markMeta := isMarkedMeta (← getEnv) c) modifyEnv (ctx.combinatorAttr.setDeclFor · c c') if cinfo.type.isConst then if let some kind ← parserNodeKind? cinfo.value! then