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

Panic with not implemented CompletionItemKind(0) in Odin project #4657

Closed
Tefached95 opened this issue Nov 8, 2022 · 4 comments · Fixed by #4658
Closed

Panic with not implemented CompletionItemKind(0) in Odin project #4657

Tefached95 opened this issue Nov 8, 2022 · 4 comments · Fixed by #4658
Labels
A-language-server Area: Language server client C-bug Category: This is a bug E-good-first-issue Call for participation: Issues suitable for new contributors E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR

Comments

@Tefached95
Copy link
Contributor

Summary

Trying to access a function implemented in an imported package causes the editor to panic.
The project can be found here.
odin version dev-2022-11:f1c24f43
OLS at commit 1c814ac250fa96083981fecc7a5cf22e6440ed2f
Paths to both odin and ols have been added to PATH.

Windows 11 Pro 22H2, build 22621.755

Language support added according to instructions found here inside ~\AppData\Roaming\helix\languages.toml
Here's the full backtrace:

PS E:\Projects\Odin\Odin8> env RUST_BACKTRACE=full hx .
thread 'main' panicked at 'not implemented: CompletionItemKind(0)', helix-term\src\ui\completion.rs:69:31
stack backtrace:
   0:     0x7ff75b65e794 - std::backtrace_rs::backtrace::dbghelp::trace
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:98
   1:     0x7ff75b65e794 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff75b65e794 - std::sys_common::backtrace::_print_fmt
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\sys_common\backtrace.rs:66
   3:     0x7ff75b65e794 - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\sys_common\backtrace.rs:45
   4:     0x7ff75ad2d80a - core::fmt::write
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\core\src\fmt\mod.rs:1194
   5:     0x7ff75b657379 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\io\mod.rs:1655
   6:     0x7ff75b661f4b - std::sys_common::backtrace::_print
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\sys_common\backtrace.rs:48
   7:     0x7ff75b661f4b - std::sys_common::backtrace::print
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\sys_common\backtrace.rs:35
   8:     0x7ff75b661f4b - std::panicking::default_hook::closure$1
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:295
   9:     0x7ff75b661be9 - std::panicking::default_hook
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:314
  10:     0x7ff75b66268f - std::panicking::rust_panic_with_hook
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:702
  11:     0x7ff75b662403 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:588
  12:     0x7ff75b65f9e7 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\sys_common\backtrace.rs:138
  13:     0x7ff75b6620bf - std::panicking::begin_panic_handler
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:584
  14:     0x7ff75b707cc5 - core::panicking::panic_fmt
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\core\src\panicking.rs:143
  15:     0x7ff75b090ed3 - helix_term::ui::completion::<impl helix_term::ui::menu::Item for lsp_types::completion::CompletionItem>::row::hd8f044cb9d894b9e
  16:     0x7ff75b34e8f8 - <helix_term::ui::menu::Menu<T> as helix_term::compositor::Component>::required_size::h42b0dcc06df183a0
  17:     0x7ff75b1ad155 - <helix_term::ui::popup::Popup<T> as helix_term::compositor::Component>::required_size::hca9481d4d7afadad
  18:     0x7ff75b06be3d - helix_term::ui::editor::EditorView::set_completion::hff7cb75f76a6f238
  19:     0x7ff75b362c97 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once::hc6bb1e4c9309133b
  20:     0x7ff75b1ce268 - helix_term::job::Jobs::handle_callback::he25a2489a2f6dbbe
  21:     0x7ff75b4fad48 - hx::main_impl::{{closure}}::hfb234965068c1ce7
  22:     0x7ff75b4c6dea - tokio::park::thread::CachedParkThread::block_on::h81471069af3f9bdd
  23:     0x7ff75b4b3f63 - tokio::runtime::scheduler::multi_thread::MultiThread::block_on::hefac43343426bb29
  24:     0x7ff75b5190e3 - tokio::runtime::Runtime::block_on::h696f5efcc5998273
  25:     0x7ff75b4c9c32 - hx::setup_logging::hca17b0194df5e1c4
  26:     0x7ff75b4bf096 - std::sys_common::backtrace::__rust_begin_short_backtrace::hd004344f418fdc62
  27:     0x7ff75b5128aa - std::rt::lang_start::{{closure}}::h2c921be82a73ba61
  28:     0x7ff75b650572 - core::ops::function::impls::impl$2::call_once
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\core\src\ops\function.rs:259
  29:     0x7ff75b650572 - std::panicking::try::do_call
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:492
  30:     0x7ff75b650572 - std::panicking::try
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:456
  31:     0x7ff75b650572 - std::panic::catch_unwind
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panic.rs:137
  32:     0x7ff75b650572 - std::rt::lang_start_internal::closure$2
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\rt.rs:128
  33:     0x7ff75b650572 - std::panicking::try::do_call
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:492
  34:     0x7ff75b650572 - std::panicking::try
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:456
  35:     0x7ff75b650572 - std::panic::catch_unwind
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panic.rs:137
  36:     0x7ff75b650572 - std::rt::lang_start_internal
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\rt.rs:128
  37:     0x7ff75b4c9dd7 - main
  38:     0x7ff75b701d9c - invoke_main
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  39:     0x7ff75b701d9c - __scrt_common_main_seh
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  40:     0x7ff972ad244d - BaseThreadInitThunk
  41:     0x7ff97490dfb8 - RtlUserThreadStart

Reproduction Steps

  1. Install Odin and OLS, put both in PATH
  2. Add support for OLS inside Helix
  3. hx . inside the project directory
  4. Open the src/interpreter/interpreter.odin file
  5. Go down to line 38 inside interpreter.odin
  6. Start typing memory
  7. Hit dot .

I expected this to happen:

The language completion feature should have popped up with all the exported functions found within the memory package.

Instead, this happened:

hx panics and crashes with Not implemented: CompletionItemKind(0)

Helix log

helix.log

Platform

Windows 11

Terminal Emulator

Windows Terminal Version: 1.15.2875.0

Helix Version

helix 22.08.1 (6cafd81)

@Tefached95 Tefached95 added the C-bug Category: This is a bug label Nov 8, 2022
@the-mikedavis
Copy link
Member

This was fixed a few hours ago 1312682

Can you try from that commit?

@Tefached95
Copy link
Contributor Author

Tefached95 commented Nov 8, 2022

Sorry for the delay, I was not sure if I had rebuilt the project properly but I think I did everything correctly. Anyway I checked out the latest commit from master and rebuilt the editor, but it still crashes with the same error unfortunately.

$ hx -V shows helix 22.08.1 (75d7e055)

I've also gone and pulled the latest commits for both Odin and OLS and rebuilt both just in case.

Here's the latest backtrace:

