Fix core-signals bytecode: letrec for self-ref, explicit get for dict destructuring

Two issues prevented core-signals.sx from working as bytecode:

1. computed/effect used (let) for self-referencing bindings (recompute,
   run-effect). Changed to (letrec) so the VM pre-allocates slots before
   compiling the lambda bodies — required for self-reference in bytecode.

2. deref used dict destructuring (let {:notify n :deps d} ctx ...) which
   the transpiled OCaml compiler doesn't support. Rewrote to explicit
   (get ctx "notify") / (get ctx "deps") calls.

Also fixed compile-let dict destructuring opcodes (OP_CONST=1 not 2,
OP_CALL_PRIM=52 not 10) for future use when compiler is retranspiled.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-11 12:38:07 +00:00
parent ef8f8b7c03
commit fc9c90b7b1
6 changed files with 16 additions and 22 deletions

View File

@@ -614,13 +614,10 @@
(str k))))
(emit-op em 16)
(emit-byte em temp-slot)
(let
((key-idx (pool-add (get em "pool") key-str)))
(emit-op em 2)
(emit-u16 em key-idx))
(emit-const em key-str)
(let
((get-idx (pool-add (get em "pool") "get")))
(emit-op em 10)
(emit-op em 52)
(emit-u16 em get-idx)
(emit-byte em 2))
(let