js-on-sx: constructors carry __proto__ = Function.prototype
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 42s
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.
This commit is contained in:
@@ -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-07 — **Constructors (`Object`/`Array`/`Number`/`String`/`Boolean`) carry `__proto__ = Function.prototype`.** Per spec, the constructors are functions and inherit from `Function.prototype`, so `Function.prototype.foo = 1; Array.foo === 1`. Previously the constructor dicts had no `__proto__`, so they only saw `Object.prototype` via the recent fallback — `Function.prototype` mutations were invisible. Added a `(begin (dict-set! ...))` post-init at the end of `runtime.sx` after the constructors are defined. Combined with the existing Object.prototype fallback, the proto chain now terminates correctly for the constructor → `Function.prototype` → `Object.prototype` walk. 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 — **`js-neg` preserves IEEE-754 negative zero.** `-0` was returning `0` (rational integer) because `js-neg` did `(- 0 (js-to-number a))`, which loses sign-of-zero in any arithmetic implementation that follows IEEE 754. Per JS spec, `-0` and `1/-0 === -Infinity` must be observable. Switched to `(* -1 (exact->inexact (js-to-number a)))` so the result is always a float and `-0.0` is preserved. Fixes `Math.asinh(-0)` and other `-0`-sensitive tests; `1/(-0) === -Infinity` now works. built-ins/Math: 41/45 → 42/45. conformance.sh: 148/148.
|
||||
|
||||
- 2026-05-07 — **`js-div` coerces divisor to inexact before dividing.** When both operands are SX rationals (e.g. `(js-div 1 0)` from JS-transpiled `1/0` reaching the harness's `_isSameValue` +0/-0 check), SX integer-rational division throws "rational: division by zero" instead of producing JS `Infinity`. Wrapped the divisor in `(exact->inexact ...)` so it's always a float; integer-by-zero now returns `inf` (positive numerator), `-inf` (negative), `nan` (zero numerator), matching JS semantics. Was hitting harness assertion failures even when the test value matched expected. built-ins/Number: 37/50 → 41/50. built-ins/String: 77/99. conformance.sh: 148/148.
|
||||
|
||||
Reference in New Issue
Block a user