`lean --deps` panics in `HeaderSyntax.imports` on a header that does not parse
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- Half a day
- Newbie friendliness
- 62/100
Research direction
Start with Lean.Elab.parseImports, which passes the result of Parser.parseHeader to headerToImports without checking its messages, then with HeaderSyntax.imports in Lean/Elab/Import.lean, where the unreachable! at line 40 is hit. Reproduce with printf 'import\n' > W.lean && lean --deps W.lean. Done when the header's parse error is reported with a non-zero exit and no panic, for import, import Init., import 3, a tab before import, and a lone carriage return.
Written by the indexing model from the issue text.
Description
Description
lean --deps panics on any file whose header doesn't parse, then goes on to look up a module named [anonymous]. lean on the same file reports the parse error as a normal message.
Steps to Reproduce
printf 'import\n' > W.lean
lean --deps W.lean
Expected behavior: the header's parse error, as lean W.lean reports it (W.lean:2:0: error: unexpected end of input; expected identifier), with a non-zero exit and no panic.
Actual behavior:
PANIC at Lean.Elab.HeaderSyntax.imports Lean.Elab.Import:40:13: unreachable code has been reached
backtrace:
…
<toolchain>/lib/lean/Init.olean
<toolchain>/lib/lean/Init.olean
unknown module prefix '[anonymous]'
No directory '[anonymous]' or file '[anonymous].olean' in the search path entries:
<toolchain>/lib/lean
The same happens for every header error I tried: import Init., import 3, a tab before an import ("tabs are not allowed"), and an isolated carriage return.
Cause
Lean.Elab.parseImports passes the header that Parser.parseHeader returns to headerToImports without checking the returned messages for errors. On the error-recovered syntax, neither pattern in HeaderSyntax.imports matches, so it reaches unreachable!. printImports (--deps) and printImportSrcs (--src-deps) both go through it. So does any program that calls parseImports to read a header's imports and its end position.
Versions
Lean (version 4.34.1, aarch64-unknown-linux-gnu, commit 5045d0056413266e57c625dcd7c365b10e377c52, Release), on Linux.
Impact
A tool that reads a module's imports with parseImports or lean --deps, as a build driver does before passing them through --setup, has to check the header's messages itself first.
- Dominant language
- Lean
- Stars
- 10.3k
- Forks
- 1.1k
- Avg merge
- 19h 8m
- Merged PRs (30d)
- 421
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from leanprover/lean4
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
leanprover/lean4#16681 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
leanprover/lean4#16305 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
leanprover/lean4#16299 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
leanprover/lean4#16257 ·
Maintainers usually reply within 1 day
-
`IO.FS.realPath` reports every failure as `noFileOrDirectory` instead of classifying by `errno`Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
leanprover/lean4#15683 ·
Maintainers usually reply within 1 day
All issues in leanprover/lean4
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
uselagoon/lagoon-cli#501 · 1 reaction ·
-
area: cli
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
vitruv-tools/NeoJoin#415 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Tarektouati/made#197 ·
Maintainers usually reply within 1 day
-
soup data dedup --semantic --threshold 1.0 keeps byte-identical rows (float32 self-dot is below 1.0)Possibly taken @nazek52 claimed this today. Openbug difficulty:2
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
MakazhanAlpamys/Soup#3214 · 2 comments ·
Maintainers usually reply within 1 day