Skip to content

fix(engine): keep hoisted bindings from capturing variables - #2342

Draft
maximebuyse wants to merge 1 commit into
fix-short-circuit-2336from
fix-hoisting-capture
Draft

maximebuyse wants to merge 1 commit into
fix-short-circuit-2336from
fix-hoisting-capture

Conversation

@maximebuyse

Copy link
Copy Markdown
Contributor

Stacked on #2338.

Fixes #1734.

  • Simplify_hoisting no longer inlines a hoisted expression under a rebinding of one of its variables. For instance, add(bump(a), set(b)) was extracted as add out out, and add(v, { v = 5; 1 }) read the new v.
  • Hoisted lets that would shadow another variable are renamed (x_1). Bindings get unique ids from Rust's name-based scoping before hoisting, captures are detected after hoisting, and the original ids are restored. Ids are rebuilt because the Rust engine round trip keeps only the names of local identifiers.
  • New evaluation_order and issue_1734 modules in the hoisting test crate.
  • The existing side-effects snapshot changes: add3(x, { x = x + 1; .. }, x) now passes the old x as first argument, as in Rust.

- Simplify_hoisting: do not inline a hoisted expression under a rebinding of its variables
- Hoist: rename hoisted `let`s that shadow another variable
- Add evaluation-order and #1734 tests

Fixes #1734
@maximebuyse
maximebuyse added this pull request to stack #2343 October 22, 2026 13:08

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant