mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
add equal_types_with_storage helper
This commit is contained in:
parent
e8bf5fa378
commit
6baae55980
1 changed files with 28 additions and 0 deletions
|
@ -215,6 +215,34 @@ impl Constraints {
|
||||||
Constraint::Eq(type_index, expected_index, category_index, region)
|
Constraint::Eq(type_index, expected_index, category_index, region)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn equal_types_with_storage(
|
||||||
|
&mut self,
|
||||||
|
typ: Type,
|
||||||
|
expected: Expected<Type>,
|
||||||
|
category: Category,
|
||||||
|
region: Region,
|
||||||
|
storage_var: Variable,
|
||||||
|
) -> Constraint {
|
||||||
|
let type_index = self.push_type(typ);
|
||||||
|
let expected_index = Index::push_new(&mut self.expectations, expected);
|
||||||
|
let category_index = Self::push_category(self, category);
|
||||||
|
|
||||||
|
let equal = Constraint::Eq(type_index, expected_index, category_index, region);
|
||||||
|
|
||||||
|
let storage_type_index = Self::push_type_variable(storage_var);
|
||||||
|
let storage_category = Category::Storage(std::file!(), std::line!());
|
||||||
|
let storage_category_index = Self::push_category(self, storage_category);
|
||||||
|
let storage = Constraint::Eq(
|
||||||
|
storage_type_index,
|
||||||
|
expected_index,
|
||||||
|
storage_category_index,
|
||||||
|
region,
|
||||||
|
);
|
||||||
|
|
||||||
|
self.and_constraint([equal, storage])
|
||||||
|
}
|
||||||
|
|
||||||
pub fn equal_pattern_types(
|
pub fn equal_pattern_types(
|
||||||
&mut self,
|
&mut self,
|
||||||
typ: Type,
|
typ: Type,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue