> running the following interpreted or compiled code works (but shouldn't)
After looking into this a little more, it seems the behavior of eval inside modules in compiled code is due to the last two lines of module.scm rather than `eval-handler`. I believe the stated explanations still hold true for interpreted code (and in either case, the behavior of eval inside modules remains dubious) I experimented with commenting out these lines of `eval-hander`: ;; When se is empty, it's the first time eval was called: ;; ensure an active default environment. We do it here because ;; eval does not work yet at the end of modules.scm, and we ;; don't want to inject calls into every toplevel (see #1437) (when (null? se) ((compile-to-closure `(##core#begin (import-for-syntax ,@default-syntax-imports) (import ,@default-imports)) '() #f #f #f #t) '())) In which case it becomes much easier to implement a pure r5rs/r7rs switch, and nothing seemed to break on the surface (in trivial interpreted/compiled code tests), but to be honest I don't fully understand the comment that comes with it and did almost no testing, so I'm definitely missing something there.