Bad error message "unknown parser declaration/category/alias `...`" when using a non-public syntax declaration from a public one.
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. - Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
This error message appears when using a non-public parser from a public one. This error message is confusing because the parser is known, and is similar cases with terms produce error messages that address the need for a public modifier.
It could also be remedied if the documentation on syntax would address this error explicitly and explain this case.
Context
Steps to Reproduce
- Open a new lean file.
- Paste the following:
module
syntax foo := ident
public syntax bar := foo
Expected behavior: An error explaining that syntax bar is public but uses a private parser foo
Actual behavior: The following error appears: "unknown parser declaration/category/alias foo"
Versions
Lean 4.32.0-nightly-2026-06-15
Target: x86_64-unknown-linux-gnu
Using live.lean-lang.org.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal Lean file from the Steps to Reproduce and run it against the latest nightly release or live.lean-lang.org. Trace how the public syntax bar := foo declaration resolves the private foo parser. Done means the diagnostic explains that public syntax bar uses a non-public parser, instead of reporting foo as unknown.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100