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
5 changes: 5 additions & 0 deletions crates/oxc_semantic/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ impl SymbolTable {
self.flags[symbol_id]
}

#[inline]
pub fn get_flags_mut(&mut self, symbol_id: SymbolId) -> &mut SymbolFlags {
&mut self.flags[symbol_id]
}

#[inline]
pub fn get_redeclarations(&self, symbol_id: SymbolId) -> &[Span] {
if let Some(redeclaration_id) = self.redeclarations[symbol_id] {
Expand Down
14 changes: 14 additions & 0 deletions crates/oxc_transformer/src/es2015/arrow_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,20 @@ impl<'a> Traverse<'a> for ArrowFunctions<'a> {
fn exit_class(&mut self, _class: &mut Class<'a>, _ctx: &mut TraverseCtx<'a>) {
self.stacks.pop();
}

fn enter_variable_declarator(
&mut self,
node: &mut VariableDeclarator<'a>,
ctx: &mut TraverseCtx<'a>,
) {
if !matches!(node.init, Some(Expression::ArrowFunctionExpression(_))) {
return;
}

let Some(id) = node.id.get_binding_identifier() else { return };
*ctx.symbols_mut().get_flags_mut(id.symbol_id.get().unwrap()) &=
!SymbolFlags::ArrowFunction;
}
}

impl<'a> ArrowFunctions<'a> {
Expand Down
8 changes: 8 additions & 0 deletions crates/oxc_transformer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,14 @@ impl<'a> Traverse<'a> for Transformer<'a> {
self.x2_es2019.enter_catch_clause(clause, ctx);
}

fn enter_variable_declarator(
&mut self,
node: &mut VariableDeclarator<'a>,
ctx: &mut TraverseCtx<'a>,
) {
self.x3_es2015.enter_variable_declarator(node, ctx);
}

fn enter_ts_export_assignment(
&mut self,
export_assignment: &mut TSExportAssignment<'a>,
Expand Down
49 changes: 2 additions & 47 deletions tasks/transform_conformance/babel.snap.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
commit: 12619ffe

Passed: 281/953
Passed: 282/953

# All Passed:
* babel-plugin-transform-optional-catch-binding
Expand Down Expand Up @@ -1341,12 +1341,6 @@ Targets: The `esmodules` is not supported


* preset-options/ios-6/input.mjs
x Output mismatch
x Symbol flags mismatch:
| after transform: SymbolId(0): SymbolFlags(BlockScopedVariable |
| ConstVariable | ArrowFunction)
| rebuilt : SymbolId(0): SymbolFlags(BlockScopedVariable |
| ConstVariable)


* preset-options/no-options/input.mjs
Expand Down Expand Up @@ -1419,12 +1413,6 @@ Targets: The `esmodules` is not supported


* preset-options-babel-7/ios-6/input.mjs
x Output mismatch
x Symbol flags mismatch:
| after transform: SymbolId(0): SymbolFlags(BlockScopedVariable |
| ConstVariable | ArrowFunction)
| rebuilt : SymbolId(0): SymbolFlags(BlockScopedVariable |
| ConstVariable)


* preset-options-babel-7/loose-typeof-symbol/input.mjs
Expand Down Expand Up @@ -1916,53 +1904,20 @@ failed to resolve query: failed to parse the rest of input: ...''



# babel-plugin-transform-arrow-functions (0/6)
# babel-plugin-transform-arrow-functions (1/6)
* assumption-newableArrowFunctions-false/basic/input.js
x Output mismatch
x Symbol flags mismatch:
| after transform: SymbolId(2): SymbolFlags(FunctionScopedVariable |
| ArrowFunction)
| rebuilt : SymbolId(3): SymbolFlags(FunctionScopedVariable)


* assumption-newableArrowFunctions-false/naming/input.js
x Output mismatch
x Symbol flags mismatch:
| after transform: SymbolId(1): SymbolFlags(BlockScopedVariable |
| ConstVariable | ArrowFunction)
| rebuilt : SymbolId(1): SymbolFlags(BlockScopedVariable |
| ConstVariable)


* assumption-newableArrowFunctions-false/self-referential/input.js
x Output mismatch
x Symbol flags mismatch:
| after transform: SymbolId(1): SymbolFlags(FunctionScopedVariable |
| ArrowFunction)
| rebuilt : SymbolId(1): SymbolFlags(FunctionScopedVariable)


* spec/newableArrowFunction-default/input.js
x Output mismatch
x Symbol flags mismatch:
| after transform: SymbolId(0): SymbolFlags(BlockScopedVariable |
| ArrowFunction)
| rebuilt : SymbolId(0): SymbolFlags(BlockScopedVariable)


* spec/newableArrowFunction-vs-spec-false/input.js
x Output mismatch
x Symbol flags mismatch:
| after transform: SymbolId(0): SymbolFlags(BlockScopedVariable |
| ArrowFunction)
| rebuilt : SymbolId(0): SymbolFlags(BlockScopedVariable)


* spec/newableArrowFunction-vs-spec-true/input.js
x Symbol flags mismatch:
| after transform: SymbolId(0): SymbolFlags(BlockScopedVariable |
| ArrowFunction)
| rebuilt : SymbolId(0): SymbolFlags(BlockScopedVariable)



Expand Down
17 changes: 2 additions & 15 deletions tasks/transform_conformance/oxc.snap.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
commit: 12619ffe

Passed: 9/36
Passed: 10/36

# All Passed:
* babel-plugin-transform-optional-catch-binding


# babel-plugin-transform-arrow-functions (0/1)
* use-this-inside-blocks/input.js
x Symbol flags mismatch:
| after transform: SymbolId(1): SymbolFlags(BlockScopedVariable |
| ArrowFunction)
| rebuilt : SymbolId(2): SymbolFlags(BlockScopedVariable)

x Symbol flags mismatch:
| after transform: SymbolId(2): SymbolFlags(BlockScopedVariable |
| ArrowFunction)
| rebuilt : SymbolId(3): SymbolFlags(BlockScopedVariable)

* babel-plugin-transform-arrow-functions


# babel-plugin-transform-typescript (2/7)
Expand Down