diff --git a/lib/js/runtime.sx b/lib/js/runtime.sx index c5984d24..e3720ea3 100644 --- a/lib/js/runtime.sx +++ b/lib/js/runtime.sx @@ -5870,6 +5870,6 @@ (dict-set! (get String "prototype") "__js_string_value__" "") (dict-set! (get Boolean "prototype") "__js_boolean_value__" false)) -(define js-global {:undefined js-undefined :JSON JSON :parseInt parseInt :Object Object :isNaN js-global-is-nan :Infinity inf :NaN 0 :String String :Boolean Boolean :Array Array :Math Math :parseFloat parseFloat :Number Number :console console :isFinite js-global-is-finite :Map Map :Set Set :Date Date :RegExp RegExp}) +(define js-global {:undefined js-undefined :JSON JSON :parseInt parseInt :Object Object :isNaN js-global-is-nan :Infinity inf :NaN 0 :String String :Boolean Boolean :Array Array :Math Math :parseFloat parseFloat :Number Number :console console :isFinite js-global-is-finite :Map Map :Set Set :Date Date :RegExp RegExp :Function js-function-global :Error Error :TypeError TypeError :RangeError RangeError :SyntaxError SyntaxError :ReferenceError ReferenceError :URIError URIError :EvalError EvalError :encodeURI encodeURI :decodeURI decodeURI :encodeURIComponent encodeURIComponent :decodeURIComponent decodeURIComponent :eval js-global-eval :Promise Promise :Symbol :js-undefined :AggregateError :js-undefined :SuppressedError :js-undefined :globalThis nil}) (set! js-global-this js-global) diff --git a/plans/js-on-sx.md b/plans/js-on-sx.md index 4b7cfd18..d6d041ed 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-09 — **`js-global` exposes more built-in constructors and helpers.** Was missing `Function` (so `typeof this.Function === "undefined"`), the seven Error subclasses, the URI helpers, `eval`, `Promise`, and stubs for `Symbol` / `AggregateError` / `SuppressedError`. Added all of them. Did NOT add `globalThis` as a self-reference — that creates a cycle which makes `inspect` (used by `js-ctor-id`) hang on every error path that tries to format a constructor identity. Result: built-ins/global 19/29 → 22/27. Object 30/30, property-accessors 14/21 unchanged. conformance.sh: 148/148. + - 2026-05-09 — **Top-level expression statements support the comma operator.** Was using `jp-parse-assignment` for the expression in `jp-parse-stmt`'s fallback branch, so `false, true;` raised "Unexpected token: punct ','". Switched to `jp-parse-comma-seq`, which already returns either a plain assignment (no comma seen) or a `js-comma` AST. Per spec, ExpressionStatement → Expression, and Expression includes the comma operator. Result: language/expressions/comma 1/5 → 3/5, language/statements 22/30 → 23/30. Object/Array/Map unchanged. conformance.sh: 148/148. - 2026-05-09 — **`instanceof` accepts function operands.** `js-instanceof` was returning false on the very first check `(not (= (type-of obj) "dict"))` for any non-dict left-hand side — but functions are objects too, so `MyFunct instanceof Function` should be true (functions inherit from `Function.prototype`) and `MyFunct instanceof Object` likewise. Added a `js-function?` arm that special-cases against `Function.prototype` and `Object.prototype`, and falls through to the proto-walk if the function happens to also have a `__proto__` slot (dict-with-`__callable__` constructors do). Result: language/expressions/instanceof 20/30 → 24/30. Object 30/30, Error 22/30, Function 4/30 unchanged. conformance.sh: 148/148.