jolt/.dirge/memory/MEMORY.md
Yogthos 1de109f261 Bug fixes: nth, list, name, subs support in compiler
- core.janet: add core-nth function + nth binding (was missing entirely)
- compiler.janet: add list, name, subs to core-renames and core-fn-values
- compiler.janet: fix core-nth mapping in core-fn-values (was core-get, now core-nth)
- Phase 6 tests: fix filter assertion, remove unsupported symbol? test
- symbol? with quoted symbols: Janet symbols ≠ Jolt symbol structs
- All 317 tests pass, 0 failures
2026-06-02 16:30:25 -04:00

2.1 KiB

Janet's eval runs in Janet's default environment and does NOT have access to symbols imported via (use ...) in the calling file. (eval '(core-inc 1)) fails with "unknown symbol core-inc" even when the file does (use ./core). FIX: emit Janet data structures where function VALUES are embedded directly (e.g. [core-inc 1]) rather than source strings "(core-inc 1)". The core-fn-values table resolves Janet symbol names to actual function values at compile time. § Jolt Compiler Architecture (Phases 1-6, dfa9874→c366963): Two-phase — analyze-form (Clojure form → annotated AST) → emit-ast (→ Janet source string) or emit-expr (→ Janet data structures for eval). analyze-form takes [form bindings &opt ctx]; ctx needed for macro expansion. Symbol classification: bindings first (:local), then core-renames (:core-symbol), then plain (:symbol). Two emitter paths: string (compile-form) and data structures (compile-ast). Core fn values resolved via core-fn-values table. compile-and-eval takes [form ctx]; pass nil for no macro ctx. Naming: Clojure - → core-sub. Key bugs found: emit-vector-expr must wrap with (tuple ...) — bare tuples eval as fn calls. make-symbol must treat / at pos 0 as unqualified. raw-form->janet converter for quote (don't re-analyze). core-renames entry for fn? was missing. § eval-string dispatch (api.janet): When :compile? is true, stateful forms (defmacro, ns, deftype, defmulti, defmethod, require, in-ns) always use interpreter. All others (def, defn via macros, pure expressions) go through compile-and-eval. defn bug was caused by macros not being expanded — fixed in Phase 4 by routing macros through compiler's analyze-form which expands them at analyze time. § Phase 6: 47 comprehensive compile-mode tests in test/phase6-final.janet. Collections, math, predicates, comparison, seq ops (map/filter/reduce/take/drop), special forms (let/if/loop/try/quote), macros (defn/when/and/or/fn/if-let), complex nesting. All 317 tests pass. Remaining: syntax-quote, set! compiler support. deftype, defmulti/defmethod routed to interpreter (stateful).