nim-lang / nim-mode

An emacs major mode for the Nim programming language
139 stars 46 forks source link

(wrong-type-argument stringp nil) #154

Closed krux02 closed 7 years ago

krux02 commented 7 years ago

Today flycheck stopped working. I did some upgrades on my system, that could be the reason.

This is the error message that is shown in the minibuffer and in *Messages*

Error from syntax checker nim-nimsuggest: (wrong-type-argument stringp nil)

It would be very helpful if anybody can give me support in finding out where that error occured.

EDIT: I got a hint that the problem is related to this line: https://github.com/nim-lang/nim-mode/blob/master/flycheck-nimsuggest.el#L67

StefanSalewski commented 7 years ago

I guess you know that output format for nimsuggest chk command send over socket has changed recently? For my NEd editor check (Ctrl E) stopped working some days ago, but it is already fixed. I do know nothing about emacs nim-mode. sorry.

krux02 commented 7 years ago

Well aparently I did not know that the format did change. It would be nice if someone could help me fix it to the new format, so that I can do a pull request.

krux02 commented 7 years ago

Well I did test it now on another computer, might be that the version is a bet newver from nimsuggest, but I get this error message:

Error while checking syntax automatically: (error "Server may raise an error. Use \"M-x epc:pop-to-last-server-process-buffer RET\" to see full traceback:

Process epc:server:51 finished
")

and when I go into the server-process-buffer I get the following content:

Process epc:server:51 finished

not very informative

yuutayamada commented 7 years ago

This may be a hint to debug: https://github.com/nim-lang/nimsuggest/issues/37 I used this to distinguish the problem whether nimsuggest side or nim-mode side. Are you using both devel version's nim and nimsuggest?

yuutayamada commented 7 years ago

@StefanSalewski thank you for mentioning nim's error format change. It was really help:)

yuutayamada commented 7 years ago

@krux02 I've merged the fix. But since the error format change is only nim's devel branch, you need to configure like this:

;; you may use setq instead of defconst (, but I used this to avoid flycheck warnign)
(defconst flycheck-nimsuggest-error-parser 'flycheck-nimsuggest-error-parser)
krux02 commented 7 years ago

@yuutayamada I tried the defconst, but for some reason it doesn't work. Are you sure that these things here do not conflict? I mean what does the symbol flycheck-nimsuggest-error-parser refer to?

(defun    flycheck-nimsuggest-error-parser ...
(defvar   flycheck-nimsuggest-error-parser ...
(defconst flycheck-nimsuggest-error-parser ...
yuutayamada commented 7 years ago

Ah sorry, maybe it was criptic... Since new nim's error format was introduced only in devel, I needed to set old error parser as nim-mode's default. The flycheck-nimsuggest-error-parser function should treat nim devel's new error format. (and there is flycheck-nimsuggest-old-error-parser function for nim version 0.16.0, which will be deleted on the future and I will switch new error parser silently after nim's new version is introduced)

I'm not sure it's help, but for your information:

(also you may know, defconst and setq can override default variable)

just for clarification, I have following configuration to use devel's nimsuggest:

(defconst flycheck-nimsuggest-error-parser 'flycheck-nimsuggest-error-parser)

EDIT: flycheck-nimsuggest-error-parser variable is called when flycheck-nimsuggest parse nimsuggest's errors over EPC protocol.

yuutayamada commented 7 years ago

Is there any chance that you are loading old bytecompiled nimsuggest-flycheck.el or loading your own nim-mode repo?

krux02 commented 7 years ago

I am loading my own nim-mode repo. This is how I do it:

(add-to-list 'load-path "~/proj/nim-mode/")
(require 'nim-mode)
(require 'nim-suggest)
(require 'nimscript-mode)
(require 'nim-eldoc)

This is my least favorite part, but I have no idea on how to do it better. I just found instructions somewher to do it like this, but I kept gettings warning and problems about other modules that should have been inside of nim-mode. I could not help myself better than doing this ugly mess. I looked though the cask documentation, but it explained everything but how to test it interactively in the with the current emacs configuration.

And I have old elc files, do they case problems when they get out of date?

, and I have once done bytecode compiled stuff, I did not know it could case problems.

yuutayamada commented 7 years ago

And I have old elc files, do they case problems when they get out of date?

yes very likely. You may want to set load-prefer-newer to t to prior up-to-date files.

and I have once done bytecode compiled stuff, I did not know it could case problems.

I'm not sure whether I understood what you did. Is your emacs loading latest files? (it may depends on the value of load-prefer-newer, but I don't know there are more configuration)

You may check following way at a nim file: a.nim:

# (fboundp 'flycheck-nimsuggest-error-parser) <- C-x C-e at end of paren

This way should return t if your emacs already defined the flycheck-nimsuggest-error-parser and that means you already loaded latest flycheck-nimsuggest.el

krux02 commented 7 years ago

Thanks a lot for your support. It seems to work now. I have some outdated elc files, but I did not know they can cause problems. And about the load-prefer-newer, that is a typical emacs thing, set to the wrong value by default because it behaved differently in the past.

krux02 commented 7 years ago

Well I am now this far:

Image of Yaktocat

Seems like the error messages are one line off. I should add, that this does not happen in all files. I just tested it with two files, my scratch file that resides outside of a project (everythig worked), and my project I am woring on, specifically this file:

https://github.com/krux02/opengl-sandbox/blob/master/includes/shadingDsl.nim

yuutayamada commented 7 years ago

yeah, I added offset to adjust it, but sometimes slip somewhere... I think it's due to nimsuggest or nim's new feature (I saw somewhere in nimlang repo like auto cursor or something...)

Please PR if you think you can fix it by specifying fixed value at https://github.com/nim-lang/nim-mode/blob/master/flycheck-nimsuggest.el#L79

krux02 commented 7 years ago

I don't know what feature you are referring to. Maybe it is really a nimsuggest bug. I still have bugs, but this one here is resolved (for me, for other people you should put the defconst instruction in the readme).

yuutayamada commented 7 years ago

but this one here is resolved (for me, for other people you should put the defconst instruction in the readme).

yeah I will, but not today.