Commit Graph

37 Commits

Author SHA1 Message Date
24a67fae97 js-on-sx: arr.length = N extends the array
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 41s
js-list-set! was a no-op for the length key. Added a clause that
pads with js-undefined via js-pad-list! when target > current.
Truncation skipped: the pop-last! SX primitive doesn't actually
mutate the list (length unchanged after the call), so no clean
way to shrink in place from SX. Extension covers common cases.
built-ins/Array: 16/45 → 17/45. conformance.sh: 148/148.
2026-05-08 01:38:51 +00:00
b9dc69a3c1 js-on-sx: arrays inherit from Array.prototype on lookup miss
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 39s
js-get-prop for SX lists fell through to js-undefined for any key
not in its hardcoded method list, so Array.prototype.myprop and
Object.prototype.hasOwnProperty were invisible to arrays.
Switched the fallback to walk Array.prototype via js-dict-get-walk,
which already chains to Object.prototype.
built-ins/Array: 14/45 → 16/45. conformance.sh: 148/148.
2026-05-08 01:00:32 +00:00
c8f9b8be06 js-on-sx: arrays accept numeric-string property keys
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s
JS arrays must treat string indices that look like numbers ("0",
"42") as the corresponding integer slot. js-get-prop and js-list-set!
only handled numeric key, falling through to undefined / no-op for
string keys. Added a (and (string-typed key) (numeric? key)) clause
that converts via js-string-to-number and recurses with the integer
key. built-ins/Array: 13/45 → 14/45. conformance.sh: 148/148.
2026-05-08 00:28:36 +00:00
82100603f0 js-on-sx: scope var defines + js-args for call args
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s
JS top-level var was emitting (define <name> X) at SX top level,
permanently rebinding any SX primitive of that name (e.g. var list
= X broke (list ...) globally). Two-part fix:
1. wrap transpiled program in (let () ...) in js-eval so defines
   scope to the eval and don't leak.
2. rename call-args constructor in js-transpile-args from list to
   js-args (a variadic alias) so even within the eval's own scope,
   JS vars named list don't shadow arg construction.
