js-on-sx: lexer treats } as ending regex context
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s
This commit is contained in:
@@ -467,7 +467,7 @@
|
||||
((ty (dict-get tk "type")) (vv (dict-get tk "value")))
|
||||
(cond
|
||||
((= ty "punct")
|
||||
(and (not (= vv ")")) (not (= vv "]"))))
|
||||
(and (not (= vv ")")) (not (= vv "]")) (not (= vv "}"))))
|
||||
((= ty "op") true)
|
||||
((= ty "keyword")
|
||||
(contains?
|
||||
|
||||
@@ -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 — **Lexer: `}` ends the regex context, like `)` and `]`.** Was treating `/` after `}` as the start of a regex literal, so `({}) / function(){return 1}` lexed `} / function(){...})` as `}` + regex `/ function(){return 1}/`. Per JS, after `}` of an object literal we're in expression-end position and `/` is division. The "block vs object" distinction is context-sensitive, but in practice expression-position `}` is the common case and there is no statement/block hazard for our parser since blocks at expression position don't typically have a following `/`. Single-char addition to the no-regex-context check. Result: language/expressions/division 25/30 → 26/30. asi/Map/Object unchanged. conformance.sh: 148/148.
|
||||
|
||||
- 2026-05-09 — **`js-to-number` of functions/lists returns NaN / sensible coercion (was 0).** `js-to-number` had no clauses for `lambda`/`function`/`component`/`list` types, so they fell into the `(else 0)` arm. Per spec: ToNumber of any function is NaN, and ToNumber of an Array goes through ToPrimitive which calls `Array.prototype.toString` (the comma-join), so `[]` → "" → 0, `[5]` → "5" → 5, and `[1,2]` → "1,2" → NaN. Added explicit lambda/function/component clauses (return NaN) and a list clause (length 0 → 0, length 1 → recurse, else NaN). Now `function(){return 1} - function(){return 1}` is NaN instead of 0. Result: language/expressions/subtraction 25/30 → 26/30; multiplication 90%, division 83% confirmed unchanged-or-better. Object/Array/Number unchanged. conformance.sh: 148/148.
|
||||
|
||||
- 2026-05-09 — **`+` operator now ToPrimitive's plain Objects + Dates via `valueOf`/`toString`.** Followup to the wrapper-unwrap fix. `js-add-unwrap` only handled `__js_string_value__` / `__js_number_value__` / `__js_boolean_value__` markers — for plain `{}` or `new Date()`, it returned the dict as-is, which then fell into `js-to-number` and produced `NaN`. Added two helpers: `js-add-toprim-default` calls `valueOf()` first (the "default" hint, used by `+`), and falls back to `toString()` if valueOf returns an object; for Date instances (`__js_is_date__` marker) we go straight to `toString` per spec. `js-add-call-method` walks the proto chain via `js-dict-get-walk`, calls the method with the receiver bound, and gives up if the slot is missing or not callable. Now `date + date === date.toString() + date.toString()`. Result: language/expressions/addition 23/30 → 24/30. Object/Array unchanged. conformance.sh: 148/148.
|
||||
|
||||
Reference in New Issue
Block a user