js-on-sx: JSON.parse raises SyntaxError, rejects trailing content + control chars
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 43s

This commit is contained in:
2026-05-10 06:32:11 +00:00
parent 836b31a5b6
commit 769559bae7
2 changed files with 23 additions and 7 deletions

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-10 — **`JSON.parse` raises spec-correct `SyntaxError` instances and rejects malformed input.** Previously `JSON.parse("12 34")` silently returned `12` (no trailing-content check), `JSON.parse('""')` accepted control chars in strings, an unterminated string read off the end, and the inner `(error "JSON: ...")` calls produced generic Errors not `instanceof SyntaxError`. Added: (1) post-value whitespace skip + trailing-content check in `js-json-parse`; (2) control-char rejection (code < 0x20) and unterminated-string check in `js-json-parse-string-loop`; (3) all internal "JSON: ..." errors now `(raise (js-new-call SyntaxError ...))`. Result: built-ins/JSON/parse 7/30 → 25/30 (+18). JSON 26/30. conformance.sh: 148/148.
- 2026-05-10 — **`arguments` object inside functions is now a mutable list.** `js-arguments-build-form` produced `(cons p1 (cons p2 __extra_args__))` which yielded a structurally-shared (immutable) list — `arguments[1] = 7; arguments[1]++` raised "set-nth!: list is immutable". Wrapping the build in `js-list-copy` so each function entry constructs a fresh mutable list. Existing reads (`arguments.length`, `arguments[i]`) unaffected. Result: language/expressions/postfix-increment 14/30 → 15/30. conformance.sh: 148/148.
- 2026-05-10 — **`String.prototype.split(undefined)` returns `[wholeString]`; function-expression bodies have spec-correct implicit `undefined` return.** (1) `js-string-method "split"` was calling `js-to-string` on the separator unconditionally, so `"undefinedd".split(undefined)` produced `["", "d"]` (split by `"undefined"`); also `limit=0` returned the whole-string list instead of `[]`. New arms: `undefined` separator → `[s]`, `limit=0``[]`, otherwise existing string-split. (2) Function expressions wrapped the body in `(call/cc (fn (__return__) (begin <stmts>)))` and used the begin's last expression as the implicit return value. So `function F(){ this.x = function(){return 99} }` returned the inner lambda (because `js-set-prop` returns the rhs), and `new F()` saw a callable return and replaced the freshly-allocated `this` with it — so `i.x` was missing. Append `nil` to the begin so the implicit completion is always `:js-undefined`; explicit `return` still works via call/cc as before. Result: built-ins/String/prototype/split 8/30 → 10/30. Constructors with function-valued `this.X` now keep their assignments. conformance.sh: 148/148.