no title pasted by megane on Fri Jul 5 10:54:56 2019

This only triggers with the (not captured) test removed:

(define (foo x y)
  (define (any pred lst)
    (let loop ((lst lst))
      (cond ((null? lst) #f)
            ((pred (car lst)))
            (else (loop (cdr lst))))))

  (define (append-map proc lst1 . lsts)
    (if (null? lsts)
        (foldr (lambda (x r) (append (proc x) r)) '() lst1)
        (let loop ((lsts (cons lst1 lsts)))
          (if (any null? lsts)
              '()
              (append (apply proc (map (lambda (x) (car x)) lsts))
                      (loop (map (lambda (x) (cdr x)) lsts)))))))
  (append-map (lambda (a b) (print a b)) x y))

no title added by megane on Tue Jul 9 18:16:30 2019

(define (foo x y)
  (define (append-map proc . lsts)
    (if (null? lsts)
        (proc 1)
        (apply proc lsts)))
  (append-map (lambda (a) (print a)))
  (append-map (lambda (a b) (print a b)) x y))

;; $ ./csc -O2 ../fail.scm && ../fail
;;
;; Error: ../fail.scm:31: proc: procedure `proc' called with wrong number of arguments