Skip to content

Commit

Permalink
Change the dead code analysis for if expressions. (FuelLabs#1770)
Browse files Browse the repository at this point in the history
  • Loading branch information
otrho authored May 30, 2022
1 parent 41664a1 commit e21bf89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions sway-core/src/control_flow_analysis/dead_code_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ fn connect_expression(
let then_expr = connect_expression(
&(*then).expression,
graph,
&condition_expr,
leaves,
exit_node,
"then branch",
tree_type,
Expand All @@ -792,7 +792,7 @@ fn connect_expression(
connect_expression(
&(*else_expr).expression,
graph,
&condition_expr,
leaves,
exit_node,
"else branch",
tree_type,
Expand All @@ -802,7 +802,7 @@ fn connect_expression(
vec![]
};

Ok([then_expr, else_expr].concat())
Ok([condition_expr, then_expr, else_expr].concat())
}
CodeBlock(a @ TypedCodeBlock { .. }) => {
connect_code_block(a, graph, leaves, exit_node, tree_type)
Expand Down
5 changes: 2 additions & 3 deletions sway-lib-std/src/u128.sw
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,13 @@ impl core::ops::Shiftable for U128 {
pub fn lsh(self, rhs: u64) -> Self {
// If shifting by at least the number of bits, then saturate with
// zeroes.
if (rhs >= 128) {
if rhs >= 128 {
return ~Self::new();
}

// If shifting by at least half the number of bits, then upper word can
// be discarded.
// TODO remove the `else` once #1682 is fixed
else if (rhs >= 64) {
if rhs >= 64 {
return ~Self::from(self.lower <<(rhs - 64), 0);
}

Expand Down

0 comments on commit e21bf89

Please sign in to comment.