From c79aa880afb467ee9ca76a0d3461fa1d49d8b252 Mon Sep 17 00:00:00 2001 From: giles Date: Thu, 19 Mar 2026 21:08:01 +0000 Subject: [PATCH] Compiler: handle :effects annotation in define, adapter-sx.sx compiles Fixed compile-define to skip :effects/:as keyword annotations between the name and body. (define name :effects [render] (fn ...)) now correctly compiles the fn body, not the :effects keyword. Result: adapter-sx.sx compiles to 25 code objects, 4044 bytes of bytecode. All 12 aser functions (aser, aser-call, aser-list, aser-fragment, aser-expand-component, etc.) compile successfully. 40/40 VM tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) --- spec/compiler.sx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/spec/compiler.sx b/spec/compiler.sx index c05b9be..8a6d162 100644 --- a/spec/compiler.sx +++ b/spec/compiler.sx @@ -429,7 +429,20 @@ (name (if (= (type-of name-expr) "symbol") (symbol-name name-expr) name-expr)) - (value (nth args 1)) + ;; Handle :effects annotation: (define name :effects [...] value) + ;; Skip keyword-value pairs between name and body + (value (let ((rest-args (rest args))) + (if (and (not (empty? rest-args)) + (= (type-of (first rest-args)) "keyword")) + ;; Skip :keyword value pairs until we hit the body + (let ((skip-annotations + (fn (items) + (if (empty? items) nil + (if (= (type-of (first items)) "keyword") + (skip-annotations (rest (rest items))) + (first items)))))) + (skip-annotations rest-args)) + (first rest-args)))) (name-idx (pool-add (get em "pool") name))) (compile-expr em value scope false) (emit-op em 128) ;; OP_DEFINE