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

go to declaration does not work within def #1430

Open
alefminus opened this issue May 21, 2024 · 5 comments
Open

go to declaration does not work within def #1430

alefminus opened this issue May 21, 2024 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@alefminus
Copy link

alefminus commented May 21, 2024

Describe the bug

  1. write a def containing a variable assignment and usage.
  2. place cursor on usage, click go to declaration hotkey F12 (or right click menu)
  3. nothing happens

Code to reproduce

def test():
    a = 10
    print(a)

Second variant: if you have a variable in a function body that is also used as a free variable (produced and consumed by cells) than go to definition will jump to it.

Code to reproduce second variant

# line 1
a = 10
# line 2
print(a)

def test():
    # line 3
    a = 10
    # line 4
    print(a)

Select the 'a' below line 4, then press F12, and you will jump to line 1.

Environment

latest git (installed with pip install -e ., and frontend built with make fe)

✦ ❯ python -c 'import marimo; print(marimo.__version__); print(marimo); from os import system; system("cd {}; git describe".format("/home/alon/src/marimo"))'
0.6.0
<module 'marimo' from '/home/alon/src/marimo/marimo/__init__.py'>
0.6.0-17-g502820f1
{
  "marimo": "0.6.0",
  "OS": "Linux",
  "OS Version": "6.8.7-300.fc40.x86_64",
  "Processor": "",
  "Python Version": "3.12.3",
  "Binaries": {
    "Browser": "--",
    "Node": "v20.12.2"
  },
  "Requirements": {
    "click": "8.1.7",
    "importlib-resources": "missing",
    "jedi": "0.19.1",
    "markdown": "3.6",
    "pymdown-extensions": "10.8.1",
    "pygments": "2.18.0",
    "tomlkit": "0.12.5",
    "uvicorn": "0.29.0",
    "starlette": "0.37.2",
    "websocket": "missing",
    "typing-extensions": "4.11.0",
    "black": "24.4.2"
  }
}
@alefminus alefminus added the bug Something isn't working label May 21, 2024
@mscolnick
Copy link
Contributor

right now our go-to-definition logic is on the frontend and doesn't handle this edge case. we can probably handle this in the same logic, but the longer term solution might be to move to a proper language-server

@mscolnick mscolnick added the help wanted Extra attention is needed label May 21, 2024
@alefminus
Copy link
Author

alefminus commented May 21, 2024

Two additional things:

  1. The feature as is is very useful, kudos to all involved!
  2. Going to a variable local to a cell also fails - i.e.
_x = 10
output = _x + 10  # fails on _x

This is of course not interesting for a 2 line cell but for a 40 it is.

@alefminus
Copy link
Author

A language server would miss out on the quick jump due to the DAG - so I think a combination of using the DAG and an LSP would probably be better. Right now F12 is instantaneous, would hate to lose that.

@mscolnick
Copy link
Contributor

I have a fix for private variables in #1425

@alefminus
Copy link
Author

alefminus commented May 21, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants