Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(span): document validity of ModuleKind::Unambiguous #6423

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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