-
-
Notifications
You must be signed in to change notification settings - Fork 933
Description
Stack up to #7148 contains a few places where it checks if a Function is an object method with matches!(parent, Ancestor::ObjectPropertyValue(_)). I think the code it's trying to match is:
obj = {
async function foo() {}
};But it will also match where the function is a property value, not a method:
obj = {
foo: async function() {}
};I think also need a check if object_prop.method to be able to tell the difference between the two.
oxc/crates/oxc_transformer/src/common/arrow_function_converter.rs
Lines 401 to 404 in b57d5a5
| && matches!( | |
| ancestors.next().unwrap(), | |
| Ancestor::MethodDefinitionValue(_) | Ancestor::ObjectPropertyValue(_) | |
| ) { |
oxc/crates/oxc_transformer/src/es2017/async_to_generator.rs
Lines 136 to 140 in c307e1b
| && matches!( | |
| ctx.parent(), | |
| // `class A { async foo() {} }` | `({ async foo() {} })` | |
| Ancestor::MethodDefinitionValue(_) | Ancestor::PropertyDefinitionValue(_) | |
| ) |
oxc/crates/oxc_transformer/src/es2018/async_generator_functions/mod.rs
Lines 148 to 152 in c307e1b
| && matches!( | |
| ctx.parent(), | |
| // `class A { async foo() {} }` | `({ async foo() {} })` | |
| Ancestor::MethodDefinitionValue(_) | Ancestor::ObjectPropertyValue(_) | |
| ) |
Personally, I think it'd be ideal if AST didn't use ObjectProperty for both properties and methods, to avoid this confusing ambiguity. oxc-project/backlog#142
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackPriority