From 3818ac8539bf0f2b7356d8f564f3ce6fc97a8cdd Mon Sep 17 00:00:00 2001 From: James Price Date: Tue, 3 Dec 2024 13:49:11 -0500 Subject: [PATCH] [wgsl] Add two more statement behavior test cases (#4071) These cover unreachable code after statements with `return` behavior for functions that have non-void return types, which were not previously covered and not handled correctly in Tint. --- .../shader/validation/statement/statement_behavior.spec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/webgpu/shader/validation/statement/statement_behavior.spec.ts b/src/webgpu/shader/validation/statement/statement_behavior.spec.ts index 1acfd01d8b90..cd9867ac12d4 100644 --- a/src/webgpu/shader/validation/statement/statement_behavior.spec.ts +++ b/src/webgpu/shader/validation/statement/statement_behavior.spec.ts @@ -86,7 +86,7 @@ const kValidStatements = { while3: `while true { continue; break; }`, switch1: `switch 1 { default { } }`, - swtich2: `switch 1 { case 1 { } default { } }`, + switch2: `switch 1 { case 1 { } default { } }`, switch3: `switch 1 { default { break; } }`, switch4: `switch 1 { default { } case 1 { break; } }`, @@ -130,7 +130,9 @@ g.test('invalid_functions') const kValidFunctions = { empty: `fn foo() { }`, next_return: `fn foo() { if true { return; } }`, + unreachable_code_after_return_with_value: `fn foo() -> bool { return false; _ = 0; }`, no_final_return: `fn foo() -> bool { if true { return true; } else { return false; } }`, + no_final_return_unreachable_code: `fn foo() -> bool { if true { return true; } else { return false; } _ = 0; _ = 1; }`, }; g.test('valid_functions')