iquiw / company-ghc

Company-mode completion back-end for haskell-mode via ghc-mod
125 stars 6 forks source link

Company gives “Wrong type argument” error message #9

Closed 8573 closed 9 years ago

8573 commented 9 years ago

If I’m typing a word, and the Company-Mode completions pop-up appears, and the active completion back-end is company-ghc, the completions pop-up appears to be properly populated, but it disappears soon after appearing, and the following error message is logged:

Company: An error occurred in post-command
Company: Front-end company-echo-metadata-frontend error "Company: Back-end company-ghc error "Wrong type argument: stringp, nil" with args (meta putChar)" on command post-command

company-ghc-diagnose’s output seems fine:

* company-ghc backend found: company-ghc
* automatic scan module is enabled
* ghc-boot process has been done

Module                                  Alias               Candidates
-------------------------------------------------------------------------------
Prelude                                 -                        212
iquiw commented 9 years ago

I pushed the fix as commit 9010952cebb8f7f126fccfb64f6125345d3eac1f Please try it.

Aside from this error, ghc-get-info seems not work in this case. You might want to check *GHC Debug* buffer by setting ghc-debug to t.

8573 commented 9 years ago

The “Wrong type argument” error appears fixed; thanks!

I see no error messages in *GHC Debug*, though I don’t know what to look for.

iquiw commented 9 years ago

M-x ghc-show-info works?

8573 commented 9 years ago

M-x ghc-show-info doesn’t seem to do anything.

iquiw commented 9 years ago

Check the return value of M-: ghc-process-running. If it is t, I am afraid you hit the problem written in https://github.com/kazu-yamamoto/ghc-mod/issues/405#issuecomment-63602731

It is appreciated if you could try the code written in the above issue comment.

8573 commented 9 years ago

ghc-process-running is nil when I first visit a Haskell source file, and neither completing a word with company-ghc nor running ghc-show-info seem to change the value of ghc-process-running to anything other than nil.

It is appreciated if you could try the code written in the above issue comment.

Having made the following change to ghc-mod

diff --git i/elisp/ghc-process.el w/elisp/ghc-process.el
index 9fb92d8..5f40675 100644
--- i/elisp/ghc-process.el
+++ w/elisp/ghc-process.el
@@ -112,8 +112,9 @@
     (setq ghc-process-num-of-results (or n 1))
     (let ((pro (ghc-with-process cmd 'ghc-process-callback nil hook)))
       (condition-case nil
-         (while (and (null ghc-process-rendezvous)
-                     (accept-process-output pro 2)))
+          (let ((inhibit-quit nil))
+            (while (null ghc-process-rendezvous)
+              (accept-process-output pro)))
        (quit
         (setq ghc-process-running nil))))
     ghc-process-results))

company-ghc still works, ghc-show-info still doesn’t seem to do anything, and ghc-process-running still stays nil.

iquiw commented 9 years ago

Thanks for trying. Then I have no idea what happens.

iquiw commented 9 years ago

This is an issue in ghc-mod. Maybe ghc-mod people can help.