forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug which created dead and incorrectly typed blocks into IR, trig…
…gering a verification failure. (FuelLabs#3210) If both arms of an `if` (or all arms of a `match` which are converted to `if`s) were terminated with `return` then we still created a merge block with an unknown arg, which ended up being dead code and incorrectly typed.
- Loading branch information
Showing
7 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...2e_vm_tests/test_programs/should_pass/language/match_expressions_explicit_rets/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
out | ||
target |
8 changes: 8 additions & 0 deletions
8
...e2e_vm_tests/test_programs/should_pass/language/match_expressions_explicit_rets/Forc.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-3F456608F1F32854' | ||
|
||
[[package]] | ||
name = 'match_expressions_explicit_rets' | ||
source = 'root' | ||
dependencies = ['core'] |
9 changes: 9 additions & 0 deletions
9
...e2e_vm_tests/test_programs/should_pass/language/match_expressions_explicit_rets/Forc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "match_expressions_explicit_rets" | ||
implicit-std = false | ||
|
||
[dependencies] | ||
core = { path = "../../../../../../../sway-lib-core" } |
15 changes: 15 additions & 0 deletions
15
...e_vm_tests/test_programs/should_pass/language/match_expressions_explicit_rets/src/main.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
script; | ||
|
||
// Explicit returns from each arm of a match expression. Was causing mistyped dead IR to be | ||
// generated. | ||
|
||
fn main() -> bool { | ||
match true { | ||
true => { | ||
return true; | ||
}, | ||
false => { | ||
return false; | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...e2e_vm_tests/test_programs/should_pass/language/match_expressions_explicit_rets/test.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
category = "run" | ||
expected_result = { action = "return", value = 1 } | ||
validate_abi = false |