Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions crates/oxc_transformer/src/es2018/object_rest_spread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ impl<'a, 'ctx> ObjectRestSpread<'a, 'ctx> {
}
}

// Transform `try {} catch (...x) {}`.
// Transform `try {} catch ({...x}) {}`.
fn transform_catch_clause(clause: &mut CatchClause<'a>, ctx: &mut TraverseCtx<'a>) {
let Some(param) = &mut clause.param else { unreachable!() };
if Self::has_nested_object_rest(&param.pattern) {
Expand All @@ -589,12 +589,6 @@ impl<'a, 'ctx> ObjectRestSpread<'a, 'ctx> {
scope_id,
ctx,
);
// Add `SymbolFlags::CatchVariable`.
param.pattern.bound_names(&mut |ident| {
ctx.symbols_mut()
.get_flags_mut(ident.symbol_id())
.insert(SymbolFlags::CatchVariable);
});
}
}

Expand All @@ -617,7 +611,7 @@ impl<'a, 'ctx> ObjectRestSpread<'a, 'ctx> {
declarator.kind,
&mut declarator.id,
&mut block.body,
scope_id,
if decl.kind.is_var() { ctx.current_hoist_scope_id() } else { scope_id },
ctx,
);
// Move the bindings from the for init scope to scope of the loop body.
Expand Down Expand Up @@ -755,7 +749,13 @@ impl<'a, 'ctx> ObjectRestSpread<'a, 'ctx> {
scope_id: ScopeId,
ctx: &mut TraverseCtx<'a>,
) -> VariableDeclaration<'a> {
let bound_identifier = ctx.generate_uid("ref", scope_id, kind_to_symbol_flags(kind));
let mut flags = kind_to_symbol_flags(kind);
if matches!(ctx.parent(), Ancestor::TryStatementHandler(_)) {
// try {} catch (ref) {}
// ^^^
flags |= SymbolFlags::CatchVariable;
}
let bound_identifier = ctx.generate_uid("ref", scope_id, flags);
let kind = VariableDeclarationKind::Let;
let id = mem::replace(pat, bound_identifier.create_binding_pattern(ctx));
let init = bound_identifier.create_read_expression(ctx);
Expand Down
24 changes: 3 additions & 21 deletions tasks/coverage/snapshots/semantic_test262.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6733,45 +6733,27 @@ rebuilt : SymbolId(7): ScopeId(0)

tasks/coverage/test262/test/language/statements/for-of/dstr/var-obj-ptrn-rest-getter.js
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["_extends", "_objectDestructuringEmpty", "count", "iterCount", "x"]
after transform: ScopeId(0): ["_extends", "_objectDestructuringEmpty", "_ref", "count", "iterCount", "x"]
rebuilt : ScopeId(0): ["_extends", "_objectDestructuringEmpty", "_ref", "count", "iterCount"]
Bindings mismatch:
after transform: ScopeId(1): ["_ref"]
rebuilt : ScopeId(1): []
Bindings mismatch:
after transform: ScopeId(3): []
rebuilt : ScopeId(3): ["x"]
Symbol scope ID mismatch for "_ref":
after transform: SymbolId(3): ScopeId(1)
rebuilt : SymbolId(4): ScopeId(0)

tasks/coverage/test262/test/language/statements/for-of/dstr/var-obj-ptrn-rest-skip-non-enumerable.js
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["_extends", "_objectDestructuringEmpty", "iterCount", "o", "rest"]
after transform: ScopeId(0): ["_extends", "_objectDestructuringEmpty", "_ref", "iterCount", "o", "rest"]
rebuilt : ScopeId(0): ["_extends", "_objectDestructuringEmpty", "_ref", "iterCount", "o"]
Bindings mismatch:
after transform: ScopeId(1): ["_ref"]
rebuilt : ScopeId(1): []
Bindings mismatch:
after transform: ScopeId(2): []
rebuilt : ScopeId(2): ["rest"]
Symbol scope ID mismatch for "_ref":
after transform: SymbolId(3): ScopeId(1)
rebuilt : SymbolId(4): ScopeId(0)

tasks/coverage/test262/test/language/statements/for-of/dstr/var-obj-ptrn-rest-val-obj.js
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["_excluded", "_objectWithoutProperties", "a", "b", "iterCount", "rest"]
after transform: ScopeId(0): ["_excluded", "_objectWithoutProperties", "_ref", "a", "b", "iterCount", "rest"]
rebuilt : ScopeId(0): ["_excluded", "_objectWithoutProperties", "_ref", "iterCount"]
Bindings mismatch:
after transform: ScopeId(1): ["_ref"]
rebuilt : ScopeId(1): []
Bindings mismatch:
after transform: ScopeId(2): []
rebuilt : ScopeId(2): ["a", "b", "rest"]
Symbol scope ID mismatch for "_ref":
after transform: SymbolId(4): ScopeId(1)
rebuilt : SymbolId(3): ScopeId(0)

tasks/coverage/test262/test/language/statements/switch/scope-lex-async-function.js
semantic error: Symbol flags mismatch for "x":
Expand Down