bytesToU16 and bytesToU32 have proper types

This commit is contained in:
Joshua Hoeflich 2021-08-18 15:46:53 -05:00
parent 2d65bfdb5f
commit a4197d073c
3 changed files with 138 additions and 143 deletions

View file

@ -508,7 +508,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
Box::new(nat_type()),
);
// bytesToU16 : List U8, Nat -> U16
// bytesToU16 : List U8, Nat -> Result U16 [ OutOfBounds ]
{
let position_out_of_bounds = SolvedType::TagUnion(
vec![(TagName::Global("OutOfBounds".into()), vec![])],
@ -521,12 +521,18 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
);
}
// bytesToU32 : List U8, Nat -> U32
add_top_level_function_type!(
Symbol::NUM_BYTES_TO_U32,
vec![list_type(u8_type()), nat_type()],
Box::new(u32_type()),
);
// bytesToU32 : List U8, Nat -> Result U32 [ OutOfBounds ]
{
let position_out_of_bounds = SolvedType::TagUnion(
vec![(TagName::Global("OutOfBounds".into()), vec![])],
Box::new(SolvedType::Wildcard),
);
add_top_level_function_type!(
Symbol::NUM_BYTES_TO_U32,
vec![list_type(u8_type()), nat_type()],
Box::new(result_type(u32_type(), position_out_of_bounds)),
);
}
// Bool module