fix: switch from unwrap to if let to allow boolean when

fix: test 67 fixed to take in ByteArray instead of string literal
This commit is contained in:
Kasey White 2023-02-20 04:37:33 -05:00
parent 2394438a91
commit 70164282f8
4 changed files with 33 additions and 23 deletions

View File

@ -756,16 +756,29 @@ impl<'a> CodeGenerator<'a> {
scope.clone(),
);
let data_type =
lookup_data_type_by_tipo(self.data_types.clone(), subject_type).unwrap();
let data_type = lookup_data_type_by_tipo(self.data_types.clone(), subject_type);
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,
});
if let Some(data_type) = data_type {
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(),
});
}
} else {
ir_stack.push(Air::Clause {
scope: scope.clone(),
@ -773,11 +786,6 @@ impl<'a> CodeGenerator<'a> {
complex_clause: *clause_properties.is_complex_clause(),
subject_name,
});
ir_stack.push(Air::Int {
scope,
value: "0".to_string(),
});
}
}
ClauseProperties::ListClause {

View File

@ -3,11 +3,11 @@
[[requirements]]
name = "aiken-lang/stdlib"
version = "3b47c89006e7580c2213370d7426ed2a38d2836e"
version = "main"
source = "github"
[[packages]]
name = "aiken-lang/stdlib"
version = "3b47c89006e7580c2213370d7426ed2a38d2836e"
version = "main"
requirements = []
source = "github"

View File

@ -1,6 +1,8 @@
name = "aiken-lang/acceptance_test_067"
version = "0.0.0"
version = '0.0.0'
description = ''
dependencies = [
{ name = "aiken-lang/stdlib", version = "3b47c89006e7580c2213370d7426ed2a38d2836e", source = "github" },
]
[[dependencies]]
name = 'aiken-lang/stdlib'
version = 'main'
source = 'github'

View File

@ -54,7 +54,7 @@ test to_list_1() {
// Function returning a hash of a given Merkle Tree element
pub fn root_hash(self: MerkleTree<a>) -> Hash<Sha2_256, ByteArray> {
when self is {
Empty -> #""
Empty -> ""
Leaf { hash, .. } -> hash
Node { hash, .. } -> hash
}
@ -579,6 +579,6 @@ fn get_proof_item_value(proof_item: ProofItem) -> Hash<Sha2_256, ByteArray> {
}
}
fn create_string_item_hash_fn() -> fn(String) -> Hash<Sha2_256, String> {
fn(x: String) { sha2_256(from_string(x)) }
fn create_string_item_hash_fn() -> fn(ByteArray) -> Hash<Sha2_256, String> {
fn(x: ByteArray) { sha2_256(x) }
}