Skip to content

Commit cc622b9

Browse files
committed
chore: backward.privateInPublic.warn and attrs
1 parent f8c42e1 commit cc622b9

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Lean/Attributes.lean

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,14 @@ def throwAttrDeclNotOfExpectedType (attrName declName : Name) (givenType expecte
148148
throwError m!"Cannot add attribute `[{attrName}]`: Declaration `{.ofConstName declName}` has type{indentExpr givenType}\n\
149149
but `[{attrName}]` can only be added to declarations of type{indentExpr expectedType}"
150150

151-
def ensureAttrDeclIsPublic [MonadEnv m] (attrName declName : Name) (attrKind : AttributeKind) : m Unit := do
152-
if (← getEnv).header.isModule && attrKind != .local && !((← getEnv).setExporting true).contains declName then
153-
throwError m!"Cannot add attribute `[{attrName}]`: Declaration `{.ofConstName declName}` must be public"
154-
155-
def ensureAttrDeclIsMeta [MonadEnv m] (attrName declName : Name) (attrKind : AttributeKind) : m Unit := do
151+
def ensureAttrDeclIsPublic (attrName declName : Name) (attrKind : AttributeKind) : AttrM Unit := do
152+
if (← getEnv).header.isModule && attrKind != .local then
153+
withExporting do
154+
checkPrivateInPublic declName
155+
if !(← hasConst declName) then
156+
throwError m!"Cannot add attribute `[{attrName}]`: Declaration `{.ofConstName declName}` must be public"
157+
158+
def ensureAttrDeclIsMeta (attrName declName : Name) (attrKind : AttributeKind) : AttrM Unit := do
156159
if (← getEnv).header.isModule && !isMeta (← getEnv) declName then
157160
throwError m!"Cannot add attribute `[{attrName}]`: Declaration `{.ofConstName declName}` must be marked as `meta`"
158161
-- Make sure attributed decls can't refer to private meta imports, which is already checked for

0 commit comments

Comments
 (0)