js-on-sx: delete operator

js-transpile-unop intercepts 'delete' before transpiling the
operand. Maps to (js-delete-prop obj key) for members and indexed
access. Runtime js-delete-prop sets the dict value to js-undefined
and returns true.

444/446 unit (+2), 148/148 slice unchanged.
This commit is contained in:
2026-04-23 23:34:05 +00:00
parent 27bd25843e
commit 6293a0fe70
3 changed files with 44 additions and 10 deletions

View File

@@ -1141,6 +1141,12 @@ cat > "$TMPFILE" << 'EPOCHS'
(epoch 3201)
(eval "(js-eval \"var {aa: x2, bb: y2} = {aa:1, bb:2}; x2+y2\")")
;; ── Phase 11.delete ────────────────────────────────────────────
(epoch 3300)
(eval "(js-eval \"var o = {x: 5}; delete o.x; o.x === undefined\")")
(epoch 3301)
(eval "(js-eval \"var o = {a:1, b:2}; delete o.a; o.b\")")
EPOCHS
@@ -1760,6 +1766,10 @@ check 3101 "rest arr join" '"2,3,4"'
check 3200 "obj rename" '100'
check 3201 "obj multi rename" '3'
# ── Phase 11.delete ───────────────────────────────────────────
check 3300 "delete obj.x" 'true'
check 3301 "delete obj.a keeps b" '2'
TOTAL=$((PASS + FAIL))
if [ $FAIL -eq 0 ]; then
echo "$PASS/$TOTAL JS-on-SX tests passed"