From d2b1d055cec19813dfdb6e8690ff9bc2f3e04a8f Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu <23022326+d0cd@users.noreply.github.com> Date: Mon, 13 May 2024 11:09:15 -0700 Subject: [PATCH] Update tests and fix --- .circleci/lottery/src/main.leo | 6 ++--- .circleci/token/src/main.leo | 24 +++++++++---------- .../src/type_checking/check_statements.rs | 3 ++- .../passes/src/type_checking/scope_state.rs | 3 --- .../compiler/address/special_address.out | 20 ++++++++-------- .../compiler/expression/network_id.out | 20 ++++++++-------- .../finalize/closure_with_finalize_fail.out | 2 +- .../compiler/finalize/finalize_fail.out | 2 +- .../finalize_incorrect_modes_fail.out | 2 +- .../finalize_incorrect_return_fail.out | 2 +- .../finalize_reassign_to_outer_scope_fail.out | 2 +- .../only_finalize_with_flattening.out | 18 +++++++------- .../parser/program/network_id.out | 15 ++++++------ .../parser/program/special_address.out | 15 ++++++------ .../finalize/closure_with_finalize_fail.leo | 4 ++-- .../tests/compiler/finalize/finalize_fail.leo | 16 ++++++------- .../finalize_incorrect_modes_fail.leo | 12 +++++----- .../finalize_incorrect_return_fail.leo | 6 ++--- .../finalize_reassign_to_outer_scope_fail.leo | 6 ++--- .../only_finalize_with_flattening.leo | 7 ++---- .../program/locator_expression_fail.leo | 6 ++--- 21 files changed, 92 insertions(+), 99 deletions(-) diff --git a/.circleci/lottery/src/main.leo b/.circleci/lottery/src/main.leo index cb450a1dd9..27485fdeda 100644 --- a/.circleci/lottery/src/main.leo +++ b/.circleci/lottery/src/main.leo @@ -7,14 +7,14 @@ program lottery.aleo { owner: address, } - transition play() -> Ticket { + async transition play() -> (Ticket, Future) { let ticket: Ticket = Ticket { owner: self.caller, }; - return ticket then finalize(); + return (ticket, finalize_play()); } - finalize play() { + async function finalize_play() { // Check that the lottery has not expired. assert(block.height <= 1000u32); diff --git a/.circleci/token/src/main.leo b/.circleci/token/src/main.leo index 120c6648fd..7746348eec 100644 --- a/.circleci/token/src/main.leo +++ b/.circleci/token/src/main.leo @@ -13,12 +13,12 @@ program token.aleo { /* Mint */ // The function `mint_public` issues the specified token amount for the token receiver publicly on the network. - transition mint_public(public receiver: address, public amount: u64) { + async transition mint_public(public receiver: address, public amount: u64) -> Future { // Mint the tokens publicly by invoking the computation on-chain. - return then finalize(receiver, amount); + return finalize_mint_public(receiver, amount); } - finalize mint_public(public receiver: address, public amount: u64) { + async function finalize_mint_public(public receiver: address, public amount: u64) { // Increments `account[receiver]` by `amount`. // If `account[receiver]` does not exist, it will be created. // If `account[receiver] + amount` overflows, `mint_public` is reverted. @@ -35,12 +35,12 @@ program token.aleo { } /* Transfer */ - transition transfer_public(public receiver: address, public amount: u64) { + async transition transfer_public(public receiver: address, public amount: u64) -> Future { // Transfer the tokens publicly, by invoking the computation on-chain. - return then finalize(self.caller, receiver, amount); + return finalize_transfer_public(self.caller, receiver, amount); } - finalize transfer_public(public sender: address, public receiver: address, public amount: u64) { + async function finalize_transfer_public(public sender: address, public receiver: address, public amount: u64) { // Decrements `account[sender]` by `amount`. // If `account[sender]` does not exist, it will be created. // If `account[sender] - amount` underflows, `transfer_public` is reverted. @@ -78,7 +78,7 @@ program token.aleo { // The function `transfer_private_to_public` turns a specified token amount from a token record into public tokens for the specified receiver. // This function preserves privacy for the sender's record, however it publicly reveals the token receiver and the token amount. - transition transfer_private_to_public(sender: token, public receiver: address, public amount: u64) -> token { + async transition transfer_private_to_public(sender: token, public receiver: address, public amount: u64) -> (token, Future) { // Checks the given token record has a sufficient token amount. // This `sub` operation is safe, and the proof will fail if an underflow occurs. // `difference` holds the change amount for the caller. @@ -92,10 +92,10 @@ program token.aleo { // Output the sender's change record. // Increment the token amount publicly for the token receiver. - return remaining then finalize(receiver, amount); + return (remaining, finalize_transfer_private_to_public(receiver, amount)); } - finalize transfer_private_to_public(public receiver: address, public amount: u64) { + async function finalize_transfer_private_to_public(public receiver: address, public amount: u64) { // Increments `account[receiver]` by `amount`. // If `account[receiver]` does not exist, it will be created. // If `account[receiver] + amount` overflows, `transfer_private_to_public` is reverted. @@ -105,7 +105,7 @@ program token.aleo { // The function `transfer_public_to_private` turns a specified token amount from `account` into a token record for the specified receiver. // This function preserves privacy for the receiver's record, however it publicly reveals the caller and the specified token amount. - transition transfer_public_to_private(public receiver: address, public amount: u64) -> token { + async transition transfer_public_to_private(public receiver: address, public amount: u64) -> (token, Future) { // Produces a token record for the token receiver. let transferred: token = token { owner: receiver, @@ -114,10 +114,10 @@ program token.aleo { // Output the receiver's record. // Decrement the token amount of the caller publicly. - return transferred then finalize(self.caller, amount); + return (transferred, finalize_transfer_public_to_private(self.caller, amount)); } - finalize transfer_public_to_private(public sender: address, public amount: u64) { + async function finalize_transfer_public_to_private(public sender: address, public amount: u64) { // Decrements `account[sender]` by `amount`. // If `account[sender]` does not exist, it will be created. // If `account[sender] - amount` underflows, `transfer_public_to_private` is reverted. diff --git a/compiler/passes/src/type_checking/check_statements.rs b/compiler/passes/src/type_checking/check_statements.rs index 3a9dfdc23e..86489af218 100644 --- a/compiler/passes/src/type_checking/check_statements.rs +++ b/compiler/passes/src/type_checking/check_statements.rs @@ -83,7 +83,8 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> { } // If the variable exists and its in an async function, then check that it is in the current scope. - if self.scope_state.is_async + // Note that this unwrap is safe because the scope state is initalized before traversing the function. + if self.scope_state.variant.unwrap().is_async_function() && self.scope_state.is_conditional && self .symbol_table diff --git a/compiler/passes/src/type_checking/scope_state.rs b/compiler/passes/src/type_checking/scope_state.rs index 2099404d84..32d0a640ef 100644 --- a/compiler/passes/src/type_checking/scope_state.rs +++ b/compiler/passes/src/type_checking/scope_state.rs @@ -41,8 +41,6 @@ pub struct ScopeState { pub(crate) is_call: bool, /// Location of most recent external call that produced a future. pub(crate) call_location: Option, - /// Whether currently traversing an async function. - pub(crate) is_async: bool, } impl ScopeState { @@ -60,7 +58,6 @@ impl ScopeState { is_conditional: false, is_call: false, call_location: None, - is_async: false, } } diff --git a/tests/expectations/compiler/address/special_address.out b/tests/expectations/compiler/address/special_address.out index 2d06994d07..a971584f72 100644 --- a/tests/expectations/compiler/address/special_address.out +++ b/tests/expectations/compiler/address/special_address.out @@ -3,16 +3,16 @@ namespace: Compile expectation: Pass outputs: - - compile: - - initial_symbol_table: f159adcd5ea24c580a6b8535b217667a40173809e5802a0b03db3dc5b9bec9aa - type_checked_symbol_table: 9fd0ee7288d5151305f4cd3820594bd9db7accb589bc936e186709af1df6de21 - unrolled_symbol_table: 9fd0ee7288d5151305f4cd3820594bd9db7accb589bc936e186709af1df6de21 - initial_ast: 21db64864f84959ad71dace62a2487285c3b6bb74818536b83a54b63a2bd8d82 - unrolled_ast: 21db64864f84959ad71dace62a2487285c3b6bb74818536b83a54b63a2bd8d82 - ssa_ast: d4e2a516deaa30f8663bb3cd1501c52e3cc781b330dbb149ee3bad0692a8cb59 - flattened_ast: 175fbd23f91421e3d47440c8a7e00fb9e3a2bef1147e061cd8a3f2bd0c978098 - destructured_ast: a23caa23b3ac10d6c2a1b119af502a9ec4380cf521eb65da2c9e2a5f19d44172 - inlined_ast: a23caa23b3ac10d6c2a1b119af502a9ec4380cf521eb65da2c9e2a5f19d44172 - dce_ast: a23caa23b3ac10d6c2a1b119af502a9ec4380cf521eb65da2c9e2a5f19d44172 + - initial_symbol_table: 9093a20a62879f03d6a7a4dc24b051778d2c543d1df6a59af8c423d047ec2e13 + type_checked_symbol_table: 639ed2aefe557daf6c3433d645bec25030a82e3296f26ac46961f451d2bb28ae + unrolled_symbol_table: 639ed2aefe557daf6c3433d645bec25030a82e3296f26ac46961f451d2bb28ae + initial_ast: da0a545e9de3b8cdec100132e7d9886d08b7e69217d129229e8a86489199ec21 + unrolled_ast: da0a545e9de3b8cdec100132e7d9886d08b7e69217d129229e8a86489199ec21 + ssa_ast: f76c8e4b70096ec05a1583648b295127d0a60d8b9973a1d5c7dff53782282c1d + flattened_ast: d743a19b1faa6b66b90bd8496249cc5b94e9ba8260ad7ce95da721b68e59c3a9 + destructured_ast: d36731bec3ce6fd1c46b5660340e8e396fb874b0c3d3f6ae407e5f55aeb07aa4 + inlined_ast: d36731bec3ce6fd1c46b5660340e8e396fb874b0c3d3f6ae407e5f55aeb07aa4 + dce_ast: d36731bec3ce6fd1c46b5660340e8e396fb874b0c3d3f6ae407e5f55aeb07aa4 bytecode: d9e6c28f9e5527abe9cdb07b9d35375901446415f5d645b0363597200ee45be7 errors: "" warnings: "" diff --git a/tests/expectations/compiler/expression/network_id.out b/tests/expectations/compiler/expression/network_id.out index 8ac6529d83..0c598517f4 100644 --- a/tests/expectations/compiler/expression/network_id.out +++ b/tests/expectations/compiler/expression/network_id.out @@ -3,16 +3,16 @@ namespace: Compile expectation: Pass outputs: - - compile: - - initial_symbol_table: 02b83350abcecb36109bf268cf52b9fc867ab1893c49badf31ff527156528943 - type_checked_symbol_table: 1ace971bd20adb9ce07f802070f05c51733af791ef32c7b1130d4a4b2182768d - unrolled_symbol_table: 1ace971bd20adb9ce07f802070f05c51733af791ef32c7b1130d4a4b2182768d - initial_ast: 6dc0a710ab752f571f4dae9fdb172a7fa1c43e3af3858cbc8cf96c5d510a0c3a - unrolled_ast: 6dc0a710ab752f571f4dae9fdb172a7fa1c43e3af3858cbc8cf96c5d510a0c3a - ssa_ast: e09d30595377e81788433b702f76f1338ff4bb720f8564e2560e5f78ebd18bc0 - flattened_ast: 16df732ae63243e249201817b30ae02b8a190072d39894648607970eb2b09192 - destructured_ast: b2f615fbb0825b50c961b4014e2e2d60117b543cab0d2e1acd4f3237c878e95e - inlined_ast: d3f7291df3faf6f8a4893b91133fe183d44c35f3d9c4b9d270d71f943482f965 - dce_ast: d3f7291df3faf6f8a4893b91133fe183d44c35f3d9c4b9d270d71f943482f965 + - initial_symbol_table: ef5cbe43fd02c4bdf9de14a42e77c7f1635e0ee8df54b45b71d9a82bae42e8eb + type_checked_symbol_table: 85e41486c103f9351c482a271ae2cc9e89eb37b36a50f786bff51feaf6537034 + unrolled_symbol_table: 85e41486c103f9351c482a271ae2cc9e89eb37b36a50f786bff51feaf6537034 + initial_ast: ad760a62ddcf6370800d4319ce4b0c48832cdf7442c2ad6b2fc244b7d9c8bbd7 + unrolled_ast: ad760a62ddcf6370800d4319ce4b0c48832cdf7442c2ad6b2fc244b7d9c8bbd7 + ssa_ast: 5f2251b6411d4843954be231b25beee450771b068de30ca66cdcbd0f6b371357 + flattened_ast: aba52a6d70cd6fc0ae608ca6853b8e41b720ce3ff7b4d67274c92e35d2269749 + destructured_ast: c2c04fdc548c372848fb69f8201af5a5657d8acbceb2ef7bea7a109ece2e9851 + inlined_ast: 663c8ee124bbb7a55247b2f5ce18443687e3262f9874bad35f21f65dbbf09a83 + dce_ast: 663c8ee124bbb7a55247b2f5ce18443687e3262f9874bad35f21f65dbbf09a83 bytecode: ae04a04e7ffb01dfdd0ae0249f31649302bc120ea928c5ace16bc0879140e1f9 errors: "" warnings: "" diff --git a/tests/expectations/compiler/finalize/closure_with_finalize_fail.out b/tests/expectations/compiler/finalize/closure_with_finalize_fail.out index ca09169fae..4c2a770eb7 100644 --- a/tests/expectations/compiler/finalize/closure_with_finalize_fail.out +++ b/tests/expectations/compiler/finalize/closure_with_finalize_fail.out @@ -2,4 +2,4 @@ namespace: Compile expectation: Fail outputs: - - "Error [EPAR0370005]: expected ; -- found 'then'\n --> compiler-test:5:22\n |\n 5 | return a + b then finalize(a, b);\n | ^^^^" + - "Error [ETYC0372110]: A `transition` cannot return a future.\n --> compiler-test:4:35\n |\n 4 | function foo(a: u8, b: u8) -> Future {\n | ^^^^^^\n |\n = Use an `async transition` instead.\nError [ETYC0372042]: Only `inline` can be called from a `function` or `inline`.\n --> compiler-test:5:16\n |\n 5 | return finalize_bar(a, b);\n | ^^^^^^^^^^^^^^^^^^\nError [ETYC0372101]: Can only make an async call from an async transition.\n --> compiler-test:5:16\n |\n 5 | return finalize_bar(a, b);\n | ^^^^^^^^^^^^^^^^^^\n |\n = Move the async call inside of the async transition block.\nError [ETYC0372106]: An async function is not allowed to return a value.\n --> compiler-test:12:5\n |\n 12 | async function finalize_bar(a: u8, b: u8) -> u8 {\n 13 | return a + b;\n 14 | }\n | ^\n |\n = Remove an output type in the function signature, and remove the return statement from the function. Note that the future returned by async functions is automatically inferred, and must not be explicitly written.\nError [ETYC0372110]: A `transition` cannot return a future.\n --> compiler-test:17:61\n |\n 17 | function mint_public(receiver: address, amount: u64) -> Future {\n | ^^^^^^\n |\n = Use an `async transition` instead.\nError [ETYC0372042]: Only `inline` can be called from a `function` or `inline`.\n --> compiler-test:18:16\n |\n 18 | return finalize_mint(receiver, amount);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nError [ETYC0372101]: Can only make an async call from an async transition.\n --> compiler-test:18:16\n |\n 18 | return finalize_mint(receiver, amount);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Move the async call inside of the async transition block.\nError [ETYC0372005]: Unknown variable `account`\n --> compiler-test:22:22\n |\n 22 | Mapping::set(account, receiver, amount);\n | ^^^^^^^\nError [ETYC0372083]: A program must have at least one transition function.\n --> compiler-test:1:1\n |\n 1 | \n 2 | \n 3 | program test.aleo { \n | ^^^^^^^^^^^^\n" diff --git a/tests/expectations/compiler/finalize/finalize_fail.out b/tests/expectations/compiler/finalize/finalize_fail.out index 38ec912fa4..54fd32eb77 100644 --- a/tests/expectations/compiler/finalize/finalize_fail.out +++ b/tests/expectations/compiler/finalize/finalize_fail.out @@ -2,4 +2,4 @@ namespace: Compile expectation: Fail outputs: - - "Error [EPAR0370005]: expected ; -- found 'finalize'\n --> compiler-test:8:21\n |\n 8 | return then finalize(receiver, amount);\n | ^^^^^^^^" + - "Error [EAST0372006]: function `finalize_no_params` shadowed by\n --> compiler-test:27:5\n |\n 27 | async function finalize_no_params() {\n 28 | increment(values, 0u8, 1u8);\n 29 | increment(account, self.caller, 1u64);\n 30 | }\n | ^\nWarning [WPAR0370001]: The keyword `increment` is deprecated.\n --> compiler-test:12:9\n |\n 12 | increment(account, receiver, amount);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or_use, set, remove, contains}` for manipulating on-chain mappings.\nWarning [WPAR0370001]: The keyword `increment` is deprecated.\n --> compiler-test:28:9\n |\n 28 | increment(values, 0u8, 1u8);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or_use, set, remove, contains}` for manipulating on-chain mappings.\nWarning [WPAR0370001]: The keyword `increment` is deprecated.\n --> compiler-test:29:9\n |\n 29 | increment(account, self.caller, 1u64);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or_use, set, remove, contains}` for manipulating on-chain mappings." diff --git a/tests/expectations/compiler/finalize/finalize_incorrect_modes_fail.out b/tests/expectations/compiler/finalize/finalize_incorrect_modes_fail.out index d69ff4f05e..bf673e679a 100644 --- a/tests/expectations/compiler/finalize/finalize_incorrect_modes_fail.out +++ b/tests/expectations/compiler/finalize/finalize_incorrect_modes_fail.out @@ -2,4 +2,4 @@ namespace: Compile expectation: Fail outputs: - - "Error [EPAR0370005]: expected ; -- found 'finalize'\n --> compiler-test:7:21\n |\n 7 | return then finalize(receiver, amount);\n | ^^^^^^^^" + - "Error [ETYC0372106]: An async function is not allowed to return a value.\n --> compiler-test:10:5\n |\n 10 | async function finalize_mint_public(public receiver: address, constant amount: u64) -> constant u64 {\n 11 | Mapping::set(account, receiver, amount);\n 12 | }\n | ^\n |\n = Remove an output type in the function signature, and remove the return statement from the function. Note that the future returned by async functions is automatically inferred, and must not be explicitly written.\nError [ETYC0372032]: An input to an async function must be public.\n --> compiler-test:10:76\n |\n 10 | async function finalize_mint_public(public receiver: address, constant amount: u64) -> constant u64 {\n | ^^^^^^\n |\n = Use a `public` modifier to the input variable declaration or remove the visibility modifier entirely.\nError [ETYC0372038]: A returned value cannot be a constant.\n --> compiler-test:10:101\n |\n 10 | async function finalize_mint_public(public receiver: address, constant amount: u64) -> constant u64 {\n | ^^^\nError [ETYC0372036]: Function must return a value.\n --> compiler-test:10:5\n |\n 10 | async function finalize_mint_public(public receiver: address, constant amount: u64) -> constant u64 {\n 11 | Mapping::set(account, receiver, amount);\n 12 | }\n | ^\nError [ETYC0372106]: An async function is not allowed to return a value.\n --> compiler-test:18:5\n |\n 18 | async function finalize_mint_public2(public receiver: address, amount: u64) -> u64 {\n 19 | Mapping::set(account, receiver, amount);\n 20 | return amount + amount;\n 21 | }\n | ^\n |\n = Remove an output type in the function signature, and remove the return statement from the function. Note that the future returned by async functions is automatically inferred, and must not be explicitly written.\n" diff --git a/tests/expectations/compiler/finalize/finalize_incorrect_return_fail.out b/tests/expectations/compiler/finalize/finalize_incorrect_return_fail.out index d69ff4f05e..ca98538534 100644 --- a/tests/expectations/compiler/finalize/finalize_incorrect_return_fail.out +++ b/tests/expectations/compiler/finalize/finalize_incorrect_return_fail.out @@ -2,4 +2,4 @@ namespace: Compile expectation: Fail outputs: - - "Error [EPAR0370005]: expected ; -- found 'finalize'\n --> compiler-test:7:21\n |\n 7 | return then finalize(receiver, amount);\n | ^^^^^^^^" + - "Error [ETYC0372106]: An async function is not allowed to return a value.\n --> compiler-test:10:5\n |\n 10 | async function finalize_mint_public(public receiver: address, public amount: u64) -> u64 {\n 11 | Mapping::set(account, receiver, amount);\n 12 | return 1u8 + 2u8;\n 13 | }\n | ^\n |\n = Remove an output type in the function signature, and remove the return statement from the function. Note that the future returned by async functions is automatically inferred, and must not be explicitly written.\nError [ETYC0372003]: Expected type `u64` but type `u8` was found\n --> compiler-test:12:16\n |\n 12 | return 1u8 + 2u8;\n | ^^^\nError [ETYC0372003]: Expected type `u64` but type `u8` was found\n --> compiler-test:12:22\n |\n 12 | return 1u8 + 2u8;\n | ^^^\n" 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 index a766d45e3c..19eb5bdeef 100644 --- a/tests/expectations/compiler/finalize/finalize_reassign_to_outer_scope_fail.out +++ b/tests/expectations/compiler/finalize/finalize_reassign_to_outer_scope_fail.out @@ -2,4 +2,4 @@ namespace: Compile expectation: Fail outputs: - - "Error [EPAR0370005]: expected ; -- found 'finalize'\n --> compiler-test:11:21\n |\n 11 | return then finalize();\n | ^^^^^^^^" + - "Error [ETYC0372109]: Cannot re-assign to `try_get_token` from a conditional scope to an outer scope in an async function.\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 async functions.\n" diff --git a/tests/expectations/compiler/finalize/only_finalize_with_flattening.out b/tests/expectations/compiler/finalize/only_finalize_with_flattening.out index a19272f83e..837c247828 100644 --- a/tests/expectations/compiler/finalize/only_finalize_with_flattening.out +++ b/tests/expectations/compiler/finalize/only_finalize_with_flattening.out @@ -4,15 +4,15 @@ expectation: Pass outputs: - - compile: - initial_symbol_table: 56c4eea018bad5b00fa3584917fe6327a28220606b7ef3392dd4f52510eb836d - type_checked_symbol_table: 9aef8c132cabed231ccd4e6f52d22aeeb6ab58e8b4a6c1495ed006b362dc9300 - unrolled_symbol_table: 9aef8c132cabed231ccd4e6f52d22aeeb6ab58e8b4a6c1495ed006b362dc9300 - initial_ast: 673ddb7aefe2c0b9730729803ed75d8872403283c84d98a54d7fc6523ded8910 - unrolled_ast: 673ddb7aefe2c0b9730729803ed75d8872403283c84d98a54d7fc6523ded8910 - ssa_ast: 16e3251569666681488bebdd375c59699798513d504a0b425276804e48a4bb05 - flattened_ast: b5c04913c1c93e7d83d43110ff20867d47638939ae3f9c14c72c20093d3541d8 - destructured_ast: 3cae3c5514a1f66dd417a45e5459abaf68f6ca1c16c0869144b275b7f3ddf35d - inlined_ast: 9a915933070f37ae3a89bca25e56d4a085b05fea61ea7e7cc2a524b498b1dc1d - dce_ast: 9a915933070f37ae3a89bca25e56d4a085b05fea61ea7e7cc2a524b498b1dc1d + type_checked_symbol_table: a53c4315ffbe58449d9ef772a8fab06c43082a1d24d3eb4240fd8c3be3ac0ad1 + unrolled_symbol_table: a53c4315ffbe58449d9ef772a8fab06c43082a1d24d3eb4240fd8c3be3ac0ad1 + initial_ast: 31d6210343f8a439e9a731aa2b344a0a35bb4828fcbfb5b7f3d3c532aa0d49e0 + unrolled_ast: 31d6210343f8a439e9a731aa2b344a0a35bb4828fcbfb5b7f3d3c532aa0d49e0 + ssa_ast: ed0d528c739439b087da26d083d1a1c6705e5e9b020f6dbb6d1510929df3079f + flattened_ast: 6022517c96f9f27f698a3763e2745248829606c98f0089a6ec969c21e46c17e8 + destructured_ast: d3da411156bdf490343160266cbc638347e8699097e129137eaf2eb328d5227c + inlined_ast: ab6e5a75c050c438cf92aeb65992405668b7587c04c088d5b158a9bbecf31c55 + dce_ast: ab6e5a75c050c438cf92aeb65992405668b7587c04c088d5b158a9bbecf31c55 bytecode: d6edcce70bf27b2fad397a62ae0bee08448a0c157d89e49867d843d83a04bfb7 errors: "" warnings: "" diff --git a/tests/expectations/parser/program/network_id.out b/tests/expectations/parser/program/network_id.out index f080857fcf..4ad5c61a1f 100644 --- a/tests/expectations/parser/program/network_id.out +++ b/tests/expectations/parser/program/network_id.out @@ -16,14 +16,13 @@ outputs: variant: Function identifier: "{\"id\":\"2\",\"name\":\"main\",\"span\":\"{\\\"lo\\\":34,\\\"hi\\\":38}\"}" input: - - Internal: - identifier: "{\"id\":\"3\",\"name\":\"a\",\"span\":\"{\\\"lo\\\":39,\\\"hi\\\":40}\"}" - mode: None - type_: Address - span: - lo: 39 - hi: 40 - id: 4 + - identifier: "{\"id\":\"3\",\"name\":\"a\",\"span\":\"{\\\"lo\\\":39,\\\"hi\\\":40}\"}" + mode: None + type_: Address + span: + lo: 39 + hi: 40 + id: 4 output: [] output_type: Unit block: diff --git a/tests/expectations/parser/program/special_address.out b/tests/expectations/parser/program/special_address.out index f581b49bdf..f444d7d4f9 100644 --- a/tests/expectations/parser/program/special_address.out +++ b/tests/expectations/parser/program/special_address.out @@ -25,14 +25,13 @@ outputs: variant: Transition identifier: "{\"id\":\"4\",\"name\":\"main\",\"span\":\"{\\\"lo\\\":70,\\\"hi\\\":74}\"}" input: - - Internal: - identifier: "{\"id\":\"5\",\"name\":\"a\",\"span\":\"{\\\"lo\\\":75,\\\"hi\\\":76}\"}" - mode: None - type_: Address - span: - lo: 75 - hi: 76 - id: 6 + - identifier: "{\"id\":\"5\",\"name\":\"a\",\"span\":\"{\\\"lo\\\":75,\\\"hi\\\":76}\"}" + mode: None + type_: Address + span: + lo: 75 + hi: 76 + id: 6 output: [] output_type: Unit block: diff --git a/tests/tests/compiler/finalize/closure_with_finalize_fail.leo b/tests/tests/compiler/finalize/closure_with_finalize_fail.leo index b435058f73..83d9733d73 100644 --- a/tests/tests/compiler/finalize/closure_with_finalize_fail.leo +++ b/tests/tests/compiler/finalize/closure_with_finalize_fail.leo @@ -4,8 +4,8 @@ expectation: Fail */ program test.aleo { - function foo(a: u8, b: u8) -> u8 { - return a + b then finalize(a, b); + function foo(a: u8, b: u8) -> Future { + return finalize_bar(a, b); } function bar(a: u8, b: u8) -> u8 { diff --git a/tests/tests/compiler/finalize/finalize_fail.leo b/tests/tests/compiler/finalize/finalize_fail.leo index 309454d7bd..74f91d7c07 100644 --- a/tests/tests/compiler/finalize/finalize_fail.leo +++ b/tests/tests/compiler/finalize/finalize_fail.leo @@ -8,26 +8,26 @@ program test.aleo { mapping values: u8 => u8; async transition mint_public(public receiver: address, public amount: u64) -> Future { - return then finalize(receiver, amount); + return finalize_mint_public(receiver, amount); } - finalize mint_public (public receiver: address, public amount: u64) { + async function finalize_mint_public(public receiver: address, public amount: u64) { increment(account, receiver, amount); } - transition public_adder(public a: u8, public b: u8) { - return then finalize(a, b); + async transition public_adder(public a: u8, public b: u8) -> Future { + return finalize_public_adder(a, b); } - finalize public_adder(a: u8, b: u8) -> public u8 { + async function finalize_public_adder(a: u8, b: u8) -> public u8 { return a + b; } - transition finalize_no_params() { - return then finalize(); + async transition finalize_no_params() -> Future { + return finalize_no_params(); } - finalize finalize_no_params() { + async function finalize_no_params() { increment(values, 0u8, 1u8); increment(account, self.caller, 1u64); } diff --git a/tests/tests/compiler/finalize/finalize_incorrect_modes_fail.leo b/tests/tests/compiler/finalize/finalize_incorrect_modes_fail.leo index 9d715064b0..24db42bb6c 100644 --- a/tests/tests/compiler/finalize/finalize_incorrect_modes_fail.leo +++ b/tests/tests/compiler/finalize/finalize_incorrect_modes_fail.leo @@ -6,19 +6,19 @@ expectation: Fail program test.aleo { mapping account: address => u64; - transition mint_public(public receiver: address, public amount: u64) { - return then finalize(receiver, amount); + async transition mint_public(public receiver: address, public amount: u64) -> Future { + return finalize_mint_public(receiver, amount); } - finalize mint_public (public receiver: address, constant amount: u64) -> constant u64 { + async function finalize_mint_public(public receiver: address, constant amount: u64) -> constant u64 { Mapping::set(account, receiver, amount); } - transition mint_public2(public receiver: address, public amount: u64) { - return then finalize(receiver, amount); + async transition mint_public2(public receiver: address, public amount: u64) -> Future { + return finalize_mint_public2(receiver, amount); } - finalize mint_public2(public receiver: address, amount: u64) -> u64 { + async function finalize_mint_public2(public receiver: address, amount: u64) -> u64 { Mapping::set(account, receiver, amount); return amount + amount; } diff --git a/tests/tests/compiler/finalize/finalize_incorrect_return_fail.leo b/tests/tests/compiler/finalize/finalize_incorrect_return_fail.leo index 86b6e01c44..e9cf2a2492 100644 --- a/tests/tests/compiler/finalize/finalize_incorrect_return_fail.leo +++ b/tests/tests/compiler/finalize/finalize_incorrect_return_fail.leo @@ -6,11 +6,11 @@ expectation: Fail program test.aleo { mapping account: address => u64; - transition mint_public(public receiver: address, public amount: u64) { - return then finalize(receiver, amount); + async transition mint_public(public receiver: address, public amount: u64) -> Future { + return finalize_mint_public(receiver, amount); } - finalize mint_public(public receiver: address, public amount: u64) -> u64 { + async function finalize_mint_public(public receiver: address, public amount: u64) -> u64 { Mapping::set(account, receiver, amount); return 1u8 + 2u8; } 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 index c44438454f..295f7d2262 100644 --- a/tests/tests/compiler/finalize/finalize_reassign_to_outer_scope_fail.leo +++ b/tests/tests/compiler/finalize/finalize_reassign_to_outer_scope_fail.leo @@ -12,12 +12,12 @@ program test.aleo { mapping token_name_to_info: field => TokenInfo; - transition add_new_liquidity_token_2 () { - return then finalize(); + async transition add_new_liquidity_token_2() -> Future { + return finalize_add_new_liquidity_token_2(); } - finalize add_new_liquidity_token_2() { + async function finalize_add_new_liquidity_token_2() { let try_get_token: TokenInfo = Mapping::get_or_use( token_name_to_info, 0field, diff --git a/tests/tests/compiler/finalize/only_finalize_with_flattening.leo b/tests/tests/compiler/finalize/only_finalize_with_flattening.leo index 335be3392f..1e3adddfc4 100644 --- a/tests/tests/compiler/finalize/only_finalize_with_flattening.leo +++ b/tests/tests/compiler/finalize/only_finalize_with_flattening.leo @@ -44,11 +44,8 @@ program test.aleo { 0field, TokenInfo { id: 0u64 } ); - if try_get_token.id == 0u64 { - try_get_token = TokenInfo { id: 10u64 }; - } else { - return; - } + try_get_token = (try_get_token.id == 0u64) ? TokenInfo { id: 10u64 } : try_get_token; + return; } } diff --git a/tests/tests/parser/program/locator_expression_fail.leo b/tests/tests/parser/program/locator_expression_fail.leo index e47dbc5591..b2eaded3f8 100644 --- a/tests/tests/parser/program/locator_expression_fail.leo +++ b/tests/tests/parser/program/locator_expression_fail.leo @@ -6,11 +6,11 @@ expectation: Fail program relay.aleo { mapping users: address => bool; - transition send(addr: address) { + transition send(addr: address) -> Future { let a: mapping = relay.aleo/users; - return then finalize(addr); + return finalize_send(addr); } async function finalize_send(addr: address) { let a:bool = Mapping::get(relay.aleo/users, addr); } -} \ No newline at end of file +}