Array-literal transpile keeps list (arrays must be mutable).
built-ins/Object: 41/50 → 42/50. conformance.sh: 148/148.
2026-05-07 23:55:07 +00:00
06a5b5b07c js-on-sx: Object.__callable__ returns this for new Object() no-args
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 43s
js-new-call Object had set obj.__proto__ correctly, but then the
__callable__ returned a fresh (dict), which js-new-call's "use
returned dict over obj" rule honoured — losing the proto. Added
is-new check (this.__proto__ === Object.prototype) and return
this instead of a new dict when invoked as a constructor with
no/null args. Now new Object().__proto__ === Object.prototype.
built-ins/Object: 37/50 → 41/50. conformance.sh: 148/148.
2026-05-07 22:55:35 +00:00
2490c901bf js-on-sx: js-loose-eq unwraps Number and Boolean wrappers
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 31s
js-loose-eq only had a __js_string_value__ unwrap clause, so
Object(1.1) == 1.1 returned false. Added parallel clauses for
__js_number_value__ and __js_boolean_value__ in both directions.
Now new Number(5) == 5, Object(true) == true, etc.
built-ins/Object: 26/50 → 37/50. conformance.sh: 148/148.
2026-05-07 22:25:01 +00:00
27bfceb1aa js-on-sx: Object(value) wraps primitives in their wrapper class
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s
Per ES spec, Object('s') instanceof String, Object(42).constructor
=== Number, etc. Was passing primitives through as-is. Added cond
clauses to Object.__callable__ that dispatch by type and call
(js-new-call String/Number/Boolean (list arg)). The wrapper
constructors already store __js_*_value__ on this.
built-ins/Object: 16/50 → 26/50. conformance.sh: 148/148.
2026-05-07 22:08:49 +00:00
96a7541d70 js-on-sx: Object(null) and Object(undefined) return new empty object
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
Per ES spec, Object(value) returns a new object when value is null
or undefined. Was returning the argument itself, breaking
Object(null).toString(). Added a cond clause to Object.__callable__
that detects nil/js-undefined and falls through to (dict).
built-ins/Object: 15/50 → 16/50. conformance.sh: 148/148.
2026-05-07 21:19:43 +00:00
42cce5e3fc js-on-sx: js-num-from-string uses string->number for exp-form
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
Was computing m * pow(10, e) for "1.2345e-3" forms; floating-point
multiplication introduced rounding (Number(".12345e-3") -
0.00012345 == 2.7e-20). The SX string->number primitive parses the
whole literal in one IEEE round, matching JS literal parsing. Falls
back to manual m * pow(10, e) only when string->number returns nil.
built-ins/Number: 42/50 → 43/50. conformance.sh: 148/148.
2026-05-07 20:47:29 +00:00
2d475f95d1 js-on-sx: constructors carry __proto__ = Function.prototype
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 42s
Object/Array/Number/String/Boolean had no __proto__, so
Function.prototype mutations were invisible to them. Added a
post-init (begin (dict-set! ...)) at the end of runtime.sx
that wires each constructor to js-function-global.prototype.
Combined with the recent Object.prototype fallback, the chain
now terminates correctly: ctor → Function.prototype → Object.prototype.
built-ins/Number: 41/50 → 42/50, built-ins/String: 75/99 → 78/99,
built-ins/Array: 12/45 → 13/45. conformance.sh: 148/148.
2026-05-07 20:14:15 +00:00
11612a511b js-on-sx: js-neg preserves IEEE-754 negative zero
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 45s
JS -0 was returning rational integer 0; the (- 0 x) form loses the
sign-of-zero. Switched js-neg to (* -1 (exact->inexact (js-to-number a))),
which produces a float and preserves -0.0. Now 1/(-0) === -Infinity
and Math.asinh(-0) preserves the sign as required by the spec.
built-ins/Math: 41/45 → 42/45. conformance.sh: 148/148.
2026-05-07 19:11:30 +00:00
5f97e78d5f js-on-sx: js-div coerces divisor to inexact
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 55s
(js-div 1 0) with rational integer literals throws "rational: division
by zero" instead of producing Infinity. Wrapped the divisor in
(exact->inexact ...) so integer-by-zero now returns inf/-inf/nan
matching JS semantics. Hit by the harness's _isSameValue +0/-0 check
which calls (js-div 1 a) on JS literal arguments.
built-ins/Number: 37/50 → 41/50. built-ins/String: 77/99.
conformance.sh: 148/148.
2026-05-07 18:35:29 +00:00
f4b0ebf353 js-on-sx: js-to-string throws TypeError on non-primitive toString/valueOf
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 52s
Per ECMA, String(obj) should throw TypeError when both
obj.toString() and obj.valueOf() return objects. Was returning
"[object Object]" instead, silently swallowing the spec violation.
Replaced the inner fallback with (raise (js-new-call TypeError ...)).
Preserves the outer "[object Object]" for the case where there's
no toString lambda. Fixes S8.12.8_A1.
built-ins/String: 75/99 → 77/99 (canonical, best run).
conformance.sh: 148/148.
2026-05-07 17:44:30 +00:00
95fb5ef8ef js-on-sx: TypeError-on-not-callable uses type-of, not (str fn-val)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 56s
Formatting wrapper dicts with (str fn-val) recursively walks the
proto chain through SX inspect — for String/Number wrappers whose
prototype contains lambdas this hangs. Switched the message to
(type-of fn-val), e.g. "dict is not a function". Less specific
but always terminates.
built-ins/String: 73/99 → 75/99 (canonical). conformance.sh:
148/148.
2026-05-07 16:54:06 +00:00
843c3a7e5e js-on-sx: raise JS TypeError for non-callable callee, undefined()
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 59s
Calling a non-callable raised an OCaml-level Eval_error "Not callable"
that JS try/catch couldn't intercept. Added a (js-function? callable)
precheck in js-apply-fn that raises a TypeError instance via
(js-new-call TypeError (list msg)) so e instanceof TypeError is
true. Same swap for the undefined() branch in js-call-plain (was
raising a bare string). built-ins/String: 71/99 → 73/99 (canonical),
74/99 → 75/99 (isolated). conformance.sh: 148/148.
2026-05-07 15:58:16 +00:00
cf0ba8a02a js-on-sx: js-dict-get-walk falls back to Object.prototype
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 54s
Object literals didn't carry a __proto__ link, so ({}).toString()
couldn't reach Object.prototype.toString. Added a cond clause: if
the object has no __proto__ AND is not Object.prototype itself,
walk into Object.prototype. Now ({}).toString() works, override
of Object.prototype.toString propagates, and ({a:1}).hasOwnProperty
('a') returns true. built-ins/String: 69/99 → 71/99 (canonical),
71/99 → 74/99 (isolated). conformance.sh: 148/148.
2026-05-07 15:08:55 +00:00
4e554113a9 js-on-sx: js-new-call accepts list-typed constructor returns
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m1s
new Array(1,2,3) was returning an empty wrapper object because
js-new-call only honoured a non-undefined return when
(type-of ret) === "dict"; SX lists (representing JS arrays) were
silently discarded. Widened the check to accept "list" too.
Fixes new Array(1,2,3).length, String(new Array(1,2,3)), and any
constructor whose body returns a list. built-ins/String:
67/99 → 69/99 (canonical). conformance.sh: 148/148.
2026-05-07 14:24:52 +00:00
c81e3f3705 js-on-sx: js-num-from-string uses pow (float) for exponent
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m4s
js-pow-int 10 20 overflows int64 (10^20 > 2^63), so numeric literals
like 1e20 and 100000000000000000000 were parsing as
-1457092405402533888. The pow primitive uses float-domain
exponentiation and produces 1e+20 correctly. Single call swap in
js-num-from-string. built-ins/String (with --restart-every 1):
67/99 → 70/99. conformance.sh: 148/148.
2026-05-07 13:42:32 +00:00
66f13c95d5 js-on-sx: js-to-string emits comma-joined elements for SX lists
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m3s
String([1,2,3]) was returning "(1 2 3)" (the SX (str v) fallback in
js-to-string fell through for SX lists). Replaced the fallback with
a list-typed branch that delegates to (js-list-join v ","). Fixes
String(arr), "" + arr, and any implicit array-to-string coercion.
built-ins/String: 65/99 → 67/99. conformance.sh: 148/148.
2026-05-07 12:45:06 +00:00
081f934cad js-on-sx: lexer handles \uXXXX and \xXX string escapes
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m3s
read-string fell through to the literal-char branch for \u and \x,
silently stripping the backslash ("A".length returned 5 instead
of 1). Added js-hex-value helper and two cond clauses that read the
hex digits via js-peek + js-hex-digit?, compute the code point, and
emit it via char-from-code. Invalid escapes fall through to the
literal-char behaviour. built-ins/String (with --restart-every 1):
65/99 → 68/99. conformance.sh: 148/148.
2026-05-07 12:02:30 +00:00
89f1c0ccbe js-on-sx: bump test262 runner per-test timeout 5s→15s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 59s
With 4 parallel workers contending, the 5s default timed out 85/99
built-ins/String tests. Bumping to 15s yields 65/99 (65.7%) with
real failure modes now visible instead of "85x Timeout".
2026-05-07 07:57:23 +00:00
97180b4aa3 js-on-sx: wrapper constructor-detection, Array.prototype.toString, >>> operator
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 11s
Number.__callable__ and String.__callable__ now check this.__proto__ ===
Number/String.prototype before writing wrapper slots, preventing false-positive
mutation when called as plain function. js-to-number extended to unwrap
wrapper dicts and call valueOf/toString for plain objects. Array.prototype.toString
replaced with a direct js-list-join implementation (eliminates infinite recursion
via js-invoke-method on dict-based arrays). >>> added to transpiler + runtime.

