mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-25 11:11:11 +08:00
fix: 绑定侧解构计算键参与闭包捕获遍历防静默错值
This commit is contained in:
@@ -788,7 +788,9 @@ impl Emitter {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 遍历解构 pattern 收集内嵌默认值表达式(AssignmentPattern.right)。
|
||||
/// 遍历解构 pattern 收集内嵌默认值表达式(AssignmentPattern.right)与
|
||||
/// 计算键表达式(`{[k]: a}` 的键,运行时求值)——二者都会在参数绑定期被
|
||||
/// 内部闭包引用,须一并纳入捕获分析。
|
||||
fn collect_pattern_default_exprs<'a>(
|
||||
&self, pattern: &'a oxide_parser::BindingPattern<'a>, out: &mut Vec<&'a oxide_parser::Expression<'a>>,
|
||||
) {
|
||||
@@ -808,6 +810,9 @@ impl Emitter {
|
||||
}
|
||||
BindingPattern::ObjectPattern(op) => {
|
||||
for prop in &op.properties {
|
||||
if prop.computed {
|
||||
out.push(prop.key.to_expression());
|
||||
}
|
||||
self.collect_pattern_default_exprs(&prop.value, out);
|
||||
}
|
||||
if let Some(rest) = &op.rest {
|
||||
|
||||
Reference in New Issue
Block a user