Remove Cells from Types

This commit is contained in:
Ayaz Hafiz 2022-11-15 09:00:16 -06:00
parent f4fcb9f421
commit b30e8fc9b2
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
5 changed files with 89 additions and 117 deletions

View file

@ -30,7 +30,7 @@ use roc_region::all::{Loc, Region};
use roc_types::subs::{IllegalCycleMark, Variable};
use roc_types::types::Type::{self, *};
use roc_types::types::{
AliasKind, AnnotationSource, Category, OptAbleType, PReason, Reason, RecordField, TypeCell,
AliasKind, AnnotationSource, Category, OptAbleType, PReason, Reason, RecordField,
TypeExtension, TypeTag, Types,
};
@ -1608,7 +1608,7 @@ fn constrain_function_def(
let signature_index = constraints.push_type(types, signature);
let (arg_types, signature_closure_type, ret_type) = match types[signature].get() {
let (arg_types, signature_closure_type, ret_type) = match types[signature] {
TypeTag::Function(signature_closure_type, ret_type) => (
types.get_type_arguments(signature),
signature_closure_type,
@ -2503,7 +2503,7 @@ fn constrain_typed_def(
//
// This means we get errors like "the first argument of `f` is weird"
// instead of the more generic "something is wrong with the body of `f`"
match (&def.loc_expr.value, types[signature].get()) {
match (&def.loc_expr.value, types[signature]) {
(
Closure(ClosureData {
function_type: fn_var,
@ -2667,7 +2667,7 @@ fn constrain_typed_function_arguments(
def_pattern_state: &mut PatternState,
argument_pattern_state: &mut PatternState,
arguments: &[(Variable, AnnotatedMark, Loc<Pattern>)],
arg_types: Slice<TypeCell>,
arg_types: Slice<TypeTag>,
) {
// ensure type matches the one in the annotation
let opt_label = if let Pattern::Identifier(label) = def.loc_pattern.value {
@ -2805,7 +2805,7 @@ fn constrain_typed_function_arguments_simple(
def_pattern_state: &mut PatternState,
argument_pattern_state: &mut PatternState,
arguments: &[(Variable, AnnotatedMark, Loc<Pattern>)],
arg_types: Slice<TypeCell>,
arg_types: Slice<TypeTag>,
) {
let it = arguments.iter().zip(arg_types.into_iter()).enumerate();
for (index, ((pattern_var, annotated_mark, loc_pattern), ann)) in it {
@ -3094,7 +3094,7 @@ fn constrain_closure_size(
}
pub struct InstantiateRigids {
pub signature: Index<TypeCell>,
pub signature: Index<TypeTag>,
pub new_rigid_variables: Vec<Variable>,
pub new_infer_variables: Vec<Variable>,
}
@ -3321,7 +3321,7 @@ fn constraint_recursive_function(
signature_index,
));
let (arg_types, _signature_closure_type, ret_type) = match types[signature].get() {
let (arg_types, _signature_closure_type, ret_type) = match types[signature] {
TypeTag::Function(signature_closure_type, ret_type) => (
types.get_type_arguments(signature),
signature_closure_type,
@ -3764,7 +3764,7 @@ fn rec_defs_help(
//
// This means we get errors like "the first argument of `f` is weird"
// instead of the more generic "something is wrong with the body of `f`"
match (&def.loc_expr.value, types[signature].get()) {
match (&def.loc_expr.value, types[signature]) {
(
Closure(ClosureData {
function_type: fn_var,

View file

@ -769,7 +769,7 @@ pub fn constrain_pattern(
fn could_be_a_tag_union(types: &Types, typ: TypeOrVar) -> bool {
match typ.split() {
Ok(typ_index) => !matches!(
types[typ_index].get(),
types[typ_index],
TypeTag::Apply { .. } | TypeTag::Function(..) | TypeTag::Record(..)
),
Err(_) => {