String test262 subset: 62→66/100. 529/530 unit, 147/148 slice.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 19:22:53 +00:00
5d7f931cf1 js-on-sx: high-precision number-to-string via round-trip + digit extraction
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
- js-big-int-str-loop: extract decimal digits from integer-valued float
- js-find-decimal-k: find min decimal places k where round(n*10^k)/10^k == n
- js-format-decimal-digits: insert decimal point into digit string at position (len-k)
- js-number-to-string: if 6-sig-fig round-trip fails AND n in [1e-6, 1e21),
  use digit extraction for full precision (up to 17 sig figs)
- String(1.0000001)="1.0000001", String(1/3)="0.3333333333333333"
- String test262 subset: 58→62/100

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 14:42:32 +00:00
4d00250233 js-on-sx: String wrapper objects + number-to-string sci notation expansion
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
- js-to-string: return __js_string_value__ for String wrapper dicts
- js-loose-eq: coerce String wrapper objects to primitive before compare
- String.__callable__: set __js_string_value__ + length on 'this' when called as constructor
- js-expand-sci-notation: new helper converts mantissa+exp to decimal or integer form
- js-number-to-string: expand 1e-06→0.000001, 1e+06→1000000; fix 1e+21 (was 1e21)
- String test262 subset: 45→58/100

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 14:27:13 +00:00
80c21cbabb js-on-sx: String fixes — fromCodePoint, multi-arg indexOf/split/lastIndexOf, matchAll, constructor, js-to-string dict
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
- String.fromCodePoint added (BMP + surrogate pairs)
- indexOf/lastIndexOf/split now accept optional second argument (fromIndex / limit)
- matchAll stub added to js-string-method and String.prototype
- String property else-branch now falls back to String.prototype (fixes 'a'.constructor === String)
- js-to-string for dict returns [object Object] instead of recursing into circular String.prototype.constructor structure
- js-list-take helper added for split limit

Scoreboard: String 42→43, timeouts 32→13, total 162→202/300 (54%→67.3%). 529/530 unit, 148/148 slice.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 13:41:58 +00:00
9db703324d scoreboard: 162/300 (54.0%) wide, +48 over session baseline 2026-04-24 13:27:55 +00:00
81059861fd js-on-sx: Function.prototype.isPrototypeOf recognises callable recvs (+3)
Tests expected Function.prototype.isPrototypeOf(Number/String/…) ===
true because every built-in ctor inherits from Function.prototype.
Our model doesn't link Number.__proto__ anywhere, so the default
Object.isPrototypeOf walked an empty chain and returned false.

Fix: post-definition dict-set! adds an explicit isPrototypeOf override
on js-function-global.prototype that returns (js-function? x) — which
accepts lambdas, functions, components, and __callable__ dicts. Good
enough to satisfy the spec for every case that isn't a bespoke proto
chain.

Unit 521/522, slice 148/148 unchanged.
Wide scoreboard: 156/300 → 159/300 (+3, Number/S15.7.3_A7 and the
three S15.5.3_A2 / S15.6.3_A2 / S15.9.3_A2 twins).
2026-04-24 13:07:33 +00:00
52fc87f222 scoreboard: 156/300 (52%) wide, +42 from session-start 114/300 2026-04-24 12:54:44 +00:00
83c9d60d72 scoreboard: 147/300 (49.0%) wide, up from 114/300 baseline
Math 40% / Number 73% / String 33% = 147/300 (49.0%), +33 tests since
session-3 start. Wall time 277s (vs prior 593s baseline → 2.14× via
harness cache).

Top remaining failure modes (141 fails, 12 timeouts):
- 115× Test262Error (assertion failed) — numeric precision at
  MAX_VALUE/MIN_VALUE boundary, (new Number()).constructor chain,
  toFixed edge cases, String.fromCharCode code-point ranges
- 34× TypeError: not a function — still the missing Math trig
  primitives (filed as Blocker)
- 12× Timeout — long-running String loops
2026-04-24 12:19:45 +00:00
4a277941b6 js-on-sx: harness cache — precompute HARNESS_STUB SX once per run
Root cause: every sx_server worker session used js-eval on the 3.6KB
HARNESS_STUB, paying ~15s for tokenize+parse+transpile even though every
session does the same thing. Over a full scoreboard with periodic worker
restarts that's minutes of wasted work.

