From ac14512706cd2be7d9019d069363dbfba174cee1 Mon Sep 17 00:00:00 2001 From: Kasey White Date: Tue, 20 Dec 2022 03:02:33 -0500 Subject: [PATCH] feat: fix nil equals nil, and fix funcs with discard params --- crates/lang/src/uplc.rs | 14 ++++++++++---- examples/acceptance_tests/025/lib/test.ak | 3 +++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/lang/src/uplc.rs b/crates/lang/src/uplc.rs index bd4d1d68..6f79bdcd 100644 --- a/crates/lang/src/uplc.rs +++ b/crates/lang/src/uplc.rs @@ -1837,7 +1837,9 @@ impl<'a> CodeGenerator<'a> { | ArgName::NamedLabeled { name, .. } => { args.push(name.clone()); } - _ => {} + _ => { + args.push("_".to_string()); + } } } let recursive = if let Ok(index) = @@ -2596,6 +2598,9 @@ impl<'a> CodeGenerator<'a> { }; arg_stack.push(term); return; + } else if tipo.is_nil() { + arg_stack.push(Term::Constant(UplcConstant::Bool(true))); + return; } Term::Apply { @@ -2705,9 +2710,7 @@ impl<'a> CodeGenerator<'a> { // arg_stack.push(term); // return; todo!() - } else if tipo.is_list() - || matches!(tipo.get_uplc_type(), UplcType::List(_)) - { + } else if tipo.is_list() { let term = Term::Apply { function: Term::Apply { function: Term::Apply { @@ -2745,6 +2748,9 @@ impl<'a> CodeGenerator<'a> { arg_stack.push(term); return; + } else if tipo.is_nil() { + arg_stack.push(Term::Constant(UplcConstant::Bool(false))); + return; } Term::Apply { diff --git a/examples/acceptance_tests/025/lib/test.ak b/examples/acceptance_tests/025/lib/test.ak index 7375fbd8..3f5d0828 100644 --- a/examples/acceptance_tests/025/lib/test.ak +++ b/examples/acceptance_tests/025/lib/test.ak @@ -1,3 +1,6 @@ +// Should this fail or equal true? +// Should != be false or true? + test nil_1() { Nil == Nil }