Appropriately substitute symbols in switch conditions

Closes #4557
This commit is contained in:
Ayaz Hafiz 2022-12-27 12:28:04 -06:00
parent 4dbe90db93
commit 23fc7f1413
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
3 changed files with 81 additions and 3 deletions

View file

@ -7079,10 +7079,18 @@ fn substitute_in_stmt_help<'a>(
default_branch,
ret_layout,
} => {
let opt_default = substitute_in_stmt_help(arena, default_branch.1, subs);
let mut did_change = false;
let cond_symbol = match substitute(subs, *cond_symbol) {
Some(s) => {
did_change = true;
s
}
None => *cond_symbol,
};
let opt_default = substitute_in_stmt_help(arena, default_branch.1, subs);
let opt_branches = Vec::from_iter_in(
branches.iter().map(|(label, info, branch)| {
match substitute_in_stmt_help(arena, branch, subs) {
@ -7119,7 +7127,7 @@ fn substitute_in_stmt_help<'a>(
};
Some(arena.alloc(Switch {
cond_symbol: *cond_symbol,
cond_symbol,
cond_layout: *cond_layout,
default_branch,
branches,