diff --git a/lib/js/runtime.sx b/lib/js/runtime.sx index 2a2e7de1..eaa64e08 100644 --- a/lib/js/runtime.sx +++ b/lib/js/runtime.sx @@ -474,9 +474,9 @@ (fn (n radix) (cond - ((and (number? n) (not (= n n))) "NaN") - ((= n (/ 1 0)) "Infinity") - ((= n (/ -1 0)) "-Infinity") + ((and (number? n) (js-number-is-nan n)) "NaN") + ((= n (js-infinity-value)) "Infinity") + ((= n (- 0 (js-infinity-value))) "-Infinity") ((or (= radix 10) (= radix nil) (js-undefined? radix)) (js-to-string n)) (else diff --git a/plans/js-on-sx.md b/plans/js-on-sx.md index 2d3cca7a..e941f61e 100644 --- a/plans/js-on-sx.md +++ b/plans/js-on-sx.md @@ -158,6 +158,8 @@ Each item: implement → tests → update progress. Mark `[x]` when tests green. Append-only record of completed iterations. Loop writes one line per iteration: date, what was done, test count delta. +- 2026-05-10 — **`Number.prototype.toString(radix)` no longer crashes on rational division-by-zero.** `js-num-to-str-radix` was probing for ±Infinity by comparing against `(/ 1 0)` / `(/ -1 0)` — but on the rational arithmetic path that throws "rational: division by zero" before the comparison ever happens, so every `Number(x).toString(radix)` call exploded. Replaced the probes with `(js-infinity-value)` / `(- 0 (js-infinity-value))` and the NaN check with `js-number-is-nan`. Result: built-ins/Number/prototype/toString 0/30 → 29/30 (+29). Number 26/30. conformance.sh: 148/148. + - 2026-05-10 — **Array literal elision (holes), `list instanceof Array`, `array.toString` identity.** Three coupled fixes for `language/expressions/array`. (1) Parser: `jp-array-loop` accepts a leading or interior `,` as elision and pushes `(js-undef)`, so `[,]`, `[,,3,,,]`, `[1,,3]` parse and produce length 1, 5, 3. (2) Runtime: `js-instanceof` adds a `(list? obj)` arm that returns true when the right-hand side is `Array` (or `Object`). (3) Runtime: `js-get-prop` for `key="toString"` on a list returns the actual `Array.prototype.toString` slot via `js-dict-get-walk` instead of a fresh `js-array-method` callable, so `[1,2,3].toString === Array.prototype.toString`. `toLocaleString` left on the legacy arm — its proto entry is a dict-with-`__callable__` whose body re-enters `js-invoke-method`, which would loop. Result: language/expressions/array 13/30 → 21/30 (+8). conformance.sh: 148/148. - 2026-05-10 — **`Object.getOwnPropertyDescriptor` skips internal `__proto__` and `__js_order__` keys.** Was returning a regular property descriptor for our internal `__proto__` and `__js_order__` markers — `Object.getOwnPropertyDescriptor({__proto__: null}, "__proto__")` returned `{configurable, enumerable, value: null, writable}` instead of `undefined` per spec. Added a `(js-key-internal? sk)` short-circuit in the descriptor path that returns `:js-undefined` for internal keys. Result: language/expressions/object 13/30 → 16/30. Object 30/30 holds, getOwnPropertyDescriptor 28/30. conformance.sh: 148/148.