magit / forge

Work with Git forges from the comfort of Magit
GNU General Public License v3.0
1.33k stars 117 forks source link

"Wrong number of arguments" during closing of gitlab merge request #619

Closed nagy closed 10 months ago

nagy commented 10 months ago

This happens when attempting to close a merge request in a gitlab repository:

Debugger entered--Lisp error: (wrong-number-of-arguments ((t) (repo topic) (progn (forge--set-topic-field repo topic 'state_event (let* ((val (eieio-oref topic ...))) (cond ((eq val ...) (let nil "reopen")) ((eq val ...) (let nil "close")) (t (let ... ...))))))) 3)
  ((closure (t) (repo topic) (progn (forge--set-topic-field repo topic 'state_event (let* ((val (eieio-oref topic ...))) (cond ((eq val ...) (let nil "reopen")) ((eq val ...) (let nil "close")) (t (let ... ...))))))) #<forge-gitlab-repository forge-gitlab-repository-24354f4> #<forge-pullreq forge-pullreq-59db1d4> closed)
  (apply (closure (t) (repo topic) (progn (forge--set-topic-field repo topic 'state_event (let* ((val (eieio-oref topic ...))) (cond ((eq val ...) (let nil "reopen")) ((eq val ...) (let nil "close")) (t (let ... ...))))))) #<forge-gitlab-repository forge-gitlab-repository-24354f4> (#<forge-pullreq forge-pullreq-59db1d4> closed))
  (forge--set-topic-state #<forge-gitlab-repository forge-gitlab-repository-24354f4> #<forge-pullreq forge-pullreq-59db1d4> closed)
  (funcall forge--set-topic-state #<forge-gitlab-repository forge-gitlab-repository-24354f4> #<forge-pullreq forge-pullreq-59db1d4> closed)
  (forge--topic-set state closed)
  (forge-edit-topic-state)

That is because in forge-gitlab.el, the function accepts two arguments:

(cl-defmethod forge--set-topic-state
  ((repo forge-gitlab-repository) topic)
  (forge--set-topic-field repo topic 'state_event
                          (pcase-exhaustive (oref topic state)
                            ('closed "reopen")
                            ('open   "close"))))

But in forge-topic.el , it is being called with three arguments:

(defun forge--topic-set (slot value &optional topic)
  (unless topic
    (setq topic (forge-current-topic t)))
  (funcall (intern (format "forge--set-topic-%s" slot))
           (forge-get-repository topic)
           topic
           value))
tarsius commented 10 months ago

Thanks for the report!