diff --git a/compiler/passes/src/code_generation/generator.rs b/compiler/passes/src/code_generation/generator.rs index e9e4c8619f..9166ff33e7 100644 --- a/compiler/passes/src/code_generation/generator.rs +++ b/compiler/passes/src/code_generation/generator.rs @@ -53,6 +53,10 @@ pub struct CodeGenerator<'a> { pub(crate) program: &'a Program, // The program ID of the current program. pub(crate) program_id: Option, + /// A counter to track the next available label. + pub(crate) next_label: u64, + /// The depth of the current conditional block. + pub(crate) conditional_depth: u64, } impl<'a> CodeGenerator<'a> { @@ -80,6 +84,8 @@ impl<'a> CodeGenerator<'a> { futures: Vec::new(), program, program_id: None, + next_label: 0u64, + conditional_depth: 0u64, } } } diff --git a/compiler/passes/src/code_generation/visit_statements.rs b/compiler/passes/src/code_generation/visit_statements.rs index 61343ad8be..39f65557e6 100644 --- a/compiler/passes/src/code_generation/visit_statements.rs +++ b/compiler/passes/src/code_generation/visit_statements.rs @@ -220,12 +220,59 @@ impl<'a> CodeGenerator<'a> { } fn visit_conditional(&mut self, _input: &'a ConditionalStatement) -> String { - // TODO: Once SSA is made optional, create a Leo error informing the user to enable the SSA pass. - unreachable!("`ConditionalStatement`s should not be in the AST at this phase of compilation.") + if !self.in_finalize { + unreachable!("`ConditionalStatement`s should not be in the AST at this phase of compilation.") + } else { + // Construct a label for the end of the `then` block. + let end_then_label = format!("end_then_{}_{}", self.conditional_depth, self.next_label); + self.next_label += 1; + // Construct a label for the end of the `otherwise` block if it exists. + let (has_otherwise, end_otherwise_label) = { + match _input.otherwise.is_some() { + true => { + // Construct a label for the end of the `otherwise` block. + let end_otherwise_label = + { format!("end_otherwise_{}_{}", self.conditional_depth, self.next_label) }; + self.next_label += 1; + (true, end_otherwise_label) + } + false => (false, String::new()), + } + }; + + // Increment the conditional depth. + self.conditional_depth += 1; + + // Create a `branch` instruction. + let (condition, mut instructions) = self.visit_expression(&_input.condition); + instructions.push_str(&format!(" branch.eq {condition} false to {end_then_label};\n")); + + // Visit the `then` block. + instructions.push_str(&self.visit_block(&_input.then)); + // If the `otherwise` block is present, add a branch instruction to jump to the end of the `otherwise` block. + if has_otherwise { + instructions.push_str(&format!(" branch.eq true true to {end_otherwise_label};\n")); + } + + // Add a label for the end of the `then` block. + instructions.push_str(&format!(" position {};\n", end_then_label)); + + // Visit the `otherwise` block. + if let Some(else_block) = &_input.otherwise { + // Visit the `otherwise` block. + instructions.push_str(&self.visit_statement(else_block)); + // Add a label for the end of the `otherwise` block. + instructions.push_str(&format!(" position {end_otherwise_label};\n")); + } + + // Decrement the conditional depth. + self.conditional_depth -= 1; + + instructions + } } fn visit_iteration(&mut self, _input: &'a IterationStatement) -> String { - // TODO: Once loop unrolling is made optional, create a Leo error informing the user to enable the loop unrolling pass.. unreachable!("`IterationStatement`s should not be in the AST at this phase of compilation."); } diff --git a/compiler/passes/src/common/symbol_table/mod.rs b/compiler/passes/src/common/symbol_table/mod.rs index c8ed24dc79..698bf077c4 100644 --- a/compiler/passes/src/common/symbol_table/mod.rs +++ b/compiler/passes/src/common/symbol_table/mod.rs @@ -181,6 +181,11 @@ impl SymbolTable { } } + /// Attempts to lookup a variable in the current scope. + pub fn lookup_variable_in_current_scope(&self, location: Location) -> Option<&VariableSymbol> { + self.variables.get(&location) + } + /// Returns the scope associated with `index`, if it exists in the symbol table. pub fn lookup_scope_by_index(&self, index: usize) -> Option<&RefCell> { self.scopes.get(index) diff --git a/compiler/passes/src/dead_code_elimination/dead_code_eliminator.rs b/compiler/passes/src/dead_code_elimination/dead_code_eliminator.rs index e033a57138..732b999b04 100644 --- a/compiler/passes/src/dead_code_elimination/dead_code_eliminator.rs +++ b/compiler/passes/src/dead_code_elimination/dead_code_eliminator.rs @@ -26,11 +26,13 @@ pub struct DeadCodeEliminator<'a> { pub(crate) used_variables: IndexSet, /// Whether or not the variables are necessary. pub(crate) is_necessary: bool, + /// Whether or not we are currently traversing a finalize block. + pub(crate) is_finalize: bool, } impl<'a> DeadCodeEliminator<'a> { /// Initializes a new `DeadCodeEliminator`. pub fn new(node_builder: &'a NodeBuilder) -> Self { - Self { node_builder, used_variables: Default::default(), is_necessary: false } + Self { node_builder, used_variables: Default::default(), is_necessary: false, is_finalize: false } } } diff --git a/compiler/passes/src/dead_code_elimination/eliminate_program.rs b/compiler/passes/src/dead_code_elimination/eliminate_program.rs index 3cbbf05357..b6b26f3cb4 100644 --- a/compiler/passes/src/dead_code_elimination/eliminate_program.rs +++ b/compiler/passes/src/dead_code_elimination/eliminate_program.rs @@ -33,9 +33,15 @@ impl ProgramReconstructor for DeadCodeEliminator<'_> { self.used_variables.clear(); self.is_necessary = false; + // Set the `is_finalize` flag. + self.is_finalize = true; + // Traverse the finalize block. let block = self.reconstruct_block(finalize.block).0; + // Reset the `is_finalize` flag. + self.is_finalize = false; + Finalize { identifier: finalize.identifier, input: finalize.input, diff --git a/compiler/passes/src/dead_code_elimination/eliminate_statement.rs b/compiler/passes/src/dead_code_elimination/eliminate_statement.rs index 4eeaf0d244..ce1accc898 100644 --- a/compiler/passes/src/dead_code_elimination/eliminate_statement.rs +++ b/compiler/passes/src/dead_code_elimination/eliminate_statement.rs @@ -117,8 +117,29 @@ impl StatementReconstructor for DeadCodeEliminator<'_> { } /// Flattening removes conditional statements from the program. - fn reconstruct_conditional(&mut self, _: ConditionalStatement) -> (Statement, Self::AdditionalOutput) { - unreachable!("`ConditionalStatement`s should not be in the AST at this phase of compilation.") + fn reconstruct_conditional(&mut self, input: ConditionalStatement) -> (Statement, Self::AdditionalOutput) { + if !self.is_finalize { + unreachable!("`ConditionalStatement`s should not be in the AST at this phase of compilation.") + } else { + ( + Statement::Conditional(ConditionalStatement { + then: self.reconstruct_block(input.then).0, + otherwise: input.otherwise.map(|n| Box::new(self.reconstruct_statement(*n).0)), + condition: { + // Set the `is_necessary` flag. + self.is_necessary = true; + let condition = self.reconstruct_expression(input.condition).0; + // Unset the `is_necessary` flag. + self.is_necessary = false; + + condition + }, + span: input.span, + id: input.id, + }), + Default::default(), + ) + } } /// Parsing guarantees that console statements are not present in the program. diff --git a/compiler/passes/src/destructuring/destructure_program.rs b/compiler/passes/src/destructuring/destructure_program.rs index 0809fc68a6..c09a548660 100644 --- a/compiler/passes/src/destructuring/destructure_program.rs +++ b/compiler/passes/src/destructuring/destructure_program.rs @@ -16,6 +16,37 @@ use crate::Destructurer; -use leo_ast::ProgramReconstructor; +use leo_ast::{Finalize, Function, ProgramReconstructor, StatementReconstructor}; -impl ProgramReconstructor for Destructurer<'_> {} +impl ProgramReconstructor for Destructurer<'_> { + fn reconstruct_function(&mut self, input: Function) -> Function { + Function { + annotations: input.annotations, + variant: input.variant, + identifier: input.identifier, + input: input.input, + output: input.output, + output_type: input.output_type, + block: self.reconstruct_block(input.block).0, + finalize: input.finalize.map(|finalize| { + // Set the `is_finalize` flag before reconstructing the finalize block. + self.is_finalize = true; + // Reconstruct the finalize block. + let finalize = Finalize { + identifier: finalize.identifier, + input: finalize.input, + output: finalize.output, + output_type: finalize.output_type, + block: self.reconstruct_block(finalize.block).0, + span: finalize.span, + id: finalize.id, + }; + // Reset the `is_finalize` flag. + self.is_finalize = false; + finalize + }), + span: input.span, + id: input.id, + } + } +} diff --git a/compiler/passes/src/destructuring/destructure_statement.rs b/compiler/passes/src/destructuring/destructure_statement.rs index c5cd99cd92..cfd383733b 100644 --- a/compiler/passes/src/destructuring/destructure_statement.rs +++ b/compiler/passes/src/destructuring/destructure_statement.rs @@ -220,8 +220,22 @@ impl StatementReconstructor for Destructurer<'_> { (Block { span: block.span, statements, id: self.node_builder.next_id() }, Default::default()) } - fn reconstruct_conditional(&mut self, _: ConditionalStatement) -> (Statement, Self::AdditionalOutput) { - unreachable!("`ConditionalStatement`s should not be in the AST at this phase of compilation.") + fn reconstruct_conditional(&mut self, input: ConditionalStatement) -> (Statement, Self::AdditionalOutput) { + // Conditional statements can only exist in finalize blocks. + if !self.is_finalize { + unreachable!("`ConditionalStatement`s should not be in the AST at this phase of compilation.") + } else { + ( + Statement::Conditional(ConditionalStatement { + condition: self.reconstruct_expression(input.condition).0, + then: self.reconstruct_block(input.then).0, + otherwise: input.otherwise.map(|n| Box::new(self.reconstruct_statement(*n).0)), + span: input.span, + id: input.id, + }), + Default::default(), + ) + } } fn reconstruct_console(&mut self, _: ConsoleStatement) -> (Statement, Self::AdditionalOutput) { diff --git a/compiler/passes/src/destructuring/destructurer.rs b/compiler/passes/src/destructuring/destructurer.rs index 6d61f3ea30..14f8b91e90 100644 --- a/compiler/passes/src/destructuring/destructurer.rs +++ b/compiler/passes/src/destructuring/destructurer.rs @@ -30,11 +30,13 @@ pub struct Destructurer<'a> { pub(crate) assigner: &'a Assigner, /// A mapping between variables and flattened tuple expressions. pub(crate) tuples: IndexMap, + /// Whether or not we are currently traversing a finalize block. + pub(crate) is_finalize: bool, } impl<'a> Destructurer<'a> { pub(crate) fn new(type_table: &'a TypeTable, node_builder: &'a NodeBuilder, assigner: &'a Assigner) -> Self { - Self { type_table, node_builder, assigner, tuples: IndexMap::new() } + Self { type_table, node_builder, assigner, tuples: IndexMap::new(), is_finalize: false } } /// A wrapper around `assigner.simple_assign_statement` that tracks the type of the lhs. diff --git a/compiler/passes/src/flattening/flatten_program.rs b/compiler/passes/src/flattening/flatten_program.rs index a23f0027e5..d6290de9a7 100644 --- a/compiler/passes/src/flattening/flatten_program.rs +++ b/compiler/passes/src/flattening/flatten_program.rs @@ -16,7 +16,7 @@ use crate::Flattener; -use leo_ast::{Finalize, Function, ProgramReconstructor, ProgramScope, Statement, StatementReconstructor}; +use leo_ast::{Function, ProgramReconstructor, ProgramScope, Statement, StatementReconstructor}; impl ProgramReconstructor for Flattener<'_> { /// Flattens a program scope. @@ -40,30 +40,8 @@ impl ProgramReconstructor for Flattener<'_> { } /// Flattens a function's body and finalize block, if it exists. + /// Note that the finalize block is not flattened since it uses `branch` instructions to produce correct code in for conditional execution. fn reconstruct_function(&mut self, function: Function) -> Function { - // First, flatten the finalize block. This allows us to initialize self.finalizes correctly. - // Note that this is safe since the finalize block is independent of the function body. - let finalize = function.finalize.map(|finalize| { - // Flatten the finalize block. - let mut block = self.reconstruct_block(finalize.block).0; - - // Get all of the guards and return expression. - let returns = self.clear_early_returns(); - - // Fold the return statements into the block. - self.fold_returns(&mut block, returns); - - Finalize { - identifier: finalize.identifier, - input: finalize.input, - output: finalize.output, - output_type: finalize.output_type, - block, - span: finalize.span, - id: finalize.id, - } - }); - // Flatten the function body. let mut block = self.reconstruct_block(function.block).0; @@ -81,7 +59,7 @@ impl ProgramReconstructor for Flattener<'_> { output: function.output, output_type: function.output_type, block, - finalize, + finalize: function.finalize, span: function.span, id: function.id, } diff --git a/compiler/passes/src/flattening/mod.rs b/compiler/passes/src/flattening/mod.rs index 2586b28ce1..ac35cdb12b 100644 --- a/compiler/passes/src/flattening/mod.rs +++ b/compiler/passes/src/flattening/mod.rs @@ -18,6 +18,7 @@ //! The pass flattens `ConditionalStatement`s into a sequence of `AssignStatement`s. //! The pass rewrites `ReturnStatement`s into `AssignStatement`s and consolidates the returned values as a single `ReturnStatement` at the end of the function. //! The pass rewrites ternary expressions over composite data types, into ternary expressions over the individual fields of the composite data type, followed by an expression constructing the composite data type. +//! Note that this transformation is only applied to non-finalize code. //! //! Consider the following Leo code, output by the SSA pass. //! ```leo diff --git a/compiler/passes/src/function_inlining/function_inliner.rs b/compiler/passes/src/function_inlining/function_inliner.rs index 69163cb1ca..0c24e719df 100644 --- a/compiler/passes/src/function_inlining/function_inliner.rs +++ b/compiler/passes/src/function_inlining/function_inliner.rs @@ -32,6 +32,8 @@ pub struct FunctionInliner<'a> { pub(crate) reconstructed_functions: Vec<(Symbol, Function)>, /// The main program. pub(crate) program: Option, + /// Whether or not we are currently traversing a finalize block. + pub(crate) is_finalize: bool, } impl<'a> FunctionInliner<'a> { @@ -49,6 +51,7 @@ impl<'a> FunctionInliner<'a> { reconstructed_functions: Default::default(), type_table, program: None, + is_finalize: false, } } } diff --git a/compiler/passes/src/function_inlining/inline_program.rs b/compiler/passes/src/function_inlining/inline_program.rs index 6494b7c7a6..ab4cd649fb 100644 --- a/compiler/passes/src/function_inlining/inline_program.rs +++ b/compiler/passes/src/function_inlining/inline_program.rs @@ -16,7 +16,7 @@ use crate::FunctionInliner; -use leo_ast::{Function, ProgramReconstructor, ProgramScope}; +use leo_ast::{Finalize, Function, ProgramReconstructor, ProgramScope, StatementReconstructor}; use leo_span::Symbol; use indexmap::IndexMap; @@ -60,4 +60,35 @@ impl ProgramReconstructor for FunctionInliner<'_> { span: input.span, } } + + fn reconstruct_function(&mut self, input: Function) -> Function { + Function { + annotations: input.annotations, + variant: input.variant, + identifier: input.identifier, + input: input.input, + output: input.output, + output_type: input.output_type, + block: self.reconstruct_block(input.block).0, + finalize: input.finalize.map(|finalize| { + // Set the `is_finalize` flag before reconstructing the finalize block. + self.is_finalize = true; + // Reconstruct the finalize block. + let finalize = Finalize { + identifier: finalize.identifier, + input: finalize.input, + output: finalize.output, + output_type: finalize.output_type, + block: self.reconstruct_block(finalize.block).0, + span: finalize.span, + id: finalize.id, + }; + // Reset the `is_finalize` flag. + self.is_finalize = false; + finalize + }), + span: input.span, + id: input.id, + } + } } diff --git a/compiler/passes/src/function_inlining/inline_statement.rs b/compiler/passes/src/function_inlining/inline_statement.rs index ad1031da4f..f5f9d3012e 100644 --- a/compiler/passes/src/function_inlining/inline_statement.rs +++ b/compiler/passes/src/function_inlining/inline_statement.rs @@ -70,8 +70,21 @@ impl StatementReconstructor for FunctionInliner<'_> { } /// Flattening removes conditional statements from the program. - fn reconstruct_conditional(&mut self, _: ConditionalStatement) -> (Statement, Self::AdditionalOutput) { - unreachable!("`ConditionalStatement`s should not be in the AST at this phase of compilation.") + fn reconstruct_conditional(&mut self, input: ConditionalStatement) -> (Statement, Self::AdditionalOutput) { + if !self.is_finalize { + unreachable!("`ConditionalStatement`s should not be in the AST at this phase of compilation.") + } else { + ( + Statement::Conditional(ConditionalStatement { + condition: self.reconstruct_expression(input.condition).0, + then: self.reconstruct_block(input.then).0, + otherwise: input.otherwise.map(|n| Box::new(self.reconstruct_statement(*n).0)), + span: input.span, + id: input.id, + }), + Default::default(), + ) + } } /// Parsing guarantees that console statements are not present in the program. diff --git a/compiler/passes/src/type_checking/check_statements.rs b/compiler/passes/src/type_checking/check_statements.rs index 5da1e549b9..09b2822a2f 100644 --- a/compiler/passes/src/type_checking/check_statements.rs +++ b/compiler/passes/src/type_checking/check_statements.rs @@ -68,21 +68,33 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> { } }; - let var_type = if let Some(var) = - self.symbol_table.borrow_mut().lookup_variable(Location::new(None, var_name.name)) + // Lookup the variable in the symbol table and retrieve its type. + let var_type = if let Some(var) = self.symbol_table.borrow().lookup_variable(Location::new(None, var_name.name)) { + // If the variable exists, then check that it is not a constant. match &var.declaration { VariableType::Const => self.emit_err(TypeCheckerError::cannot_assign_to_const_var(var_name, var.span)), VariableType::Input(Mode::Constant) => { self.emit_err(TypeCheckerError::cannot_assign_to_const_input(var_name, var.span)) } - _ => {} + VariableType::Mut | VariableType::Input(_) => {} + } + + // If the variable exists and its in a finalize, then check that it is in the current scope. + if self.is_finalize + && self.is_conditional + && self + .symbol_table + .borrow() + .lookup_variable_in_current_scope(Location::new(None, var_name.name)) + .is_none() + { + self.emit_err(TypeCheckerError::finalize_cannot_assign_outside_conditional(var_name, var.span)); } Some(var.type_.clone()) } else { self.emit_err(TypeCheckerError::unknown_sym("variable", var_name.name, var_name.span)); - None }; @@ -114,6 +126,8 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> { let previous_has_return = core::mem::replace(&mut self.has_return, then_block_has_return); // Set the `has_finalize` flag for the then-block. let previous_has_finalize = core::mem::replace(&mut self.has_finalize, then_block_has_finalize); + // Set the `is_conditional` flag. + let previous_is_conditional = core::mem::replace(&mut self.is_conditional, true); self.visit_block(&input.then); @@ -147,6 +161,8 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> { self.has_return = previous_has_return || (then_block_has_return && otherwise_block_has_return); // Restore the previous `has_finalize` flag. self.has_finalize = previous_has_finalize || (then_block_has_finalize && otherwise_block_has_finalize); + // Restore the previous `is_conditional` flag. + self.is_conditional = previous_is_conditional; } fn visit_console(&mut self, _: &'a ConsoleStatement) { diff --git a/compiler/passes/src/type_checking/checker.rs b/compiler/passes/src/type_checking/checker.rs index be2dfa3ecc..6f047c2441 100644 --- a/compiler/passes/src/type_checking/checker.rs +++ b/compiler/passes/src/type_checking/checker.rs @@ -69,6 +69,8 @@ pub struct TypeChecker<'a> { pub(crate) is_stub: bool, /// The set of used composites. pub(crate) used_structs: IndexSet, + /// Whether or not we are currently traversing a conditional statement. + pub(crate) is_conditional: bool, } const ADDRESS_TYPE: Type = Type::Address; @@ -138,6 +140,7 @@ impl<'a> TypeChecker<'a> { program_name: None, is_stub: true, used_structs: IndexSet::new(), + is_conditional: false, } } diff --git a/errors/src/errors/type_checker/type_checker_error.rs b/errors/src/errors/type_checker/type_checker_error.rs index 854489acf7..934ce86d55 100644 --- a/errors/src/errors/type_checker/type_checker_error.rs +++ b/errors/src/errors/type_checker/type_checker_error.rs @@ -775,4 +775,11 @@ create_messages!( msg: format!("Cannot use operation `{operation}` on external mapping."), help: Some("The only valid operations on external mappings are get, and get_or_use.".to_string()), } + + @formatted + finalize_cannot_assign_outside_conditional { + args: (variable: impl Display), + msg: format!("Cannot re-assign to `{variable}` from a conditional scope to an outer scope in a finalize block."), + help: Some("This is a fundamental restriction that can often be avoided by using a ternary operator `?` or re-declaring the variable in the current scope. In the future, ARC XXXX (https://github.com/AleoHQ/ARCs) will support more complex assignments in finalize blocks.".to_string()), + } ); diff --git a/tests/expectations/compiler/array/array_in_finalize.out b/tests/expectations/compiler/array/array_in_finalize.out index c3763b9f9c..86d965d807 100644 --- a/tests/expectations/compiler/array/array_in_finalize.out +++ b/tests/expectations/compiler/array/array_in_finalize.out @@ -9,10 +9,10 @@ outputs: initial_ast: 46b97966bd59f7f2ef2a8e9db3276ecccfb56cae533e223e8664aa40b7cd976f unrolled_ast: 46b97966bd59f7f2ef2a8e9db3276ecccfb56cae533e223e8664aa40b7cd976f ssa_ast: dc2456142b747ad537b8c8f4f454d902a63be4fd33ea0e3995b32d3e27696b6f - flattened_ast: 2d565c001d469769cf49641c76479052f64cf856f5d881447904bab5c59c10c5 - destructured_ast: 6895090c4dbf3184e19aab7b93fc582e93a1127e1dd0c27c27a6543c5f2c3cc2 - inlined_ast: 6895090c4dbf3184e19aab7b93fc582e93a1127e1dd0c27c27a6543c5f2c3cc2 - dce_ast: 6895090c4dbf3184e19aab7b93fc582e93a1127e1dd0c27c27a6543c5f2c3cc2 + flattened_ast: 97e88581628c88cb5041806210a506045c89e331d65f9565b31c7bf78fd28505 + destructured_ast: 71dda6bb1090bef21d053bd16480c533355595bf7a4361d706ce576236c3e561 + inlined_ast: 71dda6bb1090bef21d053bd16480c533355595bf7a4361d706ce576236c3e561 + dce_ast: 71dda6bb1090bef21d053bd16480c533355595bf7a4361d706ce576236c3e561 bytecode: 66a857f6a5e79328d146c55f5e42c6eb249b7c6c9cc1c6e0c534328b85e649eb errors: "" warnings: "" diff --git a/tests/expectations/compiler/array/array_in_mapping.out b/tests/expectations/compiler/array/array_in_mapping.out index 7fc1810321..1f4e61ff26 100644 --- a/tests/expectations/compiler/array/array_in_mapping.out +++ b/tests/expectations/compiler/array/array_in_mapping.out @@ -9,10 +9,10 @@ outputs: initial_ast: d22023292a932c574e079af02a3fe01dbef4d23182af231295a5ac416624f327 unrolled_ast: d22023292a932c574e079af02a3fe01dbef4d23182af231295a5ac416624f327 ssa_ast: d22023292a932c574e079af02a3fe01dbef4d23182af231295a5ac416624f327 - flattened_ast: 39bd6072b1337e8dbb155c7e86c21d96d8364c68740b17728f408080ac66bcc9 - destructured_ast: 7eecab738122e55b5bf7e6d0cfef6dbb0d4a7de524cf3d259e7990825c9e37e0 - inlined_ast: 7eecab738122e55b5bf7e6d0cfef6dbb0d4a7de524cf3d259e7990825c9e37e0 - dce_ast: 7eecab738122e55b5bf7e6d0cfef6dbb0d4a7de524cf3d259e7990825c9e37e0 + flattened_ast: 7849fd84194fbc2e18cf12f92a9bee03f9e8cc88345df61dec47f060d6f3d463 + destructured_ast: e2470df3c2ccb69bf2f164ea073e332d5a67c11436833f0503169b0339f92ab5 + inlined_ast: e2470df3c2ccb69bf2f164ea073e332d5a67c11436833f0503169b0339f92ab5 + dce_ast: e2470df3c2ccb69bf2f164ea073e332d5a67c11436833f0503169b0339f92ab5 bytecode: bbabb76319d2c69ed28a19090796ad7f974be74a1ef138d0cc58507cc4787632 errors: "" warnings: "" diff --git a/tests/expectations/compiler/constants/constant_finalize.out b/tests/expectations/compiler/constants/constant_finalize.out index b18e1ab585..20bd22da8d 100644 --- a/tests/expectations/compiler/constants/constant_finalize.out +++ b/tests/expectations/compiler/constants/constant_finalize.out @@ -9,10 +9,10 @@ outputs: initial_ast: 3c93df9e002456e3280997e691a26070059d00b3360aedfa21eadbf6ac874d55 unrolled_ast: c7e2d16c2f3925ca9c070c3c5e732afa2da488bec9913c2c1d60253fb3864e58 ssa_ast: 86d0e28c9fb58f62f297380f63bb1d82dbd31dea4b3bacaf2b78def816cc40f7 - flattened_ast: 4a7a83f06568768bd98e016848ed4251137b17893958c0f43f54ba06b9733726 - destructured_ast: dbe3ea662e64e6eacfc1575104c0135faa98fe36a0387a7ff3c652e7bb7498b9 - inlined_ast: dbe3ea662e64e6eacfc1575104c0135faa98fe36a0387a7ff3c652e7bb7498b9 - dce_ast: dbe3ea662e64e6eacfc1575104c0135faa98fe36a0387a7ff3c652e7bb7498b9 + flattened_ast: f4dacdcab926d687a4f80ac491f9d8be747f18f067db603f35ccbd9800804fde + destructured_ast: 3324379561b920162a9510e6608a5f4f4f4f7be8df7507897292d26261a4f48f + inlined_ast: 3324379561b920162a9510e6608a5f4f4f4f7be8df7507897292d26261a4f48f + dce_ast: 3324379561b920162a9510e6608a5f4f4f4f7be8df7507897292d26261a4f48f bytecode: 34335e40c3ca26e00044d055cc0cb8d262fce1ac49a4940b36b1136e0772d305 errors: "" warnings: "" diff --git a/tests/expectations/compiler/examples/basic_bank.out b/tests/expectations/compiler/examples/basic_bank.out index e6ee212639..b7bf7387b5 100644 --- a/tests/expectations/compiler/examples/basic_bank.out +++ b/tests/expectations/compiler/examples/basic_bank.out @@ -9,10 +9,10 @@ outputs: initial_ast: 579697d492aea0987211cee47e9c9f2071010c3231a95a51d7f74c553fee7f10 unrolled_ast: b6dd96e88085733fd3ac7edee137e379c158c987570e453f68acbb71465ca781 ssa_ast: 69fe5fe4fa856413a0e16e9c28dd3f280d90a0ed936324f4ebeea49f4acc90ee - flattened_ast: 357675d996d321c401ac4f5541baeb3b43da3f5f6e2d58615660040a5d6ced66 - destructured_ast: 80ebc5eaf0c549fce8e2898e97f75465f150636bec9f021c80d90d5c2e32fc86 - inlined_ast: 463bb4e435626c20b19009f4663c79349df712a9893f40c324f3d1e091d26fe4 - dce_ast: 463bb4e435626c20b19009f4663c79349df712a9893f40c324f3d1e091d26fe4 + flattened_ast: a71aa3203192639eb05b7a2074230211002d5cda95c2e05383b2b187491c7ac0 + destructured_ast: ae1b58fb26a8532993ab2eb9f3baae3f5ad718aa99bfdb794690883f4ecf719a + inlined_ast: ebcb03ac587c9b1c75dac698ba51b92a17c864b1b414c81c227154735d0d986b + dce_ast: ebcb03ac587c9b1c75dac698ba51b92a17c864b1b414c81c227154735d0d986b bytecode: 799c84f9a28bcdd1cb72269b56baae0905a136fc2d041745fb7ae52c9958b24e errors: "" warnings: "" diff --git a/tests/expectations/compiler/examples/lottery.out b/tests/expectations/compiler/examples/lottery.out index ca1354390b..6e7ef08b3b 100644 --- a/tests/expectations/compiler/examples/lottery.out +++ b/tests/expectations/compiler/examples/lottery.out @@ -9,10 +9,10 @@ outputs: initial_ast: 21db026676b02baa0d131a215daa74249bb578f1768855ffce41b09458340033 unrolled_ast: 21db026676b02baa0d131a215daa74249bb578f1768855ffce41b09458340033 ssa_ast: 7b3a647dfdd6ef643d5710df4ead3b98d93025b1f0264382bfff2c24e55d1cb8 - flattened_ast: 44ab04585ea1c64b2de3c687ad4c38344754258ee8ab0d55bae15d5e5eddc69b - destructured_ast: 0464cd29a1a8c44bdd1c880d3fcae6211a3699042e2e765292e48e1ec57c30cd - inlined_ast: 0464cd29a1a8c44bdd1c880d3fcae6211a3699042e2e765292e48e1ec57c30cd - dce_ast: 0464cd29a1a8c44bdd1c880d3fcae6211a3699042e2e765292e48e1ec57c30cd + flattened_ast: e552d82aad18b816cfdb8711f5b6f80c967775112b3ef2cf4d5ee712e0339106 + destructured_ast: be725f4ba9212e153a2ddf8a6f770c58d7a2b1b29a5e826f21435f68fba82578 + inlined_ast: be725f4ba9212e153a2ddf8a6f770c58d7a2b1b29a5e826f21435f68fba82578 + dce_ast: be725f4ba9212e153a2ddf8a6f770c58d7a2b1b29a5e826f21435f68fba82578 bytecode: ec9d10d78356538cf9f94bc46c20c33001a05100906259e217eeea2cfd0c4a66 errors: "" warnings: "" diff --git a/tests/expectations/compiler/examples/token.out b/tests/expectations/compiler/examples/token.out index 1cb42f0dd9..54ddf9cc30 100644 --- a/tests/expectations/compiler/examples/token.out +++ b/tests/expectations/compiler/examples/token.out @@ -9,10 +9,10 @@ outputs: initial_ast: 2b4311f224203d0a83a9e7821524e46bef0eaacd87717329fe86696cad6f2a61 unrolled_ast: 2b4311f224203d0a83a9e7821524e46bef0eaacd87717329fe86696cad6f2a61 ssa_ast: b46417bdbf9c7dfd30150e16923bb7e5f1e5699489867c606be254917abbc90d - flattened_ast: 359ded3eeb8e6a74bdf1d251b66637c6dff84ef017c40d9bfa4f07c3ffdad2fb - destructured_ast: fba8f866c82b3a5b2e8e02c8c5ed6107dea45801d5cc837f66f37c26bc2794f7 - inlined_ast: fba8f866c82b3a5b2e8e02c8c5ed6107dea45801d5cc837f66f37c26bc2794f7 - dce_ast: fba8f866c82b3a5b2e8e02c8c5ed6107dea45801d5cc837f66f37c26bc2794f7 + flattened_ast: a00704d16fc88fb9485a4e0420b68ca30eac03b9f52923df06c058593c6da195 + destructured_ast: 614e4825a4c9ed7f5b0bdbc86506e91b5386eb2c7e6201c931d05cd69fb36043 + inlined_ast: 614e4825a4c9ed7f5b0bdbc86506e91b5386eb2c7e6201c931d05cd69fb36043 + dce_ast: 614e4825a4c9ed7f5b0bdbc86506e91b5386eb2c7e6201c931d05cd69fb36043 bytecode: 379643d6f93f6040c0bb64ea96345269a23d6fb23fa3eae46ceb8e9ea9c73f9a errors: "" warnings: "" diff --git a/tests/expectations/compiler/examples/vote.out b/tests/expectations/compiler/examples/vote.out index cfee71f03a..0fb682dee6 100644 --- a/tests/expectations/compiler/examples/vote.out +++ b/tests/expectations/compiler/examples/vote.out @@ -9,10 +9,10 @@ outputs: initial_ast: 4fd9a923fcf8c5a2f2d02c9b831bd039180254769e92a3ae03da2216775f7e63 unrolled_ast: 9329eff974f22dc5fbea357bc1336d823ad12d87851e61d509f9a22b3941ddd6 ssa_ast: 217effef6281efd10a94925fbe5237172eac4d96433885e491588f2f1a46e55a - flattened_ast: f03fe093ba54b74b2c87fb5beb9f9039f2878978066a9cfb77b3928b713487ac - destructured_ast: 9035f154abe474572533537e0d5eded3354ea3a1c1056f3e56747091def2a4c0 - inlined_ast: 9035f154abe474572533537e0d5eded3354ea3a1c1056f3e56747091def2a4c0 - dce_ast: 9035f154abe474572533537e0d5eded3354ea3a1c1056f3e56747091def2a4c0 + flattened_ast: 9b2ff8a6bdb6756fb02559df1b6793570aeeac5d8c45186f573528e8556d07c0 + destructured_ast: bdddbe221634c8e1dcf817fa4b336264abd26e7b156d90f03ae2f1f0076acdf6 + inlined_ast: bdddbe221634c8e1dcf817fa4b336264abd26e7b156d90f03ae2f1f0076acdf6 + dce_ast: bdddbe221634c8e1dcf817fa4b336264abd26e7b156d90f03ae2f1f0076acdf6 bytecode: 0c73fbf3a08f7b89b82fc3189771704f58740f37c41f9c5aa7aef2a808badf9b errors: "" warnings: "" diff --git a/tests/expectations/compiler/finalize/block_height.out b/tests/expectations/compiler/finalize/block_height.out index 3de27f2561..743feac729 100644 --- a/tests/expectations/compiler/finalize/block_height.out +++ b/tests/expectations/compiler/finalize/block_height.out @@ -9,10 +9,10 @@ outputs: initial_ast: 42f2b37c4ed365be1f60aed2ef9830376dcb2edfab050789b7b63b7e5e75dbbc unrolled_ast: 42f2b37c4ed365be1f60aed2ef9830376dcb2edfab050789b7b63b7e5e75dbbc ssa_ast: bdfdc3e00a555dc9e5fbaa42bbfd195e59ce08919324835b0b3922f9f20f7f12 - flattened_ast: c3f222224bab6fd67c6c4cd544fd2bf0e463c8c42a976ea3dc8254a9afdabe40 - destructured_ast: 2cff5ef07b16d8053cc59dabc8148ddffa55ab3eff6b8abeadaf2b7f632ceb72 - inlined_ast: 2cff5ef07b16d8053cc59dabc8148ddffa55ab3eff6b8abeadaf2b7f632ceb72 - dce_ast: 2cff5ef07b16d8053cc59dabc8148ddffa55ab3eff6b8abeadaf2b7f632ceb72 + flattened_ast: f0eb10f3368c93edddd730646118d23bcb52b80d8f68719a244d51c649f820ac + destructured_ast: 8e6f5c329820ec4e92fbd99b4cc3280ac2477630302003365fe9f644417ca804 + inlined_ast: 8e6f5c329820ec4e92fbd99b4cc3280ac2477630302003365fe9f644417ca804 + dce_ast: 8e6f5c329820ec4e92fbd99b4cc3280ac2477630302003365fe9f644417ca804 bytecode: 6e4a8aeaf3eabc361bf427126c0a7f35c64030fb9c8f66e178c7c05bbede1c48 errors: "" warnings: "" diff --git a/tests/expectations/compiler/finalize/contains.out b/tests/expectations/compiler/finalize/contains.out index c769f2f69e..2ca69b5d31 100644 --- a/tests/expectations/compiler/finalize/contains.out +++ b/tests/expectations/compiler/finalize/contains.out @@ -9,10 +9,10 @@ outputs: initial_ast: 00ae8cc302ee7025d063eee1c9ea9b9589cb9e4b94028b931f085c44041032cb unrolled_ast: 00ae8cc302ee7025d063eee1c9ea9b9589cb9e4b94028b931f085c44041032cb ssa_ast: ca540994be2e1cb0cdf6b3473d90ed778c7c1a2070ad82183f74625d586f8eb3 - flattened_ast: 5b923b61e6cd781878cf390838a275cb4f0cb14795e27bfb3dd99004db3b385a - destructured_ast: bfda65b4898cd9066d05ee5425d55577fc7a84fb0a759b2ef75567a9dd00a965 - inlined_ast: bfda65b4898cd9066d05ee5425d55577fc7a84fb0a759b2ef75567a9dd00a965 - dce_ast: bfda65b4898cd9066d05ee5425d55577fc7a84fb0a759b2ef75567a9dd00a965 + flattened_ast: af70353b9c96a1cfe61605303f6363ee8ab283b59ac0a18ea5006b20b222c199 + destructured_ast: 4980be46ab5007df59342e1f8802efade3cc04e77ed0b6dfa97004e492edfb78 + inlined_ast: 4980be46ab5007df59342e1f8802efade3cc04e77ed0b6dfa97004e492edfb78 + dce_ast: 4980be46ab5007df59342e1f8802efade3cc04e77ed0b6dfa97004e492edfb78 bytecode: 2560848929684abb429a7de8a2ff0368fa2ea939f25ae84851be67374b652e8e errors: "" warnings: "" diff --git a/tests/expectations/compiler/finalize/decrement_via_get_set.out b/tests/expectations/compiler/finalize/decrement_via_get_set.out index 1ef0cc2c10..bba02c3454 100644 --- a/tests/expectations/compiler/finalize/decrement_via_get_set.out +++ b/tests/expectations/compiler/finalize/decrement_via_get_set.out @@ -9,10 +9,10 @@ outputs: initial_ast: 726a9bcb5c98d56a65e14cd1362d48835ffcafadacdb98a5ad0bf38eb5b92aec unrolled_ast: 726a9bcb5c98d56a65e14cd1362d48835ffcafadacdb98a5ad0bf38eb5b92aec ssa_ast: 6bc87e36f16e5f3353309d2c7280f0eda43c8cecc2f28d96a29f79afa28bbe5f - flattened_ast: 6e2cd4a613e58ae2a7ddb2c9ac49842017a9593bbe7f00044f0d1b949e25020a - destructured_ast: e1330537549ab60ce809fbc758305da43811b7365f237889a831aa6d435dc2b8 - inlined_ast: e1330537549ab60ce809fbc758305da43811b7365f237889a831aa6d435dc2b8 - dce_ast: e1330537549ab60ce809fbc758305da43811b7365f237889a831aa6d435dc2b8 + flattened_ast: 102791ff2b41f6e0620ec61874abe4b49e9977b1161a08fd342f208cb8e14486 + destructured_ast: c73fed24711eaf8f1465cbb59c7df6639f51bda5ebb21da0d39d9eb71fafd723 + inlined_ast: c73fed24711eaf8f1465cbb59c7df6639f51bda5ebb21da0d39d9eb71fafd723 + dce_ast: c73fed24711eaf8f1465cbb59c7df6639f51bda5ebb21da0d39d9eb71fafd723 bytecode: bbef5ec539b8616fe91e41c03c8ea6a71dfd3cb9731e634919bc8356e6664594 errors: "" warnings: "" diff --git a/tests/expectations/compiler/finalize/finalize.out b/tests/expectations/compiler/finalize/finalize.out index 4b793de3be..f0a7fc4b39 100644 --- a/tests/expectations/compiler/finalize/finalize.out +++ b/tests/expectations/compiler/finalize/finalize.out @@ -9,10 +9,10 @@ outputs: initial_ast: 6cf15b0de9fdcf8d9de46628aeeeacbaaddc8e1452ec1aeb447e94da0a336fb1 unrolled_ast: 6cf15b0de9fdcf8d9de46628aeeeacbaaddc8e1452ec1aeb447e94da0a336fb1 ssa_ast: 900b75b5aa816680c3cc9133ee530df22f3d8e9a555b77e7b66f32d7243fe542 - flattened_ast: 1943e2a521352312d5559b40aaa34388f0665aeaf4b5c4ab214d3cbdf429c36b - destructured_ast: 74139b78c5901dec8c01332185d4bcfc8ff7e7090c92c4d50a0ec2d7bfbc52a5 - inlined_ast: 74139b78c5901dec8c01332185d4bcfc8ff7e7090c92c4d50a0ec2d7bfbc52a5 - dce_ast: 74139b78c5901dec8c01332185d4bcfc8ff7e7090c92c4d50a0ec2d7bfbc52a5 + flattened_ast: 91dd5cecad4aa325475573c3ac8fc34c82d81ae4114c9f02cf9f5f60bafc9aef + destructured_ast: 86c18064b28556713063dd40006db5c2ddbc814c0624401a9af4e1014f68d216 + inlined_ast: 86c18064b28556713063dd40006db5c2ddbc814c0624401a9af4e1014f68d216 + dce_ast: 86c18064b28556713063dd40006db5c2ddbc814c0624401a9af4e1014f68d216 bytecode: 33d8ca1b78918f26980919a4a8b332fb9b375ac476b64636a387fdab715d4ed9 errors: "" warnings: "" diff --git a/tests/expectations/compiler/finalize/finalize_reassign_to_outer_scope_fail.out b/tests/expectations/compiler/finalize/finalize_reassign_to_outer_scope_fail.out new file mode 100644 index 0000000000..d456e07369 --- /dev/null +++ b/tests/expectations/compiler/finalize/finalize_reassign_to_outer_scope_fail.out @@ -0,0 +1,5 @@ +--- +namespace: Compile +expectation: Fail +outputs: + - "Error [ETYC0372097]: Cannot re-assign to `try_get_token` from a conditional scope to an outer scope in a finalize block.\n --> compiler-test:16:13\n |\n 16 | let try_get_token: TokenInfo = Mapping::get_or_use(\n | ^^^^^^^^^^^^^\n |\n = This is a fundamental restriction that can often be avoided by using a ternary operator `?` or re-declaring the variable in the current scope. In the future, ARC XXXX (https://github.com/AleoHQ/ARCs) will support more complex assignments in finalize blocks.\n" diff --git a/tests/expectations/compiler/finalize/finalize_with_method_calls.out b/tests/expectations/compiler/finalize/finalize_with_method_calls.out index 0660eb0add..9ce21e33d6 100644 --- a/tests/expectations/compiler/finalize/finalize_with_method_calls.out +++ b/tests/expectations/compiler/finalize/finalize_with_method_calls.out @@ -9,10 +9,10 @@ outputs: initial_ast: 50d96bc477a8528b09993639f92c505b7b91eed0f634f8a982741113bd0912d1 unrolled_ast: 50d96bc477a8528b09993639f92c505b7b91eed0f634f8a982741113bd0912d1 ssa_ast: ab8bfadeab820ffabb413af8450b081200ecc0074e335dc9d2ce0194153ed826 - flattened_ast: 1f0817d086e3d13362201dc4648eb2c9b486cc90745eef2e81f6a01d28f3fb28 - destructured_ast: 6562499ae3a309f9b0a59ca08cb6e02d1bf372662c5281a79e70cc1c92f35967 - inlined_ast: 6562499ae3a309f9b0a59ca08cb6e02d1bf372662c5281a79e70cc1c92f35967 - dce_ast: 6562499ae3a309f9b0a59ca08cb6e02d1bf372662c5281a79e70cc1c92f35967 + flattened_ast: 3151a26a35fc39acb1bd78005a6c00299c72c1bb168a73196cf10b7a3f31512f + destructured_ast: f648e6e0170a73ac78c50a2ca22d08e035e21f70895dbd350471c3e498423143 + inlined_ast: f648e6e0170a73ac78c50a2ca22d08e035e21f70895dbd350471c3e498423143 + dce_ast: f648e6e0170a73ac78c50a2ca22d08e035e21f70895dbd350471c3e498423143 bytecode: e9bcea998f0ff492fb57deabfcf08c4ed3f854880b595f17c9aa89181feb3764 errors: "" warnings: "" diff --git a/tests/expectations/compiler/finalize/increment_via_get_set.out b/tests/expectations/compiler/finalize/increment_via_get_set.out index 8bc58c5415..6378910756 100644 --- a/tests/expectations/compiler/finalize/increment_via_get_set.out +++ b/tests/expectations/compiler/finalize/increment_via_get_set.out @@ -9,10 +9,10 @@ outputs: initial_ast: 329d475959c785e4434b657951d60a67b5623a3994873f0530230155ffa35d80 unrolled_ast: 329d475959c785e4434b657951d60a67b5623a3994873f0530230155ffa35d80 ssa_ast: a1b7f65d63f9d63f50b4d769b48b87abcc6d20d0b69347c3b8f0cb84a7dc3ff8 - flattened_ast: 5b4f5f308c840a434f9a78a7e649be051c9795a591a9588163ad6cfa38095279 - destructured_ast: 287578cb85354bc59c37c8519e2ca7233913be9c57d5c05a4bf4ebcdcfba9895 - inlined_ast: 287578cb85354bc59c37c8519e2ca7233913be9c57d5c05a4bf4ebcdcfba9895 - dce_ast: 287578cb85354bc59c37c8519e2ca7233913be9c57d5c05a4bf4ebcdcfba9895 + flattened_ast: badcea479106d411e219a6d3aca622de1d9e3e2c129b60efbad59eb73b336529 + destructured_ast: e44205fe03136f850d4c1f66203ad6c42f1c7b4122fcb113af4071ebbbe426f6 + inlined_ast: e44205fe03136f850d4c1f66203ad6c42f1c7b4122fcb113af4071ebbbe426f6 + dce_ast: e44205fe03136f850d4c1f66203ad6c42f1c7b4122fcb113af4071ebbbe426f6 bytecode: 10e754c190939dcffa342c5eef2be0dcb73ef1a9b4391a99e963db6dc61bd38a errors: "" warnings: "" diff --git a/tests/expectations/compiler/finalize/inline_in_finalize.out b/tests/expectations/compiler/finalize/inline_in_finalize.out index 64c3187fde..3b7bf4687c 100644 --- a/tests/expectations/compiler/finalize/inline_in_finalize.out +++ b/tests/expectations/compiler/finalize/inline_in_finalize.out @@ -9,10 +9,10 @@ outputs: initial_ast: 439dc6e864f8346a6d8d8d0d663b622523a4f4073e7f618f8a3b48af57751117 unrolled_ast: 439dc6e864f8346a6d8d8d0d663b622523a4f4073e7f618f8a3b48af57751117 ssa_ast: 1691648d977f1ed92edd89210e0e32beac43e921e61f097c9e2d48cdcb7a1c79 - flattened_ast: eb704e426b913adcf8e0b8f2b52d58cd72a9e636e82d3f0592ba62bf948a87a5 - destructured_ast: 0ef36a604b1ccfb9c86318bf183397345ed3f62aca8b25b92f6ccbb2e940625d - inlined_ast: f4489ab531adf9b06bbc70d0a48b245b70a500f89490b870e723474a3a583289 - dce_ast: f4489ab531adf9b06bbc70d0a48b245b70a500f89490b870e723474a3a583289 + flattened_ast: 161e05f17750487cfcbe37b099a9ca694c90fd6d4de62b652dc0a3a28f906fd3 + destructured_ast: fc770d497d05cf52fa18d8cae7a160d92f42b6e530412e943be032b57fde0333 + inlined_ast: 1a8009ee940ed404ee0ec79951f2f6578c890d997c6f2bdbd6be07bf6cb83632 + dce_ast: 1a8009ee940ed404ee0ec79951f2f6578c890d997c6f2bdbd6be07bf6cb83632 bytecode: 643990908e94b8c16515df0d5dcd64918c17b356ad82d652cd9d6504089c49f0 errors: "" warnings: "" diff --git a/tests/expectations/compiler/finalize/only_finalize_with_flattening.out b/tests/expectations/compiler/finalize/only_finalize_with_flattening.out index cc6847926e..c8a859c297 100644 --- a/tests/expectations/compiler/finalize/only_finalize_with_flattening.out +++ b/tests/expectations/compiler/finalize/only_finalize_with_flattening.out @@ -3,16 +3,16 @@ namespace: Compile expectation: Pass outputs: - - compile: - - initial_symbol_table: 9bd9265feccd95ed896c73c966728add44d1683a9af934f028653148d0a1974f - type_checked_symbol_table: d0c2f7a1c92c7f3f5082a13126fe299ebdbc6230d3ba5fe2aef98521ca7980c1 - unrolled_symbol_table: d0c2f7a1c92c7f3f5082a13126fe299ebdbc6230d3ba5fe2aef98521ca7980c1 - initial_ast: 42fe71a0071c69c50a20580b772790a5c59ae03f86667f808221a031b444d3e4 - unrolled_ast: 42fe71a0071c69c50a20580b772790a5c59ae03f86667f808221a031b444d3e4 - ssa_ast: ea973cac72553e3038ae1cc8c82bfa08f4d573374704fb9ab0b7818de47bbfad - flattened_ast: 527bf92474e805a34f0b5c944296e55c2d0e2e37d6ca42bc0cdfa0933ea314d9 - destructured_ast: e49e7cbbc94a66e6094bd63d8fbb2d998d81c3fc2d726d05b8bfc5b08216857d - inlined_ast: e49e7cbbc94a66e6094bd63d8fbb2d998d81c3fc2d726d05b8bfc5b08216857d - dce_ast: e49e7cbbc94a66e6094bd63d8fbb2d998d81c3fc2d726d05b8bfc5b08216857d - bytecode: d1cb76177aa7ffcdc033855e2696b25791292c7c6b38fdc3c1e145dadc0f838a + - initial_symbol_table: a7c2abe734962ef0ce05e807ab7f1fa657be9eef9cb80fbe856d2a135ea6680f + type_checked_symbol_table: 5cd23f35c9f9a5e0f29f8c1772cec1a1f6c5a621b4414a71ce0fae224767d9db + unrolled_symbol_table: 5cd23f35c9f9a5e0f29f8c1772cec1a1f6c5a621b4414a71ce0fae224767d9db + initial_ast: 991d132fe9975a7cb259af42d8942a7efd4a57ece5c7d3239bacaabae17fb9d6 + unrolled_ast: 991d132fe9975a7cb259af42d8942a7efd4a57ece5c7d3239bacaabae17fb9d6 + ssa_ast: 13d77a08556b597e35c8af0391a83aac325e6b2ebd6d74f3e7b5c0629c64f3e9 + flattened_ast: 57c3f6864b8d9e18eb05902e2f0170682f19fe0c7025f608bab60cd81b064a1f + destructured_ast: 4d8b69be245b6a2e60293c7ddb538830edbe75ed3b6c28eea0891b6122e15ed1 + inlined_ast: 4d8b69be245b6a2e60293c7ddb538830edbe75ed3b6c28eea0891b6122e15ed1 + dce_ast: 4d8b69be245b6a2e60293c7ddb538830edbe75ed3b6c28eea0891b6122e15ed1 + bytecode: 458db8252b38f698e38938e87f24157a1843de705c8bb55537902a6ea32934c9 errors: "" warnings: "" diff --git a/tests/expectations/compiler/finalize/rand.out b/tests/expectations/compiler/finalize/rand.out index 1fcf2608b6..6a988073ed 100644 --- a/tests/expectations/compiler/finalize/rand.out +++ b/tests/expectations/compiler/finalize/rand.out @@ -9,10 +9,10 @@ outputs: initial_ast: 2ecdc46c95dfd4317447595490716949274d6acbd6b952886a36473c1a92ddd6 unrolled_ast: 2ecdc46c95dfd4317447595490716949274d6acbd6b952886a36473c1a92ddd6 ssa_ast: 752d946f7bfce55c490605e43814a6effaba2584b93dd250dfd01bb72e568720 - flattened_ast: 895e2a824b3381bd1d589f848ca1df994a85587d0051d629187375df2f1ef916 - destructured_ast: b0ddab401a6857d807034c9e19635d0d341905eb5a8e51a018965eff7ade28b7 - inlined_ast: b0ddab401a6857d807034c9e19635d0d341905eb5a8e51a018965eff7ade28b7 - dce_ast: 54a919c6eaa140f36a22ec7ab6878359f9f3a1238daf9973e3ff97c1bfcabff8 + flattened_ast: 348eda5d636d5f1e981d2babfb83e87ac7cb06d089dd26d886d868575238836f + destructured_ast: 01c11db1153404dbac5d28e931cea5a5c384993f1746d08ec282972311e25afe + inlined_ast: 01c11db1153404dbac5d28e931cea5a5c384993f1746d08ec282972311e25afe + dce_ast: 5ae5d831fa36b7d03fe64b1093bf5af9aa5d8e04c9c6586100bc99a56184b46b bytecode: c5e80399ab1edccfae4591f3c38695e9a4129b35ad2cc75238859a2e109a245f errors: "" warnings: "" diff --git a/tests/expectations/compiler/finalize/remove.out b/tests/expectations/compiler/finalize/remove.out index fee0588b62..b9942bc9a1 100644 --- a/tests/expectations/compiler/finalize/remove.out +++ b/tests/expectations/compiler/finalize/remove.out @@ -9,10 +9,10 @@ outputs: initial_ast: c31953108735c45451da79bdc610fbb48d0d804b585e6a85d468f6759505b5dd unrolled_ast: c31953108735c45451da79bdc610fbb48d0d804b585e6a85d468f6759505b5dd ssa_ast: 2a3a93dd928e94638aca5302b278dfa2a64dcf1975d4fa7216959c5ae7c65798 - flattened_ast: 09d1a43d18fbd98565e089897750ad724430a57022d4ee72d4eac049a0c6c483 - destructured_ast: 360e6bf531fe21a355da1f88b6ff57ab0da6eaa875db66a9eb65548692a24335 - inlined_ast: 360e6bf531fe21a355da1f88b6ff57ab0da6eaa875db66a9eb65548692a24335 - dce_ast: 360e6bf531fe21a355da1f88b6ff57ab0da6eaa875db66a9eb65548692a24335 + flattened_ast: 65d92f820e775e7aaa315aed8b50b6406f77bbb6a988733e2c477509219fe923 + destructured_ast: eeb8c5e3accdfdb6efd03d5f8b344320e073cb0b25421b872ff8473c112fb4fe + inlined_ast: eeb8c5e3accdfdb6efd03d5f8b344320e073cb0b25421b872ff8473c112fb4fe + dce_ast: eeb8c5e3accdfdb6efd03d5f8b344320e073cb0b25421b872ff8473c112fb4fe bytecode: 7598ca95ba8e589482a0d951cae6f2f8571e7ae33ec8f56dbe83077dac5100d4 errors: "" warnings: "" diff --git a/tests/expectations/compiler/mappings/read_external_mapping.out b/tests/expectations/compiler/mappings/read_external_mapping.out index 06d3dcc325..de5cc9d395 100644 --- a/tests/expectations/compiler/mappings/read_external_mapping.out +++ b/tests/expectations/compiler/mappings/read_external_mapping.out @@ -9,10 +9,10 @@ outputs: initial_ast: b6e69083825f6830b9bb8a584ea96a715bfce9591ab466b224c48b138ebfc2f1 unrolled_ast: b6e69083825f6830b9bb8a584ea96a715bfce9591ab466b224c48b138ebfc2f1 ssa_ast: 191493c157b000f1d2fe4325ed902f14a83ef08168e131929ff6efabb98c5d38 - flattened_ast: 44c35a22721e45be3d77a17f397c2428994607ee88bcd79c8df8ab9144d5543e - destructured_ast: ec37f60d6d06b469c75abeae897cbc19c7f34abeafeceb6d7766ded97d73c329 - inlined_ast: ec37f60d6d06b469c75abeae897cbc19c7f34abeafeceb6d7766ded97d73c329 - dce_ast: ec37f60d6d06b469c75abeae897cbc19c7f34abeafeceb6d7766ded97d73c329 + flattened_ast: 824b49236899cda5fe627c854e9571dd5166c3750b22dcecc7e83c9c6a253386 + destructured_ast: dbd525e3d53d5b4b248f71d05fbd25d1ec41767a0493d73a7bfaeb5a22160137 + inlined_ast: dbd525e3d53d5b4b248f71d05fbd25d1ec41767a0493d73a7bfaeb5a22160137 + dce_ast: dbd525e3d53d5b4b248f71d05fbd25d1ec41767a0493d73a7bfaeb5a22160137 bytecode: c44dd5a8d2158e3729310c6e423739cde6f4f8261609820886f26aa09afe707b errors: "" warnings: "" @@ -22,10 +22,10 @@ outputs: initial_ast: 08b601b7a0688a2d20a8811a61e8667cb7b3ef2f2da9f8b7c1337de5399b82b7 unrolled_ast: bbdd48c020c95460f993557345841e67402b73d0e26417ed41ff911c9030ee64 ssa_ast: b2fc01fbec80689a201f92f620ae397994e63005573b1482126cc027bc8d8453 - flattened_ast: 252d9cf0500795cc58c8a0cb591bb6cd374c5cdd4124cae9c107912217169aaa - destructured_ast: 2cbd54cc57bee27af8f0791f230a354256db2608d1803b91a6b5f8c9c99075ba - inlined_ast: 2cbd54cc57bee27af8f0791f230a354256db2608d1803b91a6b5f8c9c99075ba - dce_ast: 2cbd54cc57bee27af8f0791f230a354256db2608d1803b91a6b5f8c9c99075ba + flattened_ast: 98bd93276a08927862d873a3d1e0a52b46d5cec3b5622b53518b930d4bc19644 + destructured_ast: 49218a199ad96f32c613962d40adccdf7b851e5306b0d89ba071da7b3e4bb2f1 + inlined_ast: 49218a199ad96f32c613962d40adccdf7b851e5306b0d89ba071da7b3e4bb2f1 + dce_ast: 49218a199ad96f32c613962d40adccdf7b851e5306b0d89ba071da7b3e4bb2f1 bytecode: 1260b31fff8f93549822bd3a3bba846b38ca6dd13eacaf908842384748b4ea4c errors: "" warnings: "" diff --git a/tests/expectations/execution/complex_finalization.out b/tests/expectations/execution/complex_finalization.out index 32d11ca888..67cd42e969 100644 --- a/tests/expectations/execution/complex_finalization.out +++ b/tests/expectations/execution/complex_finalization.out @@ -9,10 +9,10 @@ outputs: initial_ast: 1d2d0a6b451ada7091b7179f0326bcfcc805ac80d8396be54a97d5b1b3ae99bc unrolled_ast: 1d2d0a6b451ada7091b7179f0326bcfcc805ac80d8396be54a97d5b1b3ae99bc ssa_ast: 41bec5b5a892842f78160a1e6944a7ae58182987bd630895b1848a7d6b811219 - flattened_ast: b43d756ef5380d1cafd109310f7f24c75504e6b2d49b6df7a181fb71ee2a01d0 - destructured_ast: a8a976421e6afafe278623726b96c71572984c9f1ebf54d340d4a3ee8d7472b1 - inlined_ast: a8a976421e6afafe278623726b96c71572984c9f1ebf54d340d4a3ee8d7472b1 - dce_ast: a8a976421e6afafe278623726b96c71572984c9f1ebf54d340d4a3ee8d7472b1 + flattened_ast: 507abcda8923d756f84977f8d86956087a941b24c0e22762f6d11dc943b8035b + destructured_ast: 045857303558423467b3544cc9896948f0bf34cdf3f64d4412bc667a1d8c54a4 + inlined_ast: 045857303558423467b3544cc9896948f0bf34cdf3f64d4412bc667a1d8c54a4 + dce_ast: 045857303558423467b3544cc9896948f0bf34cdf3f64d4412bc667a1d8c54a4 bytecode: 56b9658985c66ccadb9f1193ce728164bf8a64605f1ebf23bca2489366856408 errors: "" warnings: "" @@ -22,10 +22,10 @@ outputs: initial_ast: 6b344a6590d2ca4f06753a518b547ba428865c07dc32133d71421dac708c760e unrolled_ast: 6b344a6590d2ca4f06753a518b547ba428865c07dc32133d71421dac708c760e ssa_ast: 9da15e57a114500c297bc1bc32ee3bb2b4c14b47faa4ddc1c88e20d1894a63e5 - flattened_ast: b6689cca5bc09801f4cfad054569fa5c84ba942e32861994c21619bb5d0235c9 - destructured_ast: b0f929668475fb68ea2c0498fe98511080b646d7fc189ea5a0770479cfdb572e - inlined_ast: b0f929668475fb68ea2c0498fe98511080b646d7fc189ea5a0770479cfdb572e - dce_ast: b0f929668475fb68ea2c0498fe98511080b646d7fc189ea5a0770479cfdb572e + flattened_ast: 53876bb6f0e53d36fb78d8d708bc2ffca3fcbcc096201df180f8e4796b0cbf9c + destructured_ast: b0f5d553a83dcfb6b99722cbce50f5adb58af9626b8ad95b629547bc5f6d42b0 + inlined_ast: b0f5d553a83dcfb6b99722cbce50f5adb58af9626b8ad95b629547bc5f6d42b0 + dce_ast: b0f5d553a83dcfb6b99722cbce50f5adb58af9626b8ad95b629547bc5f6d42b0 bytecode: 2a3a8d08d08cb50221d366a70bb52bc132b8e46552dacf23efa66b85e306affc errors: "" warnings: "" @@ -35,10 +35,10 @@ outputs: initial_ast: f149292694c9429ece1d09db5bcb836eb421d70aaab7bcdb98e4bac6c68ef508 unrolled_ast: 2529425cc78afd160751160b99090545a0cd56273088698217045793a554b146 ssa_ast: f7ab9967658759127bc1f9456327c6163c41243f344bc2b307135a40fbb8e856 - flattened_ast: 6719e0c45bc9324bf8348e91bb96577383e6e4f4ab6cbdcb85d956e497cd0940 - destructured_ast: ca0ea7cf8be3085214701ef2d14c49c9f8ce03e83f9de072190fbcea8febfab9 - inlined_ast: ca0ea7cf8be3085214701ef2d14c49c9f8ce03e83f9de072190fbcea8febfab9 - dce_ast: ca0ea7cf8be3085214701ef2d14c49c9f8ce03e83f9de072190fbcea8febfab9 + flattened_ast: f8c136572519aa426bb394b62ef1b1d5591b369337a8424f5f66281d2d21947c + destructured_ast: ae7dd87b1116a519181d64c5e4e761454b20e7c318ae3f2c621f61e0436e0852 + inlined_ast: ae7dd87b1116a519181d64c5e4e761454b20e7c318ae3f2c621f61e0436e0852 + dce_ast: ae7dd87b1116a519181d64c5e4e761454b20e7c318ae3f2c621f61e0436e0852 bytecode: 115508df86f6c7e48dae71a5a27aed36bade699723aef76ac71e64316e995c03 errors: "" warnings: "" @@ -48,10 +48,10 @@ outputs: initial_ast: cdfbec7a117dd626b930b66db6ddc0e0e90064c86601084e76c401514d7c3885 unrolled_ast: 01376813f128de7dcd29f2bf10ff0e9ee773bab891dc135b0396544487a6243e ssa_ast: 63927909d1e737cf05b4d60402d91e7de869ceb442ee6be261fab76704382853 - flattened_ast: 0115c00a5b2da00f42d8fe178f71a10f51f4b905069d98ee71a73cac6d85f3d2 - destructured_ast: 12e502ad86a8d5e057f7309b4a61a3b5f23d8fca4f3a93dddb04d2aed957adff - inlined_ast: 12e502ad86a8d5e057f7309b4a61a3b5f23d8fca4f3a93dddb04d2aed957adff - dce_ast: 12e502ad86a8d5e057f7309b4a61a3b5f23d8fca4f3a93dddb04d2aed957adff + flattened_ast: 22d7950ed83dc1da363590773067f0446e06cc2f170c53739449179d98d3ae8f + destructured_ast: 39e5b6f7f0489cee6b3ba3b84eae5147bf36b65cadcc642de0de7ebe1e79a35e + inlined_ast: 39e5b6f7f0489cee6b3ba3b84eae5147bf36b65cadcc642de0de7ebe1e79a35e + dce_ast: 39e5b6f7f0489cee6b3ba3b84eae5147bf36b65cadcc642de0de7ebe1e79a35e bytecode: 52f79fd1e434cc22a2984e367922be363de60fb3bcdc7f2792c2ff44beaa3025 errors: "" warnings: "" @@ -61,10 +61,10 @@ outputs: initial_ast: f4362a002f5c31e52b226cd9a32f714e1a6b57253dcc330baeb6daceb8fd61a7 unrolled_ast: 932721c4c08e822f7cecd9170bdc0392ea04bbc208345d7fe68613175ffe3142 ssa_ast: 76e03b3cac35e3d10e3a73e99ffac3daaa1971e2241101e91d8ac3f6a22eba90 - flattened_ast: 3d2d97ae62ff6955b63056c998f38e1402bbf08e15de89be69a952f566b8ee15 - destructured_ast: 99d90c7d8c92e8aa865291f6479515aa1045ac327e7a882fde781259798a5df7 - inlined_ast: 99d90c7d8c92e8aa865291f6479515aa1045ac327e7a882fde781259798a5df7 - dce_ast: 99d90c7d8c92e8aa865291f6479515aa1045ac327e7a882fde781259798a5df7 + flattened_ast: 509d3881b0ceac122449711653d70cac226e1f675a8a695d16bb2ce25521d420 + destructured_ast: f7420f7d27f71f524ea7d5a648356a134179fa4081228e2dc9b19b0a3d13a2aa + inlined_ast: f7420f7d27f71f524ea7d5a648356a134179fa4081228e2dc9b19b0a3d13a2aa + dce_ast: f7420f7d27f71f524ea7d5a648356a134179fa4081228e2dc9b19b0a3d13a2aa bytecode: a4f1358380ab021bfa21fc627b0dac45b4065098f6b688fca09daa3906e7c768 errors: "" warnings: "" diff --git a/tests/expectations/execution/cond_exec_in_finalize.out b/tests/expectations/execution/cond_exec_in_finalize.out new file mode 100644 index 0000000000..4fc337048d --- /dev/null +++ b/tests/expectations/execution/cond_exec_in_finalize.out @@ -0,0 +1,91 @@ +--- +namespace: Execute +expectation: Pass +outputs: + - - compile: + - initial_symbol_table: bf3ab2a7e202ca44d269abb9876817308ccc967dc19762ebfc45083d2d16a95c + type_checked_symbol_table: 3951d3d66613f8203f23ff7216a38b7fa155922648dfbe1d9b1201f84b697315 + unrolled_symbol_table: 3951d3d66613f8203f23ff7216a38b7fa155922648dfbe1d9b1201f84b697315 + initial_ast: 21104527f729cd9523b74f7902131e756ac4615405c3ca225635573abcf92fb3 + unrolled_ast: 21104527f729cd9523b74f7902131e756ac4615405c3ca225635573abcf92fb3 + ssa_ast: f7b1644dfb4b99b5960906ee80bf88ca6b7d6a6dfeb0b50195a2cd94c0e788f5 + flattened_ast: ce2048db3cf0d124c10c6a418e38bed03c9b5ac251fe342b5f79e8b2d3c7a8cd + destructured_ast: 17bb3b101a6fd5936f1eb879e3cbb2938f93f53ae3291ac02a1f5ce66f5532be + inlined_ast: 17bb3b101a6fd5936f1eb879e3cbb2938f93f53ae3291ac02a1f5ce66f5532be + dce_ast: 17bb3b101a6fd5936f1eb879e3cbb2938f93f53ae3291ac02a1f5ce66f5532be + bytecode: 1714432c88873553dfc5e23b3097d205011de6a60cae026ff319b139e8b12d7b + errors: "" + warnings: "" + execute: + - execution: + transitions: + - id: au1hnth740vefp7jq5dcjnggq9hfmarpyscjysk0cvr0a3488mcg5rsamq48l + program: cond_exec_in_finalize.aleo + function: a + inputs: + - type: private + id: 8439431422115674265164472483490708670658760244412750772980523672963521358457field + value: ciphertext1qyqwpjrpfzwspvw5j3vr5rnu05jk944a5xkaefh3uvy5gsawz6pvurgzs4570 + - type: private + id: 582963545993539343219219179975209903939449980999695117631522815041705958243field + value: ciphertext1qyq9vkjwgy2rug0u3rg4kqrty37lq7sezgugqxqs4k45qpgy8wn5vygf0mu7h + outputs: + - type: future + id: 8259485654359189397095752007942598763747436067076711852451648060024173375253field + value: "{\n program_id: cond_exec_in_finalize.aleo,\n function_name: a,\n arguments: [\n 1u64,\n 0u64\n ]\n}" + tpk: 4207409092521788773697665282957518117044749858057590104309967566781092115271group + tcm: 5720809732376370870922323426771185853315798040351592412162356650894648757129field + global_state_root: sr1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq6gk0xu + proof: proof1qyqsqqqqqqqqqqqpqqqqqqqqqqq27xafejh3rfy9r7flupzdenl0vglwcy7j3eax7l6c0692lqnp4v9z6758u8d74chd5nuv8vqnmyqpqy9n20azz298hyrlc9apsmacr80wx2x8vm3ku83gxlz9gz5cff57sjvhzfcjutvhk29k04f2jg0tkqphrmz5yuys26q0n5vx7vnmrsedusg0y74vlqn2nw55mwtm3s79mys3v3krszj2fd7lkmgud9jvuyqzx35d47g7zp26qd8pn0rxhxf4ftj2gyr2ldwwzn7z54zh42k30h96t4d9fp3qr84alxffg0kcz3qq0tqmnkxnea7eqlplev8m82a6f79386qy8aqquykfazfkru8jvukp56jdukgmuedhfgs4mnwvmgjcr9mfm0j4wmxpdsa9ce57due6rf0h57z4qtfjzyt4d5tnghesttldvhucwjzfey2m7x0chtg4tzv9q9rxp65ktmkt8jkfn3cm73kle7xd3j7x4myprf90ffnc5n7tapzxp7vd6h426e2hyrd6x29ftqp0gq9ptsspaytdzzh0tp5dx0ls9v8dgvsw6vzlqjh350q5pqdsrrgxp9h8p55mfpntcupg6wwehus09cq0vyqw290l93lzn0wgxpc35kjcx3hvlrnddzmnzdlwe70rnqfwg2rsg6np8px62np9uv6hnputy3uqnnw8p6rys8eee04cf9mwvexxecn4z7gxa6ylg4rf3avs465s2qy3ekff5y0sd60t5qk7rrdlyeeenwag3pxzdr3djxurff5cteydqp0wz6awgf892zhgjhujw28mqchvu6820h3sx3vue8vm30jpuazgpzxdalg5lv7nyrcegz7935qdrjq9xe3vup7z6gd0sgljdfm32efsg8tzneurlsxgjk82e095495s4lxc6mds9y26yf8n3ph0gnrt7ecy7u8ufv5g0jagj0huyaffrvqscndrfy69703kzm5h9xgq4zvm7s97c47zzwmh2kmp4h98f3yy0vtjxd8g85xxu7xlkkcu35qwwcx6kqyc6py6uzy7e0n8qgc052wpgw68u4vfnla7uh4z8c9ynskzsrrjpuny4edr24fw57y0y8a2le8d0z8pu988sghc25aeuh2aqcl25y0q6hhq78nggjjge5pv692samxxq3eytjt43kazls8qqy7l3qxq60q0qvqqqqqqqqqqpvxevrn6pj72s5amzvc70fhkynkqnwwjecv8r0wtmhl04x492axaytufuc8t6v2u7vcv8xu27d44sqq8jkgep7nrg9ks2gvdmv3qycvwwpvac3pgsqer4rzj6qnu9aztej3sv9zc9vv7slccja8fpwqufjuqq8m0yefdjp7x7fwfhezwkk83f0u8lg3sc3kltsf7r2m5fmxhrkuq7wqry7r697r8hfpdyr4cw25vj4zy5qaq6ay5wfvzmeek8vytr76fltrd6gdk4ujvctc80qfrag2uqyqqvstf5t + verified: true + status: accepted + errors: "" + warnings: "" + - execution: + transitions: + - id: au1y308ypfwfwhhm4jepwazp276t2fr2nqgaqppqx6z70w88aq2jv9syu6as4 + program: cond_exec_in_finalize.aleo + function: a + inputs: + - type: private + id: 1631318581148965008674844087839181853396169120474775467118751107469904730527field + value: ciphertext1qyq05fhpftu7pg49cql4l8rmzpayfutsjyjq9yt0mdpdk7luhas4vrqz5yp3l + - type: private + id: 2730883656536056771736746580650804733132269756588008567659943372030531745988field + value: ciphertext1qyqgem7prc6rmvufszxqgztjsq3c08me6txscjz3cl6yeus9qgg85rqrw35jq + outputs: + - type: future + id: 7386294196767656539101367746470737224910311672267601420512890407269047059437field + value: "{\n program_id: cond_exec_in_finalize.aleo,\n function_name: a,\n arguments: [\n 1u64,\n 1u64\n ]\n}" + tpk: 539929479867149800733285453788663840307959183316106833158590803990176232963group + tcm: 750293666249868558647437278234877709852569665340157728357983917884441329142field + global_state_root: sr1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq6gk0xu + proof: proof1qyqsqqqqqqqqqqqpqqqqqqqqqqqvuqxzqplhy8tfkehsr66dwa6uxafp2frp7anzslxal0t8ryrsf6qw4kv3dw5nl06y3rstjqyzercqqy24v3px5rm3y2yuatleccqp762grxpnz5mzr2ducchjvpes6ds2xdk4kg0q8a2769jtdgve6sd5qqq4faa55rml8z8ep26sf27uyv6wrdcmcqxdq9zhysds6ch6344dxtm4877f3u2t4h7z3pg7wkezr7qch7mx588dxwkn60jc2k8efalwrkjqmhcck4kqmvfqmw0f7ek9lpkftx79rj4j8hwjcwcwp00lzm5pldufllzqg7lkrmwa4zpxflv4relr6nksp6qg2vlur3qm8rlkfyexdx93du2mk40957cq0y2kfyyqphyy7j8pcntnhvp8xaaazztd2jwuyaqqml2k0saclf4aur2448zh2lttz0n7xmc7l2a4tuqqn9yzsx7yfe33xpnnuy4e6xev8zhyc2ckxsl5wvpmnxwfqnu35v9x9us7sdfu0drtlz03ul9gk5g65dfs6q233jn3cx3rhnw59ncgfl27cfcfy3rmddal9rkacpgsph2vpurpvvvn8slu0pjk6uahp06pa6ul7xqqzmschhvy956jtpc0p6kxpllkw69wrnvdngyt2tc6z4ezwzhxkue99e324ugv34l2gnyj27h59g5pslgnefctav83fnp3gqmxl02qrwz73znmyk3hgv4la80jlc33ruy6vs8srntsxlj83d7ersc4chyv7t865qdea73hpzztgy7mtdu3wpt6jhl586x94du2x4e6sh3lwqs97j98j3yctfav9rxh6z8pxnkmqklp6mu77ln7lu3p5xzdfgj70dwanh7ha7g7vx855jy9ursu7knss9v0y5lw27keue04lgp420y40um6sjgx4af08gcp5lwnrhzdqwq3r0zkzjyhy09h8gjnyjz03p9h8edthh88rxewr3dlltkn207m5vxlhu66mklgfddudrqh37fs7gnhptzadyzexupnyvvzh2sfa5h76zzhgfg86kcnl7shthv2ef0pa845m9zwheyr4j67xs9q98rhypq6q3c65snrl5drg2cn94dyz4k5nhdyxc37qa6a8l7xmvwth6n6j4hqetrtmk8qj8cw6tx7kuzcnv2du80khwrsk8vz9pn8s53t7udwh0c2qvqqqqqqqqqqpx2j8rrhzjz2n7vc7mu7axz5w70pnplkn7th3e0n4np88fd9pn824e4tethgckudjkdw8nx4j5n9qqqrfy3u00l06ulcf5arm6s99kz32n2f4ceprkf8xtqp8mn9vvx5apemt63pryh7yxxtr8qzyf8nspspqy8mp0qql8llavuug9xc4hzhauaqxw7yka30cerjse8w8auqyxwsy960yr3fjemmr0f4dsj2vxgnust3tcletp5hsnyhgdgppy3wssju8n9dehaptwsm2399hgnltrdnqqqqw5x6kz + verified: true + status: accepted + errors: "" + warnings: "" + - execution: + transitions: + - id: au15x0h7t67dt4qtd8rw88n6p7z8qlrl87k73cs6ccp87qn6yrfnvqqh79dch + program: cond_exec_in_finalize.aleo + function: a + inputs: + - type: private + id: 270031312842872099149153816168966123261059659148779587198535012228139245910field + value: ciphertext1qyqwmtz9hdlr84wzls0c9r75x9nehdvj6q97djepe3uksazeqy2q6ysu60ag8 + - type: private + id: 2324112544709230142835944577027874423920312613748094000298404077279994623487field + value: ciphertext1qyqxxlgwh8nx6lg7kgxrvrl2rg40g9m0y4s9cjykdc4vsn3u7r5p2yqywpkty + outputs: + - type: future + id: 2083750374367970367055399814294610712389072795928419568916374373502193990747field + value: "{\n program_id: cond_exec_in_finalize.aleo,\n function_name: a,\n arguments: [\n 1u64,\n 2u64\n ]\n}" + tpk: 7458390631358257933021695534982934099811217047220226771581295540904028489993group + tcm: 6633056545390342742807118551129484810714402998268060346969235503471015910575field + global_state_root: sr1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq6gk0xu + proof: proof1qyqsqqqqqqqqqqqpqqqqqqqqqqqzklf2q5p4v0hwx62rvkwjzlp23t8w5fysmmjr8yaa90flg5h5ff737ydef42s55v0c66quhzes55qqxh6da50s32ccfvl6t8tn4sv3w5epruyg8yzv2zmfqztz7f4rerksyewmjf0l6x4srenzcenmmk0lqr07rszm2hz28wdq8v6200thzku6pz0rs9uxel9tlpdkhaj6x2wx3nthjeysr23kkzqsxeykad7jqqley365zugtp8qdxkpgnj7r4cnlu5rt9xfexdt34fln5uhtjd8az3vrz2cr73p3dqzctz765e02suqw9ye6lyx0c83u8g3ewkch9208snmq8vds3g89x86h68wx793rqk8d8r977ljm5kwnes67h6flvtczse0lfgejzqn2te6yetnq0x4437c7auf2q9atlm4yy666jd5p9ya8ztwnkmqhenk6cyw4an9ceukqr6ml5aq0jplvp634l2nx5vuml20nwatv79vlt36fxmedpu5r6wamshrnlxfaas3g3n5jw6tx6mqtqw5g0luxdv5g94r6fewl653l5twff53kjtrqmhva9j5vyhuhrq0nwjcuwk74v42ffe4ysa5e2j54jqmgrlj6223enqgjeg6ur8ejjara52p4y79nvlt5shzevu85sh2dh8zvge8w25xsfneg4zrfa4frrqpgt9f060ytrp80mktrm22q2kshuhgs73f894xtzg5jldtuvpfavzdmu84p6pd2tql7f0j7xhharle4jryuxqxhvhp49cdu28u03ervpjz6a54x2mnpv3aj0qkwd2w5x2f5sy6ceffpc2l6ed77npurl3kpznm0u2ek26e03977lvn7y7u8n9hgz4j503q270nrgva0yhf9kmsc3pe8evegg5jvg6dz8e4r83kxtqpm30k7t7tnqq3pjvvs7ycdfg95y6efazd79kue3fcp8fwmakn5k452r5dkf6tgs7eaqz2znpv7cqj47kepgq5003uqhmjk0xfwyprhftq7a255kmfemk2eylfkl0z6rt7q7hqcke79dv0dpl5sr92slvyyqlvzztq0f5ftunuul3rhgfeq92cp8m3he59ujz0jvs67r90h4fgr7jgv0rhs50ev7d2ahn7du8s67aeh24q5r8665r9h739qumzpuqvpfsgxqumgzrdtfgjqh7gw0g8qvqqqqqqqqqqq7qrqssrfgs54nfgh00q3rrwg05p576tk9uyac54x9gq5793fljxv8lujjfsyjfql5m72sd47uw6sqqppfh0lmcvl8me4qgkzny9gwkm88daj8t38thnxvzpckwtd9luf5m0lksanwyd8s9r5ms58jc2l7uqqx5t2avtkpeff86q8xarc34chnrwswa3ynajuqes3evad87pmqhqety77egc4a7e4nszwt7epm5n69e4m5twl9wtpn239w4z07sjkhu52tlmzpyena58y9t63y5w79n3qyqqmhyez9 + verified: true + status: rejected + errors: "" + warnings: "" diff --git a/tests/expectations/execution/counter.out b/tests/expectations/execution/counter.out index effb37229c..aabd1ff8dc 100644 --- a/tests/expectations/execution/counter.out +++ b/tests/expectations/execution/counter.out @@ -9,10 +9,10 @@ outputs: initial_ast: c69d09a2934a19ac8d699564f07369508dd0cdbdc4a5c08ea9b8a736e1a5db3c unrolled_ast: e290dac1247a03cad86c90a6f11312c5c9972dffbade372853165407cbb12f59 ssa_ast: 0c6f458c7cc9ad347c76ebf4898795072b6f5020f4ad09a1e8598439a0a9c572 - flattened_ast: 30a84a5eee7a8398352a8fdf95868a915bbcb926c6c364f03b3f50f12872e7e4 - destructured_ast: d836973e69033fd401837e46d115b84f899e87d9cd1f5ed2447cd7c86d7f1c37 - inlined_ast: d836973e69033fd401837e46d115b84f899e87d9cd1f5ed2447cd7c86d7f1c37 - dce_ast: d836973e69033fd401837e46d115b84f899e87d9cd1f5ed2447cd7c86d7f1c37 + flattened_ast: a4b92d64c082476b1143262768d09a7cc8cf86d8847ff780c03692541d4eeeda + destructured_ast: 90bce95bc581cab4336f446e673962dde6e8092e02e04f14e3bd76eb68005f03 + inlined_ast: 90bce95bc581cab4336f446e673962dde6e8092e02e04f14e3bd76eb68005f03 + dce_ast: 90bce95bc581cab4336f446e673962dde6e8092e02e04f14e3bd76eb68005f03 bytecode: 75252a5477a2943c07eaf114bef3dd214acbd7184b3118f14786beb8215bfb94 errors: "" warnings: "" diff --git a/tests/tests/compiler/finalize/finalize_reassign_to_outer_scope_fail.leo b/tests/tests/compiler/finalize/finalize_reassign_to_outer_scope_fail.leo new file mode 100644 index 0000000000..c44438454f --- /dev/null +++ b/tests/tests/compiler/finalize/finalize_reassign_to_outer_scope_fail.leo @@ -0,0 +1,35 @@ +/* +namespace: Compile +expectation: Fail +configs: + - dce_enabled : false +*/ + +program test.aleo { + struct TokenInfo { + id: u64, + } + mapping token_name_to_info: field => TokenInfo; + + + transition add_new_liquidity_token_2 () { + return then finalize(); + } + + + finalize add_new_liquidity_token_2() { + let try_get_token: TokenInfo = Mapping::get_or_use( + token_name_to_info, + 0field, + TokenInfo { id: 0u64 } + ); + if try_get_token.id == 0u64 { + try_get_token = TokenInfo { id: 10u64 }; + } else { + return; + } + } +} + + + diff --git a/tests/tests/compiler/finalize/only_finalize_with_flattening.leo b/tests/tests/compiler/finalize/only_finalize_with_flattening.leo index 4ec903bf73..d1a37eccac 100644 --- a/tests/tests/compiler/finalize/only_finalize_with_flattening.leo +++ b/tests/tests/compiler/finalize/only_finalize_with_flattening.leo @@ -32,24 +32,6 @@ program test.aleo { return; } } - - transition add_new_liquidity_token_2 () { - return then finalize(); - } - - - finalize add_new_liquidity_token_2() { - let try_get_token: TokenInfo = Mapping::get_or_use( - token_name_to_info, - 0field, - TokenInfo { id: 0u64 } - ); - if try_get_token.id == 0u64 { - try_get_token = TokenInfo { id: 10u64 }; - } else { - return; - } - } } diff --git a/tests/tests/execution/cond_exec_in_finalize.leo b/tests/tests/execution/cond_exec_in_finalize.leo new file mode 100644 index 0000000000..7fe041752e --- /dev/null +++ b/tests/tests/execution/cond_exec_in_finalize.leo @@ -0,0 +1,30 @@ +/* +namespace: Execute +expectation: Pass +cases: + - program: cond_exec_in_finalize.aleo + function: a + input: ["1u64", "0u64"] + - program: cond_exec_in_finalize.aleo + function: a + input: ["1u64", "1u64"] + - program: cond_exec_in_finalize.aleo + function: a + input: ["1u64", "2u64"] +*/ + + +program cond_exec_in_finalize.aleo { + + transition a(a: u64, b: u64) { + return then finalize(a, b); + } + + finalize a(a: u64, b: u64) { + if (b == 0u64) { + assert_eq(b, 0u64); + } else { + assert_eq(a / b, 1u64); + } + } +}