Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Lean/Elab/Attributes.lean
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def elabAttr [Monad m] [MonadEnv m] [MonadResolveName m] [MonadError m] [MonadMa
else match attr.getKind with
| .str _ s => pure <| Name.mkSimple s
| _ => throwErrorAt attr "Unknown attribute"
let .ok _impl := getAttributeImpl (← getEnv) attrName
| throwError "Unknown attribute `[{attrName}]`"
if let .ok impl := getAttributeImpl (← getEnv) attrName then
match getAttributeImpl (← getEnv) attrName with
| .error _ => throwError "Unknown attribute `[{attrName}]`. Note, that attributes are impossible to use in the same file they are declared in: consider extracting the declaration into a separate file."
| .ok impl =>
if regularInitAttr.getParam? (← getEnv) impl.ref |>.isSome then -- skip `builtin_initialize` attributes
-- Reject attribute uses where the implementation's module has been loaded for IR only as
-- this would make it `inServer`-dependent and confused shake as well (#13599).
Expand Down
2 changes: 1 addition & 1 deletion tests/elab/attributeErrors.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Tests errors generated by the core attribute infrastructure. Does *not* test err
attributes' individual preprocessing (e.g., `[reducible]`).
-/

/-- error: Unknown attribute `[nonexistent_attribute]` -/
/-- error: Unknown attribute `[nonexistent_attribute]`. Note, that attributes are impossible to use in the same file they are declared in: consider extracting the declaration into a separate file. -/
#guard_msgs in
@[nonexistent_attribute] def x := 32

Expand Down
2 changes: 1 addition & 1 deletion tests/elab_fail/nonfatalattrs.lean.out.expected
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
nonfatalattrs.lean:6:2-6:19: error: Unknown attribute `[attrUnimplementedattr]`
nonfatalattrs.lean:6:2-6:19: error: Unknown attribute `[attrUnimplementedattr]`. Note, that attributes are impossible to use in the same file they are declared in: consider extracting the declaration into a separate file.
foo : Nat
nonfatalattrs.lean:11:12-11:17: error: invalid 'class', declaration 'bar.bar' must be inductive datatype, structure, or constant
bar : Nat
Loading