reproducible testcase pasted by sjamaan on Sun Dec 8 20:44:46 2019

(module foo (bar)

(import scheme (chicken base) matchable)

(define (foo x y z)
  (print x y z)
  z)

(define bar
  (lambda (name parent init resize paint)
    (foo
     name parent
     (match-lambda*
       ((0) (init))
       ((1 w h) (resize w h)) ) ) )  )
)

(import foo)

((bar 1 2 (lambda () (print "init " 3)) (lambda (x y) (print "resize " x y)) 5) 0)
((bar 1 2 (lambda () (print "init " 3)) (lambda (x y) (print "resize " x y)) 5) 1 6 7)

no title pasted by megane on Wed Dec 11 16:23:08 2019

(import scheme (chicken base))
((lambda f0
   (let ((v0 f0))
     (let ((failure0
            (lambda ()
              (if (scheme#pair? v0)
                  (scheme#car v0)))))
       (failure0))))
 1)
;; Error: [internal compiler error] Saw rest op for captured variable.  This should not happen!: ##core#rest
;; -car


;; Also this different case:

;; (import scheme (chicken base) matchable)
;; ((lambda f
;;    (match f
;;      ((1 w h) 'resize)))
;;  1 6 5)
;; Error: attempted rest argument access at index 0 but rest list length is 0: #<procedure>
;; 
;; 	Call history:
;; 
;; 	qt-lite-fail.scm:1: chicken.load#load-extension	  	<--

Simplified added by sjamaan on Thu Dec 12 22:35:59 2019

(let ((proc (lambda rest0
              (let ((rest rest0)) ;; This triggers the bug
                (if (pair? rest)
                    (car rest)
                    #f)))))
  (proc 1 6))