nim-lang / nim-mode

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

Byte compile error and warnings #247

Closed jcs090218 closed 10 months ago

jcs090218 commented 10 months ago

This package is not installable at the moment.

Here is the compile log:

In toplevel form:
nim-mode.el:100:2: Warning: unescaped character literals `?[' detected, `?\[' expected!

In nim-electric-space:
nim-mode.el:358:33: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.

Compiling d:/_workspace/_lang/elisp/nim-mode/nim-capf.el... done v

In end of data:
nim-capf.el:296:18: Warning: the function `company-grab-symbol-cons' is not known to be defined.
nim-capf.el:290:22: Warning: the function `company-begin-backend' is not known to be defined.

Compiling d:/_workspace/_lang/elisp/nim-mode/nim-compile.el... done v

In nim-find-file-in-heirarchy:
nim-compile.el:54:2: Warning: docstring wider than 80 characters

Compiling d:/_workspace/_lang/elisp/nim-mode/nim-fill.el... done v
Compiling d:/_workspace/_lang/elisp/nim-mode/nim-helper.el... done v
Compiling d:/_workspace/_lang/elisp/nim-mode/nim-rx.el... skipped X

In toplevel form:
- nim-rx.el:27:4: Error: Invalid function: ((lambda nil (rx symbol-start (or "elif" "else" "of" "except" "finally") symbol-end)))

Compiling d:/_workspace/_lang/elisp/nim-mode/nim-smie.el... done v

In nim-traverse:
nim-smie.el:195:18: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.

In nim-smie--colon:
nim-smie.el:332:45: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.

In nim-smie--handle-object-of:
nim-smie.el:499:35: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.

In nim-smie--object:
nim-smie.el:551:49: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.

In nim-smie--list-intro-conditions:
nim-smie.el:561:36: Warning: `point-at-eol' is an obsolete function (as of 29.1); use `line-end-position' or `pos-eol' instead.

In nim-mode-backward-token:
nim-smie.el:653:35: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.

In nim-get-indent-start-p:
nim-smie.el:723:20: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.

In nim-smie-rule-adjust-else-stmt:
nim-smie.el:743:35: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.

In nim-smie--break:
nim-smie.el:787:25: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.
nim-smie.el:802:31: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.

In nim-previous-line-end-with:
nim-smie.el:818:19: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.

In nim-get-comment-indent:
nim-smie.el:829:50: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.
nim-smie.el:830:57: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.
nim-smie.el:831:55: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.
nim-smie.el:836:39: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.
nim-smie.el:838:21: Warning: `point-at-eol' is an obsolete function (as of 29.1); use `line-end-position' or `pos-eol' instead.

In nim-get-comment-start-point:
nim-smie.el:857:41: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.
nim-smie.el:858:52: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.

In nim-get-empty-line-indent:
nim-smie.el:899:45: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.
nim-smie.el:906:21: Warning: `point-at-bol' is an obsolete function (as of 29.1); use `line-beginning-position' or `pos-bol' instead.

In nim-smie-indent-calculate:
nim-smie.el:944:21: Warning: Missing format argument

Compiling d:/_workspace/_lang/elisp/nim-mode/nim-suggest.el... done v

In nimsuggest--start-server-deferred:
nim-suggest.el:146:2: Warning: docstring wider than 80 characters
nim-suggest.el:491:12: Warning: defcustom for `nimsuggest-doc-directive' has syntactically odd type `'(choice (const :tag suggest 'sug) (const :tag definition 'def))'

In end of data:
nim-suggest.el:606:8: Warning: the function `evil-make-intercept-map' is not known to be defined.
nim-suggest.el:594:6: Warning: the function `org-show-all' is not known to be defined.

Compiling d:/_workspace/_lang/elisp/nim-mode/nim-syntax.el... done v

In nim-syntax-commentify:
nim-syntax.el:280:27: Warning: `point-at-eol' is an obsolete function (as of 29.1); use `line-end-position' or `pos-eol' instead.
nim-syntax.el:280:42: Warning: `point-at-eol' is an obsolete function (as of 29.1); use `line-end-position' or `pos-eol' instead.

In nim-syntax-comment-or-string-p:
nim-syntax.el:330:2: Warning: docstring has wrong usage of unescaped single quotes (use \= or different quoting)

Compiling d:/_workspace/_lang/elisp/nim-mode/nim-util.el... done v
Compiling d:/_workspace/_lang/elisp/nim-mode/nim-vars.el... done v

In toplevel form:
nim-vars.el:223:52: Warning: reference to free variable `org-mode-map'
nim-vars.el:638:55: Warning: Alias for `nimsuggest-path' should be declared before its referent
nim-vars.el:639:55: Warning: Alias for `nimsuggest-dirty-directory' should be declared before its referent
nim-vars.el:640:55: Warning: Alias for `nimsuggest-options' should be declared before its referent
nim-vars.el:641:61: Warning: Alias for `nimsuggest-local-options' should be declared before its referent
nim-vars.el:642:64: Warning: Alias for `nimsuggest-ignore-dir-regex' should be declared before its referent
nim-vars.el:643:61: Warning: Alias for `nim--inside-compiler-dir-p' should be declared before its referent
Vindaar commented 10 months ago

I noticed the same the other day. It's a bit confusing though, because the recent PRs that were merged did not touch nim-rx. So I just checked locally if I can reproduce the same error on HEAD~3 744e076f0bea1c5ddc49f92397d9aa98ffa7eff8

Running emacs with -Q and:

;; load all packages required by nim-mode
(add-to-list 'load-path "~/.emacs.d/elpa/commenter-20160219.1627/")
(add-to-list 'load-path "~/.emacs.d/elpa/epc-20140610.534/")
(add-to-list 'load-path "~/.emacs.d/elpa/concurrent-20170601.435/")
(add-to-list 'load-path "~/.emacs.d/elpa/deferred-20170901.1330/")
(add-to-list 'load-path "~/.emacs.d/elpa/ctable-20210128.629/")

;; add nim-mode itself
(add-to-list 'load-path "~/src/nim/nim-mode")
;; try to recompile the module
(byte-recompile-directory "~/src/nim/nim-mode/" 0 t)

yields the same error for me on that commit.

So I suppose this is some issue that didn't appear on older emacs versions?

Also (betraying my ignorance) I'm a bit confused that evaluating the nim-rx-constituents definition in nim-rx.org works fine, but only doing the byte compilation fails.

Unfortunately, the nim-rx code is a bit over my head. I'm more used to writing Nim macros. :rofl: While I managed to fix (?) it locally for me, I'm not sure if I'm changing the result. Or rather I am if I base it on evaluating the defvar by hand, but this

((dedenter . "\\_<\\(?:e\\(?:l\\(?:if\\|se\\)\\|xcept\\)\\|finally\\|of\\)\\_>") (defun . "\\_<\\(?:converter\\|func\\|iterator\\|m\\(?:acro\\|ethod\\)\\|proc\\|template\\)\\_>") (block-start-defun . "\\_<\\(?:block\\|c\\(?:ase\\|onverter\\)\\|e\\(?:l\\(?:if\\|se\\)\\|num\\|xcept\\)\\|f\\(?:inally\\|or\\|unc\\)\\|i\\(?:f\\|terator\\)\\|m\\(?:acro\\|ethod\\)\\|o\\(?:bject\\|f\\)\\|proc\\|t\\(?:emplate\\|ry\\|uple\\)\\|w\\(?:h\\(?:en\\|ile\\)\\|ith\\)\\)\\_>") (decl-block . "\\_<\\(?:const\\|import\\|let\\|type\\|var\\)\\_>[[:space:]]*\\(?:#\\|$\\)") (symbol-name . "[_–[:alpha:]][_–[:word:]]*") (hex-lit . "0[Xx][[:xdigit:]]\\(?:[[:xdigit:]]\\|_\\)*") (dec-lit . "[[:digit:]]\\(?:[[:digit:]]\\|_\\)*") (oct-lit . "0[Cco][0-7][0-7_]*") (bin-lit . "0[Bb][01][01_]*") (exponent . "\\([Ee][+-]?[[:digit:]]\\(?:_\\|[[:digit:]]\\)*\\)") (open-paren . "[([{]") (close-paren . "[])}]") ...)

is a bit hard to read for me (this is what the current code produces for me when evaluated by hand). The confusing thing to me is also that the entire

(dedenter          . ("elif" "else" "of" "except" "finally"))

does not at all appear.

If anyone can help out, that would be appreciated! I'll try to understand if my fix is correct later and possibly open a PR with it.

jcs090218 commented 10 months ago

I think this is how you solve this issue. 🤔

diff --git a/nim-rx.el b/nim-rx.el
index 5628c17..079ad58 100644
--- a/nim-rx.el
+++ b/nim-rx.el
@@ -34,7 +34,10 @@
                                                                 "try" "except" "finally"
                                                                 "with" "block"
                                                                 "enum" "tuple" "object")))
-                     collect (cons sym (apply `((lambda () (rx symbol-start (or ,@kwd) symbol-end)))))))
+                     collect (cons sym (apply
+                                        (lambda (kwd)
+                                          (eval `(rx symbol-start (or ,@kwd) symbol-end)))
+                                        (list kwd)))))
            (constituents2 `((decl-block . ,(rx symbol-start
                                                (or "type" "const" "var" "let" "import")
                                                symbol-end
jcs090218 commented 10 months ago

I've opened the PR in #248 for the fix!

By seeing many warnings and errors in this package, I strongly recommend adding CI/CD to this repo; therefore, it can lower your maintenance. 🤔

Vindaar commented 10 months ago

By seeing many warnings and errors in this package, I strongly recommend adding CI/CD to this repo; therefore, it can lower your maintenance. 🤔

You're more than welcome to help with that. I've never set up a CI for emacs, so I'm not sure how this is typically done (i.e. how do we test different versions of emacs? how do we generally run the test cases? etc.). I've only started to actively help maintaining this repo, because no one else was doing it. Not because I'm an expert, heh.

jcs090218 commented 10 months ago

I only use Eask to test my packages. If you want, I can open a PR for this.

See lsp-grammarly as the reference.

Vindaar commented 10 months ago

That would be much appreciated! :rocket:

Vindaar commented 10 months ago

Closed by #248.