Skip to content

Restarts with both :test and :interactive don't work

If a restart in restart-case provides both :test and :interactive, the :test will be ignored.

(restart-case
    (error "error")
  (test ()
     :test (lambda () (print "interactive") nil)
     :interactive (lambda (x) (print "in test") x)
    19))

This should print "in test" at least once as the condition is tested, and then if the restart is selected interactively, "interactive" should print. In fact, "in test" is not printed.

I believe this is due to the following in the definition of restart-case:

(when test
  (setq keywords (list :TEST-FUNCTION `#',test)))                              
(when interactive
  (setq keywords (list :INTERACTIVE-FUNCTION `#',interactive)))

https://gitlab.com/embeddable-common-lisp/ecl/blob/8406e1e4fc1eb88f7ef8412cce1542235207cb6f/src/clos/conditions.lsp#L144-148

Obviously the latter setq can render the former irrelevant. The :report code does things properly with list*.

I have not reproduced this in ecl, but clasp has the same code and works like this. I apologize if some other factor makes this report irrelevant.