Skip to main content

block_needs_scope

Function block_needs_scope 

Source
pub fn block_needs_scope(body: &[Stmt]) -> bool
Expand description

Does this statement list declare anything that needs a block scope of its own? let / const / class / a hoisted function bind into the block; var does not (it lands in the enclosing function’s base env). A block that binds nothing needs no scope at all, so { …; } inside a hot loop stops allocating and freeing an EnvData per pass.

Direct eval forces a scope: eval("let x = 1") declares into the running block, and with no block open that binding would escape to the function.