   (should
    (equal
     (wh/bound-syms '(lambda (x y) XXX))
-    (list 'x 'y))))
+    (list 'x 'y)))
+  (should
+   (equal
+    (wh/bound-syms '(lambda (x &optional y &rest z) XXX))
+    (list 'x 'y 'z))))
 
 (ert-deftest wh/bound-syms-let ()
   ;; Handle bindings introduced by let.

      (setq form
            (macroexpand-all (read (current-buffer)))))
    (delete-char 5)
    (message "syms: %S"
             (-filter #'wh/in-obarray-p
                      (wh/bound-syms form)))))

(defun wh/bound-syms (form &optional accum)
  "Return a list of bound symbols around the symbol XXX in FORM.

Assumes FORM has been fully macro-expanded."
  (catch 'done
    ;; If we've hit the symbol we're looking for, we can return the
    ;; bound symbols we found.
    (when (eq form 'XXX)
      (throw 'done accum))
    
    (when (consp form)
      (let (bindings-found)
        ;; If this is a lambda form, the enclosed forms have the parameters
        ;; too.
        (cond
         ((eq (car form) 'lambda)
          (-let [(_ args . body) form]
            (setq args
                  (--remove (member it '(&optional &rest)) args))
            (setq bindings-found
                  (--map (wh/bound-syms it (append accum args))
                         body))))
