diff --git a/lib/erlang/transpile.sx b/lib/erlang/transpile.sx index 1cb64268..915d31b6 100644 --- a/lib/erlang/transpile.sx +++ b/lib/erlang/transpile.sx @@ -1895,15 +1895,20 @@ (define er-env-derived-from? (fn (env target-env) + ;; Object-identity check, NOT value `=`. On evaluators where dict `=` + ;; is structural/deep, comparing closure envs (which are large and + ;; cyclic — a module fun's env references the fun) does not terminate. + ;; `identical?` is pointer identity on every host and is the actual + ;; intended semantics: "is this the same env object". (cond - (= env target-env) true + (identical? env target-env) true :else (let ((ks (keys env)) (found-ref (list false))) (for-each (fn (i) (when (not (nth found-ref 0)) (let ((v (get env (nth ks i)))) - (when (and (er-fun? v) (= (get v :env) target-env)) + (when (and (er-fun? v) (identical? (get v :env) target-env)) (set-nth! found-ref 0 true))))) (range 0 (len ks))) (nth found-ref 0)))))