js-on-sx: numeric keys in object literals stringify on parse
{0: 41, 1: 42} was raising 'dict-set!: dict key val' because the parser
kept numeric keys as numbers in the entry dict, but SX dicts require string
keys. Now we str-coerce number-type tokens during jp-parse-object-entry.
Unblocks a huge chunk of test262 array-like-receiver tests that build
{length: N, 0: v, 1: v, ...} literals.
3 new tests, 453/455 total.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -552,7 +552,7 @@
|
||||
(do
|
||||
(jp-advance! st)
|
||||
(jp-expect! st "punct" ":")
|
||||
(append! kvs {:value (jp-parse-assignment st) :key (get t :value)})))
|
||||
(append! kvs {:value (jp-parse-assignment st) :key (str (get t :value))})))
|
||||
((= (get t :type) "keyword")
|
||||
(do
|
||||
(jp-advance! st)
|
||||
|
||||
@@ -1147,6 +1147,14 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 3301)
|
||||
(eval "(js-eval \"var o = {a:1, b:2}; delete o.a; o.b\")")
|
||||
|
||||
;; ── Phase 11.numkey: numeric object-literal keys ─────────────
|
||||
(epoch 3350)
|
||||
(eval "(js-eval \"var a = {0: 41, 1: 42, 2: 43}; a[0]\")")
|
||||
(epoch 3351)
|
||||
(eval "(js-eval \"var a = {length: 3, 0: 10, 1: 20, 2: 30}; a.length\")")
|
||||
(epoch 3352)
|
||||
(eval "(js-eval \"var a = {0: 'x'}; a['0']\")")
|
||||
|
||||
;; ── Phase 11.fnmethod: Function.prototype.call/apply/bind ─────
|
||||
(epoch 3400)
|
||||
(eval "(js-eval \"function greet3(n) { return 'hi ' + n; } greet3.call(null, 'ada')\")")
|
||||
@@ -1784,6 +1792,11 @@ check 3201 "obj multi rename" '3'
|
||||
check 3300 "delete obj.x" 'true'
|
||||
check 3301 "delete obj.a keeps b" '2'
|
||||
|
||||
# ── Phase 11.numkey: numeric object-literal keys ─────────────
|
||||
check 3350 "numeric key [0]" '41'
|
||||
check 3351 "numkey with length" '3'
|
||||
check 3352 "numeric key ['0']" '"x"'
|
||||
|
||||
# ── Phase 11.fnmethod: call/apply/bind ────────────────────────
|
||||
check 3400 "fn.call basic" '"hi ada"'
|
||||
check 3401 "fn.apply basic" '"hi bob"'
|
||||
|
||||
Reference in New Issue
Block a user