Skip to content

Commit

Permalink
docs(span): document validity of ModuleKind::Unambiguous (#6423)
Browse files Browse the repository at this point in the history
relates #6249
  • Loading branch information
Boshen committed Oct 10, 2024
1 parent b5b0af9 commit 6a194f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion crates/oxc_span/src/source_type/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://babel.dev/docs/options#misc-options>
Unambiguous = 2,
Expand Down
5 changes: 4 additions & 1 deletion tasks/coverage/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down

0 comments on commit 6a194f9

Please sign in to comment.