From 2f3e207b412c6cc28a3a182d131756dd6ee49b13 Mon Sep 17 00:00:00 2001 From: YunfeiHe Date: Fri, 18 Aug 2023 23:13:56 +0800 Subject: [PATCH] Fix test --- tasks/coverage/src/suite.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tasks/coverage/src/suite.rs b/tasks/coverage/src/suite.rs index 796ff385278951..6d9fd0d038f113 100644 --- a/tasks/coverage/src/suite.rs +++ b/tasks/coverage/src/suite.rs @@ -365,14 +365,16 @@ pub trait Case: Sized + Sync + Send + UnwindSafe { } fn are_all_identifiers_resolved(semantic: &oxc_semantic::Semantic<'_>) -> bool { - use oxc_ast::ast; - use oxc_ast::AstKind; + use oxc_ast::{ast, AstKind}; + use oxc_semantic::AstNode; let ast_nodes = semantic.nodes(); let has_non_resolved = ast_nodes.iter().any(|node| { match node.kind() { AstKind::BindingIdentifier(id) => { - match ast_nodes.parent_kind(node.id()) { + let mut parents = ast_nodes.iter_parents(node.id()).map(AstNode::kind); + parents.next(); // Exclude BindingIdentifier itself + match parents.next() { Some(AstKind::Function(func)) if func.r#type == ast::FunctionType::FunctionExpression => { @@ -381,6 +383,17 @@ fn are_all_identifiers_resolved(semantic: &oxc_semantic::Semantic<'_>) -> bool { } _ => {} } + let mut parents = ast_nodes.iter_parents(node.id()).map(AstNode::kind); + parents.next(); // Exclude BindingIdentifier itself + match (parents.next(), parents.next()) { + // FIXME: case like `if (xx) ; else function test() {}` + (Some(AstKind::Function(func)), Some(AstKind::IfStatement(_))) + if func.r#type == ast::FunctionType::FunctionDeclaration => + { + return false; + } + _ => {} + } id.symbol_id.get().is_none() }