mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
support nested pattern matches on tag unions
This commit is contained in:
parent
0f22cbbf7d
commit
655dc32098
2 changed files with 58 additions and 36 deletions
|
@ -330,7 +330,7 @@ pub fn build_expr<'a, B: Backend>(
|
|||
let mem_flags = MemFlags::new();
|
||||
let expr = build_expr(env, scope, module, builder, expr, procs);
|
||||
|
||||
let ret_type = layout_to_type(&field_layout, cfg.pointer_type());
|
||||
let ret_type = type_from_layout(cfg, field_layout);
|
||||
|
||||
return builder
|
||||
.ins()
|
||||
|
@ -426,21 +426,6 @@ pub fn build_expr<'a, B: Backend>(
|
|||
}
|
||||
}
|
||||
|
||||
fn layout_to_type<'a>(layout: &Layout<'a>, _pointer_type: Type) -> Type {
|
||||
use roc_mono::layout::Builtin::*;
|
||||
|
||||
match layout {
|
||||
Layout::Builtin(builtin) => match builtin {
|
||||
Int64 => cranelift::prelude::types::I64,
|
||||
Byte => cranelift::prelude::types::I8,
|
||||
Bool => cranelift::prelude::types::B1,
|
||||
Float64 => cranelift::prelude::types::F64,
|
||||
other => panic!("I don't yet know how to make a type from {:?}", other),
|
||||
},
|
||||
other => panic!("I don't yet know how to make a type from {:?}", other),
|
||||
}
|
||||
}
|
||||
|
||||
struct Branch2<'a> {
|
||||
cond: &'a Expr<'a>,
|
||||
cond_layout: &'a Layout<'a>,
|
||||
|
@ -570,7 +555,7 @@ fn build_switch<'a, B: Backend>(
|
|||
|
||||
let mem_flags = MemFlags::new();
|
||||
|
||||
let ret_type = layout_to_type(&new_cond_layout, env.cfg.pointer_type());
|
||||
let ret_type = type_from_layout(env.cfg, &new_cond_layout);
|
||||
|
||||
builder
|
||||
.ins()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue