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

@@ -14,7 +14,7 @@
(define render-to-html
(fn (expr env)
(fn (expr (env :as dict))
(set-render-active! true)
(case (type-of expr)
;; Literals — render directly
@@ -34,7 +34,7 @@
:else (render-value-to-html (trampoline (eval-expr expr env)) env))))
(define render-value-to-html
(fn (val env)
(fn (val (env :as dict))
(case (type-of val)
"nil" ""
"string" (escape-html val)
@@ -55,7 +55,7 @@
"map" "map-indexed" "filter" "for-each"))
(define render-html-form?
(fn (name)
(fn ((name :as string))
(contains? RENDER_HTML_FORMS name)))
@@ -64,7 +64,7 @@
;; --------------------------------------------------------------------------
(define render-list-to-html
(fn (expr env)
(fn ((expr :as list) (env :as dict))
(if (empty? expr)
""
(let ((head (first expr)))
@@ -135,7 +135,7 @@
;; --------------------------------------------------------------------------
(define dispatch-html-form
(fn (name expr env)
(fn ((name :as string) (expr :as list) (env :as dict))
(cond
;; if
(= name "if")
@@ -235,7 +235,7 @@
;; --------------------------------------------------------------------------
(define render-lambda-html
(fn (f args env)
(fn ((f :as lambda) (args :as list) (env :as dict))
(let ((local (env-merge (lambda-closure f) env)))
(for-each-indexed
(fn (i p)
@@ -249,7 +249,7 @@
;; --------------------------------------------------------------------------
(define render-html-component
(fn (comp args env)
(fn ((comp :as component) (args :as list) (env :as dict))
;; Expand component and render body through HTML adapter.
;; Component body contains rendering forms (HTML tags) that only the
;; adapter understands, so expansion must happen here, not in eval-expr.
@@ -288,7 +288,7 @@
(define render-html-element
(fn (tag args env)
(fn ((tag :as string) (args :as list) (env :as dict))
(let ((parsed (parse-element-args args env))
(attrs (first parsed))
(children (nth parsed 1))
@@ -312,7 +312,7 @@
;; content while preserving surrounding reactive DOM.
(define render-html-lake
(fn (args env)
(fn ((args :as list) (env :as dict))
(let ((lake-id nil)
(lake-tag "div")
(children (list)))
@@ -351,7 +351,7 @@
;; the :transform is a client-only concern.
(define render-html-marsh
(fn (args env)
(fn ((args :as list) (env :as dict))
(let ((marsh-id nil)
(marsh-tag "div")
(children (list)))
@@ -394,7 +394,7 @@
;; (swap! s f) → no-op
(define render-html-island
(fn (island args env)
(fn ((island :as island) (args :as list) (env :as dict))
;; Parse kwargs and children (same pattern as render-html-component)
(let ((kwargs (dict))
(children (list)))
@@ -452,7 +452,7 @@
;; Handles all SX types natively: numbers, strings, booleans, nil, lists, dicts.
(define serialize-island-state
(fn (kwargs)
(fn ((kwargs :as dict))
(if (empty-dict? kwargs)
nil
(sx-serialize kwargs))))