Skip to content

Possible logic error in arrow functions transform #7174

@overlookmotel

Description

@overlookmotel

While reviewing #7113, I was confused by the logic in get_arrow_function_scope. Previously this function returned the ScopeId of enclosing arrow function (as the function's name suggests). But now it also returns the ScopeId of a class method or object method:

Ancestor::FunctionBody(func) => {
return if self.is_async_only() && *func.r#async()
&& matches!(
ancestors.next().unwrap(),
Ancestor::MethodDefinitionValue(_) | Ancestor::ObjectPropertyValue(_)
) {
Some(func.scope_id().get().unwrap())
} else {
None
}
}

Is this correct?

If it is correct, the name of the function should probably be changed to reflect what it's now doing, and a comment added explaining why.

Metadata

Metadata

Assignees

Labels

A-transformerArea - Transformer / TranspilerC-bugCategory - Bug

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions