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