Calling into a Chez Scheme library from Racket -- imported symbol rewritten in vm-eval?

I think the problem is how Racket adjusts import expansion via the expand-omit-library-invocations parameter. You can restore it while evaluating like this:

#lang racket
(require ffi/unsafe/vm)

(define call-with-import-working
  (vm-eval '(lambda (thunk)
              (call-with-system-wind
               (lambda ()
                 (parameterize ([expand-omit-library-invocations #f])
                   (thunk)))))))

(call-with-import-working
 (lambda ()
   (vm-eval
    '((lambda () (import (foo)) (bar))))))
3 Likes