mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +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 {
|
match &loc_when_pat.value {
|
||||||
NumLiteral(var, num) => {
|
NumLiteral(var, num) => {
|
||||||
panic!(
|
// This is jumpable iff it's an int
|
||||||
"TODO check if this var is an Int; if so, it's jumpable! var: {:?}, num: {:?}",
|
match to_int_or_float(env.subs, *var) {
|
||||||
var, num
|
IntOrFloat::IntType => {
|
||||||
);
|
jumpable_branches.push((*num as u64, mono_expr));
|
||||||
// Switch only compares the condition to the
|
}
|
||||||
// alternatives based on their bit patterns,
|
IntOrFloat::FloatType => {
|
||||||
// so casting from i64 to u64 makes no difference here.
|
// The type checker should have converted these mismatches into RuntimeErrors already!
|
||||||
// jumpable_branches.push((*int as u64, mono_expr));
|
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) => {
|
IntLiteral(int) => {
|
||||||
// Switch only compares the condition to the
|
// Switch only compares the condition to the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue