refactor(transformer): arrow function transform: remove unnecessary assertion (#6002)

This assertion was required previously for soundness, but now `SparseStack::pop` makes it impossible for `self.this_var_stack.len()` to be 0. Being exactly 1 is not a safety invariant, only that it's not 0.
This commit is contained in:
overlookmotel 2024-09-23 18:05:31 +00:00
parent 2b17003e0b
commit f02bf516cf

View file

@ -165,7 +165,6 @@ impl<'a> Traverse<'a> for ArrowFunctions<'a> {
/// Insert `var _this = this;` for the global scope.
fn exit_program(&mut self, program: &mut Program<'a>, _ctx: &mut TraverseCtx<'a>) {
assert!(self.this_var_stack.len() == 1);
if let Some(this_var) = self.this_var_stack.take() {
self.insert_this_var_statement_at_the_top_of_statements(&mut program.body, &this_var);
}