emacs-lsp / lsp-ui

UI integrations for lsp-mode
https://emacs-lsp.github.io/lsp-ui
GNU General Public License v3.0
1.04k stars 141 forks source link

"Lisp error: (void-variable it)" from lsp-ui-sideline--flycheck() #164

Closed brandon-rhodes closed 6 years ago

brandon-rhodes commented 6 years ago

I have lsp-mode-20180709.214 and lsp-ui-20180619.251 and flycheck-20180720.947 and this in my init.el:

(require 'lsp-ui)
(add-hook 'lsp-mode-hook 'lsp-ui-mode)

(global-flycheck-mode)

When a language server offers a textDocument/publishDiagnostics notification, flycheck is correctly putting a little chevron in the gutter over on the left edge of the affected line. But when I move point on to the line, I get the exception:

Debugger entered--Lisp error: (void-variable it)
  lsp-ui-sideline--flycheck()
  lsp-ui-sideline--run()
  #[0 "\300p\232\205\301 \207" [#<buffer sample.py> lsp-ui-sideline--run] 2]()
  apply(#[0 "\300p\232\205\301 \207" [#<buffer sample.py> lsp-ui-sideline--run] 2] nil)
  timer-event-handler([t 0 0 200000 nil #[0 "\300p\232\205\301 \207" [#<buffer sample.py> lsp-ui-sideline--run] 2] nil idle 0])

Having read through the source code once, I have no idea where it is getting set. I'll go re-read in case I've missed something (and I'll also read the docs on those --> routines since I saw one of them mentioned in another issue that involved a void variable), but at the moment I can't even tell where it was supposed to come from.

Oh — and, I'm on Emacs 25.2.2.

Thanks for any hints about how I could debug!

brandon-rhodes commented 6 years ago

I've never encountered "dash" before, and so I'm not sure what the macro --> accomplishes in lsp-ui-sideline.el that isn't accomplished by simply inlining the lists into each other. But if I replace:

             (message (--> (flycheck-error-format-message-and-id e)
                           (car (split-string it "\n"))
                           (replace-regexp-in-string "[\n\t ]+" " " it)))

in lsp-ui-sideline--flycheck with:

             (message (replace-regexp-in-string
                       "[\n\t ]+" " "
                       (car (split-string
                             (flycheck-error-format-message-and-id e) "\n"))))

then the feature starts working without error. So, for the moment at least, I'm un-blocked, and can put that definition in my .init.el if I need to until you have time to debug why this doesn't happen in everyone's copy of the code.

Thanks for lsp-ui, it's letting me connect Emacs to a larger world of language features!

erikbye commented 6 years ago

Is the dash library not loading correctly? That's where --> and it comes from.

https://github.com/magnars/dash.el#---x-rest-forms

brandon-rhodes commented 6 years ago

Yes, dash is loading correctly. The expression (--> (+ 1 2) (+ 10 it)) that I just had Emacs evaluate comes back as 13.

jefftrull commented 6 years ago

This may have nothing to do with the problem but... lexical scoping issue?

https://stackoverflow.com/questions/30813929/emacs-org-mode-gnuplot-error-running-timer-void-variable-data-file

jefftrull commented 6 years ago

And @brandon-rhodes hack fixes my issue as well.

jefftrull commented 6 years ago

Evaluating the defun for lsp-ui-sideline--flycheck with C-M-x makes the problem go away :-/

jefftrull commented 6 years ago

OK I believe I've gotten to the root of this issue.

With the latest lsp-ui (20180619) and an outdated version of dash that came with my system, I get the error. If I update dash, I still get the error. But if I recompile or install lsp-ui with the updated dash the problem goes away. It looks like you can get a different byte compilation result if a package you depend on changes!

@brandon-rhodes can you try installing an updated "dash", then re-installing lsp-ui, and see if that fixes your problem?

MaskRay commented 6 years ago

The package requirement has been bumped on Sep 4. It seems it shall address the problem.

-;; Package-Requires: ((emacs "25.1") (dash "2.13") (dash-functional "1.2.0") (flycheck "31") (lsp-mode "4.0") (markdown-mode "2.3"))
+;; Package-Requires: ((emacs "25.1") (dash "2.14") (dash-functional "1.2.0") (flycheck "31") (lsp-mode "4.2") (markdown-mode "2.3"))