andras-simonyi / citeproc-el

A CSL 1.0.2 Citation Processor for Emacs.
GNU General Public License v3.0
84 stars 9 forks source link

Error when loading `citeproc-generic-elements.el` #146

Closed swflint closed 6 months ago

swflint commented 8 months ago

I'm currently unable to load the library, receiving this error:

Debugger entered--Lisp error: (error "Eager macro-expansion failure: (wrong-type-argumen...")
  error("Eager macro-expansion failure: %S" (wrong-type-argument listp issued))
  internal-macroexpand-for-load((defalias 'citeproc--text #'(lambda (attrs context &rest _body) "Render the content of a text element with ATTRS an..." (let-alist attrs (let ((content nil) (type ...) (no-external-links ...)) (cond (\.value ...) (\.variable ...) (\.term ...) (\.macro ...)) (let (...) (citeproc-lib-maybe-stop-rendering ... context result ...)))))) t)
  load-with-code-conversion("/home/swflint/.emacs.d/citeproc/citeproc-generic-e..." "/home/swflint/.emacs.d/citeproc/citeproc-generic-e..." nil t)
  require(citeproc-generic-elements)

This is from 290320f.

andras-simonyi commented 8 months ago

Hello, thanks for reporting! Could you send an MWE (minimal working example) of steps that lead to the error? Also, which Emacs version are you using, and is the error reproducible with a minimal init file as well?

swflint commented 8 months ago

With the following versions:

I load as follows:

(add-to-list 'load-path "~/.emacs.d/f.el")
(add-to-list 'load-path "~/.emacs.d/dash")
(add-to-list 'load-path "~/.emacs.d/s.el")
(add-to-list 'load-path "~/.emacs.d/lisp")
(add-to-list 'load-path "~/.emacs.d/citeproc")
(require 'citeproc)

Note, queue.el is in ~/.emacs.d/lisp.

I receive this as the whole error:

Debugger entered--Lisp error: (error "Eager macro-expansion failure: (wrong-type-argumen...")
  error("Eager macro-expansion failure: %S" (wrong-type-argument listp issued))
  internal-macroexpand-for-load((defalias 'citeproc--text #'(lambda (attrs context &rest _body) "Render the content of a text element with ATTRS an..." (let-alist attrs (let ((content nil) (type ...) (no-external-links ...)) (cond (\.value ...) (\.variable ...) (\.term ...) (\.macro ...)) (let (...) (citeproc-lib-maybe-stop-rendering ... context result ...)))))) t)
  load-with-code-conversion("/home/swflint/.emacs.d/citeproc/citeproc-generic-e..." "/home/swflint/.emacs.d/citeproc/citeproc-generic-e..." nil t)
  require(citeproc-generic-elements)
  load-with-code-conversion("/home/swflint/.emacs.d/citeproc/citeproc.el" "/home/swflint/.emacs.d/citeproc/citeproc.el" nil t)
  require(citeproc)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  command-execute(eval-last-sexp)
andras-simonyi commented 8 months ago

The parsebib package (https://github.com/joostkremers/parsebib) is missing from the dependencies, but if I add it then I'm unable to reproduce the error -- with the exact same emacs and package versions you are using and without an init file (emacs -q)

(add-to-list 'load-path "~/.emacs.d/f.el")
(add-to-list 'load-path "~/.emacs.d/dash.el")
(add-to-list 'load-path "~/.emacs.d/s.el")
(add-to-list 'load-path "~/.emacs.d/citeproc-el")
(add-to-list 'load-path "~/.emacs.d/parsebib")
(add-to-list 'load-path "~/.emacs.d/lisp")
(require 'citeproc)

is executed without an error on my system (all I get is a Package cl is deprecated warning). Are you executing the above steps without loading any init files etc. before?

swflint commented 8 months ago

That's interesting. I see the same thing when I add parsebib to a test.el and load without an init file.

I load parsebib in my normal configuration, and I still get the error. Loading citeproc earlier in my init does not seem to help either.

andras-simonyi commented 8 months ago

Interesting indeed -- somehow the expansion of the citeproc--text function's defun throws an error in your case but I have no idea why exactly and cannot reproduce it with seemingly the exact same setup. Based on the error maybe you could try replacing the part

(if (string= .term "no date")
    (progn
       (setq type 'present-var)
       `(((rendered-var . issued)) ,con
   cont)

simply with

cont

in the function's body and see what happens but this is a very long shot unfortunately.

andras-simonyi commented 8 months ago

Any update on this?

swflint commented 8 months ago

Apologies! That does fix the error.

swflint commented 7 months ago

These are the results of emacs --batch -L compat/ -L citeproc/ -L dash/ -L f.el/ -L s.el/ -L parsebib/ -L lisp/ -f batch-byte-compile citeproc/*.el:

In toplevel form:
citeproc/citeproc-cite.el:32:11: Warning: Package cl is deprecated

In toplevel form:
citeproc/citeproc-generic-elements.el:92:4: Error: Wrong type argument: listp, issued

With

andras-simonyi commented 6 months ago

Thanks, I've tried again and still couldn't reproduce. I've also added Emacs 29.1 to the list of CI target platforms and the current code compiles there without an error too. Also, I haven't received any other report on the issue. Anyhow, could you try the latest version with commit 9fe5f28? I made a small change, which hopefully solves the problem although that is just a guess unfortunately.

swflint commented 6 months ago

I am still getting that error with the latest version. In addition, I'm getting a new error:

In toplevel form: citeproc/citeproc.el:41:2: Error: Eager macro-expansion failure: (wrong-type-argument listp issued)

andras-simonyi commented 6 months ago

Thanks, the whole thing is a mystery. I'm on the same platform (x86_64-pc-linux-gnu) as you, using the same Emacs version (29.1) and not seeing these problems at all, and there are no problems in the CI environment either. Is citeproc-el the only Emacs package for which you are getting this type of compilation error? The only cases similar to this I've seen were situations in which bytecodes from different Emacs versions were mixed up, so please make sure that you are removing all earlier .elc files before compilation.

swflint commented 6 months ago

It is the only package for which I am getting that sort of error.

Until fairly recently, I did not compile any packages. I've made sure that I delete bytecode for any/all packages, and I still get that error.

andras-simonyi commented 6 months ago

What is the source of your Emacs 29.1 binary? Is it a precompiled package, or are you compiling Emacs on your system?

swflint commented 6 months ago

Precompiled package (NixOS package, no user-specified overrides (though package default is lucid toolkit)).

andras-simonyi commented 6 months ago

I've installed now NixOS on a virtual machine (using VirtualBox and the most recent graphical ISO image) and still couldn't reproduce the problem in a clean environment with Emacs installed using nix-shell -p emacs29. I clone the latest versions of all dependencies and run

emacs --batch -L compat/ -L citeproc-el/ -L dash.el/ -L f.el/ -L s.el/ -L string-inflection/ -L parsebib/ -L lisp/ -f batch-byte-compile citeproc/*.el 

and the package compiles with a single warning that package cl is deprecated (coming from the queue package). The package also compiles without an error (although with warnings) if it's installed using Emacs's builtin package manager. It seems that the problem is somehow specific to your setup, I'd still suspect some kind of version and byte-code mixup.

swflint commented 6 months ago

That seems rather unlikely, as I have (multiple times) removed all elc files before compiling.