Skip to content

Commit 94b06ef

Browse files
committed
fix(ast): correct logic in Expression::is_call_like_expression (#12534)
The `is_call_like_expression` function is intended to identify expressions that are function calls, new expressions, or import expressions. The previous implementation incorrectly used a logical AND (`&&`) to combine these checks. This would always evaluate to false, since an expression cannot be a `CallExpression` *and* a `NewExpression` or `ImportExpression` simultaneously. This pull request corrects the logic by replacing the logical AND (`&&`) with a logical OR (`||`). This ensures the function accurately returns `true` if an expression is any of the call-like types, aligning with its intended purpose.
1 parent abb690a commit 94b06ef

File tree

1 file changed

+1
-1
lines changed
  • crates/oxc_ast/src/ast_impl

1 file changed

+1
-1
lines changed

crates/oxc_ast/src/ast_impl/js.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ impl<'a> Expression<'a> {
341341
/// or [`ImportExpression`].
342342
pub fn is_call_like_expression(&self) -> bool {
343343
self.is_call_expression()
344-
&& matches!(self, Expression::NewExpression(_) | Expression::ImportExpression(_))
344+
|| matches!(self, Expression::NewExpression(_) | Expression::ImportExpression(_))
345345
}
346346

347347
/// Returns `true` if this [`Expression`] is a [`BinaryExpression`] or [`LogicalExpression`].

0 commit comments

Comments
 (0)