Skip to content
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
2 changes: 1 addition & 1 deletion crates/oxc_semantic/src/checker/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ pub fn check_for_of_statement(stmt: &ForOfStatement, ctx: &SemanticBuilder<'_>)
// ClassStaticBlockBody : ClassStaticBlockStatementList
// It is a Syntax Error if ClassStaticBlockStatementList Contains await is true.
if stmt.r#await && ctx.scoping.scope_flags(ctx.current_scope_id).is_class_static_block() {
ctx.error(diagnostics::class_static_block_await(stmt.span));
ctx.error(diagnostics::class_static_block_for_await(stmt.span));
}
}

Expand Down
6 changes: 6 additions & 0 deletions crates/oxc_semantic/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ pub fn class_static_block_await(span: Span) -> OxcDiagnostic {
OxcDiagnostic::error("Cannot use await in class static initialization block").with_label(span)
}

#[cold]
pub fn class_static_block_for_await(span: Span) -> OxcDiagnostic {
OxcDiagnostic::error("Cannot use 'for await' in class static initialization block")
.with_label(span)
}

#[cold]
pub fn reserved_keyword(x0: &str, span1: Span) -> OxcDiagnostic {
OxcDiagnostic::error(format!("The keyword '{x0}' is reserved")).with_label(span1)
Expand Down
4 changes: 2 additions & 2 deletions tasks/coverage/snapshots/parser_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13834,7 +13834,7 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
14 │ }
╰────

× Cannot use await in class static initialization block
× Cannot use 'for await' in class static initialization block
╭─[typescript/tests/cases/conformance/classes/classStaticBlock/classStaticBlock23.ts:5:5]
4 │ static {
5 │ ╭─▶ for await (const nn of nums) {
Expand All @@ -13843,7 +13843,7 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
8 │ }
╰────

× Cannot use await in class static initialization block
× Cannot use 'for await' in class static initialization block
╭─[typescript/tests/cases/conformance/classes/classStaticBlock/classStaticBlock23.ts:14:7]
13 │ static {
14 │ ╭─▶ for await (const nn of nums) {
Expand Down
Loading