|
@@ -283,7 +283,7 @@ pub enum Type {
|
|
String,
|
|
String,
|
|
DateTime,
|
|
DateTime,
|
|
Fn(Vec<Type>, Box<Type>),
|
|
Fn(Vec<Type>, Box<Type>),
|
|
- Struct(StructInfo),
|
|
|
|
|
|
+ Struct(Box<StructInfo>),
|
|
List(Box<Type>),
|
|
List(Box<Type>),
|
|
}
|
|
}
|
|
|
|
|
|
@@ -306,7 +306,8 @@ impl std::fmt::Display for Type {
|
|
ps = param_types.iter().map(|p| p.to_string()).join(", ")
|
|
ps = param_types.iter().map(|p| p.to_string()).join(", ")
|
|
)
|
|
)
|
|
}
|
|
}
|
|
- Type::Struct(StructInfo { name, fields, .. }) => {
|
|
|
|
|
|
+ Type::Struct(info) => {
|
|
|
|
+ let StructInfo { name, fields, .. } = &**info;
|
|
write!(
|
|
write!(
|
|
f,
|
|
f,
|
|
"{name} {{{}}}",
|
|
"{name} {{{}}}",
|
|
@@ -348,7 +349,7 @@ impl PrettyPrint for Type {
|
|
+ return_type.pretty_print()
|
|
+ return_type.pretty_print()
|
|
+ m::operator("]")
|
|
+ m::operator("]")
|
|
}
|
|
}
|
|
- Type::Struct(StructInfo { name, .. }) => m::type_identifier(name),
|
|
|
|
|
|
+ Type::Struct(info) => m::type_identifier(&info.name),
|
|
Type::List(element_type) => {
|
|
Type::List(element_type) => {
|
|
m::type_identifier("List")
|
|
m::type_identifier("List")
|
|
+ m::operator("<")
|
|
+ m::operator("<")
|
|
@@ -400,9 +401,9 @@ impl Type {
|
|
vars.dedup();
|
|
vars.dedup();
|
|
vars
|
|
vars
|
|
}
|
|
}
|
|
- Type::Struct(StructInfo { fields, .. }) => {
|
|
|
|
|
|
+ Type::Struct(info) => {
|
|
let mut vars = vec![];
|
|
let mut vars = vec![];
|
|
- for (_, (_, t)) in fields {
|
|
|
|
|
|
+ for (_, (_, t)) in &info.fields {
|
|
vars.extend(t.type_variables(including_type_parameters));
|
|
vars.extend(t.type_variables(including_type_parameters));
|
|
}
|
|
}
|
|
vars
|
|
vars
|
|
@@ -750,7 +751,7 @@ impl Expression {
|
|
Expression::Boolean(_, _) => Type::Boolean,
|
|
Expression::Boolean(_, _) => Type::Boolean,
|
|
Expression::Condition(_, _, then_, _) => then_.get_type(),
|
|
Expression::Condition(_, _, then_, _) => then_.get_type(),
|
|
Expression::String(_, _) => Type::String,
|
|
Expression::String(_, _) => Type::String,
|
|
- Expression::InstantiateStruct(_, _, info_) => Type::Struct(info_.clone()),
|
|
|
|
|
|
+ Expression::InstantiateStruct(_, _, info_) => Type::Struct(Box::new(info_.clone())),
|
|
Expression::AccessField(_, _, _, _, _struct_type, field_type) => {
|
|
Expression::AccessField(_, _, _, _, _struct_type, field_type) => {
|
|
field_type.unsafe_as_concrete()
|
|
field_type.unsafe_as_concrete()
|
|
}
|
|
}
|
|
@@ -775,7 +776,7 @@ impl Expression {
|
|
Expression::Condition(_, _, then_, _) => then_.get_type_scheme(),
|
|
Expression::Condition(_, _, then_, _) => then_.get_type_scheme(),
|
|
Expression::String(_, _) => TypeScheme::make_quantified(Type::String),
|
|
Expression::String(_, _) => TypeScheme::make_quantified(Type::String),
|
|
Expression::InstantiateStruct(_, _, info_) => {
|
|
Expression::InstantiateStruct(_, _, info_) => {
|
|
- TypeScheme::make_quantified(Type::Struct(info_.clone()))
|
|
|
|
|
|
+ TypeScheme::make_quantified(Type::Struct(Box::new(info_.clone())))
|
|
}
|
|
}
|
|
Expression::AccessField(_, _, _, _, _struct_type, field_type) => field_type.clone(),
|
|
Expression::AccessField(_, _, _, _, _struct_type, field_type) => field_type.clone(),
|
|
Expression::List(_, _, inner) => match inner {
|
|
Expression::List(_, _, inner) => match inner {
|