js-on-sx: logical assignment &&= ||= ??=

js-compound-update gains logical-assign operators:
- &&= → (if (js-to-boolean lhs) rhs lhs)
- ||= → (if (js-to-boolean lhs) lhs rhs)
- ??= → (if nullish? rhs lhs)

427/429 unit (+4), 148/148 slice unchanged.
This commit is contained in:
2026-04-23 22:43:38 +00:00
parent 18ae63b0bd
commit d6975d3c79
2 changed files with 37 additions and 0 deletions

View File

@@ -506,6 +506,27 @@
((= op "/=") (list (js-sym "js-div") lhs-expr rhs-expr))
((= op "%=") (list (js-sym "js-mod") lhs-expr rhs-expr))
((= op "**=") (list (js-sym "js-pow") lhs-expr rhs-expr))
((= op "&&=")
(list
(js-sym "if")
(list (js-sym "js-to-boolean") lhs-expr)
rhs-expr
lhs-expr))
((= op "||=")
(list
(js-sym "if")
(list (js-sym "js-to-boolean") lhs-expr)
lhs-expr
rhs-expr))
((= op "??=")
(list
(js-sym "if")
(list
(js-sym "or")
(list (js-sym "=") lhs-expr nil)
(list (js-sym "js-undefined?") lhs-expr))
rhs-expr
lhs-expr))
(else (error (str "js-compound-update: unsupported op: " op))))))
(define