Nicer error message if `set_option` goes after doc string
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Check that your issue is not already filed.
- Reduce the issue to a minimal, self-contained, reproducible test case. Avoid dependencies to mathlib4 or std4.
Description
If I do
/-- A comment that should go after `set_option` -/
set_option maxHeartbeats 10000 in
theorem simple : 0 = 0 := rfl
I get the confusing error message
unexpected token 'set_option'; expected 'abbrev', 'add_decl_doc', 'axiom', 'builtin_initialize', 'class', 'declare_simp_like_tactic', 'declare_syntax_cat', 'def', 'elab', 'elab_rules', 'example', 'inductive', 'infix', 'infixl', 'infixr', 'initialize', 'instance', 'macro', 'macro_rules', 'notation', 'opaque', 'postfix', 'prefix', 'structure', 'syntax', 'theorem' or 'unif_hint'
which doesn't give any hints that the correct ordering is
set_option maxHeartbeats 10000 in
/-- A comment in the right place -/
theorem simple : 0 = 0 := rfl
Context
Zulip thread (which doesn't have any additional information): https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Confusing.20error.20message.20with.20set_option.20before.20doc.20comment/near/410865491
Steps to Reproduce
See above.
Expected behavior:
An error message that explains that set_option should go before the doc string, or at least hints in that direction.
Actual behavior:
The uninformative error message shown above.
Versions
lean --version:Lean (version 4.5.0-rc1, commit b614ff1d12bc, Release)- OS: macOS 14.1.2
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
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 by reproducing the example with Lean 4.5.0-rc1 and inspect the parser or diagnostic path handling a doc comment before set_option. Done means the reported error explains that set_option must precede the doc string, or provides a similarly useful hint, with coverage for the shown ordering.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100