mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
support more complex nested patterns
This commit is contained in:
parent
fbadd9d620
commit
e062404a63
3 changed files with 162 additions and 117 deletions
|
@ -893,7 +893,7 @@ fn store_pattern<'a>(
|
|||
_ => {
|
||||
// store the field in a symbol, and continue matching on it
|
||||
let symbol = env.fresh_symbol();
|
||||
stored.push((symbol, layout.clone(), load));
|
||||
stored.push((symbol, arg_layout.clone(), load));
|
||||
|
||||
store_pattern(env, argument, symbol, arg_layout.clone(), stored)?;
|
||||
}
|
||||
|
@ -1402,3 +1402,26 @@ fn from_can_record_destruct<'a>(
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn specialize_equality<'a>(
|
||||
arena: &'a Bump,
|
||||
lhs: Expr<'a>,
|
||||
rhs: Expr<'a>,
|
||||
layout: Layout<'a>,
|
||||
) -> Expr<'a> {
|
||||
let symbol = match &layout {
|
||||
Layout::Builtin(builtin) => match builtin {
|
||||
Builtin::Int64 => Symbol::INT_EQ_I64,
|
||||
Builtin::Float64 => Symbol::FLOAT_EQ,
|
||||
Builtin::Byte => Symbol::INT_EQ_I8,
|
||||
Builtin::Bool => Symbol::INT_EQ_I1,
|
||||
other => todo!("Cannot yet compare for equality {:?}", other),
|
||||
},
|
||||
other => todo!("Cannot yet compare for equality {:?}", other),
|
||||
};
|
||||
|
||||
Expr::CallByName(
|
||||
symbol,
|
||||
arena.alloc([(lhs, layout.clone()), (rhs, layout.clone())]),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue