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

Cannot handle C++14 generalized lambda captures when using with ccls #201

Closed
finalpatch opened this issue Jan 9, 2019 · 10 comments
Closed

Comments

@finalpatch
Copy link

example code:

#include <string>
#include <iostream>
int main (int argc, char *argv[])
{
    std::string s = "hello";
    auto foo = [s = std::move(s)] {
                   std::cout << s << std::endl;
               };
    foo();
    return 0;
}

when cursor is placed on the s in std::move(s), eglot shows error message in echo area:

error in process filter: Wrong type argument: stringp, [5 14]
@cmm
Copy link

cmm commented Jan 9, 2019

I'm seeing this even in plain C lately. Might be specific to ccls?

@joaotavora
Copy link
Owner

Can you try this with debug-on-error temporarily set to t? Use M-x toggle-debug-on-error. Then paste the backtrace here, please.

@finalpatch
Copy link
Author

Debugger entered--Lisp error: (wrong-type-argument stringp [5 14])
  regexp-quote([5 14])
  #f(compiled-function () #<bytecode 0x410c5e85>)()
  eglot--call-with-interface((ParameterInformation (:label) (:documentation)) (:label [5 14]) #f(compiled-function () #<bytecode 0x410c5e85>))
  #f(compiled-function () #<bytecode 0x410c5e09>)()
  eglot--call-with-interface((SignatureInformation (:label) (:documentation :parameters)) (:label "move(_Tp &&__t) -> typename remove_reference<_Tp>:..." :parameters [(:label [5 14])]) #f(compiled-function () #<bytecode 0x410c5e09>))
  eglot--sig-info([(:label "move(_Tp &&__t) -> typename remove_reference<_Tp>:..." :parameters [(:label [5 14])]) (:label "move(_InputIterator __first, _InputIterator __last..." :parameters [(:label [5 27]) (:label [29 50]) (:label [52 76])]) (:label "move(__bit_iterator<_Cp, _IsConst> __first, __bit_..." :parameters [(:label [5 42]) (:label [44 80]) (:label [82 117])])] 0 0)
  #f(compiled-function () #<bytecode 0x4109fda9>)()
  eglot--call-with-interface((SignatureHelp (:signatures) (:activeSignature :activeParameter)) (:signatures [(:label "move(_Tp &&__t) -> typename remove_reference<_Tp>:..." :parameters [(:label [5 14])]) (:label "move(_InputIterator __first, _InputIterator __last..." :parameters [(:label [5 27]) (:label [29 50]) (:label [52 76])]) (:label "move(__bit_iterator<_Cp, _IsConst> __first, __bit_..." :parameters [(:label [5 42]) (:label [44 80]) (:label [82 117])])] :activeSignature 0 :activeParameter 0) #f(compiled-function () #<bytecode 0x4109fda9>))
  #f(compiled-function (jsonrpc-lambda-elem118) #<bytecode 0x41648235>)((:signatures [(:label "move(_Tp &&__t) -> typename remove_reference<_Tp>:..." :parameters [(:label [5 14])]) (:label "move(_InputIterator __first, _InputIterator __last..." :parameters [(:label [5 27]) (:label [29 50]) (:label [52 76])]) (:label "move(__bit_iterator<_Cp, _IsConst> __first, __bit_..." :parameters [(:label [5 42]) (:label [44 80]) (:label [82 117])])] :activeSignature 0 :activeParameter 0))
  jsonrpc-connection-receive(#<eglot-lsp-server eglot-lsp-server-41617440> (:jsonrpc "2.0" :id 339 :result (:signatures [(:label "move(_Tp &&__t) -> typename remove_reference<_Tp>:..." :parameters [(:label [5 14])]) (:label "move(_InputIterator __first, _InputIterator __last..." :parameters [(:label [5 27]) (:label [29 50]) (:label [52 76])]) (:label "move(__bit_iterator<_Cp, _IsConst> __first, __bit_..." :parameters [(:label [5 42]) (:label [44 80]) (:label [82 117])])] :activeSignature 0 :activeParameter 0)))
  jsonrpc--process-filter(#<process EGLOT (Desktop/c++-mode)> "Content-Length: 51\15\n\15\n{\"jsonrpc\":\"2.0\",\"id\":340,\"r...")

@finalpatch
Copy link
Author

the last line fully expanded:

  jsonrpc--process-filter(#<process EGLOT (Desktop/c++-mode)> "Content-Length: 51\15\n\15\n{\"jsonrpc\":\"2.0\",\"id\":340,\"result\":{\"contents\":[]}}Content-Length: 38\15\n\15\n{\"jsonrpc\":\"2.0\",\"id\":341,\"result\":[]}Content-Length: 602\15\n\15\n{\"jsonrpc\":\"2.0\",\"id\":339,\"result\":{\"signatures\":[{\"label\":\"move(_Tp &&__t) -> typename remove_reference<_Tp>::type &&\",\"parameters\":[{\"label\":[5,14]}]},{\"label\":\"move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) -> _OutputIterator\",\"parameters\":[{\"label\":[5,27]},{\"label\":[29,50]},{\"label\":[52,76]}]},{\"label\":\"move(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) -> __bit_iterator<_Cp, false>\",\"parameters\":[{\"label\":[5,42]},{\"label\":[44,80]},{\"label\":[82,117]}]}],\"activeSignature\":0,\"activeParameter\":0}}")

@joaotavora
Copy link
Owner

Thanks. This is a bug. label used to be a string and now it can be vector of ints. actually this is a bug in ccls since I don't think eglot reported labelOffsetSupport as one of its capabilities. @MaskRay want to fix? Though I don't since it's very hard to support this in Eglot, too.

@MaskRay
Copy link
Contributor

MaskRay commented Jan 9, 2019

ParameterInformation.label being string was a mistake. My fault was that I thought clients would soon pick up the ParameterInformation.label: [number, number] (LSP 3.14 labelOffsetSupport: true) so I simply dropped ParameterInformation.label: string. I'm travelling and I'll find time to look into this closely.

BTW, the ParameterInformation.label enhancement proposal may be of interests: microsoft/language-server-protocol#640 more clients (eglot) may chime in to make this actually happen.

@joaotavora
Copy link
Owner

@MaskRay It's not very hard to support this in Eglot, I'll do it later this week if I find the time.

The link you gave me is a long read, I don't have time for it yet.

@joaotavora
Copy link
Owner

Should be fixed. Everybody test if possible and report back here if it works.

@finalpatch
Copy link
Author

I can confirm bug is fixed.

@galeo
Copy link
Contributor

galeo commented Sep 25, 2019

I have reported issue #272 when using eglot with MS python language server.

bhankas pushed a commit to bhankas/emacs that referenced this issue Sep 18, 2022
At least ccls uses this.

* eglot.el (eglot-client-capabilities): Declare support for
:labelOffsetSupport.
(eglot--sig-info): Handle label offsets in ParameterInformation
bhankas pushed a commit to bhankas/emacs that referenced this issue Sep 19, 2022
At least ccls uses this.

* eglot.el (eglot-client-capabilities): Declare support for
:labelOffsetSupport.
(eglot--sig-info): Handle label offsets in ParameterInformation
bhankas pushed a commit to bhankas/emacs that referenced this issue Sep 19, 2022
At least ccls uses this.

* eglot.el (eglot-client-capabilities): Declare support for
:labelOffsetSupport.
(eglot--sig-info): Handle label offsets in ParameterInformation

#201: joaotavora/eglot#201
jollaitbot pushed a commit to sailfishos-mirror/emacs that referenced this issue Oct 12, 2022
At least ccls uses this.

* eglot.el (eglot-client-capabilities): Declare support for
:labelOffsetSupport.
(eglot--sig-info): Handle label offsets in ParameterInformation

GitHub-reference: fix joaotavora/eglot#201
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

5 participants