Add (param :as type) annotations to all fn/lambda params across SX spec

Extend the type annotation system from defcomp-only to fn/lambda params:
- Infrastructure: sf-lambda, py/js-collect-params-loop, and bootstrap_py.py
  now recognize (name :as type) in param lists, extracting just the name
- bootstrap_py.py: add _extract_param_name() helper, fix _emit_for_each_stmt
- 521 type annotations across 22 .sx spec files (eval, types, adapters,
  transpilers, engine, orchestration, deps, signals, router, prove, etc.)
- Zero behavioral change: annotations are metadata for static analysis only
- All bootstrappers (Python, JS, G1) pass, 81/81 spec tests pass

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-11 20:27:36 +00:00
parent c82941d93c
commit b99e69d1bb
23 changed files with 532 additions and 498 deletions

View File

@@ -12,7 +12,7 @@
(define render-to-sx
(fn (expr env)
(fn (expr (env :as dict))
(let ((result (aser expr env)))
;; aser-call already returns serialized SX strings;
;; only serialize non-string values
@@ -21,7 +21,7 @@
(serialize result)))))
(define aser
(fn (expr env)
(fn (expr (env :as dict))
;; Evaluate for SX wire format — serialize rendering forms,
;; evaluate control flow and function calls.
(set-render-active! true)
@@ -52,7 +52,7 @@
(define aser-list
(fn (expr env)
(fn ((expr :as list) (env :as dict))
(let ((head (first expr))
(args (rest expr)))
(if (not (= (type-of head) "symbol"))
@@ -104,7 +104,7 @@
(define aser-fragment
(fn (children env)
(fn ((children :as list) (env :as dict))
;; Serialize (<> child1 child2 ...) to sx source string
;; Must flatten list results (e.g. from map/filter) to avoid nested parens
(let ((parts (list)))
@@ -126,7 +126,7 @@
(define aser-call
(fn (name args env)
(fn ((name :as string) (args :as list) (env :as dict))
;; Serialize (name :key val child ...) — evaluate args but keep as sx
;; Uses for-each + mutable state (not reduce) so bootstrapper emits for-loops
;; that can contain nested for-each for list flattening.
@@ -177,11 +177,11 @@
"some" "every?" "for-each"))
(define special-form?
(fn (name)
(fn ((name :as string))
(contains? SPECIAL_FORM_NAMES name)))
(define ho-form?
(fn (name)
(fn ((name :as string))
(contains? HO_FORM_NAMES name)))
@@ -194,7 +194,7 @@
;; Definition forms evaluate for side effects and return nil.
(define aser-special
(fn (name expr env)
(fn ((name :as string) (expr :as list) (env :as dict))
(let ((args (rest expr)))
(cond
;; if — evaluate condition, aser chosen branch
@@ -314,7 +314,7 @@
;; Helper: case dispatch for aser mode
(define eval-case-aser
(fn (match-val clauses env)
(fn (match-val (clauses :as list) (env :as dict))
(if (< (len clauses) 2)
nil
(let ((test (first clauses))