Goto definition failing with multiple libraries
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Description
In a configuration with multiple libraries, "go to definition" fails in some circumstances.
Context
I had noticed intermittent failures of "go to definition" while working on Verso. Another user experienced them, so I took the time to minimize it and produce a bug report.
Steps to Reproduce
- Check out the branch
goto-def-minimizedof Verso - Open the file
verso-blog/Verso/Genre/Blog/Template.lean - Try to use "go to definition" on the occurrence of
MonadPathon line 13
Expected behavior:
A jump to the definition of MonadPath
(or, alternatively, I would expect a "variable out of scope" error message, but the file elaborates without errors)
Actual behavior:
It fails to do so in Codium:
and also Emacs:
so I suspect the language server is at fault, rather than the editor plugin.
Versions
I can reproduce this in the following Lean versions:
- leanprover/lean4:nightly-2024-08-08
- leanprover/lean4:v4.11.0-rc1
- leanprover/lean4:v4.10.0
- leanprover/lean4:v4.9.0
- leanprover/lean4:v4.8.0
- leanprover/lean4:v4.1.0
I didn't try the intervening versions.
Additional Information
Editing the Lakefile to remove the first library and restarting the language server:
import Lake
open Lake DSL
package verso where
@[default_target]
lean_lib VersoBlog where
srcDir := "src/verso-blog"
roots := #[`Verso.Genre.Blog]
makes it so that the feature works correctly.
I suspected that the problem might be from one library's roots containing another, but the following Lakefile still exhibits the bug:
import Lake
open Lake DSL
package verso where
@[default_target]
lean_lib Verso where
srcDir := "src/verso"
roots := #[`Verso.A]
@[default_target]
lean_lib VersoBlog where
srcDir := "src/verso-blog"
roots := #[`Verso.Genre.Blog]
as does one in which the library is renamed to VersoA.
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
Reproduce the failure using the goto-def-minimized Verso branch, opening verso-blog/Verso/Genre/Blog/Template.lean and targeting MonadPath on line 13. Compare behavior with the reduced Lakefiles in the report and inspect the language-server handling of multiple libraries. Done means go-to-definition reaches Verso/Genre/Blog/Site.lean, or reports a clear out-of-scope error.
Written by the indexing model from the issue text.
Assessment
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100