mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
Support integer (Num *) patterns in jump tables
This commit is contained in:
parent
a0d762d1e5
commit
a033f325f4
1 changed files with 14 additions and 8 deletions
|
@ -672,14 +672,20 @@ fn from_can_when<'a>(
|
|||
|
||||
match &loc_when_pat.value {
|
||||
NumLiteral(var, num) => {
|
||||
panic!(
|
||||
"TODO check if this var is an Int; if so, it's jumpable! var: {:?}, num: {:?}",
|
||||
var, num
|
||||
);
|
||||
// Switch only compares the condition to the
|
||||
// alternatives based on their bit patterns,
|
||||
// so casting from i64 to u64 makes no difference here.
|
||||
// jumpable_branches.push((*int as u64, mono_expr));
|
||||
// This is jumpable iff it's an int
|
||||
match to_int_or_float(env.subs, *var) {
|
||||
IntOrFloat::IntType => {
|
||||
jumpable_branches.push((*num as u64, mono_expr));
|
||||
}
|
||||
IntOrFloat::FloatType => {
|
||||
// The type checker should have converted these mismatches into RuntimeErrors already!
|
||||
if cfg!(debug_assertions) {
|
||||
panic!("A type mismatch in a pattern was not converted to a runtime error: {:?}", loc_when_pat);
|
||||
} else {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
IntLiteral(int) => {
|
||||
// Switch only compares the condition to the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue