You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(hir): #5579 — publish module-top global eval's top-level var/function as configurable global bindings
EvalDeclarationInstantiation: a sloppy *global* (direct or indirect) eval whose
body declares a top-level `var` or `function` must create a configurable own
binding on the global object (CreateGlobalVarBinding / CreateGlobalFunctionBinding)
that survives after the eval returns. Perry folds an eval body into a
scope-capturing arrow IIFE, which trapped top-level `var`/`function` as
arrow-locals, so `eval('var x; …')` / `eval('function f(){}')` never published
`x`/`f` to globalThis (test262 reason: "x/f should be an own property"). #5636
already handled *nested* block functions; this extends the same hoist to the eval
body's own top level.
- global_eval_hoist: a top-level `function` is renamed to a hidden binding and
published with its value at instantiation via `void (f = <hidden>)` (the `void`
keeps the declaration's empty completion value); a top-level `var x = init`
becomes a create-if-absent global slot plus `void (x = init)`. A non-simple
(destructuring) declarator bails the rewrite.
- const_fold_fn: a declaration-bearing *indirect* eval body at module-top global
with nothing to hoist now still folds to the completion IIFE (running its side
effects + yielding the completion value) instead of deferring to the runtime
eval thunk, which returns `undefined` without executing the body. Guarded by
`eval_body_iife_foldable`, which keeps a class-declaring body on the runtime
thunk (Perry would otherwise leak the class to module scope —
language/eval-code/indirect/lex-env-distinct-cls).
test262 language/eval-code + annexB/language/eval-code: 753 → 764 passing
(parity 93.2% → 94.6%), zero regressions. Fixes var-env-{var,func}-init-global-new
(direct+indirect), var-env-func-init-multi (direct+indirect),
var-env-func-init-global-update-non-configurable, and the
non-definable-function-with-{function,variable} negatives.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments