Transpiler local-ref shadowing fix + foreign test runner bindings
ml-scan-set now checks ml-is-mutable-global? before adding set!/append! targets to the needs-ref list. Previously, mutable globals like *bind-tracking* got local `ref Nil` shadows that masked the global _ref, causing `append!: expected list, got nil` in 43 bind-tracking tests. Test runner: bind foreign registry functions (foreign-registered?, foreign-lookup, foreign-names, foreign-register!, foreign-resolve-binding, foreign-check-args, foreign-build-lambda) + initialize _cek_call_ref for with-capabilities. 22/24 foreign tests now pass, 8 capabilities tests fixed. Retranspiled sx_ref.ml — all mutable global shadows eliminated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -417,11 +417,13 @@
|
||||
(= (symbol-name head) "set!")
|
||||
(>= (len node) 2))
|
||||
(let
|
||||
((var-name (if (= (type-of (nth node 1)) "symbol") (symbol-name (nth node 1)) (str (nth node 1)))))
|
||||
((var-name (symbol-name (nth node 1))))
|
||||
(let
|
||||
((mangled (ml-mangle var-name)))
|
||||
(when
|
||||
(not (some (fn (x) (= x mangled)) result))
|
||||
(and
|
||||
(not (ml-is-mutable-global? var-name))
|
||||
(not (some (fn (x) (= x mangled)) result)))
|
||||
(append! result mangled))))
|
||||
(and
|
||||
(= (type-of head) "symbol")
|
||||
@@ -433,7 +435,9 @@
|
||||
(let
|
||||
((mangled (ml-mangle var-name)))
|
||||
(when
|
||||
(not (some (fn (x) (= x mangled)) result))
|
||||
(and
|
||||
(not (ml-is-mutable-global? var-name))
|
||||
(not (some (fn (x) (= x mangled)) result)))
|
||||
(append! result mangled))))
|
||||
:else (for-each
|
||||
(fn (child) (when (list? child) (ml-scan-set child result)))
|
||||
|
||||
Reference in New Issue
Block a user