Fork me on GitHub

I'm debugging an issue with clojure indentation in emacs, and I'd like some pointers to continue the debugging. I found, using edebug, that my error

clojure-indent-function: Wrong type argument: number-or-marker-p, nil
comes from trying to do:
((= pos (1+ method))
where method comes from:
(let ((method (clojure--find-indent-spec))
Now, the question: I enabled edebug also for clojure--find-indent-spec, but the debugger doesn't step in that automatically! Why?


I'd like another pair of eyes to see how method can become nil in this code, from clojure-mode:


(defun clojure-indent-function (indent-point state)

  ;; Goto to the open-paren.
  (goto-char (elt state 1))
  ;; Maps, sets, vectors and reader conditionals.
  (if (clojure--not-function-form-p)
      (1+ (current-column))
    ;; Function or macro call.
    (forward-char 1)
    (let ((method (clojure--find-indent-spec))
          (last-sexp calculate-lisp-indent-last-sexp)
          (containing-form-column (1- (current-column))))
      (pcase method
        ((or (pred integerp) `(,method))
         (let ((pos -1))
           (condition-case nil
               (while (and (<= (point) indent-point)
                           (not (eobp)))
                 (clojure-forward-logical-sexp 1)
                 (cl-incf pos))
             ;; If indent-point is _after_ the last sexp in the
             ;; current sexp, we detect that by catching the
             ;; `scan-error'. In that case, we should return the
             ;; indentation as if there were an extra sexp at point.
             (scan-error (cl-incf pos)))
            ;; The first non-special arg. Rigidly reduce indentation.
            ((= pos (1+ method))
             (+ lisp-body-indent containing-form-column))


basically, in the last but one line, I have (= pos (1+ method)) and method is nil there, but it wasn't nil in the let block in which it has been defined, and I'm not sure where else it could have changed!


i don't have time to look at it atm. and these kinds of things just require stepping through. I doubt anyone has context on this low level stuff except at the time they've worked on it. its quite possible you know the most about it at the current time


but if you open an issue on clojure-mode it might get some eyes on it. and be a place for discussion that won't go away when the slack scroll limit is hit

🙌 3

thanks, yes, I'll probably do that. I stepped through that, hence my disbelief, since the only place in which it could have changed is:

(pcase method
        ((or (pred integerp) `(,method))
and I don't think that modifies method. Anyway, yes, I'll head for github


oof. sucks when its a language control flow issue you end up diagnosing


so, there was a PR here following that discussion, but I tried to modify that locally, and the problem persists


it doesn't help that I don't understand why pcase (which is pattern matching) should ever overwrite the variable it's matching on. I'm trying to understand the semantics of pcase now that we restricted the problem


pinging @manuel since he knows more


ah, no, my bad, it's not literally the same problem 👼


problem solved 🙂