Default Num layout to Int

This commit is contained in:
Richard Feldman 2020-06-21 15:21:03 -04:00
parent 6ef74a2432
commit 1f6afe1182

View file

@ -537,11 +537,12 @@ fn layout_from_num_content<'a>(content: Content) -> Result<Layout<'a>, ()> {
use roc_types::subs::FlatType::*;
match content {
var @ FlexVar(_) | var @ RigidVar(_) => {
panic!(
"Layout::from_num_content encountered an unresolved {:?}",
var
);
FlexVar(_) | RigidVar(_) => {
// If a Num makes it all the way through type checking with an unbound
// type variable, then assume it's a 64-bit integer.
//
// (e.g. for (5 + 5) assume both 5s are 64-bit integers.)
Ok(Layout::Builtin(Builtin::Int64))
}
Structure(Apply(symbol, args)) => match symbol {
Symbol::INT_INTEGER => Ok(Layout::Builtin(Builtin::Int64)),
@ -553,12 +554,12 @@ fn layout_from_num_content<'a>(content: Content) -> Result<Layout<'a>, ()> {
);
}
},
Alias(_, _, _) => {
todo!("TODO recursively resolve type aliases in num_from_content");
}
Structure(_) => {
panic!("Invalid Num.Num type application: {:?}", content);
}
Alias(_, _, _) => {
panic!("TODO recursively resolve type aliases in num_from_content");
}
Error => Err(()),
}
}