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:
@@ -2339,6 +2339,9 @@ output.append(';; Locals are injected as a `let` wrapping the compiled body, the
|
||||
output.append(';; in a fresh CEK env. Avoids `apply` (whose JIT path can loop on some forms).')
|
||||
output.append('(define eval-hs-locals')
|
||||
output.append(' (fn (src bindings)')
|
||||
output.append(' ;; Also expose bindings on the `window` global so tests that reference')
|
||||
output.append(' ;; window.X (common in upstream tests) can resolve them.')
|
||||
output.append(' (for-each (fn (b) (host-set! (host-global "window") (str (first b)) (nth b 1))) bindings)')
|
||||
output.append(' (let ((sx (hs-to-sx (hs-compile src))))')
|
||||
output.append(' ;; Build (let ((name1 (quote val1)) ...) <wrap-body>)')
|
||||
output.append(' (let ((let-binds (map (fn (b) (list (first b) (list (quote quote) (nth b 1)))) bindings)))')
|
||||
|
||||
Reference in New Issue
Block a user