Zulip Chat Archive

Stream: general

Topic: Lean register_label_attr not working


Frederick Pu (Apr 28 2024 at 01:33):

Can someone explain to me why this is not working. I'm really new to register_labell_attr:

import Lean.LabelAttribute

/-
  test label
-/
register_label_attr rom

@[rom] -- unknown attribute rom
def womp : 2 + 2 = 4 := by rfl

Damiano Testa (Apr 28 2024 at 06:03):

I think that you cannot define and use an attribute in the same file: the file where the attribute is used should import the file where the attribute is registered.

If you move

@[rom] -- unknown attribute rom
def womp : 2 + 2 = 4 := by rfl

to a separate file importing the previous one, it should work.

Asei Inoue (Apr 28 2024 at 09:25):

very interesting.
why Lean forbids to define attribute and use it in same file

Asei Inoue (Apr 28 2024 at 09:26):

I think it is very inconvenient…

Asei Inoue (Apr 28 2024 at 09:27):

For example, register_label_attr doesn’t work in Lean4 web.

Asei Inoue (Apr 28 2024 at 09:28):

Even if there is reasonable reason, the error message should suggest file separation.

Kim Morrison (Apr 28 2024 at 09:32):

Could you open an issue about the error message?

Asei Inoue (Apr 28 2024 at 15:44):

@Kim Morrison done! https://github.com/leanprover/lean4/issues/4011

Asei Inoue (Apr 29 2024 at 09:32):

Why can't we register and use label in the same file?


Last updated: Dec 20 2025 at 21:32 UTC