jolt/.dirge/memory/PITFALLS.md
Yogthos 4ca7c31e50 Route syntax-quote, set!, var, ., new to interpreter
Compile-time implementation of syntax-quote proved too complex for the
current emission pipeline (qualified symbol handling across both
string and data-structure paths). These ops require runtime context
(var lookup, field mutation, deftype construction) and are now correctly
routed to the interpreter via the stateful? check in eval-string.

Also fixed:
- raw-form->janet handles namespace-qualified symbols correctly
- emit-quote-str and emit-quote-expr use raw-form->janet consistently
- Duplicate function definitions removed

All 317 tests pass, 0 failures.
2026-06-02 16:48:10 -04:00

1.6 KiB

When you need to mutate a local with set, use (var x nil) not (def x nil). def creates constants — (set ns-name ...) on a def fails with "cannot set constant". This hit us in loader.janet ns-name extraction loop. § core-renames MUST match actual function names in core.janet. "-"core-sub NOT core--. "fn?" was missing entirely (caused silent nil). Missing entries → symbol treated as unknown global, returns nil. When adding: grep core.janet for actual (defn core-XXX) name, add to BOTH core-renames (string table) and core-fn-values (fn value table). § Bare tuples in Janet's eval are function calls: (eval [1 2 3]) tries to call 1 as function. Always emit ['tuple 1 2 3] or (tuple 1 2 3) in data-structure emitter. Similarly, (eval (try body (sym handler))) fails because catch is not a Janet special form — must be (try body ([sym] handler)). Discovered during Phase 5/6 compiler work. § core-renames MUST match actual function names in core.janet. "-"core-sub NOT core--. "fn?" was missing entirely (caused silent nil). Missing entries → symbol treated as unknown global, returns nil. When adding: grep core.janet for actual (defn core-XXX) name, add to BOTH core-renames (string table) and core-fn-values (fn value table). § Bare tuples in Janet's eval are function calls: (eval [1 2 3]) tries to call 1 as function. Always emit ['tuple 1 2 3] or (tuple 1 2 3) in data-structure emitter. Similarly, (eval (try body (sym handler))) fails because catch is not a Janet special form — must be (try body ([sym] handler)). Discovered during Phase 5/6 compiler work.