Zulip Chat Archive
Stream: general
Topic: Unclear Error Message
Asei Inoue (Jul 03 2025 at 18:02):
When running the following code, it produces the error "unknown identifier 'Unexpander'".
However, the actual cause of the error is the in at the end of the set_option line.
If you remove the in, the error disappears.
This error message is hard to understand, in my opinion.
set_option linter.unusedVariables false in
open Lean PrettyPrinter
def unexpander : Unexpander := fun stx =>
match stx with
| _ => throw ()
Aaron Liu (Jul 03 2025 at 18:07):
It fails to parse but doesn't throw an error???
Damiano Testa (Jul 03 2025 at 19:34):
Is this caused by the fact that the in makes the open finish its scope as soon as it's over?
Damiano Testa (Jul 03 2025 at 19:35):
So then Unexpanded is unknown, since it is missing some namespace?
Damiano Testa (Jul 03 2025 at 19:36):
A good mental model for in is that it wraps the following command inside a section/end pair, so the open command is only opening the namespaces in a very very very narrow margin.
Aaron Liu (Jul 03 2025 at 19:41):
It looks like
set_option linter.unusedVariables false in
open Lean PrettyPrinter
is one command
Damiano Testa (Jul 03 2025 at 19:45):
I agree, and the command is roughly equivalent to section (...) end.
Robin Arnez (Jul 03 2025 at 20:10):
Damiano Testa schrieb:
I agree, and the command is roughly equivalent to
section (...) end.
Not just roughly:
@[builtin_macro Lean.Parser.Command.«in»] def expandInCmd : Macro
| `($cmd₁ in%$tk $cmd₂) =>
-- Limit ref variability for incrementality; see Note [Incremental Macros]
withRef tk `(section $cmd₁:command $cmd₂ end)
| _ => Macro.throwUnsupported
Last updated: Dec 20 2025 at 21:32 UTC