disable debug prints
This commit is contained in:
parent
a7262c66b4
commit
0884e52cdf
4 changed files with 49 additions and 30 deletions
|
@ -233,7 +233,7 @@ impl ConstraintSystem {
|
|||
}
|
||||
|
||||
if let Some(lower_bound) = self.lower_bounds.get(&v).cloned() {
|
||||
eprintln!("var already exists. check max. type");
|
||||
//eprintln!("var already exists. check max. type");
|
||||
if let Ok(halo) = self.eval_subtype(
|
||||
ConstraintPair {
|
||||
lhs: lower_bound.clone(),
|
||||
|
@ -241,8 +241,8 @@ impl ConstraintSystem {
|
|||
addr: vec![]
|
||||
}
|
||||
) {
|
||||
eprintln!("found more general lower bound");
|
||||
eprintln!("set var {}'s lowerbound to {:?}", v, new_lower_bound.clone());
|
||||
//eprintln!("found more general lower bound");
|
||||
//eprintln!("set var {}'s lowerbound to {:?}", v, new_lower_bound.clone());
|
||||
// generalize variable type to supertype
|
||||
self.lower_bounds.insert(v, new_lower_bound);
|
||||
Ok(())
|
||||
|
@ -253,14 +253,14 @@ impl ConstraintSystem {
|
|||
addr: vec![]
|
||||
}
|
||||
) {
|
||||
eprintln!("OK, is already larger type");
|
||||
Ok(())
|
||||
//eprintln!("OK, is already larger type");
|
||||
Ok(())
|
||||
} else {
|
||||
eprintln!("violated subtype restriction");
|
||||
//eprintln!("violated subtype restriction");
|
||||
Err(())
|
||||
}
|
||||
} else {
|
||||
eprintln!("set var {}'s lowerbound to {:?}", v, new_lower_bound.clone());
|
||||
//eprintln!("set var {}'s lowerbound to {:?}", v, new_lower_bound.clone());
|
||||
self.lower_bounds.insert(v, new_lower_bound);
|
||||
Ok(())
|
||||
}
|
||||
|
@ -285,16 +285,16 @@ impl ConstraintSystem {
|
|||
addr: vec![]
|
||||
}
|
||||
) {
|
||||
eprintln!("found a lower upper bound: {} <= {:?}", v, new_upper_bound);
|
||||
//println!("found a lower upper bound: {} <= {:?}", v, new_upper_bound);
|
||||
// found a lower upper bound
|
||||
self.upper_bounds.insert(v, new_upper_bound);
|
||||
Ok(())
|
||||
} else {
|
||||
eprintln!("new upper bound violates subtype restriction");
|
||||
//println!("new upper bound violates subtype restriction");
|
||||
Err(())
|
||||
}
|
||||
} else {
|
||||
eprintln!("set upper bound: {} <= {:?}", v, new_upper_bound);
|
||||
//eprintln!("set upper bound: {} <= {:?}", v, new_upper_bound);
|
||||
self.upper_bounds.insert(v, new_upper_bound);
|
||||
Ok(())
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ impl ConstraintSystem {
|
|||
// error
|
||||
ConstraintError
|
||||
> {
|
||||
eprintln!("eval_subtype {:?} <=? {:?}", unification_pair.lhs, unification_pair.rhs);
|
||||
//eprintln!("eval_subtype {:?} <=? {:?}", unification_pair.lhs, unification_pair.rhs);
|
||||
match (unification_pair.lhs.clone().strip(), unification_pair.rhs.clone().strip()) {
|
||||
|
||||
/*
|
||||
|
@ -592,7 +592,7 @@ impl ConstraintSystem {
|
|||
itemsψ.push(ψ);
|
||||
}
|
||||
}
|
||||
eprintln!("itemsψ = {:?}", itemsψ);
|
||||
//eprintln!("itemsψ = {:?}", itemsψ);
|
||||
|
||||
if n_halos_required > 0 {
|
||||
reprψ = TypeTerm::Ladder(vec![
|
||||
|
@ -600,7 +600,7 @@ impl ConstraintSystem {
|
|||
reprψinterface
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Ok(
|
||||
TypeTerm::Seq {
|
||||
seq_repr: if reprψ.is_empty() { None }
|
||||
|
@ -737,7 +737,7 @@ impl ConstraintSystem {
|
|||
}
|
||||
|
||||
// solve subtypes
|
||||
eprintln!("------ SOLVE SUBTYPES ---- ");
|
||||
//eprintln!("------ SOLVE SUBTYPES ---- ");
|
||||
for mut subtype_pair in self.subtype_pairs.clone().into_iter() {
|
||||
subtype_pair.lhs.apply_subst(&self.σ);
|
||||
subtype_pair.rhs.apply_subst(&self.σ);
|
||||
|
@ -757,7 +757,7 @@ impl ConstraintSystem {
|
|||
|
||||
self.reapply_subst();
|
||||
|
||||
eprintln!("------ MAKE HALOS -----");
|
||||
//eprintln!("------ MAKE HALOS -----");
|
||||
let mut halo_types = Vec::new();
|
||||
for mut subtype_pair in self.subtype_pairs.clone().into_iter() {
|
||||
subtype_pair.lhs = subtype_pair.lhs.apply_subst(&self.σ).clone();
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::{term::TypeTerm, constraint_system, EnumVariant, StructMember};
|
|||
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>\\
|
||||
|
||||
pub fn splice_ladders( mut upper: Vec< TypeTerm >, mut lower: Vec< TypeTerm > ) -> Vec< TypeTerm > {
|
||||
eprintln!("splice ladders {:?} <<<====>>> {:?} ", upper, lower);
|
||||
//eprintln!("splice ladders {:?} <<<====>>> {:?} ", upper, lower);
|
||||
// check for overlap
|
||||
for i in 0 .. upper.len() {
|
||||
if upper[i] == lower[0] {
|
||||
|
|
46
src/term.rs
46
src/term.rs
|
@ -515,26 +515,44 @@ impl TypeTerm {
|
|||
|
||||
SugaredTypeTerm::Univ(t)
|
||||
=> SugaredTypeTerm::Univ(Box::new(t.get_floor_type())),
|
||||
|
||||
SugaredTypeTerm::Seq { seq_repr, items } => {
|
||||
SugaredTypeTerm::Seq {
|
||||
seq_repr: if let Some(sr) = seq_repr {
|
||||
Some(Box::new(sr.clone().get_floor_type()))
|
||||
*/
|
||||
/*
|
||||
TypeTerm::Seq { seq_repr, items } => {
|
||||
(TypeTerm::Seq {
|
||||
seq_repr: if let Some(sr) = seq_repr.clone() {
|
||||
Some(Box::new(sr.clone().get_floor_type().0))
|
||||
} else { None },
|
||||
items: items.iter().map(|t| t.get_floor_type()).collect()
|
||||
}
|
||||
items: items.iter().map(|t| t.get_floor_type().0).collect()
|
||||
},
|
||||
TypeTerm::Seq {
|
||||
seq_repr: if let Some(sr) = seq_repr {
|
||||
Some(Box::new(sr.clone().get_floor_type().1))
|
||||
} else { None },
|
||||
items: items.iter().map(|t| t.get_floor_type().1).collect()
|
||||
})
|
||||
}
|
||||
SugaredTypeTerm::Struct { struct_repr, members } => {
|
||||
SugaredTypeTerm::Struct {
|
||||
struct_repr: if let Some(sr) = struct_repr {
|
||||
Some(Box::new(sr.clone().get_floor_type()))
|
||||
TypeTerm::Struct { struct_repr, members } => {
|
||||
(TypeTerm::Struct {
|
||||
struct_repr: if let Some(sr) = struct_repr.clone() {
|
||||
Some(Box::new(sr.clone().get_floor_type().0))
|
||||
} else { None },
|
||||
members: members.iter()
|
||||
.map(|SugaredStructMember{symbol,ty}|
|
||||
SugaredStructMember {symbol:symbol.clone(), ty:ty.get_floor_type() })
|
||||
.map(|StructMember{symbol,ty}|
|
||||
StructMember {symbol:symbol.clone(), ty:ty.get_floor_type().0 })
|
||||
.collect()
|
||||
}
|
||||
},
|
||||
TypeTerm::Struct {
|
||||
struct_repr: if let Some(sr) = struct_repr {
|
||||
Some(Box::new(sr.clone().get_floor_type().1))
|
||||
} else { None },
|
||||
members: members.iter()
|
||||
.map(|StructMember{symbol,ty}|
|
||||
StructMember {symbol:symbol.clone(), ty:ty.get_floor_type().1 })
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
*/
|
||||
/*
|
||||
SugaredTypeTerm::Enum { enum_repr, variants } => {
|
||||
SugaredTypeTerm::Enum {
|
||||
enum_repr: if let Some(sr) = enum_repr {
|
||||
|
|
|
@ -85,6 +85,7 @@ fn test_unification() {
|
|||
// this worked easily with desugared terms,
|
||||
// but is a weird edge case with sugared terms
|
||||
// not relevant now
|
||||
|
||||
//test_unify("<Seq T>", "<U Char>", true);
|
||||
|
||||
test_unify(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue