Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect environment in command snaps for code action #3250

Open
digama0 opened this issue Feb 3, 2024 · 0 comments
Open

Incorrect environment in command snaps for code action #3250

digama0 opened this issue Feb 3, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@digama0
Copy link
Collaborator

digama0 commented Feb 3, 2024

import Lean
open Lean Server

@[code_action_provider] def holeCodeActionProvider : CodeActionProvider := fun _ snap => do
  panic! toString <| snap.cmdState.env.contains `foo
  pure #[]

def foo : Nat := 
  -- here
  1

Placing the cursor at the indicated location results in true being printed, meaning that the environment passed in the snap corresponds to the one after the command is executed. This results in incorrect behavior when traversing the info trees, because unless the environment is overridden in the context info it will still say that we are in the new environment, not the original environment used for the actual elaboration. I believe this issue was preexisting but exacerbated by #3159, because previously all info tree context nodes would override the environment and now most of them don't.

This is causing problems for the implementation of leanprover-community/batteries#577 , which needs to be able to determine whether an instance exists prior to the command to mimic the behavior of the structure instance notation.

@digama0 digama0 added the bug Something isn't working label Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants