diff --git a/compiler/passes/src/code_generation/visit_expressions.rs b/compiler/passes/src/code_generation/visit_expressions.rs
index 69e0c48e6d..0855ce3c72 100644
--- a/compiler/passes/src/code_generation/visit_expressions.rs
+++ b/compiler/passes/src/code_generation/visit_expressions.rs
@@ -47,7 +47,6 @@ impl<'a> CodeGenerator<'a> {
}
fn visit_identifier(&mut self, input: &'a Identifier) -> (String, String) {
- println!("{input}");
(self.variable_mapping.get(&input.name).unwrap().clone(), String::new())
}
diff --git a/compiler/passes/src/dead_code_elimination/eliminate_expression.rs b/compiler/passes/src/dead_code_elimination/eliminate_expression.rs
index 12c0f1dc8d..f68d395560 100644
--- a/compiler/passes/src/dead_code_elimination/eliminate_expression.rs
+++ b/compiler/passes/src/dead_code_elimination/eliminate_expression.rs
@@ -14,12 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use crate::{DeadCodeEliminator};
+use crate::DeadCodeEliminator;
-use leo_ast::{
- Expression, ExpressionReconstructor, Identifier,
- StructExpression, StructVariableInitializer,
-};
+use leo_ast::{Expression, ExpressionReconstructor, Identifier, StructExpression, StructVariableInitializer};
impl ExpressionReconstructor for DeadCodeEliminator {
type AdditionalOutput = ();
diff --git a/compiler/passes/src/dead_code_elimination/eliminate_statement.rs b/compiler/passes/src/dead_code_elimination/eliminate_statement.rs
index c3430bfcca..a25872d345 100644
--- a/compiler/passes/src/dead_code_elimination/eliminate_statement.rs
+++ b/compiler/passes/src/dead_code_elimination/eliminate_statement.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use crate::{DeadCodeEliminator};
+use crate::DeadCodeEliminator;
use leo_ast::{
AssertStatement, AssertVariant, AssignStatement, Block, ConditionalStatement, ConsoleStatement, DecrementStatement,
@@ -69,9 +69,6 @@ impl StatementReconstructor for DeadCodeEliminator {
),
};
- println!("self.used_variables: {:?}", self.used_variables);
- println!("Statement: {}, lhs_is_used: {:?}", input, lhs_is_used);
-
match lhs_is_used {
// If the lhs is used, then we return the original statement.
true => {
@@ -102,10 +99,7 @@ impl StatementReconstructor for DeadCodeEliminator {
.statements
.into_iter()
.rev()
- .map(|statement| {
- println!("Reconstructing statement: {}", statement);
- self.reconstruct_statement(statement).0
- })
+ .map(|statement| self.reconstruct_statement(statement).0)
.collect();
// Reverse the direction of `statements`.
diff --git a/tests/expectations/compiler/function/dead_code_elimination.out b/tests/expectations/compiler/function/dead_code_elimination.out
new file mode 100644
index 0000000000..25bb6b0c8e
--- /dev/null
+++ b/tests/expectations/compiler/function/dead_code_elimination.out
@@ -0,0 +1,11 @@
+---
+namespace: Compile
+expectation: Pass
+outputs:
+ - initial_ast: d7414ef76b5d83ba8daed6e65487425048596937d5a6f783a313d3264d5db267
+ unrolled_ast: d7414ef76b5d83ba8daed6e65487425048596937d5a6f783a313d3264d5db267
+ ssa_ast: 6722ef50ccdf19eaaa57f68a249a6eb01ba78ec8ec60da0d8d664613324287aa
+ flattened_ast: 58ed29011b87aad89fe50f62402f441c9aa53fc2e18c3a188d94d0a88734236d
+ inlined_ast: 1c57a7047a0523c5f576e5df33fa9b70cf2baedfb8149266686837ba2827c44e
+ dce_ast: 48e52aa4ba7d5f4c5126ec93a14ec29772f80c73cc2d6ab5c77001f920b4c65b
+ bytecode: 0bc43312bbddd72a443eddc893fb31630e9a29db8a6c6cadf79c4ed79f054ae4
diff --git a/tests/tests/compiler/function/dead_code_elimination.leo b/tests/tests/compiler/function/dead_code_elimination.leo
new file mode 100644
index 0000000000..73d3ea66e4
--- /dev/null
+++ b/tests/tests/compiler/function/dead_code_elimination.leo
@@ -0,0 +1,59 @@
+/*
+namespace: Compile
+expectation: Pass
+*/
+
+/*
+The program should produce the following bytecode:
+
+program test.aleo;
+
+record dummy:
+ owner as address.private;
+ gates as u64.private;
+ data as u8.private;
+
+closure eliminate_unused_function_call:
+ input r0 as u8;
+ input r1 as u8;
+ add r0 r1 into r2;
+ output r2 as u8;
+
+function foo:
+ input r0 as u8.private;
+ input r1 as u8.private;
+ add r0 r1 into r2;
+ output r2 as u8.private;
+*/
+
+program test.aleo {
+
+ record dummy {
+ owner: address,
+ gates: u64,
+ data: u8,
+ }
+
+ function eliminate_unused_function_call(a: u8, b: u8) -> u8 {
+ return a + b;
+ }
+
+ inline inline_and_eliminate(a: u8, b: u8) -> u8 {
+ return a * b;
+ }
+
+ transition foo(a: u8, b: u8) -> u8 {
+ let c: u8 = a + b;
+ let d: u8 = eliminate_unused_function_call(a, b);
+ let e: u8 = 0u8;
+ if (a == b) {
+ e = inline_and_eliminate(a, b);
+ }
+ let f: dummy = dummy {
+ owner: self.caller,
+ gates: 0u64,
+ data: e,
+ };
+ return a + b;
+ }
+}