Re-applied from worktree-agent-a7c6dca2be5bbada0 (commit c4241d57)
onto HEAD that already has clusters 30, 26, 27 runtime changes —
straight cherry-pick conflicted on the cluster-30 log-all block
and cluster-27 intersection helper, so the logical diff was
replayed surgically.
Parser (parse-atom object-literal):
- obj-collect now `append`s pairs in source order instead of
`cons`'ing, so `{foo:1, bar:2, baz:3}` reaches hs-make-object
as `((foo 1) (bar 2) (baz 3))`.
Compiler (emit-for, array-index emission):
- emit-for detects `for x in COLL where COND` (parser wraps COLL
as `(coll-where INNER COND)`) and rewrites the filter lambda
to bind the for-loop variable name rather than the default
`it`, so `where x.val > 10` sees the right binding. Also
unwraps `coll-where` so filter targets the real inner coll.
- emit-for now wraps a symbol collection with `cek-try` (not the
broken `hs-safe-call`, which has an uninitialised CEK call-ref
in the WASM build) so `for prop in x` after `set x to {…}`
iterates x's keys instead of nil.
- array-index emits `(hs-index obj key)` instead of
`(nth obj key)`, which only worked on lists.
Runtime:
- New polymorphic `hs-index` dispatches to get / nth / host-get
based on target type (dict / list / string / otherwise).
- `hs-put-at!` default branch now detects DOM elements via
`hs-element?` and delegates to `hs-put!`, so `put X at end of
elt` on a DOM node appends innerHTML instead of crashing.
- `hs-make-object` tracks insertion order in a hidden `_order`
list; `hs-for-each` and `hs-coerce` (Keys / Entries / Map
branches) prefer `_order` when present, filtering the marker
out of output.
Suite hs-upstream-repeat: 25/30 → 28/30 (+3).
Smoke 0-195 unchanged at 165/195.
67 KiB
67 KiB