Skip to content

Commit

Permalink
[wgsl] Add two more statement behavior test cases (#4071)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrprice authored Dec 3, 2024
1 parent a252d9d commit 3818ac8
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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; } }`,

Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 3818ac8

Please sign in to comment.