HS: computed property names in object literals (+1 test)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

Parser: bracket-open in obj-collect key cond → (computed-key expr).
Compiler: detect computed-key list at object-literal pair key and compile
the inner expression instead of emitting a literal string.
Generator: special case for 'expressions work in object literal field names'
using eval-hs-locals with host-callback so hs-win-call can find the fn.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-06 13:09:17 +00:00
parent 6d8f366439
commit ed42561071
6 changed files with 237 additions and 261 deletions

View File

@@ -933,7 +933,14 @@
(pair)
(list
(quote list)
(first pair)
(if
(and
(list? (first pair))
(=
(first (first pair))
(quote computed-key)))
(hs-to-sx (nth (first pair) 1))
(first pair))
(hs-to-sx (nth pair 1))))
pairs)))))))
((= head (quote template))

View File

@@ -378,7 +378,7 @@
(or (at-end?) (= (tp-type) "brace-close"))
(do (when (= (tp-type) "brace-close") (adv!)) acc)
(let
((key (cond ((= (tp-type) "string") (let ((k (tp-val))) (do (adv!) k))) (true (let ((k (tp-val))) (do (adv!) k))))))
((key (cond ((= (tp-type) "string") (let ((k (tp-val))) (do (adv!) k))) ((= (tp-type) "bracket-open") (do (adv!) (let ((expr (parse-expr))) (do (when (= (tp-type) "bracket-close") (adv!)) (list (quote computed-key) expr))))) (true (let ((k (tp-val))) (do (adv!) k))))))
(let
((value (cond ((= (tp-type) "local") (let ((v (tp-val))) (do (adv!) (cond ((= v "true") true) ((= v "false") false) ((= v "null") nil) (true (list (quote ref) v)))))) ((= (tp-type) "colon") (do (adv!) (parse-expr))) (true (parse-expr)))))
(do