chore: update changelog
expecting a type on List<Data> from data now only checks that type is a list and not each element
This commit is contained in:
parent
eda388fb29
commit
2f7784f31e
|
@ -11,8 +11,10 @@
|
|||
tree abstraction.
|
||||
- **aiken-lang**: Zero argument anonymous functions now are implemted as a
|
||||
delayed function body and calling them simply does force
|
||||
- **aiken-lang**: Matching on int in expect and when cases is now implemented.
|
||||
- **aiken-lang**: Using assign in nested pattern matches is now implemented.
|
||||
- **aiken-lang**: Matching on int in expect and when cases is now implemented
|
||||
- **aiken-lang**: Using assign in nested pattern matches is now implemented
|
||||
- **aiken-lang**: Using List<Data> as a validator params only checks the type is
|
||||
a list and does not attempt to check each item
|
||||
|
||||
### Optimization
|
||||
|
||||
|
|
|
@ -1212,65 +1212,69 @@ impl<'a> CodeGenerator<'a> {
|
|||
|
||||
let inner_list_type = &tipo.get_inner_types()[0];
|
||||
|
||||
let list_name = format!("__list_span_{}_{}", location.start, location.end);
|
||||
let item_name = format!("__item_span_{}_{}", location.start, location.end);
|
||||
|
||||
let assign = AirTree::let_assignment(&list_name, value);
|
||||
|
||||
let expect_item = self.expect_type_assign(
|
||||
inner_list_type,
|
||||
AirTree::cast_from_data(
|
||||
AirTree::local_var(&item_name, data()),
|
||||
inner_list_type.clone(),
|
||||
),
|
||||
defined_data_types,
|
||||
location,
|
||||
);
|
||||
|
||||
let anon_func_body = expect_item;
|
||||
|
||||
let unwrap_function = AirTree::anon_func(vec![item_name], anon_func_body);
|
||||
|
||||
let function = self.code_gen_functions.get(EXPECT_ON_LIST);
|
||||
|
||||
if function.is_none() {
|
||||
let expect_list_func = AirTree::expect_on_list();
|
||||
self.code_gen_functions.insert(
|
||||
EXPECT_ON_LIST.to_string(),
|
||||
CodeGenFunction::Function {
|
||||
body: expect_list_func,
|
||||
params: vec!["__list_to_check".to_string(), "__check_with".to_string()],
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(counter) = defined_data_types.get_mut(EXPECT_ON_LIST) {
|
||||
*counter += 1
|
||||
if inner_list_type.is_data() {
|
||||
value
|
||||
} else {
|
||||
defined_data_types.insert(EXPECT_ON_LIST.to_string(), 1);
|
||||
}
|
||||
let list_name = format!("__list_span_{}_{}", location.start, location.end);
|
||||
let item_name = format!("__item_span_{}_{}", location.start, location.end);
|
||||
|
||||
let func_call = AirTree::call(
|
||||
AirTree::var(
|
||||
ValueConstructor::public(
|
||||
void(),
|
||||
ValueConstructorVariant::ModuleFn {
|
||||
name: EXPECT_ON_LIST.to_string(),
|
||||
field_map: None,
|
||||
module: "".to_string(),
|
||||
arity: 1,
|
||||
location,
|
||||
builtin: None,
|
||||
},
|
||||
let assign = AirTree::let_assignment(&list_name, value);
|
||||
|
||||
let expect_item = self.expect_type_assign(
|
||||
inner_list_type,
|
||||
AirTree::cast_from_data(
|
||||
AirTree::local_var(&item_name, data()),
|
||||
inner_list_type.clone(),
|
||||
),
|
||||
EXPECT_ON_LIST,
|
||||
"",
|
||||
),
|
||||
void(),
|
||||
vec![AirTree::local_var(list_name, tipo.clone()), unwrap_function],
|
||||
);
|
||||
defined_data_types,
|
||||
location,
|
||||
);
|
||||
|
||||
assign.hoist_over(func_call)
|
||||
let anon_func_body = expect_item;
|
||||
|
||||
let unwrap_function = AirTree::anon_func(vec![item_name], anon_func_body);
|
||||
|
||||
let function = self.code_gen_functions.get(EXPECT_ON_LIST);
|
||||
|
||||
if function.is_none() {
|
||||
let expect_list_func = AirTree::expect_on_list();
|
||||
self.code_gen_functions.insert(
|
||||
EXPECT_ON_LIST.to_string(),
|
||||
CodeGenFunction::Function {
|
||||
body: expect_list_func,
|
||||
params: vec!["__list_to_check".to_string(), "__check_with".to_string()],
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(counter) = defined_data_types.get_mut(EXPECT_ON_LIST) {
|
||||
*counter += 1
|
||||
} else {
|
||||
defined_data_types.insert(EXPECT_ON_LIST.to_string(), 1);
|
||||
}
|
||||
|
||||
let func_call = AirTree::call(
|
||||
AirTree::var(
|
||||
ValueConstructor::public(
|
||||
void(),
|
||||
ValueConstructorVariant::ModuleFn {
|
||||
name: EXPECT_ON_LIST.to_string(),
|
||||
field_map: None,
|
||||
module: "".to_string(),
|
||||
arity: 1,
|
||||
location,
|
||||
builtin: None,
|
||||
},
|
||||
),
|
||||
EXPECT_ON_LIST,
|
||||
"",
|
||||
),
|
||||
void(),
|
||||
vec![AirTree::local_var(list_name, tipo.clone()), unwrap_function],
|
||||
);
|
||||
|
||||
assign.hoist_over(func_call)
|
||||
}
|
||||
} else if tipo.is_2_tuple() {
|
||||
let tuple_inner_types = tipo.get_inner_types();
|
||||
|
||||
|
|
Loading…
Reference in New Issue