Commit Graph

1889 Commits

Author SHA1 Message Date
a8a79dc902 spec: bitwise operations (bitwise-and/or/xor/not, arithmetic-shift, bit-count, integer-length)
OCaml: land/lor/lxor/lnot/lsl/asr in sx_primitives.ml
JS: & | ^ ~ << >> with Kernighan popcount and Math.clz32 for integer-length
spec/primitives.sx: stdlib.bitwise module with 7 entries
26 tests, 158 assertions, all pass OCaml+JS

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 19:06:09 +00:00
1ad9d63f1b plan: tick Phase 6 JS+Tests+Commit — ADT complete, Phase 7 next
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 18:56:22 +00:00
f63b214726 plan: tick Phase 6 OCaml task — ADT bootstrap implementation done
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 18:52:40 +00:00
5d1913e730 ocaml: ADT support via bootstrap FIXUPS — define-type + match
Hand-write sf_define_type in bootstrap.py FIXUPS (skipped from transpile
because the spec uses &rest params and empty-dict literals the transpiler
can't emit). Registers define-type via register_special_form. Adds
step_limit/step_count to PREAMBLE (referenced by sx_vm.ml/run_tests.ml).

172 assertions pass (test-adt). Full suite: 4280/1080 (was 4243/1117).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 18:52:16 +00:00
0dc7e1599c spec: match special form — ADT constructor pattern matching (20 tests)
Extends match-pattern in spec/evaluator.sx with an ADT case: when the
pattern is (CtorName var...) and the value is an ADT dict (:_adt true),
check :_ctor matches, arity matches, then recursively bind field patterns.
Supports nested patterns, wildcard _, variable binding, and zero-arg ctors.

Changes step-sf-match to route no-clause errors through raise-eval-frame
instead of direct error, allowing guard to catch non-exhaustive matches.

40/40 ADT tests pass (20 define-type + 20 match). Zero regressions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 18:16:16 +00:00
6c87210728 spec: define-type special form — constructors, predicates, accessors (20 tests)
Adds sf-define-type via register-special-form! in spec/evaluator.sx.
ADT values are dicts {:_adt true :_type "T" :_ctor "C" :_fields (list ...)}.
Each define-type call registers: ctor functions with arity checking, Name?
type predicate, Ctor? constructor predicates, Ctor-field positional accessors,
and populates *adt-registry* dict with type→[ctor-names] mapping.
20/20 JS tests pass in spec/tests/test-adt.sx.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 17:56:50 +00:00
3fb0212414 plan: Phase 6 ADT design doc — define-type/match syntax, CEK dispatch, exhaustiveness
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 17:17:14 +00:00
518ad37def plan: tick Phase 5 Tests+Commit tasks — string-buffer complete
17 tests written inline with the implementation step. All 17 pass
on OCaml and JS. Phase 5 fully done as d98b5fa2.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 17:09:30 +00:00
d98b5fa223 spec: string-buffer primitive — make-string-buffer/append!/->string/length
OCaml: StringBuffer of Buffer.t in sx_types.ml; 5 primitives in
sx_primitives.ml (make-string-buffer, string-buffer?, string-buffer-append!,
string-buffer->string, string-buffer-length); inspect case added.

JS: SxStringBuffer with array+join backend; _string_buffer marker for
typeOf dispatch and dict? exclusion (also excludes _vector from dict?).

spec/primitives.sx: 5 define-primitive entries.
17/17 tests pass on both OCaml and JS.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 17:05:05 +00:00
cc0af51921 plan: tick Phase 4 commit task — coroutine primitive complete
All Phase 4 work landed across 4 commits (21cb9cf5, 9eb12c66, b78e06a7,
0ffe208e). Phase 5 (string buffer) is next.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 16:54:22 +00:00
0ffe208e31 spec: coroutine tests — expand to 27 (was 17)
10 new tests: state field transitions (ready/suspended/dead), yield from
nested helper function, initial resume arg ignored by ready coroutine,
mutable closure state via dict-set!, complex yield values (list/dict),
round-robin scheduling, factory creates independent coroutines, resuming
non-coroutine raises error.

27/27 pass on both OCaml and JS.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 16:49:22 +00:00
b78e06a772 js: coroutine JS step — pre-load spec/coroutines.sx in run_tests.js
All CEK primitives (cek-step-loop/cek-resume/make-cek-state/cek-suspended?/
cek-io-request/cek-terminal?/cek-value) were already registered in sx-browser.js.

Root cause of test failure: (import (sx coroutines)) creates an io-suspended
state when the library isn't pre-loaded; overridden cekRun throws on suspension.
Fix: pre-load spec/signals.sx + spec/coroutines.sx before test files run.

17/17 coroutine tests pass in JS. 1965/2500 total (+25 vs 1940 baseline),
zero new failures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 16:43:02 +00:00
9eb12c66fd ocaml: coroutine OCaml step — verified via existing CEK suspension primitives
No native SxCoroutine type needed. dict-based coroutine identity +
cek-step-loop/cek-resume/perform/make-cek-state primitives already in
run_tests.ml fully implement the coroutine contract. 284/284 pass
(coroutines+vectors+numeric-tower+dynamic-wind), zero regressions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 16:32:59 +00:00
21cb9cf51a spec: coroutine primitive — make-coroutine/resume/yield via perform/cek-step-loop
spec/coroutines.sx: define-library with make-coroutine, coroutine-resume,
coroutine-yield, coroutine?, coroutine-alive?. Built on existing perform/
cek-step-loop/cek-resume suspension machinery.

spec/tests/test-coroutines.sx: 17 tests — multi-yield, final return,
arg passthrough, alive? predicate, nested coroutines, recursive iteration,
independent coroutine interleaving.

Key: coroutine body must use (define loop (fn…)) not named let — named let
transpiles to cek_call→cek_run which rejects IO suspension. All 17/17 pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 16:15:48 +00:00
d84cf1882a plan: tick Phase 3 complete — dynamic-wind OCaml+JS done
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 15:18:07 +00:00
6602ec8cc9 ocaml: wire dynamic-wind through CEK — WindFrame + winders stack
- sx_types.ml: CallccContinuation gains winders depth int field
- sx_runtime.ml: make_callcc_continuation(captured, winders_len),
  callcc_continuation_winders_len accessor; get_val maps after-thunk,
  winders-len, body-result to cf_f/cf_extra/cf_name
- sx_ref.ml: step_limit/step_count restored; make_wind_after_frame and
  make_wind_return_frame now store their args in the CekFrame fields
- transpiler.sx: after-thunk→cf_f, winders-len→cf_extra,
  body-result→cf_name for future bootstrap runs
- 8 new dynamic-wind tests pass (OCaml), 235/235 no regressions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 15:16:56 +00:00
b126d4da76 plan: tick Phase 3 Spec+Tests, update progress log
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 14:19:52 +00:00
a9d5a1082f spec: dynamic-wind — after-thunk fires on normal return, raise, and call/cc escape
- Add make-wind-after-frame / make-wind-return-frame CEK frame types
- Add *winders* global stack tracking active after-thunks
- Add kont-unwind-to-handler (replaces kont-find-handler in raise-eval) — calls
  after-thunks for wind frames encountered while unwinding to handler
- Add wind-escape-to — pops and calls after-thunks down to captured winders-len
- Replace sf-dynamic-wind with step-sf-dynamic-wind (full CEK dispatch)
- Fix "callcc" frame: store winders-len in continuation object
- Fix callcc-continuation? case: call wind-escape-to before escape
- JS platform: extend SxCallccContinuation to store windersLen; add
  callcc-continuation-winders-len accessor
- 8 tests: normal return, raise escape, call/cc escape, nested LIFO, guard ordering
- 1948/2500 (was 1940); zero regressions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 14:19:17 +00:00
0577f245e2 plan: tick Phase 2 Verify+Commit, mark phase complete
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 12:53:40 +00:00
f5acb31c94 plan: tick Phase 2 JS bootstrapper checkbox, update progress log
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 12:46:32 +00:00
b12a22e68a js: numeric tower — integer?/float?/exact?/inexact? + epoch Integer fix
Add integer?/float?/exact?/inexact? predicates (Number.isInteger check).
Add truncate/remainder/modulo/random-int/exact->inexact/inexact->exact/parse-number.
inexact->exact uses Math.round (rounds to nearest, matching OCaml).
Fix sx_server.ml epoch/blob/io-response protocol to accept Integer as
well as Number — parser now produces Integer for whole-number literals.
JS: 60 new passing tests (1880→1940). OCaml: 4874/394 baseline unchanged.
Note: 6 tests fail in JS due to platform limitation (JS cannot distinguish
float 2.0 from integer 2).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 12:46:17 +00:00
7888fbfd81 plan: tick Phase 2 Spec checkbox, update progress log
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 12:31:13 +00:00
45ec553519 spec: numeric tower primitives — integer?/float? predicates, contagion docs
Add integer? and float? to spec/primitives.sx predicates section.
Update number? doc and body (or-guard for integer? type).
Update / :returns to "float" (always inexact).
Update floor/ceil/truncate :returns to "integer", improve docs.
Update round doc (returns integer at ndigits=0).
Update exact?/inexact?/exact->inexact/inexact->exact docs and returns.
Update +/-/* docs to document float contagion rule.
Fix double-paren :params on truncate/exact?/inexact?/exact->inexact/inexact->exact.
4874 passed, 394 failed (baseline unchanged).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 12:31:01 +00:00
e3e767e434 plan: tick Phase 2 OCaml + Tests checkboxes, update progress log
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 12:11:39 +00:00
c70bbdeb36 ocaml: numeric tower — Integer/Number distinction + float contagion
Add `Integer of int` to sx_types.ml alongside `Number of float`. Parser
produces Integer for whole-number literals. Arithmetic primitives apply
float contagion (int op int → Integer, int op float → Number). Division
always returns Number. Rounding (floor/truncate/round) returns Integer.
Predicates: integer?, float?, exact?, inexact?, exact->inexact,
inexact->exact. run_tests.ml updated for json_of_value, value_of_json,
identical?, random-int mock, DOM accessors, and parser pattern matches.
New spec/tests/test-numeric-tower.sx — 92 tests, all pass (394 unchanged).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 12:10:50 +00:00
8f0fc4ce52 primitives-loop: tick Phase 1 JS + Tests + Verify + Commit steps [x]
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 10:02:49 +00:00
1d85e3a79c js: fix lambda binding (index-of on lists), add vectors + R7RS platform stubs
- Fix PRIMITIVES["index-of"] for arrays: return NIL when not found (matching
  OCaml semantics) so bind-lambda-params correctly detects absent &rest params.
  Previously String(array).indexOf() returned -1, which passed number? check
  and mis-fired the &rest branch, leaving non-&rest params unbound.
- Declare var _lastErrorKont_ and var hostError in IIFE scope (strict mode fix)
- Add PRIMITIVES["host-error"], ["try-catch"], ["without-io-hook"]
- Add env["test-allowed?"] stub in run_tests.js
- Add spec/tests/test-vectors.sx: 42 tests for all vector primitives
- Rebuild sx-browser.js: 1847 standard / 2362 full tests pass (up from 5)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 10:02:23 +00:00
5a332fa430 spec: vector primitive — complete type signatures in spec/primitives.sx
All 10 vector primitives now have :as type annotations on every parameter,
:returns types, and :doc strings. make-vector gains optional fill annotation;
vector uses :rest for its variadic args; vector-ref/set! document bounds error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 19:33:39 +00:00
d1a00562a4 spec: vector primitives — bounds-checked ref/set!, vector-copy start/end slice
vector-ref and vector-set! now raise Eval_error on out-of-bounds index instead of
an OCaml array exception. vector-copy accepts optional start and end parameters for
slicing (R7RS §6.8). spec/primitives.sx doc updated to reflect slice params.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 19:27:54 +00:00
3759575b29 primitives-loop: Phase 0 done — stop language loops, verify E38/E39
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 19:02:12 +00:00
f247cb2898 js: let/const TDZ infrastructure — sentinel + kind threading in transpiler
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 11s
Threads declaration kind ("var"/"let"/"const") through js-transpile-var →
js-vardecl-forms so the transpiler knows which kind is being declared.
Infrastructure for full TDZ enforcement: js-tdz-check can wrap let/const
reads to raise TypeError before initialization.

Updates plans/js-on-sx.md: ticks [x] for TDZ, marks regex blocker RESOLVED,
adds progress log entry for 2026-04-25.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 18:35:32 +00:00
f8023cf74e js: regex engine (lib/js/regex.sx) — pure-SX recursive backtracker
Adds a full regex engine written in SX, installed via js-regex-platform-override!.
Supports char classes (.  \d\D\w\W\s\S  [abc]  [^abc]  ranges), anchors (^ $ \b \B),
quantifiers (* + ? {n,m} greedy and lazy), capturing/non-capturing groups,
alternation (a|b), flags i/g/m.  exec() returns {:match :index :input :groups}.

Also fixes String.prototype.match to dispatch through the platform engine
(was calling js-regex-stub-exec directly, bypassing regex.sx).
Adds TDZ sentinel infrastructure: __js_tdz_sentinel__, js-tdz?, js-tdz-check.
Updates test.sh (+34 regex tests + 4 TDZ infra tests), conformance.sh,
and test262-runner.py to load regex.sx as epoch 6.

Tests: 559/560 unit (1 pre-existing failure), 148/148 conformance.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 18:35:23 +00:00
3316d402fd HS: null-safety piece 1 — eval-hs-error recognizer + helper (+18 tests unlocked)
Add recognizer for expect(await error("HS")).toBe("MSG") pattern in
generate-sx-tests.py, plus eval-hs-error SX helper in the generated
test file. All 18 runtimeErrors tests now generate real test cases
instead of SKIP stubs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 12:10:19 +00:00
fb72c4ab9c sx-loops: add common-lisp, apl, ruby, tcl (12 slots)
Plans + briefings for four new language loops, each with a delcc/JIT
showcase that the runtime already supports natively:

- common-lisp — conditions + restarts on delimited continuations
- apl — rank-polymorphic primitives + 6 operators on the JIT
- ruby — fibers as delcc, blocks/yield as escape continuations
- tcl — uplevel/upvar via first-class env chain, the Dodekalogue

Launcher scripts now spawn 12 windows (was 8).
2026-04-25 09:25:30 +00:00
e52c209c3d hs: drain plan for blockers + Bucket E + F
Tracks the path from 1277/1496 (85.4%) to 100%. Records each blocker's
fix sketch, files in scope, and order of attack. Cluster #31 spec'd in
detail for the next focused sit-down.
2026-04-25 08:54:00 +00:00
6a00df2609 smalltalk: plan + briefing + sx-loops 8th slot
Showcase: blocks with non-local return on captured method-return
continuation. ANSI-ish Smalltalk-80 subset, SUnit + Pharo Kernel-Tests
slice, 7 phases. Worktree: /root/rose-ash-loops/smalltalk on
branch loops/smalltalk.
2026-04-25 00:05:31 +00:00
30d76537d1 sx-loops: each language runs in its own git worktree
Previous version ran all 7 claude sessions in the main working tree on
branch 'architecture'. That would race on git operations and cross-
contaminate commits between languages even though their file scopes
don't overlap. Now each session runs in /root/rose-ash-loops/<lang> on
branch loops/<lang>, created from the current architecture HEAD.

sx-loops-down.sh gains --clean to remove the worktrees; loops/<lang>
branches stay unless explicitly deleted.

Also: second Enter keystroke after the /loop command, since Claude's
input box sometimes interprets the first newline as a soft break.
2026-04-24 16:50:27 +00:00
d7070ee901 Local sx-loops tmux launcher: 7 claude sessions, one per language
sx-loops-up.sh spawns a tmux session 'sx-loops' with 7 windows (lua,
prolog, forth, erlang, haskell, js, hs). Each window runs 'claude'
and then /loop against its briefing at plans/agent-briefings/<x>-loop.md.
Optional arg is the interval (e.g. 15m); omit for model-self-paced.

Each loop does ONE iteration per fire: pick the first unchecked [ ] item,
implement, test, commit, tick, log — then stop. Commits push to
origin/loops/<lang> (safe; not main).

sx-loops-down.sh sends /exit to each window and kills the session.

Attach with: tmux a -t sx-loops
2026-04-24 16:43:40 +00:00
e67852ca96 Scheduled-loop infra: lockfile guard + release + fire log
- scripts/loop-guard.sh — atomic claim with 30-min staleness overtake,
  appends NDJSON event to .loop-logs/<lang>.ndjson. Exit 0 = go ahead,
  exit 1 = another run is live, skip.
- scripts/loop-release.sh — clear lock, log release with exit status.

Intended for 7 per-language /schedule routines firing every 15 minutes.
Lock detects overlap so tight cadences are safe; stale lock (>30 min)
overtaken automatically if an agent dies mid-run.
2026-04-24 16:39:17 +00:00
99753580b4 Recover agent-loop progress: lua/prolog/forth/erlang/haskell phases 1-2
Salvaged from worktree-agent-* branches killed during sx-tree MCP outage:
- lua: tokenizer + parser + phase-2 transpile (~157 tests)
- prolog: tokenizer + parser + unification (72 tests, plan update lost to WIP)
- forth: phase-1 reader/interpreter + phase-2 colon/VARIABLE (134 tests)
- erlang: tokenizer + parser (114 tests)
- haskell: tokenizer + parse tests (43 tests)

Cherry-picked file contents only, not branch history, to avoid pulling in
unrelated ocaml-vm merge commits that were in those branches' bases.
2026-04-24 16:03:00 +00:00
e274878052 HS-plan: log cluster 29 blocked
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 15:50:22 +00:00
a3d1c37c95 HS-plan: scoreboard — cluster 29 blocked, C=4 done + 1 blocked
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 15:47:25 +00:00
2b486976a6 HS-plan: mark cluster 29 blocked
sx-tree MCP file ops broken this session (Yojson Type_error "Expected
string, got null" on every file-based call — sx_read_subtree,
sx_find_all, sx_replace_by_pattern, sx_summarise, sx_pretty_print, even
sx_load_check on existing files works but summarise fails). Can't edit
integration.sx to add before:init/after:init dispatch. Additionally 4
of the 6 tests fundamentally require stricter parser error-rejection
(add - to currently parses to (set! nil ...); on click blargh end
accepts blargh as symbol expression) — out of single-cluster budget.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 15:46:55 +00:00
6e92a5ad66 HS-plan: claim cluster 29 hyperscript:before:init events
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 15:31:52 +00:00
2cd8e57694 HS-plan: log cluster 19 (pick regex + indices) done +13
Cluster 19 was implemented in 4be90bf2 but the plan/scoreboard rows
still marked it pending. Sync the plan state: mark done, add log entry,
bump merged total 1264 → 1277.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 15:31:11 +00:00
0f67021aa3 plans: briefings + roadmaps for lua, prolog, forth, erlang, haskell
Five new guest-language plans mirroring the js-on-sx / hs-loop pattern, each
with a phased roadmap (Progress log + Blockers), a self-contained agent
briefing for respawning a long-lived loop, and a shared restore-all.sh that
snapshots state across all seven language loops.

Briefings bake in the lessons from today's stall debugging: never call
sx_build (600s watchdog), only touch lib/<lang>/** + own plan file, commit
every feature, update Progress log on each commit, route shared-file
issues to Blockers rather than fixing them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 15:16:45 +00:00
81022784bc sx primitives: add regex-* (Re + Re.Pcre backed)
Adds regex-compile/test/exec/match-all/replace/replace-fn/split/source/flags.
Opaque dict handle {:__regex__ true :id :source :flags}; compiled Re.re
cached in a primitives-local table. Replacement supports $&, $1-$9, $$.
Flags: i (CASELESS), m (MULTILINE), s (DOTALL). g is a runtime flag handled
in replace. u (unicode) skipped for now.

Unblocks js-on-sx's regex-platform-override! hook — the JS RegExp shim can
now delegate to real regex instead of the substring stub.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 15:12:13 +00:00
4be90bf21f HS: pick regex + indices (+13 tests)
Implements cluster 19 — pick command extensions for hs-upstream-pick suite
(11/24 → 24/24, +13):

- Parser:
  - pick items/item EXPR to EXPR supports `start` and `end` keywords
  - pick match / pick matches accept `| <flag>` syntax after regex
  - pick item N without `to` still works (single-item slice)
- Runtime:
  - hs-pick-items / hs-pick-first / hs-pick-last now handle strings
    (not just lists) via slice
  - hs-pick-items resolves `start`/`end` sentinel strings and negative
    indices (len + N) at runtime
  - hs-pick-matches added (wraps regex-find-all, each match as a list)
  - hs-pick-regex-pattern handles (list pat flags) form; `i` flag
    transforms pattern to case-insensitive by replacing alpha chars with
    [aA] character classes (Re.Pcre has no inline-flag support)
- Generator:
  - extract_hs_expr now decodes JS string escape sequences (\" -> ",
    \\ -> \) instead of stripping all backslashes, then re-escapes for
    SX. Preserves regex escapes (\d, \s), CSS escapes, and lambda `\`
    syntax for String.raw template literals while still producing
    correct output for regular JS strings.

Smoke (0-195): 170/195 unchanged (no regressions).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 15:10:34 +00:00
b45a69b7a4 sx: format_number helper — defuse int_of_float overflow on huge floats
Shared formatter in sx_types.ml. Small integer-valued floats still print
as plain ints; floats outside safe-int range (|n| >= 1e16) now print as
%.17g (full precision) instead of silently wrapping to negative or 0.
Non-integer values keep %g 6-digit behavior — no existing SX tests regress.

Unblocks Number.MAX_VALUE / Math.pow(2,N) style tests in js-on-sx where
iterative float loops were collapsing to 0 at ~2^63.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 15:09:11 +00:00
8f202e03c2 js-on-sx: .constructor backlink on Number/String/Array/Object protos (+1)
Number.prototype.constructor === Number etc. Four dict-set! lines add
the backlink after each constructor dict is defined.

new String().constructor === String now returns true. Array literals
don't yet link to Array.prototype so [].constructor === Array is still
false — that would need a boxing refactor.

Unit 521/522, slice 148/148 unchanged.
Number 76/100 → 77/100 (+1). String variance-heavy under CPU load.
2026-04-24 14:18:18 +00:00