js-on-sx: parser handles comma operator (a, b, c)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 48s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 48s
Was failing with "Expected punct ')' got punct ','" because the paren handler only consumed a single assignment. Added jp-parse-comma-seq helpers that build a js-comma AST node with the expression list; transpiler emits (begin ...) so each is evaluated in order and the last value is returned. built-ins/Object: 44/50 → 46/50. 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-08 — **Comma operator `(a, b, c)` parses and evaluates left-to-right, returning last.** Was failing with `Expected punct ')' got punct ','` because `jp-try-arrow-or-paren` only consumed a single assignment expression. Added `jp-parse-comma-seq` / `jp-parse-comma-seq-rest` helpers that build a `js-comma` AST node with the list of expressions; the transpiler emits `(begin ...)` which evaluates each in order and returns the last. Fixes `Object((null,2,3),1,2)`-style tests. built-ins/Object: 44/50 → 46/50. conformance.sh: 148/148.
|
||||
|
||||
- 2026-05-08 — **ToPrimitive treats functions as non-primitive in `js-to-string` / `js-to-number`.** Per ES, ToPrimitive only accepts strings/numbers/booleans/null/undefined as primitives — objects AND functions must trigger the next conversion step. Was treating function returns from toString/valueOf as primitives (recursing to extract a string), so a `toString` returning a function wouldn't fall through to `valueOf`. Widened the dict-only check to `(or (= type "dict") (js-function? result))` in both ToPrimitive paths. Now `var o = {toString: () => function(){}, valueOf: () => { throw 'x' }}; new String(o)` propagates `'x'` from valueOf. built-ins/String: 85/99 → 86/99. conformance.sh: 148/148.
|
||||
|
||||
- 2026-05-08 — **`fn.toString()` and `String(fn)` honour `Function.prototype.toString` overrides.** Two hardcoded paths returned `"function () { [native code] }"` regardless of any user override: the function-method dispatch in `js-invoke-function-method`, and the lambda branch of `js-to-string`. Both now look up `Function.prototype.toString` via `js-dict-get-walk` and invoke it on the function (`recv`/`v`) when available, falling back to the native marker only if no override exists. Now `Function.prototype.toString = ...; (function(){}).toString()` returns the override, and `new String(fn)` stores the override result. built-ins/String: 84/99 → 85/99. conformance.sh: 148/148.
|
||||
|
||||
Reference in New Issue
Block a user