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
8 changes: 8 additions & 0 deletions crates/oxc_semantic/src/checker/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,14 @@ pub fn check_for_statement_left(
}
}

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));
}
}

pub fn check_class(class: &Class, ctx: &SemanticBuilder<'_>) {
check_private_identifier(ctx);

Expand Down
1 change: 1 addition & 0 deletions crates/oxc_semantic/src/checker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub fn check<'a>(kind: AstKind<'a>, ctx: &SemanticBuilder<'a>) {
}
AstKind::ForOfStatement(stmt) => {
js::check_function_declaration(&stmt.body, false, ctx);
js::check_for_of_statement(stmt, ctx);
js::check_for_statement_left(&stmt.left, false, ctx);
ts::check_for_statement_left(&stmt.left, false, ctx);
}
Expand Down
22 changes: 19 additions & 3 deletions tasks/coverage/snapshots/parser_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ commit: 34725489
parser_typescript Summary:
AST Parsed : 9831/9834 (99.97%)
Positive Passed: 9820/9834 (99.86%)
Negative Passed: 1527/2578 (59.23%)
Negative Passed: 1528/2578 (59.27%)
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/FunctionDeclaration3.ts

Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/FunctionDeclaration4.ts
Expand Down Expand Up @@ -1006,8 +1006,6 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/classes/c

Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts

Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/classes/classStaticBlock/classStaticBlock23.ts

Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/classes/constructorDeclarations/classConstructorOverloadsAccessibility.ts

Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorDefaultValuesReferencingThis.ts
Expand Down Expand Up @@ -13820,6 +13818,24 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
14 │ }
╰────

× Cannot use 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) {
6 │ │ console.log(nn)
7 │ ╰─▶ }
8 │ }
╰────

× Cannot use 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) {
15 │ │ console.log(nn)
16 │ ╰─▶ }
17 │ }
╰────

× Unexpected token
╭─[typescript/tests/cases/conformance/classes/classStaticBlock/classStaticBlock26.ts:3:14]
2 │ static {
Expand Down
Loading