Fix more tests and issues
This commit is contained in:
@@ -2485,7 +2485,7 @@ impl<'a> CodeGenerator<'a> {
|
||||
|
||||
AirTree::clause(
|
||||
test_subject_name.clone(),
|
||||
case.get_air_pattern(),
|
||||
case.get_air_pattern(current_tipo.clone()),
|
||||
current_tipo.clone(),
|
||||
case_air,
|
||||
AirTree::anon_func(vec![], acc, true),
|
||||
|
||||
@@ -53,18 +53,6 @@ impl ToString for Path {
|
||||
}
|
||||
}
|
||||
|
||||
// impl Display for Path {
|
||||
// fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
// match self {
|
||||
// Path::Pair(i) => write!(f, "Pair({})", i),
|
||||
// Path::Tuple(i) => write!(f, "Tuple({})", i),
|
||||
// Path::Constr(_, i) => write!(f, "Constr({})", i),
|
||||
// Path::List(i) => write!(f, "List({})", i),
|
||||
// Path::ListTail(i) => write!(f, "ListTail({})", i),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
impl PartialEq for Path {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match (self, other) {
|
||||
@@ -115,9 +103,15 @@ pub enum CaseTest {
|
||||
}
|
||||
|
||||
impl CaseTest {
|
||||
pub fn get_air_pattern(&self) -> AirTree {
|
||||
pub fn get_air_pattern(&self, current_type: Rc<Type>) -> AirTree {
|
||||
match self {
|
||||
CaseTest::Constr(i) => AirTree::int(i),
|
||||
CaseTest::Constr(i) => {
|
||||
if current_type.is_bool() {
|
||||
AirTree::bool(1 == *i)
|
||||
} else {
|
||||
AirTree::int(i)
|
||||
}
|
||||
}
|
||||
CaseTest::Int(i) => AirTree::int(i),
|
||||
CaseTest::Bytes(vec) => AirTree::byte_array(vec.clone()),
|
||||
CaseTest::List(_) => unreachable!(),
|
||||
@@ -839,13 +833,14 @@ impl<'a, 'b> TreeGen<'a, 'b> {
|
||||
// Add inner patterns to existing row
|
||||
let mut new_cols = remaining_patts.into_iter().flat_map(|x| x.1).collect_vec();
|
||||
|
||||
let added_columns = new_cols.len();
|
||||
|
||||
// Pop off tail so that it aligns more easily with other list patterns
|
||||
if matches!(case, CaseTest::ListWithTail(_)) {
|
||||
new_cols.pop();
|
||||
}
|
||||
|
||||
let added_columns = new_cols.len();
|
||||
|
||||
// Pop off tail so that it aligns more easily with other list patterns
|
||||
|
||||
new_cols.extend(row.columns);
|
||||
|
||||
row.columns = new_cols;
|
||||
|
||||
@@ -23,10 +23,11 @@ pub enum Builtin {
|
||||
impl PartialEq for Builtin {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match (self, other) {
|
||||
(Builtin::HeadList(_), Builtin::HeadList(_)) => true,
|
||||
(Builtin::TailList, Builtin::TailList) => true,
|
||||
(Builtin::UnConstrFields, Builtin::UnConstrFields) => true,
|
||||
(Builtin::SndPair(_), Builtin::SndPair(_)) => true,
|
||||
(Builtin::HeadList(_), Builtin::HeadList(_))
|
||||
| (Builtin::TailList, Builtin::TailList)
|
||||
| (Builtin::UnConstrFields, Builtin::UnConstrFields)
|
||||
| (Builtin::FstPair(_), Builtin::FstPair(_))
|
||||
| (Builtin::SndPair(_), Builtin::SndPair(_)) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@@ -112,7 +113,7 @@ impl Builtins {
|
||||
match i {
|
||||
Path::Pair(i) => {
|
||||
if i == 0 {
|
||||
builtins.push(Builtin::HeadList(get_tipo_by_path(
|
||||
builtins.push(Builtin::FstPair(get_tipo_by_path(
|
||||
subject_tipo.clone(),
|
||||
&rebuilt_path,
|
||||
)));
|
||||
|
||||
Reference in New Issue
Block a user