Fix: transpile once per Python process. Spin up a throwaway sx_server,
run (inspect (js-transpile (js-parse (js-tokenize HARNESS_STUB)))), write
the resulting SX source to lib/js/.harness-cache/stub.<fingerprint>.sx and
a stable-name symlink-ish copy stub.sx. Every worker session then does a
single (load .harness-cache/stub.sx) instead of re-running js-eval.

Fingerprint: sha256(HARNESS_STUB + lexer.sx + parser.sx + transpile.sx).
Transpiler edits invalidate the cache automatically. Runs back-to-back
reuse the cache — only the first run after a transpiler change pays the
~15s precompute.

Transpile had to gain a $-to-_js_dollar_ name-mangler: the SX tokenizer
rejects $ in identifiers, which broke round-tripping via inspect. JS
$DONOTEVALUATE → SX _js_dollar_DONOTEVALUATE. Internal JS-on-SX names are
unaffected (none contain $).

Measured: 300-test wide (Math+Number+String @ 100/cat, --per-test-timeout 5):
593.7s → 288.0s, 2.06x speedup. Scoreboard 114→115/300 (38.3%, noise band).
Math 40%, Number 44%, String 30% — same shape as prior.

Baselines: 520/522 unit, 148/148 slice — unchanged.
2026-04-24 11:20:55 +00:00
99706a91d1 scoreboard: Math 40%, Number 48%, String 30% (100/cat, 118/300 total) 2026-04-24 09:28:58 +00:00
c22f553146 plan: update progress log with session 3 summary, Math 39.6% wide 36.4% 2026-04-24 09:08:15 +00:00
65d4c70638 js-on-sx: parallel test262 runner with raw-fd line buffer
Rework test262-runner.py to support --workers N parallel shards, each running
a long-lived sx_server session. Replace thread-per-readline with a select-based
raw-fd line buffer.

On 2-core machines, 1 worker still beats 2 (OCaml eval is CPU-bound and starves
when shared). Auto-defaults n_workers=1 on <=2 CPU, nproc-1 (up to 8) otherwise.

Throughput baseline: ~1.1 Math tests/s serial on 2-core (unchanged; the
evaluator dominates). The runner framework is now ready to scale on bigger
machines without further code changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 06:18:48 +00:00
c94b340943 js-on-sx: updated Math scoreboard — 66/288 (22.9%)
Up from 56/288 (19.4%) baseline. Progress from:
- Math.sqrt/pow/trunc/sign/cbrt/hypot
- Array.prototype stubs for verifyProperty
- typeof callable-dict → "function"
- __callable__ dispatch in js-apply-fn
2026-04-23 23:41:38 +00:00
8984520f05 js-on-sx: runner fix, 8-test smoke 3/7 (was 0/8)
Agent committed before monitor-exit. Full tree still TODO.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 20:08:46 +00:00
1613f551ef HS add/append: Set dedup, @attr support, when-clause result tracking
- runtime hs-add-to!/hs-append: dedupe on list targets (Set semantics)
- compiler emit-set: set result to X now syncs it too
- compiler append!: handle (local)/(ref) targets via emit-set so scoped
  vars get rebound to the returned list
- parser add/remove: accept bare @attr (not just [@attr])
- parser add-attr: support when-clause → emits add-attr-when
- compiler add-class-when/add-attr-when: collect matched items into
  the-result / it so subsequent "if the result is empty" works

+6 upstream tests in early range (add 13→17, append 10→12).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 19:55:27 +00:00
9e568ad886 js-on-sx: baseline commit (278/280 unit, 148/148 slice, runner stub)
Initial commit of the lib/js/ tree and plans/ directory. A previous
session left template-string work in progress — 278/280 unit tests pass
(2 failing: tpl part-count off-by-one, escaped-backtick ident lookup).
test262-runner.py and scoreboard are placeholders (0/8 with 7 timeouts);
fixing the runner is the next queue item.
2026-04-23 19:42:16 +00:00