leanprover / leanprover/lean4

Language server diverges from `lake build`

Open
#12,732 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-high
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Prerequisites
Description

In the module system, the language server loads more data than lake build does on the command line, resulting in divergence in behavior between the two.

For example, this may cause the language server to succeed while the command line fails, leading to users being unaware of command-line build failures while editing interactively.

Context

This issue has reared its head when shake modifies imports and when options are imported, since they are registered with initialize.

Steps to Reproduce

To inline the example from the second discussion:

If you have a file called Foo which registers an option:

module
public import Lean

/-- the docstring -/
public meta register_option foo : Bool := {
  defValue := true
  descr := "the descr"
}

Then you import that file in Bar:

module
import Foo

Then you import that file in Baz:

module
import Bar

set_option foo true

the language server will not complain. However lake build Baz will fail with "Unknown option foo". (The previous file Bar would succeed if you wrote set_option foo true in it.)

(The hover on foo in Baz also shows that the docstring is not available, as it falls back to displaying "the descr".)

Expected behavior: In Baz, the user sees an error "Unknown option foo" in both the language server and on the command line.

Actual behavior: In Baz, the user sees an error "Unknown option foo" on the command line, but no error and suboptimal hovers in the language server.

Versions

4.29.0-rc2, nightly-2026-2-25, macOS

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Foo, Bar, and Baz reproduction from the issue and run it with both the language server and lake build on the latest nightly. Trace how the module imports and registered option are loaded in each path; done means both paths report the unknown option consistently and provide equivalent hover information.

Written by the indexing model from the issue text.

Assessment

Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.