feat: handle single constr when with multiple branches
Add case to acceptance test 40 Add special case for top level single constr in a when.
This commit is contained in:
parent
95fce14b75
commit
87eb4ca3b4
|
@ -756,12 +756,29 @@ impl<'a> CodeGenerator<'a> {
|
|||
scope.clone(),
|
||||
);
|
||||
|
||||
ir_stack.push(Air::Clause {
|
||||
scope,
|
||||
tipo: subject_type.clone(),
|
||||
complex_clause: *clause_properties.is_complex_clause(),
|
||||
subject_name,
|
||||
});
|
||||
let data_type =
|
||||
lookup_data_type_by_tipo(self.data_types.clone(), &subject_type).unwrap();
|
||||
|
||||
if data_type.constructors.len() > 1 {
|
||||
ir_stack.push(Air::Clause {
|
||||
scope,
|
||||
tipo: subject_type.clone(),
|
||||
complex_clause: *clause_properties.is_complex_clause(),
|
||||
subject_name,
|
||||
});
|
||||
} else {
|
||||
ir_stack.push(Air::Clause {
|
||||
scope: scope.clone(),
|
||||
tipo: subject_type.clone(),
|
||||
complex_clause: *clause_properties.is_complex_clause(),
|
||||
subject_name,
|
||||
});
|
||||
|
||||
ir_stack.push(Air::Int {
|
||||
scope,
|
||||
value: "0".to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
ClauseProperties::ListClause {
|
||||
original_subject_name,
|
||||
|
|
|
@ -73,3 +73,12 @@ test single_field_expect() {
|
|||
expect CreateVoteBatch { id } = redeemer
|
||||
id == #""
|
||||
}
|
||||
|
||||
test single_when() {
|
||||
let redeemer = CreateVoteBatch { id: #"" }
|
||||
let x = when redeemer is {
|
||||
CreateVoteBatch { id } -> id == #""
|
||||
_ -> False
|
||||
}
|
||||
x == True
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue