Fix minor issues found when testing
This commit is contained in:
parent
4249ef2509
commit
33370b8637
|
@ -1014,6 +1014,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
pattern.location(),
|
pattern.location(),
|
||||||
then,
|
then,
|
||||||
otherwise,
|
otherwise,
|
||||||
|
0,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1056,6 +1057,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
pattern.location(),
|
pattern.location(),
|
||||||
then,
|
then,
|
||||||
otherwise,
|
otherwise,
|
||||||
|
0,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1605,6 +1607,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
location: Span,
|
location: Span,
|
||||||
then: AirTree,
|
then: AirTree,
|
||||||
otherwise: AirTree,
|
otherwise: AirTree,
|
||||||
|
depth: usize,
|
||||||
) -> AirTree {
|
) -> AirTree {
|
||||||
assert!(tipo.get_generic().is_none());
|
assert!(tipo.get_generic().is_none());
|
||||||
// Shouldn't be needed but still here just in case
|
// Shouldn't be needed but still here just in case
|
||||||
|
@ -1647,15 +1650,19 @@ impl<'a> CodeGenerator<'a> {
|
||||||
defined_data_types,
|
defined_data_types,
|
||||||
location,
|
location,
|
||||||
AirTree::call(
|
AirTree::call(
|
||||||
AirTree::local_var("__curried_expect_on_list", void()),
|
AirTree::local_var(format!("__curried_expect_on_list_{}", depth), void()),
|
||||||
void(),
|
void(),
|
||||||
vec![AirTree::builtin(
|
vec![AirTree::builtin(
|
||||||
DefaultFunction::TailList,
|
DefaultFunction::TailList,
|
||||||
list(data()),
|
list(data()),
|
||||||
vec![AirTree::local_var("__list", tipo.clone())],
|
vec![AirTree::local_var(
|
||||||
|
format!("__list_{}", depth),
|
||||||
|
tipo.clone(),
|
||||||
|
)],
|
||||||
)],
|
)],
|
||||||
),
|
),
|
||||||
otherwise.clone(),
|
otherwise.clone(),
|
||||||
|
depth + 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
let expect_fst = self.expect_type_assign(
|
let expect_fst = self.expect_type_assign(
|
||||||
|
@ -1665,19 +1672,28 @@ impl<'a> CodeGenerator<'a> {
|
||||||
location,
|
location,
|
||||||
expect_snd,
|
expect_snd,
|
||||||
otherwise.clone(),
|
otherwise.clone(),
|
||||||
|
depth + 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
let unwrap_function = AirTree::anon_func(
|
let unwrap_function = AirTree::anon_func(
|
||||||
vec!["__list".to_string(), "__curried_expect_on_list".to_string()],
|
vec![
|
||||||
|
format!("__list_{}", depth),
|
||||||
|
format!("__curried_expect_on_list_{}", depth),
|
||||||
|
],
|
||||||
AirTree::list_empty(
|
AirTree::list_empty(
|
||||||
AirTree::local_var("__list", tipo.clone()),
|
AirTree::local_var(format!("__list_{}", depth), tipo.clone()),
|
||||||
then,
|
then,
|
||||||
|
AirTree::anon_func(
|
||||||
|
vec![],
|
||||||
AirTree::let_assignment(
|
AirTree::let_assignment(
|
||||||
&pair_name,
|
&pair_name,
|
||||||
AirTree::builtin(
|
AirTree::builtin(
|
||||||
DefaultFunction::HeadList,
|
DefaultFunction::HeadList,
|
||||||
pair(data(), data()),
|
pair(data(), data()),
|
||||||
vec![AirTree::local_var("__list", tipo.clone())],
|
vec![AirTree::local_var(
|
||||||
|
format!("__list_{}", depth),
|
||||||
|
tipo.clone(),
|
||||||
|
)],
|
||||||
),
|
),
|
||||||
AirTree::pair_access(
|
AirTree::pair_access(
|
||||||
Some(fst_name),
|
Some(fst_name),
|
||||||
|
@ -1689,6 +1705,8 @@ impl<'a> CodeGenerator<'a> {
|
||||||
otherwise.clone(),
|
otherwise.clone(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
true,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
@ -1761,6 +1779,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
location,
|
location,
|
||||||
then,
|
then,
|
||||||
otherwise.clone(),
|
otherwise.clone(),
|
||||||
|
depth + 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
tuple_expect_items.push(tuple_index_name);
|
tuple_expect_items.push(tuple_index_name);
|
||||||
|
@ -1794,9 +1813,12 @@ impl<'a> CodeGenerator<'a> {
|
||||||
let item_name = format!("__item_span_{}_{}", location.start, location.end);
|
let item_name = format!("__item_span_{}_{}", location.start, location.end);
|
||||||
|
|
||||||
let unwrap_function = AirTree::anon_func(
|
let unwrap_function = AirTree::anon_func(
|
||||||
vec!["__list".to_string(), "__curried_expect_on_list".to_string()],
|
vec![
|
||||||
|
format!("__list_{}", depth),
|
||||||
|
format!("__curried_expect_on_list_{}", depth),
|
||||||
|
],
|
||||||
AirTree::list_empty(
|
AirTree::list_empty(
|
||||||
AirTree::local_var("__list", tipo.clone()),
|
AirTree::local_var(format!("__list_{}", depth), tipo.clone()),
|
||||||
then,
|
then,
|
||||||
AirTree::anon_func(
|
AirTree::anon_func(
|
||||||
vec![],
|
vec![],
|
||||||
|
@ -1805,7 +1827,10 @@ impl<'a> CodeGenerator<'a> {
|
||||||
AirTree::builtin(
|
AirTree::builtin(
|
||||||
DefaultFunction::HeadList,
|
DefaultFunction::HeadList,
|
||||||
data(),
|
data(),
|
||||||
vec![AirTree::local_var("__list", tipo.clone())],
|
vec![AirTree::local_var(
|
||||||
|
format!("__list_{}", depth),
|
||||||
|
tipo.clone(),
|
||||||
|
)],
|
||||||
),
|
),
|
||||||
AirTree::soft_cast_assignment(
|
AirTree::soft_cast_assignment(
|
||||||
&item_name,
|
&item_name,
|
||||||
|
@ -1818,7 +1843,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
location,
|
location,
|
||||||
AirTree::call(
|
AirTree::call(
|
||||||
AirTree::local_var(
|
AirTree::local_var(
|
||||||
"__curried_expect_on_list",
|
format!("__curried_expect_on_list_{}", depth),
|
||||||
void(),
|
void(),
|
||||||
),
|
),
|
||||||
void(),
|
void(),
|
||||||
|
@ -1826,12 +1851,13 @@ impl<'a> CodeGenerator<'a> {
|
||||||
DefaultFunction::TailList,
|
DefaultFunction::TailList,
|
||||||
list(data()),
|
list(data()),
|
||||||
vec![AirTree::local_var(
|
vec![AirTree::local_var(
|
||||||
"__list",
|
format!("__list_{}", depth),
|
||||||
tipo.clone(),
|
tipo.clone(),
|
||||||
)],
|
)],
|
||||||
)],
|
)],
|
||||||
),
|
),
|
||||||
otherwise.clone(),
|
otherwise.clone(),
|
||||||
|
depth + 1,
|
||||||
),
|
),
|
||||||
otherwise,
|
otherwise,
|
||||||
),
|
),
|
||||||
|
@ -1908,6 +1934,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
location,
|
location,
|
||||||
then,
|
then,
|
||||||
otherwise.clone(),
|
otherwise.clone(),
|
||||||
|
depth + 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
let expect_fst = self.expect_type_assign(
|
let expect_fst = self.expect_type_assign(
|
||||||
|
@ -1917,6 +1944,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
location,
|
location,
|
||||||
expect_snd,
|
expect_snd,
|
||||||
otherwise.clone(),
|
otherwise.clone(),
|
||||||
|
depth + 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
let pair_access = AirTree::pair_access(
|
let pair_access = AirTree::pair_access(
|
||||||
|
@ -1972,8 +2000,10 @@ impl<'a> CodeGenerator<'a> {
|
||||||
let var_then =
|
let var_then =
|
||||||
AirTree::call(AirTree::local_var("then_delayed", void()), void(), vec![]);
|
AirTree::call(AirTree::local_var("then_delayed", void()), void(), vec![]);
|
||||||
|
|
||||||
|
let otherwise_delayed = AirTree::local_var("otherwise_delayed", void());
|
||||||
|
|
||||||
let constr_clauses = data_type.constructors.iter().enumerate().rfold(
|
let constr_clauses = data_type.constructors.iter().enumerate().rfold(
|
||||||
otherwise.clone(),
|
otherwise_delayed.clone(),
|
||||||
|acc, (index, constr)| {
|
|acc, (index, constr)| {
|
||||||
let mut constr_args = vec![];
|
let mut constr_args = vec![];
|
||||||
|
|
||||||
|
@ -1994,7 +2024,8 @@ impl<'a> CodeGenerator<'a> {
|
||||||
defined_data_types,
|
defined_data_types,
|
||||||
location,
|
location,
|
||||||
then,
|
then,
|
||||||
otherwise.clone(),
|
otherwise_delayed.clone(),
|
||||||
|
depth + 1,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -2010,7 +2041,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
tipo.clone(),
|
tipo.clone(),
|
||||||
),
|
),
|
||||||
constr_then,
|
constr_then,
|
||||||
otherwise.clone(),
|
otherwise_delayed.clone(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
AirTree::fields_expose(
|
AirTree::fields_expose(
|
||||||
|
@ -2024,7 +2055,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
),
|
),
|
||||||
true,
|
true,
|
||||||
constr_then,
|
constr_then,
|
||||||
otherwise.clone(),
|
otherwise_delayed.clone(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1212,7 +1212,8 @@ pub fn list_access_to_uplc(
|
||||||
if name == "_" {
|
if name == "_" {
|
||||||
then
|
then
|
||||||
} else if tipo.is_pair() && is_list_accessor {
|
} else if tipo.is_pair() && is_list_accessor {
|
||||||
Term::head_list().apply(Term::var(tail_name.to_string()))
|
then.lambda(name)
|
||||||
|
.apply(Term::head_list().apply(Term::var(tail_name.to_string())))
|
||||||
} else if matches!(expect_level, ExpectLevel::Full) {
|
} else if matches!(expect_level, ExpectLevel::Full) {
|
||||||
// Expect level is full so we have an unknown piece of data to cast
|
// Expect level is full so we have an unknown piece of data to cast
|
||||||
if otherwise_delayed == Term::Error.delay() {
|
if otherwise_delayed == Term::Error.delay() {
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
use super::TestProject;
|
use super::TestProject;
|
||||||
use crate::module::CheckedModules;
|
use crate::module::CheckedModules;
|
||||||
use aiken_lang::ast::{Definition, Function, TraceLevel, Tracing, TypedTest, TypedValidator};
|
use aiken_lang::ast::{Definition, Function, TraceLevel, Tracing, TypedTest, TypedValidator};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use uplc::{
|
use uplc::{
|
||||||
ast::{Constant, Data, DeBruijn, Name, Program, Term, Type},
|
ast::{Constant, Data, DeBruijn, Name, Program, Term, Type},
|
||||||
builder::{CONSTR_FIELDS_EXPOSER, CONSTR_INDEX_EXPOSER},
|
builder::{CONSTR_FIELDS_EXPOSER, CONSTR_INDEX_EXPOSER, EXPECT_ON_LIST},
|
||||||
machine::{cost_model::ExBudget, runtime::Compressable},
|
machine::{cost_model::ExBudget, runtime::Compressable},
|
||||||
optimize,
|
optimize,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue