Skip to content

'julia/getModuleAt' sometimes fails with MethodError #713

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

Closed
pfitzseb opened this issue May 25, 2020 · 4 comments · Fixed by #714
Closed

'julia/getModuleAt' sometimes fails with MethodError #713

pfitzseb opened this issue May 25, 2020 · 4 comments · Fixed by #714
Assignees
Labels

Comments

@pfitzseb
Copy link
Member

┌ Warning: Some Julia code in the VS Code extension crashed with
│   e =
│    MethodError: no method matching parentof(::Nothing)
│    Closest candidates are:
│      parentof(!Matched::StaticLint.Scope) at /home/pfitzseb/Documents/Git/julia-vscode/scripts/languageserver/packages/StaticLint/src/scope.jl:92
│      parentof(!Matched::CSTParser.EXPR) at /home/pfitzseb/Documents/Git/julia-vscode/scripts/languageserver/packages/CSTParser/src/spec.jl:294
└ @ Main ~/Documents/Git/julia-vscode/scripts/error_handler.jl:5
ERROR: MethodError: no method matching parentof(::Nothing)
Closest candidates are:
  parentof(!Matched::StaticLint.Scope) at /home/pfitzseb/Documents/Git/julia-vscode/scripts/languageserver/packages/StaticLint/src/scope.jl:92
  parentof(!Matched::CSTParser.EXPR) at /home/pfitzseb/Documents/Git/julia-vscode/scripts/languageserver/packages/CSTParser/src/spec.jl:294
Stacktrace:
 [1] retrieve_scope(::Nothing) at /home/pfitzseb/Documents/Git/julia-vscode/scripts/languageserver/packages/StaticLint/src/utils.jl:138
 [2] process(::LanguageServer.JSONRPC.Request{Val{Symbol("julia/getModuleAt")},LanguageServer.TextDocumentPositionParams}, ::LanguageServerInstance) at /home/pfitzseb/Documents/Git/julia-vscode/scripts/languageserver/packages/LanguageServer/src/requests/features.jl:314
 [3] run(::LanguageServerInstance) at /home/pfitzseb/Documents/Git/julia-vscode/scripts/languageserver/packages/LanguageServer/src/languageserverinstance.jl:251
 [4] top-level scope at /home/pfitzseb/Documents/Git/julia-vscode/scripts/languageserver/main.jl:59
 [5] include(::Module, ::String) at ./Base.jl:377
 [6] exec_options(::Base.JLOptions) at ./client.jl:288
 [7] _start() at ./client.jl:484

Not 100% what triggers this though.

@pfitzseb pfitzseb added the bug label May 25, 2020
@ZacLN ZacLN self-assigned this May 25, 2020
@pfitzseb
Copy link
Member Author

Ok, so when the current position is in whitespace then get_expr1 returns nothing. The best solution here would be to call something like next_expr, but I'm not sure if we have that already. Could presumably just increment the offset until we find an expr?

@pfitzseb
Copy link
Member Author

This also seems like it could just run in a try catch because we fall back to Main anyways.

@ZacLN
Copy link
Contributor

ZacLN commented May 25, 2020

There's a version of get_expr that always returns an EXPR, I'll have a look and work out which one. The getModule handler should also probably be adjusted to handle a nothing response as well though (to return Main?) - e.g. in the case of an empty document.

@pfitzseb
Copy link
Member Author

Yea. Currently branching on nothing is really annoying because the module changes between whitespace and actual code.

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

Successfully merging a pull request may close this issue.

3 participants