js-on-sx: js-is-space? covers full ES WhiteSpace + LineTerminator set
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 49s

This commit is contained in:
2026-05-08 23:52:44 +00:00
parent 20997d3360
commit c45a2b34a0
2 changed files with 22 additions and 1 deletions

View File

@@ -1553,7 +1553,26 @@
(define
js-is-space?
(fn (c) (or (= c " ") (= c "\t") (= c "\n") (= c "\r"))))
(fn
(c)
(let
((cc (char-code c)))
(or
(= cc 9)
(= cc 10)
(= cc 11)
(= cc 12)
(= cc 13)
(= cc 32)
(= cc 160)
(= cc 5760)
(and (>= cc 8192) (<= cc 8202))
(= cc 8232)
(= cc 8233)
(= cc 8239)
(= cc 8287)
(= cc 12288)
(= cc 65279)))))
(define
js-parse-decimal

View File

@@ -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-08 — **`js-is-space?` recognises the full ES whitespace set** (was only ` \t\n\r`). `parseFloat(" 1.1")`, `parseFloat(" 1.1")`, etc. now strip leading whitespace correctly per spec. Added: form feed (12), vertical tab (11), NBSP (160), Ogham space mark (5760), the en/em-width run 81928202, line/paragraph separator (8232/8233), narrow no-break space (8239), medium math space (8287), ideographic space (12288), ZWNBSP/BOM (65279). Single helper used by every trim/whitespace path (`parseFloat`, `parseInt`, `String.prototype.trim*`, `js-string-to-number`, JSON parse-ws). Result: built-ins/parseFloat 15/30 → 17/30. String/Number/parseInt unchanged. conformance.sh: 148/148.
- 2026-05-08 — **NativeError prototype chain wired: `Object.getPrototypeOf(EvalError) === Error`, `Error.prototype.constructor === Error`, `[object Error]` brand.** Three pieces: (1) `js-object-tostring-class` now recognises `__js_error_data__` (returns `"[object Error]"`), `__js_is_date__` (`"[object Date]"`), `__map_keys__` / `__set_items__` (`"[object Map]"` / `"[object Set]"`) — these were all falling through to `"[object Object]"`. (2) New `__js_ctor_proto__` side-table maps lambda-ctor identity → its [[Prototype]] constructor; `js-object-get-prototype-of` consults it for non-dict callables. Populated for all six native error subclasses (TypeError/RangeError/SyntaxError/ReferenceError/URIError/EvalError) → Error. (3) Each subclass's `prototype.__proto__` set to `Error.prototype`, and `Error.prototype` gets `name`, `message`, `constructor` populated; each subclass prototype also gets its own `name` and `constructor`. Result: built-ins/NativeErrors 14/30 → 27/30 (+13), built-ins/Error 11/30 → 17/30 (+6). Object/Map/Array unchanged. conformance.sh: 148/148.
- 2026-05-08 — **Object literals get `__proto__: Object.prototype`; try/catch wraps SX error strings into JS Error instances.** Two fixes that work together: (1) `js-make-obj` now sets `__proto__` to `(get Object "prototype")` on every plain object literal `{}` — was missing, so `({}) instanceof Object` was `false`. (2) `js-transpile-try` now wraps the catch param via `js-wrap-exn` — when SX throws an `Eval_error("TypeError: ...")` / `("RangeError: ...")` / `("SyntaxError: ...")` etc. into the catch body, the user previously got a plain string. Now each prefix dispatches to the matching `js-new-call` so `e instanceof TypeError` etc. is truthy. Note: `Eval_error("Undefined symbol: y")` is NOT caught by SX `guard` at all, so the `1 + y → ReferenceError` shape remains unfixable from JS land — out of scope (would need OCaml-side change to make symbol lookup raisable). Result: language/expressions/instanceof 13/30 → 18/30 (+5). Object/Map/Array unchanged. conformance.sh: 148/148.