$ env RUST_BACKTRACE=full hx .
thread 'main' panicked at 'not implemented: CompletionItemKind(0)', helix-term\src\ui\completion.rs:69:31
stack backtrace:
   0:     0x7ff7603f0574 - std::backtrace_rs::backtrace::dbghelp::trace
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:98
   1:     0x7ff7603f0574 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff7603f0574 - std::sys_common::backtrace::_print_fmt
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\sys_common\backtrace.rs:66
   3:     0x7ff7603f0574 - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\sys_common\backtrace.rs:45
   4:     0x7ff75fabd8fa - core::fmt::write
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\core\src\fmt\mod.rs:1194
   5:     0x7ff7603e9159 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\io\mod.rs:1655
   6:     0x7ff7603f3d2b - std::sys_common::backtrace::_print
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\sys_common\backtrace.rs:48
   7:     0x7ff7603f3d2b - std::sys_common::backtrace::print
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\sys_common\backtrace.rs:35
   8:     0x7ff7603f3d2b - std::panicking::default_hook::closure$1
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:295
   9:     0x7ff7603f39c9 - std::panicking::default_hook
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:314
  10:     0x7ff7603f446f - std::panicking::rust_panic_with_hook
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:702
  11:     0x7ff7603f41e3 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:588
  12:     0x7ff7603f17c7 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\sys_common\backtrace.rs:138
  13:     0x7ff7603f3e9f - std::panicking::begin_panic_handler
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:584
  14:     0x7ff760499bf5 - core::panicking::panic_fmt
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\core\src\panicking.rs:143
  15:     0x7ff75fe21a43 - helix_term::ui::completion::<impl helix_term::ui::menu::Item for lsp_types::completion::CompletionItem>::row::h59f19b6a13b162dc
  16:     0x7ff7600e06d6 - <helix_term::ui::menu::Menu<T> as helix_term::compositor::Component>::required_size::h2d22945317fa246b
  17:     0x7ff75ff3a485 - <helix_term::ui::popup::Popup<T> as helix_term::compositor::Component>::required_size::h9ec0ba59679ccc38
  18:     0x7ff75fdfcb6d - helix_term::ui::editor::EditorView::set_completion::h3e74add7717bc7e1
  19:     0x7ff7600f8d27 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hb557a7bbcc4f668a
  20:     0x7ff75ff5f488 - helix_term::job::Jobs::handle_callback::hc5a009c633a9f03f
  21:     0x7ff76028c588 - hx::main_impl::{{closure}}::hebbcc4bc61d1f394
  22:     0x7ff760258f0a - tokio::park::thread::CachedParkThread::block_on::hcc28cff122f3abe6
  23:     0x7ff760246213 - tokio::runtime::scheduler::multi_thread::MultiThread::block_on::h889db30df2ebcedb
  24:     0x7ff7602aa923 - tokio::runtime::Runtime::block_on::hbd7927266735d503
  25:     0x7ff76025bfc2 - hx::setup_logging::h380d4fb0e1999a99
  26:     0x7ff760251346 - std::sys_common::backtrace::__rust_begin_short_backtrace::hdceb27d1860906de
  27:     0x7ff7602a40ea - std::rt::lang_start::{{closure}}::h90615bd9ba5d24f9
  28:     0x7ff7603e2352 - core::ops::function::impls::impl$2::call_once
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\core\src\ops\function.rs:259
  29:     0x7ff7603e2352 - std::panicking::try::do_call
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:492
  30:     0x7ff7603e2352 - std::panicking::try
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:456
  31:     0x7ff7603e2352 - std::panic::catch_unwind
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panic.rs:137
  32:     0x7ff7603e2352 - std::rt::lang_start_internal::closure$2
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\rt.rs:128
  33:     0x7ff7603e2352 - std::panicking::try::do_call
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:492
  34:     0x7ff7603e2352 - std::panicking::try
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:456
  35:     0x7ff7603e2352 - std::panic::catch_unwind
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panic.rs:137
  36:     0x7ff7603e2352 - std::rt::lang_start_internal
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\rt.rs:128
  37:     0x7ff76025c167 - main
  38:     0x7ff760493ccc - invoke_main
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  39:     0x7ff760493ccc - __scrt_common_main_seh
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  40:     0x7ff972ad244d - BaseThreadInitThunk
  41:     0x7ff97490dfb8 - RtlUserThreadStart

@the-mikedavis
Copy link
Member

Oh whoops I was looking at the wrong unimplemented! - this is separate from insert-replace completion. 😅

We're panicking here:

Some(kind) => unimplemented!("{:?}", kind),

Because the server is sending a completion item with a CompletionItemKind of 0. The spec shows that this is not a recognized CompletionItemKind https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItemKind, so this should probably be reported to the language server. It may be a bug on their end.

However, the spec also says:

To support the evolution of enumerations the using side of an enumeration shouldn’t fail on an enumeration value it doesn’t know. It should simply ignore it as a value it can use and try to do its best to preserve the value on round trips.
...
Lets look at the CompletionItemKind enumeration as an example again: if in a future version of the specification an additional completion item kind with the value n gets added and announced by a client a (older) server not knowing about the value should not fail but simply ignore the value as a usable item kind.

(https://github.com/microsoft/language-server-protocol/blob/50732421db206ec7dd5c30b88326083bcaf826ef/_specifications/lsp/3.17/types/enumerations.md?plain=1#L5)

So in that branch, instead of panicking with unimplemented! we should log a message with log::error! saying that we received a completion item with an unknown kind and return "" like we do in the None branch. Would you like to make a PR?

@the-mikedavis the-mikedavis added A-language-server Area: Language server client E-good-first-issue Call for participation: Issues suitable for new contributors E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR labels Nov 8, 2022
@Tefached95
Copy link
Contributor Author

Tefached95 commented Nov 8, 2022

Will do, give me a couple of minutes!

Edit: here it is -> #4658

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-server Area: Language server client C-bug Category: This is a bug E-good-first-issue Call for participation: Issues suitable for new contributors E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants