HS: string template \${x} (+2 tests)

`\$window.foo` / `\${window.foo}` couldn't resolve. Two fixes:
(a) compiler.sx: in a dot-chain base position, known globals (window,
    document, navigator, location, history, screen, localStorage,
    sessionStorage, console) emit `(host-global "name")` instead of a
    bare unbound symbol.
(b) generator: `eval-hs-locals` now also sets each binding on
    `window.<name>` via `host-set!`, so tests that translated
    `window.X = Y` as a local pair still see `window.X` at eval time.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-23 21:52:55 +00:00
parent babef2503f
commit 108e25d418
4 changed files with 10 additions and 2 deletions

View File

@@ -918,7 +918,8 @@
((= head (quote event)) (quote event))
((= head dot-sym)
(let
((target (hs-to-sx (nth ast 1))) (prop (nth ast 2)))
((target (let ((t (hs-to-sx (nth ast 1)))) (if (and (symbol? t) (or (= (str t) "window") (= (str t) "document") (= (str t) "navigator") (= (str t) "location") (= (str t) "history") (= (str t) "screen") (= (str t) "localStorage") (= (str t) "sessionStorage") (= (str t) "console"))) (list (quote host-global) (str t)) t)))
(prop (nth ast 2)))
(cond
((= prop "first") (list (quote hs-first) target))
((= prop "last") (list (quote hs-last) target))