fix incorrect layout for Switch

This commit is contained in:
Folkert 2020-03-20 19:56:50 +01:00
parent d0da300042
commit 0f22cbbf7d
3 changed files with 11 additions and 10 deletions

View file

@ -969,9 +969,9 @@ fn decide_to_branching<'a>(
tests,
fallback,
} => {
let cond = env
.arena
.alloc(path_to_expr(env, cond_symbol, &path, &cond_layout));
// the cond_layout can change in the process. E.g. if the cond is a Tag, we actually
// switch on the tag discriminant (currently an i64 value)
let (cond, cond_layout) = path_to_expr_help(env, cond_symbol, &path, cond_layout);
let default_branch = env.arena.alloc(decide_to_branching(
env,
@ -1008,7 +1008,7 @@ fn decide_to_branching<'a>(
// make a jump table based on the tests
Expr::Switch {
cond,
cond: env.arena.alloc(cond),
cond_layout,
branches: branches.into_bump_slice(),
default_branch,