Support integer (Num *) patterns in jump tables

This commit is contained in:
Richard Feldman 2020-03-10 23:08:26 -04:00
parent a0d762d1e5
commit a033f325f4

View file

@ -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