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

GoToDefinition forces functions to be defined before, even if incorrect #1125

Open
leonschreuder opened this issue Mar 21, 2024 · 0 comments

Comments

@leonschreuder
Copy link

Code editor

neovim

Platform

Linux

Version

5.1.2

What steps will reproduce the bug?

To preserve a top-down structuring in my scripts, I tend to create a main function at the top of the file, any other functions below it, and call the main function in the last line. Shellcheck has no problem with this, but the bash-language-server enforces functions to be defined before they are called, even if the load order is correct.
The following code might describe the problem a little better:

#!/bin/bash

function1() { :; }

main() {
  function1 # GoToDefinition etc works
  function2 # GoToDefinition not available
}

function2() { :; }

main "$@"

How often does it reproduce? Is there a required condition?

always

What is the expected behavior?

For the bash-language-server to support language features despite custom function ordering similar to shellcheck.

What do you see instead?

Language features don't work for function2 despite valid availability in the scope.

Additional information

If this is hard to fix/change, I could also imagine a ALWAYS_IN_SCOPE type config option, that simply puts the whole file in scope. Shellcheck seems to catch any scoping errors as a fallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant