Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clojure-indent-function: (wrong-type-argument number-or-marker-p nil) #584

Closed
manuel-uberti opened this issue Mar 3, 2021 · 8 comments
Closed

Comments

@manuel-uberti
Copy link
Contributor

manuel-uberti commented Mar 3, 2021

Expected behavior

With the whole buffer marked, I expect indent-region to indent it all with no errors.

Actual behavior

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  #f(compiled-function (method) #<bytecode -0x11a418d65ea601b1>)(nil)
  clojure-indent-function(17 (1 1 5 nil nil nil 0 nil nil (1) nil))
  calculate-lisp-indent((1 1 5 nil nil nil 0 nil nil (1) nil))
  lisp-indent-line()
  clojure-indent-line()
  indent-according-to-mode()
  indent-region-line-by-line(1 546)
  indent-region(1 546)
  clojure-indent-region(1 546)
  indent-region(1 546 nil)
  funcall-interactively(indent-region 1 546 nil)
  call-interactively(indent-region record nil)
  command-execute(indent-region record)
  execute-extended-command(nil "indent-region" nil)
  funcall-interactively(execute-extended-command nil "indent-region" nil)
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

Steps to reproduce the problem

  • emacs -Q
  • install clojure-mode (I used straight.el)
  • visit a Clojure file (I used core.clj)
  • C-x h
  • M-x indent-region

Environment & Version information

clojure-mode version

clojure-mode (version 5.13.0-snapshot)

Emacs version

GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.18, cairo version 1.16.0)
of 2021-03-03

Operating system

Ubuntu 20.04 LTS

@manuel-uberti
Copy link
Contributor Author

I don't know if this could be helpful, but following the above steps when I evaluate (clojure--find-indent-spec) I get nil.

@manuel-uberti
Copy link
Contributor Author

On further debugging I noticed that in clojure--find-indent-spec-backtracking I get a 1 for method (line 1359). Then on line 1367 I see:

(when (numberp method)
  (setq method (list method)))

And then on line 1376:

(`1 (let ((head (elt method 0)))
      (when (or (= pos 0) (sequencep head))
        head)))

But it looks like that head is never returned, because head is not a sequence? This is, of course, if I have been understanding it all correctly. :)

@omar-polo
Copy link

I have the same error with emacs compiled from the latest master, but not with 27.1. Furthermore, it's something that changed recently, as I recompile emacs every couple of weeks, and noticed this regression only yesterday.

I don't have the time to bisect the master right now, sorry for not providing additional info.

@manuel-uberti
Copy link
Contributor Author

I hard reset to commit 6bf56a3614ccd23a31e34ae997b2a6bb0d158489 and it seems to work now.

@manuel-uberti
Copy link
Contributor Author

@omar-polo I saw many changes on pcase in Emacs master. Could it be related? Both clojure--find-indent-spec-backtracking and clojure-indent-function use pcase.

@omar-polo
Copy link

This commit seems only about comments and a style change, so maybe the culprit is some commit after?

Since clojure-indent-function & friends weren't touched recently, this could be an emacs bug in the recent pcase changes you mentioned.

@manuel-uberti
Copy link
Contributor Author

Yes I explicitly reverted to the first commit I found without changes to pcase. I wrote to emacs-devel[1] pointing at this issue here to see if I can get some help on this, provided it is indeed related to the changes on pcase.

[1] https://lists.gnu.org/archive/html/emacs-devel/2021-03/msg00172.html

@manuel-uberti
Copy link
Contributor Author

manuel-uberti commented Mar 4, 2021

As per the exchange on emacs-devel, clojure-indent-function could be fixed by changing:

(pcase method
  ((or (pred integerp) `(,method))
   (let ((pos -1))
     [...]

to:

(pcase method
  ((or (pred integerp) `(m))
   (let ((method (if (integerp method) method m))
         (pos -1))
     [...]

Not sure how to make the change backward compatible, though, but since this is related to changes on Emacs master, I guess we can close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants