diff --git a/crates/oxc_span/src/source_type/mod.rs b/crates/oxc_span/src/source_type/mod.rs index 8b6a759e75739..37e411fa67800 100644 --- a/crates/oxc_span/src/source_type/mod.rs +++ b/crates/oxc_span/src/source_type/mod.rs @@ -55,7 +55,8 @@ pub enum ModuleKind { /// /// ESM syntax includes `import` statement, `export` statement and `import.meta`. /// - /// Note: Dynamic import expression is not ESM syntax. + /// Note1: This value is only valid as a parser input, and does not appear on a valid AST's `Program::source_type`. + /// Note2: Dynamic import expression is not ESM syntax. /// /// See Unambiguous = 2, diff --git a/tasks/coverage/src/driver.rs b/tasks/coverage/src/driver.rs index e053e8315e29e..aac49759cc9a2 100644 --- a/tasks/coverage/src/driver.rs +++ b/tasks/coverage/src/driver.rs @@ -67,11 +67,14 @@ impl CompilerInterface for Driver { } fn after_parse(&mut self, parser_return: &mut ParserReturn) -> ControlFlow<()> { - let ParserReturn { program, trivias, panicked, .. } = parser_return; + let ParserReturn { program, trivias, panicked, errors } = parser_return; self.panicked = *panicked; if self.check_comments(trivias) { return ControlFlow::Break(()); } + if (errors.is_empty() || !*panicked) && program.source_type.is_unambiguous() { + self.errors.push(OxcDiagnostic::error("SourceType must not be unambiguous.")); + } // Make sure serialization doesn't crash; also for code coverage. let _serializer = program.serializer(); ControlFlow::Continue(())