From 5b147acfbba829250f893e608f30b362e6b6337e Mon Sep 17 00:00:00 2001 From: Sean Billig Date: Mon, 30 May 2022 14:25:13 -0700 Subject: [PATCH] Curly brace block syntax --- README.md | 14 +- crates/analyzer/src/traversal/functions.rs | 1 - crates/analyzer/tests/errors.rs | 35 +- .../analysis__abi_encoding_stress.snap | 478 ++- .../analysis__address_bytes10_map.snap | 102 +- .../tests/snapshots/analysis__assert.snap | 157 +- .../snapshots/analysis__associated_fns.snap | 171 +- .../tests/snapshots/analysis__aug_assign.snap | 247 +- .../tests/snapshots/analysis__balances.snap | 114 +- .../tests/snapshots/analysis__base_tuple.snap | 5 +- .../snapshots/analysis__basic_ingot.snap | 317 +- .../analysis__call_statement_with_args.snap | 84 +- .../analysis__call_statement_with_args_2.snap | 42 +- ...analysis__call_statement_without_args.snap | 84 +- .../analysis__checked_arithmetic.snap | 1888 +++++----- .../snapshots/analysis__const_generics.snap | 22 +- .../snapshots/analysis__const_local.snap | 6 +- .../snapshots/analysis__constructor.snap | 53 +- .../snapshots/analysis__create2_contract.snap | 35 +- .../snapshots/analysis__create_contract.snap | 46 +- .../analysis__create_contract_from_init.snap | 30 +- .../analysis__data_copying_stress.snap | 491 ++- .../tests/snapshots/analysis__empty.snap | 6 +- .../snapshots/analysis__erc20_token.snap | 1487 ++++---- .../tests/snapshots/analysis__events.snap | 110 +- .../analysis__external_contract.snap | 130 +- .../analysis__for_loop_with_break.snap | 82 +- .../analysis__for_loop_with_continue.snap | 81 +- .../analysis__for_loop_with_static_array.snap | 71 +- .../tests/snapshots/analysis__guest_book.snap | 68 +- .../snapshots/analysis__if_statement.snap | 30 +- .../snapshots/analysis__if_statement_2.snap | 36 +- ...__if_statement_with_block_declaration.snap | 66 +- .../tests/snapshots/analysis__keccak.snap | 39 +- .../tests/snapshots/analysis__math.snap | 149 +- .../snapshots/analysis__module_const.snap | 67 +- .../analysis__module_level_events.snap | 21 +- .../snapshots/analysis__multi_param.snap | 5 +- .../tests/snapshots/analysis__nested_map.snap | 196 +- .../snapshots/analysis__numeric_sizes.snap | 420 +-- .../tests/snapshots/analysis__ownable.snap | 229 +- .../analysis__pure_fn_standalone.snap | 94 +- .../analysis__return_addition_i256.snap | 5 +- .../analysis__return_addition_u128.snap | 5 +- .../analysis__return_addition_u256.snap | 5 +- .../snapshots/analysis__return_array.snap | 11 +- .../analysis__return_bitwiseand_u128.snap | 5 +- .../analysis__return_bitwiseand_u256.snap | 5 +- .../analysis__return_bitwiseor_u256.snap | 5 +- .../analysis__return_bitwiseshl_u256.snap | 5 +- .../analysis__return_bitwiseshr_i256.snap | 5 +- .../analysis__return_bitwiseshr_u256.snap | 5 +- .../analysis__return_bitwisexor_u256.snap | 5 +- .../analysis__return_bool_false.snap | 5 +- .../analysis__return_bool_inverted.snap | 5 +- .../analysis__return_bool_op_and.snap | 5 +- .../analysis__return_bool_op_or.snap | 5 +- .../snapshots/analysis__return_bool_true.snap | 5 +- .../analysis__return_builtin_attributes.snap | 216 +- .../analysis__return_division_i256.snap | 5 +- .../analysis__return_division_u256.snap | 5 +- .../analysis__return_empty_tuple.snap | 70 +- .../snapshots/analysis__return_eq_u256.snap | 5 +- .../snapshots/analysis__return_gt_i256.snap | 5 +- .../snapshots/analysis__return_gt_u256.snap | 5 +- .../snapshots/analysis__return_gte_i256.snap | 5 +- .../snapshots/analysis__return_gte_u256.snap | 5 +- .../snapshots/analysis__return_i128_cast.snap | 5 +- .../snapshots/analysis__return_i256.snap | 5 +- .../analysis__return_identity_u128.snap | 5 +- .../analysis__return_identity_u16.snap | 5 +- .../analysis__return_identity_u256.snap | 5 +- .../analysis__return_identity_u32.snap | 5 +- .../analysis__return_identity_u64.snap | 5 +- .../analysis__return_identity_u8.snap | 5 +- .../snapshots/analysis__return_lt_i256.snap | 5 +- .../snapshots/analysis__return_lt_u128.snap | 5 +- .../snapshots/analysis__return_lt_u256.snap | 5 +- .../snapshots/analysis__return_lte_i256.snap | 5 +- .../snapshots/analysis__return_lte_u256.snap | 5 +- .../snapshots/analysis__return_mod_i256.snap | 5 +- .../snapshots/analysis__return_mod_u256.snap | 5 +- .../snapshots/analysis__return_msg_sig.snap | 5 +- .../analysis__return_multiplication_i256.snap | 5 +- .../analysis__return_multiplication_u256.snap | 5 +- .../analysis__return_noteq_u256.snap | 5 +- .../snapshots/analysis__return_pow_i256.snap | 5 +- .../snapshots/analysis__return_pow_u256.snap | 5 +- .../analysis__return_subtraction_i256.snap | 5 +- .../analysis__return_subtraction_u256.snap | 5 +- .../snapshots/analysis__return_u128_cast.snap | 5 +- .../snapshots/analysis__return_u256.snap | 5 +- .../analysis__return_u256_from_called_fn.snap | 26 +- ..._return_u256_from_called_fn_with_args.snap | 111 +- .../tests/snapshots/analysis__revert.snap | 84 +- .../snapshots/analysis__self_address.snap | 5 +- .../tests/snapshots/analysis__send_value.snap | 5 +- .../analysis__simple_open_auction.snap | 261 +- .../analysis__sized_vals_in_sto.snap | 187 +- .../tests/snapshots/analysis__strings.snap | 77 +- .../tests/snapshots/analysis__struct_fns.snap | 674 ++-- .../tests/snapshots/analysis__structs.snap | 2116 ++++++----- .../analysis__ternary_expression.snap | 21 +- .../snapshots/analysis__tuple_stress.snap | 298 +- .../snapshots/analysis__two_contracts.snap | 100 +- .../snapshots/analysis__type_aliases.snap | 168 +- .../snapshots/analysis__u128_u128_map.snap | 100 +- .../snapshots/analysis__u16_u16_map.snap | 100 +- .../snapshots/analysis__u256_u256_map.snap | 100 +- .../snapshots/analysis__u32_u32_map.snap | 100 +- .../snapshots/analysis__u64_u64_map.snap | 100 +- .../tests/snapshots/analysis__u8_u8_map.snap | 100 +- .../tests/snapshots/analysis__uniswap.snap | 3105 +++++++++-------- .../tests/snapshots/analysis__while_loop.snap | 73 +- .../analysis__while_loop_with_break.snap | 19 +- .../analysis__while_loop_with_break_2.snap | 66 +- .../analysis__while_loop_with_continue.snap | 34 +- .../tests/snapshots/errors__bad_ingot.snap | 22 +- .../snapshots/errors__bad_visibility.snap | 89 +- .../errors__break_without_loop_2.snap | 6 +- .../errors__call_balance_of_with_2_args.snap | 10 +- ...rors__call_balance_of_with_wrong_type.snap | 6 +- ...rs__call_balance_of_without_parameter.snap | 10 +- .../errors__call_balance_with_arg.snap | 10 +- .../errors__call_builtin_object.snap | 6 +- ...rrors__call_call_on_external_contract.snap | 6 +- .../snapshots/errors__call_call_on_self.snap | 6 +- .../errors__call_create2_with_wrong_type.snap | 28 +- .../errors__call_create_with_wrong_type.snap | 8 +- .../snapshots/errors__call_duplicate_def.snap | 25 +- .../errors__call_event_with_wrong_types.snap | 16 +- ..._call_non_pub_fn_on_external_contract.snap | 13 +- ..._static_function_without_double_colon.snap | 4 +- .../errors__call_to_mut_fn_without_self.snap | 4 +- .../errors__call_to_pure_fn_on_self.snap | 4 +- ...defined_function_on_external_contract.snap | 6 +- ...l_undefined_function_on_memory_struct.snap | 6 +- ..._undefined_function_on_storage_struct.snap | 6 +- .../snapshots/errors__call_with_pub_fns.snap | 38 +- .../errors__call_wrong_return_type.snap | 2 +- .../tests/snapshots/errors__cannot_move2.snap | 6 +- .../errors__circular_type_alias.snap | 8 +- .../tests/snapshots/errors__const_assign.snap | 12 +- .../errors__const_generics_param.snap | 24 +- .../tests/snapshots/errors__const_local.snap | 22 +- .../errors__continue_without_loop_2.snap | 6 +- ...rs__ctx_builtins_param_incorrect_type.snap | 16 +- .../snapshots/errors__ctx_missing_event.snap | 12 +- .../errors__ctx_missing_internal_call.snap | 4 +- .../snapshots/errors__ctx_not_after_self.snap | 2 +- .../snapshots/errors__ctx_not_first.snap | 2 +- .../errors__ctx_passed_external_call.snap | 4 +- .../tests/snapshots/errors__ctx_pure.snap | 2 +- .../errors__ctx_undefined_contract_init.snap | 10 +- .../errors__ctx_undefined_create.snap | 10 +- .../errors__ctx_undefined_create2.snap | 10 +- .../errors__ctx_undefined_event.snap | 6 +- ...ors__duplicate_arg_in_contract_method.snap | 4 +- .../errors__duplicate_contract_in_module.snap | 4 +- .../errors__duplicate_event_in_contract.snap | 14 +- .../errors__duplicate_method_in_contract.snap | 16 +- .../errors__duplicate_struct_in_module.snap | 4 +- .../errors__duplicate_typedef_in_module.snap | 14 +- .../errors__duplicate_var_in_child_scope.snap | 2 +- .../errors__duplicate_var_in_for_loop.snap | 20 +- .../snapshots/errors__emit_bad_args.snap | 34 +- .../errors__for_loop_sto_iter_no_copy.snap | 2 +- ...rrors__init_call_on_external_contract.snap | 6 +- .../snapshots/errors__init_call_on_self.snap | 6 +- .../snapshots/errors__init_duplicate_def.snap | 25 +- .../errors__init_wrong_return_type.snap | 2 +- .../errors__invalid_block_field.snap | 6 +- .../errors__invalid_chain_field.snap | 6 +- .../errors__invalid_contract_field.snap | 6 +- .../snapshots/errors__invalid_msg_field.snap | 6 +- .../errors__invalid_string_field.snap | 6 +- .../errors__invalid_struct_field.snap | 6 +- .../errors__invalid_tuple_field.snap | 6 +- .../snapshots/errors__invalid_tx_field.snap | 6 +- .../errors__invalid_var_declaration_1.snap | 6 +- .../errors__invalid_var_declaration_2.snap | 6 +- .../tests/snapshots/errors__issue_451.snap | 27 +- .../errors__mislabeled_call_args.snap | 8 +- ...eled_call_args_external_contract_call.snap | 12 +- .../errors__mislabeled_call_args_self.snap | 8 +- .../errors__mismatch_return_type.snap | 4 +- .../snapshots/errors__missing_return.snap | 2 +- .../errors__missing_return_after_if.snap | 2 +- .../errors__missing_return_in_else.snap | 2 +- .../tests/snapshots/errors__missing_self.snap | 4 +- .../snapshots/errors__module_const_call.snap | 6 +- .../snapshots/errors__needs_mem_copy.snap | 4 +- .../tests/snapshots/errors__non_pub_init.snap | 9 +- .../tests/snapshots/errors__not_callable.snap | 18 +- .../errors__private_struct_field.snap | 6 +- .../errors__return_complex_struct.snap | 6 +- .../snapshots/errors__return_from_init.snap | 2 +- .../errors__return_type_not_fixedsize.snap | 6 +- .../errors__return_type_undefined.snap | 6 +- .../errors__revert_sto_error_no_copy.snap | 4 +- .../errors__self_in_standalone_fn.snap | 4 +- .../tests/snapshots/errors__self_misuse.snap | 34 +- .../snapshots/errors__self_not_first.snap | 2 +- .../errors__shadow_builtin_function.snap | 20 +- .../errors__shadow_builtin_type.snap | 28 +- .../errors__strict_boolean_if_else.snap | 2 +- .../errors__struct_recursive_cycles.snap | 11 +- .../errors__undefined_type_param.snap | 2 +- .../snapshots/errors__unsafe_misuse.snap | 39 +- .../snapshots/errors__unsafe_nesting.snap | 18 +- crates/library/std/src/context.fe | 139 +- crates/library/std/src/error.fe | 3 +- crates/library/std/src/evm.fe | 305 +- crates/library/std/src/lib.fe | 3 +- crates/mir/src/lower/function.rs | 7 - crates/parser/src/ast.rs | 236 +- crates/parser/src/grammar/Fe.grammar | 32 +- crates/parser/src/grammar/Python.asdl | 130 - crates/parser/src/grammar/SimPy.grammar | 164 - crates/parser/src/grammar/contracts.rs | 41 +- crates/parser/src/grammar/expressions.rs | 6 +- crates/parser/src/grammar/functions.rs | 102 +- crates/parser/src/grammar/module.rs | 12 +- crates/parser/src/grammar/types.rs | 58 +- crates/parser/src/lexer.rs | 1 - crates/parser/src/lexer/token.rs | 14 +- crates/parser/src/parser.rs | 330 +- crates/parser/tests/cases/errors.rs | 44 +- crates/parser/tests/cases/parse_ast.rs | 98 +- crates/parser/tests/cases/print_ast.rs | 17 +- .../cases__errors__contract_bad_name.snap | 4 +- .../cases__errors__contract_const_fn.snap | 4 +- .../cases__errors__contract_empty_body.snap | 8 +- ...ses__errors__contract_field_after_def.snap | 6 +- .../cases__errors__contract_pub_event.snap | 4 +- .../cases__errors__emit_bad_call.snap | 4 +- .../snapshots/cases__errors__fn_def_kw.snap | 4 +- .../snapshots/cases__errors__fn_no_args.snap | 4 +- .../cases__errors__fn_unsafe_pub.snap | 4 +- .../snapshots/cases__errors__for_no_in.snap | 8 +- .../snapshots/cases__errors__if_no_body.snap | 8 +- .../cases__errors__module_bad_stmt.snap | 4 +- .../cases__errors__module_nonsense.snap | 12 +- .../cases__errors__self_contract.snap | 4 +- .../snapshots/cases__errors__self_fn.snap | 4 +- .../snapshots/cases__errors__self_struct.snap | 4 +- ..._stmt_vardecl_invalid_type_annotation.snap | 4 +- .../cases__errors__struct_bad_field_name.snap | 4 +- .../cases__parse_ast__contract_def.snap | 106 +- .../cases__parse_ast__empty_contract_def.snap | 6 +- .../cases__parse_ast__empty_event_def.snap | 6 +- .../cases__parse_ast__empty_struct_def.snap | 6 +- .../cases__parse_ast__event_def.snap | 30 +- .../snapshots/cases__parse_ast__fn_def.snap | 14 +- .../cases__parse_ast__fn_def_generic.snap | 6 +- .../cases__parse_ast__fn_def_pub.snap | 6 +- .../cases__parse_ast__fn_def_pub_unsafe.snap | 14 +- .../cases__parse_ast__fn_def_unsafe.snap | 14 +- .../cases__parse_ast__guest_book.snap | 206 +- ...cases__parse_ast__module_level_events.snap | 158 +- .../cases__parse_ast__module_stmts.snap | 86 +- .../cases__parse_ast__pub_contract_def.snap | 44 +- .../cases__parse_ast__pub_event_def.snap | 41 +- .../snapshots/cases__parse_ast__stmt_for.snap | 14 +- .../snapshots/cases__parse_ast__stmt_if.snap | 12 +- .../snapshots/cases__parse_ast__stmt_if2.snap | 44 +- .../cases__parse_ast__stmt_semicolons.snap | 91 + .../cases__parse_ast__stmt_while.snap | 20 +- .../cases__parse_ast__struct_def.snap | 156 +- .../snapshots/cases__print_ast__defs.snap | 66 + .../snapshots/cases__print_ast__erc20.snap | 124 + .../cases__print_ast__expr_parens.snap | 28 + .../cases__print_ast__guest_book.snap | 24 + .../compile_errors/abi_encode_from_storage.fe | 8 +- .../compile_errors/abi_encode_u256.fe | 8 +- .../compile_errors/assert_sto_msg_no_copy.fe | 8 +- .../compile_errors/bad_ingot/src/bing.fe | 3 +- .../compile_errors/bad_ingot/src/biz/bad.fe | 6 +- .../compile_errors/bad_ingot/src/foo.fe | 6 +- .../compile_errors/bad_ingot/src/main.fe | 10 +- .../fixtures/compile_errors/bad_string.fe | 6 +- .../compile_errors/bad_tuple_attr1.fe | 6 +- .../compile_errors/bad_tuple_attr2.fe | 8 +- .../compile_errors/bad_tuple_attr3.fe | 8 +- .../compile_errors/bad_visibility/src/foo.fe | 20 +- .../compile_errors/bad_visibility/src/main.fe | 31 +- .../compile_errors/call_builtin_object.fe | 9 +- .../call_call_on_external_contract.fe | 19 +- .../compile_errors/call_call_on_self.fe | 11 +- .../call_create2_with_wrong_type.fe | 10 +- .../call_create_with_wrong_type.fe | 9 +- .../compile_errors/call_duplicate_def.fe | 15 +- .../call_event_with_wrong_types.fe | 9 +- .../call_non_pub_fn_on_external_contract.fe | 19 +- ...ll_static_function_without_double_colon.fe | 15 +- .../call_to_mut_fn_without_self.fe | 9 +- .../compile_errors/call_to_pure_fn_on_self.fe | 11 +- ...undefined_function_on_external_contract.fe | 13 +- ...all_undefined_function_on_memory_struct.fe | 15 +- ...ll_undefined_function_on_storage_struct.fe | 15 +- .../compile_errors/call_with_pub_fns.fe | 15 +- .../compile_errors/call_wrong_return_type.fe | 8 +- .../fixtures/compile_errors/cannot_move.fe | 6 +- .../fixtures/compile_errors/cannot_move2.fe | 13 +- .../circular_dependency_create.fe | 9 +- .../circular_dependency_create2.fe | 9 +- .../compile_errors/circular_type_alias.fe | 2 + .../fixtures/compile_errors/const_assign.fe | 13 +- .../compile_errors/const_generics_param.fe | 29 +- .../fixtures/compile_errors/const_local.fe | 30 +- .../ctx_builtins_param_incorrect_type.fe | 15 +- .../fixtures/compile_errors/ctx_init.fe | 8 +- .../compile_errors/ctx_missing_create.fe | 12 +- .../compile_errors/ctx_missing_event.fe | 9 +- .../ctx_missing_internal_call.fe | 11 +- .../compile_errors/ctx_missing_load.fe | 12 +- .../compile_errors/ctx_not_after_self.fe | 6 +- .../fixtures/compile_errors/ctx_not_first.fe | 6 +- .../ctx_passed_external_call.fe | 15 +- .../fixtures/compile_errors/ctx_pure.fe | 3 +- .../fixtures/compile_errors/ctx_undeclared.fe | 8 +- .../ctx_undefined_contract_init.fe | 11 +- .../compile_errors/ctx_undefined_create.fe | 11 +- .../compile_errors/ctx_undefined_create2.fe | 11 +- .../compile_errors/ctx_undefined_event.fe | 11 +- .../duplicate_arg_in_contract_method.fe | 6 +- .../duplicate_contract_in_module.fe | 14 +- .../duplicate_event_in_contract.fe | 9 +- .../duplicate_field_in_contract.fe | 3 +- .../duplicate_field_in_struct.fe | 6 +- .../duplicate_method_in_contract.fe | 10 +- .../duplicate_struct_in_module.fe | 13 +- .../duplicate_typedef_in_module.fe | 8 +- .../duplicate_var_in_child_scope.fe | 9 +- .../duplicate_var_in_contract_method.fe | 6 +- .../duplicate_var_in_for_loop.fe | 18 +- .../fixtures/compile_errors/emit_bad_args.fe | 17 +- .../external_call_type_error.fe | 14 +- .../external_call_wrong_number_of_params.fe | 12 +- .../for_loop_sto_iter_no_copy.fe | 11 +- .../fixtures/compile_errors/indexed_event.fe | 6 +- .../init_call_on_external_contract.fe | 21 +- .../compile_errors/init_call_on_self.fe | 11 +- .../compile_errors/init_duplicate_def.fe | 15 +- .../compile_errors/init_wrong_return_type.fe | 8 +- .../compile_errors/invalid_block_field.fe | 9 +- .../compile_errors/invalid_chain_field.fe | 9 +- .../invalid_compiler_version.fe | 3 +- .../compile_errors/invalid_contract_field.fe | 10 +- .../compile_errors/invalid_msg_field.fe | 9 +- .../compile_errors/invalid_string_field.fe | 9 +- .../compile_errors/invalid_struct_field.fe | 15 +- .../compile_errors/invalid_tuple_field.fe | 10 +- .../compile_errors/invalid_tx_field.fe | 9 +- .../invalid_var_declaration_1.fe | 8 +- .../invalid_var_declaration_2.fe | 8 +- .../fixtures/compile_errors/issue_451.fe | 14 +- .../compile_errors/mislabeled_call_args.fe | 12 +- ...abeled_call_args_external_contract_call.fe | 16 +- .../mislabeled_call_args_self.fe | 10 +- .../compile_errors/mismatch_return_type.fe | 7 +- .../fixtures/compile_errors/missing_return.fe | 6 +- .../compile_errors/missing_return_after_if.fe | 9 +- .../compile_errors/missing_return_in_else.fe | 13 +- .../fixtures/compile_errors/missing_self.fe | 17 +- .../compile_errors/module_const_call.fe | 8 +- .../fixtures/compile_errors/needs_mem_copy.fe | 9 +- .../fixtures/compile_errors/non_pub_init.fe | 6 +- .../fixtures/compile_errors/not_callable.fe | 24 +- .../fixtures/compile_errors/not_in_scope.fe | 14 +- .../fixtures/compile_errors/not_in_scope_2.fe | 12 +- .../compile_errors/private_struct_field.fe | 15 +- .../return_addition_with_mixed_types.fe | 6 +- ...urn_call_to_fn_with_param_type_mismatch.fe | 10 +- .../return_call_to_fn_without_return.fe | 10 +- .../compile_errors/return_complex_struct.fe | 13 +- .../compile_errors/return_from_init.fe | 6 +- .../compile_errors/return_lt_mixed_types.fe | 6 +- .../return_type_not_fixedsize.fe | 6 +- .../compile_errors/return_type_undefined.fe | 6 +- .../revert_sto_error_no_copy.fe | 11 +- .../compile_errors/self_in_standalone_fn.fe | 12 +- .../fixtures/compile_errors/self_misuse.fe | 53 +- .../fixtures/compile_errors/self_not_first.fe | 6 +- .../compile_errors/shadow_builtin_function.fe | 18 +- .../compile_errors/shadow_builtin_type.fe | 15 +- .../compile_errors/strict_boolean_if_else.fe | 11 +- .../compile_errors/struct_call_bad_args.fe | 10 +- .../struct_call_without_kw_args.fe | 10 +- .../struct_private_constructor.fe | 10 +- .../compile_errors/struct_recursive_cycles.fe | 19 +- .../compile_errors/undefined_type_param.fe | 18 +- .../fixtures/compile_errors/unsafe_misuse.fe | 82 +- .../fixtures/compile_errors/unsafe_nesting.fe | 20 +- .../test-files/fixtures/crashes/agroce531.fe | 10 +- .../test-files/fixtures/crashes/agroce550.fe | 8 +- .../test-files/fixtures/crashes/agroce551.fe | 8 +- .../test-files/fixtures/crashes/agroce623.fe | 8 +- .../fixtures/crashes/revert_const.fe | 10 +- .../test-files/fixtures/demos/erc20_token.fe | 63 +- .../test-files/fixtures/demos/guest_book.fe | 12 +- .../fixtures/demos/simple_open_auction.fe | 70 +- crates/test-files/fixtures/demos/uniswap.fe | 204 +- .../fixtures/differential/math_i8.fe | 100 +- .../fixtures/differential/math_u8.fe | 141 +- .../differential/storage_and_memory.fe | 90 +- .../fixtures/features/abi_decode_checks.fe | 25 +- .../fixtures/features/address_bytes10_map.fe | 11 +- crates/test-files/fixtures/features/arrays.fe | 9 +- crates/test-files/fixtures/features/assert.fe | 18 +- .../fixtures/features/associated_fns.fe | 30 +- .../fixtures/features/aug_assign.fe | 42 +- .../test-files/fixtures/features/balances.fe | 9 +- .../fixtures/features/base_tuple.fe | 6 +- .../test-files/fixtures/features/call_fn.fe | 16 +- .../features/call_statement_with_args.fe | 9 +- .../features/call_statement_with_args_2.fe | 9 +- .../features/call_statement_without_args.fe | 9 +- .../fixtures/features/cast_address_to_u256.fe | 10 +- .../fixtures/features/checked_arithmetic.fe | 222 +- .../fixtures/features/const_generics.fe | 18 +- .../fixtures/features/const_local.fe | 8 +- .../fixtures/features/constructor.fe | 11 +- .../fixtures/features/create2_contract.fe | 13 +- .../fixtures/features/create_contract.fe | 12 +- .../features/create_contract_from_init.fe | 17 +- .../fixtures/features/ctx_init_in_call.fe | 15 +- .../features/ctx_param_external_func_call.fe | 22 +- .../features/ctx_param_internal_func_call.fe | 13 +- .../fixtures/features/ctx_param_simple.fe | 9 +- crates/test-files/fixtures/features/empty.fe | 5 +- crates/test-files/fixtures/features/events.fe | 29 +- .../fixtures/features/external_contract.fe | 32 +- .../fixtures/features/for_loop_with_break.fe | 15 +- .../features/for_loop_with_continue.fe | 15 +- .../features/for_loop_with_static_array.fe | 12 +- .../for_loop_with_static_array_from_sto.fe | 14 +- .../fixtures/features/if_statement.fe | 12 +- .../fixtures/features/if_statement_2.fe | 13 +- .../features/if_statement_test_from_sto.fe | 21 +- .../if_statement_with_block_declaration.fe | 14 +- .../fixtures/features/int_literal_coercion.fe | 6 +- .../fixtures/features/intrinsics.fe | 235 +- crates/test-files/fixtures/features/keccak.fe | 13 +- .../test-files/fixtures/features/map_tuple.fe | 6 +- crates/test-files/fixtures/features/math.fe | 19 +- .../fixtures/features/module_const.fe | 9 +- .../fixtures/features/module_level_events.fe | 11 +- .../fixtures/features/multi_param.fe | 6 +- .../fixtures/features/nested_map.fe | 15 +- .../fixtures/features/numeric_casts.fe | 22 +- .../fixtures/features/numeric_sizes.fe | 78 +- .../test-files/fixtures/features/ownable.fe | 42 +- .../test-files/fixtures/features/pure_fn.fe | 8 +- .../features/pure_fn_internal_call.fe | 11 +- .../fixtures/features/pure_fn_standalone.fe | 18 +- .../fixtures/features/radix_binary.fe | 6 +- .../test-files/fixtures/features/radix_hex.fe | 6 +- .../fixtures/features/radix_octal.fe | 6 +- .../fixtures/features/return_addition_i256.fe | 6 +- .../fixtures/features/return_addition_u128.fe | 6 +- .../fixtures/features/return_addition_u256.fe | 6 +- .../fixtures/features/return_array.fe | 8 +- .../features/return_bitwiseand_u128.fe | 6 +- .../features/return_bitwiseand_u256.fe | 6 +- .../features/return_bitwiseor_u256.fe | 6 +- .../features/return_bitwiseshl_i64_coerced.fe | 6 +- .../fixtures/features/return_bitwiseshl_i8.fe | 6 +- .../features/return_bitwiseshl_u256.fe | 6 +- .../fixtures/features/return_bitwiseshl_u8.fe | 6 +- .../features/return_bitwiseshr_i256.fe | 6 +- .../features/return_bitwiseshr_u256.fe | 6 +- .../features/return_bitwisexor_u256.fe | 6 +- .../fixtures/features/return_bool_false.fe | 6 +- .../fixtures/features/return_bool_inverted.fe | 6 +- .../fixtures/features/return_bool_op_and.fe | 8 +- .../fixtures/features/return_bool_op_or.fe | 8 +- .../fixtures/features/return_bool_true.fe | 6 +- .../features/return_builtin_attributes.fe | 34 +- .../features/return_cast_i8_to_unsigned.fe | 6 +- .../features/return_cast_u8_to_signed.fe | 6 +- .../fixtures/features/return_division_i256.fe | 6 +- .../fixtures/features/return_division_u256.fe | 6 +- .../fixtures/features/return_eq_u256.fe | 6 +- .../features/return_from_memory_i8.fe | 16 +- .../features/return_from_storage_array_i8.fe | 11 +- .../features/return_from_storage_i8.fe | 18 +- .../fixtures/features/return_gt_i256.fe | 6 +- .../fixtures/features/return_gt_u256.fe | 6 +- .../fixtures/features/return_gte_i256.fe | 6 +- .../fixtures/features/return_gte_u256.fe | 6 +- .../fixtures/features/return_i128_cast.fe | 6 +- .../fixtures/features/return_i256.fe | 6 +- .../fixtures/features/return_identity_u128.fe | 6 +- .../fixtures/features/return_identity_u16.fe | 6 +- .../fixtures/features/return_identity_u256.fe | 6 +- .../fixtures/features/return_identity_u32.fe | 6 +- .../fixtures/features/return_identity_u64.fe | 6 +- .../fixtures/features/return_identity_u8.fe | 6 +- .../fixtures/features/return_int_array.fe | 9 +- .../fixtures/features/return_invert_i128.fe | 6 +- .../fixtures/features/return_invert_i16.fe | 6 +- .../fixtures/features/return_invert_i256.fe | 6 +- .../fixtures/features/return_invert_i32.fe | 6 +- .../fixtures/features/return_invert_i64.fe | 6 +- .../fixtures/features/return_invert_i8.fe | 6 +- .../fixtures/features/return_invert_u128.fe | 6 +- .../fixtures/features/return_invert_u16.fe | 6 +- .../fixtures/features/return_invert_u256.fe | 6 +- .../fixtures/features/return_invert_u32.fe | 6 +- .../fixtures/features/return_invert_u64.fe | 6 +- .../fixtures/features/return_invert_u8.fe | 6 +- .../fixtures/features/return_lt_i256.fe | 6 +- .../fixtures/features/return_lt_u128.fe | 6 +- .../fixtures/features/return_lt_u256.fe | 6 +- .../fixtures/features/return_lte_i256.fe | 6 +- .../fixtures/features/return_lte_u256.fe | 6 +- .../fixtures/features/return_mod_i256.fe | 6 +- .../fixtures/features/return_mod_u256.fe | 6 +- .../fixtures/features/return_msg_sig.fe | 6 +- .../features/return_multiplication_i256.fe | 6 +- .../features/return_multiplication_u256.fe | 6 +- .../fixtures/features/return_noteq_u256.fe | 6 +- .../fixtures/features/return_pow_i256.fe | 6 +- .../fixtures/features/return_pow_u256.fe | 6 +- .../features/return_subtraction_i256.fe | 6 +- .../features/return_subtraction_u256.fe | 6 +- .../features/return_sum_list_expression_1.fe | 9 +- .../features/return_sum_list_expression_2.fe | 13 +- .../fixtures/features/return_u128_cast.fe | 6 +- .../fixtures/features/return_u256.fe | 6 +- .../features/return_u256_from_called_fn.fe | 11 +- .../return_u256_from_called_fn_with_args.fe | 13 +- .../fixtures/features/return_unit.fe | 30 +- crates/test-files/fixtures/features/revert.fe | 18 +- .../fixtures/features/self_address.fe | 8 +- .../fixtures/features/send_value.fe | 6 +- .../fixtures/features/short_circuit.fe | 21 +- .../fixtures/features/sized_vals_in_sto.fe | 34 +- .../test-files/fixtures/features/strings.fe | 26 +- .../fixtures/features/struct_fns.fe | 116 +- .../test-files/fixtures/features/structs.fe | 131 +- .../fixtures/features/ternary_expression.fe | 9 +- .../fixtures/features/tuple_destructuring.fe | 12 +- .../fixtures/features/two_contracts.fe | 21 +- .../fixtures/features/type_aliases.fe | 20 +- .../fixtures/features/u128_u128_map.fe | 11 +- .../fixtures/features/u16_u16_map.fe | 11 +- .../fixtures/features/u256_u256_map.fe | 11 +- .../fixtures/features/u32_u32_map.fe | 11 +- .../fixtures/features/u64_u64_map.fe | 11 +- .../test-files/fixtures/features/u8_u8_map.fe | 11 +- .../fixtures/features/while_loop.fe | 12 +- .../features/while_loop_test_from_sto.fe | 13 +- .../features/while_loop_with_break.fe | 9 +- .../features/while_loop_with_break_2.fe | 12 +- .../features/while_loop_with_continue.fe | 13 +- .../fixtures/ingots/basic_ingot/src/bar.fe | 6 +- .../ingots/basic_ingot/src/bar/baz.fe | 3 +- .../ingots/basic_ingot/src/bar/mee.fe | 11 +- .../fixtures/ingots/basic_ingot/src/bing.fe | 14 +- .../ingots/basic_ingot/src/ding/dang.fe | 2 +- .../ingots/basic_ingot/src/ding/dong.fe | 12 +- .../fixtures/ingots/basic_ingot/src/main.fe | 32 +- .../ingots/pub_contract_ingot/src/foo.fe | 14 +- .../ingots/pub_contract_ingot/src/main.fe | 13 +- .../ingots/visibility_ingot/src/foo.fe | 14 +- .../ingots/visibility_ingot/src/main.fe | 11 +- crates/test-files/fixtures/lowering/and_or.fe | 55 +- .../fixtures/lowering/array_tuple.fe | 8 +- .../fixtures/lowering/aug_assign.fe | 42 +- .../fixtures/lowering/base_tuple.fe | 31 +- .../fixtures/lowering/custom_empty_type.fe | 11 +- crates/test-files/fixtures/lowering/init.fe | 6 +- .../fixtures/lowering/list_expressions.fe | 6 +- .../test-files/fixtures/lowering/map_tuple.fe | 6 +- .../fixtures/lowering/module_const.fe | 79 +- .../test-files/fixtures/lowering/module_fn.fe | 19 +- .../fixtures/lowering/module_level_events.fe | 9 +- .../fixtures/lowering/nested_tuple.fe | 6 +- .../fixtures/lowering/return_unit.fe | 50 +- .../test-files/fixtures/lowering/struct_fn.fe | 28 +- .../test-files/fixtures/lowering/ternary.fe | 28 +- .../fixtures/lowering/tuple_destruct.fe | 8 +- .../fixtures/lowering/type_alias_tuple.fe | 3 +- .../fixtures/lowering/unit_implicit.fe | 6 +- crates/test-files/fixtures/printing/defs.fe | 52 +- .../fixtures/printing/expr_parens.fe | 6 +- .../printing/guest_book_no_comments.fe | 12 +- .../fixtures/stress/abi_encoding_stress.fe | 71 +- .../fixtures/stress/data_copying_stress.fe | 58 +- .../fixtures/stress/external_calls.fe | 90 +- .../fixtures/stress/tuple_stress.fe | 48 +- docs/book.toml | 1 + docs/src/SUMMARY.md | 3 +- docs/src/quickstart/deploy_contract.md | 17 +- docs/src/quickstart/first_contract.md | 70 +- .../spec/data_layout/memory/clone_function.md | 28 +- .../memory/sequence_types_in_memory.md | 9 +- docs/src/spec/data_layout/stack.md | 9 +- .../constant_size_values_in_storage.md | 9 +- .../data_layout/storage/maps_in_storage.md | 9 +- .../data_layout/storage/to_mem_function.md | 4 +- .../spec/expressions/arithmetic_operators.md | 6 +- docs/src/spec/expressions/attribute.md | 15 +- .../src/spec/expressions/boolean_operators.md | 13 +- docs/src/spec/expressions/call.md | 11 +- .../spec/expressions/comparison_operators.md | 4 +- docs/src/spec/expressions/indexing.md | 10 +- docs/src/spec/expressions/list.md | 11 +- docs/src/spec/expressions/literal.md | 4 +- docs/src/spec/expressions/name.md | 9 +- docs/src/spec/expressions/tuple.md | 13 +- docs/src/spec/expressions/unary_operators.md | 12 +- docs/src/spec/index.md | 1 - docs/src/spec/items/contracts.md | 23 +- docs/src/spec/items/enum.md | 26 +- docs/src/spec/items/events.md | 18 +- docs/src/spec/items/functions.md | 57 +- docs/src/spec/items/structs.md | 24 +- docs/src/spec/items/type_aliases.md | 4 +- docs/src/spec/items/visibility_and_privacy.md | 36 +- docs/src/spec/lexical_structure/keywords.md | 2 - docs/src/spec/lexical_structure/tokens.md | 29 +- docs/src/spec/statements/assert.md | 18 +- docs/src/spec/statements/assign.md | 8 +- docs/src/spec/statements/augassign.md | 38 +- docs/src/spec/statements/break.md | 38 +- docs/src/spec/statements/const.md | 15 +- docs/src/spec/statements/continue.md | 37 +- docs/src/spec/statements/emit.md | 12 +- docs/src/spec/statements/for.md | 19 +- docs/src/spec/statements/if.md | 27 +- docs/src/spec/statements/index.md | 1 - docs/src/spec/statements/let.md | 8 +- docs/src/spec/statements/pass.md | 34 - docs/src/spec/statements/pragma.md | 4 +- docs/src/spec/statements/return.md | 30 +- docs/src/spec/statements/revert.md | 38 +- docs/src/spec/statements/while.md | 19 +- docs/src/spec/type_system/types/address.md | 12 +- docs/src/spec/type_system/types/array.md | 10 +- docs/src/spec/type_system/types/boolean.md | 6 +- docs/src/spec/type_system/types/contract.md | 20 +- docs/src/spec/type_system/types/map.md | 19 +- docs/src/spec/type_system/types/string.md | 13 +- docs/src/spec/type_system/types/struct.md | 15 +- docs/theme/custom-highlight.js | 87 + docs/validate_doc_examples.py | 45 +- newsfragments/707.feature.md | 28 + 650 files changed, 14152 insertions(+), 12880 deletions(-) delete mode 100644 crates/parser/src/grammar/Python.asdl delete mode 100644 crates/parser/src/grammar/SimPy.grammar create mode 100644 crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_semicolons.snap create mode 100644 crates/parser/tests/cases/snapshots/cases__print_ast__defs.snap create mode 100644 crates/parser/tests/cases/snapshots/cases__print_ast__erc20.snap create mode 100644 crates/parser/tests/cases/snapshots/cases__print_ast__expr_parens.snap create mode 100644 crates/parser/tests/cases/snapshots/cases__print_ast__guest_book.snap delete mode 100644 docs/src/spec/statements/pass.md create mode 100644 docs/theme/custom-highlight.js create mode 100644 newsfragments/707.feature.md diff --git a/README.md b/README.md index 002141429b..851aac3b0b 100644 --- a/README.md +++ b/README.md @@ -55,21 +55,25 @@ Run `fe --help` to explore further options. The following is a simple contract implemented in Fe. -```python +```rust use std::context::Context -contract GuestBook: +contract GuestBook { messages: Map> - event Signed: + event Signed { book_msg: String<100> + } - pub fn sign(self, ctx: Context, book_msg: String<100>): + pub fn sign(self, ctx: Context, book_msg: String<100>) { self.messages[ctx.msg_sender()] = book_msg emit Signed(ctx, book_msg: book_msg) + } - pub fn get_msg(self, addr: address) -> String<100>: + pub fn get_msg(self, addr: address) -> String<100> { return self.messages[addr].to_mem() + } +} ``` A lot more working examples can be found in our [test fixtures directory](https://github.com/ethereum/fe/tree/master/crates/test-files/fixtures/demos). diff --git a/crates/analyzer/src/traversal/functions.rs b/crates/analyzer/src/traversal/functions.rs index ad5ff71664..22ff5f0fdf 100644 --- a/crates/analyzer/src/traversal/functions.rs +++ b/crates/analyzer/src/traversal/functions.rs @@ -33,7 +33,6 @@ fn func_stmt(scope: &mut BlockScope, stmt: &Node) -> Result<(), Fa Unsafe { .. } => unsafe_block(scope, stmt), Assert { .. } => assert(scope, stmt), Expr { value } => expressions::expr(scope, value, None).map(|_| ()), - Pass => Ok(()), Revert { .. } => revert(scope, stmt), Break | Continue => { loop_flow_statement(scope, stmt); diff --git a/crates/analyzer/tests/errors.rs b/crates/analyzer/tests/errors.rs index 5d079c455f..0def76286f 100644 --- a/crates/analyzer/tests/errors.rs +++ b/crates/analyzer/tests/errors.rs @@ -81,28 +81,7 @@ macro_rules! test_stmt { #[wasm_bindgen_test] fn $name() { let src = format!( - "contract C:\n pub fn f(self):\n {}", - $stmt.replace('\n', "\n ") - ); - if cfg!(target_arch = "wasm32") { - fe_common::assert_snapshot_wasm!( - concat!("snapshots/errors__", stringify!($name), ".snap"), - error_string("[snippet]", &src) - ); - } else { - assert_snapshot!(error_string("[snippet]", &src)); - } - } - }; -} - -macro_rules! test_stmt_unsafe { - ($name:ident, $stmt:expr) => { - #[test] - #[wasm_bindgen_test] - fn $name() { - let src = format!( - "contract C:\n pub fn f(self):\n unsafe:\n {}", + "contract C {{\n pub fn f(self) {{\n {}\n }}\n}}", $stmt.replace('\n', "\n ") ); if cfg!(target_arch = "wasm32") { @@ -136,7 +115,7 @@ test_stmt! { binary_op_boolean_mismatch3, "1 or 2" } test_stmt! { bool_constructor, "bool(true)" } test_stmt! { bool_cast, "bool(0)" } test_stmt! { break_without_loop, "break" } -test_stmt! { break_without_loop_2, "if true:\n break" } +test_stmt! { break_without_loop_2, "if true { break }" } test_stmt! { call_undefined_function_on_contract, "self.doesnt_exist()" } test_stmt! { call_address_with_wrong_type, "address(true)" } test_stmt! { call_keccak_without_parameter, "keccak256()" } @@ -145,13 +124,13 @@ test_stmt! { call_keccak_with_2_args, "keccak256(1, 2)" } test_stmt! { call_keccak_with_generic_args, "keccak256<10>(1)" } test_stmt! { cast_address_to_u64, "u64(address(0))" } -test_stmt_unsafe! { call_balance_of_without_parameter, "std::evm::balance_of()" } -test_stmt_unsafe! { call_balance_of_with_wrong_type, "std::evm::balance_of(true)" } -test_stmt_unsafe! { call_balance_of_with_2_args, "std::evm::balance_of(address(0), 2)" } -test_stmt_unsafe! { call_balance_with_arg, "std::evm::balance(address(0))" } +test_stmt! { call_balance_of_without_parameter, "unsafe { std::evm::balance_of() }" } +test_stmt! { call_balance_of_with_wrong_type, "unsafe { std::evm::balance_of(true) }" } +test_stmt! { call_balance_of_with_2_args, "unsafe { std::evm::balance_of(address(0), 2) }" } +test_stmt! { call_balance_with_arg, "unsafe { std::evm::balance(address(0)) }" } test_stmt! { clone_arg_count, "let x: Array = [5, 6]\nlet y: Array = x.clone(y)" } test_stmt! { continue_without_loop, "continue" } -test_stmt! { continue_without_loop_2, "if true:\n continue" } +test_stmt! { continue_without_loop_2, "if true { continue }" } test_stmt! { emit_undefined_event, "emit MyEvent()" } test_stmt! { emit_type_name, "emit u8()" } test_stmt! { emit_variable, "let x: u8 = 10\nemit x()" } diff --git a/crates/analyzer/tests/snapshots/analysis__abi_encoding_stress.snap b/crates/analyzer/tests/snapshots/analysis__abi_encoding_stress.snap index 7fd546442f..3d4840c3a0 100644 --- a/crates/analyzer/tests/snapshots/analysis__abi_encoding_stress.snap +++ b/crates/analyzer/tests/snapshots/analysis__abi_encoding_stress.snap @@ -16,43 +16,44 @@ note: │ ^^^^^^^^^^^^^^^^^^^^ address note: - ┌─ abi_encoding_stress.fe:10:5 + ┌─ abi_encoding_stress.fe:11:5 │ -10 │ my_addrs: Array +11 │ my_addrs: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array -11 │ my_u128: u128 +12 │ my_u128: u128 │ ^^^^^^^^^^^^^ u128 -12 │ my_string: String<10> +13 │ my_string: String<10> │ ^^^^^^^^^^^^^^^^^^^^^ String<10> -13 │ my_u16s: Array +14 │ my_u16s: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^ Array -14 │ my_bool: bool +15 │ my_bool: bool │ ^^^^^^^^^^^^^ bool -15 │ my_bytes: Array +16 │ my_bytes: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^ Array note: - ┌─ abi_encoding_stress.fe:18:9 + ┌─ abi_encoding_stress.fe:19:9 │ -18 │ my_addrs: Array +19 │ my_addrs: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array -19 │ my_u128: u128 +20 │ my_u128: u128 │ ^^^^^^^^^^^^^ u128 -20 │ my_string: String<10> +21 │ my_string: String<10> │ ^^^^^^^^^^^^^^^^^^^^^ String<10> -21 │ my_u16s: Array +22 │ my_u16s: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^ Array -22 │ my_bool: bool +23 │ my_bool: bool │ ^^^^^^^^^^^^^ bool -23 │ my_bytes: Array +24 │ my_bytes: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^ Array note: - ┌─ abi_encoding_stress.fe:25:5 + ┌─ abi_encoding_stress.fe:27:5 │ -25 │ ╭ pub fn set_my_addrs(self, my_addrs: Array): -26 │ │ self.my_addrs = my_addrs - │ ╰────────────────────────────────^ attributes hash: 8893819222299525150 +27 │ ╭ pub fn set_my_addrs(self, my_addrs: Array) { +28 │ │ self.my_addrs = my_addrs +29 │ │ } + │ ╰─────^ attributes hash: 8893819222299525150 │ = FunctionSignature { self_decl: Some( @@ -81,25 +82,26 @@ note: } note: - ┌─ abi_encoding_stress.fe:26:9 + ┌─ abi_encoding_stress.fe:28:9 │ -26 │ self.my_addrs = my_addrs +28 │ self.my_addrs = my_addrs │ ^^^^ Foo: Value note: - ┌─ abi_encoding_stress.fe:26:9 + ┌─ abi_encoding_stress.fe:28:9 │ -26 │ self.my_addrs = my_addrs +28 │ self.my_addrs = my_addrs │ ^^^^^^^^^^^^^ ^^^^^^^^ Array: Memory │ │ │ Array: Storage { nonce: Some(0) } note: - ┌─ abi_encoding_stress.fe:28:5 + ┌─ abi_encoding_stress.fe:31:5 │ -28 │ ╭ pub fn get_my_addrs(self) -> Array: -29 │ │ return self.my_addrs.to_mem() - │ ╰─────────────────────────────────────^ attributes hash: 1736881624347502724 +31 │ ╭ pub fn get_my_addrs(self) -> Array { +32 │ │ return self.my_addrs.to_mem() +33 │ │ } + │ ╰─────^ attributes hash: 1736881624347502724 │ = FunctionSignature { self_decl: Some( @@ -118,29 +120,30 @@ note: } note: - ┌─ abi_encoding_stress.fe:29:16 + ┌─ abi_encoding_stress.fe:32:16 │ -29 │ return self.my_addrs.to_mem() +32 │ return self.my_addrs.to_mem() │ ^^^^ Foo: Value note: - ┌─ abi_encoding_stress.fe:29:16 + ┌─ abi_encoding_stress.fe:32:16 │ -29 │ return self.my_addrs.to_mem() +32 │ return self.my_addrs.to_mem() │ ^^^^^^^^^^^^^ Array: Storage { nonce: Some(0) } note: - ┌─ abi_encoding_stress.fe:29:16 + ┌─ abi_encoding_stress.fe:32:16 │ -29 │ return self.my_addrs.to_mem() +32 │ return self.my_addrs.to_mem() │ ^^^^^^^^^^^^^^^^^^^^^^ Array: Storage { nonce: Some(0) } => Memory note: - ┌─ abi_encoding_stress.fe:31:5 + ┌─ abi_encoding_stress.fe:35:5 │ -31 │ ╭ pub fn set_my_u128(self, my_u128: u128): -32 │ │ self.my_u128 = my_u128 - │ ╰──────────────────────────────^ attributes hash: 15199964699853061770 +35 │ ╭ pub fn set_my_u128(self, my_u128: u128) { +36 │ │ self.my_u128 = my_u128 +37 │ │ } + │ ╰─────^ attributes hash: 15199964699853061770 │ = FunctionSignature { self_decl: Some( @@ -168,25 +171,26 @@ note: } note: - ┌─ abi_encoding_stress.fe:32:9 + ┌─ abi_encoding_stress.fe:36:9 │ -32 │ self.my_u128 = my_u128 +36 │ self.my_u128 = my_u128 │ ^^^^ Foo: Value note: - ┌─ abi_encoding_stress.fe:32:9 + ┌─ abi_encoding_stress.fe:36:9 │ -32 │ self.my_u128 = my_u128 +36 │ self.my_u128 = my_u128 │ ^^^^^^^^^^^^ ^^^^^^^ u128: Value │ │ │ u128: Storage { nonce: Some(1) } note: - ┌─ abi_encoding_stress.fe:34:5 + ┌─ abi_encoding_stress.fe:39:5 │ -34 │ ╭ pub fn get_my_u128(self) -> u128: -35 │ │ return self.my_u128 - │ ╰───────────────────────────^ attributes hash: 15343208064821852867 +39 │ ╭ pub fn get_my_u128(self) -> u128 { +40 │ │ return self.my_u128 +41 │ │ } + │ ╰─────^ attributes hash: 15343208064821852867 │ = FunctionSignature { self_decl: Some( @@ -204,23 +208,24 @@ note: } note: - ┌─ abi_encoding_stress.fe:35:16 + ┌─ abi_encoding_stress.fe:40:16 │ -35 │ return self.my_u128 +40 │ return self.my_u128 │ ^^^^ Foo: Value note: - ┌─ abi_encoding_stress.fe:35:16 + ┌─ abi_encoding_stress.fe:40:16 │ -35 │ return self.my_u128 +40 │ return self.my_u128 │ ^^^^^^^^^^^^ u128: Storage { nonce: Some(1) } => Value note: - ┌─ abi_encoding_stress.fe:37:5 + ┌─ abi_encoding_stress.fe:43:5 │ -37 │ ╭ pub fn set_my_string(self, my_string: String<10>): -38 │ │ self.my_string = my_string - │ ╰──────────────────────────────────^ attributes hash: 241116312146617781 +43 │ ╭ pub fn set_my_string(self, my_string: String<10>) { +44 │ │ self.my_string = my_string +45 │ │ } + │ ╰─────^ attributes hash: 241116312146617781 │ = FunctionSignature { self_decl: Some( @@ -248,25 +253,26 @@ note: } note: - ┌─ abi_encoding_stress.fe:38:9 + ┌─ abi_encoding_stress.fe:44:9 │ -38 │ self.my_string = my_string +44 │ self.my_string = my_string │ ^^^^ Foo: Value note: - ┌─ abi_encoding_stress.fe:38:9 + ┌─ abi_encoding_stress.fe:44:9 │ -38 │ self.my_string = my_string +44 │ self.my_string = my_string │ ^^^^^^^^^^^^^^ ^^^^^^^^^ String<10>: Memory │ │ │ String<10>: Storage { nonce: Some(2) } note: - ┌─ abi_encoding_stress.fe:40:5 + ┌─ abi_encoding_stress.fe:47:5 │ -40 │ ╭ pub fn get_my_string(self) -> String<10>: -41 │ │ return self.my_string.to_mem() - │ ╰──────────────────────────────────────^ attributes hash: 1556448784000816371 +47 │ ╭ pub fn get_my_string(self) -> String<10> { +48 │ │ return self.my_string.to_mem() +49 │ │ } + │ ╰─────^ attributes hash: 1556448784000816371 │ = FunctionSignature { self_decl: Some( @@ -284,29 +290,30 @@ note: } note: - ┌─ abi_encoding_stress.fe:41:16 + ┌─ abi_encoding_stress.fe:48:16 │ -41 │ return self.my_string.to_mem() +48 │ return self.my_string.to_mem() │ ^^^^ Foo: Value note: - ┌─ abi_encoding_stress.fe:41:16 + ┌─ abi_encoding_stress.fe:48:16 │ -41 │ return self.my_string.to_mem() +48 │ return self.my_string.to_mem() │ ^^^^^^^^^^^^^^ String<10>: Storage { nonce: Some(2) } note: - ┌─ abi_encoding_stress.fe:41:16 + ┌─ abi_encoding_stress.fe:48:16 │ -41 │ return self.my_string.to_mem() +48 │ return self.my_string.to_mem() │ ^^^^^^^^^^^^^^^^^^^^^^^ String<10>: Storage { nonce: Some(2) } => Memory note: - ┌─ abi_encoding_stress.fe:43:5 + ┌─ abi_encoding_stress.fe:51:5 │ -43 │ ╭ pub fn set_my_u16s(self, my_u16s: Array): -44 │ │ self.my_u16s = my_u16s - │ ╰──────────────────────────────^ attributes hash: 15015381430419725173 +51 │ ╭ pub fn set_my_u16s(self, my_u16s: Array) { +52 │ │ self.my_u16s = my_u16s +53 │ │ } + │ ╰─────^ attributes hash: 15015381430419725173 │ = FunctionSignature { self_decl: Some( @@ -337,25 +344,26 @@ note: } note: - ┌─ abi_encoding_stress.fe:44:9 + ┌─ abi_encoding_stress.fe:52:9 │ -44 │ self.my_u16s = my_u16s +52 │ self.my_u16s = my_u16s │ ^^^^ Foo: Value note: - ┌─ abi_encoding_stress.fe:44:9 + ┌─ abi_encoding_stress.fe:52:9 │ -44 │ self.my_u16s = my_u16s +52 │ self.my_u16s = my_u16s │ ^^^^^^^^^^^^ ^^^^^^^ Array: Memory │ │ │ Array: Storage { nonce: Some(3) } note: - ┌─ abi_encoding_stress.fe:46:5 + ┌─ abi_encoding_stress.fe:55:5 │ -46 │ ╭ pub fn get_my_u16s(self) -> Array: -47 │ │ return self.my_u16s.to_mem() - │ ╰────────────────────────────────────^ attributes hash: 14119474618304681318 +55 │ ╭ pub fn get_my_u16s(self) -> Array { +56 │ │ return self.my_u16s.to_mem() +57 │ │ } + │ ╰─────^ attributes hash: 14119474618304681318 │ = FunctionSignature { self_decl: Some( @@ -376,29 +384,30 @@ note: } note: - ┌─ abi_encoding_stress.fe:47:16 + ┌─ abi_encoding_stress.fe:56:16 │ -47 │ return self.my_u16s.to_mem() +56 │ return self.my_u16s.to_mem() │ ^^^^ Foo: Value note: - ┌─ abi_encoding_stress.fe:47:16 + ┌─ abi_encoding_stress.fe:56:16 │ -47 │ return self.my_u16s.to_mem() +56 │ return self.my_u16s.to_mem() │ ^^^^^^^^^^^^ Array: Storage { nonce: Some(3) } note: - ┌─ abi_encoding_stress.fe:47:16 + ┌─ abi_encoding_stress.fe:56:16 │ -47 │ return self.my_u16s.to_mem() +56 │ return self.my_u16s.to_mem() │ ^^^^^^^^^^^^^^^^^^^^^ Array: Storage { nonce: Some(3) } => Memory note: - ┌─ abi_encoding_stress.fe:49:5 + ┌─ abi_encoding_stress.fe:59:5 │ -49 │ ╭ pub fn set_my_bool(self, my_bool: bool): -50 │ │ self.my_bool = my_bool - │ ╰──────────────────────────────^ attributes hash: 3845928701529339179 +59 │ ╭ pub fn set_my_bool(self, my_bool: bool) { +60 │ │ self.my_bool = my_bool +61 │ │ } + │ ╰─────^ attributes hash: 3845928701529339179 │ = FunctionSignature { self_decl: Some( @@ -424,25 +433,26 @@ note: } note: - ┌─ abi_encoding_stress.fe:50:9 + ┌─ abi_encoding_stress.fe:60:9 │ -50 │ self.my_bool = my_bool +60 │ self.my_bool = my_bool │ ^^^^ Foo: Value note: - ┌─ abi_encoding_stress.fe:50:9 + ┌─ abi_encoding_stress.fe:60:9 │ -50 │ self.my_bool = my_bool +60 │ self.my_bool = my_bool │ ^^^^^^^^^^^^ ^^^^^^^ bool: Value │ │ │ bool: Storage { nonce: Some(4) } note: - ┌─ abi_encoding_stress.fe:52:5 + ┌─ abi_encoding_stress.fe:63:5 │ -52 │ ╭ pub fn get_my_bool(self) -> bool: -53 │ │ return self.my_bool - │ ╰───────────────────────────^ attributes hash: 2163156009319630199 +63 │ ╭ pub fn get_my_bool(self) -> bool { +64 │ │ return self.my_bool +65 │ │ } + │ ╰─────^ attributes hash: 2163156009319630199 │ = FunctionSignature { self_decl: Some( @@ -458,23 +468,24 @@ note: } note: - ┌─ abi_encoding_stress.fe:53:16 + ┌─ abi_encoding_stress.fe:64:16 │ -53 │ return self.my_bool +64 │ return self.my_bool │ ^^^^ Foo: Value note: - ┌─ abi_encoding_stress.fe:53:16 + ┌─ abi_encoding_stress.fe:64:16 │ -53 │ return self.my_bool +64 │ return self.my_bool │ ^^^^^^^^^^^^ bool: Storage { nonce: Some(4) } => Value note: - ┌─ abi_encoding_stress.fe:55:5 + ┌─ abi_encoding_stress.fe:67:5 │ -55 │ ╭ pub fn set_my_bytes(self, my_bytes: Array): -56 │ │ self.my_bytes = my_bytes - │ ╰────────────────────────────────^ attributes hash: 11573101353594183790 +67 │ ╭ pub fn set_my_bytes(self, my_bytes: Array) { +68 │ │ self.my_bytes = my_bytes +69 │ │ } + │ ╰─────^ attributes hash: 11573101353594183790 │ = FunctionSignature { self_decl: Some( @@ -505,25 +516,26 @@ note: } note: - ┌─ abi_encoding_stress.fe:56:9 + ┌─ abi_encoding_stress.fe:68:9 │ -56 │ self.my_bytes = my_bytes +68 │ self.my_bytes = my_bytes │ ^^^^ Foo: Value note: - ┌─ abi_encoding_stress.fe:56:9 + ┌─ abi_encoding_stress.fe:68:9 │ -56 │ self.my_bytes = my_bytes +68 │ self.my_bytes = my_bytes │ ^^^^^^^^^^^^^ ^^^^^^^^ Array: Memory │ │ │ Array: Storage { nonce: Some(5) } note: - ┌─ abi_encoding_stress.fe:58:5 + ┌─ abi_encoding_stress.fe:71:5 │ -58 │ ╭ pub fn get_my_bytes(self) -> Array: -59 │ │ return self.my_bytes.to_mem() - │ ╰─────────────────────────────────────^ attributes hash: 157798734366762321 +71 │ ╭ pub fn get_my_bytes(self) -> Array { +72 │ │ return self.my_bytes.to_mem() +73 │ │ } + │ ╰─────^ attributes hash: 157798734366762321 │ = FunctionSignature { self_decl: Some( @@ -544,34 +556,30 @@ note: } note: - ┌─ abi_encoding_stress.fe:59:16 + ┌─ abi_encoding_stress.fe:72:16 │ -59 │ return self.my_bytes.to_mem() +72 │ return self.my_bytes.to_mem() │ ^^^^ Foo: Value note: - ┌─ abi_encoding_stress.fe:59:16 + ┌─ abi_encoding_stress.fe:72:16 │ -59 │ return self.my_bytes.to_mem() +72 │ return self.my_bytes.to_mem() │ ^^^^^^^^^^^^^ Array: Storage { nonce: Some(5) } note: - ┌─ abi_encoding_stress.fe:59:16 + ┌─ abi_encoding_stress.fe:72:16 │ -59 │ return self.my_bytes.to_mem() +72 │ return self.my_bytes.to_mem() │ ^^^^^^^^^^^^^^^^^^^^^^ Array: Storage { nonce: Some(5) } => Memory note: - ┌─ abi_encoding_stress.fe:61:5 + ┌─ abi_encoding_stress.fe:75:5 │ -61 │ ╭ pub fn get_my_struct() -> MyStruct: -62 │ │ return MyStruct( -63 │ │ my_num: 42, -64 │ │ my_num2: u8(26), -65 │ │ my_bool: true, -66 │ │ my_addr: address(123456) -67 │ │ ) - │ ╰─────────^ attributes hash: 16166951200114277325 +75 │ ╭ pub fn get_my_struct() -> MyStruct { +76 │ │ return MyStruct(my_num: 42, my_num2: u8(26), my_bool: true, my_addr: address(123456)) +77 │ │ } + │ ╰─────^ attributes hash: 16166951200114277325 │ = FunctionSignature { self_decl: None, @@ -588,51 +596,45 @@ note: } note: - ┌─ abi_encoding_stress.fe:63:21 + ┌─ abi_encoding_stress.fe:76:33 │ -63 │ my_num: 42, - │ ^^ u256: Value -64 │ my_num2: u8(26), - │ ^^ u8: Value +76 │ return MyStruct(my_num: 42, my_num2: u8(26), my_bool: true, my_addr: address(123456)) + │ ^^ ^^ u8: Value + │ │ + │ u256: Value note: - ┌─ abi_encoding_stress.fe:64:22 + ┌─ abi_encoding_stress.fe:76:46 │ -64 │ my_num2: u8(26), - │ ^^^^^^ u8: Value -65 │ my_bool: true, - │ ^^^^ bool: Value -66 │ my_addr: address(123456) - │ ^^^^^^ u256: Value +76 │ return MyStruct(my_num: 42, my_num2: u8(26), my_bool: true, my_addr: address(123456)) + │ ^^^^^^ ^^^^ ^^^^^^ u256: Value + │ │ │ + │ │ bool: Value + │ u8: Value note: - ┌─ abi_encoding_stress.fe:66:22 + ┌─ abi_encoding_stress.fe:76:78 │ -66 │ my_addr: address(123456) - │ ^^^^^^^^^^^^^^^ address: Value +76 │ return MyStruct(my_num: 42, my_num2: u8(26), my_bool: true, my_addr: address(123456)) + │ ^^^^^^^^^^^^^^^ address: Value note: - ┌─ abi_encoding_stress.fe:62:16 - │ -62 │ return MyStruct( - │ ╭────────────────^ -63 │ │ my_num: 42, -64 │ │ my_num2: u8(26), -65 │ │ my_bool: true, -66 │ │ my_addr: address(123456) -67 │ │ ) - │ ╰─────────^ MyStruct: Memory + ┌─ abi_encoding_stress.fe:76:16 + │ +76 │ return MyStruct(my_num: 42, my_num2: u8(26), my_bool: true, my_addr: address(123456)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ MyStruct: Memory note: - ┌─ abi_encoding_stress.fe:69:5 + ┌─ abi_encoding_stress.fe:79:5 │ -69 │ ╭ pub fn mod_my_struct(my_struct: MyStruct) -> MyStruct: -70 │ │ my_struct.my_num = 12341234 -71 │ │ my_struct.my_num2 = u8(42) -72 │ │ my_struct.my_bool = false -73 │ │ my_struct.my_addr = address(9999) -74 │ │ return my_struct - │ ╰────────────────────────^ attributes hash: 11747697140833990696 +79 │ ╭ pub fn mod_my_struct(my_struct: MyStruct) -> MyStruct { +80 │ │ my_struct.my_num = 12341234 +81 │ │ my_struct.my_num2 = u8(42) +82 │ │ my_struct.my_bool = false +83 │ │ my_struct.my_addr = address(9999) +84 │ │ return my_struct +85 │ │ } + │ ╰─────^ attributes hash: 11747697140833990696 │ = FunctionSignature { self_decl: None, @@ -662,74 +664,70 @@ note: } note: - ┌─ abi_encoding_stress.fe:70:9 + ┌─ abi_encoding_stress.fe:80:9 │ -70 │ my_struct.my_num = 12341234 +80 │ my_struct.my_num = 12341234 │ ^^^^^^^^^ MyStruct: Memory note: - ┌─ abi_encoding_stress.fe:70:9 + ┌─ abi_encoding_stress.fe:80:9 │ -70 │ my_struct.my_num = 12341234 +80 │ my_struct.my_num = 12341234 │ ^^^^^^^^^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ u256: Memory -71 │ my_struct.my_num2 = u8(42) +81 │ my_struct.my_num2 = u8(42) │ ^^^^^^^^^ MyStruct: Memory note: - ┌─ abi_encoding_stress.fe:71:9 + ┌─ abi_encoding_stress.fe:81:9 │ -71 │ my_struct.my_num2 = u8(42) +81 │ my_struct.my_num2 = u8(42) │ ^^^^^^^^^^^^^^^^^ ^^ u8: Value │ │ │ u8: Memory note: - ┌─ abi_encoding_stress.fe:71:29 + ┌─ abi_encoding_stress.fe:81:29 │ -71 │ my_struct.my_num2 = u8(42) +81 │ my_struct.my_num2 = u8(42) │ ^^^^^^ u8: Value -72 │ my_struct.my_bool = false +82 │ my_struct.my_bool = false │ ^^^^^^^^^ MyStruct: Memory note: - ┌─ abi_encoding_stress.fe:72:9 + ┌─ abi_encoding_stress.fe:82:9 │ -72 │ my_struct.my_bool = false +82 │ my_struct.my_bool = false │ ^^^^^^^^^^^^^^^^^ ^^^^^ bool: Value │ │ │ bool: Memory -73 │ my_struct.my_addr = address(9999) +83 │ my_struct.my_addr = address(9999) │ ^^^^^^^^^ MyStruct: Memory note: - ┌─ abi_encoding_stress.fe:73:9 + ┌─ abi_encoding_stress.fe:83:9 │ -73 │ my_struct.my_addr = address(9999) +83 │ my_struct.my_addr = address(9999) │ ^^^^^^^^^^^^^^^^^ ^^^^ u256: Value │ │ │ address: Memory note: - ┌─ abi_encoding_stress.fe:73:29 + ┌─ abi_encoding_stress.fe:83:29 │ -73 │ my_struct.my_addr = address(9999) +83 │ my_struct.my_addr = address(9999) │ ^^^^^^^^^^^^^ address: Value -74 │ return my_struct +84 │ return my_struct │ ^^^^^^^^^ MyStruct: Memory note: - ┌─ abi_encoding_stress.fe:76:5 + ┌─ abi_encoding_stress.fe:87:5 │ -76 │ ╭ pub fn emit_my_event(self, ctx: Context): -77 │ │ emit MyEvent( -78 │ │ ctx, -79 │ │ my_addrs: self.my_addrs.to_mem(), - · │ -84 │ │ my_bytes: self.my_bytes.to_mem() -85 │ │ ) - │ ╰─────────^ attributes hash: 1731341862738941170 +87 │ ╭ pub fn emit_my_event(self, ctx: Context) { +88 │ │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) +89 │ │ } + │ ╰─────^ attributes hash: 1731341862738941170 │ = FunctionSignature { self_decl: Some( @@ -760,95 +758,89 @@ note: } note: - ┌─ abi_encoding_stress.fe:78:13 + ┌─ abi_encoding_stress.fe:88:22 │ -78 │ ctx, - │ ^^^ Context: Memory -79 │ my_addrs: self.my_addrs.to_mem(), - │ ^^^^ Foo: Value +88 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) + │ ^^^ ^^^^ Foo: Value + │ │ + │ Context: Memory note: - ┌─ abi_encoding_stress.fe:79:23 + ┌─ abi_encoding_stress.fe:88:37 │ -79 │ my_addrs: self.my_addrs.to_mem(), - │ ^^^^^^^^^^^^^ Array: Storage { nonce: Some(0) } +88 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) + │ ^^^^^^^^^^^^^ Array: Storage { nonce: Some(0) } note: - ┌─ abi_encoding_stress.fe:79:23 + ┌─ abi_encoding_stress.fe:88:37 │ -79 │ my_addrs: self.my_addrs.to_mem(), - │ ^^^^^^^^^^^^^^^^^^^^^^ Array: Storage { nonce: Some(0) } => Memory -80 │ my_u128: self.my_u128, - │ ^^^^ Foo: Value +88 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) + │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^ Foo: Value + │ │ + │ Array: Storage { nonce: Some(0) } => Memory note: - ┌─ abi_encoding_stress.fe:80:22 + ┌─ abi_encoding_stress.fe:88:70 │ -80 │ my_u128: self.my_u128, - │ ^^^^^^^^^^^^ u128: Storage { nonce: Some(1) } => Value -81 │ my_string: self.my_string.to_mem(), - │ ^^^^ Foo: Value +88 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) + │ ^^^^^^^^^^^^ ^^^^ Foo: Value + │ │ + │ u128: Storage { nonce: Some(1) } => Value note: - ┌─ abi_encoding_stress.fe:81:24 + ┌─ abi_encoding_stress.fe:88:95 │ -81 │ my_string: self.my_string.to_mem(), - │ ^^^^^^^^^^^^^^ String<10>: Storage { nonce: Some(2) } +88 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) + │ ^^^^^^^^^^^^^^ String<10>: Storage { nonce: Some(2) } note: - ┌─ abi_encoding_stress.fe:81:24 + ┌─ abi_encoding_stress.fe:88:95 │ -81 │ my_string: self.my_string.to_mem(), - │ ^^^^^^^^^^^^^^^^^^^^^^^ String<10>: Storage { nonce: Some(2) } => Memory -82 │ my_u16s: self.my_u16s.to_mem(), - │ ^^^^ Foo: Value +88 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) + │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ Foo: Value + │ │ + │ String<10>: Storage { nonce: Some(2) } => Memory note: - ┌─ abi_encoding_stress.fe:82:22 + ┌─ abi_encoding_stress.fe:88:129 │ -82 │ my_u16s: self.my_u16s.to_mem(), - │ ^^^^^^^^^^^^ Array: Storage { nonce: Some(3) } +88 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) + │ ^^^^^^^^^^^^ Array: Storage { nonce: Some(3) } note: - ┌─ abi_encoding_stress.fe:82:22 + ┌─ abi_encoding_stress.fe:88:129 │ -82 │ my_u16s: self.my_u16s.to_mem(), - │ ^^^^^^^^^^^^^^^^^^^^^ Array: Storage { nonce: Some(3) } => Memory -83 │ my_bool: self.my_bool, - │ ^^^^ Foo: Value +88 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) + │ ^^^^^^^^^^^^^^^^^^^^^ ^^^^ Foo: Value + │ │ + │ Array: Storage { nonce: Some(3) } => Memory note: - ┌─ abi_encoding_stress.fe:83:22 + ┌─ abi_encoding_stress.fe:88:161 │ -83 │ my_bool: self.my_bool, - │ ^^^^^^^^^^^^ bool: Storage { nonce: Some(4) } => Value -84 │ my_bytes: self.my_bytes.to_mem() - │ ^^^^ Foo: Value +88 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) + │ ^^^^^^^^^^^^ ^^^^ Foo: Value + │ │ + │ bool: Storage { nonce: Some(4) } => Value note: - ┌─ abi_encoding_stress.fe:84:23 + ┌─ abi_encoding_stress.fe:88:185 │ -84 │ my_bytes: self.my_bytes.to_mem() - │ ^^^^^^^^^^^^^ Array: Storage { nonce: Some(5) } +88 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) + │ ^^^^^^^^^^^^^ Array: Storage { nonce: Some(5) } note: - ┌─ abi_encoding_stress.fe:84:23 + ┌─ abi_encoding_stress.fe:88:185 │ -84 │ my_bytes: self.my_bytes.to_mem() - │ ^^^^^^^^^^^^^^^^^^^^^^ Array: Storage { nonce: Some(5) } => Memory +88 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) + │ ^^^^^^^^^^^^^^^^^^^^^^ Array: Storage { nonce: Some(5) } => Memory note: - ┌─ abi_encoding_stress.fe:77:9 - │ -77 │ ╭ emit MyEvent( -78 │ │ ctx, -79 │ │ my_addrs: self.my_addrs.to_mem(), -80 │ │ my_u128: self.my_u128, - · │ -84 │ │ my_bytes: self.my_bytes.to_mem() -85 │ │ ) - │ ╰─────────^ attributes hash: 2185685122923697263 - │ + ┌─ abi_encoding_stress.fe:88:9 + │ +88 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 2185685122923697263 + │ = Event { name: "MyEvent", fields: [ diff --git a/crates/analyzer/tests/snapshots/analysis__address_bytes10_map.snap b/crates/analyzer/tests/snapshots/analysis__address_bytes10_map.snap index ca8cd9645f..5cd353e9fb 100644 --- a/crates/analyzer/tests/snapshots/analysis__address_bytes10_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__address_bytes10_map.snap @@ -12,9 +12,10 @@ note: note: ┌─ address_bytes10_map.fe:4:5 │ -4 │ ╭ pub fn read_bar(self, key: address) -> Array: +4 │ ╭ pub fn read_bar(self, key: address) -> Array { 5 │ │ return self.bar[key].to_mem() - │ ╰─────────────────────────────────────^ attributes hash: 7365261960972751402 +6 │ │ } + │ ╰─────^ attributes hash: 7365261960972751402 │ = FunctionSignature { self_decl: Some( @@ -71,67 +72,68 @@ note: │ ^^^^^^^^^^^^^^^^^^^^^^ Array: Storage { nonce: None } => Memory note: - ┌─ address_bytes10_map.fe:7:5 - │ -7 │ ╭ pub fn write_bar(self, key: address, value: Array): -8 │ │ self.bar[key] = value - │ ╰─────────────────────────────^ attributes hash: 10331226497424577374 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "key", - typ: Ok( - Base( - Address, - ), - ), - }, - FunctionParam { - label: None, - name: "value", - typ: Ok( - Array( - Array { - size: 10, - inner: Numeric( - U8, - ), - }, - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } + ┌─ address_bytes10_map.fe:8:5 + │ + 8 │ ╭ pub fn write_bar(self, key: address, value: Array) { + 9 │ │ self.bar[key] = value +10 │ │ } + │ ╰─────^ attributes hash: 10331226497424577374 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "key", + typ: Ok( + Base( + Address, + ), + ), + }, + FunctionParam { + label: None, + name: "value", + typ: Ok( + Array( + Array { + size: 10, + inner: Numeric( + U8, + ), + }, + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } note: - ┌─ address_bytes10_map.fe:8:9 + ┌─ address_bytes10_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^ Foo: Value note: - ┌─ address_bytes10_map.fe:8:9 + ┌─ address_bytes10_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^^^^^ ^^^ address: Value │ │ │ Map>: Storage { nonce: Some(0) } note: - ┌─ address_bytes10_map.fe:8:9 + ┌─ address_bytes10_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^^^^^^^^^^ ^^^^^ Array: Memory │ │ │ Array: Storage { nonce: None } diff --git a/crates/analyzer/tests/snapshots/analysis__assert.snap b/crates/analyzer/tests/snapshots/analysis__assert.snap index 8697cf7847..8caccc07a7 100644 --- a/crates/analyzer/tests/snapshots/analysis__assert.snap +++ b/crates/analyzer/tests/snapshots/analysis__assert.snap @@ -14,9 +14,10 @@ note: note: ┌─ assert.fe:5:5 │ -5 │ ╭ pub fn bar(baz: u256): +5 │ ╭ pub fn bar(baz: u256) { 6 │ │ assert baz > 5 - │ ╰──────────────────────^ attributes hash: 2614610269237134179 +7 │ │ } + │ ╰─────^ attributes hash: 2614610269237134179 │ = FunctionSignature { self_decl: None, @@ -56,57 +57,59 @@ note: │ ^^^^^^^ bool: Value note: - ┌─ assert.fe:8:5 - │ -8 │ ╭ pub fn revert_with_static_string(baz: u256): -9 │ │ assert baz > 5, "Must be greater than five" - │ ╰───────────────────────────────────────────────────^ attributes hash: 2614610269237134179 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "baz", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } + ┌─ assert.fe:9:5 + │ + 9 │ ╭ pub fn revert_with_static_string(baz: u256) { +10 │ │ assert baz > 5, "Must be greater than five" +11 │ │ } + │ ╰─────^ attributes hash: 2614610269237134179 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "baz", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } note: - ┌─ assert.fe:9:16 - │ -9 │ assert baz > 5, "Must be greater than five" - │ ^^^ ^ u256: Value - │ │ - │ u256: Value + ┌─ assert.fe:10:16 + │ +10 │ assert baz > 5, "Must be greater than five" + │ ^^^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ assert.fe:9:16 - │ -9 │ assert baz > 5, "Must be greater than five" - │ ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<25>: Memory - │ │ - │ bool: Value + ┌─ assert.fe:10:16 + │ +10 │ assert baz > 5, "Must be greater than five" + │ ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<25>: Memory + │ │ + │ bool: Value note: - ┌─ assert.fe:11:5 + ┌─ assert.fe:13:5 │ -11 │ ╭ pub fn revert_with(baz: u256, reason: String<1000>): -12 │ │ assert baz > 5, reason - │ ╰──────────────────────────────^ attributes hash: 10044481770469626577 +13 │ ╭ pub fn revert_with(baz: u256, reason: String<1000>) { +14 │ │ assert baz > 5, reason +15 │ │ } + │ ╰─────^ attributes hash: 10044481770469626577 │ = FunctionSignature { self_decl: None, @@ -143,28 +146,29 @@ note: } note: - ┌─ assert.fe:12:16 + ┌─ assert.fe:14:16 │ -12 │ assert baz > 5, reason +14 │ assert baz > 5, reason │ ^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ assert.fe:12:16 + ┌─ assert.fe:14:16 │ -12 │ assert baz > 5, reason +14 │ assert baz > 5, reason │ ^^^^^^^ ^^^^^^ String<1000>: Memory │ │ │ bool: Value note: - ┌─ assert.fe:14:5 + ┌─ assert.fe:17:5 │ -14 │ ╭ pub fn assert_sto_bool(self): -15 │ │ self.my_bool = false -16 │ │ assert self.my_bool - │ ╰───────────────────────────^ attributes hash: 18235041182630809162 +17 │ ╭ pub fn assert_sto_bool(self) { +18 │ │ self.my_bool = false +19 │ │ assert self.my_bool +20 │ │ } + │ ╰─────^ attributes hash: 18235041182630809162 │ = FunctionSignature { self_decl: Some( @@ -180,34 +184,35 @@ note: } note: - ┌─ assert.fe:15:9 + ┌─ assert.fe:18:9 │ -15 │ self.my_bool = false +18 │ self.my_bool = false │ ^^^^ Foo: Value note: - ┌─ assert.fe:15:9 + ┌─ assert.fe:18:9 │ -15 │ self.my_bool = false +18 │ self.my_bool = false │ ^^^^^^^^^^^^ ^^^^^ bool: Value │ │ │ bool: Storage { nonce: Some(0) } -16 │ assert self.my_bool +19 │ assert self.my_bool │ ^^^^ Foo: Value note: - ┌─ assert.fe:16:16 + ┌─ assert.fe:19:16 │ -16 │ assert self.my_bool +19 │ assert self.my_bool │ ^^^^^^^^^^^^ bool: Storage { nonce: Some(0) } => Value note: - ┌─ assert.fe:18:5 + ┌─ assert.fe:22:5 │ -18 │ ╭ pub fn assert_sto_string_msg(self): -19 │ │ self.my_string = "hello" -20 │ │ assert false, self.my_string.to_mem() - │ ╰─────────────────────────────────────────────^ attributes hash: 18235041182630809162 +22 │ ╭ pub fn assert_sto_string_msg(self) { +23 │ │ self.my_string = "hello" +24 │ │ assert false, self.my_string.to_mem() +25 │ │ } + │ ╰─────^ attributes hash: 18235041182630809162 │ = FunctionSignature { self_decl: Some( @@ -223,33 +228,33 @@ note: } note: - ┌─ assert.fe:19:9 + ┌─ assert.fe:23:9 │ -19 │ self.my_string = "hello" +23 │ self.my_string = "hello" │ ^^^^ Foo: Value note: - ┌─ assert.fe:19:9 + ┌─ assert.fe:23:9 │ -19 │ self.my_string = "hello" +23 │ self.my_string = "hello" │ ^^^^^^^^^^^^^^ ^^^^^^^ String<5>: Memory │ │ │ String<5>: Storage { nonce: Some(1) } -20 │ assert false, self.my_string.to_mem() +24 │ assert false, self.my_string.to_mem() │ ^^^^^ ^^^^ Foo: Value │ │ │ bool: Value note: - ┌─ assert.fe:20:23 + ┌─ assert.fe:24:23 │ -20 │ assert false, self.my_string.to_mem() +24 │ assert false, self.my_string.to_mem() │ ^^^^^^^^^^^^^^ String<5>: Storage { nonce: Some(1) } note: - ┌─ assert.fe:20:23 + ┌─ assert.fe:24:23 │ -20 │ assert false, self.my_string.to_mem() +24 │ assert false, self.my_string.to_mem() │ ^^^^^^^^^^^^^^^^^^^^^^^ String<5>: Storage { nonce: Some(1) } => Memory diff --git a/crates/analyzer/tests/snapshots/analysis__associated_fns.snap b/crates/analyzer/tests/snapshots/analysis__associated_fns.snap index 3b64ebc6bb..6dd61318bb 100644 --- a/crates/analyzer/tests/snapshots/analysis__associated_fns.snap +++ b/crates/analyzer/tests/snapshots/analysis__associated_fns.snap @@ -4,11 +4,12 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ associated_fns.fe:3:3 + ┌─ associated_fns.fe:2:5 │ -3 │ ╭ pub fn square(x: u256) -> u256: -4 │ │ return x * x - │ ╰────────────────^ attributes hash: 6622018637299644818 +2 │ ╭ pub fn square(x: u256) -> u256 { +3 │ │ return x * x +4 │ │ } + │ ╰─────^ attributes hash: 6622018637299644818 │ = FunctionSignature { self_decl: None, @@ -36,83 +37,85 @@ note: } note: - ┌─ associated_fns.fe:4:12 + ┌─ associated_fns.fe:3:16 │ -4 │ return x * x - │ ^ ^ u256: Value - │ │ - │ u256: Value +3 │ return x * x + │ ^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ associated_fns.fe:4:12 + ┌─ associated_fns.fe:3:16 │ -4 │ return x * x - │ ^^^^^ u256: Value +3 │ return x * x + │ ^^^^^ u256: Value note: - ┌─ associated_fns.fe:7:3 + ┌─ associated_fns.fe:8:5 │ -7 │ pub x: u256 - │ ^^^^^^^^^^^ u256 +8 │ pub x: u256 + │ ^^^^^^^^^^^ u256 note: - ┌─ associated_fns.fe:8:3 - │ -8 │ ╭ pub fn new(x: u256) -> MyStruct: -9 │ │ return MyStruct(x) - │ ╰──────────────────────^ attributes hash: 2145703897684373991 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "x", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - }, - ], - return_type: Ok( - Struct( - Struct { - name: "MyStruct", - field_count: 1, - }, - ), - ), - } + ┌─ associated_fns.fe:10:5 + │ +10 │ ╭ pub fn new(x: u256) -> MyStruct { +11 │ │ return MyStruct(x) +12 │ │ } + │ ╰─────^ attributes hash: 2145703897684373991 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "x", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + }, + ], + return_type: Ok( + Struct( + Struct { + name: "MyStruct", + field_count: 1, + }, + ), + ), + } note: - ┌─ associated_fns.fe:9:21 - │ -9 │ return MyStruct(x) - │ ^ u256: Value + ┌─ associated_fns.fe:11:25 + │ +11 │ return MyStruct(x) + │ ^ u256: Value note: - ┌─ associated_fns.fe:9:12 - │ -9 │ return MyStruct(x) - │ ^^^^^^^^^^^ MyStruct: Memory + ┌─ associated_fns.fe:11:16 + │ +11 │ return MyStruct(x) + │ ^^^^^^^^^^^ MyStruct: Memory note: - ┌─ associated_fns.fe:12:3 + ┌─ associated_fns.fe:16:5 │ -12 │ my_struct: MyStruct - │ ^^^^^^^^^^^^^^^^^^^ MyStruct +16 │ my_struct: MyStruct + │ ^^^^^^^^^^^^^^^^^^^ MyStruct note: - ┌─ associated_fns.fe:14:3 + ┌─ associated_fns.fe:18:5 │ -14 │ ╭ pub fn bar(self, val: u256) -> u256: -15 │ │ self.my_struct = MyStruct::new(x: val) -16 │ │ return Lib::square(x: self.my_struct.x) - │ ╰───────────────────────────────────────────^ attributes hash: 2950430758151367369 +18 │ ╭ pub fn bar(self, val: u256) -> u256 { +19 │ │ self.my_struct = MyStruct::new(x: val) +20 │ │ return Lib::square(x: self.my_struct.x) +21 │ │ } + │ ╰─────^ attributes hash: 2950430758151367369 │ = FunctionSignature { self_decl: Some( @@ -142,43 +145,43 @@ note: } note: - ┌─ associated_fns.fe:15:5 + ┌─ associated_fns.fe:19:9 │ -15 │ self.my_struct = MyStruct::new(x: val) - │ ^^^^ Foo: Value +19 │ self.my_struct = MyStruct::new(x: val) + │ ^^^^ Foo: Value note: - ┌─ associated_fns.fe:15:5 + ┌─ associated_fns.fe:19:9 │ -15 │ self.my_struct = MyStruct::new(x: val) - │ ^^^^^^^^^^^^^^ ^^^ u256: Value - │ │ - │ MyStruct: Storage { nonce: Some(0) } +19 │ self.my_struct = MyStruct::new(x: val) + │ ^^^^^^^^^^^^^^ ^^^ u256: Value + │ │ + │ MyStruct: Storage { nonce: Some(0) } note: - ┌─ associated_fns.fe:15:22 + ┌─ associated_fns.fe:19:26 │ -15 │ self.my_struct = MyStruct::new(x: val) - │ ^^^^^^^^^^^^^^^^^^^^^ MyStruct: Memory -16 │ return Lib::square(x: self.my_struct.x) - │ ^^^^ Foo: Value +19 │ self.my_struct = MyStruct::new(x: val) + │ ^^^^^^^^^^^^^^^^^^^^^ MyStruct: Memory +20 │ return Lib::square(x: self.my_struct.x) + │ ^^^^ Foo: Value note: - ┌─ associated_fns.fe:16:27 + ┌─ associated_fns.fe:20:31 │ -16 │ return Lib::square(x: self.my_struct.x) - │ ^^^^^^^^^^^^^^ MyStruct: Storage { nonce: Some(0) } +20 │ return Lib::square(x: self.my_struct.x) + │ ^^^^^^^^^^^^^^ MyStruct: Storage { nonce: Some(0) } note: - ┌─ associated_fns.fe:16:27 + ┌─ associated_fns.fe:20:31 │ -16 │ return Lib::square(x: self.my_struct.x) - │ ^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(0) } => Value +20 │ return Lib::square(x: self.my_struct.x) + │ ^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(0) } => Value note: - ┌─ associated_fns.fe:16:12 + ┌─ associated_fns.fe:20:16 │ -16 │ return Lib::square(x: self.my_struct.x) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +20 │ return Lib::square(x: self.my_struct.x) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__aug_assign.snap b/crates/analyzer/tests/snapshots/analysis__aug_assign.snap index 5361ebc923..f22675eb02 100644 --- a/crates/analyzer/tests/snapshots/analysis__aug_assign.snap +++ b/crates/analyzer/tests/snapshots/analysis__aug_assign.snap @@ -12,10 +12,11 @@ note: note: ┌─ aug_assign.fe:4:5 │ -4 │ ╭ pub fn add(a: u256, b: u256) -> u256: +4 │ ╭ pub fn add(a: u256, b: u256) -> u256 { 5 │ │ a += b 6 │ │ return a - │ ╰────────────────^ attributes hash: 14373109651426912995 +7 │ │ } + │ ╰─────^ attributes hash: 14373109651426912995 │ = FunctionSignature { self_decl: None, @@ -64,12 +65,13 @@ note: │ ^ u256: Value note: - ┌─ aug_assign.fe:8:5 + ┌─ aug_assign.fe:9:5 │ - 8 │ ╭ pub fn sub(a: u256, b: u256) -> u256: - 9 │ │ a -= b -10 │ │ return a - │ ╰────────────────^ attributes hash: 14373109651426912995 + 9 │ ╭ pub fn sub(a: u256, b: u256) -> u256 { +10 │ │ a -= b +11 │ │ return a +12 │ │ } + │ ╰─────^ attributes hash: 14373109651426912995 │ = FunctionSignature { self_decl: None, @@ -108,22 +110,23 @@ note: } note: - ┌─ aug_assign.fe:9:9 + ┌─ aug_assign.fe:10:9 │ - 9 │ a -= b +10 │ a -= b │ ^ ^ u256: Value │ │ │ u256: Value -10 │ return a +11 │ return a │ ^ u256: Value note: - ┌─ aug_assign.fe:12:5 + ┌─ aug_assign.fe:14:5 │ -12 │ ╭ pub fn mul(a: u256, b: u256) -> u256: -13 │ │ a *= b -14 │ │ return a - │ ╰────────────────^ attributes hash: 14373109651426912995 +14 │ ╭ pub fn mul(a: u256, b: u256) -> u256 { +15 │ │ a *= b +16 │ │ return a +17 │ │ } + │ ╰─────^ attributes hash: 14373109651426912995 │ = FunctionSignature { self_decl: None, @@ -162,22 +165,23 @@ note: } note: - ┌─ aug_assign.fe:13:9 + ┌─ aug_assign.fe:15:9 │ -13 │ a *= b +15 │ a *= b │ ^ ^ u256: Value │ │ │ u256: Value -14 │ return a +16 │ return a │ ^ u256: Value note: - ┌─ aug_assign.fe:16:5 + ┌─ aug_assign.fe:19:5 │ -16 │ ╭ pub fn div(a: u256, b: u256) -> u256: -17 │ │ a /= b -18 │ │ return a - │ ╰────────────────^ attributes hash: 14373109651426912995 +19 │ ╭ pub fn div(a: u256, b: u256) -> u256 { +20 │ │ a /= b +21 │ │ return a +22 │ │ } + │ ╰─────^ attributes hash: 14373109651426912995 │ = FunctionSignature { self_decl: None, @@ -216,22 +220,23 @@ note: } note: - ┌─ aug_assign.fe:17:9 + ┌─ aug_assign.fe:20:9 │ -17 │ a /= b +20 │ a /= b │ ^ ^ u256: Value │ │ │ u256: Value -18 │ return a +21 │ return a │ ^ u256: Value note: - ┌─ aug_assign.fe:20:5 + ┌─ aug_assign.fe:24:5 │ -20 │ ╭ pub fn mod(a: u256, b: u256) -> u256: -21 │ │ a %= b -22 │ │ return a - │ ╰────────────────^ attributes hash: 14373109651426912995 +24 │ ╭ pub fn mod(a: u256, b: u256) -> u256 { +25 │ │ a %= b +26 │ │ return a +27 │ │ } + │ ╰─────^ attributes hash: 14373109651426912995 │ = FunctionSignature { self_decl: None, @@ -270,22 +275,23 @@ note: } note: - ┌─ aug_assign.fe:21:9 + ┌─ aug_assign.fe:25:9 │ -21 │ a %= b +25 │ a %= b │ ^ ^ u256: Value │ │ │ u256: Value -22 │ return a +26 │ return a │ ^ u256: Value note: - ┌─ aug_assign.fe:24:5 + ┌─ aug_assign.fe:29:5 │ -24 │ ╭ pub fn pow(a: u256, b: u256) -> u256: -25 │ │ a **= b -26 │ │ return a - │ ╰────────────────^ attributes hash: 14373109651426912995 +29 │ ╭ pub fn pow(a: u256, b: u256) -> u256 { +30 │ │ a **= b +31 │ │ return a +32 │ │ } + │ ╰─────^ attributes hash: 14373109651426912995 │ = FunctionSignature { self_decl: None, @@ -324,22 +330,23 @@ note: } note: - ┌─ aug_assign.fe:25:9 + ┌─ aug_assign.fe:30:9 │ -25 │ a **= b +30 │ a **= b │ ^ ^ u256: Value │ │ │ u256: Value -26 │ return a +31 │ return a │ ^ u256: Value note: - ┌─ aug_assign.fe:28:5 + ┌─ aug_assign.fe:34:5 │ -28 │ ╭ pub fn lshift(a: u8, b: u8) -> u8: -29 │ │ a <<= b -30 │ │ return a - │ ╰────────────────^ attributes hash: 3365128954177167387 +34 │ ╭ pub fn lshift(a: u8, b: u8) -> u8 { +35 │ │ a <<= b +36 │ │ return a +37 │ │ } + │ ╰─────^ attributes hash: 3365128954177167387 │ = FunctionSignature { self_decl: None, @@ -378,22 +385,23 @@ note: } note: - ┌─ aug_assign.fe:29:9 + ┌─ aug_assign.fe:35:9 │ -29 │ a <<= b +35 │ a <<= b │ ^ ^ u8: Value │ │ │ u8: Value -30 │ return a +36 │ return a │ ^ u8: Value note: - ┌─ aug_assign.fe:32:5 + ┌─ aug_assign.fe:39:5 │ -32 │ ╭ pub fn rshift(a: u8, b: u8) -> u8: -33 │ │ a >>= b -34 │ │ return a - │ ╰────────────────^ attributes hash: 3365128954177167387 +39 │ ╭ pub fn rshift(a: u8, b: u8) -> u8 { +40 │ │ a >>= b +41 │ │ return a +42 │ │ } + │ ╰─────^ attributes hash: 3365128954177167387 │ = FunctionSignature { self_decl: None, @@ -432,22 +440,23 @@ note: } note: - ┌─ aug_assign.fe:33:9 + ┌─ aug_assign.fe:40:9 │ -33 │ a >>= b +40 │ a >>= b │ ^ ^ u8: Value │ │ │ u8: Value -34 │ return a +41 │ return a │ ^ u8: Value note: - ┌─ aug_assign.fe:36:5 + ┌─ aug_assign.fe:44:5 │ -36 │ ╭ pub fn bit_or(a: u8, b: u8) -> u8: -37 │ │ a |= b -38 │ │ return a - │ ╰────────────────^ attributes hash: 3365128954177167387 +44 │ ╭ pub fn bit_or(a: u8, b: u8) -> u8 { +45 │ │ a |= b +46 │ │ return a +47 │ │ } + │ ╰─────^ attributes hash: 3365128954177167387 │ = FunctionSignature { self_decl: None, @@ -486,22 +495,23 @@ note: } note: - ┌─ aug_assign.fe:37:9 + ┌─ aug_assign.fe:45:9 │ -37 │ a |= b +45 │ a |= b │ ^ ^ u8: Value │ │ │ u8: Value -38 │ return a +46 │ return a │ ^ u8: Value note: - ┌─ aug_assign.fe:40:5 + ┌─ aug_assign.fe:49:5 │ -40 │ ╭ pub fn bit_xor(a: u8, b: u8) -> u8: -41 │ │ a ^= b -42 │ │ return a - │ ╰────────────────^ attributes hash: 3365128954177167387 +49 │ ╭ pub fn bit_xor(a: u8, b: u8) -> u8 { +50 │ │ a ^= b +51 │ │ return a +52 │ │ } + │ ╰─────^ attributes hash: 3365128954177167387 │ = FunctionSignature { self_decl: None, @@ -540,22 +550,23 @@ note: } note: - ┌─ aug_assign.fe:41:9 + ┌─ aug_assign.fe:50:9 │ -41 │ a ^= b +50 │ a ^= b │ ^ ^ u8: Value │ │ │ u8: Value -42 │ return a +51 │ return a │ ^ u8: Value note: - ┌─ aug_assign.fe:44:5 + ┌─ aug_assign.fe:54:5 │ -44 │ ╭ pub fn bit_and(a: u8, b: u8) -> u8: -45 │ │ a &= b -46 │ │ return a - │ ╰────────────────^ attributes hash: 3365128954177167387 +54 │ ╭ pub fn bit_and(a: u8, b: u8) -> u8 { +55 │ │ a &= b +56 │ │ return a +57 │ │ } + │ ╰─────^ attributes hash: 3365128954177167387 │ = FunctionSignature { self_decl: None, @@ -594,23 +605,24 @@ note: } note: - ┌─ aug_assign.fe:45:9 + ┌─ aug_assign.fe:55:9 │ -45 │ a &= b +55 │ a &= b │ ^ ^ u8: Value │ │ │ u8: Value -46 │ return a +56 │ return a │ ^ u8: Value note: - ┌─ aug_assign.fe:48:5 + ┌─ aug_assign.fe:59:5 │ -48 │ ╭ pub fn add_from_sto(self, a: u256, b: u256) -> u256: -49 │ │ self.my_num = a -50 │ │ self.my_num += b -51 │ │ return self.my_num - │ ╰──────────────────────────^ attributes hash: 3506345928150766050 +59 │ ╭ pub fn add_from_sto(self, a: u256, b: u256) -> u256 { +60 │ │ self.my_num = a +61 │ │ self.my_num += b +62 │ │ return self.my_num +63 │ │ } + │ ╰─────^ attributes hash: 3506345928150766050 │ = FunctionSignature { self_decl: Some( @@ -651,46 +663,47 @@ note: } note: - ┌─ aug_assign.fe:49:9 + ┌─ aug_assign.fe:60:9 │ -49 │ self.my_num = a +60 │ self.my_num = a │ ^^^^ Foo: Value note: - ┌─ aug_assign.fe:49:9 + ┌─ aug_assign.fe:60:9 │ -49 │ self.my_num = a +60 │ self.my_num = a │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } -50 │ self.my_num += b +61 │ self.my_num += b │ ^^^^ Foo: Value note: - ┌─ aug_assign.fe:50:9 + ┌─ aug_assign.fe:61:9 │ -50 │ self.my_num += b +61 │ self.my_num += b │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } -51 │ return self.my_num +62 │ return self.my_num │ ^^^^ Foo: Value note: - ┌─ aug_assign.fe:51:16 + ┌─ aug_assign.fe:62:16 │ -51 │ return self.my_num +62 │ return self.my_num │ ^^^^^^^^^^^ u256: Storage { nonce: Some(0) } => Value note: - ┌─ aug_assign.fe:53:5 + ┌─ aug_assign.fe:65:5 │ -53 │ ╭ pub fn add_from_mem(a: u256, b: u256) -> u256: -54 │ │ let my_array: Array -55 │ │ my_array[7] = a -56 │ │ my_array[7] += b -57 │ │ return my_array[7] - │ ╰──────────────────────────^ attributes hash: 14373109651426912995 +65 │ ╭ pub fn add_from_mem(a: u256, b: u256) -> u256 { +66 │ │ let my_array: Array +67 │ │ my_array[7] = a +68 │ │ my_array[7] += b +69 │ │ return my_array[7] +70 │ │ } + │ ╰─────^ attributes hash: 14373109651426912995 │ = FunctionSignature { self_decl: None, @@ -729,47 +742,47 @@ note: } note: - ┌─ aug_assign.fe:54:23 + ┌─ aug_assign.fe:66:23 │ -54 │ let my_array: Array +66 │ let my_array: Array │ ^^^^^^^^^^^^^^^ Array note: - ┌─ aug_assign.fe:55:9 + ┌─ aug_assign.fe:67:9 │ -55 │ my_array[7] = a +67 │ my_array[7] = a │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ aug_assign.fe:55:9 + ┌─ aug_assign.fe:67:9 │ -55 │ my_array[7] = a +67 │ my_array[7] = a │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -56 │ my_array[7] += b +68 │ my_array[7] += b │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ aug_assign.fe:56:9 + ┌─ aug_assign.fe:68:9 │ -56 │ my_array[7] += b +68 │ my_array[7] += b │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -57 │ return my_array[7] +69 │ return my_array[7] │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ aug_assign.fe:57:16 + ┌─ aug_assign.fe:69:16 │ -57 │ return my_array[7] +69 │ return my_array[7] │ ^^^^^^^^^^^ u256: Memory => Value diff --git a/crates/analyzer/tests/snapshots/analysis__balances.snap b/crates/analyzer/tests/snapshots/analysis__balances.snap index db25123286..80543a6138 100644 --- a/crates/analyzer/tests/snapshots/analysis__balances.snap +++ b/crates/analyzer/tests/snapshots/analysis__balances.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ balances.fe:5:5 │ -5 │ ╭ pub fn my_balance(self, ctx: Context) -> u256: +5 │ ╭ pub fn my_balance(self, ctx: Context) -> u256 { 6 │ │ return ctx.self_balance() - │ ╰─────────────────────────────────^ attributes hash: 3247318976601732237 +7 │ │ } + │ ╰─────^ attributes hash: 3247318976601732237 │ = FunctionSignature { self_decl: Some( @@ -53,63 +54,64 @@ note: │ ^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ balances.fe:8:5 - │ -8 │ ╭ pub fn other_balance(self, ctx: Context, someone: address) -> u256: -9 │ │ return ctx.balance_of(someone) - │ ╰──────────────────────────────────────^ attributes hash: 7590750053308816492 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: Some( - Mutable, - ), - params: [ - FunctionParam { - label: None, - name: "ctx", - typ: Ok( - Struct( - Struct { - name: "Context", - field_count: 0, - }, - ), - ), - }, - FunctionParam { - label: None, - name: "someone", - typ: Ok( - Base( - Address, - ), - ), - }, - ], - return_type: Ok( - Base( - Numeric( - U256, - ), - ), - ), - } + ┌─ balances.fe:9:5 + │ + 9 │ ╭ pub fn other_balance(self, ctx: Context, someone: address) -> u256 { +10 │ │ return ctx.balance_of(someone) +11 │ │ } + │ ╰─────^ attributes hash: 7590750053308816492 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: Some( + Mutable, + ), + params: [ + FunctionParam { + label: None, + name: "ctx", + typ: Ok( + Struct( + Struct { + name: "Context", + field_count: 0, + }, + ), + ), + }, + FunctionParam { + label: None, + name: "someone", + typ: Ok( + Base( + Address, + ), + ), + }, + ], + return_type: Ok( + Base( + Numeric( + U256, + ), + ), + ), + } note: - ┌─ balances.fe:9:16 - │ -9 │ return ctx.balance_of(someone) - │ ^^^ ^^^^^^^ address: Value - │ │ - │ Context: Memory + ┌─ balances.fe:10:16 + │ +10 │ return ctx.balance_of(someone) + │ ^^^ ^^^^^^^ address: Value + │ │ + │ Context: Memory note: - ┌─ balances.fe:9:16 - │ -9 │ return ctx.balance_of(someone) - │ ^^^^^^^^^^^^^^^^^^^^^^^ u256: Value + ┌─ balances.fe:10:16 + │ +10 │ return ctx.balance_of(someone) + │ ^^^^^^^^^^^^^^^^^^^^^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__base_tuple.snap b/crates/analyzer/tests/snapshots/analysis__base_tuple.snap index 6f1e7390b7..d81acf2de8 100644 --- a/crates/analyzer/tests/snapshots/analysis__base_tuple.snap +++ b/crates/analyzer/tests/snapshots/analysis__base_tuple.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ base_tuple.fe:2:5 │ -2 │ ╭ pub fn bar(my_num: u256, my_bool: bool) -> (u256, bool): +2 │ ╭ pub fn bar(my_num: u256, my_bool: bool) -> (u256, bool) { 3 │ │ return (my_num, my_bool) - │ ╰────────────────────────────────^ attributes hash: 10319049298189511667 +4 │ │ } + │ ╰─────^ attributes hash: 10319049298189511667 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__basic_ingot.snap b/crates/analyzer/tests/snapshots/analysis__basic_ingot.snap index c399574387..759256df5f 100644 --- a/crates/analyzer/tests/snapshots/analysis__basic_ingot.snap +++ b/crates/analyzer/tests/snapshots/analysis__basic_ingot.snap @@ -6,10 +6,11 @@ expression: snapshot note: ┌─ ingots/basic_ingot/src/main.fe:10:5 │ -10 │ ╭ pub fn get_my_baz() -> Baz: +10 │ ╭ pub fn get_my_baz() -> Baz { 11 │ │ assert file_items_work() 12 │ │ return Baz(my_bool: true, my_u256: 26) - │ ╰──────────────────────────────────────────────^ attributes hash: 12617626076609670469 +13 │ │ } + │ ╰─────^ attributes hash: 12617626076609670469 │ = FunctionSignature { self_decl: None, @@ -42,11 +43,12 @@ note: │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Baz: Memory note: - ┌─ ingots/basic_ingot/src/main.fe:14:5 + ┌─ ingots/basic_ingot/src/main.fe:15:5 │ -14 │ ╭ pub fn get_my_bing() -> Bong: -15 │ │ return Bong(my_address: address(42)) - │ ╰────────────────────────────────────────────^ attributes hash: 10335209349982667488 +15 │ ╭ pub fn get_my_bing() -> Bong { +16 │ │ return Bong(my_address: address(42)) +17 │ │ } + │ ╰─────^ attributes hash: 10335209349982667488 │ = FunctionSignature { self_decl: None, @@ -63,29 +65,30 @@ note: } note: - ┌─ ingots/basic_ingot/src/main.fe:15:41 + ┌─ ingots/basic_ingot/src/main.fe:16:41 │ -15 │ return Bong(my_address: address(42)) +16 │ return Bong(my_address: address(42)) │ ^^ u256: Value note: - ┌─ ingots/basic_ingot/src/main.fe:15:33 + ┌─ ingots/basic_ingot/src/main.fe:16:33 │ -15 │ return Bong(my_address: address(42)) +16 │ return Bong(my_address: address(42)) │ ^^^^^^^^^^^ address: Value note: - ┌─ ingots/basic_ingot/src/main.fe:15:16 + ┌─ ingots/basic_ingot/src/main.fe:16:16 │ -15 │ return Bong(my_address: address(42)) +16 │ return Bong(my_address: address(42)) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Bing: Memory note: - ┌─ ingots/basic_ingot/src/main.fe:17:5 + ┌─ ingots/basic_ingot/src/main.fe:19:5 │ -17 │ ╭ pub fn get_42() -> u256: -18 │ │ return get_42_backend() - │ ╰───────────────────────────────^ attributes hash: 6115314201970082834 +19 │ ╭ pub fn get_42() -> u256 { +20 │ │ return get_42_backend() +21 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -101,17 +104,18 @@ note: } note: - ┌─ ingots/basic_ingot/src/main.fe:18:16 + ┌─ ingots/basic_ingot/src/main.fe:20:16 │ -18 │ return get_42_backend() +20 │ return get_42_backend() │ ^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ ingots/basic_ingot/src/main.fe:20:5 + ┌─ ingots/basic_ingot/src/main.fe:23:5 │ -20 │ ╭ pub fn get_26() -> u256: -21 │ │ return std::evm::add(13, 13) - │ ╰────────────────────────────────────^ attributes hash: 6115314201970082834 +23 │ ╭ pub fn get_26() -> u256 { +24 │ │ return std::evm::add(13, 13) +25 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -127,26 +131,27 @@ note: } note: - ┌─ ingots/basic_ingot/src/main.fe:21:30 + ┌─ ingots/basic_ingot/src/main.fe:24:30 │ -21 │ return std::evm::add(13, 13) +24 │ return std::evm::add(13, 13) │ ^^ ^^ u256: Value │ │ │ u256: Value note: - ┌─ ingots/basic_ingot/src/main.fe:21:16 + ┌─ ingots/basic_ingot/src/main.fe:24:16 │ -21 │ return std::evm::add(13, 13) +24 │ return std::evm::add(13, 13) │ ^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ ingots/basic_ingot/src/main.fe:23:5 + ┌─ ingots/basic_ingot/src/main.fe:27:5 │ -23 │ ╭ pub fn call_on_path(): -24 │ │ assert bar::mee::Mee::kawum() == 1 -25 │ │ assert bar::mee::Mee().rums() == 1 - │ ╰──────────────────────────────────────────^ attributes hash: 8319796915330632390 +27 │ ╭ pub fn call_on_path() { +28 │ │ assert bar::mee::Mee::kawum() == 1 +29 │ │ assert bar::mee::Mee().rums() == 1 +30 │ │ } + │ ╰─────^ attributes hash: 8319796915330632390 │ = FunctionSignature { self_decl: None, @@ -160,45 +165,42 @@ note: } note: - ┌─ ingots/basic_ingot/src/main.fe:24:16 + ┌─ ingots/basic_ingot/src/main.fe:28:16 │ -24 │ assert bar::mee::Mee::kawum() == 1 +28 │ assert bar::mee::Mee::kawum() == 1 │ ^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ ingots/basic_ingot/src/main.fe:24:16 + ┌─ ingots/basic_ingot/src/main.fe:28:16 │ -24 │ assert bar::mee::Mee::kawum() == 1 +28 │ assert bar::mee::Mee::kawum() == 1 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -25 │ assert bar::mee::Mee().rums() == 1 +29 │ assert bar::mee::Mee().rums() == 1 │ ^^^^^^^^^^^^^^^ Mee: Memory note: - ┌─ ingots/basic_ingot/src/main.fe:25:16 + ┌─ ingots/basic_ingot/src/main.fe:29:16 │ -25 │ assert bar::mee::Mee().rums() == 1 +29 │ assert bar::mee::Mee().rums() == 1 │ ^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ ingots/basic_ingot/src/main.fe:25:16 + ┌─ ingots/basic_ingot/src/main.fe:29:16 │ -25 │ assert bar::mee::Mee().rums() == 1 +29 │ assert bar::mee::Mee().rums() == 1 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value note: - ┌─ ingots/basic_ingot/src/main.fe:27:5 + ┌─ ingots/basic_ingot/src/main.fe:32:5 │ -27 │ ╭ pub fn get_my_dyng() -> dong::Dyng: -28 │ │ return dong::Dyng( -29 │ │ my_address: address(8), -30 │ │ my_u256: 42, -31 │ │ my_i8: -1 -32 │ │ ) - │ ╰─────────^ attributes hash: 13186223862505072309 +32 │ ╭ pub fn get_my_dyng() -> dong::Dyng { +33 │ │ return dong::Dyng(my_address: address(8), my_u256: 42, my_i8: -1) +34 │ │ } + │ ╰─────^ attributes hash: 13186223862505072309 │ = FunctionSignature { self_decl: None, @@ -215,45 +217,40 @@ note: } note: - ┌─ ingots/basic_ingot/src/main.fe:29:33 + ┌─ ingots/basic_ingot/src/main.fe:33:47 │ -29 │ my_address: address(8), - │ ^ u256: Value +33 │ return dong::Dyng(my_address: address(8), my_u256: 42, my_i8: -1) + │ ^ u256: Value note: - ┌─ ingots/basic_ingot/src/main.fe:29:25 + ┌─ ingots/basic_ingot/src/main.fe:33:39 │ -29 │ my_address: address(8), - │ ^^^^^^^^^^ address: Value -30 │ my_u256: 42, - │ ^^ u256: Value -31 │ my_i8: -1 - │ ^ u256: Value +33 │ return dong::Dyng(my_address: address(8), my_u256: 42, my_i8: -1) + │ ^^^^^^^^^^ ^^ ^ u256: Value + │ │ │ + │ │ u256: Value + │ address: Value note: - ┌─ ingots/basic_ingot/src/main.fe:31:20 + ┌─ ingots/basic_ingot/src/main.fe:33:71 │ -31 │ my_i8: -1 - │ ^^ i8: Value +33 │ return dong::Dyng(my_address: address(8), my_u256: 42, my_i8: -1) + │ ^^ i8: Value note: - ┌─ ingots/basic_ingot/src/main.fe:28:16 - │ -28 │ return dong::Dyng( - │ ╭────────────────^ -29 │ │ my_address: address(8), -30 │ │ my_u256: 42, -31 │ │ my_i8: -1 -32 │ │ ) - │ ╰─────────^ Dyng: Memory + ┌─ ingots/basic_ingot/src/main.fe:33:16 + │ +33 │ return dong::Dyng(my_address: address(8), my_u256: 42, my_i8: -1) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Dyng: Memory note: - ┌─ ingots/basic_ingot/src/main.fe:34:5 + ┌─ ingots/basic_ingot/src/main.fe:36:5 │ -34 │ ╭ pub fn create_bing_contract(ctx: Context) -> u256: -35 │ │ let bing_contract: BingContract = BingContract.create(ctx, 0) -36 │ │ return bing_contract.add(40, 50) - │ ╰────────────────────────────────────────^ attributes hash: 10526263819290319263 +36 │ ╭ pub fn create_bing_contract(ctx: Context) -> u256 { +37 │ │ let bing_contract: BingContract = BingContract.create(ctx, 0) +38 │ │ return bing_contract.add(40, 50) +39 │ │ } + │ ╰─────^ attributes hash: 10526263819290319263 │ = FunctionSignature { self_decl: None, @@ -284,43 +281,44 @@ note: } note: - ┌─ ingots/basic_ingot/src/main.fe:35:28 + ┌─ ingots/basic_ingot/src/main.fe:37:28 │ -35 │ let bing_contract: BingContract = BingContract.create(ctx, 0) +37 │ let bing_contract: BingContract = BingContract.create(ctx, 0) │ ^^^^^^^^^^^^ BingContract note: - ┌─ ingots/basic_ingot/src/main.fe:35:63 + ┌─ ingots/basic_ingot/src/main.fe:37:63 │ -35 │ let bing_contract: BingContract = BingContract.create(ctx, 0) +37 │ let bing_contract: BingContract = BingContract.create(ctx, 0) │ ^^^ ^ u256: Value │ │ │ Context: Memory note: - ┌─ ingots/basic_ingot/src/main.fe:35:43 + ┌─ ingots/basic_ingot/src/main.fe:37:43 │ -35 │ let bing_contract: BingContract = BingContract.create(ctx, 0) +37 │ let bing_contract: BingContract = BingContract.create(ctx, 0) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ BingContract: Value -36 │ return bing_contract.add(40, 50) +38 │ return bing_contract.add(40, 50) │ ^^^^^^^^^^^^^ ^^ ^^ u256: Value │ │ │ │ │ u256: Value │ BingContract: Value note: - ┌─ ingots/basic_ingot/src/main.fe:36:16 + ┌─ ingots/basic_ingot/src/main.fe:38:16 │ -36 │ return bing_contract.add(40, 50) +38 │ return bing_contract.add(40, 50) │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ ingots/basic_ingot/src/bar.fe:2:1 + ┌─ ingots/basic_ingot/src/bar.fe:1:1 │ -2 │ ╭ pub fn file_items_work() -> bool: -3 │ │ return true - │ ╰─────────────^ attributes hash: 5583437014632790429 +1 │ ╭ pub fn file_items_work() -> bool { +2 │ │ return true +3 │ │ } + │ ╰─^ attributes hash: 5583437014632790429 │ = FunctionSignature { self_decl: None, @@ -334,10 +332,10 @@ note: } note: - ┌─ ingots/basic_ingot/src/bar.fe:3:10 + ┌─ ingots/basic_ingot/src/bar.fe:2:12 │ -3 │ return true - │ ^^^^ bool: Value +2 │ return true + │ ^^^^ bool: Value note: @@ -347,11 +345,12 @@ note: │ ^^^^^^^^^^^^^^^^^^^^^^^ address note: - ┌─ ingots/basic_ingot/src/bing.fe:6:1 + ┌─ ingots/basic_ingot/src/bing.fe:7:1 │ -6 │ ╭ pub fn get_42_backend() -> u256: -7 │ │ return std::evm::add(21, 21) - │ ╰────────────────────────────────^ attributes hash: 6115314201970082834 +7 │ ╭ pub fn get_42_backend() -> u256 { +8 │ │ return std::evm::add(21, 21) +9 │ │ } + │ ╰─^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -367,25 +366,26 @@ note: } note: - ┌─ ingots/basic_ingot/src/bing.fe:7:26 + ┌─ ingots/basic_ingot/src/bing.fe:8:26 │ -7 │ return std::evm::add(21, 21) +8 │ return std::evm::add(21, 21) │ ^^ ^^ u256: Value │ │ │ u256: Value note: - ┌─ ingots/basic_ingot/src/bing.fe:7:12 + ┌─ ingots/basic_ingot/src/bing.fe:8:12 │ -7 │ return std::evm::add(21, 21) +8 │ return std::evm::add(21, 21) │ ^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ ingots/basic_ingot/src/bing.fe:10:4 + ┌─ ingots/basic_ingot/src/bing.fe:12:5 │ -10 │ ╭ pub fn add(_ x: u256, _ y: u256) -> u256: -11 │ │ return x + y - │ ╰───────────────────^ attributes hash: 4448606202021980030 +12 │ ╭ pub fn add(_ x: u256, _ y: u256) -> u256 { +13 │ │ return x + y +14 │ │ } + │ ╰─────^ attributes hash: 4448606202021980030 │ = FunctionSignature { self_decl: None, @@ -428,18 +428,18 @@ note: } note: - ┌─ ingots/basic_ingot/src/bing.fe:11:15 + ┌─ ingots/basic_ingot/src/bing.fe:13:16 │ -11 │ return x + y - │ ^ ^ u256: Value - │ │ - │ u256: Value +13 │ return x + y + │ ^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ ingots/basic_ingot/src/bing.fe:11:15 + ┌─ ingots/basic_ingot/src/bing.fe:13:16 │ -11 │ return x + y - │ ^^^^^ u256: Value +13 │ return x + y + │ ^^^^^ u256: Value @@ -455,9 +455,10 @@ note: note: ┌─ ingots/basic_ingot/src/bar/mee.fe:2:5 │ -2 │ ╭ pub fn kawum() -> u256: +2 │ ╭ pub fn kawum() -> u256 { 3 │ │ return 1 - │ ╰────────────────^ attributes hash: 6115314201970082834 +4 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -479,11 +480,12 @@ note: │ ^ u256: Value note: - ┌─ ingots/basic_ingot/src/bar/mee.fe:5:5 + ┌─ ingots/basic_ingot/src/bar/mee.fe:6:5 │ -5 │ ╭ pub fn rums(self) -> u256: -6 │ │ return 1 - │ ╰────────────────^ attributes hash: 11773348765973600208 +6 │ ╭ pub fn rums(self) -> u256 { +7 │ │ return 1 +8 │ │ } + │ ╰─────^ attributes hash: 11773348765973600208 │ = FunctionSignature { self_decl: Some( @@ -501,9 +503,9 @@ note: } note: - ┌─ ingots/basic_ingot/src/bar/mee.fe:6:16 + ┌─ ingots/basic_ingot/src/bar/mee.fe:7:16 │ -6 │ return 1 +7 │ return 1 │ ^ u256: Value @@ -515,52 +517,53 @@ note: note: - ┌─ ingots/basic_ingot/src/ding/dong.fe:4:3 + ┌─ ingots/basic_ingot/src/ding/dong.fe:4:5 │ -4 │ pub my_address: address - │ ^^^^^^^^^^^^^^^^^^^^^^^ address -5 │ pub my_u256: u256 - │ ^^^^^^^^^^^^^^^^^ u256 -6 │ pub my_i8: i8 - │ ^^^^^^^^^^^^^ i8 +4 │ pub my_address: address + │ ^^^^^^^^^^^^^^^^^^^^^^^ address +5 │ pub my_u256: u256 + │ ^^^^^^^^^^^^^^^^^ u256 +6 │ pub my_i8: i8 + │ ^^^^^^^^^^^^^ i8 note: - ┌─ ingots/basic_ingot/src/ding/dong.fe:8:1 - │ -8 │ ╭ fn get_bing() -> Bing: -9 │ │ return Bing(my_address: address(0)) - │ ╰───────────────────────────────────────^ attributes hash: 10335209349982667488 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [], - return_type: Ok( - Struct( - Struct { - name: "Bing", - field_count: 1, - }, - ), - ), - } + ┌─ ingots/basic_ingot/src/ding/dong.fe:9:1 + │ + 9 │ ╭ fn get_bing() -> Bing { +10 │ │ return Bing(my_address: address(0)) +11 │ │ } + │ ╰─^ attributes hash: 10335209349982667488 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [], + return_type: Ok( + Struct( + Struct { + name: "Bing", + field_count: 1, + }, + ), + ), + } note: - ┌─ ingots/basic_ingot/src/ding/dong.fe:9:37 - │ -9 │ return Bing(my_address: address(0)) - │ ^ u256: Value + ┌─ ingots/basic_ingot/src/ding/dong.fe:10:37 + │ +10 │ return Bing(my_address: address(0)) + │ ^ u256: Value note: - ┌─ ingots/basic_ingot/src/ding/dong.fe:9:29 - │ -9 │ return Bing(my_address: address(0)) - │ ^^^^^^^^^^ address: Value + ┌─ ingots/basic_ingot/src/ding/dong.fe:10:29 + │ +10 │ return Bing(my_address: address(0)) + │ ^^^^^^^^^^ address: Value note: - ┌─ ingots/basic_ingot/src/ding/dong.fe:9:12 - │ -9 │ return Bing(my_address: address(0)) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Bing: Memory + ┌─ ingots/basic_ingot/src/ding/dong.fe:10:12 + │ +10 │ return Bing(my_address: address(0)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Bing: Memory diff --git a/crates/analyzer/tests/snapshots/analysis__call_statement_with_args.snap b/crates/analyzer/tests/snapshots/analysis__call_statement_with_args.snap index 9c9b2ce6ae..6315e99df2 100644 --- a/crates/analyzer/tests/snapshots/analysis__call_statement_with_args.snap +++ b/crates/analyzer/tests/snapshots/analysis__call_statement_with_args.snap @@ -12,9 +12,10 @@ note: note: ┌─ call_statement_with_args.fe:4:5 │ -4 │ ╭ fn assign(self, _ val: u256): +4 │ ╭ fn assign(self, _ val: u256) { 5 │ │ self.baz[0] = val - │ ╰─────────────────────────^ attributes hash: 15254234582808678866 +6 │ │ } + │ ╰─────^ attributes hash: 15254234582808678866 │ = FunctionSignature { self_decl: Some( @@ -66,56 +67,57 @@ note: │ u256: Storage { nonce: None } note: - ┌─ call_statement_with_args.fe:7:5 - │ -7 │ ╭ pub fn bar(self) -> u256: -8 │ │ self.assign(100) -9 │ │ return self.baz[0] - │ ╰──────────────────────────^ attributes hash: 11773348765973600208 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: None, - params: [], - return_type: Ok( - Base( - Numeric( - U256, - ), - ), - ), - } + ┌─ call_statement_with_args.fe:8:5 + │ + 8 │ ╭ pub fn bar(self) -> u256 { + 9 │ │ self.assign(100) +10 │ │ return self.baz[0] +11 │ │ } + │ ╰─────^ attributes hash: 11773348765973600208 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: None, + params: [], + return_type: Ok( + Base( + Numeric( + U256, + ), + ), + ), + } note: - ┌─ call_statement_with_args.fe:8:9 + ┌─ call_statement_with_args.fe:9:9 │ -8 │ self.assign(100) +9 │ self.assign(100) │ ^^^^ ^^^ u256: Value │ │ │ Foo: Value note: - ┌─ call_statement_with_args.fe:8:9 - │ -8 │ self.assign(100) - │ ^^^^^^^^^^^^^^^^ (): Value -9 │ return self.baz[0] - │ ^^^^ Foo: Value + ┌─ call_statement_with_args.fe:9:9 + │ + 9 │ self.assign(100) + │ ^^^^^^^^^^^^^^^^ (): Value +10 │ return self.baz[0] + │ ^^^^ Foo: Value note: - ┌─ call_statement_with_args.fe:9:16 - │ -9 │ return self.baz[0] - │ ^^^^^^^^ ^ u256: Value - │ │ - │ Map: Storage { nonce: Some(0) } + ┌─ call_statement_with_args.fe:10:16 + │ +10 │ return self.baz[0] + │ ^^^^^^^^ ^ u256: Value + │ │ + │ Map: Storage { nonce: Some(0) } note: - ┌─ call_statement_with_args.fe:9:16 - │ -9 │ return self.baz[0] - │ ^^^^^^^^^^^ u256: Storage { nonce: None } => Value + ┌─ call_statement_with_args.fe:10:16 + │ +10 │ return self.baz[0] + │ ^^^^^^^^^^^ u256: Storage { nonce: None } => Value diff --git a/crates/analyzer/tests/snapshots/analysis__call_statement_with_args_2.snap b/crates/analyzer/tests/snapshots/analysis__call_statement_with_args_2.snap index e1c41eb08a..5735079ec7 100644 --- a/crates/analyzer/tests/snapshots/analysis__call_statement_with_args_2.snap +++ b/crates/analyzer/tests/snapshots/analysis__call_statement_with_args_2.snap @@ -12,10 +12,11 @@ note: note: ┌─ call_statement_with_args_2.fe:4:5 │ -4 │ ╭ fn assign(self, _ val: u256) -> u256: +4 │ ╭ fn assign(self, _ val: u256) -> u256 { 5 │ │ self.baz[0] = val 6 │ │ return val - │ ╰──────────────────^ attributes hash: 11102768331449211201 +7 │ │ } + │ ╰─────^ attributes hash: 11102768331449211201 │ = FunctionSignature { self_decl: Some( @@ -71,12 +72,13 @@ note: │ ^^^ u256: Value note: - ┌─ call_statement_with_args_2.fe:8:5 + ┌─ call_statement_with_args_2.fe:9:5 │ - 8 │ ╭ pub fn bar(self) -> u256: - 9 │ │ self.assign(100) -10 │ │ return self.baz[0] - │ ╰──────────────────────────^ attributes hash: 11773348765973600208 + 9 │ ╭ pub fn bar(self) -> u256 { +10 │ │ self.assign(100) +11 │ │ return self.baz[0] +12 │ │ } + │ ╰─────^ attributes hash: 11773348765973600208 │ = FunctionSignature { self_decl: Some( @@ -94,33 +96,33 @@ note: } note: - ┌─ call_statement_with_args_2.fe:9:9 - │ -9 │ self.assign(100) - │ ^^^^ ^^^ u256: Value - │ │ - │ Foo: Value + ┌─ call_statement_with_args_2.fe:10:9 + │ +10 │ self.assign(100) + │ ^^^^ ^^^ u256: Value + │ │ + │ Foo: Value note: - ┌─ call_statement_with_args_2.fe:9:9 + ┌─ call_statement_with_args_2.fe:10:9 │ - 9 │ self.assign(100) +10 │ self.assign(100) │ ^^^^^^^^^^^^^^^^ u256: Value -10 │ return self.baz[0] +11 │ return self.baz[0] │ ^^^^ Foo: Value note: - ┌─ call_statement_with_args_2.fe:10:16 + ┌─ call_statement_with_args_2.fe:11:16 │ -10 │ return self.baz[0] +11 │ return self.baz[0] │ ^^^^^^^^ ^ u256: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ call_statement_with_args_2.fe:10:16 + ┌─ call_statement_with_args_2.fe:11:16 │ -10 │ return self.baz[0] +11 │ return self.baz[0] │ ^^^^^^^^^^^ u256: Storage { nonce: None } => Value diff --git a/crates/analyzer/tests/snapshots/analysis__call_statement_without_args.snap b/crates/analyzer/tests/snapshots/analysis__call_statement_without_args.snap index 249d88acef..ac178ec864 100644 --- a/crates/analyzer/tests/snapshots/analysis__call_statement_without_args.snap +++ b/crates/analyzer/tests/snapshots/analysis__call_statement_without_args.snap @@ -12,9 +12,10 @@ note: note: ┌─ call_statement_without_args.fe:4:5 │ -4 │ ╭ fn assign(self): +4 │ ╭ fn assign(self) { 5 │ │ self.baz[0] = 100 - │ ╰─────────────────────────^ attributes hash: 18235041182630809162 +6 │ │ } + │ ╰─────^ attributes hash: 18235041182630809162 │ = FunctionSignature { self_decl: Some( @@ -52,54 +53,55 @@ note: │ u256: Storage { nonce: None } note: - ┌─ call_statement_without_args.fe:7:5 - │ -7 │ ╭ pub fn bar(self) -> u256: -8 │ │ self.assign() -9 │ │ return self.baz[0] - │ ╰──────────────────────────^ attributes hash: 11773348765973600208 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: None, - params: [], - return_type: Ok( - Base( - Numeric( - U256, - ), - ), - ), - } + ┌─ call_statement_without_args.fe:8:5 + │ + 8 │ ╭ pub fn bar(self) -> u256 { + 9 │ │ self.assign() +10 │ │ return self.baz[0] +11 │ │ } + │ ╰─────^ attributes hash: 11773348765973600208 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: None, + params: [], + return_type: Ok( + Base( + Numeric( + U256, + ), + ), + ), + } note: - ┌─ call_statement_without_args.fe:8:9 + ┌─ call_statement_without_args.fe:9:9 │ -8 │ self.assign() +9 │ self.assign() │ ^^^^ Foo: Value note: - ┌─ call_statement_without_args.fe:8:9 - │ -8 │ self.assign() - │ ^^^^^^^^^^^^^ (): Value -9 │ return self.baz[0] - │ ^^^^ Foo: Value + ┌─ call_statement_without_args.fe:9:9 + │ + 9 │ self.assign() + │ ^^^^^^^^^^^^^ (): Value +10 │ return self.baz[0] + │ ^^^^ Foo: Value note: - ┌─ call_statement_without_args.fe:9:16 - │ -9 │ return self.baz[0] - │ ^^^^^^^^ ^ u256: Value - │ │ - │ Map: Storage { nonce: Some(0) } + ┌─ call_statement_without_args.fe:10:16 + │ +10 │ return self.baz[0] + │ ^^^^^^^^ ^ u256: Value + │ │ + │ Map: Storage { nonce: Some(0) } note: - ┌─ call_statement_without_args.fe:9:16 - │ -9 │ return self.baz[0] - │ ^^^^^^^^^^^ u256: Storage { nonce: None } => Value + ┌─ call_statement_without_args.fe:10:16 + │ +10 │ return self.baz[0] + │ ^^^^^^^^^^^ u256: Storage { nonce: None } => Value diff --git a/crates/analyzer/tests/snapshots/analysis__checked_arithmetic.snap b/crates/analyzer/tests/snapshots/analysis__checked_arithmetic.snap index 1d14519585..6ddf7ea3ad 100644 --- a/crates/analyzer/tests/snapshots/analysis__checked_arithmetic.snap +++ b/crates/analyzer/tests/snapshots/analysis__checked_arithmetic.snap @@ -4,11 +4,12 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ checked_arithmetic.fe:3:5 + ┌─ checked_arithmetic.fe:2:5 │ -3 │ ╭ pub fn add_u256(left: u256, right: u256) -> u256: -4 │ │ return left + right - │ ╰───────────────────────────^ attributes hash: 8877497213208027149 +2 │ ╭ pub fn add_u256(left: u256, right: u256) -> u256 { +3 │ │ return left + right +4 │ │ } + │ ╰─────^ attributes hash: 8877497213208027149 │ = FunctionSignature { self_decl: None, @@ -47,25 +48,26 @@ note: } note: - ┌─ checked_arithmetic.fe:4:16 + ┌─ checked_arithmetic.fe:3:16 │ -4 │ return left + right +3 │ return left + right │ ^^^^ ^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ checked_arithmetic.fe:4:16 + ┌─ checked_arithmetic.fe:3:16 │ -4 │ return left + right +3 │ return left + right │ ^^^^^^^^^^^^ u256: Value note: ┌─ checked_arithmetic.fe:6:5 │ -6 │ ╭ pub fn add_u128(left: u128, right: u128) -> u128: +6 │ ╭ pub fn add_u128(left: u128, right: u128) -> u128 { 7 │ │ return left + right - │ ╰───────────────────────────^ attributes hash: 11187416061572591496 +8 │ │ } + │ ╰─────^ attributes hash: 11187416061572591496 │ = FunctionSignature { self_decl: None, @@ -118,11 +120,12 @@ note: │ ^^^^^^^^^^^^ u128: Value note: - ┌─ checked_arithmetic.fe:9:5 + ┌─ checked_arithmetic.fe:10:5 │ - 9 │ ╭ pub fn add_u64(left: u64, right: u64) -> u64: -10 │ │ return left + right - │ ╰───────────────────────────^ attributes hash: 9316585824156398552 +10 │ ╭ pub fn add_u64(left: u64, right: u64) -> u64 { +11 │ │ return left + right +12 │ │ } + │ ╰─────^ attributes hash: 9316585824156398552 │ = FunctionSignature { self_decl: None, @@ -161,25 +164,26 @@ note: } note: - ┌─ checked_arithmetic.fe:10:16 + ┌─ checked_arithmetic.fe:11:16 │ -10 │ return left + right +11 │ return left + right │ ^^^^ ^^^^^ u64: Value │ │ │ u64: Value note: - ┌─ checked_arithmetic.fe:10:16 + ┌─ checked_arithmetic.fe:11:16 │ -10 │ return left + right +11 │ return left + right │ ^^^^^^^^^^^^ u64: Value note: - ┌─ checked_arithmetic.fe:12:5 + ┌─ checked_arithmetic.fe:14:5 │ -12 │ ╭ pub fn add_u32(left: u32, right: u32) -> u32: -13 │ │ return left + right - │ ╰───────────────────────────^ attributes hash: 6948562809403003686 +14 │ ╭ pub fn add_u32(left: u32, right: u32) -> u32 { +15 │ │ return left + right +16 │ │ } + │ ╰─────^ attributes hash: 6948562809403003686 │ = FunctionSignature { self_decl: None, @@ -218,25 +222,26 @@ note: } note: - ┌─ checked_arithmetic.fe:13:16 + ┌─ checked_arithmetic.fe:15:16 │ -13 │ return left + right +15 │ return left + right │ ^^^^ ^^^^^ u32: Value │ │ │ u32: Value note: - ┌─ checked_arithmetic.fe:13:16 + ┌─ checked_arithmetic.fe:15:16 │ -13 │ return left + right +15 │ return left + right │ ^^^^^^^^^^^^ u32: Value note: - ┌─ checked_arithmetic.fe:15:5 + ┌─ checked_arithmetic.fe:18:5 │ -15 │ ╭ pub fn add_u16(left: u16, right: u16) -> u16: -16 │ │ return left + right - │ ╰───────────────────────────^ attributes hash: 4214429573900255413 +18 │ ╭ pub fn add_u16(left: u16, right: u16) -> u16 { +19 │ │ return left + right +20 │ │ } + │ ╰─────^ attributes hash: 4214429573900255413 │ = FunctionSignature { self_decl: None, @@ -275,25 +280,26 @@ note: } note: - ┌─ checked_arithmetic.fe:16:16 + ┌─ checked_arithmetic.fe:19:16 │ -16 │ return left + right +19 │ return left + right │ ^^^^ ^^^^^ u16: Value │ │ │ u16: Value note: - ┌─ checked_arithmetic.fe:16:16 + ┌─ checked_arithmetic.fe:19:16 │ -16 │ return left + right +19 │ return left + right │ ^^^^^^^^^^^^ u16: Value note: - ┌─ checked_arithmetic.fe:18:5 + ┌─ checked_arithmetic.fe:22:5 │ -18 │ ╭ pub fn add_u8(left: u8, right: u8) -> u8: -19 │ │ return left + right - │ ╰───────────────────────────^ attributes hash: 3749617961046563034 +22 │ ╭ pub fn add_u8(left: u8, right: u8) -> u8 { +23 │ │ return left + right +24 │ │ } + │ ╰─────^ attributes hash: 3749617961046563034 │ = FunctionSignature { self_decl: None, @@ -332,25 +338,26 @@ note: } note: - ┌─ checked_arithmetic.fe:19:16 + ┌─ checked_arithmetic.fe:23:16 │ -19 │ return left + right +23 │ return left + right │ ^^^^ ^^^^^ u8: Value │ │ │ u8: Value note: - ┌─ checked_arithmetic.fe:19:16 + ┌─ checked_arithmetic.fe:23:16 │ -19 │ return left + right +23 │ return left + right │ ^^^^^^^^^^^^ u8: Value note: - ┌─ checked_arithmetic.fe:21:5 + ┌─ checked_arithmetic.fe:26:5 │ -21 │ ╭ pub fn add_i256(left: i256, right: i256) -> i256: -22 │ │ return left + right - │ ╰───────────────────────────^ attributes hash: 17908204859155721295 +26 │ ╭ pub fn add_i256(left: i256, right: i256) -> i256 { +27 │ │ return left + right +28 │ │ } + │ ╰─────^ attributes hash: 17908204859155721295 │ = FunctionSignature { self_decl: None, @@ -389,25 +396,26 @@ note: } note: - ┌─ checked_arithmetic.fe:22:16 + ┌─ checked_arithmetic.fe:27:16 │ -22 │ return left + right +27 │ return left + right │ ^^^^ ^^^^^ i256: Value │ │ │ i256: Value note: - ┌─ checked_arithmetic.fe:22:16 + ┌─ checked_arithmetic.fe:27:16 │ -22 │ return left + right +27 │ return left + right │ ^^^^^^^^^^^^ i256: Value note: - ┌─ checked_arithmetic.fe:24:5 + ┌─ checked_arithmetic.fe:30:5 │ -24 │ ╭ pub fn add_i128(left: i128, right: i128) -> i128: -25 │ │ return left + right - │ ╰───────────────────────────^ attributes hash: 1332431709112937827 +30 │ ╭ pub fn add_i128(left: i128, right: i128) -> i128 { +31 │ │ return left + right +32 │ │ } + │ ╰─────^ attributes hash: 1332431709112937827 │ = FunctionSignature { self_decl: None, @@ -446,25 +454,26 @@ note: } note: - ┌─ checked_arithmetic.fe:25:16 + ┌─ checked_arithmetic.fe:31:16 │ -25 │ return left + right +31 │ return left + right │ ^^^^ ^^^^^ i128: Value │ │ │ i128: Value note: - ┌─ checked_arithmetic.fe:25:16 + ┌─ checked_arithmetic.fe:31:16 │ -25 │ return left + right +31 │ return left + right │ ^^^^^^^^^^^^ i128: Value note: - ┌─ checked_arithmetic.fe:27:5 + ┌─ checked_arithmetic.fe:34:5 │ -27 │ ╭ pub fn add_i64(left: i64, right: i64) -> i64: -28 │ │ return left + right - │ ╰───────────────────────────^ attributes hash: 3549113083347694903 +34 │ ╭ pub fn add_i64(left: i64, right: i64) -> i64 { +35 │ │ return left + right +36 │ │ } + │ ╰─────^ attributes hash: 3549113083347694903 │ = FunctionSignature { self_decl: None, @@ -503,25 +512,26 @@ note: } note: - ┌─ checked_arithmetic.fe:28:16 + ┌─ checked_arithmetic.fe:35:16 │ -28 │ return left + right +35 │ return left + right │ ^^^^ ^^^^^ i64: Value │ │ │ i64: Value note: - ┌─ checked_arithmetic.fe:28:16 + ┌─ checked_arithmetic.fe:35:16 │ -28 │ return left + right +35 │ return left + right │ ^^^^^^^^^^^^ i64: Value note: - ┌─ checked_arithmetic.fe:30:5 + ┌─ checked_arithmetic.fe:38:5 │ -30 │ ╭ pub fn add_i32(left: i32, right: i32) -> i32: -31 │ │ return left + right - │ ╰───────────────────────────^ attributes hash: 15117649447142800500 +38 │ ╭ pub fn add_i32(left: i32, right: i32) -> i32 { +39 │ │ return left + right +40 │ │ } + │ ╰─────^ attributes hash: 15117649447142800500 │ = FunctionSignature { self_decl: None, @@ -560,25 +570,26 @@ note: } note: - ┌─ checked_arithmetic.fe:31:16 + ┌─ checked_arithmetic.fe:39:16 │ -31 │ return left + right +39 │ return left + right │ ^^^^ ^^^^^ i32: Value │ │ │ i32: Value note: - ┌─ checked_arithmetic.fe:31:16 + ┌─ checked_arithmetic.fe:39:16 │ -31 │ return left + right +39 │ return left + right │ ^^^^^^^^^^^^ i32: Value note: - ┌─ checked_arithmetic.fe:33:5 + ┌─ checked_arithmetic.fe:42:5 │ -33 │ ╭ pub fn add_i16(left: i16, right: i16) -> i16: -34 │ │ return left + right - │ ╰───────────────────────────^ attributes hash: 16520261699954225452 +42 │ ╭ pub fn add_i16(left: i16, right: i16) -> i16 { +43 │ │ return left + right +44 │ │ } + │ ╰─────^ attributes hash: 16520261699954225452 │ = FunctionSignature { self_decl: None, @@ -617,25 +628,26 @@ note: } note: - ┌─ checked_arithmetic.fe:34:16 + ┌─ checked_arithmetic.fe:43:16 │ -34 │ return left + right +43 │ return left + right │ ^^^^ ^^^^^ i16: Value │ │ │ i16: Value note: - ┌─ checked_arithmetic.fe:34:16 + ┌─ checked_arithmetic.fe:43:16 │ -34 │ return left + right +43 │ return left + right │ ^^^^^^^^^^^^ i16: Value note: - ┌─ checked_arithmetic.fe:36:5 + ┌─ checked_arithmetic.fe:46:5 │ -36 │ ╭ pub fn add_i8(left: i8, right: i8) -> i8: -37 │ │ return left + right - │ ╰───────────────────────────^ attributes hash: 2984879578165475690 +46 │ ╭ pub fn add_i8(left: i8, right: i8) -> i8 { +47 │ │ return left + right +48 │ │ } + │ ╰─────^ attributes hash: 2984879578165475690 │ = FunctionSignature { self_decl: None, @@ -674,25 +686,26 @@ note: } note: - ┌─ checked_arithmetic.fe:37:16 + ┌─ checked_arithmetic.fe:47:16 │ -37 │ return left + right +47 │ return left + right │ ^^^^ ^^^^^ i8: Value │ │ │ i8: Value note: - ┌─ checked_arithmetic.fe:37:16 + ┌─ checked_arithmetic.fe:47:16 │ -37 │ return left + right +47 │ return left + right │ ^^^^^^^^^^^^ i8: Value note: - ┌─ checked_arithmetic.fe:39:5 + ┌─ checked_arithmetic.fe:50:5 │ -39 │ ╭ pub fn sub_u256(left: u256, right: u256) -> u256: -40 │ │ return left - right - │ ╰───────────────────────────^ attributes hash: 8877497213208027149 +50 │ ╭ pub fn sub_u256(left: u256, right: u256) -> u256 { +51 │ │ return left - right +52 │ │ } + │ ╰─────^ attributes hash: 8877497213208027149 │ = FunctionSignature { self_decl: None, @@ -731,25 +744,26 @@ note: } note: - ┌─ checked_arithmetic.fe:40:16 + ┌─ checked_arithmetic.fe:51:16 │ -40 │ return left - right +51 │ return left - right │ ^^^^ ^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ checked_arithmetic.fe:40:16 + ┌─ checked_arithmetic.fe:51:16 │ -40 │ return left - right +51 │ return left - right │ ^^^^^^^^^^^^ u256: Value note: - ┌─ checked_arithmetic.fe:42:5 + ┌─ checked_arithmetic.fe:54:5 │ -42 │ ╭ pub fn sub_u128(left: u128, right: u128) -> u128: -43 │ │ return left - right - │ ╰───────────────────────────^ attributes hash: 11187416061572591496 +54 │ ╭ pub fn sub_u128(left: u128, right: u128) -> u128 { +55 │ │ return left - right +56 │ │ } + │ ╰─────^ attributes hash: 11187416061572591496 │ = FunctionSignature { self_decl: None, @@ -788,25 +802,26 @@ note: } note: - ┌─ checked_arithmetic.fe:43:16 + ┌─ checked_arithmetic.fe:55:16 │ -43 │ return left - right +55 │ return left - right │ ^^^^ ^^^^^ u128: Value │ │ │ u128: Value note: - ┌─ checked_arithmetic.fe:43:16 + ┌─ checked_arithmetic.fe:55:16 │ -43 │ return left - right +55 │ return left - right │ ^^^^^^^^^^^^ u128: Value note: - ┌─ checked_arithmetic.fe:45:5 + ┌─ checked_arithmetic.fe:58:5 │ -45 │ ╭ pub fn sub_u64(left: u64, right: u64) -> u64: -46 │ │ return left - right - │ ╰───────────────────────────^ attributes hash: 9316585824156398552 +58 │ ╭ pub fn sub_u64(left: u64, right: u64) -> u64 { +59 │ │ return left - right +60 │ │ } + │ ╰─────^ attributes hash: 9316585824156398552 │ = FunctionSignature { self_decl: None, @@ -845,25 +860,26 @@ note: } note: - ┌─ checked_arithmetic.fe:46:16 + ┌─ checked_arithmetic.fe:59:16 │ -46 │ return left - right +59 │ return left - right │ ^^^^ ^^^^^ u64: Value │ │ │ u64: Value note: - ┌─ checked_arithmetic.fe:46:16 + ┌─ checked_arithmetic.fe:59:16 │ -46 │ return left - right +59 │ return left - right │ ^^^^^^^^^^^^ u64: Value note: - ┌─ checked_arithmetic.fe:48:5 + ┌─ checked_arithmetic.fe:62:5 │ -48 │ ╭ pub fn sub_u32(left: u32, right: u32) -> u32: -49 │ │ return left - right - │ ╰───────────────────────────^ attributes hash: 6948562809403003686 +62 │ ╭ pub fn sub_u32(left: u32, right: u32) -> u32 { +63 │ │ return left - right +64 │ │ } + │ ╰─────^ attributes hash: 6948562809403003686 │ = FunctionSignature { self_decl: None, @@ -902,25 +918,26 @@ note: } note: - ┌─ checked_arithmetic.fe:49:16 + ┌─ checked_arithmetic.fe:63:16 │ -49 │ return left - right +63 │ return left - right │ ^^^^ ^^^^^ u32: Value │ │ │ u32: Value note: - ┌─ checked_arithmetic.fe:49:16 + ┌─ checked_arithmetic.fe:63:16 │ -49 │ return left - right +63 │ return left - right │ ^^^^^^^^^^^^ u32: Value note: - ┌─ checked_arithmetic.fe:51:5 + ┌─ checked_arithmetic.fe:66:5 │ -51 │ ╭ pub fn sub_u16(left: u16, right: u16) -> u16: -52 │ │ return left - right - │ ╰───────────────────────────^ attributes hash: 4214429573900255413 +66 │ ╭ pub fn sub_u16(left: u16, right: u16) -> u16 { +67 │ │ return left - right +68 │ │ } + │ ╰─────^ attributes hash: 4214429573900255413 │ = FunctionSignature { self_decl: None, @@ -959,25 +976,26 @@ note: } note: - ┌─ checked_arithmetic.fe:52:16 + ┌─ checked_arithmetic.fe:67:16 │ -52 │ return left - right +67 │ return left - right │ ^^^^ ^^^^^ u16: Value │ │ │ u16: Value note: - ┌─ checked_arithmetic.fe:52:16 + ┌─ checked_arithmetic.fe:67:16 │ -52 │ return left - right +67 │ return left - right │ ^^^^^^^^^^^^ u16: Value note: - ┌─ checked_arithmetic.fe:54:5 + ┌─ checked_arithmetic.fe:70:5 │ -54 │ ╭ pub fn sub_u8(left: u8, right: u8) -> u8: -55 │ │ return left - right - │ ╰───────────────────────────^ attributes hash: 3749617961046563034 +70 │ ╭ pub fn sub_u8(left: u8, right: u8) -> u8 { +71 │ │ return left - right +72 │ │ } + │ ╰─────^ attributes hash: 3749617961046563034 │ = FunctionSignature { self_decl: None, @@ -1016,25 +1034,26 @@ note: } note: - ┌─ checked_arithmetic.fe:55:16 + ┌─ checked_arithmetic.fe:71:16 │ -55 │ return left - right +71 │ return left - right │ ^^^^ ^^^^^ u8: Value │ │ │ u8: Value note: - ┌─ checked_arithmetic.fe:55:16 + ┌─ checked_arithmetic.fe:71:16 │ -55 │ return left - right +71 │ return left - right │ ^^^^^^^^^^^^ u8: Value note: - ┌─ checked_arithmetic.fe:57:5 + ┌─ checked_arithmetic.fe:74:5 │ -57 │ ╭ pub fn sub_i256(left: i256, right: i256) -> i256: -58 │ │ return left - right - │ ╰───────────────────────────^ attributes hash: 17908204859155721295 +74 │ ╭ pub fn sub_i256(left: i256, right: i256) -> i256 { +75 │ │ return left - right +76 │ │ } + │ ╰─────^ attributes hash: 17908204859155721295 │ = FunctionSignature { self_decl: None, @@ -1073,25 +1092,26 @@ note: } note: - ┌─ checked_arithmetic.fe:58:16 + ┌─ checked_arithmetic.fe:75:16 │ -58 │ return left - right +75 │ return left - right │ ^^^^ ^^^^^ i256: Value │ │ │ i256: Value note: - ┌─ checked_arithmetic.fe:58:16 + ┌─ checked_arithmetic.fe:75:16 │ -58 │ return left - right +75 │ return left - right │ ^^^^^^^^^^^^ i256: Value note: - ┌─ checked_arithmetic.fe:60:5 + ┌─ checked_arithmetic.fe:78:5 │ -60 │ ╭ pub fn sub_i128(left: i128, right: i128) -> i128: -61 │ │ return left - right - │ ╰───────────────────────────^ attributes hash: 1332431709112937827 +78 │ ╭ pub fn sub_i128(left: i128, right: i128) -> i128 { +79 │ │ return left - right +80 │ │ } + │ ╰─────^ attributes hash: 1332431709112937827 │ = FunctionSignature { self_decl: None, @@ -1130,25 +1150,26 @@ note: } note: - ┌─ checked_arithmetic.fe:61:16 + ┌─ checked_arithmetic.fe:79:16 │ -61 │ return left - right +79 │ return left - right │ ^^^^ ^^^^^ i128: Value │ │ │ i128: Value note: - ┌─ checked_arithmetic.fe:61:16 + ┌─ checked_arithmetic.fe:79:16 │ -61 │ return left - right +79 │ return left - right │ ^^^^^^^^^^^^ i128: Value note: - ┌─ checked_arithmetic.fe:63:5 + ┌─ checked_arithmetic.fe:82:5 │ -63 │ ╭ pub fn sub_i64(left: i64, right: i64) -> i64: -64 │ │ return left - right - │ ╰───────────────────────────^ attributes hash: 3549113083347694903 +82 │ ╭ pub fn sub_i64(left: i64, right: i64) -> i64 { +83 │ │ return left - right +84 │ │ } + │ ╰─────^ attributes hash: 3549113083347694903 │ = FunctionSignature { self_decl: None, @@ -1187,25 +1208,26 @@ note: } note: - ┌─ checked_arithmetic.fe:64:16 + ┌─ checked_arithmetic.fe:83:16 │ -64 │ return left - right +83 │ return left - right │ ^^^^ ^^^^^ i64: Value │ │ │ i64: Value note: - ┌─ checked_arithmetic.fe:64:16 + ┌─ checked_arithmetic.fe:83:16 │ -64 │ return left - right +83 │ return left - right │ ^^^^^^^^^^^^ i64: Value note: - ┌─ checked_arithmetic.fe:66:5 + ┌─ checked_arithmetic.fe:86:5 │ -66 │ ╭ pub fn sub_i32(left: i32, right: i32) -> i32: -67 │ │ return left - right - │ ╰───────────────────────────^ attributes hash: 15117649447142800500 +86 │ ╭ pub fn sub_i32(left: i32, right: i32) -> i32 { +87 │ │ return left - right +88 │ │ } + │ ╰─────^ attributes hash: 15117649447142800500 │ = FunctionSignature { self_decl: None, @@ -1244,25 +1266,26 @@ note: } note: - ┌─ checked_arithmetic.fe:67:16 + ┌─ checked_arithmetic.fe:87:16 │ -67 │ return left - right +87 │ return left - right │ ^^^^ ^^^^^ i32: Value │ │ │ i32: Value note: - ┌─ checked_arithmetic.fe:67:16 + ┌─ checked_arithmetic.fe:87:16 │ -67 │ return left - right +87 │ return left - right │ ^^^^^^^^^^^^ i32: Value note: - ┌─ checked_arithmetic.fe:69:5 + ┌─ checked_arithmetic.fe:90:5 │ -69 │ ╭ pub fn sub_i16(left: i16, right: i16) -> i16: -70 │ │ return left - right - │ ╰───────────────────────────^ attributes hash: 16520261699954225452 +90 │ ╭ pub fn sub_i16(left: i16, right: i16) -> i16 { +91 │ │ return left - right +92 │ │ } + │ ╰─────^ attributes hash: 16520261699954225452 │ = FunctionSignature { self_decl: None, @@ -1301,25 +1324,26 @@ note: } note: - ┌─ checked_arithmetic.fe:70:16 + ┌─ checked_arithmetic.fe:91:16 │ -70 │ return left - right +91 │ return left - right │ ^^^^ ^^^^^ i16: Value │ │ │ i16: Value note: - ┌─ checked_arithmetic.fe:70:16 + ┌─ checked_arithmetic.fe:91:16 │ -70 │ return left - right +91 │ return left - right │ ^^^^^^^^^^^^ i16: Value note: - ┌─ checked_arithmetic.fe:72:5 + ┌─ checked_arithmetic.fe:94:5 │ -72 │ ╭ pub fn sub_i8(left: i8, right: i8) -> i8: -73 │ │ return left - right - │ ╰───────────────────────────^ attributes hash: 2984879578165475690 +94 │ ╭ pub fn sub_i8(left: i8, right: i8) -> i8 { +95 │ │ return left - right +96 │ │ } + │ ╰─────^ attributes hash: 2984879578165475690 │ = FunctionSignature { self_decl: None, @@ -1358,481 +1382,490 @@ note: } note: - ┌─ checked_arithmetic.fe:73:16 + ┌─ checked_arithmetic.fe:95:16 │ -73 │ return left - right +95 │ return left - right │ ^^^^ ^^^^^ i8: Value │ │ │ i8: Value note: - ┌─ checked_arithmetic.fe:73:16 + ┌─ checked_arithmetic.fe:95:16 │ -73 │ return left - right +95 │ return left - right │ ^^^^^^^^^^^^ i8: Value note: - ┌─ checked_arithmetic.fe:75:5 - │ -75 │ ╭ pub fn div_u256(left: u256, right: u256) -> u256: -76 │ │ return left / right - │ ╰───────────────────────────^ attributes hash: 8877497213208027149 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "left", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - }, - FunctionParam { - label: None, - name: "right", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Numeric( - U256, - ), - ), - ), - } + ┌─ checked_arithmetic.fe:98:5 + │ + 98 │ ╭ pub fn div_u256(left: u256, right: u256) -> u256 { + 99 │ │ return left / right +100 │ │ } + │ ╰─────^ attributes hash: 8877497213208027149 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "left", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + }, + FunctionParam { + label: None, + name: "right", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Numeric( + U256, + ), + ), + ), + } note: - ┌─ checked_arithmetic.fe:76:16 + ┌─ checked_arithmetic.fe:99:16 │ -76 │ return left / right +99 │ return left / right │ ^^^^ ^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ checked_arithmetic.fe:76:16 + ┌─ checked_arithmetic.fe:99:16 │ -76 │ return left / right +99 │ return left / right │ ^^^^^^^^^^^^ u256: Value note: - ┌─ checked_arithmetic.fe:78:5 - │ -78 │ ╭ pub fn div_u128(left: u128, right: u128) -> u128: -79 │ │ return left / right - │ ╰───────────────────────────^ attributes hash: 11187416061572591496 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "left", - typ: Ok( - Base( - Numeric( - U128, - ), - ), - ), - }, - FunctionParam { - label: None, - name: "right", - typ: Ok( - Base( - Numeric( - U128, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Numeric( - U128, - ), - ), - ), - } + ┌─ checked_arithmetic.fe:102:5 + │ +102 │ ╭ pub fn div_u128(left: u128, right: u128) -> u128 { +103 │ │ return left / right +104 │ │ } + │ ╰─────^ attributes hash: 11187416061572591496 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "left", + typ: Ok( + Base( + Numeric( + U128, + ), + ), + ), + }, + FunctionParam { + label: None, + name: "right", + typ: Ok( + Base( + Numeric( + U128, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Numeric( + U128, + ), + ), + ), + } note: - ┌─ checked_arithmetic.fe:79:16 - │ -79 │ return left / right - │ ^^^^ ^^^^^ u128: Value - │ │ - │ u128: Value + ┌─ checked_arithmetic.fe:103:16 + │ +103 │ return left / right + │ ^^^^ ^^^^^ u128: Value + │ │ + │ u128: Value note: - ┌─ checked_arithmetic.fe:79:16 - │ -79 │ return left / right - │ ^^^^^^^^^^^^ u128: Value + ┌─ checked_arithmetic.fe:103:16 + │ +103 │ return left / right + │ ^^^^^^^^^^^^ u128: Value note: - ┌─ checked_arithmetic.fe:81:5 - │ -81 │ ╭ pub fn div_u64(left: u64, right: u64) -> u64: -82 │ │ return left / right - │ ╰───────────────────────────^ attributes hash: 9316585824156398552 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "left", - typ: Ok( - Base( - Numeric( - U64, - ), - ), - ), - }, - FunctionParam { - label: None, - name: "right", - typ: Ok( - Base( - Numeric( - U64, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Numeric( - U64, - ), - ), - ), - } + ┌─ checked_arithmetic.fe:106:5 + │ +106 │ ╭ pub fn div_u64(left: u64, right: u64) -> u64 { +107 │ │ return left / right +108 │ │ } + │ ╰─────^ attributes hash: 9316585824156398552 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "left", + typ: Ok( + Base( + Numeric( + U64, + ), + ), + ), + }, + FunctionParam { + label: None, + name: "right", + typ: Ok( + Base( + Numeric( + U64, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Numeric( + U64, + ), + ), + ), + } note: - ┌─ checked_arithmetic.fe:82:16 - │ -82 │ return left / right - │ ^^^^ ^^^^^ u64: Value - │ │ - │ u64: Value + ┌─ checked_arithmetic.fe:107:16 + │ +107 │ return left / right + │ ^^^^ ^^^^^ u64: Value + │ │ + │ u64: Value note: - ┌─ checked_arithmetic.fe:82:16 - │ -82 │ return left / right - │ ^^^^^^^^^^^^ u64: Value + ┌─ checked_arithmetic.fe:107:16 + │ +107 │ return left / right + │ ^^^^^^^^^^^^ u64: Value note: - ┌─ checked_arithmetic.fe:84:5 - │ -84 │ ╭ pub fn div_u32(left: u32, right: u32) -> u32: -85 │ │ return left / right - │ ╰───────────────────────────^ attributes hash: 6948562809403003686 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "left", - typ: Ok( - Base( - Numeric( - U32, - ), - ), - ), - }, - FunctionParam { - label: None, - name: "right", - typ: Ok( - Base( - Numeric( - U32, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Numeric( - U32, - ), - ), - ), - } + ┌─ checked_arithmetic.fe:110:5 + │ +110 │ ╭ pub fn div_u32(left: u32, right: u32) -> u32 { +111 │ │ return left / right +112 │ │ } + │ ╰─────^ attributes hash: 6948562809403003686 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "left", + typ: Ok( + Base( + Numeric( + U32, + ), + ), + ), + }, + FunctionParam { + label: None, + name: "right", + typ: Ok( + Base( + Numeric( + U32, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Numeric( + U32, + ), + ), + ), + } note: - ┌─ checked_arithmetic.fe:85:16 - │ -85 │ return left / right - │ ^^^^ ^^^^^ u32: Value - │ │ - │ u32: Value + ┌─ checked_arithmetic.fe:111:16 + │ +111 │ return left / right + │ ^^^^ ^^^^^ u32: Value + │ │ + │ u32: Value note: - ┌─ checked_arithmetic.fe:85:16 - │ -85 │ return left / right - │ ^^^^^^^^^^^^ u32: Value + ┌─ checked_arithmetic.fe:111:16 + │ +111 │ return left / right + │ ^^^^^^^^^^^^ u32: Value note: - ┌─ checked_arithmetic.fe:87:5 - │ -87 │ ╭ pub fn div_u16(left: u16, right: u16) -> u16: -88 │ │ return left / right - │ ╰───────────────────────────^ attributes hash: 4214429573900255413 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "left", - typ: Ok( - Base( - Numeric( - U16, - ), - ), - ), - }, - FunctionParam { - label: None, - name: "right", - typ: Ok( - Base( - Numeric( - U16, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Numeric( - U16, - ), - ), - ), - } + ┌─ checked_arithmetic.fe:114:5 + │ +114 │ ╭ pub fn div_u16(left: u16, right: u16) -> u16 { +115 │ │ return left / right +116 │ │ } + │ ╰─────^ attributes hash: 4214429573900255413 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "left", + typ: Ok( + Base( + Numeric( + U16, + ), + ), + ), + }, + FunctionParam { + label: None, + name: "right", + typ: Ok( + Base( + Numeric( + U16, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Numeric( + U16, + ), + ), + ), + } note: - ┌─ checked_arithmetic.fe:88:16 - │ -88 │ return left / right - │ ^^^^ ^^^^^ u16: Value - │ │ - │ u16: Value + ┌─ checked_arithmetic.fe:115:16 + │ +115 │ return left / right + │ ^^^^ ^^^^^ u16: Value + │ │ + │ u16: Value note: - ┌─ checked_arithmetic.fe:88:16 - │ -88 │ return left / right - │ ^^^^^^^^^^^^ u16: Value + ┌─ checked_arithmetic.fe:115:16 + │ +115 │ return left / right + │ ^^^^^^^^^^^^ u16: Value note: - ┌─ checked_arithmetic.fe:90:5 - │ -90 │ ╭ pub fn div_u8(left: u8, right: u8) -> u8: -91 │ │ return left / right - │ ╰───────────────────────────^ attributes hash: 3749617961046563034 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "left", - typ: Ok( - Base( - Numeric( - U8, - ), - ), - ), - }, - FunctionParam { - label: None, - name: "right", - typ: Ok( - Base( - Numeric( - U8, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Numeric( - U8, - ), - ), - ), - } + ┌─ checked_arithmetic.fe:118:5 + │ +118 │ ╭ pub fn div_u8(left: u8, right: u8) -> u8 { +119 │ │ return left / right +120 │ │ } + │ ╰─────^ attributes hash: 3749617961046563034 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "left", + typ: Ok( + Base( + Numeric( + U8, + ), + ), + ), + }, + FunctionParam { + label: None, + name: "right", + typ: Ok( + Base( + Numeric( + U8, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Numeric( + U8, + ), + ), + ), + } note: - ┌─ checked_arithmetic.fe:91:16 - │ -91 │ return left / right - │ ^^^^ ^^^^^ u8: Value - │ │ - │ u8: Value + ┌─ checked_arithmetic.fe:119:16 + │ +119 │ return left / right + │ ^^^^ ^^^^^ u8: Value + │ │ + │ u8: Value note: - ┌─ checked_arithmetic.fe:91:16 - │ -91 │ return left / right - │ ^^^^^^^^^^^^ u8: Value + ┌─ checked_arithmetic.fe:119:16 + │ +119 │ return left / right + │ ^^^^^^^^^^^^ u8: Value note: - ┌─ checked_arithmetic.fe:93:5 - │ -93 │ ╭ pub fn div_i256(left: i256, right: i256) -> i256: -94 │ │ return left / right - │ ╰───────────────────────────^ attributes hash: 17908204859155721295 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "left", - typ: Ok( - Base( - Numeric( - I256, - ), - ), - ), - }, - FunctionParam { - label: None, - name: "right", - typ: Ok( - Base( - Numeric( - I256, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Numeric( - I256, - ), - ), - ), - } + ┌─ checked_arithmetic.fe:122:5 + │ +122 │ ╭ pub fn div_i256(left: i256, right: i256) -> i256 { +123 │ │ return left / right +124 │ │ } + │ ╰─────^ attributes hash: 17908204859155721295 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "left", + typ: Ok( + Base( + Numeric( + I256, + ), + ), + ), + }, + FunctionParam { + label: None, + name: "right", + typ: Ok( + Base( + Numeric( + I256, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Numeric( + I256, + ), + ), + ), + } note: - ┌─ checked_arithmetic.fe:94:16 - │ -94 │ return left / right - │ ^^^^ ^^^^^ i256: Value - │ │ - │ i256: Value + ┌─ checked_arithmetic.fe:123:16 + │ +123 │ return left / right + │ ^^^^ ^^^^^ i256: Value + │ │ + │ i256: Value note: - ┌─ checked_arithmetic.fe:94:16 - │ -94 │ return left / right - │ ^^^^^^^^^^^^ i256: Value + ┌─ checked_arithmetic.fe:123:16 + │ +123 │ return left / right + │ ^^^^^^^^^^^^ i256: Value note: - ┌─ checked_arithmetic.fe:96:5 - │ -96 │ ╭ pub fn div_i128(left: i128, right: i128) -> i128: -97 │ │ return left / right - │ ╰───────────────────────────^ attributes hash: 1332431709112937827 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "left", - typ: Ok( - Base( - Numeric( - I128, - ), - ), - ), - }, - FunctionParam { - label: None, - name: "right", - typ: Ok( - Base( - Numeric( - I128, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Numeric( - I128, - ), - ), - ), - } + ┌─ checked_arithmetic.fe:126:5 + │ +126 │ ╭ pub fn div_i128(left: i128, right: i128) -> i128 { +127 │ │ return left / right +128 │ │ } + │ ╰─────^ attributes hash: 1332431709112937827 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "left", + typ: Ok( + Base( + Numeric( + I128, + ), + ), + ), + }, + FunctionParam { + label: None, + name: "right", + typ: Ok( + Base( + Numeric( + I128, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Numeric( + I128, + ), + ), + ), + } note: - ┌─ checked_arithmetic.fe:97:16 - │ -97 │ return left / right - │ ^^^^ ^^^^^ i128: Value - │ │ - │ i128: Value + ┌─ checked_arithmetic.fe:127:16 + │ +127 │ return left / right + │ ^^^^ ^^^^^ i128: Value + │ │ + │ i128: Value note: - ┌─ checked_arithmetic.fe:97:16 - │ -97 │ return left / right - │ ^^^^^^^^^^^^ i128: Value + ┌─ checked_arithmetic.fe:127:16 + │ +127 │ return left / right + │ ^^^^^^^^^^^^ i128: Value note: - ┌─ checked_arithmetic.fe:99:5 + ┌─ checked_arithmetic.fe:130:5 │ - 99 │ ╭ pub fn div_i64(left: i64, right: i64) -> i64: -100 │ │ return left / right - │ ╰───────────────────────────^ attributes hash: 3549113083347694903 +130 │ ╭ pub fn div_i64(left: i64, right: i64) -> i64 { +131 │ │ return left / right +132 │ │ } + │ ╰─────^ attributes hash: 3549113083347694903 │ = FunctionSignature { self_decl: None, @@ -1871,25 +1904,26 @@ note: } note: - ┌─ checked_arithmetic.fe:100:16 + ┌─ checked_arithmetic.fe:131:16 │ -100 │ return left / right +131 │ return left / right │ ^^^^ ^^^^^ i64: Value │ │ │ i64: Value note: - ┌─ checked_arithmetic.fe:100:16 + ┌─ checked_arithmetic.fe:131:16 │ -100 │ return left / right +131 │ return left / right │ ^^^^^^^^^^^^ i64: Value note: - ┌─ checked_arithmetic.fe:102:5 + ┌─ checked_arithmetic.fe:134:5 │ -102 │ ╭ pub fn div_i32(left: i32, right: i32) -> i32: -103 │ │ return left / right - │ ╰───────────────────────────^ attributes hash: 15117649447142800500 +134 │ ╭ pub fn div_i32(left: i32, right: i32) -> i32 { +135 │ │ return left / right +136 │ │ } + │ ╰─────^ attributes hash: 15117649447142800500 │ = FunctionSignature { self_decl: None, @@ -1928,25 +1962,26 @@ note: } note: - ┌─ checked_arithmetic.fe:103:16 + ┌─ checked_arithmetic.fe:135:16 │ -103 │ return left / right +135 │ return left / right │ ^^^^ ^^^^^ i32: Value │ │ │ i32: Value note: - ┌─ checked_arithmetic.fe:103:16 + ┌─ checked_arithmetic.fe:135:16 │ -103 │ return left / right +135 │ return left / right │ ^^^^^^^^^^^^ i32: Value note: - ┌─ checked_arithmetic.fe:105:5 + ┌─ checked_arithmetic.fe:138:5 │ -105 │ ╭ pub fn div_i16(left: i16, right: i16) -> i16: -106 │ │ return left / right - │ ╰───────────────────────────^ attributes hash: 16520261699954225452 +138 │ ╭ pub fn div_i16(left: i16, right: i16) -> i16 { +139 │ │ return left / right +140 │ │ } + │ ╰─────^ attributes hash: 16520261699954225452 │ = FunctionSignature { self_decl: None, @@ -1985,25 +2020,26 @@ note: } note: - ┌─ checked_arithmetic.fe:106:16 + ┌─ checked_arithmetic.fe:139:16 │ -106 │ return left / right +139 │ return left / right │ ^^^^ ^^^^^ i16: Value │ │ │ i16: Value note: - ┌─ checked_arithmetic.fe:106:16 + ┌─ checked_arithmetic.fe:139:16 │ -106 │ return left / right +139 │ return left / right │ ^^^^^^^^^^^^ i16: Value note: - ┌─ checked_arithmetic.fe:108:5 + ┌─ checked_arithmetic.fe:142:5 │ -108 │ ╭ pub fn div_i8(left: i8, right: i8) -> i8: -109 │ │ return left / right - │ ╰───────────────────────────^ attributes hash: 2984879578165475690 +142 │ ╭ pub fn div_i8(left: i8, right: i8) -> i8 { +143 │ │ return left / right +144 │ │ } + │ ╰─────^ attributes hash: 2984879578165475690 │ = FunctionSignature { self_decl: None, @@ -2042,25 +2078,26 @@ note: } note: - ┌─ checked_arithmetic.fe:109:16 + ┌─ checked_arithmetic.fe:143:16 │ -109 │ return left / right +143 │ return left / right │ ^^^^ ^^^^^ i8: Value │ │ │ i8: Value note: - ┌─ checked_arithmetic.fe:109:16 + ┌─ checked_arithmetic.fe:143:16 │ -109 │ return left / right +143 │ return left / right │ ^^^^^^^^^^^^ i8: Value note: - ┌─ checked_arithmetic.fe:111:5 + ┌─ checked_arithmetic.fe:146:5 │ -111 │ ╭ pub fn mul_u256(left: u256, right: u256) -> u256: -112 │ │ return left * right - │ ╰───────────────────────────^ attributes hash: 8877497213208027149 +146 │ ╭ pub fn mul_u256(left: u256, right: u256) -> u256 { +147 │ │ return left * right +148 │ │ } + │ ╰─────^ attributes hash: 8877497213208027149 │ = FunctionSignature { self_decl: None, @@ -2099,25 +2136,26 @@ note: } note: - ┌─ checked_arithmetic.fe:112:16 + ┌─ checked_arithmetic.fe:147:16 │ -112 │ return left * right +147 │ return left * right │ ^^^^ ^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ checked_arithmetic.fe:112:16 + ┌─ checked_arithmetic.fe:147:16 │ -112 │ return left * right +147 │ return left * right │ ^^^^^^^^^^^^ u256: Value note: - ┌─ checked_arithmetic.fe:114:5 + ┌─ checked_arithmetic.fe:150:5 │ -114 │ ╭ pub fn mul_u128(left: u128, right: u128) -> u128: -115 │ │ return left * right - │ ╰───────────────────────────^ attributes hash: 11187416061572591496 +150 │ ╭ pub fn mul_u128(left: u128, right: u128) -> u128 { +151 │ │ return left * right +152 │ │ } + │ ╰─────^ attributes hash: 11187416061572591496 │ = FunctionSignature { self_decl: None, @@ -2156,25 +2194,26 @@ note: } note: - ┌─ checked_arithmetic.fe:115:16 + ┌─ checked_arithmetic.fe:151:16 │ -115 │ return left * right +151 │ return left * right │ ^^^^ ^^^^^ u128: Value │ │ │ u128: Value note: - ┌─ checked_arithmetic.fe:115:16 + ┌─ checked_arithmetic.fe:151:16 │ -115 │ return left * right +151 │ return left * right │ ^^^^^^^^^^^^ u128: Value note: - ┌─ checked_arithmetic.fe:117:5 + ┌─ checked_arithmetic.fe:154:5 │ -117 │ ╭ pub fn mul_u64(left: u64, right: u64) -> u64: -118 │ │ return left * right - │ ╰───────────────────────────^ attributes hash: 9316585824156398552 +154 │ ╭ pub fn mul_u64(left: u64, right: u64) -> u64 { +155 │ │ return left * right +156 │ │ } + │ ╰─────^ attributes hash: 9316585824156398552 │ = FunctionSignature { self_decl: None, @@ -2213,25 +2252,26 @@ note: } note: - ┌─ checked_arithmetic.fe:118:16 + ┌─ checked_arithmetic.fe:155:16 │ -118 │ return left * right +155 │ return left * right │ ^^^^ ^^^^^ u64: Value │ │ │ u64: Value note: - ┌─ checked_arithmetic.fe:118:16 + ┌─ checked_arithmetic.fe:155:16 │ -118 │ return left * right +155 │ return left * right │ ^^^^^^^^^^^^ u64: Value note: - ┌─ checked_arithmetic.fe:120:5 + ┌─ checked_arithmetic.fe:158:5 │ -120 │ ╭ pub fn mul_u32(left: u32, right: u32) -> u32: -121 │ │ return left * right - │ ╰───────────────────────────^ attributes hash: 6948562809403003686 +158 │ ╭ pub fn mul_u32(left: u32, right: u32) -> u32 { +159 │ │ return left * right +160 │ │ } + │ ╰─────^ attributes hash: 6948562809403003686 │ = FunctionSignature { self_decl: None, @@ -2270,25 +2310,26 @@ note: } note: - ┌─ checked_arithmetic.fe:121:16 + ┌─ checked_arithmetic.fe:159:16 │ -121 │ return left * right +159 │ return left * right │ ^^^^ ^^^^^ u32: Value │ │ │ u32: Value note: - ┌─ checked_arithmetic.fe:121:16 + ┌─ checked_arithmetic.fe:159:16 │ -121 │ return left * right +159 │ return left * right │ ^^^^^^^^^^^^ u32: Value note: - ┌─ checked_arithmetic.fe:123:5 + ┌─ checked_arithmetic.fe:162:5 │ -123 │ ╭ pub fn mul_u16(left: u16, right: u16) -> u16: -124 │ │ return left * right - │ ╰───────────────────────────^ attributes hash: 4214429573900255413 +162 │ ╭ pub fn mul_u16(left: u16, right: u16) -> u16 { +163 │ │ return left * right +164 │ │ } + │ ╰─────^ attributes hash: 4214429573900255413 │ = FunctionSignature { self_decl: None, @@ -2327,25 +2368,26 @@ note: } note: - ┌─ checked_arithmetic.fe:124:16 + ┌─ checked_arithmetic.fe:163:16 │ -124 │ return left * right +163 │ return left * right │ ^^^^ ^^^^^ u16: Value │ │ │ u16: Value note: - ┌─ checked_arithmetic.fe:124:16 + ┌─ checked_arithmetic.fe:163:16 │ -124 │ return left * right +163 │ return left * right │ ^^^^^^^^^^^^ u16: Value note: - ┌─ checked_arithmetic.fe:126:5 + ┌─ checked_arithmetic.fe:166:5 │ -126 │ ╭ pub fn mul_u8(left: u8, right: u8) -> u8: -127 │ │ return left * right - │ ╰───────────────────────────^ attributes hash: 3749617961046563034 +166 │ ╭ pub fn mul_u8(left: u8, right: u8) -> u8 { +167 │ │ return left * right +168 │ │ } + │ ╰─────^ attributes hash: 3749617961046563034 │ = FunctionSignature { self_decl: None, @@ -2384,25 +2426,26 @@ note: } note: - ┌─ checked_arithmetic.fe:127:16 + ┌─ checked_arithmetic.fe:167:16 │ -127 │ return left * right +167 │ return left * right │ ^^^^ ^^^^^ u8: Value │ │ │ u8: Value note: - ┌─ checked_arithmetic.fe:127:16 + ┌─ checked_arithmetic.fe:167:16 │ -127 │ return left * right +167 │ return left * right │ ^^^^^^^^^^^^ u8: Value note: - ┌─ checked_arithmetic.fe:129:5 + ┌─ checked_arithmetic.fe:170:5 │ -129 │ ╭ pub fn mul_i256(left: i256, right: i256) -> i256: -130 │ │ return left * right - │ ╰───────────────────────────^ attributes hash: 17908204859155721295 +170 │ ╭ pub fn mul_i256(left: i256, right: i256) -> i256 { +171 │ │ return left * right +172 │ │ } + │ ╰─────^ attributes hash: 17908204859155721295 │ = FunctionSignature { self_decl: None, @@ -2441,25 +2484,26 @@ note: } note: - ┌─ checked_arithmetic.fe:130:16 + ┌─ checked_arithmetic.fe:171:16 │ -130 │ return left * right +171 │ return left * right │ ^^^^ ^^^^^ i256: Value │ │ │ i256: Value note: - ┌─ checked_arithmetic.fe:130:16 + ┌─ checked_arithmetic.fe:171:16 │ -130 │ return left * right +171 │ return left * right │ ^^^^^^^^^^^^ i256: Value note: - ┌─ checked_arithmetic.fe:132:5 + ┌─ checked_arithmetic.fe:174:5 │ -132 │ ╭ pub fn mul_i128(left: i128, right: i128) -> i128: -133 │ │ return left * right - │ ╰───────────────────────────^ attributes hash: 1332431709112937827 +174 │ ╭ pub fn mul_i128(left: i128, right: i128) -> i128 { +175 │ │ return left * right +176 │ │ } + │ ╰─────^ attributes hash: 1332431709112937827 │ = FunctionSignature { self_decl: None, @@ -2498,25 +2542,26 @@ note: } note: - ┌─ checked_arithmetic.fe:133:16 + ┌─ checked_arithmetic.fe:175:16 │ -133 │ return left * right +175 │ return left * right │ ^^^^ ^^^^^ i128: Value │ │ │ i128: Value note: - ┌─ checked_arithmetic.fe:133:16 + ┌─ checked_arithmetic.fe:175:16 │ -133 │ return left * right +175 │ return left * right │ ^^^^^^^^^^^^ i128: Value note: - ┌─ checked_arithmetic.fe:135:5 + ┌─ checked_arithmetic.fe:178:5 │ -135 │ ╭ pub fn mul_i64(left: i64, right: i64) -> i64: -136 │ │ return left * right - │ ╰───────────────────────────^ attributes hash: 3549113083347694903 +178 │ ╭ pub fn mul_i64(left: i64, right: i64) -> i64 { +179 │ │ return left * right +180 │ │ } + │ ╰─────^ attributes hash: 3549113083347694903 │ = FunctionSignature { self_decl: None, @@ -2555,25 +2600,26 @@ note: } note: - ┌─ checked_arithmetic.fe:136:16 + ┌─ checked_arithmetic.fe:179:16 │ -136 │ return left * right +179 │ return left * right │ ^^^^ ^^^^^ i64: Value │ │ │ i64: Value note: - ┌─ checked_arithmetic.fe:136:16 + ┌─ checked_arithmetic.fe:179:16 │ -136 │ return left * right +179 │ return left * right │ ^^^^^^^^^^^^ i64: Value note: - ┌─ checked_arithmetic.fe:138:5 + ┌─ checked_arithmetic.fe:182:5 │ -138 │ ╭ pub fn mul_i32(left: i32, right: i32) -> i32: -139 │ │ return left * right - │ ╰───────────────────────────^ attributes hash: 15117649447142800500 +182 │ ╭ pub fn mul_i32(left: i32, right: i32) -> i32 { +183 │ │ return left * right +184 │ │ } + │ ╰─────^ attributes hash: 15117649447142800500 │ = FunctionSignature { self_decl: None, @@ -2612,25 +2658,26 @@ note: } note: - ┌─ checked_arithmetic.fe:139:16 + ┌─ checked_arithmetic.fe:183:16 │ -139 │ return left * right +183 │ return left * right │ ^^^^ ^^^^^ i32: Value │ │ │ i32: Value note: - ┌─ checked_arithmetic.fe:139:16 + ┌─ checked_arithmetic.fe:183:16 │ -139 │ return left * right +183 │ return left * right │ ^^^^^^^^^^^^ i32: Value note: - ┌─ checked_arithmetic.fe:141:5 + ┌─ checked_arithmetic.fe:186:5 │ -141 │ ╭ pub fn mul_i16(left: i16, right: i16) -> i16: -142 │ │ return left * right - │ ╰───────────────────────────^ attributes hash: 16520261699954225452 +186 │ ╭ pub fn mul_i16(left: i16, right: i16) -> i16 { +187 │ │ return left * right +188 │ │ } + │ ╰─────^ attributes hash: 16520261699954225452 │ = FunctionSignature { self_decl: None, @@ -2669,25 +2716,26 @@ note: } note: - ┌─ checked_arithmetic.fe:142:16 + ┌─ checked_arithmetic.fe:187:16 │ -142 │ return left * right +187 │ return left * right │ ^^^^ ^^^^^ i16: Value │ │ │ i16: Value note: - ┌─ checked_arithmetic.fe:142:16 + ┌─ checked_arithmetic.fe:187:16 │ -142 │ return left * right +187 │ return left * right │ ^^^^^^^^^^^^ i16: Value note: - ┌─ checked_arithmetic.fe:144:5 + ┌─ checked_arithmetic.fe:190:5 │ -144 │ ╭ pub fn mul_i8(left: i8, right: i8) -> i8: -145 │ │ return left * right - │ ╰───────────────────────────^ attributes hash: 2984879578165475690 +190 │ ╭ pub fn mul_i8(left: i8, right: i8) -> i8 { +191 │ │ return left * right +192 │ │ } + │ ╰─────^ attributes hash: 2984879578165475690 │ = FunctionSignature { self_decl: None, @@ -2726,25 +2774,26 @@ note: } note: - ┌─ checked_arithmetic.fe:145:16 + ┌─ checked_arithmetic.fe:191:16 │ -145 │ return left * right +191 │ return left * right │ ^^^^ ^^^^^ i8: Value │ │ │ i8: Value note: - ┌─ checked_arithmetic.fe:145:16 + ┌─ checked_arithmetic.fe:191:16 │ -145 │ return left * right +191 │ return left * right │ ^^^^^^^^^^^^ i8: Value note: - ┌─ checked_arithmetic.fe:147:5 + ┌─ checked_arithmetic.fe:194:5 │ -147 │ ╭ pub fn mod_u256(left: u256, right: u256) -> u256: -148 │ │ return left % right - │ ╰───────────────────────────^ attributes hash: 8877497213208027149 +194 │ ╭ pub fn mod_u256(left: u256, right: u256) -> u256 { +195 │ │ return left % right +196 │ │ } + │ ╰─────^ attributes hash: 8877497213208027149 │ = FunctionSignature { self_decl: None, @@ -2783,25 +2832,26 @@ note: } note: - ┌─ checked_arithmetic.fe:148:16 + ┌─ checked_arithmetic.fe:195:16 │ -148 │ return left % right +195 │ return left % right │ ^^^^ ^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ checked_arithmetic.fe:148:16 + ┌─ checked_arithmetic.fe:195:16 │ -148 │ return left % right +195 │ return left % right │ ^^^^^^^^^^^^ u256: Value note: - ┌─ checked_arithmetic.fe:150:5 + ┌─ checked_arithmetic.fe:198:5 │ -150 │ ╭ pub fn mod_u128(left: u128, right: u128) -> u128: -151 │ │ return left % right - │ ╰───────────────────────────^ attributes hash: 11187416061572591496 +198 │ ╭ pub fn mod_u128(left: u128, right: u128) -> u128 { +199 │ │ return left % right +200 │ │ } + │ ╰─────^ attributes hash: 11187416061572591496 │ = FunctionSignature { self_decl: None, @@ -2840,25 +2890,26 @@ note: } note: - ┌─ checked_arithmetic.fe:151:16 + ┌─ checked_arithmetic.fe:199:16 │ -151 │ return left % right +199 │ return left % right │ ^^^^ ^^^^^ u128: Value │ │ │ u128: Value note: - ┌─ checked_arithmetic.fe:151:16 + ┌─ checked_arithmetic.fe:199:16 │ -151 │ return left % right +199 │ return left % right │ ^^^^^^^^^^^^ u128: Value note: - ┌─ checked_arithmetic.fe:153:5 + ┌─ checked_arithmetic.fe:202:5 │ -153 │ ╭ pub fn mod_u64(left: u64, right: u64) -> u64: -154 │ │ return left % right - │ ╰───────────────────────────^ attributes hash: 9316585824156398552 +202 │ ╭ pub fn mod_u64(left: u64, right: u64) -> u64 { +203 │ │ return left % right +204 │ │ } + │ ╰─────^ attributes hash: 9316585824156398552 │ = FunctionSignature { self_decl: None, @@ -2897,25 +2948,26 @@ note: } note: - ┌─ checked_arithmetic.fe:154:16 + ┌─ checked_arithmetic.fe:203:16 │ -154 │ return left % right +203 │ return left % right │ ^^^^ ^^^^^ u64: Value │ │ │ u64: Value note: - ┌─ checked_arithmetic.fe:154:16 + ┌─ checked_arithmetic.fe:203:16 │ -154 │ return left % right +203 │ return left % right │ ^^^^^^^^^^^^ u64: Value note: - ┌─ checked_arithmetic.fe:156:5 + ┌─ checked_arithmetic.fe:206:5 │ -156 │ ╭ pub fn mod_u32(left: u32, right: u32) -> u32: -157 │ │ return left % right - │ ╰───────────────────────────^ attributes hash: 6948562809403003686 +206 │ ╭ pub fn mod_u32(left: u32, right: u32) -> u32 { +207 │ │ return left % right +208 │ │ } + │ ╰─────^ attributes hash: 6948562809403003686 │ = FunctionSignature { self_decl: None, @@ -2954,25 +3006,26 @@ note: } note: - ┌─ checked_arithmetic.fe:157:16 + ┌─ checked_arithmetic.fe:207:16 │ -157 │ return left % right +207 │ return left % right │ ^^^^ ^^^^^ u32: Value │ │ │ u32: Value note: - ┌─ checked_arithmetic.fe:157:16 + ┌─ checked_arithmetic.fe:207:16 │ -157 │ return left % right +207 │ return left % right │ ^^^^^^^^^^^^ u32: Value note: - ┌─ checked_arithmetic.fe:159:5 + ┌─ checked_arithmetic.fe:210:5 │ -159 │ ╭ pub fn mod_u16(left: u16, right: u16) -> u16: -160 │ │ return left % right - │ ╰───────────────────────────^ attributes hash: 4214429573900255413 +210 │ ╭ pub fn mod_u16(left: u16, right: u16) -> u16 { +211 │ │ return left % right +212 │ │ } + │ ╰─────^ attributes hash: 4214429573900255413 │ = FunctionSignature { self_decl: None, @@ -3011,25 +3064,26 @@ note: } note: - ┌─ checked_arithmetic.fe:160:16 + ┌─ checked_arithmetic.fe:211:16 │ -160 │ return left % right +211 │ return left % right │ ^^^^ ^^^^^ u16: Value │ │ │ u16: Value note: - ┌─ checked_arithmetic.fe:160:16 + ┌─ checked_arithmetic.fe:211:16 │ -160 │ return left % right +211 │ return left % right │ ^^^^^^^^^^^^ u16: Value note: - ┌─ checked_arithmetic.fe:162:5 + ┌─ checked_arithmetic.fe:214:5 │ -162 │ ╭ pub fn mod_u8(left: u8, right: u8) -> u8: -163 │ │ return left % right - │ ╰───────────────────────────^ attributes hash: 3749617961046563034 +214 │ ╭ pub fn mod_u8(left: u8, right: u8) -> u8 { +215 │ │ return left % right +216 │ │ } + │ ╰─────^ attributes hash: 3749617961046563034 │ = FunctionSignature { self_decl: None, @@ -3068,25 +3122,26 @@ note: } note: - ┌─ checked_arithmetic.fe:163:16 + ┌─ checked_arithmetic.fe:215:16 │ -163 │ return left % right +215 │ return left % right │ ^^^^ ^^^^^ u8: Value │ │ │ u8: Value note: - ┌─ checked_arithmetic.fe:163:16 + ┌─ checked_arithmetic.fe:215:16 │ -163 │ return left % right +215 │ return left % right │ ^^^^^^^^^^^^ u8: Value note: - ┌─ checked_arithmetic.fe:165:5 + ┌─ checked_arithmetic.fe:218:5 │ -165 │ ╭ pub fn mod_i256(left: i256, right: i256) -> i256: -166 │ │ return left % right - │ ╰───────────────────────────^ attributes hash: 17908204859155721295 +218 │ ╭ pub fn mod_i256(left: i256, right: i256) -> i256 { +219 │ │ return left % right +220 │ │ } + │ ╰─────^ attributes hash: 17908204859155721295 │ = FunctionSignature { self_decl: None, @@ -3125,25 +3180,26 @@ note: } note: - ┌─ checked_arithmetic.fe:166:16 + ┌─ checked_arithmetic.fe:219:16 │ -166 │ return left % right +219 │ return left % right │ ^^^^ ^^^^^ i256: Value │ │ │ i256: Value note: - ┌─ checked_arithmetic.fe:166:16 + ┌─ checked_arithmetic.fe:219:16 │ -166 │ return left % right +219 │ return left % right │ ^^^^^^^^^^^^ i256: Value note: - ┌─ checked_arithmetic.fe:168:5 + ┌─ checked_arithmetic.fe:222:5 │ -168 │ ╭ pub fn mod_i128(left: i128, right: i128) -> i128: -169 │ │ return left % right - │ ╰───────────────────────────^ attributes hash: 1332431709112937827 +222 │ ╭ pub fn mod_i128(left: i128, right: i128) -> i128 { +223 │ │ return left % right +224 │ │ } + │ ╰─────^ attributes hash: 1332431709112937827 │ = FunctionSignature { self_decl: None, @@ -3182,25 +3238,26 @@ note: } note: - ┌─ checked_arithmetic.fe:169:16 + ┌─ checked_arithmetic.fe:223:16 │ -169 │ return left % right +223 │ return left % right │ ^^^^ ^^^^^ i128: Value │ │ │ i128: Value note: - ┌─ checked_arithmetic.fe:169:16 + ┌─ checked_arithmetic.fe:223:16 │ -169 │ return left % right +223 │ return left % right │ ^^^^^^^^^^^^ i128: Value note: - ┌─ checked_arithmetic.fe:171:5 + ┌─ checked_arithmetic.fe:226:5 │ -171 │ ╭ pub fn mod_i64(left: i64, right: i64) -> i64: -172 │ │ return left % right - │ ╰───────────────────────────^ attributes hash: 3549113083347694903 +226 │ ╭ pub fn mod_i64(left: i64, right: i64) -> i64 { +227 │ │ return left % right +228 │ │ } + │ ╰─────^ attributes hash: 3549113083347694903 │ = FunctionSignature { self_decl: None, @@ -3239,25 +3296,26 @@ note: } note: - ┌─ checked_arithmetic.fe:172:16 + ┌─ checked_arithmetic.fe:227:16 │ -172 │ return left % right +227 │ return left % right │ ^^^^ ^^^^^ i64: Value │ │ │ i64: Value note: - ┌─ checked_arithmetic.fe:172:16 + ┌─ checked_arithmetic.fe:227:16 │ -172 │ return left % right +227 │ return left % right │ ^^^^^^^^^^^^ i64: Value note: - ┌─ checked_arithmetic.fe:174:5 + ┌─ checked_arithmetic.fe:230:5 │ -174 │ ╭ pub fn mod_i32(left: i32, right: i32) -> i32: -175 │ │ return left % right - │ ╰───────────────────────────^ attributes hash: 15117649447142800500 +230 │ ╭ pub fn mod_i32(left: i32, right: i32) -> i32 { +231 │ │ return left % right +232 │ │ } + │ ╰─────^ attributes hash: 15117649447142800500 │ = FunctionSignature { self_decl: None, @@ -3296,25 +3354,26 @@ note: } note: - ┌─ checked_arithmetic.fe:175:16 + ┌─ checked_arithmetic.fe:231:16 │ -175 │ return left % right +231 │ return left % right │ ^^^^ ^^^^^ i32: Value │ │ │ i32: Value note: - ┌─ checked_arithmetic.fe:175:16 + ┌─ checked_arithmetic.fe:231:16 │ -175 │ return left % right +231 │ return left % right │ ^^^^^^^^^^^^ i32: Value note: - ┌─ checked_arithmetic.fe:177:5 + ┌─ checked_arithmetic.fe:234:5 │ -177 │ ╭ pub fn mod_i16(left: i16, right: i16) -> i16: -178 │ │ return left % right - │ ╰───────────────────────────^ attributes hash: 16520261699954225452 +234 │ ╭ pub fn mod_i16(left: i16, right: i16) -> i16 { +235 │ │ return left % right +236 │ │ } + │ ╰─────^ attributes hash: 16520261699954225452 │ = FunctionSignature { self_decl: None, @@ -3353,25 +3412,26 @@ note: } note: - ┌─ checked_arithmetic.fe:178:16 + ┌─ checked_arithmetic.fe:235:16 │ -178 │ return left % right +235 │ return left % right │ ^^^^ ^^^^^ i16: Value │ │ │ i16: Value note: - ┌─ checked_arithmetic.fe:178:16 + ┌─ checked_arithmetic.fe:235:16 │ -178 │ return left % right +235 │ return left % right │ ^^^^^^^^^^^^ i16: Value note: - ┌─ checked_arithmetic.fe:180:5 + ┌─ checked_arithmetic.fe:238:5 │ -180 │ ╭ pub fn mod_i8(left: i8, right: i8) -> i8: -181 │ │ return left % right - │ ╰───────────────────────────^ attributes hash: 2984879578165475690 +238 │ ╭ pub fn mod_i8(left: i8, right: i8) -> i8 { +239 │ │ return left % right +240 │ │ } + │ ╰─────^ attributes hash: 2984879578165475690 │ = FunctionSignature { self_decl: None, @@ -3410,25 +3470,26 @@ note: } note: - ┌─ checked_arithmetic.fe:181:16 + ┌─ checked_arithmetic.fe:239:16 │ -181 │ return left % right +239 │ return left % right │ ^^^^ ^^^^^ i8: Value │ │ │ i8: Value note: - ┌─ checked_arithmetic.fe:181:16 + ┌─ checked_arithmetic.fe:239:16 │ -181 │ return left % right +239 │ return left % right │ ^^^^^^^^^^^^ i8: Value note: - ┌─ checked_arithmetic.fe:183:5 + ┌─ checked_arithmetic.fe:242:5 │ -183 │ ╭ pub fn pow_u256(left: u256, right: u256) -> u256: -184 │ │ return left ** right - │ ╰────────────────────────────^ attributes hash: 8877497213208027149 +242 │ ╭ pub fn pow_u256(left: u256, right: u256) -> u256 { +243 │ │ return left ** right +244 │ │ } + │ ╰─────^ attributes hash: 8877497213208027149 │ = FunctionSignature { self_decl: None, @@ -3467,25 +3528,26 @@ note: } note: - ┌─ checked_arithmetic.fe:184:16 + ┌─ checked_arithmetic.fe:243:16 │ -184 │ return left ** right +243 │ return left ** right │ ^^^^ ^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ checked_arithmetic.fe:184:16 + ┌─ checked_arithmetic.fe:243:16 │ -184 │ return left ** right +243 │ return left ** right │ ^^^^^^^^^^^^^ u256: Value note: - ┌─ checked_arithmetic.fe:186:5 + ┌─ checked_arithmetic.fe:246:5 │ -186 │ ╭ pub fn pow_u128(left: u128, right: u128) -> u128: -187 │ │ return left ** right - │ ╰────────────────────────────^ attributes hash: 11187416061572591496 +246 │ ╭ pub fn pow_u128(left: u128, right: u128) -> u128 { +247 │ │ return left ** right +248 │ │ } + │ ╰─────^ attributes hash: 11187416061572591496 │ = FunctionSignature { self_decl: None, @@ -3524,25 +3586,26 @@ note: } note: - ┌─ checked_arithmetic.fe:187:16 + ┌─ checked_arithmetic.fe:247:16 │ -187 │ return left ** right +247 │ return left ** right │ ^^^^ ^^^^^ u128: Value │ │ │ u128: Value note: - ┌─ checked_arithmetic.fe:187:16 + ┌─ checked_arithmetic.fe:247:16 │ -187 │ return left ** right +247 │ return left ** right │ ^^^^^^^^^^^^^ u128: Value note: - ┌─ checked_arithmetic.fe:189:5 + ┌─ checked_arithmetic.fe:250:5 │ -189 │ ╭ pub fn pow_u64(left: u64, right: u64) -> u64: -190 │ │ return left ** right - │ ╰────────────────────────────^ attributes hash: 9316585824156398552 +250 │ ╭ pub fn pow_u64(left: u64, right: u64) -> u64 { +251 │ │ return left ** right +252 │ │ } + │ ╰─────^ attributes hash: 9316585824156398552 │ = FunctionSignature { self_decl: None, @@ -3581,25 +3644,26 @@ note: } note: - ┌─ checked_arithmetic.fe:190:16 + ┌─ checked_arithmetic.fe:251:16 │ -190 │ return left ** right +251 │ return left ** right │ ^^^^ ^^^^^ u64: Value │ │ │ u64: Value note: - ┌─ checked_arithmetic.fe:190:16 + ┌─ checked_arithmetic.fe:251:16 │ -190 │ return left ** right +251 │ return left ** right │ ^^^^^^^^^^^^^ u64: Value note: - ┌─ checked_arithmetic.fe:192:5 + ┌─ checked_arithmetic.fe:254:5 │ -192 │ ╭ pub fn pow_u32(left: u32, right: u32) -> u32: -193 │ │ return left ** right - │ ╰────────────────────────────^ attributes hash: 6948562809403003686 +254 │ ╭ pub fn pow_u32(left: u32, right: u32) -> u32 { +255 │ │ return left ** right +256 │ │ } + │ ╰─────^ attributes hash: 6948562809403003686 │ = FunctionSignature { self_decl: None, @@ -3638,25 +3702,26 @@ note: } note: - ┌─ checked_arithmetic.fe:193:16 + ┌─ checked_arithmetic.fe:255:16 │ -193 │ return left ** right +255 │ return left ** right │ ^^^^ ^^^^^ u32: Value │ │ │ u32: Value note: - ┌─ checked_arithmetic.fe:193:16 + ┌─ checked_arithmetic.fe:255:16 │ -193 │ return left ** right +255 │ return left ** right │ ^^^^^^^^^^^^^ u32: Value note: - ┌─ checked_arithmetic.fe:195:5 + ┌─ checked_arithmetic.fe:258:5 │ -195 │ ╭ pub fn pow_u16(left: u16, right: u16) -> u16: -196 │ │ return left ** right - │ ╰────────────────────────────^ attributes hash: 4214429573900255413 +258 │ ╭ pub fn pow_u16(left: u16, right: u16) -> u16 { +259 │ │ return left ** right +260 │ │ } + │ ╰─────^ attributes hash: 4214429573900255413 │ = FunctionSignature { self_decl: None, @@ -3695,25 +3760,26 @@ note: } note: - ┌─ checked_arithmetic.fe:196:16 + ┌─ checked_arithmetic.fe:259:16 │ -196 │ return left ** right +259 │ return left ** right │ ^^^^ ^^^^^ u16: Value │ │ │ u16: Value note: - ┌─ checked_arithmetic.fe:196:16 + ┌─ checked_arithmetic.fe:259:16 │ -196 │ return left ** right +259 │ return left ** right │ ^^^^^^^^^^^^^ u16: Value note: - ┌─ checked_arithmetic.fe:198:5 + ┌─ checked_arithmetic.fe:262:5 │ -198 │ ╭ pub fn pow_u8(left: u8, right: u8) -> u8: -199 │ │ return left ** right - │ ╰────────────────────────────^ attributes hash: 3749617961046563034 +262 │ ╭ pub fn pow_u8(left: u8, right: u8) -> u8 { +263 │ │ return left ** right +264 │ │ } + │ ╰─────^ attributes hash: 3749617961046563034 │ = FunctionSignature { self_decl: None, @@ -3752,25 +3818,26 @@ note: } note: - ┌─ checked_arithmetic.fe:199:16 + ┌─ checked_arithmetic.fe:263:16 │ -199 │ return left ** right +263 │ return left ** right │ ^^^^ ^^^^^ u8: Value │ │ │ u8: Value note: - ┌─ checked_arithmetic.fe:199:16 + ┌─ checked_arithmetic.fe:263:16 │ -199 │ return left ** right +263 │ return left ** right │ ^^^^^^^^^^^^^ u8: Value note: - ┌─ checked_arithmetic.fe:201:5 + ┌─ checked_arithmetic.fe:266:5 │ -201 │ ╭ pub fn pow_i256(left: i256, right: u256) -> i256: -202 │ │ return left ** right - │ ╰────────────────────────────^ attributes hash: 10218838230504849711 +266 │ ╭ pub fn pow_i256(left: i256, right: u256) -> i256 { +267 │ │ return left ** right +268 │ │ } + │ ╰─────^ attributes hash: 10218838230504849711 │ = FunctionSignature { self_decl: None, @@ -3809,25 +3876,26 @@ note: } note: - ┌─ checked_arithmetic.fe:202:16 + ┌─ checked_arithmetic.fe:267:16 │ -202 │ return left ** right +267 │ return left ** right │ ^^^^ ^^^^^ u256: Value │ │ │ i256: Value note: - ┌─ checked_arithmetic.fe:202:16 + ┌─ checked_arithmetic.fe:267:16 │ -202 │ return left ** right +267 │ return left ** right │ ^^^^^^^^^^^^^ i256: Value note: - ┌─ checked_arithmetic.fe:204:5 + ┌─ checked_arithmetic.fe:270:5 │ -204 │ ╭ pub fn pow_i128(left: i128, right: u128) -> i128: -205 │ │ return left ** right - │ ╰────────────────────────────^ attributes hash: 8492300797170107874 +270 │ ╭ pub fn pow_i128(left: i128, right: u128) -> i128 { +271 │ │ return left ** right +272 │ │ } + │ ╰─────^ attributes hash: 8492300797170107874 │ = FunctionSignature { self_decl: None, @@ -3866,25 +3934,26 @@ note: } note: - ┌─ checked_arithmetic.fe:205:16 + ┌─ checked_arithmetic.fe:271:16 │ -205 │ return left ** right +271 │ return left ** right │ ^^^^ ^^^^^ u128: Value │ │ │ i128: Value note: - ┌─ checked_arithmetic.fe:205:16 + ┌─ checked_arithmetic.fe:271:16 │ -205 │ return left ** right +271 │ return left ** right │ ^^^^^^^^^^^^^ i128: Value note: - ┌─ checked_arithmetic.fe:207:5 + ┌─ checked_arithmetic.fe:274:5 │ -207 │ ╭ pub fn pow_i64(left: i64, right: u64) -> i64: -208 │ │ return left ** right - │ ╰────────────────────────────^ attributes hash: 8175269888119534907 +274 │ ╭ pub fn pow_i64(left: i64, right: u64) -> i64 { +275 │ │ return left ** right +276 │ │ } + │ ╰─────^ attributes hash: 8175269888119534907 │ = FunctionSignature { self_decl: None, @@ -3923,25 +3992,26 @@ note: } note: - ┌─ checked_arithmetic.fe:208:16 + ┌─ checked_arithmetic.fe:275:16 │ -208 │ return left ** right +275 │ return left ** right │ ^^^^ ^^^^^ u64: Value │ │ │ i64: Value note: - ┌─ checked_arithmetic.fe:208:16 + ┌─ checked_arithmetic.fe:275:16 │ -208 │ return left ** right +275 │ return left ** right │ ^^^^^^^^^^^^^ i64: Value note: - ┌─ checked_arithmetic.fe:210:5 + ┌─ checked_arithmetic.fe:278:5 │ -210 │ ╭ pub fn pow_i32(left: i32, right: u32) -> i32: -211 │ │ return left ** right - │ ╰────────────────────────────^ attributes hash: 9388330002377862662 +278 │ ╭ pub fn pow_i32(left: i32, right: u32) -> i32 { +279 │ │ return left ** right +280 │ │ } + │ ╰─────^ attributes hash: 9388330002377862662 │ = FunctionSignature { self_decl: None, @@ -3980,25 +4050,26 @@ note: } note: - ┌─ checked_arithmetic.fe:211:16 + ┌─ checked_arithmetic.fe:279:16 │ -211 │ return left ** right +279 │ return left ** right │ ^^^^ ^^^^^ u32: Value │ │ │ i32: Value note: - ┌─ checked_arithmetic.fe:211:16 + ┌─ checked_arithmetic.fe:279:16 │ -211 │ return left ** right +279 │ return left ** right │ ^^^^^^^^^^^^^ i32: Value note: - ┌─ checked_arithmetic.fe:213:5 + ┌─ checked_arithmetic.fe:282:5 │ -213 │ ╭ pub fn pow_i16(left: i16, right: u16) -> i16: -214 │ │ return left ** right - │ ╰────────────────────────────^ attributes hash: 8172583117888506116 +282 │ ╭ pub fn pow_i16(left: i16, right: u16) -> i16 { +283 │ │ return left ** right +284 │ │ } + │ ╰─────^ attributes hash: 8172583117888506116 │ = FunctionSignature { self_decl: None, @@ -4037,25 +4108,26 @@ note: } note: - ┌─ checked_arithmetic.fe:214:16 + ┌─ checked_arithmetic.fe:283:16 │ -214 │ return left ** right +283 │ return left ** right │ ^^^^ ^^^^^ u16: Value │ │ │ i16: Value note: - ┌─ checked_arithmetic.fe:214:16 + ┌─ checked_arithmetic.fe:283:16 │ -214 │ return left ** right +283 │ return left ** right │ ^^^^^^^^^^^^^ i16: Value note: - ┌─ checked_arithmetic.fe:216:5 + ┌─ checked_arithmetic.fe:286:5 │ -216 │ ╭ pub fn pow_i8(left: i8, right: u8) -> i8: -217 │ │ return left ** right - │ ╰────────────────────────────^ attributes hash: 783967907920544100 +286 │ ╭ pub fn pow_i8(left: i8, right: u8) -> i8 { +287 │ │ return left ** right +288 │ │ } + │ ╰─────^ attributes hash: 783967907920544100 │ = FunctionSignature { self_decl: None, @@ -4094,17 +4166,17 @@ note: } note: - ┌─ checked_arithmetic.fe:217:16 + ┌─ checked_arithmetic.fe:287:16 │ -217 │ return left ** right +287 │ return left ** right │ ^^^^ ^^^^^ u8: Value │ │ │ i8: Value note: - ┌─ checked_arithmetic.fe:217:16 + ┌─ checked_arithmetic.fe:287:16 │ -217 │ return left ** right +287 │ return left ** right │ ^^^^^^^^^^^^^ i8: Value diff --git a/crates/analyzer/tests/snapshots/analysis__const_generics.snap b/crates/analyzer/tests/snapshots/analysis__const_generics.snap index 475d450cb2..6ba16ef208 100644 --- a/crates/analyzer/tests/snapshots/analysis__const_generics.snap +++ b/crates/analyzer/tests/snapshots/analysis__const_generics.snap @@ -6,14 +6,14 @@ expression: "build_snapshot(&db, module)" note: ┌─ const_generics.fe:2:5 │ - 2 │ ╭ pub fn bar(): + 2 │ ╭ pub fn bar() { 3 │ │ # const generics with literal. 4 │ │ let array_lit: Array 5 │ │ let array_lit2: Array · │ -45 │ │ 46 │ │ let array_with_const: Array - │ ╰───────────────────────────────────────────────────────────────────────^ attributes hash: 8319796915330632390 +47 │ │ } + │ ╰─────^ attributes hash: 8319796915330632390 │ = FunctionSignature { self_decl: None, @@ -37,9 +37,9 @@ note: 8 │ let array_ternary: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array · -11 │ let array_logical_or: Array +11 │ let array_logical_or: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array -12 │ let array_logical_and: Array +12 │ let array_logical_and: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array · 15 │ let array_add: Array @@ -120,7 +120,7 @@ note: 8 │ let array_ternary: Array │ ^^^^^^^^^^^^^^^^^ u256: Value · -11 │ let array_logical_or: Array +11 │ let array_logical_or: Array │ ^^^^ ^^^^^ bool: Value │ │ │ bool: Value @@ -128,7 +128,7 @@ note: note: ┌─ const_generics.fe:11:44 │ -11 │ let array_logical_or: Array +11 │ let array_logical_or: Array │ ^ ^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ │ │ bool: Value @@ -137,9 +137,9 @@ note: note: ┌─ const_generics.fe:11:44 │ -11 │ let array_logical_or: Array +11 │ let array_logical_or: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -12 │ let array_logical_and: Array +12 │ let array_logical_and: Array │ ^^^^ ^^^^^ bool: Value │ │ │ bool: Value @@ -147,7 +147,7 @@ note: note: ┌─ const_generics.fe:12:45 │ -12 │ let array_logical_and: Array +12 │ let array_logical_and: Array │ ^ ^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ │ │ bool: Value @@ -156,7 +156,7 @@ note: note: ┌─ const_generics.fe:12:45 │ -12 │ let array_logical_and: Array +12 │ let array_logical_and: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value · 15 │ let array_add: Array diff --git a/crates/analyzer/tests/snapshots/analysis__const_local.snap b/crates/analyzer/tests/snapshots/analysis__const_local.snap index d267226625..dd7bce88e7 100644 --- a/crates/analyzer/tests/snapshots/analysis__const_local.snap +++ b/crates/analyzer/tests/snapshots/analysis__const_local.snap @@ -6,14 +6,14 @@ expression: "build_snapshot(&db, module)" note: ┌─ const_local.fe:2:5 │ - 2 │ ╭ pub fn bar() -> u256: + 2 │ ╭ pub fn bar() -> u256 { 3 │ │ const C1: i64 = 1 4 │ │ const C2: i64 = 2 5 │ │ const C3: i64 = 10 · │ -14 │ │ let _arr: Array 15 │ │ return C10 - │ ╰──────────────────^ attributes hash: 6115314201970082834 +16 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__constructor.snap b/crates/analyzer/tests/snapshots/analysis__constructor.snap index 358905bf39..e43d7fc5fb 100644 --- a/crates/analyzer/tests/snapshots/analysis__constructor.snap +++ b/crates/analyzer/tests/snapshots/analysis__constructor.snap @@ -10,45 +10,46 @@ note: │ ^^^^^^^^^^^^^^^^^^^^ Map note: - ┌─ constructor.fe:7:5 - │ -7 │ ╭ pub fn read_bar(self) -> u256: -8 │ │ return self.bar[42] - │ ╰───────────────────────────^ attributes hash: 11773348765973600208 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: None, - params: [], - return_type: Ok( - Base( - Numeric( - U256, - ), - ), - ), - } + ┌─ constructor.fe:8:5 + │ + 8 │ ╭ pub fn read_bar(self) -> u256 { + 9 │ │ return self.bar[42] +10 │ │ } + │ ╰─────^ attributes hash: 11773348765973600208 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: None, + params: [], + return_type: Ok( + Base( + Numeric( + U256, + ), + ), + ), + } note: - ┌─ constructor.fe:8:16 + ┌─ constructor.fe:9:16 │ -8 │ return self.bar[42] +9 │ return self.bar[42] │ ^^^^ Foo: Value note: - ┌─ constructor.fe:8:16 + ┌─ constructor.fe:9:16 │ -8 │ return self.bar[42] +9 │ return self.bar[42] │ ^^^^^^^^ ^^ u256: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ constructor.fe:8:16 + ┌─ constructor.fe:9:16 │ -8 │ return self.bar[42] +9 │ return self.bar[42] │ ^^^^^^^^^^^^ u256: Storage { nonce: None } => Value diff --git a/crates/analyzer/tests/snapshots/analysis__create2_contract.snap b/crates/analyzer/tests/snapshots/analysis__create2_contract.snap index 16c82d9569..3ffbafc8d3 100644 --- a/crates/analyzer/tests/snapshots/analysis__create2_contract.snap +++ b/crates/analyzer/tests/snapshots/analysis__create2_contract.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ create2_contract.fe:4:5 │ -4 │ ╭ pub fn get_my_num() -> u256: +4 │ ╭ pub fn get_my_num() -> u256 { 5 │ │ return 42 - │ ╰─────────────────^ attributes hash: 6115314201970082834 +6 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -30,13 +31,13 @@ note: │ ^^ u256: Value note: - ┌─ create2_contract.fe:8:5 + ┌─ create2_contract.fe:10:5 │ - 8 │ ╭ pub fn create2_foo(ctx: Context) -> address: - 9 │ │ # value and salt -10 │ │ let foo: Foo = Foo.create2(ctx, 0, 52) -11 │ │ return address(foo) - │ ╰───────────────────────────^ attributes hash: 9364783648076633772 +10 │ ╭ pub fn create2_foo(ctx: Context) -> address { +11 │ │ let foo: Foo = Foo.create2(ctx, 0, 52) +12 │ │ return address(foo) +13 │ │ } + │ ╰─────^ attributes hash: 9364783648076633772 │ = FunctionSignature { self_decl: None, @@ -65,32 +66,32 @@ note: } note: - ┌─ create2_contract.fe:10:18 + ┌─ create2_contract.fe:11:18 │ -10 │ let foo: Foo = Foo.create2(ctx, 0, 52) +11 │ let foo: Foo = Foo.create2(ctx, 0, 52) │ ^^^ Foo note: - ┌─ create2_contract.fe:10:36 + ┌─ create2_contract.fe:11:36 │ -10 │ let foo: Foo = Foo.create2(ctx, 0, 52) +11 │ let foo: Foo = Foo.create2(ctx, 0, 52) │ ^^^ ^ ^^ u256: Value │ │ │ │ │ u256: Value │ Context: Memory note: - ┌─ create2_contract.fe:10:24 + ┌─ create2_contract.fe:11:24 │ -10 │ let foo: Foo = Foo.create2(ctx, 0, 52) +11 │ let foo: Foo = Foo.create2(ctx, 0, 52) │ ^^^^^^^^^^^^^^^^^^^^^^^ Foo: Value -11 │ return address(foo) +12 │ return address(foo) │ ^^^ Foo: Value note: - ┌─ create2_contract.fe:11:16 + ┌─ create2_contract.fe:12:16 │ -11 │ return address(foo) +12 │ return address(foo) │ ^^^^^^^^^^^^ address: Value diff --git a/crates/analyzer/tests/snapshots/analysis__create_contract.snap b/crates/analyzer/tests/snapshots/analysis__create_contract.snap index 5ab77847ae..6e242395fe 100644 --- a/crates/analyzer/tests/snapshots/analysis__create_contract.snap +++ b/crates/analyzer/tests/snapshots/analysis__create_contract.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ create_contract.fe:4:5 │ -4 │ ╭ pub fn get_my_num() -> u256: +4 │ ╭ pub fn get_my_num() -> u256 { 5 │ │ return 42 - │ ╰─────────────────^ attributes hash: 6115314201970082834 +6 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -30,12 +31,13 @@ note: │ ^^ u256: Value note: - ┌─ create_contract.fe:8:5 + ┌─ create_contract.fe:10:5 │ - 8 │ ╭ pub fn create_foo(ctx: Context) -> address: - 9 │ │ let foo: Foo = Foo.create(ctx, 0) -10 │ │ return address(foo) - │ ╰───────────────────────────^ attributes hash: 9364783648076633772 +10 │ ╭ pub fn create_foo(ctx: Context) -> address { +11 │ │ let foo: Foo = Foo.create(ctx, 0) +12 │ │ return address(foo) +13 │ │ } + │ ╰─────^ attributes hash: 9364783648076633772 │ = FunctionSignature { self_decl: None, @@ -64,31 +66,31 @@ note: } note: - ┌─ create_contract.fe:9:18 - │ -9 │ let foo: Foo = Foo.create(ctx, 0) - │ ^^^ Foo + ┌─ create_contract.fe:11:18 + │ +11 │ let foo: Foo = Foo.create(ctx, 0) + │ ^^^ Foo note: - ┌─ create_contract.fe:9:35 - │ -9 │ let foo: Foo = Foo.create(ctx, 0) - │ ^^^ ^ u256: Value - │ │ - │ Context: Memory + ┌─ create_contract.fe:11:35 + │ +11 │ let foo: Foo = Foo.create(ctx, 0) + │ ^^^ ^ u256: Value + │ │ + │ Context: Memory note: - ┌─ create_contract.fe:9:24 + ┌─ create_contract.fe:11:24 │ - 9 │ let foo: Foo = Foo.create(ctx, 0) +11 │ let foo: Foo = Foo.create(ctx, 0) │ ^^^^^^^^^^^^^^^^^^ Foo: Value -10 │ return address(foo) +12 │ return address(foo) │ ^^^ Foo: Value note: - ┌─ create_contract.fe:10:16 + ┌─ create_contract.fe:12:16 │ -10 │ return address(foo) +12 │ return address(foo) │ ^^^^^^^^^^^^ address: Value diff --git a/crates/analyzer/tests/snapshots/analysis__create_contract_from_init.snap b/crates/analyzer/tests/snapshots/analysis__create_contract_from_init.snap index 9d6fc40bcf..e06d4c7e3e 100644 --- a/crates/analyzer/tests/snapshots/analysis__create_contract_from_init.snap +++ b/crates/analyzer/tests/snapshots/analysis__create_contract_from_init.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ create_contract_from_init.fe:4:5 │ -4 │ ╭ pub fn get_my_num() -> u256: +4 │ ╭ pub fn get_my_num() -> u256 { 5 │ │ return 42 - │ ╰─────────────────^ attributes hash: 6115314201970082834 +6 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -30,17 +31,18 @@ note: │ ^^ u256: Value note: - ┌─ create_contract_from_init.fe:8:5 - │ -8 │ foo_addr: address - │ ^^^^^^^^^^^^^^^^^ address + ┌─ create_contract_from_init.fe:10:5 + │ +10 │ foo_addr: address + │ ^^^^^^^^^^^^^^^^^ address note: - ┌─ create_contract_from_init.fe:13:5 + ┌─ create_contract_from_init.fe:16:5 │ -13 │ ╭ pub fn get_foo_addr(self) -> address: -14 │ │ return self.foo_addr - │ ╰────────────────────────────^ attributes hash: 227275695522088782 +16 │ ╭ pub fn get_foo_addr(self) -> address { +17 │ │ return self.foo_addr +18 │ │ } + │ ╰─────^ attributes hash: 227275695522088782 │ = FunctionSignature { self_decl: Some( @@ -56,15 +58,15 @@ note: } note: - ┌─ create_contract_from_init.fe:14:16 + ┌─ create_contract_from_init.fe:17:16 │ -14 │ return self.foo_addr +17 │ return self.foo_addr │ ^^^^ FooFactory: Value note: - ┌─ create_contract_from_init.fe:14:16 + ┌─ create_contract_from_init.fe:17:16 │ -14 │ return self.foo_addr +17 │ return self.foo_addr │ ^^^^^^^^^^^^^ address: Storage { nonce: Some(0) } => Value diff --git a/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap b/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap index 648a537a96..1b4d6cdcdf 100644 --- a/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap +++ b/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap @@ -1,45 +1,42 @@ --- source: crates/analyzer/tests/analysis.rs expression: "build_snapshot(&db, module)" ---- -note: - ┌─ data_copying_stress.fe:4:5 - │ - 4 │ my_string: String<42> - │ ^^^^^^^^^^^^^^^^^^^^^ String<42> - 5 │ my_other_string: String<42> - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<42> - 6 │ - 7 │ my_u256: u256 - │ ^^^^^^^^^^^^^ u256 - 8 │ my_other_u256: u256 - │ ^^^^^^^^^^^^^^^^^^^ u256 - 9 │ -10 │ my_nums: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^ Array -11 │ -12 │ my_addrs: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array +--- note: - ┌─ data_copying_stress.fe:15:9 - │ -15 │ my_string: String<42> + ┌─ data_copying_stress.fe:4:5 + │ +4 │ my_string: String<42> + │ ^^^^^^^^^^^^^^^^^^^^^ String<42> +5 │ my_other_string: String<42> + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<42> +6 │ my_u256: u256 + │ ^^^^^^^^^^^^^ u256 +7 │ my_other_u256: u256 + │ ^^^^^^^^^^^^^^^^^^^ u256 +8 │ my_nums: Array + │ ^^^^^^^^^^^^^^^^^^^^^^^ Array +9 │ my_addrs: Array + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + +note: + ┌─ data_copying_stress.fe:12:9 + │ +12 │ my_string: String<42> │ ^^^^^^^^^^^^^^^^^^^^^ String<42> -16 │ my_u256: u256 +13 │ my_u256: u256 │ ^^^^^^^^^^^^^ u256 note: - ┌─ data_copying_stress.fe:18:5 + ┌─ data_copying_stress.fe:16:5 │ -18 │ ╭ pub fn set_my_vals( -19 │ │ self, -20 │ │ my_string: String<42>, -21 │ │ my_other_string: String<42>, - · │ -27 │ │ self.my_u256 = my_u256 -28 │ │ self.my_other_u256 = my_other_u256 - │ ╰──────────────────────────────────────────^ attributes hash: 8414520425977761339 +16 │ ╭ pub fn set_my_vals(self, my_string: String<42>, my_other_string: String<42>, my_u256: u256, my_other_u256: u256) { +17 │ │ self.my_string = my_string +18 │ │ self.my_other_string = my_other_string +19 │ │ self.my_u256 = my_u256 +20 │ │ self.my_other_u256 = my_other_u256 +21 │ │ } + │ ╰─────^ attributes hash: 8414520425977761339 │ = FunctionSignature { self_decl: Some( @@ -100,56 +97,57 @@ note: } note: - ┌─ data_copying_stress.fe:25:9 + ┌─ data_copying_stress.fe:17:9 │ -25 │ self.my_string = my_string +17 │ self.my_string = my_string │ ^^^^ Foo: Value note: - ┌─ data_copying_stress.fe:25:9 + ┌─ data_copying_stress.fe:17:9 │ -25 │ self.my_string = my_string +17 │ self.my_string = my_string │ ^^^^^^^^^^^^^^ ^^^^^^^^^ String<42>: Memory │ │ │ String<42>: Storage { nonce: Some(0) } -26 │ self.my_other_string = my_other_string +18 │ self.my_other_string = my_other_string │ ^^^^ Foo: Value note: - ┌─ data_copying_stress.fe:26:9 + ┌─ data_copying_stress.fe:18:9 │ -26 │ self.my_other_string = my_other_string +18 │ self.my_other_string = my_other_string │ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ String<42>: Memory │ │ │ String<42>: Storage { nonce: Some(1) } -27 │ self.my_u256 = my_u256 +19 │ self.my_u256 = my_u256 │ ^^^^ Foo: Value note: - ┌─ data_copying_stress.fe:27:9 + ┌─ data_copying_stress.fe:19:9 │ -27 │ self.my_u256 = my_u256 +19 │ self.my_u256 = my_u256 │ ^^^^^^^^^^^^ ^^^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(2) } -28 │ self.my_other_u256 = my_other_u256 +20 │ self.my_other_u256 = my_other_u256 │ ^^^^ Foo: Value note: - ┌─ data_copying_stress.fe:28:9 + ┌─ data_copying_stress.fe:20:9 │ -28 │ self.my_other_u256 = my_other_u256 +20 │ self.my_other_u256 = my_other_u256 │ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(3) } note: - ┌─ data_copying_stress.fe:30:5 + ┌─ data_copying_stress.fe:23:5 │ -30 │ ╭ pub fn set_to_my_other_vals(self): -31 │ │ self.my_string = self.my_other_string -32 │ │ self.my_u256 = self.my_other_u256 - │ ╰─────────────────────────────────────────^ attributes hash: 18235041182630809162 +23 │ ╭ pub fn set_to_my_other_vals(self) { +24 │ │ self.my_string = self.my_other_string +25 │ │ self.my_u256 = self.my_other_u256 +26 │ │ } + │ ╰─────^ attributes hash: 18235041182630809162 │ = FunctionSignature { self_decl: Some( @@ -165,52 +163,52 @@ note: } note: - ┌─ data_copying_stress.fe:31:9 + ┌─ data_copying_stress.fe:24:9 │ -31 │ self.my_string = self.my_other_string +24 │ self.my_string = self.my_other_string │ ^^^^ Foo: Value note: - ┌─ data_copying_stress.fe:31:9 + ┌─ data_copying_stress.fe:24:9 │ -31 │ self.my_string = self.my_other_string +24 │ self.my_string = self.my_other_string │ ^^^^^^^^^^^^^^ ^^^^ Foo: Value │ │ │ String<42>: Storage { nonce: Some(0) } note: - ┌─ data_copying_stress.fe:31:26 + ┌─ data_copying_stress.fe:24:26 │ -31 │ self.my_string = self.my_other_string +24 │ self.my_string = self.my_other_string │ ^^^^^^^^^^^^^^^^^^^^ String<42>: Storage { nonce: Some(1) } -32 │ self.my_u256 = self.my_other_u256 +25 │ self.my_u256 = self.my_other_u256 │ ^^^^ Foo: Value note: - ┌─ data_copying_stress.fe:32:9 + ┌─ data_copying_stress.fe:25:9 │ -32 │ self.my_u256 = self.my_other_u256 +25 │ self.my_u256 = self.my_other_u256 │ ^^^^^^^^^^^^ ^^^^ Foo: Value │ │ │ u256: Storage { nonce: Some(2) } note: - ┌─ data_copying_stress.fe:32:24 + ┌─ data_copying_stress.fe:25:24 │ -32 │ self.my_u256 = self.my_other_u256 +25 │ self.my_u256 = self.my_other_u256 │ ^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(3) } note: - ┌─ data_copying_stress.fe:34:5 + ┌─ data_copying_stress.fe:28:5 │ -34 │ ╭ pub fn multiple_references_shared_memory(my_array: Array): -35 │ │ let my_2nd_array: Array = my_array -36 │ │ let my_3rd_array: Array = my_2nd_array -37 │ │ +28 │ ╭ pub fn multiple_references_shared_memory(my_array: Array) { +29 │ │ let my_2nd_array: Array = my_array +30 │ │ let my_3rd_array: Array = my_2nd_array +31 │ │ assert my_array[3] != 5 · │ -46 │ │ assert my_2nd_array[3] == 50 -47 │ │ assert my_3rd_array[3] == 50 - │ ╰────────────────────────────────────^ attributes hash: 16237067187800993503 +39 │ │ assert my_3rd_array[3] == 50 +40 │ │ } + │ ╰─────^ attributes hash: 16237067187800993503 │ = FunctionSignature { self_decl: None, @@ -239,180 +237,179 @@ note: } note: - ┌─ data_copying_stress.fe:35:27 + ┌─ data_copying_stress.fe:29:27 │ -35 │ let my_2nd_array: Array = my_array +29 │ let my_2nd_array: Array = my_array │ ^^^^^^^^^^^^^^^ Array -36 │ let my_3rd_array: Array = my_2nd_array +30 │ let my_3rd_array: Array = my_2nd_array │ ^^^^^^^^^^^^^^^ Array note: - ┌─ data_copying_stress.fe:35:45 + ┌─ data_copying_stress.fe:29:45 │ -35 │ let my_2nd_array: Array = my_array +29 │ let my_2nd_array: Array = my_array │ ^^^^^^^^ Array: Memory -36 │ let my_3rd_array: Array = my_2nd_array +30 │ let my_3rd_array: Array = my_2nd_array │ ^^^^^^^^^^^^ Array: Memory -37 │ -38 │ assert my_array[3] != 5 +31 │ assert my_array[3] != 5 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ data_copying_stress.fe:38:16 + ┌─ data_copying_stress.fe:31:16 │ -38 │ assert my_array[3] != 5 +31 │ assert my_array[3] != 5 │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ data_copying_stress.fe:38:16 + ┌─ data_copying_stress.fe:31:16 │ -38 │ assert my_array[3] != 5 +31 │ assert my_array[3] != 5 │ ^^^^^^^^^^^^^^^^ bool: Value -39 │ my_array[3] = 5 +32 │ my_array[3] = 5 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ data_copying_stress.fe:39:9 + ┌─ data_copying_stress.fe:32:9 │ -39 │ my_array[3] = 5 +32 │ my_array[3] = 5 │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -40 │ assert my_array[3] == 5 +33 │ assert my_array[3] == 5 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ data_copying_stress.fe:40:16 + ┌─ data_copying_stress.fe:33:16 │ -40 │ assert my_array[3] == 5 +33 │ assert my_array[3] == 5 │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ data_copying_stress.fe:40:16 + ┌─ data_copying_stress.fe:33:16 │ -40 │ assert my_array[3] == 5 +33 │ assert my_array[3] == 5 │ ^^^^^^^^^^^^^^^^ bool: Value -41 │ assert my_2nd_array[3] == 5 +34 │ assert my_2nd_array[3] == 5 │ ^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ data_copying_stress.fe:41:16 + ┌─ data_copying_stress.fe:34:16 │ -41 │ assert my_2nd_array[3] == 5 +34 │ assert my_2nd_array[3] == 5 │ ^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ data_copying_stress.fe:41:16 + ┌─ data_copying_stress.fe:34:16 │ -41 │ assert my_2nd_array[3] == 5 +34 │ assert my_2nd_array[3] == 5 │ ^^^^^^^^^^^^^^^^^^^^ bool: Value -42 │ assert my_3rd_array[3] == 5 +35 │ assert my_3rd_array[3] == 5 │ ^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ data_copying_stress.fe:42:16 + ┌─ data_copying_stress.fe:35:16 │ -42 │ assert my_3rd_array[3] == 5 +35 │ assert my_3rd_array[3] == 5 │ ^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ data_copying_stress.fe:42:16 + ┌─ data_copying_stress.fe:35:16 │ -42 │ assert my_3rd_array[3] == 5 +35 │ assert my_3rd_array[3] == 5 │ ^^^^^^^^^^^^^^^^^^^^ bool: Value -43 │ -44 │ my_3rd_array[3] = 50 +36 │ my_3rd_array[3] = 50 │ ^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ data_copying_stress.fe:44:9 + ┌─ data_copying_stress.fe:36:9 │ -44 │ my_3rd_array[3] = 50 +36 │ my_3rd_array[3] = 50 │ ^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Memory -45 │ assert my_array[3] == 50 +37 │ assert my_array[3] == 50 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ data_copying_stress.fe:45:16 + ┌─ data_copying_stress.fe:37:16 │ -45 │ assert my_array[3] == 50 +37 │ assert my_array[3] == 50 │ ^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ data_copying_stress.fe:45:16 + ┌─ data_copying_stress.fe:37:16 │ -45 │ assert my_array[3] == 50 +37 │ assert my_array[3] == 50 │ ^^^^^^^^^^^^^^^^^ bool: Value -46 │ assert my_2nd_array[3] == 50 +38 │ assert my_2nd_array[3] == 50 │ ^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ data_copying_stress.fe:46:16 + ┌─ data_copying_stress.fe:38:16 │ -46 │ assert my_2nd_array[3] == 50 +38 │ assert my_2nd_array[3] == 50 │ ^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ data_copying_stress.fe:46:16 + ┌─ data_copying_stress.fe:38:16 │ -46 │ assert my_2nd_array[3] == 50 +38 │ assert my_2nd_array[3] == 50 │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value -47 │ assert my_3rd_array[3] == 50 +39 │ assert my_3rd_array[3] == 50 │ ^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ data_copying_stress.fe:47:16 + ┌─ data_copying_stress.fe:39:16 │ -47 │ assert my_3rd_array[3] == 50 +39 │ assert my_3rd_array[3] == 50 │ ^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ data_copying_stress.fe:47:16 + ┌─ data_copying_stress.fe:39:16 │ -47 │ assert my_3rd_array[3] == 50 +39 │ assert my_3rd_array[3] == 50 │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value note: - ┌─ data_copying_stress.fe:49:5 + ┌─ data_copying_stress.fe:42:5 │ -49 │ ╭ pub fn mutate_and_return(my_array: Array) -> Array: -50 │ │ my_array[3] = 5 -51 │ │ return my_array - │ ╰───────────────────────^ attributes hash: 15461468619504661037 +42 │ ╭ pub fn mutate_and_return(my_array: Array) -> Array { +43 │ │ my_array[3] = 5 +44 │ │ return my_array +45 │ │ } + │ ╰─────^ attributes hash: 15461468619504661037 │ = FunctionSignature { self_decl: None, @@ -446,29 +443,30 @@ note: } note: - ┌─ data_copying_stress.fe:50:9 + ┌─ data_copying_stress.fe:43:9 │ -50 │ my_array[3] = 5 +43 │ my_array[3] = 5 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ data_copying_stress.fe:50:9 + ┌─ data_copying_stress.fe:43:9 │ -50 │ my_array[3] = 5 +43 │ my_array[3] = 5 │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -51 │ return my_array +44 │ return my_array │ ^^^^^^^^ Array: Memory note: - ┌─ data_copying_stress.fe:53:5 + ┌─ data_copying_stress.fe:47:5 │ -53 │ ╭ pub fn clone_and_return(my_array: Array) -> Array: -54 │ │ return my_array.clone() - │ ╰───────────────────────────────^ attributes hash: 15461468619504661037 +47 │ ╭ pub fn clone_and_return(my_array: Array) -> Array { +48 │ │ return my_array.clone() +49 │ │ } + │ ╰─────^ attributes hash: 15461468619504661037 │ = FunctionSignature { self_decl: None, @@ -502,24 +500,25 @@ note: } note: - ┌─ data_copying_stress.fe:54:16 + ┌─ data_copying_stress.fe:48:16 │ -54 │ return my_array.clone() +48 │ return my_array.clone() │ ^^^^^^^^ Array: Memory note: - ┌─ data_copying_stress.fe:54:16 + ┌─ data_copying_stress.fe:48:16 │ -54 │ return my_array.clone() +48 │ return my_array.clone() │ ^^^^^^^^^^^^^^^^ Array: Memory => Memory note: - ┌─ data_copying_stress.fe:56:5 + ┌─ data_copying_stress.fe:51:5 │ -56 │ ╭ pub fn clone_mutate_and_return(my_array: Array) -> Array: -57 │ │ my_array.clone()[3] = 5 -58 │ │ return my_array - │ ╰───────────────────────^ attributes hash: 15461468619504661037 +51 │ ╭ pub fn clone_mutate_and_return(my_array: Array) -> Array { +52 │ │ my_array.clone()[3] = 5 +53 │ │ return my_array +54 │ │ } + │ ╰─────^ attributes hash: 15461468619504661037 │ = FunctionSignature { self_decl: None, @@ -553,40 +552,40 @@ note: } note: - ┌─ data_copying_stress.fe:57:9 + ┌─ data_copying_stress.fe:52:9 │ -57 │ my_array.clone()[3] = 5 +52 │ my_array.clone()[3] = 5 │ ^^^^^^^^ Array: Memory note: - ┌─ data_copying_stress.fe:57:9 + ┌─ data_copying_stress.fe:52:9 │ -57 │ my_array.clone()[3] = 5 +52 │ my_array.clone()[3] = 5 │ ^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Memory => Memory note: - ┌─ data_copying_stress.fe:57:9 + ┌─ data_copying_stress.fe:52:9 │ -57 │ my_array.clone()[3] = 5 +52 │ my_array.clone()[3] = 5 │ ^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -58 │ return my_array +53 │ return my_array │ ^^^^^^^^ Array: Memory note: - ┌─ data_copying_stress.fe:60:5 + ┌─ data_copying_stress.fe:56:5 │ -60 │ ╭ pub fn assign_my_nums_and_return(self) -> Array: -61 │ │ let my_nums_mem: Array -62 │ │ self.my_nums[0] = 42 -63 │ │ self.my_nums[1] = 26 +56 │ ╭ pub fn assign_my_nums_and_return(self) -> Array { +57 │ │ let my_nums_mem: Array +58 │ │ self.my_nums[0] = 42 +59 │ │ self.my_nums[1] = 26 · │ -67 │ │ my_nums_mem = self.my_nums.to_mem() -68 │ │ return my_nums_mem - │ ╰──────────────────────────^ attributes hash: 13146367689365512086 +64 │ │ return my_nums_mem +65 │ │ } + │ ╰─────^ attributes hash: 13146367689365512086 │ = FunctionSignature { self_decl: Some( @@ -607,133 +606,130 @@ note: } note: - ┌─ data_copying_stress.fe:61:26 + ┌─ data_copying_stress.fe:57:26 │ -61 │ let my_nums_mem: Array +57 │ let my_nums_mem: Array │ ^^^^^^^^^^^^^^ Array note: - ┌─ data_copying_stress.fe:62:9 + ┌─ data_copying_stress.fe:58:9 │ -62 │ self.my_nums[0] = 42 +58 │ self.my_nums[0] = 42 │ ^^^^ Foo: Value note: - ┌─ data_copying_stress.fe:62:9 + ┌─ data_copying_stress.fe:58:9 │ -62 │ self.my_nums[0] = 42 +58 │ self.my_nums[0] = 42 │ ^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Storage { nonce: Some(4) } note: - ┌─ data_copying_stress.fe:62:9 + ┌─ data_copying_stress.fe:58:9 │ -62 │ self.my_nums[0] = 42 +58 │ self.my_nums[0] = 42 │ ^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Storage { nonce: None } -63 │ self.my_nums[1] = 26 +59 │ self.my_nums[1] = 26 │ ^^^^ Foo: Value note: - ┌─ data_copying_stress.fe:63:9 + ┌─ data_copying_stress.fe:59:9 │ -63 │ self.my_nums[1] = 26 +59 │ self.my_nums[1] = 26 │ ^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Storage { nonce: Some(4) } note: - ┌─ data_copying_stress.fe:63:9 + ┌─ data_copying_stress.fe:59:9 │ -63 │ self.my_nums[1] = 26 +59 │ self.my_nums[1] = 26 │ ^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Storage { nonce: None } -64 │ self.my_nums[2] = 0 +60 │ self.my_nums[2] = 0 │ ^^^^ Foo: Value note: - ┌─ data_copying_stress.fe:64:9 + ┌─ data_copying_stress.fe:60:9 │ -64 │ self.my_nums[2] = 0 +60 │ self.my_nums[2] = 0 │ ^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Storage { nonce: Some(4) } note: - ┌─ data_copying_stress.fe:64:9 + ┌─ data_copying_stress.fe:60:9 │ -64 │ self.my_nums[2] = 0 +60 │ self.my_nums[2] = 0 │ ^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: None } -65 │ self.my_nums[3] = 1 +61 │ self.my_nums[3] = 1 │ ^^^^ Foo: Value note: - ┌─ data_copying_stress.fe:65:9 + ┌─ data_copying_stress.fe:61:9 │ -65 │ self.my_nums[3] = 1 +61 │ self.my_nums[3] = 1 │ ^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Storage { nonce: Some(4) } note: - ┌─ data_copying_stress.fe:65:9 + ┌─ data_copying_stress.fe:61:9 │ -65 │ self.my_nums[3] = 1 +61 │ self.my_nums[3] = 1 │ ^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: None } -66 │ self.my_nums[4] = 255 +62 │ self.my_nums[4] = 255 │ ^^^^ Foo: Value note: - ┌─ data_copying_stress.fe:66:9 + ┌─ data_copying_stress.fe:62:9 │ -66 │ self.my_nums[4] = 255 +62 │ self.my_nums[4] = 255 │ ^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Storage { nonce: Some(4) } note: - ┌─ data_copying_stress.fe:66:9 + ┌─ data_copying_stress.fe:62:9 │ -66 │ self.my_nums[4] = 255 +62 │ self.my_nums[4] = 255 │ ^^^^^^^^^^^^^^^ ^^^ u256: Value │ │ │ u256: Storage { nonce: None } -67 │ my_nums_mem = self.my_nums.to_mem() +63 │ my_nums_mem = self.my_nums.to_mem() │ ^^^^^^^^^^^ ^^^^ Foo: Value │ │ │ Array: Memory note: - ┌─ data_copying_stress.fe:67:23 + ┌─ data_copying_stress.fe:63:23 │ -67 │ my_nums_mem = self.my_nums.to_mem() +63 │ my_nums_mem = self.my_nums.to_mem() │ ^^^^^^^^^^^^ Array: Storage { nonce: Some(4) } note: - ┌─ data_copying_stress.fe:67:23 + ┌─ data_copying_stress.fe:63:23 │ -67 │ my_nums_mem = self.my_nums.to_mem() +63 │ my_nums_mem = self.my_nums.to_mem() │ ^^^^^^^^^^^^^^^^^^^^^ Array: Storage { nonce: Some(4) } => Memory -68 │ return my_nums_mem +64 │ return my_nums_mem │ ^^^^^^^^^^^ Array: Memory note: - ┌─ data_copying_stress.fe:70:5 + ┌─ data_copying_stress.fe:67:5 │ -70 │ ╭ pub fn emit_my_event(self, ctx: Context): -71 │ │ emit_my_event_internal( -72 │ │ ctx, -73 │ │ self.my_string.to_mem(), -74 │ │ self.my_u256 -75 │ │ ) - │ ╰─────────^ attributes hash: 1731341862738941170 +67 │ ╭ pub fn emit_my_event(self, ctx: Context) { +68 │ │ emit_my_event_internal(ctx, self.my_string.to_mem(), self.my_u256) +69 │ │ } + │ ╰─────^ attributes hash: 1731341862738941170 │ = FunctionSignature { self_decl: Some( @@ -764,49 +760,46 @@ note: } note: - ┌─ data_copying_stress.fe:72:13 + ┌─ data_copying_stress.fe:68:32 │ -72 │ ctx, - │ ^^^ Context: Memory -73 │ self.my_string.to_mem(), - │ ^^^^ Foo: Value +68 │ emit_my_event_internal(ctx, self.my_string.to_mem(), self.my_u256) + │ ^^^ ^^^^ Foo: Value + │ │ + │ Context: Memory note: - ┌─ data_copying_stress.fe:73:13 + ┌─ data_copying_stress.fe:68:37 │ -73 │ self.my_string.to_mem(), - │ ^^^^^^^^^^^^^^ String<42>: Storage { nonce: Some(0) } +68 │ emit_my_event_internal(ctx, self.my_string.to_mem(), self.my_u256) + │ ^^^^^^^^^^^^^^ String<42>: Storage { nonce: Some(0) } note: - ┌─ data_copying_stress.fe:73:13 + ┌─ data_copying_stress.fe:68:37 │ -73 │ self.my_string.to_mem(), - │ ^^^^^^^^^^^^^^^^^^^^^^^ String<42>: Storage { nonce: Some(0) } => Memory -74 │ self.my_u256 - │ ^^^^ Foo: Value +68 │ emit_my_event_internal(ctx, self.my_string.to_mem(), self.my_u256) + │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ Foo: Value + │ │ + │ String<42>: Storage { nonce: Some(0) } => Memory note: - ┌─ data_copying_stress.fe:74:13 + ┌─ data_copying_stress.fe:68:62 │ -74 │ self.my_u256 - │ ^^^^^^^^^^^^ u256: Storage { nonce: Some(2) } => Value +68 │ emit_my_event_internal(ctx, self.my_string.to_mem(), self.my_u256) + │ ^^^^^^^^^^^^ u256: Storage { nonce: Some(2) } => Value note: - ┌─ data_copying_stress.fe:71:9 - │ -71 │ ╭ emit_my_event_internal( -72 │ │ ctx, -73 │ │ self.my_string.to_mem(), -74 │ │ self.my_u256 -75 │ │ ) - │ ╰─────────^ (): Value + ┌─ data_copying_stress.fe:68:9 + │ +68 │ emit_my_event_internal(ctx, self.my_string.to_mem(), self.my_u256) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value note: - ┌─ data_copying_stress.fe:77:5 + ┌─ data_copying_stress.fe:71:5 │ -77 │ ╭ fn emit_my_event_internal(ctx: Context, _ my_string: String<42>, _ my_u256: u256): -78 │ │ emit MyEvent(ctx, my_string, my_u256) - │ ╰─────────────────────────────────────────────^ attributes hash: 15658342901286022244 +71 │ ╭ fn emit_my_event_internal(ctx: Context, _ my_string: String<42>, _ my_u256: u256) { +72 │ │ emit MyEvent(ctx, my_string, my_u256) +73 │ │ } + │ ╰─────^ attributes hash: 15658342901286022244 │ = FunctionSignature { self_decl: None, @@ -861,18 +854,18 @@ note: } note: - ┌─ data_copying_stress.fe:78:22 + ┌─ data_copying_stress.fe:72:22 │ -78 │ emit MyEvent(ctx, my_string, my_u256) +72 │ emit MyEvent(ctx, my_string, my_u256) │ ^^^ ^^^^^^^^^ ^^^^^^^ u256: Value │ │ │ │ │ String<42>: Memory │ Context: Memory note: - ┌─ data_copying_stress.fe:78:9 + ┌─ data_copying_stress.fe:72:9 │ -78 │ emit MyEvent(ctx, my_string, my_u256) +72 │ emit MyEvent(ctx, my_string, my_u256) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 595206297963940250 │ = Event { @@ -904,11 +897,12 @@ note: } note: - ┌─ data_copying_stress.fe:80:5 + ┌─ data_copying_stress.fe:75:5 │ -80 │ ╭ pub fn set_my_addrs(self, my_addrs: Array): -81 │ │ self.my_addrs = my_addrs - │ ╰────────────────────────────────^ attributes hash: 1347763946351267085 +75 │ ╭ pub fn set_my_addrs(self, my_addrs: Array) { +76 │ │ self.my_addrs = my_addrs +77 │ │ } + │ ╰─────^ attributes hash: 1347763946351267085 │ = FunctionSignature { self_decl: Some( @@ -937,25 +931,26 @@ note: } note: - ┌─ data_copying_stress.fe:81:9 + ┌─ data_copying_stress.fe:76:9 │ -81 │ self.my_addrs = my_addrs +76 │ self.my_addrs = my_addrs │ ^^^^ Foo: Value note: - ┌─ data_copying_stress.fe:81:9 + ┌─ data_copying_stress.fe:76:9 │ -81 │ self.my_addrs = my_addrs +76 │ self.my_addrs = my_addrs │ ^^^^^^^^^^^^^ ^^^^^^^^ Array: Memory │ │ │ Array: Storage { nonce: Some(5) } note: - ┌─ data_copying_stress.fe:83:5 + ┌─ data_copying_stress.fe:79:5 │ -83 │ ╭ pub fn get_my_second_addr(self) -> address: -84 │ │ return self.my_addrs[1] - │ ╰───────────────────────────────^ attributes hash: 227275695522088782 +79 │ ╭ pub fn get_my_second_addr(self) -> address { +80 │ │ return self.my_addrs[1] +81 │ │ } + │ ╰─────^ attributes hash: 227275695522088782 │ = FunctionSignature { self_decl: Some( @@ -971,23 +966,23 @@ note: } note: - ┌─ data_copying_stress.fe:84:16 + ┌─ data_copying_stress.fe:80:16 │ -84 │ return self.my_addrs[1] +80 │ return self.my_addrs[1] │ ^^^^ Foo: Value note: - ┌─ data_copying_stress.fe:84:16 + ┌─ data_copying_stress.fe:80:16 │ -84 │ return self.my_addrs[1] +80 │ return self.my_addrs[1] │ ^^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Storage { nonce: Some(5) } note: - ┌─ data_copying_stress.fe:84:16 + ┌─ data_copying_stress.fe:80:16 │ -84 │ return self.my_addrs[1] +80 │ return self.my_addrs[1] │ ^^^^^^^^^^^^^^^^ address: Storage { nonce: None } => Value diff --git a/crates/analyzer/tests/snapshots/analysis__empty.snap b/crates/analyzer/tests/snapshots/analysis__empty.snap index 7fcab83a3c..1c42536e4a 100644 --- a/crates/analyzer/tests/snapshots/analysis__empty.snap +++ b/crates/analyzer/tests/snapshots/analysis__empty.snap @@ -4,9 +4,9 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ empty.fe:2:3 + ┌─ empty.fe:2:5 │ -2 │ lonely: u256 - │ ^^^^^^^^^^^^ u256 +2 │ lonely: u256 + │ ^^^^^^^^^^^^ u256 diff --git a/crates/analyzer/tests/snapshots/analysis__erc20_token.snap b/crates/analyzer/tests/snapshots/analysis__erc20_token.snap index b70a6a1803..e0f2aa6e45 100644 --- a/crates/analyzer/tests/snapshots/analysis__erc20_token.snap +++ b/crates/analyzer/tests/snapshots/analysis__erc20_token.snap @@ -1,6 +1,7 @@ --- source: crates/analyzer/tests/analysis.rs expression: "build_snapshot(&db, module)" + --- note: ┌─ erc20_token.fe:4:5 @@ -29,21 +30,22 @@ note: │ ^^^^^^^^^^^ u256 note: - ┌─ erc20_token.fe:17:9 + ┌─ erc20_token.fe:18:9 │ -17 │ idx from: address +18 │ idx from: address │ ^^^^^^^^^^^^^^^^^ address -18 │ idx to: address +19 │ idx to: address │ ^^^^^^^^^^^^^^^ address -19 │ value: u256 +20 │ value: u256 │ ^^^^^^^^^^^ u256 note: - ┌─ erc20_token.fe:27:5 + ┌─ erc20_token.fe:30:5 │ -27 │ ╭ pub fn name(self) -> String<100>: -28 │ │ return self._name.to_mem() - │ ╰──────────────────────────────────^ attributes hash: 2936475649167061923 +30 │ ╭ pub fn name(self) -> String<100> { +31 │ │ return self._name.to_mem() +32 │ │ } + │ ╰─────^ attributes hash: 2936475649167061923 │ = FunctionSignature { self_decl: Some( @@ -61,29 +63,30 @@ note: } note: - ┌─ erc20_token.fe:28:16 + ┌─ erc20_token.fe:31:16 │ -28 │ return self._name.to_mem() +31 │ return self._name.to_mem() │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:28:16 + ┌─ erc20_token.fe:31:16 │ -28 │ return self._name.to_mem() +31 │ return self._name.to_mem() │ ^^^^^^^^^^ String<100>: Storage { nonce: Some(3) } note: - ┌─ erc20_token.fe:28:16 + ┌─ erc20_token.fe:31:16 │ -28 │ return self._name.to_mem() +31 │ return self._name.to_mem() │ ^^^^^^^^^^^^^^^^^^^ String<100>: Storage { nonce: Some(3) } => Memory note: - ┌─ erc20_token.fe:30:5 + ┌─ erc20_token.fe:34:5 │ -30 │ ╭ pub fn symbol(self) -> String<100>: -31 │ │ return self._symbol.to_mem() - │ ╰────────────────────────────────────^ attributes hash: 2936475649167061923 +34 │ ╭ pub fn symbol(self) -> String<100> { +35 │ │ return self._symbol.to_mem() +36 │ │ } + │ ╰─────^ attributes hash: 2936475649167061923 │ = FunctionSignature { self_decl: Some( @@ -101,29 +104,30 @@ note: } note: - ┌─ erc20_token.fe:31:16 + ┌─ erc20_token.fe:35:16 │ -31 │ return self._symbol.to_mem() +35 │ return self._symbol.to_mem() │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:31:16 + ┌─ erc20_token.fe:35:16 │ -31 │ return self._symbol.to_mem() +35 │ return self._symbol.to_mem() │ ^^^^^^^^^^^^ String<100>: Storage { nonce: Some(4) } note: - ┌─ erc20_token.fe:31:16 + ┌─ erc20_token.fe:35:16 │ -31 │ return self._symbol.to_mem() +35 │ return self._symbol.to_mem() │ ^^^^^^^^^^^^^^^^^^^^^ String<100>: Storage { nonce: Some(4) } => Memory note: - ┌─ erc20_token.fe:33:5 + ┌─ erc20_token.fe:38:5 │ -33 │ ╭ pub fn decimals(self) -> u8: -34 │ │ return self._decimals - │ ╰─────────────────────────────^ attributes hash: 11864308689780915279 +38 │ ╭ pub fn decimals(self) -> u8 { +39 │ │ return self._decimals +40 │ │ } + │ ╰─────^ attributes hash: 11864308689780915279 │ = FunctionSignature { self_decl: Some( @@ -141,23 +145,24 @@ note: } note: - ┌─ erc20_token.fe:34:16 + ┌─ erc20_token.fe:39:16 │ -34 │ return self._decimals +39 │ return self._decimals │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:34:16 + ┌─ erc20_token.fe:39:16 │ -34 │ return self._decimals +39 │ return self._decimals │ ^^^^^^^^^^^^^^ u8: Storage { nonce: Some(5) } => Value note: - ┌─ erc20_token.fe:36:5 + ┌─ erc20_token.fe:42:5 │ -36 │ ╭ pub fn totalSupply(self) -> u256: -37 │ │ return self._total_supply - │ ╰─────────────────────────────────^ attributes hash: 11773348765973600208 +42 │ ╭ pub fn totalSupply(self) -> u256 { +43 │ │ return self._total_supply +44 │ │ } + │ ╰─────^ attributes hash: 11773348765973600208 │ = FunctionSignature { self_decl: Some( @@ -175,23 +180,24 @@ note: } note: - ┌─ erc20_token.fe:37:16 + ┌─ erc20_token.fe:43:16 │ -37 │ return self._total_supply +43 │ return self._total_supply │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:37:16 + ┌─ erc20_token.fe:43:16 │ -37 │ return self._total_supply +43 │ return self._total_supply │ ^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(2) } => Value note: - ┌─ erc20_token.fe:39:5 + ┌─ erc20_token.fe:46:5 │ -39 │ ╭ pub fn balanceOf(self, _ account: address) -> u256: -40 │ │ return self._balances[account] - │ ╰──────────────────────────────────────^ attributes hash: 5993653573135321647 +46 │ ╭ pub fn balanceOf(self, _ account: address) -> u256 { +47 │ │ return self._balances[account] +48 │ │ } + │ ╰─────^ attributes hash: 5993653573135321647 │ = FunctionSignature { self_decl: Some( @@ -221,32 +227,33 @@ note: } note: - ┌─ erc20_token.fe:40:16 + ┌─ erc20_token.fe:47:16 │ -40 │ return self._balances[account] +47 │ return self._balances[account] │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:40:16 + ┌─ erc20_token.fe:47:16 │ -40 │ return self._balances[account] +47 │ return self._balances[account] │ ^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:40:16 + ┌─ erc20_token.fe:47:16 │ -40 │ return self._balances[account] +47 │ return self._balances[account] │ ^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:42:5 + ┌─ erc20_token.fe:50:5 │ -42 │ ╭ pub fn transfer(self, ctx: Context, recipient: address, value: u256) -> bool: -43 │ │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) -44 │ │ return true - │ ╰───────────────────^ attributes hash: 9700541873563816287 +50 │ ╭ pub fn transfer(self, ctx: Context, recipient: address, value: u256) -> bool { +51 │ │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) +52 │ │ return true +53 │ │ } + │ ╰─────^ attributes hash: 9700541873563816287 │ = FunctionSignature { self_decl: Some( @@ -297,37 +304,38 @@ note: } note: - ┌─ erc20_token.fe:43:9 + ┌─ erc20_token.fe:51:9 │ -43 │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) +51 │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) │ ^^^^ ^^^ ^^^ Context: Memory │ │ │ │ │ Context: Memory │ ERC20: Value note: - ┌─ erc20_token.fe:43:37 + ┌─ erc20_token.fe:51:37 │ -43 │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) +51 │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) │ ^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^^^^^ u256: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ erc20_token.fe:43:9 + ┌─ erc20_token.fe:51:9 │ -43 │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) +51 │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -44 │ return true +52 │ return true │ ^^^^ bool: Value note: - ┌─ erc20_token.fe:46:5 + ┌─ erc20_token.fe:55:5 │ -46 │ ╭ pub fn allowance(self, owner: address, spender: address) -> u256: -47 │ │ return self._allowances[owner][spender] - │ ╰───────────────────────────────────────────────^ attributes hash: 3316599995530573429 +55 │ ╭ pub fn allowance(self, owner: address, spender: address) -> u256 { +56 │ │ return self._allowances[owner][spender] +57 │ │ } + │ ╰─────^ attributes hash: 3316599995530573429 │ = FunctionSignature { self_decl: Some( @@ -364,40 +372,41 @@ note: } note: - ┌─ erc20_token.fe:47:16 + ┌─ erc20_token.fe:56:16 │ -47 │ return self._allowances[owner][spender] +56 │ return self._allowances[owner][spender] │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:47:16 + ┌─ erc20_token.fe:56:16 │ -47 │ return self._allowances[owner][spender] +56 │ return self._allowances[owner][spender] │ ^^^^^^^^^^^^^^^^ ^^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ erc20_token.fe:47:16 + ┌─ erc20_token.fe:56:16 │ -47 │ return self._allowances[owner][spender] +56 │ return self._allowances[owner][spender] │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ erc20_token.fe:47:16 + ┌─ erc20_token.fe:56:16 │ -47 │ return self._allowances[owner][spender] +56 │ return self._allowances[owner][spender] │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:49:5 + ┌─ erc20_token.fe:59:5 │ -49 │ ╭ pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool: -50 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) -51 │ │ return true - │ ╰───────────────────^ attributes hash: 8309406699454253603 +59 │ ╭ pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool { +60 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) +61 │ │ return true +62 │ │ } + │ ╰─────^ attributes hash: 8309406699454253603 │ = FunctionSignature { self_decl: Some( @@ -448,40 +457,41 @@ note: } note: - ┌─ erc20_token.fe:50:9 + ┌─ erc20_token.fe:60:9 │ -50 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) +60 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) │ ^^^^ ^^^ ^^^ Context: Memory │ │ │ │ │ Context: Memory │ ERC20: Value note: - ┌─ erc20_token.fe:50:35 + ┌─ erc20_token.fe:60:35 │ -50 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) +60 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) │ ^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^ u256: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ erc20_token.fe:50:9 + ┌─ erc20_token.fe:60:9 │ -50 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) +60 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -51 │ return true +61 │ return true │ ^^^^ bool: Value note: - ┌─ erc20_token.fe:53:5 + ┌─ erc20_token.fe:64:5 │ -53 │ ╭ pub fn transferFrom(self, ctx: Context, sender: address, recipient: address, value: u256) -> bool: -54 │ │ assert self._allowances[sender][ctx.msg_sender()] >= value -55 │ │ self._transfer(ctx, sender, recipient, value) -56 │ │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) -57 │ │ return true - │ ╰───────────────────^ attributes hash: 14464733394183378558 +64 │ ╭ pub fn transferFrom(self, ctx: Context, sender: address, recipient: address, value: u256) -> bool { +65 │ │ assert self._allowances[sender][ctx.msg_sender()] >= value +66 │ │ self._transfer(ctx, sender, recipient, value) +67 │ │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +68 │ │ return true +69 │ │ } + │ ╰─────^ attributes hash: 14464733394183378558 │ = FunctionSignature { self_decl: Some( @@ -541,47 +551,47 @@ note: } note: - ┌─ erc20_token.fe:54:16 + ┌─ erc20_token.fe:65:16 │ -54 │ assert self._allowances[sender][ctx.msg_sender()] >= value +65 │ assert self._allowances[sender][ctx.msg_sender()] >= value │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:54:16 + ┌─ erc20_token.fe:65:16 │ -54 │ assert self._allowances[sender][ctx.msg_sender()] >= value +65 │ assert self._allowances[sender][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ erc20_token.fe:54:16 + ┌─ erc20_token.fe:65:16 │ -54 │ assert self._allowances[sender][ctx.msg_sender()] >= value +65 │ assert self._allowances[sender][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: None } note: - ┌─ erc20_token.fe:54:41 + ┌─ erc20_token.fe:65:41 │ -54 │ assert self._allowances[sender][ctx.msg_sender()] >= value +65 │ assert self._allowances[sender][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:54:16 + ┌─ erc20_token.fe:65:16 │ -54 │ assert self._allowances[sender][ctx.msg_sender()] >= value +65 │ assert self._allowances[sender][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:54:16 + ┌─ erc20_token.fe:65:16 │ -54 │ assert self._allowances[sender][ctx.msg_sender()] >= value +65 │ assert self._allowances[sender][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -55 │ self._transfer(ctx, sender, recipient, value) +66 │ self._transfer(ctx, sender, recipient, value) │ ^^^^ ^^^ ^^^^^^ ^^^^^^^^^ ^^^^^ u256: Value │ │ │ │ │ │ │ │ │ address: Value @@ -590,11 +600,11 @@ note: │ ERC20: Value note: - ┌─ erc20_token.fe:55:9 + ┌─ erc20_token.fe:66:9 │ -55 │ self._transfer(ctx, sender, recipient, value) +66 │ self._transfer(ctx, sender, recipient, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -56 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +67 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^ ^^^ ^^^^^^ ^^^ Context: Memory │ │ │ │ │ │ │ address: Value @@ -602,64 +612,65 @@ note: │ ERC20: Value note: - ┌─ erc20_token.fe:56:52 + ┌─ erc20_token.fe:67:52 │ -56 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +67 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value │ │ │ address: Value note: - ┌─ erc20_token.fe:56:77 + ┌─ erc20_token.fe:67:77 │ -56 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +67 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^^^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ erc20_token.fe:56:77 + ┌─ erc20_token.fe:67:77 │ -56 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +67 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: None } note: - ┌─ erc20_token.fe:56:102 + ┌─ erc20_token.fe:67:102 │ -56 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +67 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:56:77 + ┌─ erc20_token.fe:67:77 │ -56 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +67 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:56:77 + ┌─ erc20_token.fe:67:77 │ -56 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +67 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ erc20_token.fe:56:9 + ┌─ erc20_token.fe:67:9 │ -56 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +67 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -57 │ return true +68 │ return true │ ^^^^ bool: Value note: - ┌─ erc20_token.fe:59:5 + ┌─ erc20_token.fe:71:5 │ -59 │ ╭ pub fn increaseAllowance(self, ctx: Context, spender: address, addedValue: u256) -> bool: -60 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) -61 │ │ return true - │ ╰───────────────────^ attributes hash: 14606848714789380929 +71 │ ╭ pub fn increaseAllowance(self, ctx: Context, spender: address, addedValue: u256) -> bool { +72 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +73 │ │ return true +74 │ │ } + │ ╰─────^ attributes hash: 14606848714789380929 │ = FunctionSignature { self_decl: Some( @@ -710,74 +721,75 @@ note: } note: - ┌─ erc20_token.fe:60:9 + ┌─ erc20_token.fe:72:9 │ -60 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +72 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^ ^^^ ^^^ Context: Memory │ │ │ │ │ Context: Memory │ ERC20: Value note: - ┌─ erc20_token.fe:60:35 + ┌─ erc20_token.fe:72:35 │ -60 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +72 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^ ERC20: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ erc20_token.fe:60:69 + ┌─ erc20_token.fe:72:69 │ -60 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +72 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ erc20_token.fe:60:86 + ┌─ erc20_token.fe:72:86 │ -60 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +72 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:60:69 + ┌─ erc20_token.fe:72:69 │ -60 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +72 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ erc20_token.fe:60:69 + ┌─ erc20_token.fe:72:69 │ -60 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +72 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:60:69 + ┌─ erc20_token.fe:72:69 │ -60 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +72 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ erc20_token.fe:60:9 + ┌─ erc20_token.fe:72:9 │ -60 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +72 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -61 │ return true +73 │ return true │ ^^^^ bool: Value note: - ┌─ erc20_token.fe:63:5 + ┌─ erc20_token.fe:76:5 │ -63 │ ╭ pub fn decreaseAllowance(self, ctx: Context, spender: address, subtractedValue: u256) -> bool: -64 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) -65 │ │ return true - │ ╰───────────────────^ attributes hash: 9154612140799800808 +76 │ ╭ pub fn decreaseAllowance(self, ctx: Context, spender: address, subtractedValue: u256) -> bool { +77 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +78 │ │ return true +79 │ │ } + │ ╰─────^ attributes hash: 9154612140799800808 │ = FunctionSignature { self_decl: Some( @@ -828,78 +840,78 @@ note: } note: - ┌─ erc20_token.fe:64:9 + ┌─ erc20_token.fe:77:9 │ -64 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +77 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^ ^^^ ^^^ Context: Memory │ │ │ │ │ Context: Memory │ ERC20: Value note: - ┌─ erc20_token.fe:64:35 + ┌─ erc20_token.fe:77:35 │ -64 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +77 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^ ERC20: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ erc20_token.fe:64:69 + ┌─ erc20_token.fe:77:69 │ -64 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +77 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ erc20_token.fe:64:86 + ┌─ erc20_token.fe:77:86 │ -64 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +77 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:64:69 + ┌─ erc20_token.fe:77:69 │ -64 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +77 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ erc20_token.fe:64:69 + ┌─ erc20_token.fe:77:69 │ -64 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +77 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:64:69 + ┌─ erc20_token.fe:77:69 │ -64 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +77 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ erc20_token.fe:64:9 + ┌─ erc20_token.fe:77:9 │ -64 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +77 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -65 │ return true +78 │ return true │ ^^^^ bool: Value note: - ┌─ erc20_token.fe:67:5 + ┌─ erc20_token.fe:81:5 │ -67 │ ╭ fn _transfer(self, ctx: Context, sender: address, recipient: address, value: u256): -68 │ │ assert sender != address(0) -69 │ │ assert recipient != address(0) -70 │ │ _before_token_transfer(from: sender, to: recipient, value) -71 │ │ self._balances[sender] = self._balances[sender] - value -72 │ │ self._balances[recipient] = self._balances[recipient] + value -73 │ │ emit Transfer(ctx, from: sender, to: recipient, value) - │ ╰──────────────────────────────────────────────────────────────^ attributes hash: 10648262769466339085 +81 │ ╭ fn _transfer(self, ctx: Context, sender: address, recipient: address, value: u256) { +82 │ │ assert sender != address(0) +83 │ │ assert recipient != address(0) +84 │ │ _before_token_transfer(from: sender, to: recipient, value) + · │ +87 │ │ emit Transfer(ctx, from: sender, to: recipient, value) +88 │ │ } + │ ╰─────^ attributes hash: 10648262769466339085 │ = FunctionSignature { self_decl: Some( @@ -959,132 +971,132 @@ note: } note: - ┌─ erc20_token.fe:68:16 + ┌─ erc20_token.fe:82:16 │ -68 │ assert sender != address(0) +82 │ assert sender != address(0) │ ^^^^^^ ^ u256: Value │ │ │ address: Value note: - ┌─ erc20_token.fe:68:26 + ┌─ erc20_token.fe:82:26 │ -68 │ assert sender != address(0) +82 │ assert sender != address(0) │ ^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:68:16 + ┌─ erc20_token.fe:82:16 │ -68 │ assert sender != address(0) +82 │ assert sender != address(0) │ ^^^^^^^^^^^^^^^^^^^^ bool: Value -69 │ assert recipient != address(0) +83 │ assert recipient != address(0) │ ^^^^^^^^^ ^ u256: Value │ │ │ address: Value note: - ┌─ erc20_token.fe:69:29 + ┌─ erc20_token.fe:83:29 │ -69 │ assert recipient != address(0) +83 │ assert recipient != address(0) │ ^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:69:16 + ┌─ erc20_token.fe:83:16 │ -69 │ assert recipient != address(0) +83 │ assert recipient != address(0) │ ^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -70 │ _before_token_transfer(from: sender, to: recipient, value) +84 │ _before_token_transfer(from: sender, to: recipient, value) │ ^^^^^^ ^^^^^^^^^ ^^^^^ u256: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ erc20_token.fe:70:9 + ┌─ erc20_token.fe:84:9 │ -70 │ _before_token_transfer(from: sender, to: recipient, value) +84 │ _before_token_transfer(from: sender, to: recipient, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -71 │ self._balances[sender] = self._balances[sender] - value +85 │ self._balances[sender] = self._balances[sender] - value │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:71:9 + ┌─ erc20_token.fe:85:9 │ -71 │ self._balances[sender] = self._balances[sender] - value +85 │ self._balances[sender] = self._balances[sender] - value │ ^^^^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:71:9 + ┌─ erc20_token.fe:85:9 │ -71 │ self._balances[sender] = self._balances[sender] - value +85 │ self._balances[sender] = self._balances[sender] - value │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value │ │ │ u256: Storage { nonce: None } note: - ┌─ erc20_token.fe:71:34 + ┌─ erc20_token.fe:85:34 │ -71 │ self._balances[sender] = self._balances[sender] - value +85 │ self._balances[sender] = self._balances[sender] - value │ ^^^^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:71:34 + ┌─ erc20_token.fe:85:34 │ -71 │ self._balances[sender] = self._balances[sender] - value +85 │ self._balances[sender] = self._balances[sender] - value │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:71:34 + ┌─ erc20_token.fe:85:34 │ -71 │ self._balances[sender] = self._balances[sender] - value +85 │ self._balances[sender] = self._balances[sender] - value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -72 │ self._balances[recipient] = self._balances[recipient] + value +86 │ self._balances[recipient] = self._balances[recipient] + value │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:72:9 + ┌─ erc20_token.fe:86:9 │ -72 │ self._balances[recipient] = self._balances[recipient] + value +86 │ self._balances[recipient] = self._balances[recipient] + value │ ^^^^^^^^^^^^^^ ^^^^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:72:9 + ┌─ erc20_token.fe:86:9 │ -72 │ self._balances[recipient] = self._balances[recipient] + value +86 │ self._balances[recipient] = self._balances[recipient] + value │ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value │ │ │ u256: Storage { nonce: None } note: - ┌─ erc20_token.fe:72:37 + ┌─ erc20_token.fe:86:37 │ -72 │ self._balances[recipient] = self._balances[recipient] + value +86 │ self._balances[recipient] = self._balances[recipient] + value │ ^^^^^^^^^^^^^^ ^^^^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:72:37 + ┌─ erc20_token.fe:86:37 │ -72 │ self._balances[recipient] = self._balances[recipient] + value +86 │ self._balances[recipient] = self._balances[recipient] + value │ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:72:37 + ┌─ erc20_token.fe:86:37 │ -72 │ self._balances[recipient] = self._balances[recipient] + value +86 │ self._balances[recipient] = self._balances[recipient] + value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -73 │ emit Transfer(ctx, from: sender, to: recipient, value) +87 │ emit Transfer(ctx, from: sender, to: recipient, value) │ ^^^ ^^^^^^ ^^^^^^^^^ ^^^^^ u256: Value │ │ │ │ │ │ │ address: Value @@ -1092,9 +1104,9 @@ note: │ Context: Memory note: - ┌─ erc20_token.fe:73:9 + ┌─ erc20_token.fe:87:9 │ -73 │ emit Transfer(ctx, from: sender, to: recipient, value) +87 │ emit Transfer(ctx, from: sender, to: recipient, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 5533489995250141934 │ = Event { @@ -1133,15 +1145,16 @@ note: } note: - ┌─ erc20_token.fe:75:5 + ┌─ erc20_token.fe:90:5 │ -75 │ ╭ fn _mint(self, ctx: Context, account: address, value: u256): -76 │ │ assert account != address(0) -77 │ │ _before_token_transfer(from: address(0), to: account, value) -78 │ │ self._total_supply = self._total_supply + value -79 │ │ self._balances[account] = self._balances[account] + value -80 │ │ emit Transfer(ctx, from: address(0), to: account, value) - │ ╰────────────────────────────────────────────────────────────────^ attributes hash: 6502254374233415580 +90 │ ╭ fn _mint(self, ctx: Context, account: address, value: u256) { +91 │ │ assert account != address(0) +92 │ │ _before_token_transfer(from: address(0), to: account, value) +93 │ │ self._total_supply = self._total_supply + value +94 │ │ self._balances[account] = self._balances[account] + value +95 │ │ emit Transfer(ctx, from: address(0), to: account, value) +96 │ │ } + │ ╰─────^ attributes hash: 6502254374233415580 │ = FunctionSignature { self_decl: Some( @@ -1192,123 +1205,123 @@ note: } note: - ┌─ erc20_token.fe:76:16 + ┌─ erc20_token.fe:91:16 │ -76 │ assert account != address(0) +91 │ assert account != address(0) │ ^^^^^^^ ^ u256: Value │ │ │ address: Value note: - ┌─ erc20_token.fe:76:27 + ┌─ erc20_token.fe:91:27 │ -76 │ assert account != address(0) +91 │ assert account != address(0) │ ^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:76:16 + ┌─ erc20_token.fe:91:16 │ -76 │ assert account != address(0) +91 │ assert account != address(0) │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value -77 │ _before_token_transfer(from: address(0), to: account, value) +92 │ _before_token_transfer(from: address(0), to: account, value) │ ^ u256: Value note: - ┌─ erc20_token.fe:77:38 + ┌─ erc20_token.fe:92:38 │ -77 │ _before_token_transfer(from: address(0), to: account, value) +92 │ _before_token_transfer(from: address(0), to: account, value) │ ^^^^^^^^^^ ^^^^^^^ ^^^^^ u256: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ erc20_token.fe:77:9 + ┌─ erc20_token.fe:92:9 │ -77 │ _before_token_transfer(from: address(0), to: account, value) +92 │ _before_token_transfer(from: address(0), to: account, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -78 │ self._total_supply = self._total_supply + value +93 │ self._total_supply = self._total_supply + value │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:78:9 + ┌─ erc20_token.fe:93:9 │ -78 │ self._total_supply = self._total_supply + value +93 │ self._total_supply = self._total_supply + value │ ^^^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value │ │ │ u256: Storage { nonce: Some(2) } note: - ┌─ erc20_token.fe:78:30 + ┌─ erc20_token.fe:93:30 │ -78 │ self._total_supply = self._total_supply + value +93 │ self._total_supply = self._total_supply + value │ ^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(2) } => Value note: - ┌─ erc20_token.fe:78:30 + ┌─ erc20_token.fe:93:30 │ -78 │ self._total_supply = self._total_supply + value +93 │ self._total_supply = self._total_supply + value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -79 │ self._balances[account] = self._balances[account] + value +94 │ self._balances[account] = self._balances[account] + value │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:79:9 + ┌─ erc20_token.fe:94:9 │ -79 │ self._balances[account] = self._balances[account] + value +94 │ self._balances[account] = self._balances[account] + value │ ^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:79:9 + ┌─ erc20_token.fe:94:9 │ -79 │ self._balances[account] = self._balances[account] + value +94 │ self._balances[account] = self._balances[account] + value │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value │ │ │ u256: Storage { nonce: None } note: - ┌─ erc20_token.fe:79:35 + ┌─ erc20_token.fe:94:35 │ -79 │ self._balances[account] = self._balances[account] + value +94 │ self._balances[account] = self._balances[account] + value │ ^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:79:35 + ┌─ erc20_token.fe:94:35 │ -79 │ self._balances[account] = self._balances[account] + value +94 │ self._balances[account] = self._balances[account] + value │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:79:35 + ┌─ erc20_token.fe:94:35 │ -79 │ self._balances[account] = self._balances[account] + value +94 │ self._balances[account] = self._balances[account] + value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -80 │ emit Transfer(ctx, from: address(0), to: account, value) +95 │ emit Transfer(ctx, from: address(0), to: account, value) │ ^^^ ^ u256: Value │ │ │ Context: Memory note: - ┌─ erc20_token.fe:80:34 + ┌─ erc20_token.fe:95:34 │ -80 │ emit Transfer(ctx, from: address(0), to: account, value) +95 │ emit Transfer(ctx, from: address(0), to: account, value) │ ^^^^^^^^^^ ^^^^^^^ ^^^^^ u256: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ erc20_token.fe:80:9 + ┌─ erc20_token.fe:95:9 │ -80 │ emit Transfer(ctx, from: address(0), to: account, value) +95 │ emit Transfer(ctx, from: address(0), to: account, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 5533489995250141934 │ = Event { @@ -1347,492 +1360,494 @@ note: } note: - ┌─ erc20_token.fe:82:5 - │ -82 │ ╭ fn _burn(self, ctx: Context, account: address, value: u256): -83 │ │ assert account != address(0) -84 │ │ _before_token_transfer(from: account, to: address(0), value) -85 │ │ self._balances[account] = self._balances[account] - value -86 │ │ self._total_supply = self._total_supply - value -87 │ │ emit Transfer(ctx, from: account, to: address(0), value) - │ ╰────────────────────────────────────────────────────────────────^ attributes hash: 6502254374233415580 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: Some( - Mutable, - ), - params: [ - FunctionParam { - label: None, - name: "ctx", - typ: Ok( - Struct( - Struct { - name: "Context", - field_count: 0, - }, - ), - ), - }, - FunctionParam { - label: None, - name: "account", - typ: Ok( - Base( - Address, - ), - ), - }, - FunctionParam { - label: None, - name: "value", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } - -note: - ┌─ erc20_token.fe:83:16 - │ -83 │ assert account != address(0) + ┌─ erc20_token.fe:98:5 + │ + 98 │ ╭ fn _burn(self, ctx: Context, account: address, value: u256) { + 99 │ │ assert account != address(0) +100 │ │ _before_token_transfer(from: account, to: address(0), value) +101 │ │ self._balances[account] = self._balances[account] - value +102 │ │ self._total_supply = self._total_supply - value +103 │ │ emit Transfer(ctx, from: account, to: address(0), value) +104 │ │ } + │ ╰─────^ attributes hash: 6502254374233415580 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: Some( + Mutable, + ), + params: [ + FunctionParam { + label: None, + name: "ctx", + typ: Ok( + Struct( + Struct { + name: "Context", + field_count: 0, + }, + ), + ), + }, + FunctionParam { + label: None, + name: "account", + typ: Ok( + Base( + Address, + ), + ), + }, + FunctionParam { + label: None, + name: "value", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } + +note: + ┌─ erc20_token.fe:99:16 + │ +99 │ assert account != address(0) │ ^^^^^^^ ^ u256: Value │ │ │ address: Value note: - ┌─ erc20_token.fe:83:27 + ┌─ erc20_token.fe:99:27 │ -83 │ assert account != address(0) +99 │ assert account != address(0) │ ^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:83:16 - │ -83 │ assert account != address(0) - │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value -84 │ _before_token_transfer(from: account, to: address(0), value) - │ ^^^^^^^ ^ u256: Value - │ │ - │ address: Value - -note: - ┌─ erc20_token.fe:84:51 - │ -84 │ _before_token_transfer(from: account, to: address(0), value) - │ ^^^^^^^^^^ ^^^^^ u256: Value - │ │ - │ address: Value - -note: - ┌─ erc20_token.fe:84:9 - │ -84 │ _before_token_transfer(from: account, to: address(0), value) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -85 │ self._balances[account] = self._balances[account] - value - │ ^^^^ ERC20: Value - -note: - ┌─ erc20_token.fe:85:9 - │ -85 │ self._balances[account] = self._balances[account] - value - │ ^^^^^^^^^^^^^^ ^^^^^^^ address: Value - │ │ - │ Map: Storage { nonce: Some(0) } - -note: - ┌─ erc20_token.fe:85:9 - │ -85 │ self._balances[account] = self._balances[account] - value - │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value - │ │ - │ u256: Storage { nonce: None } - -note: - ┌─ erc20_token.fe:85:35 - │ -85 │ self._balances[account] = self._balances[account] - value - │ ^^^^^^^^^^^^^^ ^^^^^^^ address: Value - │ │ - │ Map: Storage { nonce: Some(0) } - -note: - ┌─ erc20_token.fe:85:35 - │ -85 │ self._balances[account] = self._balances[account] - value - │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value - │ │ - │ u256: Storage { nonce: None } => Value - -note: - ┌─ erc20_token.fe:85:35 - │ -85 │ self._balances[account] = self._balances[account] - value - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -86 │ self._total_supply = self._total_supply - value - │ ^^^^ ERC20: Value - -note: - ┌─ erc20_token.fe:86:9 - │ -86 │ self._total_supply = self._total_supply - value - │ ^^^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value - │ │ - │ u256: Storage { nonce: Some(2) } - -note: - ┌─ erc20_token.fe:86:30 - │ -86 │ self._total_supply = self._total_supply - value - │ ^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value - │ │ - │ u256: Storage { nonce: Some(2) } => Value - -note: - ┌─ erc20_token.fe:86:30 - │ -86 │ self._total_supply = self._total_supply - value - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -87 │ emit Transfer(ctx, from: account, to: address(0), value) - │ ^^^ ^^^^^^^ ^ u256: Value - │ │ │ - │ │ address: Value - │ Context: Memory - -note: - ┌─ erc20_token.fe:87:47 - │ -87 │ emit Transfer(ctx, from: account, to: address(0), value) - │ ^^^^^^^^^^ ^^^^^ u256: Value - │ │ - │ address: Value - -note: - ┌─ erc20_token.fe:87:9 - │ -87 │ emit Transfer(ctx, from: account, to: address(0), value) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 5533489995250141934 - │ - = Event { - name: "Transfer", - fields: [ - EventField { - name: "from", - typ: Ok( - Base( - Address, - ), - ), - is_indexed: true, - }, - EventField { - name: "to", - typ: Ok( - Base( - Address, - ), - ), - is_indexed: true, - }, - EventField { - name: "value", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - is_indexed: false, - }, - ], - } - -note: - ┌─ erc20_token.fe:89:5 - │ -89 │ ╭ fn _approve(self, ctx: Context, owner: address, spender: address, value: u256): -90 │ │ assert owner != address(0) -91 │ │ assert spender != address(0) -92 │ │ self._allowances[owner][spender] = value -93 │ │ emit Approval(ctx, owner, spender, value) - │ ╰─────────────────────────────────────────────────^ attributes hash: 1630416716014819616 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: Some( - Mutable, - ), - params: [ - FunctionParam { - label: None, - name: "ctx", - typ: Ok( - Struct( - Struct { - name: "Context", - field_count: 0, - }, - ), - ), - }, - FunctionParam { - label: None, - name: "owner", - typ: Ok( - Base( - Address, - ), - ), - }, - FunctionParam { - label: None, - name: "spender", - typ: Ok( - Base( - Address, - ), - ), - }, - FunctionParam { - label: None, - name: "value", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } - -note: - ┌─ erc20_token.fe:90:16 - │ -90 │ assert owner != address(0) - │ ^^^^^ ^ u256: Value - │ │ - │ address: Value - -note: - ┌─ erc20_token.fe:90:25 - │ -90 │ assert owner != address(0) - │ ^^^^^^^^^^ address: Value - -note: - ┌─ erc20_token.fe:90:16 - │ -90 │ assert owner != address(0) - │ ^^^^^^^^^^^^^^^^^^^ bool: Value -91 │ assert spender != address(0) - │ ^^^^^^^ ^ u256: Value - │ │ - │ address: Value - -note: - ┌─ erc20_token.fe:91:27 - │ -91 │ assert spender != address(0) - │ ^^^^^^^^^^ address: Value - -note: - ┌─ erc20_token.fe:91:16 - │ -91 │ assert spender != address(0) - │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value -92 │ self._allowances[owner][spender] = value - │ ^^^^ ERC20: Value - -note: - ┌─ erc20_token.fe:92:9 - │ -92 │ self._allowances[owner][spender] = value - │ ^^^^^^^^^^^^^^^^ ^^^^^ address: Value - │ │ - │ Map>: Storage { nonce: Some(1) } - -note: - ┌─ erc20_token.fe:92:9 - │ -92 │ self._allowances[owner][spender] = value - │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value - │ │ - │ Map: Storage { nonce: None } - -note: - ┌─ erc20_token.fe:92:9 - │ -92 │ self._allowances[owner][spender] = value - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value - │ │ - │ u256: Storage { nonce: None } -93 │ emit Approval(ctx, owner, spender, value) - │ ^^^ ^^^^^ ^^^^^^^ ^^^^^ u256: Value - │ │ │ │ - │ │ │ address: Value - │ │ address: Value - │ Context: Memory - -note: - ┌─ erc20_token.fe:93:9 - │ -93 │ emit Approval(ctx, owner, spender, value) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 8893313742751514912 - │ - = Event { - name: "Approval", - fields: [ - EventField { - name: "owner", - typ: Ok( - Base( - Address, - ), - ), - is_indexed: true, - }, - EventField { - name: "spender", - typ: Ok( - Base( - Address, - ), - ), - is_indexed: true, - }, - EventField { - name: "value", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - is_indexed: false, - }, - ], - } - -note: - ┌─ erc20_token.fe:95:5 - │ -95 │ ╭ fn _setup_decimals(self, _ decimals_: u8): -96 │ │ self._decimals = decimals_ - │ ╰──────────────────────────────────^ attributes hash: 2241116105643912660 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: None, - params: [ - FunctionParam { - label: Some( - "_", - ), - name: "decimals_", - typ: Ok( - Base( - Numeric( - U8, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } - -note: - ┌─ erc20_token.fe:96:9 - │ -96 │ self._decimals = decimals_ - │ ^^^^ ERC20: Value - -note: - ┌─ erc20_token.fe:96:9 - │ -96 │ self._decimals = decimals_ - │ ^^^^^^^^^^^^^^ ^^^^^^^^^ u8: Value - │ │ - │ u8: Storage { nonce: Some(5) } - -note: - ┌─ erc20_token.fe:98:5 - │ -98 │ ╭ fn _before_token_transfer(from: address, to: address, _ value: u256): -99 │ │ return - │ ╰──────────────^ attributes hash: 10552855728897650120 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "from", - typ: Ok( - Base( - Address, - ), - ), - }, - FunctionParam { - label: None, - name: "to", - typ: Ok( - Base( - Address, - ), - ), - }, - FunctionParam { - label: Some( - "_", - ), - name: "value", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } + ┌─ erc20_token.fe:99:16 + │ + 99 │ assert account != address(0) + │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value +100 │ _before_token_transfer(from: account, to: address(0), value) + │ ^^^^^^^ ^ u256: Value + │ │ + │ address: Value + +note: + ┌─ erc20_token.fe:100:51 + │ +100 │ _before_token_transfer(from: account, to: address(0), value) + │ ^^^^^^^^^^ ^^^^^ u256: Value + │ │ + │ address: Value + +note: + ┌─ erc20_token.fe:100:9 + │ +100 │ _before_token_transfer(from: account, to: address(0), value) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value +101 │ self._balances[account] = self._balances[account] - value + │ ^^^^ ERC20: Value + +note: + ┌─ erc20_token.fe:101:9 + │ +101 │ self._balances[account] = self._balances[account] - value + │ ^^^^^^^^^^^^^^ ^^^^^^^ address: Value + │ │ + │ Map: Storage { nonce: Some(0) } + +note: + ┌─ erc20_token.fe:101:9 + │ +101 │ self._balances[account] = self._balances[account] - value + │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value + │ │ + │ u256: Storage { nonce: None } + +note: + ┌─ erc20_token.fe:101:35 + │ +101 │ self._balances[account] = self._balances[account] - value + │ ^^^^^^^^^^^^^^ ^^^^^^^ address: Value + │ │ + │ Map: Storage { nonce: Some(0) } + +note: + ┌─ erc20_token.fe:101:35 + │ +101 │ self._balances[account] = self._balances[account] - value + │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value + │ │ + │ u256: Storage { nonce: None } => Value + +note: + ┌─ erc20_token.fe:101:35 + │ +101 │ self._balances[account] = self._balances[account] - value + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +102 │ self._total_supply = self._total_supply - value + │ ^^^^ ERC20: Value + +note: + ┌─ erc20_token.fe:102:9 + │ +102 │ self._total_supply = self._total_supply - value + │ ^^^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value + │ │ + │ u256: Storage { nonce: Some(2) } + +note: + ┌─ erc20_token.fe:102:30 + │ +102 │ self._total_supply = self._total_supply - value + │ ^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value + │ │ + │ u256: Storage { nonce: Some(2) } => Value + +note: + ┌─ erc20_token.fe:102:30 + │ +102 │ self._total_supply = self._total_supply - value + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +103 │ emit Transfer(ctx, from: account, to: address(0), value) + │ ^^^ ^^^^^^^ ^ u256: Value + │ │ │ + │ │ address: Value + │ Context: Memory + +note: + ┌─ erc20_token.fe:103:47 + │ +103 │ emit Transfer(ctx, from: account, to: address(0), value) + │ ^^^^^^^^^^ ^^^^^ u256: Value + │ │ + │ address: Value + +note: + ┌─ erc20_token.fe:103:9 + │ +103 │ emit Transfer(ctx, from: account, to: address(0), value) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 5533489995250141934 + │ + = Event { + name: "Transfer", + fields: [ + EventField { + name: "from", + typ: Ok( + Base( + Address, + ), + ), + is_indexed: true, + }, + EventField { + name: "to", + typ: Ok( + Base( + Address, + ), + ), + is_indexed: true, + }, + EventField { + name: "value", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + is_indexed: false, + }, + ], + } + +note: + ┌─ erc20_token.fe:106:5 + │ +106 │ ╭ fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { +107 │ │ assert owner != address(0) +108 │ │ assert spender != address(0) +109 │ │ self._allowances[owner][spender] = value +110 │ │ emit Approval(ctx, owner, spender, value) +111 │ │ } + │ ╰─────^ attributes hash: 1630416716014819616 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: Some( + Mutable, + ), + params: [ + FunctionParam { + label: None, + name: "ctx", + typ: Ok( + Struct( + Struct { + name: "Context", + field_count: 0, + }, + ), + ), + }, + FunctionParam { + label: None, + name: "owner", + typ: Ok( + Base( + Address, + ), + ), + }, + FunctionParam { + label: None, + name: "spender", + typ: Ok( + Base( + Address, + ), + ), + }, + FunctionParam { + label: None, + name: "value", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } + +note: + ┌─ erc20_token.fe:107:16 + │ +107 │ assert owner != address(0) + │ ^^^^^ ^ u256: Value + │ │ + │ address: Value + +note: + ┌─ erc20_token.fe:107:25 + │ +107 │ assert owner != address(0) + │ ^^^^^^^^^^ address: Value + +note: + ┌─ erc20_token.fe:107:16 + │ +107 │ assert owner != address(0) + │ ^^^^^^^^^^^^^^^^^^^ bool: Value +108 │ assert spender != address(0) + │ ^^^^^^^ ^ u256: Value + │ │ + │ address: Value + +note: + ┌─ erc20_token.fe:108:27 + │ +108 │ assert spender != address(0) + │ ^^^^^^^^^^ address: Value + +note: + ┌─ erc20_token.fe:108:16 + │ +108 │ assert spender != address(0) + │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value +109 │ self._allowances[owner][spender] = value + │ ^^^^ ERC20: Value + +note: + ┌─ erc20_token.fe:109:9 + │ +109 │ self._allowances[owner][spender] = value + │ ^^^^^^^^^^^^^^^^ ^^^^^ address: Value + │ │ + │ Map>: Storage { nonce: Some(1) } + +note: + ┌─ erc20_token.fe:109:9 + │ +109 │ self._allowances[owner][spender] = value + │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value + │ │ + │ Map: Storage { nonce: None } + +note: + ┌─ erc20_token.fe:109:9 + │ +109 │ self._allowances[owner][spender] = value + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value + │ │ + │ u256: Storage { nonce: None } +110 │ emit Approval(ctx, owner, spender, value) + │ ^^^ ^^^^^ ^^^^^^^ ^^^^^ u256: Value + │ │ │ │ + │ │ │ address: Value + │ │ address: Value + │ Context: Memory + +note: + ┌─ erc20_token.fe:110:9 + │ +110 │ emit Approval(ctx, owner, spender, value) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 8893313742751514912 + │ + = Event { + name: "Approval", + fields: [ + EventField { + name: "owner", + typ: Ok( + Base( + Address, + ), + ), + is_indexed: true, + }, + EventField { + name: "spender", + typ: Ok( + Base( + Address, + ), + ), + is_indexed: true, + }, + EventField { + name: "value", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + is_indexed: false, + }, + ], + } + +note: + ┌─ erc20_token.fe:113:5 + │ +113 │ ╭ fn _setup_decimals(self, _ decimals_: u8) { +114 │ │ self._decimals = decimals_ +115 │ │ } + │ ╰─────^ attributes hash: 2241116105643912660 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: None, + params: [ + FunctionParam { + label: Some( + "_", + ), + name: "decimals_", + typ: Ok( + Base( + Numeric( + U8, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } + +note: + ┌─ erc20_token.fe:114:9 + │ +114 │ self._decimals = decimals_ + │ ^^^^ ERC20: Value + +note: + ┌─ erc20_token.fe:114:9 + │ +114 │ self._decimals = decimals_ + │ ^^^^^^^^^^^^^^ ^^^^^^^^^ u8: Value + │ │ + │ u8: Storage { nonce: Some(5) } + +note: + ┌─ erc20_token.fe:117:5 + │ +117 │ fn _before_token_transfer(from: address, to: address, _ value: u256) {} + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 10552855728897650120 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "from", + typ: Ok( + Base( + Address, + ), + ), + }, + FunctionParam { + label: None, + name: "to", + typ: Ok( + Base( + Address, + ), + ), + }, + FunctionParam { + label: Some( + "_", + ), + name: "value", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } diff --git a/crates/analyzer/tests/snapshots/analysis__events.snap b/crates/analyzer/tests/snapshots/analysis__events.snap index fc6dc41b1e..b8b4b0633d 100644 --- a/crates/analyzer/tests/snapshots/analysis__events.snap +++ b/crates/analyzer/tests/snapshots/analysis__events.snap @@ -12,37 +12,38 @@ note: │ ^^^^^^^^^^ u256 note: - ┌─ events.fe:9:9 + ┌─ events.fe:10:9 │ - 9 │ num: u256 +10 │ num: u256 │ ^^^^^^^^^ u256 -10 │ addr: address +11 │ addr: address │ ^^^^^^^^^^^^^ address note: - ┌─ events.fe:13:9 + ┌─ events.fe:15:9 │ -13 │ num1: u256 +15 │ num1: u256 │ ^^^^^^^^^^ u256 -14 │ idx addr: address +16 │ idx addr: address │ ^^^^^^^^^^^^^^^^^ address -15 │ num2: u256 +17 │ num2: u256 │ ^^^^^^^^^^ u256 -16 │ my_bytes: Array +18 │ my_bytes: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^ Array note: - ┌─ events.fe:19:9 + ┌─ events.fe:22:9 │ -19 │ addrs: Array +22 │ addrs: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^ Array note: - ┌─ events.fe:21:5 + ┌─ events.fe:25:5 │ -21 │ ╭ pub fn emit_nums(ctx: Context): -22 │ │ emit Nums(ctx, num1: 26, num2: 42) - │ ╰──────────────────────────────────────────^ attributes hash: 5519676733853656531 +25 │ ╭ pub fn emit_nums(ctx: Context) { +26 │ │ emit Nums(ctx, num1: 26, num2: 42) +27 │ │ } + │ ╰─────^ attributes hash: 5519676733853656531 │ = FunctionSignature { self_decl: None, @@ -71,18 +72,18 @@ note: } note: - ┌─ events.fe:22:19 + ┌─ events.fe:26:19 │ -22 │ emit Nums(ctx, num1: 26, num2: 42) +26 │ emit Nums(ctx, num1: 26, num2: 42) │ ^^^ ^^ ^^ u256: Value │ │ │ │ │ u256: Value │ Context: Memory note: - ┌─ events.fe:22:9 + ┌─ events.fe:26:9 │ -22 │ emit Nums(ctx, num1: 26, num2: 42) +26 │ emit Nums(ctx, num1: 26, num2: 42) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 4681095448721924839 │ = Event { @@ -114,11 +115,12 @@ note: } note: - ┌─ events.fe:24:5 + ┌─ events.fe:29:5 │ -24 │ ╭ pub fn emit_bases(ctx: Context, addr: address): -25 │ │ emit Bases(ctx, num: 26, addr) - │ ╰──────────────────────────────────────^ attributes hash: 15383426943610850221 +29 │ ╭ pub fn emit_bases(ctx: Context, addr: address) { +30 │ │ emit Bases(ctx, num: 26, addr) +31 │ │ } + │ ╰─────^ attributes hash: 15383426943610850221 │ = FunctionSignature { self_decl: None, @@ -156,18 +158,18 @@ note: } note: - ┌─ events.fe:25:20 + ┌─ events.fe:30:20 │ -25 │ emit Bases(ctx, num: 26, addr) +30 │ emit Bases(ctx, num: 26, addr) │ ^^^ ^^ ^^^^ address: Value │ │ │ │ │ u256: Value │ Context: Memory note: - ┌─ events.fe:25:9 + ┌─ events.fe:30:9 │ -25 │ emit Bases(ctx, num: 26, addr) +30 │ emit Bases(ctx, num: 26, addr) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 4407350417102602838 │ = Event { @@ -197,11 +199,12 @@ note: } note: - ┌─ events.fe:27:5 + ┌─ events.fe:33:5 │ -27 │ ╭ pub fn emit_mix(ctx: Context, addr: address, my_bytes: Array): -28 │ │ emit Mix(ctx, num1: 26, addr, num2: 42, my_bytes) - │ ╰─────────────────────────────────────────────────────────^ attributes hash: 9652612436637375041 +33 │ ╭ pub fn emit_mix(ctx: Context, addr: address, my_bytes: Array) { +34 │ │ emit Mix(ctx, num1: 26, addr, num2: 42, my_bytes) +35 │ │ } + │ ╰─────^ attributes hash: 9652612436637375041 │ = FunctionSignature { self_decl: None, @@ -253,9 +256,9 @@ note: } note: - ┌─ events.fe:28:18 + ┌─ events.fe:34:18 │ -28 │ emit Mix(ctx, num1: 26, addr, num2: 42, my_bytes) +34 │ emit Mix(ctx, num1: 26, addr, num2: 42, my_bytes) │ ^^^ ^^ ^^^^ ^^ ^^^^^^^^ Array: Memory │ │ │ │ │ │ │ │ │ u256: Value @@ -264,9 +267,9 @@ note: │ Context: Memory note: - ┌─ events.fe:28:9 + ┌─ events.fe:34:9 │ -28 │ emit Mix(ctx, num1: 26, addr, num2: 42, my_bytes) +34 │ emit Mix(ctx, num1: 26, addr, num2: 42, my_bytes) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 12006518826467385253 │ = Event { @@ -321,14 +324,15 @@ note: } note: - ┌─ events.fe:30:5 + ┌─ events.fe:37:5 │ -30 │ ╭ pub fn emit_addresses(ctx: Context, addr1: address, addr2: address): -31 │ │ let addrs: Array -32 │ │ addrs[0] = addr1 -33 │ │ addrs[1] = addr2 -34 │ │ emit Addresses(ctx, addrs) - │ ╰──────────────────────────────────^ attributes hash: 18438233211486921531 +37 │ ╭ pub fn emit_addresses(ctx: Context, addr1: address, addr2: address) { +38 │ │ let addrs: Array +39 │ │ addrs[0] = addr1 +40 │ │ addrs[1] = addr2 +41 │ │ emit Addresses(ctx, addrs) +42 │ │ } + │ ╰─────^ attributes hash: 18438233211486921531 │ = FunctionSignature { self_decl: None, @@ -375,47 +379,47 @@ note: } note: - ┌─ events.fe:31:20 + ┌─ events.fe:38:20 │ -31 │ let addrs: Array +38 │ let addrs: Array │ ^^^^^^^^^^^^^^^^^ Array note: - ┌─ events.fe:32:9 + ┌─ events.fe:39:9 │ -32 │ addrs[0] = addr1 +39 │ addrs[0] = addr1 │ ^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ events.fe:32:9 + ┌─ events.fe:39:9 │ -32 │ addrs[0] = addr1 +39 │ addrs[0] = addr1 │ ^^^^^^^^ ^^^^^ address: Value │ │ │ address: Memory -33 │ addrs[1] = addr2 +40 │ addrs[1] = addr2 │ ^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ events.fe:33:9 + ┌─ events.fe:40:9 │ -33 │ addrs[1] = addr2 +40 │ addrs[1] = addr2 │ ^^^^^^^^ ^^^^^ address: Value │ │ │ address: Memory -34 │ emit Addresses(ctx, addrs) +41 │ emit Addresses(ctx, addrs) │ ^^^ ^^^^^ Array: Memory │ │ │ Context: Memory note: - ┌─ events.fe:34:9 + ┌─ events.fe:41:9 │ -34 │ emit Addresses(ctx, addrs) +41 │ emit Addresses(ctx, addrs) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 17766225573703958283 │ = Event { diff --git a/crates/analyzer/tests/snapshots/analysis__external_contract.snap b/crates/analyzer/tests/snapshots/analysis__external_contract.snap index 49f62b9758..10037f97cc 100644 --- a/crates/analyzer/tests/snapshots/analysis__external_contract.snap +++ b/crates/analyzer/tests/snapshots/analysis__external_contract.snap @@ -14,11 +14,12 @@ note: │ ^^^^^^^^^^^^^^^^^^^^^ String<11> note: - ┌─ external_contract.fe:9:5 + ┌─ external_contract.fe:10:5 │ - 9 │ ╭ pub fn emit_event(ctx: Context, my_num: u256, my_addrs: Array, my_string: String<11>): -10 │ │ emit MyEvent(ctx, my_num, my_addrs, my_string) - │ ╰──────────────────────────────────────────────────────^ attributes hash: 14584319691445179306 +10 │ ╭ pub fn emit_event(ctx: Context, my_num: u256, my_addrs: Array, my_string: String<11>) { +11 │ │ emit MyEvent(ctx, my_num, my_addrs, my_string) +12 │ │ } + │ ╰─────^ attributes hash: 14584319691445179306 │ = FunctionSignature { self_decl: None, @@ -81,9 +82,9 @@ note: } note: - ┌─ external_contract.fe:10:22 + ┌─ external_contract.fe:11:22 │ -10 │ emit MyEvent(ctx, my_num, my_addrs, my_string) +11 │ emit MyEvent(ctx, my_num, my_addrs, my_string) │ ^^^ ^^^^^^ ^^^^^^^^ ^^^^^^^^^ String<11>: Memory │ │ │ │ │ │ │ Array: Memory @@ -91,9 +92,9 @@ note: │ Context: Memory note: - ┌─ external_contract.fe:10:9 + ┌─ external_contract.fe:11:9 │ -10 │ emit MyEvent(ctx, my_num, my_addrs, my_string) +11 │ emit MyEvent(ctx, my_num, my_addrs, my_string) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 3872046667435269452 │ = Event { @@ -137,15 +138,16 @@ note: } note: - ┌─ external_contract.fe:12:5 + ┌─ external_contract.fe:14:5 │ -12 │ ╭ pub fn build_array(a: u256, b: u256) -> Array: -13 │ │ let my_array: Array -14 │ │ my_array[0] = a -15 │ │ my_array[1] = a * b -16 │ │ my_array[2] = b -17 │ │ return my_array - │ ╰───────────────────────^ attributes hash: 14276910879408601208 +14 │ ╭ pub fn build_array(a: u256, b: u256) -> Array { +15 │ │ let my_array: Array +16 │ │ my_array[0] = a +17 │ │ my_array[1] = a * b +18 │ │ my_array[2] = b +19 │ │ return my_array +20 │ │ } + │ ╰─────^ attributes hash: 14276910879408601208 │ = FunctionSignature { self_decl: None, @@ -187,71 +189,68 @@ note: } note: - ┌─ external_contract.fe:13:23 + ┌─ external_contract.fe:15:23 │ -13 │ let my_array: Array +15 │ let my_array: Array │ ^^^^^^^^^^^^^^ Array note: - ┌─ external_contract.fe:14:9 + ┌─ external_contract.fe:16:9 │ -14 │ my_array[0] = a +16 │ my_array[0] = a │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ external_contract.fe:14:9 + ┌─ external_contract.fe:16:9 │ -14 │ my_array[0] = a +16 │ my_array[0] = a │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -15 │ my_array[1] = a * b +17 │ my_array[1] = a * b │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ external_contract.fe:15:9 + ┌─ external_contract.fe:17:9 │ -15 │ my_array[1] = a * b +17 │ my_array[1] = a * b │ ^^^^^^^^^^^ ^ ^ u256: Value │ │ │ │ │ u256: Value │ u256: Memory note: - ┌─ external_contract.fe:15:23 + ┌─ external_contract.fe:17:23 │ -15 │ my_array[1] = a * b +17 │ my_array[1] = a * b │ ^^^^^ u256: Value -16 │ my_array[2] = b +18 │ my_array[2] = b │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ external_contract.fe:16:9 + ┌─ external_contract.fe:18:9 │ -16 │ my_array[2] = b +18 │ my_array[2] = b │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -17 │ return my_array +19 │ return my_array │ ^^^^^^^^ Array: Memory note: - ┌─ external_contract.fe:20:5 + ┌─ external_contract.fe:24:5 │ -20 │ ╭ pub fn call_emit_event( -21 │ │ ctx: Context, -22 │ │ foo_address: address, -23 │ │ my_num: u256, - · │ -27 │ │ let foo: Foo = Foo(ctx, foo_address) -28 │ │ foo.emit_event(my_num, my_addrs, my_string) - │ ╰───────────────────────────────────────────────────^ attributes hash: 11744736773867210426 +24 │ ╭ pub fn call_emit_event(ctx: Context, foo_address: address, my_num: u256, my_addrs: Array, my_string: String<11>) { +25 │ │ let foo: Foo = Foo(ctx, foo_address) +26 │ │ foo.emit_event(my_num, my_addrs, my_string) +27 │ │ } + │ ╰─────^ attributes hash: 11744736773867210426 │ = FunctionSignature { self_decl: None, @@ -323,25 +322,25 @@ note: } note: - ┌─ external_contract.fe:27:18 + ┌─ external_contract.fe:25:18 │ -27 │ let foo: Foo = Foo(ctx, foo_address) +25 │ let foo: Foo = Foo(ctx, foo_address) │ ^^^ Foo note: - ┌─ external_contract.fe:27:28 + ┌─ external_contract.fe:25:28 │ -27 │ let foo: Foo = Foo(ctx, foo_address) +25 │ let foo: Foo = Foo(ctx, foo_address) │ ^^^ ^^^^^^^^^^^ address: Value │ │ │ Context: Memory note: - ┌─ external_contract.fe:27:24 + ┌─ external_contract.fe:25:24 │ -27 │ let foo: Foo = Foo(ctx, foo_address) +25 │ let foo: Foo = Foo(ctx, foo_address) │ ^^^^^^^^^^^^^^^^^^^^^ Foo: Value -28 │ foo.emit_event(my_num, my_addrs, my_string) +26 │ foo.emit_event(my_num, my_addrs, my_string) │ ^^^ ^^^^^^ ^^^^^^^^ ^^^^^^^^^ String<11>: Memory │ │ │ │ │ │ │ Array: Memory @@ -349,22 +348,19 @@ note: │ Foo: Value note: - ┌─ external_contract.fe:28:9 + ┌─ external_contract.fe:26:9 │ -28 │ foo.emit_event(my_num, my_addrs, my_string) +26 │ foo.emit_event(my_num, my_addrs, my_string) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value note: - ┌─ external_contract.fe:30:5 + ┌─ external_contract.fe:29:5 │ -30 │ ╭ pub fn call_build_array( -31 │ │ ctx: Context, -32 │ │ foo_address: address, -33 │ │ a: u256, - · │ -36 │ │ let foo: Foo = Foo(ctx, foo_address) -37 │ │ return foo.build_array(a, b) - │ ╰────────────────────────────────────^ attributes hash: 14801245347360386258 +29 │ ╭ pub fn call_build_array(ctx: Context, foo_address: address, a: u256, b: u256) -> Array { +30 │ │ let foo: Foo = Foo(ctx, foo_address) +31 │ │ return foo.build_array(a, b) +32 │ │ } + │ ╰─────^ attributes hash: 14801245347360386258 │ = FunctionSignature { self_decl: None, @@ -429,34 +425,34 @@ note: } note: - ┌─ external_contract.fe:36:18 + ┌─ external_contract.fe:30:18 │ -36 │ let foo: Foo = Foo(ctx, foo_address) +30 │ let foo: Foo = Foo(ctx, foo_address) │ ^^^ Foo note: - ┌─ external_contract.fe:36:28 + ┌─ external_contract.fe:30:28 │ -36 │ let foo: Foo = Foo(ctx, foo_address) +30 │ let foo: Foo = Foo(ctx, foo_address) │ ^^^ ^^^^^^^^^^^ address: Value │ │ │ Context: Memory note: - ┌─ external_contract.fe:36:24 + ┌─ external_contract.fe:30:24 │ -36 │ let foo: Foo = Foo(ctx, foo_address) +30 │ let foo: Foo = Foo(ctx, foo_address) │ ^^^^^^^^^^^^^^^^^^^^^ Foo: Value -37 │ return foo.build_array(a, b) +31 │ return foo.build_array(a, b) │ ^^^ ^ ^ u256: Value │ │ │ │ │ u256: Value │ Foo: Value note: - ┌─ external_contract.fe:37:16 + ┌─ external_contract.fe:31:16 │ -37 │ return foo.build_array(a, b) +31 │ return foo.build_array(a, b) │ ^^^^^^^^^^^^^^^^^^^^^ Array: Memory diff --git a/crates/analyzer/tests/snapshots/analysis__for_loop_with_break.snap b/crates/analyzer/tests/snapshots/analysis__for_loop_with_break.snap index 87eb86c651..56783e6d60 100644 --- a/crates/analyzer/tests/snapshots/analysis__for_loop_with_break.snap +++ b/crates/analyzer/tests/snapshots/analysis__for_loop_with_break.snap @@ -4,16 +4,16 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ for_loop_with_break.fe:3:5 + ┌─ for_loop_with_break.fe:2:5 │ - 3 │ ╭ pub fn bar() -> u256: - 4 │ │ let my_array: Array - 5 │ │ my_array[0] = 5 - 6 │ │ my_array[1] = 10 + 2 │ ╭ pub fn bar() -> u256 { + 3 │ │ let my_array: Array + 4 │ │ my_array[0] = 5 + 5 │ │ my_array[1] = 10 · │ -12 │ │ break -13 │ │ return sum - │ ╰──────────────────^ attributes hash: 6115314201970082834 +14 │ │ return sum +15 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -29,80 +29,80 @@ note: } note: - ┌─ for_loop_with_break.fe:4:23 + ┌─ for_loop_with_break.fe:3:23 │ -4 │ let my_array: Array +3 │ let my_array: Array │ ^^^^^^^^^^^^^^ Array · -8 │ let sum: u256 = 0 +7 │ let sum: u256 = 0 │ ^^^^ u256 note: - ┌─ for_loop_with_break.fe:5:9 + ┌─ for_loop_with_break.fe:4:9 │ -5 │ my_array[0] = 5 +4 │ my_array[0] = 5 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ for_loop_with_break.fe:5:9 + ┌─ for_loop_with_break.fe:4:9 │ -5 │ my_array[0] = 5 +4 │ my_array[0] = 5 │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -6 │ my_array[1] = 10 +5 │ my_array[1] = 10 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ for_loop_with_break.fe:6:9 + ┌─ for_loop_with_break.fe:5:9 │ -6 │ my_array[1] = 10 +5 │ my_array[1] = 10 │ ^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Memory -7 │ my_array[2] = 15 +6 │ my_array[2] = 15 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ for_loop_with_break.fe:7:9 - │ - 7 │ my_array[2] = 15 - │ ^^^^^^^^^^^ ^^ u256: Value - │ │ - │ u256: Memory - 8 │ let sum: u256 = 0 - │ ^ u256: Value - 9 │ for i in my_array: - │ ^^^^^^^^ Array: Memory -10 │ sum = sum + i - │ ^^^ ^^^ ^ u256: Value - │ │ │ - │ │ u256: Value - │ u256: Value + ┌─ for_loop_with_break.fe:6:9 + │ +6 │ my_array[2] = 15 + │ ^^^^^^^^^^^ ^^ u256: Value + │ │ + │ u256: Memory +7 │ let sum: u256 = 0 + │ ^ u256: Value +8 │ for i in my_array { + │ ^^^^^^^^ Array: Memory +9 │ sum = sum + i + │ ^^^ ^^^ ^ u256: Value + │ │ │ + │ │ u256: Value + │ u256: Value note: - ┌─ for_loop_with_break.fe:10:19 + ┌─ for_loop_with_break.fe:9:19 │ -10 │ sum = sum + i + 9 │ sum = sum + i │ ^^^^^^^ u256: Value -11 │ if sum == 15: +10 │ if sum == 15 { │ ^^^ ^^ u256: Value │ │ │ u256: Value note: - ┌─ for_loop_with_break.fe:11:16 + ┌─ for_loop_with_break.fe:10:16 │ -11 │ if sum == 15: +10 │ if sum == 15 { │ ^^^^^^^^^ bool: Value -12 │ break -13 │ return sum + · +14 │ return sum │ ^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__for_loop_with_continue.snap b/crates/analyzer/tests/snapshots/analysis__for_loop_with_continue.snap index 8cda06acd2..35eb020247 100644 --- a/crates/analyzer/tests/snapshots/analysis__for_loop_with_continue.snap +++ b/crates/analyzer/tests/snapshots/analysis__for_loop_with_continue.snap @@ -4,16 +4,16 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ for_loop_with_continue.fe:3:5 + ┌─ for_loop_with_continue.fe:2:5 │ - 3 │ ╭ pub fn bar() -> u256: - 4 │ │ let my_array: Array - 5 │ │ my_array[0] = 2 - 6 │ │ my_array[1] = 3 + 2 │ ╭ pub fn bar() -> u256 { + 3 │ │ let my_array: Array + 4 │ │ my_array[0] = 2 + 5 │ │ my_array[1] = 3 · │ -14 │ │ sum = sum + i -15 │ │ return sum - │ ╰──────────────────^ attributes hash: 6115314201970082834 +16 │ │ return sum +17 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -29,100 +29,100 @@ note: } note: - ┌─ for_loop_with_continue.fe:4:23 - │ - 4 │ let my_array: Array - │ ^^^^^^^^^^^^^^ Array - · -10 │ let sum: u256 = 0 - │ ^^^^ u256 + ┌─ for_loop_with_continue.fe:3:23 + │ +3 │ let my_array: Array + │ ^^^^^^^^^^^^^^ Array + · +9 │ let sum: u256 = 0 + │ ^^^^ u256 note: - ┌─ for_loop_with_continue.fe:5:9 + ┌─ for_loop_with_continue.fe:4:9 │ -5 │ my_array[0] = 2 +4 │ my_array[0] = 2 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ for_loop_with_continue.fe:5:9 + ┌─ for_loop_with_continue.fe:4:9 │ -5 │ my_array[0] = 2 +4 │ my_array[0] = 2 │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -6 │ my_array[1] = 3 +5 │ my_array[1] = 3 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ for_loop_with_continue.fe:6:9 + ┌─ for_loop_with_continue.fe:5:9 │ -6 │ my_array[1] = 3 +5 │ my_array[1] = 3 │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -7 │ my_array[2] = 5 +6 │ my_array[2] = 5 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ for_loop_with_continue.fe:7:9 + ┌─ for_loop_with_continue.fe:6:9 │ -7 │ my_array[2] = 5 +6 │ my_array[2] = 5 │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -8 │ my_array[3] = 6 +7 │ my_array[3] = 6 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ for_loop_with_continue.fe:8:9 + ┌─ for_loop_with_continue.fe:7:9 │ -8 │ my_array[3] = 6 +7 │ my_array[3] = 6 │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -9 │ my_array[4] = 9 +8 │ my_array[4] = 9 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ for_loop_with_continue.fe:9:9 + ┌─ for_loop_with_continue.fe:8:9 │ - 9 │ my_array[4] = 9 + 8 │ my_array[4] = 9 │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -10 │ let sum: u256 = 0 + 9 │ let sum: u256 = 0 │ ^ u256: Value -11 │ for i in my_array: +10 │ for i in my_array { │ ^^^^^^^^ Array: Memory -12 │ if i % 2 == 0: +11 │ if i % 2 == 0 { │ ^ ^ u256: Value │ │ │ u256: Value note: - ┌─ for_loop_with_continue.fe:12:16 + ┌─ for_loop_with_continue.fe:11:16 │ -12 │ if i % 2 == 0: +11 │ if i % 2 == 0 { │ ^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ for_loop_with_continue.fe:12:16 + ┌─ for_loop_with_continue.fe:11:16 │ -12 │ if i % 2 == 0: +11 │ if i % 2 == 0 { │ ^^^^^^^^^^ bool: Value -13 │ continue + · 14 │ sum = sum + i │ ^^^ ^^^ ^ u256: Value │ │ │ @@ -134,7 +134,8 @@ note: │ 14 │ sum = sum + i │ ^^^^^^^ u256: Value -15 │ return sum +15 │ } +16 │ return sum │ ^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__for_loop_with_static_array.snap b/crates/analyzer/tests/snapshots/analysis__for_loop_with_static_array.snap index baf2f9b2f3..e7618187d7 100644 --- a/crates/analyzer/tests/snapshots/analysis__for_loop_with_static_array.snap +++ b/crates/analyzer/tests/snapshots/analysis__for_loop_with_static_array.snap @@ -4,16 +4,16 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ for_loop_with_static_array.fe:3:5 + ┌─ for_loop_with_static_array.fe:2:5 │ - 3 │ ╭ pub fn bar() -> u256: - 4 │ │ let my_array: Array - 5 │ │ my_array[0] = 5 - 6 │ │ my_array[1] = 10 + 2 │ ╭ pub fn bar() -> u256 { + 3 │ │ let my_array: Array + 4 │ │ my_array[0] = 5 + 5 │ │ my_array[1] = 10 · │ -10 │ │ sum = sum + i 11 │ │ return sum - │ ╰──────────────────^ attributes hash: 6115314201970082834 +12 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -29,68 +29,69 @@ note: } note: - ┌─ for_loop_with_static_array.fe:4:23 + ┌─ for_loop_with_static_array.fe:3:23 │ -4 │ let my_array: Array +3 │ let my_array: Array │ ^^^^^^^^^^^^^^ Array · -8 │ let sum: u256 = 0 +7 │ let sum: u256 = 0 │ ^^^^ u256 note: - ┌─ for_loop_with_static_array.fe:5:9 + ┌─ for_loop_with_static_array.fe:4:9 │ -5 │ my_array[0] = 5 +4 │ my_array[0] = 5 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ for_loop_with_static_array.fe:5:9 + ┌─ for_loop_with_static_array.fe:4:9 │ -5 │ my_array[0] = 5 +4 │ my_array[0] = 5 │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -6 │ my_array[1] = 10 +5 │ my_array[1] = 10 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ for_loop_with_static_array.fe:6:9 + ┌─ for_loop_with_static_array.fe:5:9 │ -6 │ my_array[1] = 10 +5 │ my_array[1] = 10 │ ^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Memory -7 │ my_array[2] = 15 +6 │ my_array[2] = 15 │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ for_loop_with_static_array.fe:7:9 - │ - 7 │ my_array[2] = 15 - │ ^^^^^^^^^^^ ^^ u256: Value - │ │ - │ u256: Memory - 8 │ let sum: u256 = 0 - │ ^ u256: Value - 9 │ for i in my_array: - │ ^^^^^^^^ Array: Memory -10 │ sum = sum + i - │ ^^^ ^^^ ^ u256: Value - │ │ │ - │ │ u256: Value - │ u256: Value + ┌─ for_loop_with_static_array.fe:6:9 + │ +6 │ my_array[2] = 15 + │ ^^^^^^^^^^^ ^^ u256: Value + │ │ + │ u256: Memory +7 │ let sum: u256 = 0 + │ ^ u256: Value +8 │ for i in my_array { + │ ^^^^^^^^ Array: Memory +9 │ sum = sum + i + │ ^^^ ^^^ ^ u256: Value + │ │ │ + │ │ u256: Value + │ u256: Value note: - ┌─ for_loop_with_static_array.fe:10:19 + ┌─ for_loop_with_static_array.fe:9:19 │ -10 │ sum = sum + i + 9 │ sum = sum + i │ ^^^^^^^ u256: Value +10 │ } 11 │ return sum │ ^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__guest_book.snap b/crates/analyzer/tests/snapshots/analysis__guest_book.snap index d3f469144b..11bf5cb11f 100644 --- a/crates/analyzer/tests/snapshots/analysis__guest_book.snap +++ b/crates/analyzer/tests/snapshots/analysis__guest_book.snap @@ -16,15 +16,16 @@ note: │ ^^^^^^^^^^^^^^^^^^^^^ String<100> note: - ┌─ guest_book.fe:13:5 + ┌─ guest_book.fe:14:5 │ -13 │ ╭ pub fn sign(self, ctx: Context, book_msg: String<100>): -14 │ │ # All storage access is explicit using `self.` -15 │ │ self.messages[ctx.msg_sender()] = book_msg -16 │ │ -17 │ │ # Emit the `Signed` event -18 │ │ emit Signed(ctx, book_msg) - │ ╰──────────────────────────────────^ attributes hash: 12497999579229810685 +14 │ ╭ pub fn sign(self, ctx: Context, book_msg: String<100>) { +15 │ │ # All storage access is explicit using `self.` +16 │ │ self.messages[ctx.msg_sender()] = book_msg +17 │ │ +18 │ │ # Emit the `Signed` event +19 │ │ emit Signed(ctx, book_msg) +20 │ │ } + │ ╰─────^ attributes hash: 12497999579229810685 │ = FunctionSignature { self_decl: Some( @@ -66,42 +67,42 @@ note: } note: - ┌─ guest_book.fe:15:9 + ┌─ guest_book.fe:16:9 │ -15 │ self.messages[ctx.msg_sender()] = book_msg +16 │ self.messages[ctx.msg_sender()] = book_msg │ ^^^^ GuestBook: Value note: - ┌─ guest_book.fe:15:9 + ┌─ guest_book.fe:16:9 │ -15 │ self.messages[ctx.msg_sender()] = book_msg +16 │ self.messages[ctx.msg_sender()] = book_msg │ ^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map>: Storage { nonce: Some(0) } note: - ┌─ guest_book.fe:15:23 + ┌─ guest_book.fe:16:23 │ -15 │ self.messages[ctx.msg_sender()] = book_msg +16 │ self.messages[ctx.msg_sender()] = book_msg │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ guest_book.fe:15:9 + ┌─ guest_book.fe:16:9 │ -15 │ self.messages[ctx.msg_sender()] = book_msg +16 │ self.messages[ctx.msg_sender()] = book_msg │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ String<100>: Memory │ │ │ String<100>: Storage { nonce: None } · -18 │ emit Signed(ctx, book_msg) +19 │ emit Signed(ctx, book_msg) │ ^^^ ^^^^^^^^ String<100>: Memory │ │ │ Context: Memory note: - ┌─ guest_book.fe:18:9 + ┌─ guest_book.fe:19:9 │ -18 │ emit Signed(ctx, book_msg) +19 │ emit Signed(ctx, book_msg) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 3840771212935086148 │ = Event { @@ -122,13 +123,14 @@ note: } note: - ┌─ guest_book.fe:20:5 + ┌─ guest_book.fe:22:5 │ -20 │ ╭ pub fn get_msg(self, addr: address) -> String<100>: -21 │ │ # Copying data from storage to memory -22 │ │ # has to be done explicitly via `to_mem()` -23 │ │ return self.messages[addr].to_mem() - │ ╰───────────────────────────────────────────^ attributes hash: 3325224293767249368 +22 │ ╭ pub fn get_msg(self, addr: address) -> String<100> { +23 │ │ # Copying data from storage to memory +24 │ │ # has to be done explicitly via `to_mem()` +25 │ │ return self.messages[addr].to_mem() +26 │ │ } + │ ╰─────^ attributes hash: 3325224293767249368 │ = FunctionSignature { self_decl: Some( @@ -156,29 +158,29 @@ note: } note: - ┌─ guest_book.fe:23:16 + ┌─ guest_book.fe:25:16 │ -23 │ return self.messages[addr].to_mem() +25 │ return self.messages[addr].to_mem() │ ^^^^ GuestBook: Value note: - ┌─ guest_book.fe:23:16 + ┌─ guest_book.fe:25:16 │ -23 │ return self.messages[addr].to_mem() +25 │ return self.messages[addr].to_mem() │ ^^^^^^^^^^^^^ ^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(0) } note: - ┌─ guest_book.fe:23:16 + ┌─ guest_book.fe:25:16 │ -23 │ return self.messages[addr].to_mem() +25 │ return self.messages[addr].to_mem() │ ^^^^^^^^^^^^^^^^^^^ String<100>: Storage { nonce: None } note: - ┌─ guest_book.fe:23:16 + ┌─ guest_book.fe:25:16 │ -23 │ return self.messages[addr].to_mem() +25 │ return self.messages[addr].to_mem() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<100>: Storage { nonce: None } => Memory diff --git a/crates/analyzer/tests/snapshots/analysis__if_statement.snap b/crates/analyzer/tests/snapshots/analysis__if_statement.snap index 29a6a0cbad..47bb9f2829 100644 --- a/crates/analyzer/tests/snapshots/analysis__if_statement.snap +++ b/crates/analyzer/tests/snapshots/analysis__if_statement.snap @@ -4,14 +4,16 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ if_statement.fe:3:5 + ┌─ if_statement.fe:2:5 │ -3 │ ╭ pub fn bar(input: u256) -> u256: -4 │ │ if input > 5: -5 │ │ return 1 -6 │ │ else: -7 │ │ return 0 - │ ╰────────────────────^ attributes hash: 10660199954095577886 +2 │ ╭ pub fn bar(input: u256) -> u256 { +3 │ │ if input > 5 { +4 │ │ return 1 +5 │ │ } else { +6 │ │ return 0 +7 │ │ } +8 │ │ } + │ ╰─────^ attributes hash: 10660199954095577886 │ = FunctionSignature { self_decl: None, @@ -39,22 +41,22 @@ note: } note: - ┌─ if_statement.fe:4:12 + ┌─ if_statement.fe:3:12 │ -4 │ if input > 5: +3 │ if input > 5 { │ ^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ if_statement.fe:4:12 + ┌─ if_statement.fe:3:12 │ -4 │ if input > 5: +3 │ if input > 5 { │ ^^^^^^^^^ bool: Value -5 │ return 1 +4 │ return 1 │ ^ u256: Value -6 │ else: -7 │ return 0 +5 │ } else { +6 │ return 0 │ ^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__if_statement_2.snap b/crates/analyzer/tests/snapshots/analysis__if_statement_2.snap index 325dfca1c3..5528c27edb 100644 --- a/crates/analyzer/tests/snapshots/analysis__if_statement_2.snap +++ b/crates/analyzer/tests/snapshots/analysis__if_statement_2.snap @@ -4,16 +4,16 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ if_statement_2.fe:3:5 + ┌─ if_statement_2.fe:2:5 │ -3 │ ╭ pub fn bar(val: u256) -> u256: -4 │ │ if val > 5: -5 │ │ return 1 -6 │ │ else: -7 │ │ assert true -8 │ │ -9 │ │ return 0 - │ ╰────────────────^ attributes hash: 12367727332255217641 +2 │ ╭ pub fn bar(val: u256) -> u256 { +3 │ │ if val > 5 { +4 │ │ return 1 +5 │ │ } else { + · │ +8 │ │ return 0 +9 │ │ } + │ ╰─────^ attributes hash: 12367727332255217641 │ = FunctionSignature { self_decl: None, @@ -41,25 +41,25 @@ note: } note: - ┌─ if_statement_2.fe:4:12 + ┌─ if_statement_2.fe:3:12 │ -4 │ if val > 5: +3 │ if val > 5 { │ ^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ if_statement_2.fe:4:12 + ┌─ if_statement_2.fe:3:12 │ -4 │ if val > 5: +3 │ if val > 5 { │ ^^^^^^^ bool: Value -5 │ return 1 +4 │ return 1 │ ^ u256: Value -6 │ else: -7 │ assert true +5 │ } else { +6 │ assert true │ ^^^^ bool: Value -8 │ -9 │ return 0 +7 │ } +8 │ return 0 │ ^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__if_statement_with_block_declaration.snap b/crates/analyzer/tests/snapshots/analysis__if_statement_with_block_declaration.snap index f8168eb92c..ed62510981 100644 --- a/crates/analyzer/tests/snapshots/analysis__if_statement_with_block_declaration.snap +++ b/crates/analyzer/tests/snapshots/analysis__if_statement_with_block_declaration.snap @@ -4,52 +4,52 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ if_statement_with_block_declaration.fe:3:5 - │ -3 │ ╭ pub fn bar() -> u256: -4 │ │ if true: -5 │ │ let y: u256 = 1 -6 │ │ return y -7 │ │ else: -8 │ │ let y: u256 = 1 -9 │ │ return y - │ ╰────────────────────^ attributes hash: 6115314201970082834 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [], - return_type: Ok( - Base( - Numeric( - U256, - ), - ), - ), - } + ┌─ if_statement_with_block_declaration.fe:2:5 + │ + 2 │ ╭ pub fn bar() -> u256 { + 3 │ │ if true { + 4 │ │ let y: u256 = 1 + 5 │ │ return y + · │ + 9 │ │ } +10 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [], + return_type: Ok( + Base( + Numeric( + U256, + ), + ), + ), + } note: - ┌─ if_statement_with_block_declaration.fe:5:20 + ┌─ if_statement_with_block_declaration.fe:4:20 │ -5 │ let y: u256 = 1 +4 │ let y: u256 = 1 │ ^^^^ u256 · -8 │ let y: u256 = 1 +7 │ let y: u256 = 1 │ ^^^^ u256 note: - ┌─ if_statement_with_block_declaration.fe:4:12 + ┌─ if_statement_with_block_declaration.fe:3:12 │ -4 │ if true: +3 │ if true { │ ^^^^ bool: Value -5 │ let y: u256 = 1 +4 │ let y: u256 = 1 │ ^ u256: Value -6 │ return y +5 │ return y │ ^ u256: Value -7 │ else: -8 │ let y: u256 = 1 +6 │ } else { +7 │ let y: u256 = 1 │ ^ u256: Value -9 │ return y +8 │ return y │ ^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__keccak.snap b/crates/analyzer/tests/snapshots/analysis__keccak.snap index d51510ad62..0710b6ac1d 100644 --- a/crates/analyzer/tests/snapshots/analysis__keccak.snap +++ b/crates/analyzer/tests/snapshots/analysis__keccak.snap @@ -4,11 +4,12 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ keccak.fe:3:5 + ┌─ keccak.fe:2:5 │ -3 │ ╭ pub fn return_hash_from_u8(val: Array) -> u256: -4 │ │ return keccak256(val) - │ ╰─────────────────────────────^ attributes hash: 6936681782057010951 +2 │ ╭ pub fn return_hash_from_u8(val: Array) -> u256 { +3 │ │ return keccak256(val) +4 │ │ } + │ ╰─────^ attributes hash: 6936681782057010951 │ = FunctionSignature { self_decl: None, @@ -39,23 +40,24 @@ note: } note: - ┌─ keccak.fe:4:26 + ┌─ keccak.fe:3:26 │ -4 │ return keccak256(val) +3 │ return keccak256(val) │ ^^^ Array: Memory note: - ┌─ keccak.fe:4:16 + ┌─ keccak.fe:3:16 │ -4 │ return keccak256(val) +3 │ return keccak256(val) │ ^^^^^^^^^^^^^^ u256: Value note: ┌─ keccak.fe:6:5 │ -6 │ ╭ pub fn return_hash_from_foo(val: Array) -> u256: +6 │ ╭ pub fn return_hash_from_foo(val: Array) -> u256 { 7 │ │ return keccak256(val) - │ ╰─────────────────────────────^ attributes hash: 10874278598381710302 +8 │ │ } + │ ╰─────^ attributes hash: 10874278598381710302 │ = FunctionSignature { self_decl: None, @@ -98,11 +100,12 @@ note: │ ^^^^^^^^^^^^^^ u256: Value note: - ┌─ keccak.fe:9:5 + ┌─ keccak.fe:10:5 │ - 9 │ ╭ pub fn return_hash_from_u256(val: Array) -> u256: -10 │ │ return keccak256(val) - │ ╰─────────────────────────────^ attributes hash: 1385099984461119772 +10 │ ╭ pub fn return_hash_from_u256(val: Array) -> u256 { +11 │ │ return keccak256(val) +12 │ │ } + │ ╰─────^ attributes hash: 1385099984461119772 │ = FunctionSignature { self_decl: None, @@ -133,15 +136,15 @@ note: } note: - ┌─ keccak.fe:10:26 + ┌─ keccak.fe:11:26 │ -10 │ return keccak256(val) +11 │ return keccak256(val) │ ^^^ Array: Memory note: - ┌─ keccak.fe:10:16 + ┌─ keccak.fe:11:16 │ -10 │ return keccak256(val) +11 │ return keccak256(val) │ ^^^^^^^^^^^^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__math.snap b/crates/analyzer/tests/snapshots/analysis__math.snap index 7a5b23f73a..85a771acf5 100644 --- a/crates/analyzer/tests/snapshots/analysis__math.snap +++ b/crates/analyzer/tests/snapshots/analysis__math.snap @@ -4,16 +4,16 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ math.fe:4:5 + ┌─ math.fe:2:5 │ - 4 │ ╭ pub fn sqrt(val: u256) -> u256: - 5 │ │ let z: u256 - 6 │ │ if (val > 3): - 7 │ │ z = val + 2 │ ╭ pub fn sqrt(val: u256) -> u256 { + 3 │ │ let z: u256 + 4 │ │ if val > 3 { + 5 │ │ z = val · │ -13 │ │ z = 1 14 │ │ return z - │ ╰────────────────^ attributes hash: 12367727332255217641 +15 │ │ } + │ ╰─────^ attributes hash: 12367727332255217641 │ = FunctionSignature { self_decl: None, @@ -41,113 +41,116 @@ note: } note: - ┌─ math.fe:5:16 + ┌─ math.fe:3:16 │ -5 │ let z: u256 +3 │ let z: u256 │ ^^^^ u256 · -8 │ let x: u256 = val / 2 + 1 +6 │ let x: u256 = val / 2 + 1 │ ^^^^ u256 note: - ┌─ math.fe:6:13 + ┌─ math.fe:4:12 │ -6 │ if (val > 3): - │ ^^^ ^ u256: Value - │ │ - │ u256: Value +4 │ if val > 3 { + │ ^^^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ math.fe:6:12 + ┌─ math.fe:4:12 │ -6 │ if (val > 3): - │ ^^^^^^^^^ bool: Value -7 │ z = val +4 │ if val > 3 { + │ ^^^^^^^ bool: Value +5 │ z = val │ ^ ^^^ u256: Value │ │ │ u256: Value -8 │ let x: u256 = val / 2 + 1 +6 │ let x: u256 = val / 2 + 1 │ ^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ math.fe:8:27 + ┌─ math.fe:6:27 │ -8 │ let x: u256 = val / 2 + 1 +6 │ let x: u256 = val / 2 + 1 │ ^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ math.fe:8:27 + ┌─ math.fe:6:27 │ -8 │ let x: u256 = val / 2 + 1 +6 │ let x: u256 = val / 2 + 1 │ ^^^^^^^^^^^ u256: Value -9 │ while (x < z): - │ ^ ^ u256: Value - │ │ - │ u256: Value +7 │ while x < z { + │ ^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ math.fe:9:19 - │ - 9 │ while (x < z): - │ ^^^^^^^ bool: Value -10 │ z = x - │ ^ ^ u256: Value - │ │ - │ u256: Value -11 │ x = (val / x + x) / 2 - │ ^ ^^^ ^ u256: Value - │ │ │ - │ │ u256: Value - │ u256: Value + ┌─ math.fe:7:19 + │ +7 │ while x < z { + │ ^^^^^ bool: Value +8 │ z = x + │ ^ ^ u256: Value + │ │ + │ u256: Value +9 │ x = (val / x + x) / 2 + │ ^ ^^^ ^ u256: Value + │ │ │ + │ │ u256: Value + │ u256: Value note: - ┌─ math.fe:11:22 - │ -11 │ x = (val / x + x) / 2 - │ ^^^^^^^ ^ u256: Value - │ │ - │ u256: Value + ┌─ math.fe:9:22 + │ +9 │ x = (val / x + x) / 2 + │ ^^^^^^^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ math.fe:11:21 - │ -11 │ x = (val / x + x) / 2 - │ ^^^^^^^^^^^^^ ^ u256: Value - │ │ - │ u256: Value + ┌─ math.fe:9:21 + │ +9 │ x = (val / x + x) / 2 + │ ^^^^^^^^^^^^^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ math.fe:11:21 + ┌─ math.fe:9:21 │ -11 │ x = (val / x + x) / 2 + 9 │ x = (val / x + x) / 2 │ ^^^^^^^^^^^^^^^^^ u256: Value -12 │ elif (val != 0): - │ ^^^ ^ u256: Value - │ │ - │ u256: Value +10 │ } +11 │ } else if val != 0 { + │ ^^^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ math.fe:12:14 + ┌─ math.fe:11:19 │ -12 │ elif (val != 0): - │ ^^^^^^^^^^ bool: Value -13 │ z = 1 +11 │ } else if val != 0 { + │ ^^^^^^^^ bool: Value +12 │ z = 1 │ ^ ^ u256: Value │ │ │ u256: Value +13 │ } 14 │ return z │ ^ u256: Value note: - ┌─ math.fe:16:5 + ┌─ math.fe:17:5 │ -16 │ ╭ pub fn min(x: u256, y: u256) -> u256: -17 │ │ return x if x < y else y - │ ╰────────────────────────────────^ attributes hash: 6847926207878778580 +17 │ ╭ pub fn min(x: u256, y: u256) -> u256 { +18 │ │ return x if x < y else y +19 │ │ } + │ ╰─────^ attributes hash: 6847926207878778580 │ = FunctionSignature { self_decl: None, @@ -186,26 +189,26 @@ note: } note: - ┌─ math.fe:17:21 + ┌─ math.fe:18:21 │ -17 │ return x if x < y else y +18 │ return x if x < y else y │ ^ ^ u256: Value │ │ │ u256: Value note: - ┌─ math.fe:17:16 + ┌─ math.fe:18:16 │ -17 │ return x if x < y else y +18 │ return x if x < y else y │ ^ ^^^^^ ^ u256: Value │ │ │ │ │ bool: Value │ u256: Value note: - ┌─ math.fe:17:16 + ┌─ math.fe:18:16 │ -17 │ return x if x < y else y +18 │ return x if x < y else y │ ^^^^^^^^^^^^^^^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__module_const.snap b/crates/analyzer/tests/snapshots/analysis__module_const.snap index 566e0b03c4..a499742650 100644 --- a/crates/analyzer/tests/snapshots/analysis__module_const.snap +++ b/crates/analyzer/tests/snapshots/analysis__module_const.snap @@ -10,39 +10,40 @@ note: │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array note: - ┌─ module_const.fe:2:1 + ┌─ module_const.fe:3:1 │ -2 │ const C1: i32 = 1 +3 │ const C1: i32 = 1 │ ^^^^^^^^^^^^^^^^^ i32 note: - ┌─ module_const.fe:3:1 + ┌─ module_const.fe:4:1 │ -3 │ const C2: i32 = C1 * 3 +4 │ const C2: i32 = C1 * 3 │ ^^^^^^^^^^^^^^^^^^^^^^ i32 note: - ┌─ module_const.fe:4:1 + ┌─ module_const.fe:5:1 │ -4 │ const C3: i32 = C4 + 2 +5 │ const C3: i32 = C4 + 2 │ ^^^^^^^^^^^^^^^^^^^^^^ i32 note: - ┌─ module_const.fe:5:1 + ┌─ module_const.fe:6:1 │ -5 │ const C4: i32 = 42 +6 │ const C4: i32 = 42 │ ^^^^^^^^^^^^^^^^^^ i32 note: - ┌─ module_const.fe:8:5 + ┌─ module_const.fe:9:5 │ - 8 │ ╭ fn bar() -> i32: - 9 │ │ const LOCAL_CONST: i32 = C3 * 2 -10 │ │ let _arr1: Array -11 │ │ let _arr2: Array -12 │ │ let _my_array: MY_ARRAY -13 │ │ return C4 - │ ╰─────────────────^ attributes hash: 18058099208132403133 + 9 │ ╭ fn bar() -> i32 { +10 │ │ const LOCAL_CONST: i32 = C3 * 2 +11 │ │ let _arr1: Array +12 │ │ let _arr2: Array +13 │ │ let _my_array: MY_ARRAY +14 │ │ return C4 +15 │ │ } + │ ╰─────^ attributes hash: 18058099208132403133 │ = FunctionSignature { self_decl: None, @@ -58,36 +59,36 @@ note: } note: - ┌─ module_const.fe:9:28 + ┌─ module_const.fe:10:28 │ - 9 │ const LOCAL_CONST: i32 = C3 * 2 +10 │ const LOCAL_CONST: i32 = C3 * 2 │ ^^^ i32 -10 │ let _arr1: Array +11 │ let _arr1: Array │ ^^^^^^^^^^^^^^^^^^ Array -11 │ let _arr2: Array +12 │ let _arr2: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array -12 │ let _my_array: MY_ARRAY +13 │ let _my_array: MY_ARRAY │ ^^^^^^^^ Array note: - ┌─ module_const.fe:9:34 - │ -9 │ const LOCAL_CONST: i32 = C3 * 2 - │ ^^ ^ i32: Value - │ │ - │ i32: Value + ┌─ module_const.fe:10:34 + │ +10 │ const LOCAL_CONST: i32 = C3 * 2 + │ ^^ ^ i32: Value + │ │ + │ i32: Value note: - ┌─ module_const.fe:9:34 + ┌─ module_const.fe:10:34 │ - 9 │ const LOCAL_CONST: i32 = C3 * 2 +10 │ const LOCAL_CONST: i32 = C3 * 2 │ ^^^^^^ i32: Value -10 │ let _arr1: Array +11 │ let _arr1: Array │ ^^ i32: Value -11 │ let _arr2: Array +12 │ let _arr2: Array │ ^^^^^^^^^^^ i32: Value -12 │ let _my_array: MY_ARRAY -13 │ return C4 +13 │ let _my_array: MY_ARRAY +14 │ return C4 │ ^^ i32: Value diff --git a/crates/analyzer/tests/snapshots/analysis__module_level_events.snap b/crates/analyzer/tests/snapshots/analysis__module_level_events.snap index 895ccdde7c..e18a99628b 100644 --- a/crates/analyzer/tests/snapshots/analysis__module_level_events.snap +++ b/crates/analyzer/tests/snapshots/analysis__module_level_events.snap @@ -14,11 +14,12 @@ note: │ ^^^^^^^^^^^ u256 note: - ┌─ module_level_events.fe:9:5 + ┌─ module_level_events.fe:10:5 │ - 9 │ ╭ fn transfer(ctx: Context, to : address, value : u256): -10 │ │ emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) - │ ╰─────────────────────────────────────────────────────────────────────────^ attributes hash: 10847004199357482546 +10 │ ╭ fn transfer(ctx: Context, to: address, value: u256) { +11 │ │ emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) +12 │ │ } + │ ╰─────^ attributes hash: 10847004199357482546 │ = FunctionSignature { self_decl: None, @@ -67,26 +68,26 @@ note: } note: - ┌─ module_level_events.fe:10:23 + ┌─ module_level_events.fe:11:23 │ -10 │ emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) +11 │ emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) │ ^^^ ^^^ Context: Memory │ │ │ Context: Memory note: - ┌─ module_level_events.fe:10:36 + ┌─ module_level_events.fe:11:36 │ -10 │ emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) +11 │ emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) │ ^^^^^^^^^^^^^^^^ ^^ ^^^^^ u256: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ module_level_events.fe:10:9 + ┌─ module_level_events.fe:11:9 │ -10 │ emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) +11 │ emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 17986960071624595337 │ = Event { diff --git a/crates/analyzer/tests/snapshots/analysis__multi_param.snap b/crates/analyzer/tests/snapshots/analysis__multi_param.snap index 40a6081d92..a36902db78 100644 --- a/crates/analyzer/tests/snapshots/analysis__multi_param.snap +++ b/crates/analyzer/tests/snapshots/analysis__multi_param.snap @@ -6,13 +6,14 @@ expression: "build_snapshot(&db, module)" note: ┌─ multi_param.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256, z: u256) -> Array: +2 │ ╭ pub fn bar(x: u256, y: u256, z: u256) -> Array { 3 │ │ let my_array: Array 4 │ │ my_array[0] = x 5 │ │ my_array[1] = y 6 │ │ my_array[2] = z 7 │ │ return my_array - │ ╰───────────────────────^ attributes hash: 10778435134172267300 +8 │ │ } + │ ╰─────^ attributes hash: 10778435134172267300 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__nested_map.snap b/crates/analyzer/tests/snapshots/analysis__nested_map.snap index 306a6f5f19..7dc9adc672 100644 --- a/crates/analyzer/tests/snapshots/analysis__nested_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__nested_map.snap @@ -14,9 +14,10 @@ note: note: ┌─ nested_map.fe:5:5 │ -5 │ ╭ pub fn read_bar(self, a: address, b: address) -> u256: +5 │ ╭ pub fn read_bar(self, a: address, b: address) -> u256 { 6 │ │ return self.bar[a][b] - │ ╰─────────────────────────────^ attributes hash: 17216960098647945084 +7 │ │ } + │ ╰─────^ attributes hash: 17216960098647945084 │ = FunctionSignature { self_decl: Some( @@ -81,91 +82,93 @@ note: │ ^^^^^^^^^^^^^^ u256: Storage { nonce: None } => Value note: - ┌─ nested_map.fe:8:5 - │ -8 │ ╭ pub fn write_bar(self, a: address, b: address, value: u256): -9 │ │ self.bar[a][b] = value - │ ╰──────────────────────────────^ attributes hash: 1717293224155577849 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "a", - typ: Ok( - Base( - Address, - ), - ), - }, - FunctionParam { - label: None, - name: "b", - typ: Ok( - Base( - Address, - ), - ), - }, - FunctionParam { - label: None, - name: "value", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } + ┌─ nested_map.fe:9:5 + │ + 9 │ ╭ pub fn write_bar(self, a: address, b: address, value: u256) { +10 │ │ self.bar[a][b] = value +11 │ │ } + │ ╰─────^ attributes hash: 1717293224155577849 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "a", + typ: Ok( + Base( + Address, + ), + ), + }, + FunctionParam { + label: None, + name: "b", + typ: Ok( + Base( + Address, + ), + ), + }, + FunctionParam { + label: None, + name: "value", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } note: - ┌─ nested_map.fe:9:9 - │ -9 │ self.bar[a][b] = value - │ ^^^^ Foo: Value + ┌─ nested_map.fe:10:9 + │ +10 │ self.bar[a][b] = value + │ ^^^^ Foo: Value note: - ┌─ nested_map.fe:9:9 - │ -9 │ self.bar[a][b] = value - │ ^^^^^^^^ ^ address: Value - │ │ - │ Map>: Storage { nonce: Some(0) } + ┌─ nested_map.fe:10:9 + │ +10 │ self.bar[a][b] = value + │ ^^^^^^^^ ^ address: Value + │ │ + │ Map>: Storage { nonce: Some(0) } note: - ┌─ nested_map.fe:9:9 - │ -9 │ self.bar[a][b] = value - │ ^^^^^^^^^^^ ^ address: Value - │ │ - │ Map: Storage { nonce: None } + ┌─ nested_map.fe:10:9 + │ +10 │ self.bar[a][b] = value + │ ^^^^^^^^^^^ ^ address: Value + │ │ + │ Map: Storage { nonce: None } note: - ┌─ nested_map.fe:9:9 - │ -9 │ self.bar[a][b] = value - │ ^^^^^^^^^^^^^^ ^^^^^ u256: Value - │ │ - │ u256: Storage { nonce: None } + ┌─ nested_map.fe:10:9 + │ +10 │ self.bar[a][b] = value + │ ^^^^^^^^^^^^^^ ^^^^^ u256: Value + │ │ + │ u256: Storage { nonce: None } note: - ┌─ nested_map.fe:11:5 + ┌─ nested_map.fe:13:5 │ -11 │ ╭ pub fn read_baz(self, a: address, b: u256) -> bool: -12 │ │ return self.baz[a][b] - │ ╰─────────────────────────────^ attributes hash: 13548986453815092160 +13 │ ╭ pub fn read_baz(self, a: address, b: u256) -> bool { +14 │ │ return self.baz[a][b] +15 │ │ } + │ ╰─────^ attributes hash: 13548986453815092160 │ = FunctionSignature { self_decl: Some( @@ -202,39 +205,40 @@ note: } note: - ┌─ nested_map.fe:12:16 + ┌─ nested_map.fe:14:16 │ -12 │ return self.baz[a][b] +14 │ return self.baz[a][b] │ ^^^^ Foo: Value note: - ┌─ nested_map.fe:12:16 + ┌─ nested_map.fe:14:16 │ -12 │ return self.baz[a][b] +14 │ return self.baz[a][b] │ ^^^^^^^^ ^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ nested_map.fe:12:16 + ┌─ nested_map.fe:14:16 │ -12 │ return self.baz[a][b] +14 │ return self.baz[a][b] │ ^^^^^^^^^^^ ^ u256: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ nested_map.fe:12:16 + ┌─ nested_map.fe:14:16 │ -12 │ return self.baz[a][b] +14 │ return self.baz[a][b] │ ^^^^^^^^^^^^^^ bool: Storage { nonce: None } => Value note: - ┌─ nested_map.fe:14:5 + ┌─ nested_map.fe:17:5 │ -14 │ ╭ pub fn write_baz(self, a: address, b: u256, value: bool): -15 │ │ self.baz[a][b] = value - │ ╰──────────────────────────────^ attributes hash: 6442389777288668179 +17 │ ╭ pub fn write_baz(self, a: address, b: u256, value: bool) { +18 │ │ self.baz[a][b] = value +19 │ │ } + │ ╰─────^ attributes hash: 6442389777288668179 │ = FunctionSignature { self_decl: Some( @@ -280,31 +284,31 @@ note: } note: - ┌─ nested_map.fe:15:9 + ┌─ nested_map.fe:18:9 │ -15 │ self.baz[a][b] = value +18 │ self.baz[a][b] = value │ ^^^^ Foo: Value note: - ┌─ nested_map.fe:15:9 + ┌─ nested_map.fe:18:9 │ -15 │ self.baz[a][b] = value +18 │ self.baz[a][b] = value │ ^^^^^^^^ ^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ nested_map.fe:15:9 + ┌─ nested_map.fe:18:9 │ -15 │ self.baz[a][b] = value +18 │ self.baz[a][b] = value │ ^^^^^^^^^^^ ^ u256: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ nested_map.fe:15:9 + ┌─ nested_map.fe:18:9 │ -15 │ self.baz[a][b] = value +18 │ self.baz[a][b] = value │ ^^^^^^^^^^^^^^ ^^^^^ bool: Value │ │ │ bool: Storage { nonce: None } diff --git a/crates/analyzer/tests/snapshots/analysis__numeric_sizes.snap b/crates/analyzer/tests/snapshots/analysis__numeric_sizes.snap index 1520eb3894..16b5b39c33 100644 --- a/crates/analyzer/tests/snapshots/analysis__numeric_sizes.snap +++ b/crates/analyzer/tests/snapshots/analysis__numeric_sizes.snap @@ -4,11 +4,12 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ numeric_sizes.fe:3:5 + ┌─ numeric_sizes.fe:2:5 │ -3 │ ╭ pub fn get_u8_min() -> u8: -4 │ │ return u8(0) - │ ╰────────────────────^ attributes hash: 18193502560299416939 +2 │ ╭ pub fn get_u8_min() -> u8 { +3 │ │ return u8(0) +4 │ │ } + │ ╰─────^ attributes hash: 18193502560299416939 │ = FunctionSignature { self_decl: None, @@ -24,23 +25,24 @@ note: } note: - ┌─ numeric_sizes.fe:4:19 + ┌─ numeric_sizes.fe:3:19 │ -4 │ return u8(0) +3 │ return u8(0) │ ^ u8: Value note: - ┌─ numeric_sizes.fe:4:16 + ┌─ numeric_sizes.fe:3:16 │ -4 │ return u8(0) +3 │ return u8(0) │ ^^^^^ u8: Value note: ┌─ numeric_sizes.fe:6:5 │ -6 │ ╭ pub fn get_u16_min() -> u16: +6 │ ╭ pub fn get_u16_min() -> u16 { 7 │ │ return u16(0) - │ ╰─────────────────────^ attributes hash: 3086088635989474166 +8 │ │ } + │ ╰─────^ attributes hash: 3086088635989474166 │ = FunctionSignature { self_decl: None, @@ -68,11 +70,12 @@ note: │ ^^^^^^ u16: Value note: - ┌─ numeric_sizes.fe:9:5 + ┌─ numeric_sizes.fe:10:5 │ - 9 │ ╭ pub fn get_u32_min() -> u32: -10 │ │ return u32(0) - │ ╰─────────────────────^ attributes hash: 1978352585063323439 +10 │ ╭ pub fn get_u32_min() -> u32 { +11 │ │ return u32(0) +12 │ │ } + │ ╰─────^ attributes hash: 1978352585063323439 │ = FunctionSignature { self_decl: None, @@ -88,23 +91,24 @@ note: } note: - ┌─ numeric_sizes.fe:10:20 + ┌─ numeric_sizes.fe:11:20 │ -10 │ return u32(0) +11 │ return u32(0) │ ^ u32: Value note: - ┌─ numeric_sizes.fe:10:16 + ┌─ numeric_sizes.fe:11:16 │ -10 │ return u32(0) +11 │ return u32(0) │ ^^^^^^ u32: Value note: - ┌─ numeric_sizes.fe:12:5 + ┌─ numeric_sizes.fe:14:5 │ -12 │ ╭ pub fn get_u64_min() -> u64: -13 │ │ return u64(0) - │ ╰─────────────────────^ attributes hash: 3966212821348382963 +14 │ ╭ pub fn get_u64_min() -> u64 { +15 │ │ return u64(0) +16 │ │ } + │ ╰─────^ attributes hash: 3966212821348382963 │ = FunctionSignature { self_decl: None, @@ -120,23 +124,24 @@ note: } note: - ┌─ numeric_sizes.fe:13:20 + ┌─ numeric_sizes.fe:15:20 │ -13 │ return u64(0) +15 │ return u64(0) │ ^ u64: Value note: - ┌─ numeric_sizes.fe:13:16 + ┌─ numeric_sizes.fe:15:16 │ -13 │ return u64(0) +15 │ return u64(0) │ ^^^^^^ u64: Value note: - ┌─ numeric_sizes.fe:15:5 + ┌─ numeric_sizes.fe:18:5 │ -15 │ ╭ pub fn get_u128_min() -> u128: -16 │ │ return u128(0) - │ ╰──────────────────────^ attributes hash: 104322826323649285 +18 │ ╭ pub fn get_u128_min() -> u128 { +19 │ │ return u128(0) +20 │ │ } + │ ╰─────^ attributes hash: 104322826323649285 │ = FunctionSignature { self_decl: None, @@ -152,23 +157,24 @@ note: } note: - ┌─ numeric_sizes.fe:16:21 + ┌─ numeric_sizes.fe:19:21 │ -16 │ return u128(0) +19 │ return u128(0) │ ^ u128: Value note: - ┌─ numeric_sizes.fe:16:16 + ┌─ numeric_sizes.fe:19:16 │ -16 │ return u128(0) +19 │ return u128(0) │ ^^^^^^^ u128: Value note: - ┌─ numeric_sizes.fe:18:5 + ┌─ numeric_sizes.fe:22:5 │ -18 │ ╭ pub fn get_u256_min() -> u256: -19 │ │ return u256(0) - │ ╰──────────────────────^ attributes hash: 6115314201970082834 +22 │ ╭ pub fn get_u256_min() -> u256 { +23 │ │ return u256(0) +24 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -184,23 +190,24 @@ note: } note: - ┌─ numeric_sizes.fe:19:21 + ┌─ numeric_sizes.fe:23:21 │ -19 │ return u256(0) +23 │ return u256(0) │ ^ u256: Value note: - ┌─ numeric_sizes.fe:19:16 + ┌─ numeric_sizes.fe:23:16 │ -19 │ return u256(0) +23 │ return u256(0) │ ^^^^^^^ u256: Value note: - ┌─ numeric_sizes.fe:21:5 + ┌─ numeric_sizes.fe:26:5 │ -21 │ ╭ pub fn get_i8_min() -> i8: -22 │ │ return i8(-128) - │ ╰───────────────────────^ attributes hash: 15762448841602984320 +26 │ ╭ pub fn get_i8_min() -> i8 { +27 │ │ return i8(-128) +28 │ │ } + │ ╰─────^ attributes hash: 15762448841602984320 │ = FunctionSignature { self_decl: None, @@ -216,29 +223,30 @@ note: } note: - ┌─ numeric_sizes.fe:22:20 + ┌─ numeric_sizes.fe:27:20 │ -22 │ return i8(-128) +27 │ return i8(-128) │ ^^^ u256: Value note: - ┌─ numeric_sizes.fe:22:19 + ┌─ numeric_sizes.fe:27:19 │ -22 │ return i8(-128) +27 │ return i8(-128) │ ^^^^ i8: Value note: - ┌─ numeric_sizes.fe:22:16 + ┌─ numeric_sizes.fe:27:16 │ -22 │ return i8(-128) +27 │ return i8(-128) │ ^^^^^^^^ i8: Value note: - ┌─ numeric_sizes.fe:24:5 + ┌─ numeric_sizes.fe:30:5 │ -24 │ ╭ pub fn get_i16_min() -> i16: -25 │ │ return i16(-32768) - │ ╰──────────────────────────^ attributes hash: 1032717434757427850 +30 │ ╭ pub fn get_i16_min() -> i16 { +31 │ │ return i16(-32768) +32 │ │ } + │ ╰─────^ attributes hash: 1032717434757427850 │ = FunctionSignature { self_decl: None, @@ -254,29 +262,30 @@ note: } note: - ┌─ numeric_sizes.fe:25:21 + ┌─ numeric_sizes.fe:31:21 │ -25 │ return i16(-32768) +31 │ return i16(-32768) │ ^^^^^ u256: Value note: - ┌─ numeric_sizes.fe:25:20 + ┌─ numeric_sizes.fe:31:20 │ -25 │ return i16(-32768) +31 │ return i16(-32768) │ ^^^^^^ i16: Value note: - ┌─ numeric_sizes.fe:25:16 + ┌─ numeric_sizes.fe:31:16 │ -25 │ return i16(-32768) +31 │ return i16(-32768) │ ^^^^^^^^^^^ i16: Value note: - ┌─ numeric_sizes.fe:27:5 + ┌─ numeric_sizes.fe:34:5 │ -27 │ ╭ pub fn get_i32_min() -> i32: -28 │ │ return i32(-2147483648) - │ ╰───────────────────────────────^ attributes hash: 18058099208132403133 +34 │ ╭ pub fn get_i32_min() -> i32 { +35 │ │ return i32(-2147483648) +36 │ │ } + │ ╰─────^ attributes hash: 18058099208132403133 │ = FunctionSignature { self_decl: None, @@ -292,29 +301,30 @@ note: } note: - ┌─ numeric_sizes.fe:28:21 + ┌─ numeric_sizes.fe:35:21 │ -28 │ return i32(-2147483648) +35 │ return i32(-2147483648) │ ^^^^^^^^^^ u256: Value note: - ┌─ numeric_sizes.fe:28:20 + ┌─ numeric_sizes.fe:35:20 │ -28 │ return i32(-2147483648) +35 │ return i32(-2147483648) │ ^^^^^^^^^^^ i32: Value note: - ┌─ numeric_sizes.fe:28:16 + ┌─ numeric_sizes.fe:35:16 │ -28 │ return i32(-2147483648) +35 │ return i32(-2147483648) │ ^^^^^^^^^^^^^^^^ i32: Value note: - ┌─ numeric_sizes.fe:30:5 + ┌─ numeric_sizes.fe:38:5 │ -30 │ ╭ pub fn get_i64_min() -> i64: -31 │ │ return i64(-9223372036854775808) - │ ╰────────────────────────────────────────^ attributes hash: 6774734901144681103 +38 │ ╭ pub fn get_i64_min() -> i64 { +39 │ │ return i64(-9223372036854775808) +40 │ │ } + │ ╰─────^ attributes hash: 6774734901144681103 │ = FunctionSignature { self_decl: None, @@ -330,29 +340,30 @@ note: } note: - ┌─ numeric_sizes.fe:31:21 + ┌─ numeric_sizes.fe:39:21 │ -31 │ return i64(-9223372036854775808) +39 │ return i64(-9223372036854775808) │ ^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ numeric_sizes.fe:31:20 + ┌─ numeric_sizes.fe:39:20 │ -31 │ return i64(-9223372036854775808) +39 │ return i64(-9223372036854775808) │ ^^^^^^^^^^^^^^^^^^^^ i64: Value note: - ┌─ numeric_sizes.fe:31:16 + ┌─ numeric_sizes.fe:39:16 │ -31 │ return i64(-9223372036854775808) +39 │ return i64(-9223372036854775808) │ ^^^^^^^^^^^^^^^^^^^^^^^^^ i64: Value note: - ┌─ numeric_sizes.fe:33:5 + ┌─ numeric_sizes.fe:42:5 │ -33 │ ╭ pub fn get_i128_min() -> i128: -34 │ │ return i128(-170141183460469231731687303715884105728) - │ ╰─────────────────────────────────────────────────────────────^ attributes hash: 155533728466856391 +42 │ ╭ pub fn get_i128_min() -> i128 { +43 │ │ return i128(-170141183460469231731687303715884105728) +44 │ │ } + │ ╰─────^ attributes hash: 155533728466856391 │ = FunctionSignature { self_decl: None, @@ -368,29 +379,30 @@ note: } note: - ┌─ numeric_sizes.fe:34:22 + ┌─ numeric_sizes.fe:43:22 │ -34 │ return i128(-170141183460469231731687303715884105728) +43 │ return i128(-170141183460469231731687303715884105728) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ numeric_sizes.fe:34:21 + ┌─ numeric_sizes.fe:43:21 │ -34 │ return i128(-170141183460469231731687303715884105728) +43 │ return i128(-170141183460469231731687303715884105728) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ i128: Value note: - ┌─ numeric_sizes.fe:34:16 + ┌─ numeric_sizes.fe:43:16 │ -34 │ return i128(-170141183460469231731687303715884105728) +43 │ return i128(-170141183460469231731687303715884105728) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ i128: Value note: - ┌─ numeric_sizes.fe:36:5 + ┌─ numeric_sizes.fe:46:5 │ -36 │ ╭ pub fn get_i256_min() -> i256: -37 │ │ return i256(-57896044618658097711785492504343953926634992332820282019728792003956564819968) - │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────^ attributes hash: 8116994679119332188 +46 │ ╭ pub fn get_i256_min() -> i256 { +47 │ │ return i256(-57896044618658097711785492504343953926634992332820282019728792003956564819968) +48 │ │ } + │ ╰─────^ attributes hash: 8116994679119332188 │ = FunctionSignature { self_decl: None, @@ -406,29 +418,30 @@ note: } note: - ┌─ numeric_sizes.fe:37:22 + ┌─ numeric_sizes.fe:47:22 │ -37 │ return i256(-57896044618658097711785492504343953926634992332820282019728792003956564819968) +47 │ return i256(-57896044618658097711785492504343953926634992332820282019728792003956564819968) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ numeric_sizes.fe:37:21 + ┌─ numeric_sizes.fe:47:21 │ -37 │ return i256(-57896044618658097711785492504343953926634992332820282019728792003956564819968) +47 │ return i256(-57896044618658097711785492504343953926634992332820282019728792003956564819968) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ i256: Value note: - ┌─ numeric_sizes.fe:37:16 + ┌─ numeric_sizes.fe:47:16 │ -37 │ return i256(-57896044618658097711785492504343953926634992332820282019728792003956564819968) +47 │ return i256(-57896044618658097711785492504343953926634992332820282019728792003956564819968) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ i256: Value note: - ┌─ numeric_sizes.fe:39:5 + ┌─ numeric_sizes.fe:50:5 │ -39 │ ╭ pub fn get_u8_max() -> u8: -40 │ │ return u8(255) - │ ╰──────────────────────^ attributes hash: 18193502560299416939 +50 │ ╭ pub fn get_u8_max() -> u8 { +51 │ │ return u8(255) +52 │ │ } + │ ╰─────^ attributes hash: 18193502560299416939 │ = FunctionSignature { self_decl: None, @@ -444,23 +457,24 @@ note: } note: - ┌─ numeric_sizes.fe:40:19 + ┌─ numeric_sizes.fe:51:19 │ -40 │ return u8(255) +51 │ return u8(255) │ ^^^ u8: Value note: - ┌─ numeric_sizes.fe:40:16 + ┌─ numeric_sizes.fe:51:16 │ -40 │ return u8(255) +51 │ return u8(255) │ ^^^^^^^ u8: Value note: - ┌─ numeric_sizes.fe:42:5 + ┌─ numeric_sizes.fe:54:5 │ -42 │ ╭ pub fn get_u16_max() -> u16: -43 │ │ return u16(65535) - │ ╰─────────────────────────^ attributes hash: 3086088635989474166 +54 │ ╭ pub fn get_u16_max() -> u16 { +55 │ │ return u16(65535) +56 │ │ } + │ ╰─────^ attributes hash: 3086088635989474166 │ = FunctionSignature { self_decl: None, @@ -476,23 +490,24 @@ note: } note: - ┌─ numeric_sizes.fe:43:20 + ┌─ numeric_sizes.fe:55:20 │ -43 │ return u16(65535) +55 │ return u16(65535) │ ^^^^^ u16: Value note: - ┌─ numeric_sizes.fe:43:16 + ┌─ numeric_sizes.fe:55:16 │ -43 │ return u16(65535) +55 │ return u16(65535) │ ^^^^^^^^^^ u16: Value note: - ┌─ numeric_sizes.fe:45:5 + ┌─ numeric_sizes.fe:58:5 │ -45 │ ╭ pub fn get_u32_max() -> u32: -46 │ │ return u32(4294967295) - │ ╰──────────────────────────────^ attributes hash: 1978352585063323439 +58 │ ╭ pub fn get_u32_max() -> u32 { +59 │ │ return u32(4294967295) +60 │ │ } + │ ╰─────^ attributes hash: 1978352585063323439 │ = FunctionSignature { self_decl: None, @@ -508,23 +523,24 @@ note: } note: - ┌─ numeric_sizes.fe:46:20 + ┌─ numeric_sizes.fe:59:20 │ -46 │ return u32(4294967295) +59 │ return u32(4294967295) │ ^^^^^^^^^^ u32: Value note: - ┌─ numeric_sizes.fe:46:16 + ┌─ numeric_sizes.fe:59:16 │ -46 │ return u32(4294967295) +59 │ return u32(4294967295) │ ^^^^^^^^^^^^^^^ u32: Value note: - ┌─ numeric_sizes.fe:48:5 + ┌─ numeric_sizes.fe:62:5 │ -48 │ ╭ pub fn get_u64_max() -> u64: -49 │ │ return u64(18446744073709551615) - │ ╰────────────────────────────────────────^ attributes hash: 3966212821348382963 +62 │ ╭ pub fn get_u64_max() -> u64 { +63 │ │ return u64(18446744073709551615) +64 │ │ } + │ ╰─────^ attributes hash: 3966212821348382963 │ = FunctionSignature { self_decl: None, @@ -540,23 +556,24 @@ note: } note: - ┌─ numeric_sizes.fe:49:20 + ┌─ numeric_sizes.fe:63:20 │ -49 │ return u64(18446744073709551615) +63 │ return u64(18446744073709551615) │ ^^^^^^^^^^^^^^^^^^^^ u64: Value note: - ┌─ numeric_sizes.fe:49:16 + ┌─ numeric_sizes.fe:63:16 │ -49 │ return u64(18446744073709551615) +63 │ return u64(18446744073709551615) │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u64: Value note: - ┌─ numeric_sizes.fe:51:5 + ┌─ numeric_sizes.fe:66:5 │ -51 │ ╭ pub fn get_u128_max() -> u128: -52 │ │ return u128(340282366920938463463374607431768211455) - │ ╰────────────────────────────────────────────────────────────^ attributes hash: 104322826323649285 +66 │ ╭ pub fn get_u128_max() -> u128 { +67 │ │ return u128(340282366920938463463374607431768211455) +68 │ │ } + │ ╰─────^ attributes hash: 104322826323649285 │ = FunctionSignature { self_decl: None, @@ -572,23 +589,24 @@ note: } note: - ┌─ numeric_sizes.fe:52:21 + ┌─ numeric_sizes.fe:67:21 │ -52 │ return u128(340282366920938463463374607431768211455) +67 │ return u128(340282366920938463463374607431768211455) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u128: Value note: - ┌─ numeric_sizes.fe:52:16 + ┌─ numeric_sizes.fe:67:16 │ -52 │ return u128(340282366920938463463374607431768211455) +67 │ return u128(340282366920938463463374607431768211455) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u128: Value note: - ┌─ numeric_sizes.fe:54:5 + ┌─ numeric_sizes.fe:70:5 │ -54 │ ╭ pub fn get_u256_max() -> u256: -55 │ │ return u256(115792089237316195423570985008687907853269984665640564039457584007913129639935) - │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────^ attributes hash: 6115314201970082834 +70 │ ╭ pub fn get_u256_max() -> u256 { +71 │ │ return u256(115792089237316195423570985008687907853269984665640564039457584007913129639935) +72 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -604,23 +622,24 @@ note: } note: - ┌─ numeric_sizes.fe:55:21 + ┌─ numeric_sizes.fe:71:21 │ -55 │ return u256(115792089237316195423570985008687907853269984665640564039457584007913129639935) +71 │ return u256(115792089237316195423570985008687907853269984665640564039457584007913129639935) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ numeric_sizes.fe:55:16 + ┌─ numeric_sizes.fe:71:16 │ -55 │ return u256(115792089237316195423570985008687907853269984665640564039457584007913129639935) +71 │ return u256(115792089237316195423570985008687907853269984665640564039457584007913129639935) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ numeric_sizes.fe:57:5 + ┌─ numeric_sizes.fe:74:5 │ -57 │ ╭ pub fn get_i8_max() -> i8: -58 │ │ return i8(127) - │ ╰──────────────────────^ attributes hash: 15762448841602984320 +74 │ ╭ pub fn get_i8_max() -> i8 { +75 │ │ return i8(127) +76 │ │ } + │ ╰─────^ attributes hash: 15762448841602984320 │ = FunctionSignature { self_decl: None, @@ -636,23 +655,24 @@ note: } note: - ┌─ numeric_sizes.fe:58:19 + ┌─ numeric_sizes.fe:75:19 │ -58 │ return i8(127) +75 │ return i8(127) │ ^^^ i8: Value note: - ┌─ numeric_sizes.fe:58:16 + ┌─ numeric_sizes.fe:75:16 │ -58 │ return i8(127) +75 │ return i8(127) │ ^^^^^^^ i8: Value note: - ┌─ numeric_sizes.fe:60:5 + ┌─ numeric_sizes.fe:78:5 │ -60 │ ╭ pub fn get_i16_max() -> i16: -61 │ │ return i16(32767) - │ ╰─────────────────────────^ attributes hash: 1032717434757427850 +78 │ ╭ pub fn get_i16_max() -> i16 { +79 │ │ return i16(32767) +80 │ │ } + │ ╰─────^ attributes hash: 1032717434757427850 │ = FunctionSignature { self_decl: None, @@ -668,23 +688,24 @@ note: } note: - ┌─ numeric_sizes.fe:61:20 + ┌─ numeric_sizes.fe:79:20 │ -61 │ return i16(32767) +79 │ return i16(32767) │ ^^^^^ i16: Value note: - ┌─ numeric_sizes.fe:61:16 + ┌─ numeric_sizes.fe:79:16 │ -61 │ return i16(32767) +79 │ return i16(32767) │ ^^^^^^^^^^ i16: Value note: - ┌─ numeric_sizes.fe:63:5 + ┌─ numeric_sizes.fe:82:5 │ -63 │ ╭ pub fn get_i32_max() -> i32: -64 │ │ return i32(2147483647) - │ ╰──────────────────────────────^ attributes hash: 18058099208132403133 +82 │ ╭ pub fn get_i32_max() -> i32 { +83 │ │ return i32(2147483647) +84 │ │ } + │ ╰─────^ attributes hash: 18058099208132403133 │ = FunctionSignature { self_decl: None, @@ -700,23 +721,24 @@ note: } note: - ┌─ numeric_sizes.fe:64:20 + ┌─ numeric_sizes.fe:83:20 │ -64 │ return i32(2147483647) +83 │ return i32(2147483647) │ ^^^^^^^^^^ i32: Value note: - ┌─ numeric_sizes.fe:64:16 + ┌─ numeric_sizes.fe:83:16 │ -64 │ return i32(2147483647) +83 │ return i32(2147483647) │ ^^^^^^^^^^^^^^^ i32: Value note: - ┌─ numeric_sizes.fe:66:5 + ┌─ numeric_sizes.fe:86:5 │ -66 │ ╭ pub fn get_i64_max() -> i64: -67 │ │ return i64(9223372036854775807) - │ ╰───────────────────────────────────────^ attributes hash: 6774734901144681103 +86 │ ╭ pub fn get_i64_max() -> i64 { +87 │ │ return i64(9223372036854775807) +88 │ │ } + │ ╰─────^ attributes hash: 6774734901144681103 │ = FunctionSignature { self_decl: None, @@ -732,23 +754,24 @@ note: } note: - ┌─ numeric_sizes.fe:67:20 + ┌─ numeric_sizes.fe:87:20 │ -67 │ return i64(9223372036854775807) +87 │ return i64(9223372036854775807) │ ^^^^^^^^^^^^^^^^^^^ i64: Value note: - ┌─ numeric_sizes.fe:67:16 + ┌─ numeric_sizes.fe:87:16 │ -67 │ return i64(9223372036854775807) +87 │ return i64(9223372036854775807) │ ^^^^^^^^^^^^^^^^^^^^^^^^ i64: Value note: - ┌─ numeric_sizes.fe:69:5 + ┌─ numeric_sizes.fe:90:5 │ -69 │ ╭ pub fn get_i128_max() -> i128: -70 │ │ return i128(170141183460469231731687303715884105727) - │ ╰────────────────────────────────────────────────────────────^ attributes hash: 155533728466856391 +90 │ ╭ pub fn get_i128_max() -> i128 { +91 │ │ return i128(170141183460469231731687303715884105727) +92 │ │ } + │ ╰─────^ attributes hash: 155533728466856391 │ = FunctionSignature { self_decl: None, @@ -764,23 +787,24 @@ note: } note: - ┌─ numeric_sizes.fe:70:21 + ┌─ numeric_sizes.fe:91:21 │ -70 │ return i128(170141183460469231731687303715884105727) +91 │ return i128(170141183460469231731687303715884105727) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ i128: Value note: - ┌─ numeric_sizes.fe:70:16 + ┌─ numeric_sizes.fe:91:16 │ -70 │ return i128(170141183460469231731687303715884105727) +91 │ return i128(170141183460469231731687303715884105727) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ i128: Value note: - ┌─ numeric_sizes.fe:72:5 + ┌─ numeric_sizes.fe:94:5 │ -72 │ ╭ pub fn get_i256_max() -> i256: -73 │ │ return i256(57896044618658097711785492504343953926634992332820282019728792003956564819967) - │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────^ attributes hash: 8116994679119332188 +94 │ ╭ pub fn get_i256_max() -> i256 { +95 │ │ return i256(57896044618658097711785492504343953926634992332820282019728792003956564819967) +96 │ │ } + │ ╰─────^ attributes hash: 8116994679119332188 │ = FunctionSignature { self_decl: None, @@ -796,15 +820,15 @@ note: } note: - ┌─ numeric_sizes.fe:73:21 + ┌─ numeric_sizes.fe:95:21 │ -73 │ return i256(57896044618658097711785492504343953926634992332820282019728792003956564819967) +95 │ return i256(57896044618658097711785492504343953926634992332820282019728792003956564819967) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ i256: Value note: - ┌─ numeric_sizes.fe:73:16 + ┌─ numeric_sizes.fe:95:16 │ -73 │ return i256(57896044618658097711785492504343953926634992332820282019728792003956564819967) +95 │ return i256(57896044618658097711785492504343953926634992332820282019728792003956564819967) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ i256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__ownable.snap b/crates/analyzer/tests/snapshots/analysis__ownable.snap index 16db4871b8..196108b701 100644 --- a/crates/analyzer/tests/snapshots/analysis__ownable.snap +++ b/crates/analyzer/tests/snapshots/analysis__ownable.snap @@ -4,25 +4,26 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ ownable.fe:4:3 + ┌─ ownable.fe:4:5 │ -4 │ _owner: address - │ ^^^^^^^^^^^^^^^ address +4 │ _owner: address + │ ^^^^^^^^^^^^^^^ address note: - ┌─ ownable.fe:7:5 + ┌─ ownable.fe:7:9 │ -7 │ idx previousOwner: address - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ address -8 │ idx newOwner: address - │ ^^^^^^^^^^^^^^^^^^^^^ address +7 │ idx previousOwner: address + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ address +8 │ idx newOwner: address + │ ^^^^^^^^^^^^^^^^^^^^^ address note: - ┌─ ownable.fe:13:3 + ┌─ ownable.fe:15:5 │ -13 │ ╭ pub fn owner(self) -> address: -14 │ │ return self._owner - │ ╰──────────────────────^ attributes hash: 227275695522088782 +15 │ ╭ pub fn owner(self) -> address { +16 │ │ return self._owner +17 │ │ } + │ ╰─────^ attributes hash: 227275695522088782 │ = FunctionSignature { self_decl: Some( @@ -38,25 +39,26 @@ note: } note: - ┌─ ownable.fe:14:12 + ┌─ ownable.fe:16:16 │ -14 │ return self._owner - │ ^^^^ Ownable: Value +16 │ return self._owner + │ ^^^^ Ownable: Value note: - ┌─ ownable.fe:14:12 + ┌─ ownable.fe:16:16 │ -14 │ return self._owner - │ ^^^^^^^^^^^ address: Storage { nonce: Some(0) } => Value +16 │ return self._owner + │ ^^^^^^^^^^^ address: Storage { nonce: Some(0) } => Value note: - ┌─ ownable.fe:16:3 + ┌─ ownable.fe:19:5 │ -16 │ ╭ pub fn renounceOwnership(self, ctx: Context): -17 │ │ assert ctx.msg_sender() == self._owner -18 │ │ self._owner = address(0) -19 │ │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) - │ ╰─────────────────────────────────────────────────────────────────────────────────────────^ attributes hash: 1731341862738941170 +19 │ ╭ pub fn renounceOwnership(self, ctx: Context) { +20 │ │ assert ctx.msg_sender() == self._owner +21 │ │ self._owner = address(0) +22 │ │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) +23 │ │ } + │ ╰─────^ attributes hash: 1731341862738941170 │ = FunctionSignature { self_decl: Some( @@ -87,70 +89,70 @@ note: } note: - ┌─ ownable.fe:17:12 + ┌─ ownable.fe:20:16 │ -17 │ assert ctx.msg_sender() == self._owner - │ ^^^ Context: Memory +20 │ assert ctx.msg_sender() == self._owner + │ ^^^ Context: Memory note: - ┌─ ownable.fe:17:12 + ┌─ ownable.fe:20:16 │ -17 │ assert ctx.msg_sender() == self._owner - │ ^^^^^^^^^^^^^^^^ ^^^^ Ownable: Value - │ │ - │ address: Value +20 │ assert ctx.msg_sender() == self._owner + │ ^^^^^^^^^^^^^^^^ ^^^^ Ownable: Value + │ │ + │ address: Value note: - ┌─ ownable.fe:17:32 + ┌─ ownable.fe:20:36 │ -17 │ assert ctx.msg_sender() == self._owner - │ ^^^^^^^^^^^ address: Storage { nonce: Some(0) } => Value +20 │ assert ctx.msg_sender() == self._owner + │ ^^^^^^^^^^^ address: Storage { nonce: Some(0) } => Value note: - ┌─ ownable.fe:17:12 + ┌─ ownable.fe:20:16 │ -17 │ assert ctx.msg_sender() == self._owner - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -18 │ self._owner = address(0) - │ ^^^^ Ownable: Value +20 │ assert ctx.msg_sender() == self._owner + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value +21 │ self._owner = address(0) + │ ^^^^ Ownable: Value note: - ┌─ ownable.fe:18:5 + ┌─ ownable.fe:21:9 │ -18 │ self._owner = address(0) - │ ^^^^^^^^^^^ ^ u256: Value - │ │ - │ address: Storage { nonce: Some(0) } +21 │ self._owner = address(0) + │ ^^^^^^^^^^^ ^ u256: Value + │ │ + │ address: Storage { nonce: Some(0) } note: - ┌─ ownable.fe:18:19 + ┌─ ownable.fe:21:23 │ -18 │ self._owner = address(0) - │ ^^^^^^^^^^ address: Value -19 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) - │ ^^^ ^^^ Context: Memory - │ │ - │ Context: Memory +21 │ self._owner = address(0) + │ ^^^^^^^^^^ address: Value +22 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) + │ ^^^ ^^^ Context: Memory + │ │ + │ Context: Memory note: - ┌─ ownable.fe:19:51 + ┌─ ownable.fe:22:55 │ -19 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) - │ ^^^^^^^^^^^^^^^^ ^ u256: Value - │ │ - │ address: Value +22 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) + │ ^^^^^^^^^^^^^^^^ ^ u256: Value + │ │ + │ address: Value note: - ┌─ ownable.fe:19:79 + ┌─ ownable.fe:22:83 │ -19 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) - │ ^^^^^^^^^^ address: Value +22 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) + │ ^^^^^^^^^^ address: Value note: - ┌─ ownable.fe:19:5 + ┌─ ownable.fe:22:9 │ -19 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 12166912587337306484 +22 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 12166912587337306484 │ = Event { name: "OwnershipTransferred", @@ -177,14 +179,15 @@ note: } note: - ┌─ ownable.fe:21:3 + ┌─ ownable.fe:25:5 │ -21 │ ╭ pub fn transferOwnership(self, ctx: Context, newOwner: address): -22 │ │ assert ctx.msg_sender() == self._owner -23 │ │ assert newOwner != address(0) -24 │ │ self._owner = newOwner -25 │ │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner) - │ ╰─────────────────────────────────────────────────────────────────────────────^ attributes hash: 5690910393288515862 +25 │ ╭ pub fn transferOwnership(self, ctx: Context, newOwner: address) { +26 │ │ assert ctx.msg_sender() == self._owner +27 │ │ assert newOwner != address(0) +28 │ │ self._owner = newOwner +29 │ │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner) +30 │ │ } + │ ╰─────^ attributes hash: 5690910393288515862 │ = FunctionSignature { self_decl: Some( @@ -224,74 +227,74 @@ note: } note: - ┌─ ownable.fe:22:12 + ┌─ ownable.fe:26:16 │ -22 │ assert ctx.msg_sender() == self._owner - │ ^^^ Context: Memory +26 │ assert ctx.msg_sender() == self._owner + │ ^^^ Context: Memory note: - ┌─ ownable.fe:22:12 + ┌─ ownable.fe:26:16 │ -22 │ assert ctx.msg_sender() == self._owner - │ ^^^^^^^^^^^^^^^^ ^^^^ Ownable: Value - │ │ - │ address: Value +26 │ assert ctx.msg_sender() == self._owner + │ ^^^^^^^^^^^^^^^^ ^^^^ Ownable: Value + │ │ + │ address: Value note: - ┌─ ownable.fe:22:32 + ┌─ ownable.fe:26:36 │ -22 │ assert ctx.msg_sender() == self._owner - │ ^^^^^^^^^^^ address: Storage { nonce: Some(0) } => Value +26 │ assert ctx.msg_sender() == self._owner + │ ^^^^^^^^^^^ address: Storage { nonce: Some(0) } => Value note: - ┌─ ownable.fe:22:12 + ┌─ ownable.fe:26:16 │ -22 │ assert ctx.msg_sender() == self._owner - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -23 │ assert newOwner != address(0) - │ ^^^^^^^^ ^ u256: Value - │ │ - │ address: Value +26 │ assert ctx.msg_sender() == self._owner + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value +27 │ assert newOwner != address(0) + │ ^^^^^^^^ ^ u256: Value + │ │ + │ address: Value note: - ┌─ ownable.fe:23:24 + ┌─ ownable.fe:27:28 │ -23 │ assert newOwner != address(0) - │ ^^^^^^^^^^ address: Value +27 │ assert newOwner != address(0) + │ ^^^^^^^^^^ address: Value note: - ┌─ ownable.fe:23:12 + ┌─ ownable.fe:27:16 │ -23 │ assert newOwner != address(0) - │ ^^^^^^^^^^^^^^^^^^^^^^ bool: Value -24 │ self._owner = newOwner - │ ^^^^ Ownable: Value +27 │ assert newOwner != address(0) + │ ^^^^^^^^^^^^^^^^^^^^^^ bool: Value +28 │ self._owner = newOwner + │ ^^^^ Ownable: Value note: - ┌─ ownable.fe:24:5 + ┌─ ownable.fe:28:9 │ -24 │ self._owner = newOwner - │ ^^^^^^^^^^^ ^^^^^^^^ address: Value - │ │ - │ address: Storage { nonce: Some(0) } -25 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner) - │ ^^^ ^^^ Context: Memory - │ │ - │ Context: Memory +28 │ self._owner = newOwner + │ ^^^^^^^^^^^ ^^^^^^^^ address: Value + │ │ + │ address: Storage { nonce: Some(0) } +29 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner) + │ ^^^ ^^^ Context: Memory + │ │ + │ Context: Memory note: - ┌─ ownable.fe:25:51 + ┌─ ownable.fe:29:55 │ -25 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner) - │ ^^^^^^^^^^^^^^^^ ^^^^^^^^ address: Value - │ │ - │ address: Value +29 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner) + │ ^^^^^^^^^^^^^^^^ ^^^^^^^^ address: Value + │ │ + │ address: Value note: - ┌─ ownable.fe:25:5 + ┌─ ownable.fe:29:9 │ -25 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 12166912587337306484 +29 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 12166912587337306484 │ = Event { name: "OwnershipTransferred", diff --git a/crates/analyzer/tests/snapshots/analysis__pure_fn_standalone.snap b/crates/analyzer/tests/snapshots/analysis__pure_fn_standalone.snap index 65447c8bd1..9aaae04129 100644 --- a/crates/analyzer/tests/snapshots/analysis__pure_fn_standalone.snap +++ b/crates/analyzer/tests/snapshots/analysis__pure_fn_standalone.snap @@ -4,11 +4,12 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ pure_fn_standalone.fe:2:1 + ┌─ pure_fn_standalone.fe:1:1 │ -2 │ ╭ fn add_bonus(_ x: u256) -> u256: -3 │ │ return x + 10 - │ ╰─────────────────^ attributes hash: 4402553917254279762 +1 │ ╭ fn add_bonus(_ x: u256) -> u256 { +2 │ │ return x + 10 +3 │ │ } + │ ╰─^ attributes hash: 4402553917254279762 │ = FunctionSignature { self_decl: None, @@ -38,17 +39,17 @@ note: } note: - ┌─ pure_fn_standalone.fe:3:12 + ┌─ pure_fn_standalone.fe:2:12 │ -3 │ return x + 10 +2 │ return x + 10 │ ^ ^^ u256: Value │ │ │ u256: Value note: - ┌─ pure_fn_standalone.fe:3:12 + ┌─ pure_fn_standalone.fe:2:12 │ -3 │ return x + 10 +2 │ return x + 10 │ ^^^^^^ u256: Value note: @@ -62,12 +63,14 @@ note: note: ┌─ pure_fn_standalone.fe:9:5 │ - 9 │ ╭ fn add_points(self, _ user: address, _ val: u256): -10 │ │ if self.cool_users[user]: + 9 │ ╭ fn add_points(self, _ user: address, _ val: u256) { +10 │ │ if self.cool_users[user] { 11 │ │ self.points[user] += add_bonus(val) -12 │ │ else: +12 │ │ } else { 13 │ │ self.points[user] += val - │ ╰────────────────────────────────────^ attributes hash: 11016307003570025576 +14 │ │ } +15 │ │ } + │ ╰─────^ attributes hash: 11016307003570025576 │ = FunctionSignature { self_decl: Some( @@ -110,13 +113,13 @@ note: note: ┌─ pure_fn_standalone.fe:10:12 │ -10 │ if self.cool_users[user]: +10 │ if self.cool_users[user] { │ ^^^^ Foo: Value note: ┌─ pure_fn_standalone.fe:10:12 │ -10 │ if self.cool_users[user]: +10 │ if self.cool_users[user] { │ ^^^^^^^^^^^^^^^ ^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } @@ -124,7 +127,7 @@ note: note: ┌─ pure_fn_standalone.fe:10:12 │ -10 │ if self.cool_users[user]: +10 │ if self.cool_users[user] { │ ^^^^^^^^^^^^^^^^^^^^^ bool: Storage { nonce: None } => Value 11 │ self.points[user] += add_bonus(val) │ ^^^^ Foo: Value @@ -150,7 +153,7 @@ note: │ 11 │ self.points[user] += add_bonus(val) │ ^^^^^^^^^^^^^^ u256: Value -12 │ else: +12 │ } else { 13 │ self.points[user] += val │ ^^^^ Foo: Value @@ -171,15 +174,16 @@ note: │ u256: Storage { nonce: None } note: - ┌─ pure_fn_standalone.fe:15:5 + ┌─ pure_fn_standalone.fe:17:5 │ -15 │ ╭ pub fn bar(self, _ x: u256) -> u256: -16 │ │ let a: address = address(x) -17 │ │ self.add_points(a, 100) -18 │ │ self.cool_users[a] = true +17 │ ╭ pub fn bar(self, _ x: u256) -> u256 { +18 │ │ let a: address = address(x) 19 │ │ self.add_points(a, 100) -20 │ │ return self.points[a] - │ ╰─────────────────────────────^ attributes hash: 15237606768598971644 +20 │ │ self.cool_users[a] = true +21 │ │ self.add_points(a, 100) +22 │ │ return self.points[a] +23 │ │ } + │ ╰─────^ attributes hash: 15237606768598971644 │ = FunctionSignature { self_decl: Some( @@ -211,77 +215,77 @@ note: } note: - ┌─ pure_fn_standalone.fe:16:16 + ┌─ pure_fn_standalone.fe:18:16 │ -16 │ let a: address = address(x) +18 │ let a: address = address(x) │ ^^^^^^^ address note: - ┌─ pure_fn_standalone.fe:16:34 + ┌─ pure_fn_standalone.fe:18:34 │ -16 │ let a: address = address(x) +18 │ let a: address = address(x) │ ^ u256: Value note: - ┌─ pure_fn_standalone.fe:16:26 + ┌─ pure_fn_standalone.fe:18:26 │ -16 │ let a: address = address(x) +18 │ let a: address = address(x) │ ^^^^^^^^^^ address: Value -17 │ self.add_points(a, 100) +19 │ self.add_points(a, 100) │ ^^^^ ^ ^^^ u256: Value │ │ │ │ │ address: Value │ Foo: Value note: - ┌─ pure_fn_standalone.fe:17:9 + ┌─ pure_fn_standalone.fe:19:9 │ -17 │ self.add_points(a, 100) +19 │ self.add_points(a, 100) │ ^^^^^^^^^^^^^^^^^^^^^^^ (): Value -18 │ self.cool_users[a] = true +20 │ self.cool_users[a] = true │ ^^^^ Foo: Value note: - ┌─ pure_fn_standalone.fe:18:9 + ┌─ pure_fn_standalone.fe:20:9 │ -18 │ self.cool_users[a] = true +20 │ self.cool_users[a] = true │ ^^^^^^^^^^^^^^^ ^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ pure_fn_standalone.fe:18:9 + ┌─ pure_fn_standalone.fe:20:9 │ -18 │ self.cool_users[a] = true +20 │ self.cool_users[a] = true │ ^^^^^^^^^^^^^^^^^^ ^^^^ bool: Value │ │ │ bool: Storage { nonce: None } -19 │ self.add_points(a, 100) +21 │ self.add_points(a, 100) │ ^^^^ ^ ^^^ u256: Value │ │ │ │ │ address: Value │ Foo: Value note: - ┌─ pure_fn_standalone.fe:19:9 + ┌─ pure_fn_standalone.fe:21:9 │ -19 │ self.add_points(a, 100) +21 │ self.add_points(a, 100) │ ^^^^^^^^^^^^^^^^^^^^^^^ (): Value -20 │ return self.points[a] +22 │ return self.points[a] │ ^^^^ Foo: Value note: - ┌─ pure_fn_standalone.fe:20:16 + ┌─ pure_fn_standalone.fe:22:16 │ -20 │ return self.points[a] +22 │ return self.points[a] │ ^^^^^^^^^^^ ^ address: Value │ │ │ Map: Storage { nonce: Some(1) } note: - ┌─ pure_fn_standalone.fe:20:16 + ┌─ pure_fn_standalone.fe:22:16 │ -20 │ return self.points[a] +22 │ return self.points[a] │ ^^^^^^^^^^^^^^ u256: Storage { nonce: None } => Value diff --git a/crates/analyzer/tests/snapshots/analysis__return_addition_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_addition_i256.snap index caa43e4a8c..8d310d4a9a 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_addition_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_addition_i256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_addition_i256.fe:2:5 │ -2 │ ╭ pub fn bar(x: i256, y: i256) -> i256: +2 │ ╭ pub fn bar(x: i256, y: i256) -> i256 { 3 │ │ return x + y - │ ╰────────────────────^ attributes hash: 6924216180113238234 +4 │ │ } + │ ╰─────^ attributes hash: 6924216180113238234 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_addition_u128.snap b/crates/analyzer/tests/snapshots/analysis__return_addition_u128.snap index 931b6131fd..8c9e62ff12 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_addition_u128.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_addition_u128.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_addition_u128.fe:2:5 │ -2 │ ╭ pub fn bar(x: u128, y: u128) -> u128: +2 │ ╭ pub fn bar(x: u128, y: u128) -> u128 { 3 │ │ return x + y - │ ╰────────────────────^ attributes hash: 233274078014721184 +4 │ │ } + │ ╰─────^ attributes hash: 233274078014721184 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_addition_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_addition_u256.snap index 677863d0a9..7d75cce26d 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_addition_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_addition_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_addition_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> u256: +2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x + y - │ ╰────────────────────^ attributes hash: 6847926207878778580 +4 │ │ } + │ ╰─────^ attributes hash: 6847926207878778580 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_array.snap b/crates/analyzer/tests/snapshots/analysis__return_array.snap index 0ba625ef27..116f206e1b 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_array.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_array.snap @@ -6,11 +6,12 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_array.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256) -> Array: -3 │ │ let my_array: Array +2 │ ╭ pub fn bar(x: u256) -> Array { +3 │ │ let my_array: Array 4 │ │ my_array[3] = x 5 │ │ return my_array - │ ╰───────────────────────^ attributes hash: 5752237891839439208 +6 │ │ } + │ ╰─────^ attributes hash: 5752237891839439208 │ = FunctionSignature { self_decl: None, @@ -43,8 +44,8 @@ note: note: ┌─ return_array.fe:3:23 │ -3 │ let my_array: Array - │ ^^^^^^^^^^^^^ Array +3 │ let my_array: Array + │ ^^^^^^^^^^^^^^ Array note: ┌─ return_array.fe:4:9 diff --git a/crates/analyzer/tests/snapshots/analysis__return_bitwiseand_u128.snap b/crates/analyzer/tests/snapshots/analysis__return_bitwiseand_u128.snap index 61ab4d7179..b17725ad29 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bitwiseand_u128.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bitwiseand_u128.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_bitwiseand_u128.fe:2:5 │ -2 │ ╭ pub fn bar(x: u128, y: u128) -> u128: +2 │ ╭ pub fn bar(x: u128, y: u128) -> u128 { 3 │ │ return x & y - │ ╰────────────────────^ attributes hash: 233274078014721184 +4 │ │ } + │ ╰─────^ attributes hash: 233274078014721184 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_bitwiseand_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_bitwiseand_u256.snap index 496036ae09..d381fd8335 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bitwiseand_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bitwiseand_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_bitwiseand_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> u256: +2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x & y - │ ╰────────────────────^ attributes hash: 6847926207878778580 +4 │ │ } + │ ╰─────^ attributes hash: 6847926207878778580 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_bitwiseor_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_bitwiseor_u256.snap index 24504f7376..e12bd3c574 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bitwiseor_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bitwiseor_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_bitwiseor_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> u256: +2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x | y - │ ╰────────────────────^ attributes hash: 6847926207878778580 +4 │ │ } + │ ╰─────^ attributes hash: 6847926207878778580 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_bitwiseshl_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_bitwiseshl_u256.snap index 99c184973e..48f2db15f3 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bitwiseshl_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bitwiseshl_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_bitwiseshl_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> u256: +2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x << y - │ ╰─────────────────────^ attributes hash: 6847926207878778580 +4 │ │ } + │ ╰─────^ attributes hash: 6847926207878778580 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_i256.snap index eee6feaa6f..0629d6d210 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_i256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_bitwiseshr_i256.fe:2:5 │ -2 │ ╭ pub fn bar(x: i256, y: u256) -> i256: +2 │ ╭ pub fn bar(x: i256, y: u256) -> i256 { 3 │ │ return x >> y - │ ╰─────────────────────^ attributes hash: 12518870770702615859 +4 │ │ } + │ ╰─────^ attributes hash: 12518870770702615859 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_u256.snap index 39cac35ae8..ece7a0fffa 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_bitwiseshr_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> u256: +2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x >> y - │ ╰─────────────────────^ attributes hash: 6847926207878778580 +4 │ │ } + │ ╰─────^ attributes hash: 6847926207878778580 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_bitwisexor_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_bitwisexor_u256.snap index 3572bbabcf..c7ddf9c5d1 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bitwisexor_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bitwisexor_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_bitwisexor_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> u256: +2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x ^ y - │ ╰────────────────────^ attributes hash: 6847926207878778580 +4 │ │ } + │ ╰─────^ attributes hash: 6847926207878778580 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_bool_false.snap b/crates/analyzer/tests/snapshots/analysis__return_bool_false.snap index 1b61b301c4..d801e75048 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bool_false.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bool_false.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_bool_false.fe:2:5 │ -2 │ ╭ pub fn bar() -> bool: +2 │ ╭ pub fn bar() -> bool { 3 │ │ return false - │ ╰────────────────────^ attributes hash: 5583437014632790429 +4 │ │ } + │ ╰─────^ attributes hash: 5583437014632790429 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_bool_inverted.snap b/crates/analyzer/tests/snapshots/analysis__return_bool_inverted.snap index f35d2e1f2a..7078c985be 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bool_inverted.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bool_inverted.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_bool_inverted.fe:2:5 │ -2 │ ╭ pub fn bar(some_condition: bool) -> bool: +2 │ ╭ pub fn bar(some_condition: bool) -> bool { 3 │ │ return not some_condition - │ ╰─────────────────────────────────^ attributes hash: 9793001524182520011 +4 │ │ } + │ ╰─────^ attributes hash: 9793001524182520011 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_bool_op_and.snap b/crates/analyzer/tests/snapshots/analysis__return_bool_op_and.snap index 7799556e72..509378f776 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bool_op_and.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bool_op_and.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_bool_op_and.fe:2:5 │ -2 │ ╭ pub fn bar(x: bool, y: bool) -> bool: +2 │ ╭ pub fn bar(x: bool, y: bool) -> bool { 3 │ │ return x and y - │ ╰──────────────────────^ attributes hash: 3532809531490166398 +4 │ │ } + │ ╰─────^ attributes hash: 3532809531490166398 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_bool_op_or.snap b/crates/analyzer/tests/snapshots/analysis__return_bool_op_or.snap index 99ec8939a3..4aa2835080 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bool_op_or.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bool_op_or.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_bool_op_or.fe:2:5 │ -2 │ ╭ pub fn bar(x: bool, y: bool) -> bool: +2 │ ╭ pub fn bar(x: bool, y: bool) -> bool { 3 │ │ return x or y - │ ╰─────────────────────^ attributes hash: 3532809531490166398 +4 │ │ } + │ ╰─────^ attributes hash: 3532809531490166398 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_bool_true.snap b/crates/analyzer/tests/snapshots/analysis__return_bool_true.snap index e2be7bc30b..edaec429dc 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bool_true.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bool_true.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_bool_true.fe:2:5 │ -2 │ ╭ pub fn bar() -> bool: +2 │ ╭ pub fn bar() -> bool { 3 │ │ return true - │ ╰───────────────────^ attributes hash: 5583437014632790429 +4 │ │ } + │ ╰─────^ attributes hash: 5583437014632790429 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_builtin_attributes.snap b/crates/analyzer/tests/snapshots/analysis__return_builtin_attributes.snap index c2f39b2404..c23f50a552 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_builtin_attributes.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_builtin_attributes.snap @@ -4,11 +4,12 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ return_builtin_attributes.fe:5:5 + ┌─ return_builtin_attributes.fe:4:5 │ -5 │ ╭ pub fn base_fee(ctx: Context) -> u256: -6 │ │ return ctx.base_fee() - │ ╰─────────────────────────────^ attributes hash: 10526263819290319263 +4 │ ╭ pub fn base_fee(ctx: Context) -> u256 { +5 │ │ return ctx.base_fee() +6 │ │ } + │ ╰─────^ attributes hash: 10526263819290319263 │ = FunctionSignature { self_decl: None, @@ -39,49 +40,50 @@ note: } note: - ┌─ return_builtin_attributes.fe:6:16 + ┌─ return_builtin_attributes.fe:5:16 │ -6 │ return ctx.base_fee() +5 │ return ctx.base_fee() │ ^^^ Context: Memory note: - ┌─ return_builtin_attributes.fe:6:16 + ┌─ return_builtin_attributes.fe:5:16 │ -6 │ return ctx.base_fee() +5 │ return ctx.base_fee() │ ^^^^^^^^^^^^^^ u256: Value note: - ┌─ return_builtin_attributes.fe:8:5 - │ -8 │ ╭ pub fn coinbase(ctx: Context) -> address: -9 │ │ return ctx.block_coinbase() - │ ╰───────────────────────────────────^ attributes hash: 9364783648076633772 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: Some( - Mutable, - ), - params: [ - FunctionParam { - label: None, - name: "ctx", - typ: Ok( - Struct( - Struct { - name: "Context", - field_count: 0, - }, - ), - ), - }, - ], - return_type: Ok( - Base( - Address, - ), - ), - } + ┌─ return_builtin_attributes.fe:8:5 + │ + 8 │ ╭ pub fn coinbase(ctx: Context) -> address { + 9 │ │ return ctx.block_coinbase() +10 │ │ } + │ ╰─────^ attributes hash: 9364783648076633772 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: Some( + Mutable, + ), + params: [ + FunctionParam { + label: None, + name: "ctx", + typ: Ok( + Struct( + Struct { + name: "Context", + field_count: 0, + }, + ), + ), + }, + ], + return_type: Ok( + Base( + Address, + ), + ), + } note: ┌─ return_builtin_attributes.fe:9:16 @@ -96,11 +98,12 @@ note: │ ^^^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ return_builtin_attributes.fe:11:5 + ┌─ return_builtin_attributes.fe:12:5 │ -11 │ ╭ pub fn difficulty(ctx: Context) -> u256: -12 │ │ return ctx.block_difficulty() - │ ╰─────────────────────────────────────^ attributes hash: 10526263819290319263 +12 │ ╭ pub fn difficulty(ctx: Context) -> u256 { +13 │ │ return ctx.block_difficulty() +14 │ │ } + │ ╰─────^ attributes hash: 10526263819290319263 │ = FunctionSignature { self_decl: None, @@ -131,23 +134,24 @@ note: } note: - ┌─ return_builtin_attributes.fe:12:16 + ┌─ return_builtin_attributes.fe:13:16 │ -12 │ return ctx.block_difficulty() +13 │ return ctx.block_difficulty() │ ^^^ Context: Memory note: - ┌─ return_builtin_attributes.fe:12:16 + ┌─ return_builtin_attributes.fe:13:16 │ -12 │ return ctx.block_difficulty() +13 │ return ctx.block_difficulty() │ ^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ return_builtin_attributes.fe:14:5 + ┌─ return_builtin_attributes.fe:16:5 │ -14 │ ╭ pub fn number(ctx: Context) -> u256: -15 │ │ return ctx.block_number() - │ ╰─────────────────────────────────^ attributes hash: 10526263819290319263 +16 │ ╭ pub fn number(ctx: Context) -> u256 { +17 │ │ return ctx.block_number() +18 │ │ } + │ ╰─────^ attributes hash: 10526263819290319263 │ = FunctionSignature { self_decl: None, @@ -178,23 +182,24 @@ note: } note: - ┌─ return_builtin_attributes.fe:15:16 + ┌─ return_builtin_attributes.fe:17:16 │ -15 │ return ctx.block_number() +17 │ return ctx.block_number() │ ^^^ Context: Memory note: - ┌─ return_builtin_attributes.fe:15:16 + ┌─ return_builtin_attributes.fe:17:16 │ -15 │ return ctx.block_number() +17 │ return ctx.block_number() │ ^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ return_builtin_attributes.fe:17:5 + ┌─ return_builtin_attributes.fe:20:5 │ -17 │ ╭ pub fn timestamp(ctx: Context) -> u256: -18 │ │ return ctx.block_timestamp() - │ ╰────────────────────────────────────^ attributes hash: 10526263819290319263 +20 │ ╭ pub fn timestamp(ctx: Context) -> u256 { +21 │ │ return ctx.block_timestamp() +22 │ │ } + │ ╰─────^ attributes hash: 10526263819290319263 │ = FunctionSignature { self_decl: None, @@ -225,23 +230,24 @@ note: } note: - ┌─ return_builtin_attributes.fe:18:16 + ┌─ return_builtin_attributes.fe:21:16 │ -18 │ return ctx.block_timestamp() +21 │ return ctx.block_timestamp() │ ^^^ Context: Memory note: - ┌─ return_builtin_attributes.fe:18:16 + ┌─ return_builtin_attributes.fe:21:16 │ -18 │ return ctx.block_timestamp() +21 │ return ctx.block_timestamp() │ ^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ return_builtin_attributes.fe:20:5 + ┌─ return_builtin_attributes.fe:24:5 │ -20 │ ╭ pub fn chainid(ctx: Context) -> u256: -21 │ │ return ctx.chain_id() - │ ╰─────────────────────────────^ attributes hash: 10526263819290319263 +24 │ ╭ pub fn chainid(ctx: Context) -> u256 { +25 │ │ return ctx.chain_id() +26 │ │ } + │ ╰─────^ attributes hash: 10526263819290319263 │ = FunctionSignature { self_decl: None, @@ -272,23 +278,24 @@ note: } note: - ┌─ return_builtin_attributes.fe:21:16 + ┌─ return_builtin_attributes.fe:25:16 │ -21 │ return ctx.chain_id() +25 │ return ctx.chain_id() │ ^^^ Context: Memory note: - ┌─ return_builtin_attributes.fe:21:16 + ┌─ return_builtin_attributes.fe:25:16 │ -21 │ return ctx.chain_id() +25 │ return ctx.chain_id() │ ^^^^^^^^^^^^^^ u256: Value note: - ┌─ return_builtin_attributes.fe:23:5 + ┌─ return_builtin_attributes.fe:28:5 │ -23 │ ╭ pub fn sender(ctx: Context) -> address: -24 │ │ return ctx.msg_sender() - │ ╰───────────────────────────────^ attributes hash: 9364783648076633772 +28 │ ╭ pub fn sender(ctx: Context) -> address { +29 │ │ return ctx.msg_sender() +30 │ │ } + │ ╰─────^ attributes hash: 9364783648076633772 │ = FunctionSignature { self_decl: None, @@ -317,23 +324,24 @@ note: } note: - ┌─ return_builtin_attributes.fe:24:16 + ┌─ return_builtin_attributes.fe:29:16 │ -24 │ return ctx.msg_sender() +29 │ return ctx.msg_sender() │ ^^^ Context: Memory note: - ┌─ return_builtin_attributes.fe:24:16 + ┌─ return_builtin_attributes.fe:29:16 │ -24 │ return ctx.msg_sender() +29 │ return ctx.msg_sender() │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ return_builtin_attributes.fe:26:5 + ┌─ return_builtin_attributes.fe:32:5 │ -26 │ ╭ pub fn value(ctx: Context) -> u256: -27 │ │ return ctx.msg_value() - │ ╰──────────────────────────────^ attributes hash: 10526263819290319263 +32 │ ╭ pub fn value(ctx: Context) -> u256 { +33 │ │ return ctx.msg_value() +34 │ │ } + │ ╰─────^ attributes hash: 10526263819290319263 │ = FunctionSignature { self_decl: None, @@ -364,23 +372,24 @@ note: } note: - ┌─ return_builtin_attributes.fe:27:16 + ┌─ return_builtin_attributes.fe:33:16 │ -27 │ return ctx.msg_value() +33 │ return ctx.msg_value() │ ^^^ Context: Memory note: - ┌─ return_builtin_attributes.fe:27:16 + ┌─ return_builtin_attributes.fe:33:16 │ -27 │ return ctx.msg_value() +33 │ return ctx.msg_value() │ ^^^^^^^^^^^^^^^ u256: Value note: - ┌─ return_builtin_attributes.fe:29:5 + ┌─ return_builtin_attributes.fe:36:5 │ -29 │ ╭ pub fn origin(ctx: Context) -> address: -30 │ │ return ctx.tx_origin() - │ ╰──────────────────────────────^ attributes hash: 9364783648076633772 +36 │ ╭ pub fn origin(ctx: Context) -> address { +37 │ │ return ctx.tx_origin() +38 │ │ } + │ ╰─────^ attributes hash: 9364783648076633772 │ = FunctionSignature { self_decl: None, @@ -409,23 +418,24 @@ note: } note: - ┌─ return_builtin_attributes.fe:30:16 + ┌─ return_builtin_attributes.fe:37:16 │ -30 │ return ctx.tx_origin() +37 │ return ctx.tx_origin() │ ^^^ Context: Memory note: - ┌─ return_builtin_attributes.fe:30:16 + ┌─ return_builtin_attributes.fe:37:16 │ -30 │ return ctx.tx_origin() +37 │ return ctx.tx_origin() │ ^^^^^^^^^^^^^^^ address: Value note: - ┌─ return_builtin_attributes.fe:32:5 + ┌─ return_builtin_attributes.fe:40:5 │ -32 │ ╭ pub fn gas_price(ctx: Context) -> u256: -33 │ │ return ctx.tx_gas_price() - │ ╰─────────────────────────────────^ attributes hash: 10526263819290319263 +40 │ ╭ pub fn gas_price(ctx: Context) -> u256 { +41 │ │ return ctx.tx_gas_price() +42 │ │ } + │ ╰─────^ attributes hash: 10526263819290319263 │ = FunctionSignature { self_decl: None, @@ -456,15 +466,15 @@ note: } note: - ┌─ return_builtin_attributes.fe:33:16 + ┌─ return_builtin_attributes.fe:41:16 │ -33 │ return ctx.tx_gas_price() +41 │ return ctx.tx_gas_price() │ ^^^ Context: Memory note: - ┌─ return_builtin_attributes.fe:33:16 + ┌─ return_builtin_attributes.fe:41:16 │ -33 │ return ctx.tx_gas_price() +41 │ return ctx.tx_gas_price() │ ^^^^^^^^^^^^^^^^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__return_division_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_division_i256.snap index 9eaf889600..af84a0f319 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_division_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_division_i256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_division_i256.fe:2:5 │ -2 │ ╭ pub fn bar(x: i256, y: i256) -> i256: +2 │ ╭ pub fn bar(x: i256, y: i256) -> i256 { 3 │ │ return x / y - │ ╰────────────────────^ attributes hash: 6924216180113238234 +4 │ │ } + │ ╰─────^ attributes hash: 6924216180113238234 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_division_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_division_u256.snap index e12004a300..36546f2c8e 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_division_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_division_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_division_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> u256: +2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x / y - │ ╰────────────────────^ attributes hash: 6847926207878778580 +4 │ │ } + │ ╰─────^ attributes hash: 6847926207878778580 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_empty_tuple.snap b/crates/analyzer/tests/snapshots/analysis__return_empty_tuple.snap index 998348cdb1..fa0ab24158 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_empty_tuple.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_empty_tuple.snap @@ -4,11 +4,12 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ return_unit.fe:3:3 + ┌─ return_unit.fe:2:5 │ -3 │ ╭ pub fn explicit_return_a1(): -4 │ │ return - │ ╰──────────^ attributes hash: 8319796915330632390 +2 │ ╭ pub fn explicit_return_a1() { +3 │ │ return +4 │ │ } + │ ╰─────^ attributes hash: 8319796915330632390 │ = FunctionSignature { self_decl: None, @@ -22,11 +23,12 @@ note: } note: - ┌─ return_unit.fe:6:3 + ┌─ return_unit.fe:6:5 │ -6 │ ╭ pub fn explicit_return_a2(): -7 │ │ return () - │ ╰─────────────^ attributes hash: 8319796915330632390 +6 │ ╭ pub fn explicit_return_a2() { +7 │ │ return () +8 │ │ } + │ ╰─────^ attributes hash: 8319796915330632390 │ = FunctionSignature { self_decl: None, @@ -40,17 +42,18 @@ note: } note: - ┌─ return_unit.fe:7:12 + ┌─ return_unit.fe:7:16 │ -7 │ return () - │ ^^ (): Value +7 │ return () + │ ^^ (): Value note: - ┌─ return_unit.fe:9:3 + ┌─ return_unit.fe:10:5 │ - 9 │ ╭ pub fn explicit_return_b1() -> (): -10 │ │ return - │ ╰──────────^ attributes hash: 8319796915330632390 +10 │ ╭ pub fn explicit_return_b1() -> () { +11 │ │ return +12 │ │ } + │ ╰─────^ attributes hash: 8319796915330632390 │ = FunctionSignature { self_decl: None, @@ -64,11 +67,12 @@ note: } note: - ┌─ return_unit.fe:12:3 + ┌─ return_unit.fe:14:5 │ -12 │ ╭ pub fn explicit_return_b2() -> (): -13 │ │ return () - │ ╰─────────────^ attributes hash: 8319796915330632390 +14 │ ╭ pub fn explicit_return_b2() -> () { +15 │ │ return () +16 │ │ } + │ ╰─────^ attributes hash: 8319796915330632390 │ = FunctionSignature { self_decl: None, @@ -82,18 +86,17 @@ note: } note: - ┌─ return_unit.fe:13:12 + ┌─ return_unit.fe:15:16 │ -13 │ return () - │ ^^ (): Value +15 │ return () + │ ^^ (): Value note: - ┌─ return_unit.fe:15:3 - │ -15 │ ╭ pub fn implicit_a1(): -16 │ │ pass - │ ╰────────^ attributes hash: 8319796915330632390 - │ + ┌─ return_unit.fe:18:5 + │ +18 │ pub fn implicit_a1() {} + │ ^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 8319796915330632390 + │ = FunctionSignature { self_decl: None, ctx_decl: None, @@ -106,12 +109,11 @@ note: } note: - ┌─ return_unit.fe:18:3 - │ -18 │ ╭ pub fn implicit_a2() -> (): -19 │ │ pass - │ ╰────────^ attributes hash: 8319796915330632390 - │ + ┌─ return_unit.fe:20:5 + │ +20 │ pub fn implicit_a2() -> () {} + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 8319796915330632390 + │ = FunctionSignature { self_decl: None, ctx_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_eq_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_eq_u256.snap index d42dabb586..a7290cd713 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_eq_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_eq_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_eq_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> bool: +2 │ ╭ pub fn bar(x: u256, y: u256) -> bool { 3 │ │ return x == y - │ ╰─────────────────────^ attributes hash: 3021624743158907825 +4 │ │ } + │ ╰─────^ attributes hash: 3021624743158907825 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_gt_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_gt_i256.snap index 056d0ca01c..a2f896ae14 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_gt_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_gt_i256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_gt_i256.fe:2:5 │ -2 │ ╭ pub fn bar(x: i256, y: i256) -> bool: +2 │ ╭ pub fn bar(x: i256, y: i256) -> bool { 3 │ │ return x > y - │ ╰────────────────────^ attributes hash: 7978284628773169348 +4 │ │ } + │ ╰─────^ attributes hash: 7978284628773169348 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_gt_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_gt_u256.snap index bf7cae70fe..1a8a9d3f82 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_gt_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_gt_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_gt_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> bool: +2 │ ╭ pub fn bar(x: u256, y: u256) -> bool { 3 │ │ return x > y - │ ╰────────────────────^ attributes hash: 3021624743158907825 +4 │ │ } + │ ╰─────^ attributes hash: 3021624743158907825 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_gte_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_gte_i256.snap index 38550ab176..cd51e66fc1 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_gte_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_gte_i256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_gte_i256.fe:2:5 │ -2 │ ╭ pub fn bar(x: i256, y: i256) -> bool: +2 │ ╭ pub fn bar(x: i256, y: i256) -> bool { 3 │ │ return x >= y - │ ╰─────────────────────^ attributes hash: 7978284628773169348 +4 │ │ } + │ ╰─────^ attributes hash: 7978284628773169348 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_gte_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_gte_u256.snap index 9c3b542dd6..7d1b501f57 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_gte_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_gte_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_gte_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> bool: +2 │ ╭ pub fn bar(x: u256, y: u256) -> bool { 3 │ │ return x >= y - │ ╰─────────────────────^ attributes hash: 3021624743158907825 +4 │ │ } + │ ╰─────^ attributes hash: 3021624743158907825 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_i128_cast.snap b/crates/analyzer/tests/snapshots/analysis__return_i128_cast.snap index c7e3bc3928..12f602d687 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_i128_cast.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_i128_cast.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_i128_cast.fe:2:5 │ -2 │ ╭ pub fn bar() -> i128: +2 │ ╭ pub fn bar() -> i128 { 3 │ │ return i128(-3) - │ ╰───────────────────────^ attributes hash: 155533728466856391 +4 │ │ } + │ ╰─────^ attributes hash: 155533728466856391 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_i256.snap index 9a0951ef95..731b95fa88 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_i256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_i256.fe:2:5 │ -2 │ ╭ pub fn bar() -> i256: +2 │ ╭ pub fn bar() -> i256 { 3 │ │ return -3 - │ ╰─────────────────^ attributes hash: 8116994679119332188 +4 │ │ } + │ ╰─────^ attributes hash: 8116994679119332188 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_identity_u128.snap b/crates/analyzer/tests/snapshots/analysis__return_identity_u128.snap index 245373e856..9c397d3bb1 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_identity_u128.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_identity_u128.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_identity_u128.fe:2:5 │ -2 │ ╭ pub fn bar(x: u128) -> u128: +2 │ ╭ pub fn bar(x: u128) -> u128 { 3 │ │ return x - │ ╰────────────────^ attributes hash: 8882570074302111953 +4 │ │ } + │ ╰─────^ attributes hash: 8882570074302111953 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_identity_u16.snap b/crates/analyzer/tests/snapshots/analysis__return_identity_u16.snap index 5f5818895a..a229da26c4 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_identity_u16.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_identity_u16.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_identity_u16.fe:2:5 │ -2 │ ╭ pub fn bar(x: u16) -> u16: +2 │ ╭ pub fn bar(x: u16) -> u16 { 3 │ │ return x - │ ╰────────────────^ attributes hash: 12880247899747575992 +4 │ │ } + │ ╰─────^ attributes hash: 12880247899747575992 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_identity_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_identity_u256.snap index 0833b7041b..12f99ca768 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_identity_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_identity_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_identity_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256) -> u256: +2 │ ╭ pub fn bar(x: u256) -> u256 { 3 │ │ return x - │ ╰────────────────^ attributes hash: 6622018637299644818 +4 │ │ } + │ ╰─────^ attributes hash: 6622018637299644818 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_identity_u32.snap b/crates/analyzer/tests/snapshots/analysis__return_identity_u32.snap index 2047c1edf1..8a31db838f 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_identity_u32.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_identity_u32.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_identity_u32.fe:2:5 │ -2 │ ╭ pub fn bar(x: u32) -> u32: +2 │ ╭ pub fn bar(x: u32) -> u32 { 3 │ │ return x - │ ╰────────────────^ attributes hash: 3053189841811312763 +4 │ │ } + │ ╰─────^ attributes hash: 3053189841811312763 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_identity_u64.snap b/crates/analyzer/tests/snapshots/analysis__return_identity_u64.snap index 1e637433c9..8693495b09 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_identity_u64.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_identity_u64.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_identity_u64.fe:2:5 │ -2 │ ╭ pub fn bar(x: u64) -> u64: +2 │ ╭ pub fn bar(x: u64) -> u64 { 3 │ │ return x - │ ╰────────────────^ attributes hash: 14360693544116809530 +4 │ │ } + │ ╰─────^ attributes hash: 14360693544116809530 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_identity_u8.snap b/crates/analyzer/tests/snapshots/analysis__return_identity_u8.snap index 20d8b5765b..3b62b044ae 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_identity_u8.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_identity_u8.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_identity_u8.fe:2:5 │ -2 │ ╭ pub fn bar(x: u8) -> u8: +2 │ ╭ pub fn bar(x: u8) -> u8 { 3 │ │ return x - │ ╰────────────────^ attributes hash: 4472501580732693210 +4 │ │ } + │ ╰─────^ attributes hash: 4472501580732693210 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_lt_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_lt_i256.snap index 9cae37e632..308e699576 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_lt_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_lt_i256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_lt_i256.fe:2:5 │ -2 │ ╭ pub fn bar(x: i256, y: i256) -> bool: +2 │ ╭ pub fn bar(x: i256, y: i256) -> bool { 3 │ │ return x < y - │ ╰────────────────────^ attributes hash: 7978284628773169348 +4 │ │ } + │ ╰─────^ attributes hash: 7978284628773169348 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_lt_u128.snap b/crates/analyzer/tests/snapshots/analysis__return_lt_u128.snap index 4a156f79f3..32867706f8 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_lt_u128.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_lt_u128.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_lt_u128.fe:2:5 │ -2 │ ╭ pub fn bar(x: u128, y: u128) -> bool: +2 │ ╭ pub fn bar(x: u128, y: u128) -> bool { 3 │ │ return x < y - │ ╰────────────────────^ attributes hash: 4640755342958234471 +4 │ │ } + │ ╰─────^ attributes hash: 4640755342958234471 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_lt_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_lt_u256.snap index c4f15fcd3f..1d05310d69 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_lt_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_lt_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_lt_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> bool: +2 │ ╭ pub fn bar(x: u256, y: u256) -> bool { 3 │ │ return x < y - │ ╰────────────────────^ attributes hash: 3021624743158907825 +4 │ │ } + │ ╰─────^ attributes hash: 3021624743158907825 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_lte_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_lte_i256.snap index 7f6eb1b897..d89d6916ab 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_lte_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_lte_i256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_lte_i256.fe:2:5 │ -2 │ ╭ pub fn bar(x: i256, y: i256) -> bool: +2 │ ╭ pub fn bar(x: i256, y: i256) -> bool { 3 │ │ return x <= y - │ ╰─────────────────────^ attributes hash: 7978284628773169348 +4 │ │ } + │ ╰─────^ attributes hash: 7978284628773169348 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_lte_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_lte_u256.snap index c5ea29f2c8..6a9b88f4a9 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_lte_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_lte_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_lte_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> bool: +2 │ ╭ pub fn bar(x: u256, y: u256) -> bool { 3 │ │ return x <= y - │ ╰─────────────────────^ attributes hash: 3021624743158907825 +4 │ │ } + │ ╰─────^ attributes hash: 3021624743158907825 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_mod_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_mod_i256.snap index 7503f7dde5..b13326c05b 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_mod_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_mod_i256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_mod_i256.fe:2:5 │ -2 │ ╭ pub fn bar(x: i256, y: i256) -> i256: +2 │ ╭ pub fn bar(x: i256, y: i256) -> i256 { 3 │ │ return x % y - │ ╰────────────────────^ attributes hash: 6924216180113238234 +4 │ │ } + │ ╰─────^ attributes hash: 6924216180113238234 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_mod_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_mod_u256.snap index d2273564d4..cef3907a2b 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_mod_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_mod_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_mod_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> u256: +2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x % y - │ ╰────────────────────^ attributes hash: 6847926207878778580 +4 │ │ } + │ ╰─────^ attributes hash: 6847926207878778580 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_msg_sig.snap b/crates/analyzer/tests/snapshots/analysis__return_msg_sig.snap index 2f80620711..f1c7b27d82 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_msg_sig.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_msg_sig.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_msg_sig.fe:4:5 │ -4 │ ╭ pub fn bar(ctx: Context) -> u256: +4 │ ╭ pub fn bar(ctx: Context) -> u256 { 5 │ │ return ctx.msg_sig() - │ ╰────────────────────────────^ attributes hash: 10526263819290319263 +6 │ │ } + │ ╰─────^ attributes hash: 10526263819290319263 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_multiplication_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_multiplication_i256.snap index 8ccb5dcc42..dccf128f50 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_multiplication_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_multiplication_i256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_multiplication_i256.fe:2:5 │ -2 │ ╭ pub fn bar(x: i256, y: i256) -> i256: +2 │ ╭ pub fn bar(x: i256, y: i256) -> i256 { 3 │ │ return x * y - │ ╰────────────────────^ attributes hash: 6924216180113238234 +4 │ │ } + │ ╰─────^ attributes hash: 6924216180113238234 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_multiplication_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_multiplication_u256.snap index ba224bfcb8..e7f35f9fef 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_multiplication_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_multiplication_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_multiplication_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> u256: +2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x * y - │ ╰────────────────────^ attributes hash: 6847926207878778580 +4 │ │ } + │ ╰─────^ attributes hash: 6847926207878778580 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_noteq_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_noteq_u256.snap index 4e0fa94bdb..90cf30a944 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_noteq_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_noteq_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_noteq_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> bool: +2 │ ╭ pub fn bar(x: u256, y: u256) -> bool { 3 │ │ return x != y - │ ╰─────────────────────^ attributes hash: 3021624743158907825 +4 │ │ } + │ ╰─────^ attributes hash: 3021624743158907825 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_pow_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_pow_i256.snap index 22c531e55d..59ce547820 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_pow_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_pow_i256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_pow_i256.fe:2:5 │ -2 │ ╭ pub fn bar(x: i8, y: u8) -> i8: +2 │ ╭ pub fn bar(x: i8, y: u8) -> i8 { 3 │ │ return x ** y - │ ╰─────────────────────^ attributes hash: 14588309679488297104 +4 │ │ } + │ ╰─────^ attributes hash: 14588309679488297104 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_pow_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_pow_u256.snap index 8840ad7b1d..0a790cf373 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_pow_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_pow_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_pow_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> u256: +2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x ** y - │ ╰─────────────────────^ attributes hash: 6847926207878778580 +4 │ │ } + │ ╰─────^ attributes hash: 6847926207878778580 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_subtraction_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_subtraction_i256.snap index 25f8762ece..9cdf0116b9 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_subtraction_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_subtraction_i256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_subtraction_i256.fe:2:5 │ -2 │ ╭ pub fn bar(x: i256, y: i256) -> i256: +2 │ ╭ pub fn bar(x: i256, y: i256) -> i256 { 3 │ │ return x - y - │ ╰────────────────────^ attributes hash: 6924216180113238234 +4 │ │ } + │ ╰─────^ attributes hash: 6924216180113238234 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_subtraction_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_subtraction_u256.snap index d2bacb4c69..1562abed2b 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_subtraction_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_subtraction_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_subtraction_u256.fe:2:5 │ -2 │ ╭ pub fn bar(x: u256, y: u256) -> u256: +2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x - y - │ ╰────────────────────^ attributes hash: 6847926207878778580 +4 │ │ } + │ ╰─────^ attributes hash: 6847926207878778580 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_u128_cast.snap b/crates/analyzer/tests/snapshots/analysis__return_u128_cast.snap index d6dee7147e..e26658bc68 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_u128_cast.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_u128_cast.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_u128_cast.fe:2:5 │ -2 │ ╭ pub fn bar() -> u128: +2 │ ╭ pub fn bar() -> u128 { 3 │ │ return u128(42) - │ ╰───────────────────────^ attributes hash: 104322826323649285 +4 │ │ } + │ ╰─────^ attributes hash: 104322826323649285 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_u256.snap index fbb35d1bca..ff29d6dd41 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_u256.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ return_u256.fe:2:5 │ -2 │ ╭ pub fn bar() -> u256: +2 │ ╭ pub fn bar() -> u256 { 3 │ │ return 42 - │ ╰─────────────────^ attributes hash: 6115314201970082834 +4 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__return_u256_from_called_fn.snap b/crates/analyzer/tests/snapshots/analysis__return_u256_from_called_fn.snap index 6a2f62167e..606e6bcbe3 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_u256_from_called_fn.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_u256_from_called_fn.snap @@ -4,11 +4,12 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ return_u256_from_called_fn.fe:4:5 + ┌─ return_u256_from_called_fn.fe:2:5 │ -4 │ ╭ pub fn bar(self) -> u256: -5 │ │ return foo() - │ ╰────────────────────^ attributes hash: 11773348765973600208 +2 │ ╭ pub fn bar(self) -> u256 { +3 │ │ return foo() +4 │ │ } + │ ╰─────^ attributes hash: 11773348765973600208 │ = FunctionSignature { self_decl: Some( @@ -26,17 +27,18 @@ note: } note: - ┌─ return_u256_from_called_fn.fe:5:16 + ┌─ return_u256_from_called_fn.fe:3:16 │ -5 │ return foo() +3 │ return foo() │ ^^^^^ u256: Value note: - ┌─ return_u256_from_called_fn.fe:7:5 + ┌─ return_u256_from_called_fn.fe:6:5 │ -7 │ ╭ pub fn foo() -> u256: -8 │ │ return 42 - │ ╰─────────────────^ attributes hash: 6115314201970082834 +6 │ ╭ pub fn foo() -> u256 { +7 │ │ return 42 +8 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -52,9 +54,9 @@ note: } note: - ┌─ return_u256_from_called_fn.fe:8:16 + ┌─ return_u256_from_called_fn.fe:7:16 │ -8 │ return 42 +7 │ return 42 │ ^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__return_u256_from_called_fn_with_args.snap b/crates/analyzer/tests/snapshots/analysis__return_u256_from_called_fn_with_args.snap index 1be0097720..b463097ea4 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_u256_from_called_fn_with_args.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_u256_from_called_fn_with_args.snap @@ -10,11 +10,12 @@ note: │ ^^^^^^^^^^^^^^^^^^^^ Map note: - ┌─ return_u256_from_called_fn_with_args.fe:3:5 + ┌─ return_u256_from_called_fn_with_args.fe:4:5 │ -3 │ ╭ pub fn foo(_ v1: u256, _ v2: u256, _ v3: u256, _ v4: u256, _ v5: u256) -> u256: -4 │ │ return v1 + v2 + v3 + v4 + v5 - │ ╰─────────────────────────────────────^ attributes hash: 1504347162142127509 +4 │ ╭ pub fn foo(_ v1: u256, _ v2: u256, _ v3: u256, _ v4: u256, _ v5: u256) -> u256 { +5 │ │ return v1 + v2 + v3 + v4 + v5 +6 │ │ } + │ ╰─────^ attributes hash: 1504347162142127509 │ = FunctionSignature { self_decl: None, @@ -96,76 +97,78 @@ note: } note: - ┌─ return_u256_from_called_fn_with_args.fe:4:16 + ┌─ return_u256_from_called_fn_with_args.fe:5:16 │ -4 │ return v1 + v2 + v3 + v4 + v5 +5 │ return v1 + v2 + v3 + v4 + v5 │ ^^ ^^ u256: Value │ │ │ u256: Value note: - ┌─ return_u256_from_called_fn_with_args.fe:4:16 + ┌─ return_u256_from_called_fn_with_args.fe:5:16 │ -4 │ return v1 + v2 + v3 + v4 + v5 +5 │ return v1 + v2 + v3 + v4 + v5 │ ^^^^^^^ ^^ u256: Value │ │ │ u256: Value note: - ┌─ return_u256_from_called_fn_with_args.fe:4:16 + ┌─ return_u256_from_called_fn_with_args.fe:5:16 │ -4 │ return v1 + v2 + v3 + v4 + v5 +5 │ return v1 + v2 + v3 + v4 + v5 │ ^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Value note: - ┌─ return_u256_from_called_fn_with_args.fe:4:16 + ┌─ return_u256_from_called_fn_with_args.fe:5:16 │ -4 │ return v1 + v2 + v3 + v4 + v5 +5 │ return v1 + v2 + v3 + v4 + v5 │ ^^^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Value note: - ┌─ return_u256_from_called_fn_with_args.fe:4:16 + ┌─ return_u256_from_called_fn_with_args.fe:5:16 │ -4 │ return v1 + v2 + v3 + v4 + v5 +5 │ return v1 + v2 + v3 + v4 + v5 │ ^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ return_u256_from_called_fn_with_args.fe:6:5 - │ -6 │ ╭ pub fn cem() -> u256: -7 │ │ return 100 - │ ╰──────────────────^ attributes hash: 6115314201970082834 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [], - return_type: Ok( - Base( - Numeric( - U256, - ), - ), - ), - } + ┌─ return_u256_from_called_fn_with_args.fe:8:5 + │ + 8 │ ╭ pub fn cem() -> u256 { + 9 │ │ return 100 +10 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [], + return_type: Ok( + Base( + Numeric( + U256, + ), + ), + ), + } note: - ┌─ return_u256_from_called_fn_with_args.fe:7:16 + ┌─ return_u256_from_called_fn_with_args.fe:9:16 │ -7 │ return 100 +9 │ return 100 │ ^^^ u256: Value note: - ┌─ return_u256_from_called_fn_with_args.fe:9:5 + ┌─ return_u256_from_called_fn_with_args.fe:12:5 │ - 9 │ ╭ pub fn bar(self) -> u256: -10 │ │ self.baz[0] = 43 -11 │ │ return foo(5, 2, cem(), 25 + 25, self.baz[0]) - │ ╰─────────────────────────────────────────────────────^ attributes hash: 11773348765973600208 +12 │ ╭ pub fn bar(self) -> u256 { +13 │ │ self.baz[0] = 43 +14 │ │ return foo(5, 2, cem(), 25 + 25, self.baz[0]) +15 │ │ } + │ ╰─────^ attributes hash: 11773348765973600208 │ = FunctionSignature { self_decl: Some( @@ -183,27 +186,27 @@ note: } note: - ┌─ return_u256_from_called_fn_with_args.fe:10:9 + ┌─ return_u256_from_called_fn_with_args.fe:13:9 │ -10 │ self.baz[0] = 43 +13 │ self.baz[0] = 43 │ ^^^^ Foo: Value note: - ┌─ return_u256_from_called_fn_with_args.fe:10:9 + ┌─ return_u256_from_called_fn_with_args.fe:13:9 │ -10 │ self.baz[0] = 43 +13 │ self.baz[0] = 43 │ ^^^^^^^^ ^ u256: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ return_u256_from_called_fn_with_args.fe:10:9 + ┌─ return_u256_from_called_fn_with_args.fe:13:9 │ -10 │ self.baz[0] = 43 +13 │ self.baz[0] = 43 │ ^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Storage { nonce: None } -11 │ return foo(5, 2, cem(), 25 + 25, self.baz[0]) +14 │ return foo(5, 2, cem(), 25 + 25, self.baz[0]) │ ^ ^ ^^^^^ ^^ ^^ u256: Value │ │ │ │ │ │ │ │ │ u256: Value @@ -212,31 +215,31 @@ note: │ u256: Value note: - ┌─ return_u256_from_called_fn_with_args.fe:11:33 + ┌─ return_u256_from_called_fn_with_args.fe:14:33 │ -11 │ return foo(5, 2, cem(), 25 + 25, self.baz[0]) +14 │ return foo(5, 2, cem(), 25 + 25, self.baz[0]) │ ^^^^^^^ ^^^^ Foo: Value │ │ │ u256: Value note: - ┌─ return_u256_from_called_fn_with_args.fe:11:42 + ┌─ return_u256_from_called_fn_with_args.fe:14:42 │ -11 │ return foo(5, 2, cem(), 25 + 25, self.baz[0]) +14 │ return foo(5, 2, cem(), 25 + 25, self.baz[0]) │ ^^^^^^^^ ^ u256: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ return_u256_from_called_fn_with_args.fe:11:42 + ┌─ return_u256_from_called_fn_with_args.fe:14:42 │ -11 │ return foo(5, 2, cem(), 25 + 25, self.baz[0]) +14 │ return foo(5, 2, cem(), 25 + 25, self.baz[0]) │ ^^^^^^^^^^^ u256: Storage { nonce: None } => Value note: - ┌─ return_u256_from_called_fn_with_args.fe:11:16 + ┌─ return_u256_from_called_fn_with_args.fe:14:16 │ -11 │ return foo(5, 2, cem(), 25 + 25, self.baz[0]) +14 │ return foo(5, 2, cem(), 25 + 25, self.baz[0]) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__revert.snap b/crates/analyzer/tests/snapshots/analysis__revert.snap index 5a3c52b381..5217aabc83 100644 --- a/crates/analyzer/tests/snapshots/analysis__revert.snap +++ b/crates/analyzer/tests/snapshots/analysis__revert.snap @@ -12,17 +12,18 @@ note: │ ^^^^^^^^^^^^^ bool note: - ┌─ revert.fe:8:5 + ┌─ revert.fe:9:5 │ -8 │ my_other_error: OtherError +9 │ my_other_error: OtherError │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ OtherError note: - ┌─ revert.fe:10:5 + ┌─ revert.fe:11:5 │ -10 │ ╭ pub fn bar() -> u256: -11 │ │ revert - │ ╰──────────────^ attributes hash: 6115314201970082834 +11 │ ╭ pub fn bar() -> u256 { +12 │ │ revert +13 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -38,11 +39,12 @@ note: } note: - ┌─ revert.fe:13:5 + ┌─ revert.fe:15:5 │ -13 │ ╭ pub fn revert_custom_error(ctx: Context): -14 │ │ ctx.send_value(to: address(0), wei: 100) - │ ╰────────────────────────────────────────────────^ attributes hash: 5519676733853656531 +15 │ ╭ pub fn revert_custom_error(ctx: Context) { +16 │ │ ctx.send_value(to: address(0), wei: 100) +17 │ │ } + │ ╰─────^ attributes hash: 5519676733853656531 │ = FunctionSignature { self_decl: None, @@ -71,33 +73,34 @@ note: } note: - ┌─ revert.fe:14:9 + ┌─ revert.fe:16:9 │ -14 │ ctx.send_value(to: address(0), wei: 100) +16 │ ctx.send_value(to: address(0), wei: 100) │ ^^^ ^ u256: Value │ │ │ Context: Memory note: - ┌─ revert.fe:14:28 + ┌─ revert.fe:16:28 │ -14 │ ctx.send_value(to: address(0), wei: 100) +16 │ ctx.send_value(to: address(0), wei: 100) │ ^^^^^^^^^^ ^^^ u256: Value │ │ │ address: Value note: - ┌─ revert.fe:14:9 + ┌─ revert.fe:16:9 │ -14 │ ctx.send_value(to: address(0), wei: 100) +16 │ ctx.send_value(to: address(0), wei: 100) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value note: - ┌─ revert.fe:16:5 + ┌─ revert.fe:19:5 │ -16 │ ╭ pub fn revert_other_error(): -17 │ │ revert OtherError(msg: 1, val: true) - │ ╰────────────────────────────────────────────^ attributes hash: 8319796915330632390 +19 │ ╭ pub fn revert_other_error() { +20 │ │ revert OtherError(msg: 1, val: true) +21 │ │ } + │ ╰─────^ attributes hash: 8319796915330632390 │ = FunctionSignature { self_decl: None, @@ -111,26 +114,27 @@ note: } note: - ┌─ revert.fe:17:32 + ┌─ revert.fe:20:32 │ -17 │ revert OtherError(msg: 1, val: true) +20 │ revert OtherError(msg: 1, val: true) │ ^ ^^^^ bool: Value │ │ │ u256: Value note: - ┌─ revert.fe:17:16 + ┌─ revert.fe:20:16 │ -17 │ revert OtherError(msg: 1, val: true) +20 │ revert OtherError(msg: 1, val: true) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OtherError: Memory note: - ┌─ revert.fe:19:5 + ┌─ revert.fe:23:5 │ -19 │ ╭ pub fn revert_other_error_from_sto(self): -20 │ │ self.my_other_error = OtherError(msg: 1, val: true) -21 │ │ revert self.my_other_error.to_mem() - │ ╰───────────────────────────────────────────^ attributes hash: 18235041182630809162 +23 │ ╭ pub fn revert_other_error_from_sto(self) { +24 │ │ self.my_other_error = OtherError(msg: 1, val: true) +25 │ │ revert self.my_other_error.to_mem() +26 │ │ } + │ ╰─────^ attributes hash: 18235041182630809162 │ = FunctionSignature { self_decl: Some( @@ -146,38 +150,38 @@ note: } note: - ┌─ revert.fe:20:9 + ┌─ revert.fe:24:9 │ -20 │ self.my_other_error = OtherError(msg: 1, val: true) +24 │ self.my_other_error = OtherError(msg: 1, val: true) │ ^^^^ Foo: Value note: - ┌─ revert.fe:20:9 + ┌─ revert.fe:24:9 │ -20 │ self.my_other_error = OtherError(msg: 1, val: true) +24 │ self.my_other_error = OtherError(msg: 1, val: true) │ ^^^^^^^^^^^^^^^^^^^ ^ ^^^^ bool: Value │ │ │ │ │ u256: Value │ OtherError: Storage { nonce: Some(0) } note: - ┌─ revert.fe:20:31 + ┌─ revert.fe:24:31 │ -20 │ self.my_other_error = OtherError(msg: 1, val: true) +24 │ self.my_other_error = OtherError(msg: 1, val: true) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OtherError: Memory -21 │ revert self.my_other_error.to_mem() +25 │ revert self.my_other_error.to_mem() │ ^^^^ Foo: Value note: - ┌─ revert.fe:21:16 + ┌─ revert.fe:25:16 │ -21 │ revert self.my_other_error.to_mem() +25 │ revert self.my_other_error.to_mem() │ ^^^^^^^^^^^^^^^^^^^ OtherError: Storage { nonce: Some(0) } note: - ┌─ revert.fe:21:16 + ┌─ revert.fe:25:16 │ -21 │ revert self.my_other_error.to_mem() +25 │ revert self.my_other_error.to_mem() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OtherError: Storage { nonce: Some(0) } => Memory diff --git a/crates/analyzer/tests/snapshots/analysis__self_address.snap b/crates/analyzer/tests/snapshots/analysis__self_address.snap index b6fbafc821..f2ea18b791 100644 --- a/crates/analyzer/tests/snapshots/analysis__self_address.snap +++ b/crates/analyzer/tests/snapshots/analysis__self_address.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ self_address.fe:4:5 │ -4 │ ╭ pub fn my_address(ctx: Context) -> address: +4 │ ╭ pub fn my_address(ctx: Context) -> address { 5 │ │ return ctx.self_address() - │ ╰─────────────────────────────────^ attributes hash: 9364783648076633772 +6 │ │ } + │ ╰─────^ attributes hash: 9364783648076633772 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__send_value.snap b/crates/analyzer/tests/snapshots/analysis__send_value.snap index c9758ad977..cd2a48be20 100644 --- a/crates/analyzer/tests/snapshots/analysis__send_value.snap +++ b/crates/analyzer/tests/snapshots/analysis__send_value.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ send_value.fe:4:5 │ -4 │ ╭ pub fn send_them_wei(ctx: Context, to: address, wei: u256): +4 │ ╭ pub fn send_them_wei(ctx: Context, to: address, wei: u256) { 5 │ │ ctx.send_value(to, wei) - │ ╰───────────────────────────────^ attributes hash: 14069636423119281176 +6 │ │ } + │ ╰─────^ attributes hash: 14069636423119281176 │ = FunctionSignature { self_decl: None, diff --git a/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap b/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap index 7c3ad83a8b..d324eb003c 100644 --- a/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap +++ b/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap @@ -1,59 +1,60 @@ --- source: crates/analyzer/tests/analysis.rs expression: "build_snapshot(&db, module)" + --- note: - ┌─ simple_open_auction.fe:8:5 + ┌─ simple_open_auction.fe:9:5 │ -8 │ pub highest_bid: u256 +9 │ pub highest_bid: u256 │ ^^^^^^^^^^^^^^^^^^^^^ u256 note: - ┌─ simple_open_auction.fe:18:5 + ┌─ simple_open_auction.fe:14:5 │ -18 │ auction_end_time: u256 +14 │ auction_end_time: u256 │ ^^^^^^^^^^^^^^^^^^^^^^ u256 -19 │ beneficiary: address +15 │ beneficiary: address │ ^^^^^^^^^^^^^^^^^^^^ address -20 │ -21 │ highest_bidder: address +16 │ +17 │ highest_bidder: address │ ^^^^^^^^^^^^^^^^^^^^^^^ address -22 │ highest_bid: u256 +18 │ highest_bid: u256 │ ^^^^^^^^^^^^^^^^^ u256 -23 │ -24 │ pending_returns: Map +19 │ +20 │ pending_returns: Map │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map -25 │ -26 │ ended: bool +21 │ +22 │ ended: bool │ ^^^^^^^^^^^ bool note: - ┌─ simple_open_auction.fe:30:9 + ┌─ simple_open_auction.fe:26:9 │ -30 │ idx bidder: address +26 │ idx bidder: address │ ^^^^^^^^^^^^^^^^^^^ address -31 │ amount: u256 +27 │ amount: u256 │ ^^^^^^^^^^^^ u256 note: - ┌─ simple_open_auction.fe:34:9 + ┌─ simple_open_auction.fe:31:9 │ -34 │ idx winner: address +31 │ idx winner: address │ ^^^^^^^^^^^^^^^^^^^ address -35 │ amount: u256 +32 │ amount: u256 │ ^^^^^^^^^^^^ u256 note: - ┌─ simple_open_auction.fe:43:5 + ┌─ simple_open_auction.fe:42:5 │ -43 │ ╭ pub fn bid(self, ctx: Context): -44 │ │ if ctx.block_timestamp() > self.auction_end_time: -45 │ │ revert AuctionAlreadyEnded() -46 │ │ +42 │ ╭ pub fn bid(self, ctx: Context) { +43 │ │ if ctx.block_timestamp() > self.auction_end_time { +44 │ │ revert AuctionAlreadyEnded() +45 │ │ } · │ -55 │ │ -56 │ │ emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) - │ ╰────────────────────────────────────────────────────────────────────────────────────────^ attributes hash: 1731341862738941170 +55 │ │ emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) +56 │ │ } + │ ╰─────^ attributes hash: 1731341862738941170 │ = FunctionSignature { self_decl: Some( @@ -84,173 +85,173 @@ note: } note: - ┌─ simple_open_auction.fe:44:12 + ┌─ simple_open_auction.fe:43:12 │ -44 │ if ctx.block_timestamp() > self.auction_end_time: +43 │ if ctx.block_timestamp() > self.auction_end_time { │ ^^^ Context: Memory note: - ┌─ simple_open_auction.fe:44:12 + ┌─ simple_open_auction.fe:43:12 │ -44 │ if ctx.block_timestamp() > self.auction_end_time: +43 │ if ctx.block_timestamp() > self.auction_end_time { │ ^^^^^^^^^^^^^^^^^^^^^ ^^^^ SimpleOpenAuction: Value │ │ │ u256: Value note: - ┌─ simple_open_auction.fe:44:36 + ┌─ simple_open_auction.fe:43:36 │ -44 │ if ctx.block_timestamp() > self.auction_end_time: +43 │ if ctx.block_timestamp() > self.auction_end_time { │ ^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(0) } => Value note: - ┌─ simple_open_auction.fe:44:12 + ┌─ simple_open_auction.fe:43:12 │ -44 │ if ctx.block_timestamp() > self.auction_end_time: +43 │ if ctx.block_timestamp() > self.auction_end_time { │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -45 │ revert AuctionAlreadyEnded() +44 │ revert AuctionAlreadyEnded() │ ^^^^^^^^^^^^^^^^^^^^^ AuctionAlreadyEnded: Memory -46 │ -47 │ if ctx.msg_value() <= self.highest_bid: +45 │ } +46 │ if ctx.msg_value() <= self.highest_bid { │ ^^^ Context: Memory note: - ┌─ simple_open_auction.fe:47:12 + ┌─ simple_open_auction.fe:46:12 │ -47 │ if ctx.msg_value() <= self.highest_bid: +46 │ if ctx.msg_value() <= self.highest_bid { │ ^^^^^^^^^^^^^^^ ^^^^ SimpleOpenAuction: Value │ │ │ u256: Value note: - ┌─ simple_open_auction.fe:47:31 + ┌─ simple_open_auction.fe:46:31 │ -47 │ if ctx.msg_value() <= self.highest_bid: +46 │ if ctx.msg_value() <= self.highest_bid { │ ^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(3) } => Value note: - ┌─ simple_open_auction.fe:47:12 + ┌─ simple_open_auction.fe:46:12 │ -47 │ if ctx.msg_value() <= self.highest_bid: +46 │ if ctx.msg_value() <= self.highest_bid { │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -48 │ revert BidNotHighEnough(highest_bid: self.highest_bid) +47 │ revert BidNotHighEnough(highest_bid: self.highest_bid) │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:48:50 + ┌─ simple_open_auction.fe:47:50 │ -48 │ revert BidNotHighEnough(highest_bid: self.highest_bid) +47 │ revert BidNotHighEnough(highest_bid: self.highest_bid) │ ^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(3) } => Value note: - ┌─ simple_open_auction.fe:48:20 + ┌─ simple_open_auction.fe:47:20 │ -48 │ revert BidNotHighEnough(highest_bid: self.highest_bid) +47 │ revert BidNotHighEnough(highest_bid: self.highest_bid) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ BidNotHighEnough: Memory -49 │ -50 │ if self.highest_bid != 0: +48 │ } +49 │ if self.highest_bid != 0 { │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:50:12 + ┌─ simple_open_auction.fe:49:12 │ -50 │ if self.highest_bid != 0: +49 │ if self.highest_bid != 0 { │ ^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: Some(3) } => Value note: - ┌─ simple_open_auction.fe:50:12 + ┌─ simple_open_auction.fe:49:12 │ -50 │ if self.highest_bid != 0: +49 │ if self.highest_bid != 0 { │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value -51 │ self.pending_returns[self.highest_bidder] += self.highest_bid +50 │ self.pending_returns[self.highest_bidder] += self.highest_bid │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:51:13 + ┌─ simple_open_auction.fe:50:13 │ -51 │ self.pending_returns[self.highest_bidder] += self.highest_bid +50 │ self.pending_returns[self.highest_bidder] += self.highest_bid │ ^^^^^^^^^^^^^^^^^^^^ ^^^^ SimpleOpenAuction: Value │ │ │ Map: Storage { nonce: Some(4) } note: - ┌─ simple_open_auction.fe:51:34 + ┌─ simple_open_auction.fe:50:34 │ -51 │ self.pending_returns[self.highest_bidder] += self.highest_bid +50 │ self.pending_returns[self.highest_bidder] += self.highest_bid │ ^^^^^^^^^^^^^^^^^^^ address: Storage { nonce: Some(2) } => Value note: - ┌─ simple_open_auction.fe:51:13 + ┌─ simple_open_auction.fe:50:13 │ -51 │ self.pending_returns[self.highest_bidder] += self.highest_bid +50 │ self.pending_returns[self.highest_bidder] += self.highest_bid │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ SimpleOpenAuction: Value │ │ │ u256: Storage { nonce: None } note: - ┌─ simple_open_auction.fe:51:58 + ┌─ simple_open_auction.fe:50:58 │ -51 │ self.pending_returns[self.highest_bidder] += self.highest_bid +50 │ self.pending_returns[self.highest_bidder] += self.highest_bid │ ^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(3) } -52 │ -53 │ self.highest_bidder = ctx.msg_sender() +51 │ } +52 │ self.highest_bidder = ctx.msg_sender() │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:53:9 + ┌─ simple_open_auction.fe:52:9 │ -53 │ self.highest_bidder = ctx.msg_sender() +52 │ self.highest_bidder = ctx.msg_sender() │ ^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ address: Storage { nonce: Some(2) } note: - ┌─ simple_open_auction.fe:53:31 + ┌─ simple_open_auction.fe:52:31 │ -53 │ self.highest_bidder = ctx.msg_sender() +52 │ self.highest_bidder = ctx.msg_sender() │ ^^^^^^^^^^^^^^^^ address: Value -54 │ self.highest_bid = ctx.msg_value() +53 │ self.highest_bid = ctx.msg_value() │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:54:9 + ┌─ simple_open_auction.fe:53:9 │ -54 │ self.highest_bid = ctx.msg_value() +53 │ self.highest_bid = ctx.msg_value() │ ^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ u256: Storage { nonce: Some(3) } note: - ┌─ simple_open_auction.fe:54:28 + ┌─ simple_open_auction.fe:53:28 │ -54 │ self.highest_bid = ctx.msg_value() +53 │ self.highest_bid = ctx.msg_value() │ ^^^^^^^^^^^^^^^ u256: Value -55 │ -56 │ emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) +54 │ +55 │ emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) │ ^^^ ^^^ Context: Memory │ │ │ Context: Memory note: - ┌─ simple_open_auction.fe:56:47 + ┌─ simple_open_auction.fe:55:47 │ -56 │ emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) +55 │ emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) │ ^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ address: Value note: - ┌─ simple_open_auction.fe:56:73 + ┌─ simple_open_auction.fe:55:73 │ -56 │ emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) +55 │ emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) │ ^^^^^^^^^^^^^^^ u256: Value note: - ┌─ simple_open_auction.fe:56:9 + ┌─ simple_open_auction.fe:55:9 │ -56 │ emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) +55 │ emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 4299305322532183383 │ = Event { @@ -282,14 +283,14 @@ note: note: ┌─ simple_open_auction.fe:58:5 │ -58 │ ╭ pub fn withdraw(self, ctx: Context) -> bool: +58 │ ╭ pub fn withdraw(self, ctx: Context) -> bool { 59 │ │ let amount: u256 = self.pending_returns[ctx.msg_sender()] 60 │ │ -61 │ │ if amount > 0: +61 │ │ if amount > 0 { · │ -64 │ │ 65 │ │ return true - │ ╰───────────────────^ attributes hash: 2616212654540170552 +66 │ │ } + │ ╰─────^ attributes hash: 2616212654540170552 │ = FunctionSignature { self_decl: Some( @@ -351,7 +352,7 @@ note: 59 │ let amount: u256 = self.pending_returns[ctx.msg_sender()] │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: None } => Value 60 │ -61 │ if amount > 0: +61 │ if amount > 0 { │ ^^^^^^ ^ u256: Value │ │ │ u256: Value @@ -359,7 +360,7 @@ note: note: ┌─ simple_open_auction.fe:61:12 │ -61 │ if amount > 0: +61 │ if amount > 0 { │ ^^^^^^^^^^ bool: Value 62 │ self.pending_returns[ctx.msg_sender()] = 0 │ ^^^^ SimpleOpenAuction: Value @@ -403,21 +404,21 @@ note: │ 63 │ ctx.send_value(to: ctx.msg_sender(), wei: amount) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -64 │ +64 │ } 65 │ return true │ ^^^^ bool: Value note: - ┌─ simple_open_auction.fe:67:5 + ┌─ simple_open_auction.fe:68:5 │ -67 │ ╭ pub fn action_end(self, ctx: Context): -68 │ │ if ctx.block_timestamp() <= self.auction_end_time: -69 │ │ revert AuctionNotYetEnded() -70 │ │ +68 │ ╭ pub fn action_end(self, ctx: Context) { +69 │ │ if ctx.block_timestamp() <= self.auction_end_time { +70 │ │ revert AuctionNotYetEnded() +71 │ │ } · │ -76 │ │ -77 │ │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) - │ ╰───────────────────────────────────────────────────────────────────^ attributes hash: 1731341862738941170 +78 │ │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) +79 │ │ } + │ ╰─────^ attributes hash: 1731341862738941170 │ = FunctionSignature { self_decl: Some( @@ -448,102 +449,102 @@ note: } note: - ┌─ simple_open_auction.fe:68:12 + ┌─ simple_open_auction.fe:69:12 │ -68 │ if ctx.block_timestamp() <= self.auction_end_time: +69 │ if ctx.block_timestamp() <= self.auction_end_time { │ ^^^ Context: Memory note: - ┌─ simple_open_auction.fe:68:12 + ┌─ simple_open_auction.fe:69:12 │ -68 │ if ctx.block_timestamp() <= self.auction_end_time: +69 │ if ctx.block_timestamp() <= self.auction_end_time { │ ^^^^^^^^^^^^^^^^^^^^^ ^^^^ SimpleOpenAuction: Value │ │ │ u256: Value note: - ┌─ simple_open_auction.fe:68:37 + ┌─ simple_open_auction.fe:69:37 │ -68 │ if ctx.block_timestamp() <= self.auction_end_time: +69 │ if ctx.block_timestamp() <= self.auction_end_time { │ ^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(0) } => Value note: - ┌─ simple_open_auction.fe:68:12 + ┌─ simple_open_auction.fe:69:12 │ -68 │ if ctx.block_timestamp() <= self.auction_end_time: +69 │ if ctx.block_timestamp() <= self.auction_end_time { │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -69 │ revert AuctionNotYetEnded() +70 │ revert AuctionNotYetEnded() │ ^^^^^^^^^^^^^^^^^^^^ AuctionNotYetEnded: Memory -70 │ -71 │ if self.ended: +71 │ } +72 │ if self.ended { │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:71:12 + ┌─ simple_open_auction.fe:72:12 │ -71 │ if self.ended: +72 │ if self.ended { │ ^^^^^^^^^^ bool: Storage { nonce: Some(5) } => Value -72 │ revert AuctionEndAlreadyCalled() +73 │ revert AuctionEndAlreadyCalled() │ ^^^^^^^^^^^^^^^^^^^^^^^^^ AuctionEndAlreadyCalled: Memory -73 │ -74 │ self.ended = true +74 │ } +75 │ self.ended = true │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:74:9 + ┌─ simple_open_auction.fe:75:9 │ -74 │ self.ended = true +75 │ self.ended = true │ ^^^^^^^^^^ ^^^^ bool: Value │ │ │ bool: Storage { nonce: Some(5) } -75 │ emit AuctionEnded(ctx, winner: self.highest_bidder, amount: self.highest_bid) +76 │ emit AuctionEnded(ctx, winner: self.highest_bidder, amount: self.highest_bid) │ ^^^ ^^^^ SimpleOpenAuction: Value │ │ │ Context: Memory note: - ┌─ simple_open_auction.fe:75:40 + ┌─ simple_open_auction.fe:76:40 │ -75 │ emit AuctionEnded(ctx, winner: self.highest_bidder, amount: self.highest_bid) +76 │ emit AuctionEnded(ctx, winner: self.highest_bidder, amount: self.highest_bid) │ ^^^^^^^^^^^^^^^^^^^ ^^^^ SimpleOpenAuction: Value │ │ │ address: Storage { nonce: Some(2) } => Value note: - ┌─ simple_open_auction.fe:75:69 + ┌─ simple_open_auction.fe:76:69 │ -75 │ emit AuctionEnded(ctx, winner: self.highest_bidder, amount: self.highest_bid) +76 │ emit AuctionEnded(ctx, winner: self.highest_bidder, amount: self.highest_bid) │ ^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(3) } => Value -76 │ -77 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) +77 │ +78 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) │ ^^^ ^^^^ SimpleOpenAuction: Value │ │ │ Context: Memory note: - ┌─ simple_open_auction.fe:77:28 + ┌─ simple_open_auction.fe:78:28 │ -77 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) +78 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) │ ^^^^^^^^^^^^^^^^ ^^^^ SimpleOpenAuction: Value │ │ │ address: Storage { nonce: Some(1) } => Value note: - ┌─ simple_open_auction.fe:77:51 + ┌─ simple_open_auction.fe:78:51 │ -77 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) +78 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) │ ^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(3) } => Value note: - ┌─ simple_open_auction.fe:77:9 + ┌─ simple_open_auction.fe:78:9 │ -77 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) +78 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value note: - ┌─ simple_open_auction.fe:75:9 + ┌─ simple_open_auction.fe:76:9 │ -75 │ emit AuctionEnded(ctx, winner: self.highest_bidder, amount: self.highest_bid) +76 │ emit AuctionEnded(ctx, winner: self.highest_bidder, amount: self.highest_bid) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 10704971219741987245 │ = Event { diff --git a/crates/analyzer/tests/snapshots/analysis__sized_vals_in_sto.snap b/crates/analyzer/tests/snapshots/analysis__sized_vals_in_sto.snap index afafa383f8..dd6564ec72 100644 --- a/crates/analyzer/tests/snapshots/analysis__sized_vals_in_sto.snap +++ b/crates/analyzer/tests/snapshots/analysis__sized_vals_in_sto.snap @@ -24,11 +24,12 @@ note: │ ^^^^^^^^^^^^^^^ String<26> note: - ┌─ sized_vals_in_sto.fe:13:5 + ┌─ sized_vals_in_sto.fe:14:5 │ -13 │ ╭ pub fn write_num(self, x: u256): -14 │ │ self.num = x - │ ╰────────────────────^ attributes hash: 4582507849783874218 +14 │ ╭ pub fn write_num(self, x: u256) { +15 │ │ self.num = x +16 │ │ } + │ ╰─────^ attributes hash: 4582507849783874218 │ = FunctionSignature { self_decl: Some( @@ -56,25 +57,26 @@ note: } note: - ┌─ sized_vals_in_sto.fe:14:9 + ┌─ sized_vals_in_sto.fe:15:9 │ -14 │ self.num = x +15 │ self.num = x │ ^^^^ Foo: Value note: - ┌─ sized_vals_in_sto.fe:14:9 + ┌─ sized_vals_in_sto.fe:15:9 │ -14 │ self.num = x +15 │ self.num = x │ ^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } note: - ┌─ sized_vals_in_sto.fe:16:5 + ┌─ sized_vals_in_sto.fe:18:5 │ -16 │ ╭ pub fn read_num(self) -> u256: -17 │ │ return self.num - │ ╰───────────────────────^ attributes hash: 11773348765973600208 +18 │ ╭ pub fn read_num(self) -> u256 { +19 │ │ return self.num +20 │ │ } + │ ╰─────^ attributes hash: 11773348765973600208 │ = FunctionSignature { self_decl: Some( @@ -92,23 +94,24 @@ note: } note: - ┌─ sized_vals_in_sto.fe:17:16 + ┌─ sized_vals_in_sto.fe:19:16 │ -17 │ return self.num +19 │ return self.num │ ^^^^ Foo: Value note: - ┌─ sized_vals_in_sto.fe:17:16 + ┌─ sized_vals_in_sto.fe:19:16 │ -17 │ return self.num +19 │ return self.num │ ^^^^^^^^ u256: Storage { nonce: Some(0) } => Value note: - ┌─ sized_vals_in_sto.fe:19:5 + ┌─ sized_vals_in_sto.fe:22:5 │ -19 │ ╭ pub fn write_nums(self, x: Array): -20 │ │ self.nums = x - │ ╰─────────────────────^ attributes hash: 15243923981938152137 +22 │ ╭ pub fn write_nums(self, x: Array) { +23 │ │ self.nums = x +24 │ │ } + │ ╰─────^ attributes hash: 15243923981938152137 │ = FunctionSignature { self_decl: Some( @@ -139,25 +142,26 @@ note: } note: - ┌─ sized_vals_in_sto.fe:20:9 + ┌─ sized_vals_in_sto.fe:23:9 │ -20 │ self.nums = x +23 │ self.nums = x │ ^^^^ Foo: Value note: - ┌─ sized_vals_in_sto.fe:20:9 + ┌─ sized_vals_in_sto.fe:23:9 │ -20 │ self.nums = x +23 │ self.nums = x │ ^^^^^^^^^ ^ Array: Memory │ │ │ Array: Storage { nonce: Some(1) } note: - ┌─ sized_vals_in_sto.fe:22:5 + ┌─ sized_vals_in_sto.fe:26:5 │ -22 │ ╭ pub fn read_nums(self) -> Array: -23 │ │ return self.nums.to_mem() - │ ╰─────────────────────────────────^ attributes hash: 7235961322057554817 +26 │ ╭ pub fn read_nums(self) -> Array { +27 │ │ return self.nums.to_mem() +28 │ │ } + │ ╰─────^ attributes hash: 7235961322057554817 │ = FunctionSignature { self_decl: Some( @@ -178,29 +182,30 @@ note: } note: - ┌─ sized_vals_in_sto.fe:23:16 + ┌─ sized_vals_in_sto.fe:27:16 │ -23 │ return self.nums.to_mem() +27 │ return self.nums.to_mem() │ ^^^^ Foo: Value note: - ┌─ sized_vals_in_sto.fe:23:16 + ┌─ sized_vals_in_sto.fe:27:16 │ -23 │ return self.nums.to_mem() +27 │ return self.nums.to_mem() │ ^^^^^^^^^ Array: Storage { nonce: Some(1) } note: - ┌─ sized_vals_in_sto.fe:23:16 + ┌─ sized_vals_in_sto.fe:27:16 │ -23 │ return self.nums.to_mem() +27 │ return self.nums.to_mem() │ ^^^^^^^^^^^^^^^^^^ Array: Storage { nonce: Some(1) } => Memory note: - ┌─ sized_vals_in_sto.fe:25:5 + ┌─ sized_vals_in_sto.fe:30:5 │ -25 │ ╭ pub fn write_str(self, x: String<26>): -26 │ │ self.str = x - │ ╰────────────────────^ attributes hash: 3874088449945578306 +30 │ ╭ pub fn write_str(self, x: String<26>) { +31 │ │ self.str = x +32 │ │ } + │ ╰─────^ attributes hash: 3874088449945578306 │ = FunctionSignature { self_decl: Some( @@ -228,25 +233,26 @@ note: } note: - ┌─ sized_vals_in_sto.fe:26:9 + ┌─ sized_vals_in_sto.fe:31:9 │ -26 │ self.str = x +31 │ self.str = x │ ^^^^ Foo: Value note: - ┌─ sized_vals_in_sto.fe:26:9 + ┌─ sized_vals_in_sto.fe:31:9 │ -26 │ self.str = x +31 │ self.str = x │ ^^^^^^^^ ^ String<26>: Memory │ │ │ String<26>: Storage { nonce: Some(2) } note: - ┌─ sized_vals_in_sto.fe:28:5 + ┌─ sized_vals_in_sto.fe:34:5 │ -28 │ ╭ pub fn read_str(self) -> String<26>: -29 │ │ return self.str.to_mem() - │ ╰────────────────────────────────^ attributes hash: 3487383639176435631 +34 │ ╭ pub fn read_str(self) -> String<26> { +35 │ │ return self.str.to_mem() +36 │ │ } + │ ╰─────^ attributes hash: 3487383639176435631 │ = FunctionSignature { self_decl: Some( @@ -264,34 +270,30 @@ note: } note: - ┌─ sized_vals_in_sto.fe:29:16 + ┌─ sized_vals_in_sto.fe:35:16 │ -29 │ return self.str.to_mem() +35 │ return self.str.to_mem() │ ^^^^ Foo: Value note: - ┌─ sized_vals_in_sto.fe:29:16 + ┌─ sized_vals_in_sto.fe:35:16 │ -29 │ return self.str.to_mem() +35 │ return self.str.to_mem() │ ^^^^^^^^ String<26>: Storage { nonce: Some(2) } note: - ┌─ sized_vals_in_sto.fe:29:16 + ┌─ sized_vals_in_sto.fe:35:16 │ -29 │ return self.str.to_mem() +35 │ return self.str.to_mem() │ ^^^^^^^^^^^^^^^^^ String<26>: Storage { nonce: Some(2) } => Memory note: - ┌─ sized_vals_in_sto.fe:31:5 + ┌─ sized_vals_in_sto.fe:38:5 │ -31 │ ╭ pub fn emit_event(self, ctx: Context): -32 │ │ emit MyEvent( -33 │ │ ctx, -34 │ │ num: self.num, -35 │ │ nums: self.nums.to_mem(), -36 │ │ str: self.str.to_mem() -37 │ │ ) - │ ╰─────────^ attributes hash: 1731341862738941170 +38 │ ╭ pub fn emit_event(self, ctx: Context) { +39 │ │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) +40 │ │ } + │ ╰─────^ attributes hash: 1731341862738941170 │ = FunctionSignature { self_decl: Some( @@ -322,58 +324,53 @@ note: } note: - ┌─ sized_vals_in_sto.fe:33:13 + ┌─ sized_vals_in_sto.fe:39:22 │ -33 │ ctx, - │ ^^^ Context: Memory -34 │ num: self.num, - │ ^^^^ Foo: Value +39 │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) + │ ^^^ ^^^^ Foo: Value + │ │ + │ Context: Memory note: - ┌─ sized_vals_in_sto.fe:34:18 + ┌─ sized_vals_in_sto.fe:39:32 │ -34 │ num: self.num, - │ ^^^^^^^^ u256: Storage { nonce: Some(0) } => Value -35 │ nums: self.nums.to_mem(), - │ ^^^^ Foo: Value +39 │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) + │ ^^^^^^^^ ^^^^ Foo: Value + │ │ + │ u256: Storage { nonce: Some(0) } => Value note: - ┌─ sized_vals_in_sto.fe:35:19 + ┌─ sized_vals_in_sto.fe:39:48 │ -35 │ nums: self.nums.to_mem(), - │ ^^^^^^^^^ Array: Storage { nonce: Some(1) } +39 │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) + │ ^^^^^^^^^ Array: Storage { nonce: Some(1) } note: - ┌─ sized_vals_in_sto.fe:35:19 + ┌─ sized_vals_in_sto.fe:39:48 │ -35 │ nums: self.nums.to_mem(), - │ ^^^^^^^^^^^^^^^^^^ Array: Storage { nonce: Some(1) } => Memory -36 │ str: self.str.to_mem() - │ ^^^^ Foo: Value +39 │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) + │ ^^^^^^^^^^^^^^^^^^ ^^^^ Foo: Value + │ │ + │ Array: Storage { nonce: Some(1) } => Memory note: - ┌─ sized_vals_in_sto.fe:36:18 + ┌─ sized_vals_in_sto.fe:39:73 │ -36 │ str: self.str.to_mem() - │ ^^^^^^^^ String<26>: Storage { nonce: Some(2) } +39 │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) + │ ^^^^^^^^ String<26>: Storage { nonce: Some(2) } note: - ┌─ sized_vals_in_sto.fe:36:18 + ┌─ sized_vals_in_sto.fe:39:73 │ -36 │ str: self.str.to_mem() - │ ^^^^^^^^^^^^^^^^^ String<26>: Storage { nonce: Some(2) } => Memory +39 │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) + │ ^^^^^^^^^^^^^^^^^ String<26>: Storage { nonce: Some(2) } => Memory note: - ┌─ sized_vals_in_sto.fe:32:9 - │ -32 │ ╭ emit MyEvent( -33 │ │ ctx, -34 │ │ num: self.num, -35 │ │ nums: self.nums.to_mem(), -36 │ │ str: self.str.to_mem() -37 │ │ ) - │ ╰─────────^ attributes hash: 9998967556022527347 - │ + ┌─ sized_vals_in_sto.fe:39:9 + │ +39 │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 9998967556022527347 + │ = Event { name: "MyEvent", fields: [ diff --git a/crates/analyzer/tests/snapshots/analysis__strings.snap b/crates/analyzer/tests/snapshots/analysis__strings.snap index a4210929db..b902f24584 100644 --- a/crates/analyzer/tests/snapshots/analysis__strings.snap +++ b/crates/analyzer/tests/snapshots/analysis__strings.snap @@ -22,11 +22,12 @@ note: │ ^^^^^^^^^^^^^^^ String<100> note: - ┌─ strings.fe:16:5 + ┌─ strings.fe:18:5 │ -16 │ ╭ pub fn bar(s1: String<100>, s2: String<100>) -> String<100>: -17 │ │ return s2 - │ ╰─────────────────^ attributes hash: 4992726103398710247 +18 │ ╭ pub fn bar(s1: String<100>, s2: String<100>) -> String<100> { +19 │ │ return s2 +20 │ │ } + │ ╰─────^ attributes hash: 4992726103398710247 │ = FunctionSignature { self_decl: None, @@ -65,17 +66,18 @@ note: } note: - ┌─ strings.fe:17:16 + ┌─ strings.fe:19:16 │ -17 │ return s2 +19 │ return s2 │ ^^ String<100>: Memory note: - ┌─ strings.fe:19:5 + ┌─ strings.fe:22:5 │ -19 │ ╭ pub fn return_static_string() -> String<43>: -20 │ │ return "The quick brown fox jumps over the lazy dog" - │ ╰────────────────────────────────────────────────────────────^ attributes hash: 16859220121746101219 +22 │ ╭ pub fn return_static_string() -> String<43> { +23 │ │ return "The quick brown fox jumps over the lazy dog" +24 │ │ } + │ ╰─────^ attributes hash: 16859220121746101219 │ = FunctionSignature { self_decl: None, @@ -91,17 +93,18 @@ note: } note: - ┌─ strings.fe:20:16 + ┌─ strings.fe:23:16 │ -20 │ return "The quick brown fox jumps over the lazy dog" +23 │ return "The quick brown fox jumps over the lazy dog" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<43>: Memory note: - ┌─ strings.fe:22:5 + ┌─ strings.fe:26:5 │ -22 │ ╭ pub fn return_casted_static_string() -> String<100>: -23 │ │ return String<100>("foo") - │ ╰─────────────────────────────────^ attributes hash: 11555139189894875514 +26 │ ╭ pub fn return_casted_static_string() -> String<100> { +27 │ │ return String<100>("foo") +28 │ │ } + │ ╰─────^ attributes hash: 11555139189894875514 │ = FunctionSignature { self_decl: None, @@ -117,23 +120,24 @@ note: } note: - ┌─ strings.fe:23:28 + ┌─ strings.fe:27:28 │ -23 │ return String<100>("foo") +27 │ return String<100>("foo") │ ^^^^^ String<3>: Memory note: - ┌─ strings.fe:23:16 + ┌─ strings.fe:27:16 │ -23 │ return String<100>("foo") +27 │ return String<100>("foo") │ ^^^^^^^^^^^^^^^^^^ String<100>: Memory note: - ┌─ strings.fe:25:5 + ┌─ strings.fe:30:5 │ -25 │ ╭ pub fn shorter_string_assign(): -26 │ │ let s: String<18> = "fe" - │ ╰────────────────────────────────^ attributes hash: 8319796915330632390 +30 │ ╭ pub fn shorter_string_assign() { +31 │ │ let s: String<18> = "fe" +32 │ │ } + │ ╰─────^ attributes hash: 8319796915330632390 │ = FunctionSignature { self_decl: None, @@ -147,24 +151,25 @@ note: } note: - ┌─ strings.fe:26:16 + ┌─ strings.fe:31:16 │ -26 │ let s: String<18> = "fe" +31 │ let s: String<18> = "fe" │ ^^^^^^^^^^ String<18> note: - ┌─ strings.fe:26:29 + ┌─ strings.fe:31:29 │ -26 │ let s: String<18> = "fe" +31 │ let s: String<18> = "fe" │ ^^^^ String<18>: Memory note: - ┌─ strings.fe:28:5 + ┌─ strings.fe:34:5 │ -28 │ ╭ pub fn return_special_chars() -> String<18>: -29 │ │ return "\n\"'\r\t -30 │ │ foo\\" - │ ╰──────────────^ attributes hash: 15142206137302311439 +34 │ ╭ pub fn return_special_chars() -> String<18> { +35 │ │ return "\n\"'\r\t +36 │ │ foo\\" +37 │ │ } + │ ╰─────^ attributes hash: 15142206137302311439 │ = FunctionSignature { self_decl: None, @@ -180,11 +185,11 @@ note: } note: - ┌─ strings.fe:29:16 + ┌─ strings.fe:35:16 │ -29 │ return "\n\"'\r\t +35 │ return "\n\"'\r\t │ ╭────────────────^ -30 │ │ foo\\" +36 │ │ foo\\" │ ╰──────────────^ String<18>: Memory diff --git a/crates/analyzer/tests/snapshots/analysis__struct_fns.snap b/crates/analyzer/tests/snapshots/analysis__struct_fns.snap index 214b205b2c..9bdccbb095 100644 --- a/crates/analyzer/tests/snapshots/analysis__struct_fns.snap +++ b/crates/analyzer/tests/snapshots/analysis__struct_fns.snap @@ -4,19 +4,20 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ struct_fns.fe:2:3 + ┌─ struct_fns.fe:2:5 │ -2 │ pub x: u64 - │ ^^^^^^^^^^ u64 -3 │ pub y: u64 - │ ^^^^^^^^^^ u64 +2 │ pub x: u64 + │ ^^^^^^^^^^ u64 +3 │ pub y: u64 + │ ^^^^^^^^^^ u64 note: - ┌─ struct_fns.fe:5:3 + ┌─ struct_fns.fe:5:5 │ -5 │ ╭ pub fn new(x: u64, y: u64) -> Point: -6 │ │ return Point(x, y) - │ ╰──────────────────────^ attributes hash: 16588628800633378656 +5 │ ╭ pub fn new(x: u64, y: u64) -> Point { +6 │ │ return Point(x, y) +7 │ │ } + │ ╰─────^ attributes hash: 16588628800633378656 │ = FunctionSignature { self_decl: None, @@ -56,60 +57,62 @@ note: } note: - ┌─ struct_fns.fe:6:18 + ┌─ struct_fns.fe:6:22 │ -6 │ return Point(x, y) - │ ^ ^ u64: Value - │ │ - │ u64: Value +6 │ return Point(x, y) + │ ^ ^ u64: Value + │ │ + │ u64: Value note: - ┌─ struct_fns.fe:6:12 + ┌─ struct_fns.fe:6:16 │ -6 │ return Point(x, y) - │ ^^^^^^^^^^^ Point: Memory +6 │ return Point(x, y) + │ ^^^^^^^^^^^ Point: Memory note: - ┌─ struct_fns.fe:8:3 - │ -8 │ ╭ pub fn origin() -> Point: -9 │ │ return Point(x: 0, y: 0) - │ ╰────────────────────────────^ attributes hash: 6013258294670043138 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [], - return_type: Ok( - Struct( - Struct { - name: "Point", - field_count: 2, - }, - ), - ), - } + ┌─ struct_fns.fe:9:5 + │ + 9 │ ╭ pub fn origin() -> Point { +10 │ │ return Point(x: 0, y: 0) +11 │ │ } + │ ╰─────^ attributes hash: 6013258294670043138 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [], + return_type: Ok( + Struct( + Struct { + name: "Point", + field_count: 2, + }, + ), + ), + } note: - ┌─ struct_fns.fe:9:21 - │ -9 │ return Point(x: 0, y: 0) - │ ^ ^ u64: Value - │ │ - │ u64: Value + ┌─ struct_fns.fe:10:25 + │ +10 │ return Point(x: 0, y: 0) + │ ^ ^ u64: Value + │ │ + │ u64: Value note: - ┌─ struct_fns.fe:9:12 - │ -9 │ return Point(x: 0, y: 0) - │ ^^^^^^^^^^^^^^^^^ Point: Memory + ┌─ struct_fns.fe:10:16 + │ +10 │ return Point(x: 0, y: 0) + │ ^^^^^^^^^^^^^^^^^ Point: Memory note: - ┌─ struct_fns.fe:12:3 + ┌─ struct_fns.fe:13:5 │ -12 │ ╭ pub fn x(self) -> u64: -13 │ │ return self.x - │ ╰─────────────────^ attributes hash: 10117872852848404071 +13 │ ╭ pub fn x(self) -> u64 { +14 │ │ return self.x +15 │ │ } + │ ╰─────^ attributes hash: 10117872852848404071 │ = FunctionSignature { self_decl: Some( @@ -127,25 +130,26 @@ note: } note: - ┌─ struct_fns.fe:13:12 + ┌─ struct_fns.fe:14:16 │ -13 │ return self.x - │ ^^^^ Point: Memory +14 │ return self.x + │ ^^^^ Point: Memory note: - ┌─ struct_fns.fe:13:12 + ┌─ struct_fns.fe:14:16 │ -13 │ return self.x - │ ^^^^^^ u64: Memory => Value +14 │ return self.x + │ ^^^^^^ u64: Memory => Value note: - ┌─ struct_fns.fe:15:3 + ┌─ struct_fns.fe:17:5 │ -15 │ ╭ pub fn set_x(self, _ x: u64) -> u64: -16 │ │ let old: u64 = self.x -17 │ │ self.x = x -18 │ │ return old - │ ╰──────────────^ attributes hash: 9776752757917359734 +17 │ ╭ pub fn set_x(self, _ x: u64) -> u64 { +18 │ │ let old: u64 = self.x +19 │ │ self.x = x +20 │ │ return old +21 │ │ } + │ ╰─────^ attributes hash: 9776752757917359734 │ = FunctionSignature { self_decl: Some( @@ -177,45 +181,45 @@ note: } note: - ┌─ struct_fns.fe:16:14 + ┌─ struct_fns.fe:18:18 │ -16 │ let old: u64 = self.x - │ ^^^ u64 +18 │ let old: u64 = self.x + │ ^^^ u64 note: - ┌─ struct_fns.fe:16:20 + ┌─ struct_fns.fe:18:24 │ -16 │ let old: u64 = self.x - │ ^^^^ Point: Memory +18 │ let old: u64 = self.x + │ ^^^^ Point: Memory note: - ┌─ struct_fns.fe:16:20 + ┌─ struct_fns.fe:18:24 │ -16 │ let old: u64 = self.x - │ ^^^^^^ u64: Memory => Value -17 │ self.x = x - │ ^^^^ Point: Memory +18 │ let old: u64 = self.x + │ ^^^^^^ u64: Memory => Value +19 │ self.x = x + │ ^^^^ Point: Memory note: - ┌─ struct_fns.fe:17:5 + ┌─ struct_fns.fe:19:9 │ -17 │ self.x = x - │ ^^^^^^ ^ u64: Value - │ │ - │ u64: Memory -18 │ return old - │ ^^^ u64: Value +19 │ self.x = x + │ ^^^^^^ ^ u64: Value + │ │ + │ u64: Memory +20 │ return old + │ ^^^ u64: Value note: - ┌─ struct_fns.fe:20:3 + ┌─ struct_fns.fe:23:5 │ -20 │ ╭ pub fn reflect(self): -21 │ │ let x: u64 = self.x -22 │ │ let y: u64 = self.y -23 │ │ # self.x = self.y panics. see issue #590 -24 │ │ self.x = y -25 │ │ self.y = x - │ ╰──────────────^ attributes hash: 18235041182630809162 +23 │ ╭ pub fn reflect(self) { +24 │ │ let x: u64 = self.x +25 │ │ let y: u64 = self.y +26 │ │ self.x = y +27 │ │ self.y = x +28 │ │ } + │ ╰─────^ attributes hash: 18235041182630809162 │ = FunctionSignature { self_decl: Some( @@ -231,61 +235,61 @@ note: } note: - ┌─ struct_fns.fe:21:12 + ┌─ struct_fns.fe:24:16 │ -21 │ let x: u64 = self.x - │ ^^^ u64 -22 │ let y: u64 = self.y - │ ^^^ u64 +24 │ let x: u64 = self.x + │ ^^^ u64 +25 │ let y: u64 = self.y + │ ^^^ u64 note: - ┌─ struct_fns.fe:21:18 + ┌─ struct_fns.fe:24:22 │ -21 │ let x: u64 = self.x - │ ^^^^ Point: Memory +24 │ let x: u64 = self.x + │ ^^^^ Point: Memory note: - ┌─ struct_fns.fe:21:18 + ┌─ struct_fns.fe:24:22 │ -21 │ let x: u64 = self.x - │ ^^^^^^ u64: Memory => Value -22 │ let y: u64 = self.y - │ ^^^^ Point: Memory +24 │ let x: u64 = self.x + │ ^^^^^^ u64: Memory => Value +25 │ let y: u64 = self.y + │ ^^^^ Point: Memory note: - ┌─ struct_fns.fe:22:18 + ┌─ struct_fns.fe:25:22 │ -22 │ let y: u64 = self.y - │ ^^^^^^ u64: Memory => Value -23 │ # self.x = self.y panics. see issue #590 -24 │ self.x = y - │ ^^^^ Point: Memory +25 │ let y: u64 = self.y + │ ^^^^^^ u64: Memory => Value +26 │ self.x = y + │ ^^^^ Point: Memory note: - ┌─ struct_fns.fe:24:5 + ┌─ struct_fns.fe:26:9 │ -24 │ self.x = y - │ ^^^^^^ ^ u64: Value - │ │ - │ u64: Memory -25 │ self.y = x - │ ^^^^ Point: Memory +26 │ self.x = y + │ ^^^^^^ ^ u64: Value + │ │ + │ u64: Memory +27 │ self.y = x + │ ^^^^ Point: Memory note: - ┌─ struct_fns.fe:25:5 + ┌─ struct_fns.fe:27:9 │ -25 │ self.y = x - │ ^^^^^^ ^ u64: Value - │ │ - │ u64: Memory +27 │ self.y = x + │ ^^^^^^ ^ u64: Value + │ │ + │ u64: Memory note: - ┌─ struct_fns.fe:27:3 + ┌─ struct_fns.fe:30:5 │ -27 │ ╭ pub fn translate(self, x: u64, y: u64): -28 │ │ self.x += x -29 │ │ self.y += y - │ ╰───────────────^ attributes hash: 7723021135770029200 +30 │ ╭ pub fn translate(self, x: u64, y: u64) { +31 │ │ self.x += x +32 │ │ self.y += y +33 │ │ } + │ ╰─────^ attributes hash: 7723021135770029200 │ = FunctionSignature { self_decl: Some( @@ -324,37 +328,38 @@ note: } note: - ┌─ struct_fns.fe:28:5 + ┌─ struct_fns.fe:31:9 │ -28 │ self.x += x - │ ^^^^ Point: Memory +31 │ self.x += x + │ ^^^^ Point: Memory note: - ┌─ struct_fns.fe:28:5 + ┌─ struct_fns.fe:31:9 │ -28 │ self.x += x - │ ^^^^^^ ^ u64: Value - │ │ - │ u64: Memory -29 │ self.y += y - │ ^^^^ Point: Memory +31 │ self.x += x + │ ^^^^^^ ^ u64: Value + │ │ + │ u64: Memory +32 │ self.y += y + │ ^^^^ Point: Memory note: - ┌─ struct_fns.fe:29:5 + ┌─ struct_fns.fe:32:9 │ -29 │ self.y += y - │ ^^^^^^ ^ u64: Value - │ │ - │ u64: Memory +32 │ self.y += y + │ ^^^^^^ ^ u64: Value + │ │ + │ u64: Memory note: - ┌─ struct_fns.fe:31:3 + ┌─ struct_fns.fe:35:5 │ -31 │ ╭ pub fn add(self, _ other: Point) -> Point: -32 │ │ let x: u64 = self.x + other.x -33 │ │ let y: u64 = self.y + other.y -34 │ │ return Point(x, y) - │ ╰──────────────────────^ attributes hash: 13368777112318344367 +35 │ ╭ pub fn add(self, _ other: Point) -> Point { +36 │ │ let x: u64 = self.x + other.x +37 │ │ let y: u64 = self.y + other.y +38 │ │ return Point(x, y) +39 │ │ } + │ ╰─────^ attributes hash: 13368777112318344367 │ = FunctionSignature { self_decl: Some( @@ -388,82 +393,82 @@ note: } note: - ┌─ struct_fns.fe:32:12 + ┌─ struct_fns.fe:36:16 │ -32 │ let x: u64 = self.x + other.x - │ ^^^ u64 -33 │ let y: u64 = self.y + other.y - │ ^^^ u64 +36 │ let x: u64 = self.x + other.x + │ ^^^ u64 +37 │ let y: u64 = self.y + other.y + │ ^^^ u64 note: - ┌─ struct_fns.fe:32:18 + ┌─ struct_fns.fe:36:22 │ -32 │ let x: u64 = self.x + other.x - │ ^^^^ Point: Memory +36 │ let x: u64 = self.x + other.x + │ ^^^^ Point: Memory note: - ┌─ struct_fns.fe:32:18 + ┌─ struct_fns.fe:36:22 │ -32 │ let x: u64 = self.x + other.x - │ ^^^^^^ ^^^^^ Point: Memory - │ │ - │ u64: Memory => Value +36 │ let x: u64 = self.x + other.x + │ ^^^^^^ ^^^^^ Point: Memory + │ │ + │ u64: Memory => Value note: - ┌─ struct_fns.fe:32:27 + ┌─ struct_fns.fe:36:31 │ -32 │ let x: u64 = self.x + other.x - │ ^^^^^^^ u64: Memory => Value +36 │ let x: u64 = self.x + other.x + │ ^^^^^^^ u64: Memory => Value note: - ┌─ struct_fns.fe:32:18 + ┌─ struct_fns.fe:36:22 │ -32 │ let x: u64 = self.x + other.x - │ ^^^^^^^^^^^^^^^^ u64: Value -33 │ let y: u64 = self.y + other.y - │ ^^^^ Point: Memory +36 │ let x: u64 = self.x + other.x + │ ^^^^^^^^^^^^^^^^ u64: Value +37 │ let y: u64 = self.y + other.y + │ ^^^^ Point: Memory note: - ┌─ struct_fns.fe:33:18 + ┌─ struct_fns.fe:37:22 │ -33 │ let y: u64 = self.y + other.y - │ ^^^^^^ ^^^^^ Point: Memory - │ │ - │ u64: Memory => Value +37 │ let y: u64 = self.y + other.y + │ ^^^^^^ ^^^^^ Point: Memory + │ │ + │ u64: Memory => Value note: - ┌─ struct_fns.fe:33:27 + ┌─ struct_fns.fe:37:31 │ -33 │ let y: u64 = self.y + other.y - │ ^^^^^^^ u64: Memory => Value +37 │ let y: u64 = self.y + other.y + │ ^^^^^^^ u64: Memory => Value note: - ┌─ struct_fns.fe:33:18 + ┌─ struct_fns.fe:37:22 │ -33 │ let y: u64 = self.y + other.y - │ ^^^^^^^^^^^^^^^^ u64: Value -34 │ return Point(x, y) - │ ^ ^ u64: Value - │ │ - │ u64: Value +37 │ let y: u64 = self.y + other.y + │ ^^^^^^^^^^^^^^^^ u64: Value +38 │ return Point(x, y) + │ ^ ^ u64: Value + │ │ + │ u64: Value note: - ┌─ struct_fns.fe:34:12 + ┌─ struct_fns.fe:38:16 │ -34 │ return Point(x, y) - │ ^^^^^^^^^^^ Point: Memory +38 │ return Point(x, y) + │ ^^^^^^^^^^^ Point: Memory note: - ┌─ struct_fns.fe:36:1 + ┌─ struct_fns.fe:42:1 │ -36 │ ╭ pub fn do_pointy_things(): -37 │ │ let p1: Point = Point::origin() -38 │ │ p1.translate(x: 5, y: 10) -39 │ │ - · │ -42 │ │ -43 │ │ assert p3.x == 6 and p3.y == 12 - │ ╰─────────────────────────────────^ attributes hash: 8319796915330632390 +42 │ ╭ pub fn do_pointy_things() { +43 │ │ let p1: Point = Point::origin() +44 │ │ p1.translate(x: 5, y: 10) +45 │ │ let p2: Point = Point(x: 1, y: 2) +46 │ │ let p3: Point = p1.add(p2) +47 │ │ assert p3.x == 6 and p3.y == 12 +48 │ │ } + │ ╰─^ attributes hash: 8319796915330632390 │ = FunctionSignature { self_decl: None, @@ -477,104 +482,102 @@ note: } note: - ┌─ struct_fns.fe:37:11 + ┌─ struct_fns.fe:43:13 │ -37 │ let p1: Point = Point::origin() - │ ^^^^^ Point - · -40 │ let p2: Point = Point(x: 1, y: 2) - │ ^^^^^ Point -41 │ let p3: Point = p1.add(p2) - │ ^^^^^ Point +43 │ let p1: Point = Point::origin() + │ ^^^^^ Point +44 │ p1.translate(x: 5, y: 10) +45 │ let p2: Point = Point(x: 1, y: 2) + │ ^^^^^ Point +46 │ let p3: Point = p1.add(p2) + │ ^^^^^ Point note: - ┌─ struct_fns.fe:37:19 + ┌─ struct_fns.fe:43:21 │ -37 │ let p1: Point = Point::origin() - │ ^^^^^^^^^^^^^^^ Point: Memory -38 │ p1.translate(x: 5, y: 10) - │ ^^ ^ ^^ u64: Value - │ │ │ - │ │ u64: Value - │ Point: Memory +43 │ let p1: Point = Point::origin() + │ ^^^^^^^^^^^^^^^ Point: Memory +44 │ p1.translate(x: 5, y: 10) + │ ^^ ^ ^^ u64: Value + │ │ │ + │ │ u64: Value + │ Point: Memory note: - ┌─ struct_fns.fe:38:3 + ┌─ struct_fns.fe:44:5 │ -38 │ p1.translate(x: 5, y: 10) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -39 │ -40 │ let p2: Point = Point(x: 1, y: 2) - │ ^ ^ u64: Value - │ │ - │ u64: Value +44 │ p1.translate(x: 5, y: 10) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value +45 │ let p2: Point = Point(x: 1, y: 2) + │ ^ ^ u64: Value + │ │ + │ u64: Value note: - ┌─ struct_fns.fe:40:19 + ┌─ struct_fns.fe:45:21 │ -40 │ let p2: Point = Point(x: 1, y: 2) - │ ^^^^^^^^^^^^^^^^^ Point: Memory -41 │ let p3: Point = p1.add(p2) - │ ^^ ^^ Point: Memory - │ │ - │ Point: Memory +45 │ let p2: Point = Point(x: 1, y: 2) + │ ^^^^^^^^^^^^^^^^^ Point: Memory +46 │ let p3: Point = p1.add(p2) + │ ^^ ^^ Point: Memory + │ │ + │ Point: Memory note: - ┌─ struct_fns.fe:41:19 + ┌─ struct_fns.fe:46:21 │ -41 │ let p3: Point = p1.add(p2) - │ ^^^^^^^^^^ Point: Memory -42 │ -43 │ assert p3.x == 6 and p3.y == 12 - │ ^^ Point: Memory +46 │ let p3: Point = p1.add(p2) + │ ^^^^^^^^^^ Point: Memory +47 │ assert p3.x == 6 and p3.y == 12 + │ ^^ Point: Memory note: - ┌─ struct_fns.fe:43:10 + ┌─ struct_fns.fe:47:12 │ -43 │ assert p3.x == 6 and p3.y == 12 - │ ^^^^ ^ u64: Value - │ │ - │ u64: Memory => Value +47 │ assert p3.x == 6 and p3.y == 12 + │ ^^^^ ^ u64: Value + │ │ + │ u64: Memory => Value note: - ┌─ struct_fns.fe:43:10 + ┌─ struct_fns.fe:47:12 │ -43 │ assert p3.x == 6 and p3.y == 12 - │ ^^^^^^^^^ ^^ Point: Memory - │ │ - │ bool: Value +47 │ assert p3.x == 6 and p3.y == 12 + │ ^^^^^^^^^ ^^ Point: Memory + │ │ + │ bool: Value note: - ┌─ struct_fns.fe:43:24 + ┌─ struct_fns.fe:47:26 │ -43 │ assert p3.x == 6 and p3.y == 12 - │ ^^^^ ^^ u64: Value - │ │ - │ u64: Memory => Value +47 │ assert p3.x == 6 and p3.y == 12 + │ ^^^^ ^^ u64: Value + │ │ + │ u64: Memory => Value note: - ┌─ struct_fns.fe:43:24 + ┌─ struct_fns.fe:47:26 │ -43 │ assert p3.x == 6 and p3.y == 12 - │ ^^^^^^^^^^ bool: Value +47 │ assert p3.x == 6 and p3.y == 12 + │ ^^^^^^^^^^ bool: Value note: - ┌─ struct_fns.fe:43:10 + ┌─ struct_fns.fe:47:12 │ -43 │ assert p3.x == 6 and p3.y == 12 - │ ^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value +47 │ assert p3.x == 6 and p3.y == 12 + │ ^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value note: - ┌─ struct_fns.fe:48:3 + ┌─ struct_fns.fe:51:5 │ -48 │ ╭ pub fn bar(x: u64, y: u64) -> u64: -49 │ │ do_pointy_things() -50 │ │ -51 │ │ let p: Point = Point::new(x, y) +51 │ ╭ pub fn bar(x: u64, y: u64) -> u64 { +52 │ │ do_pointy_things() +53 │ │ let p: Point = Point::new(x, y) +54 │ │ assert p.x == x and p.y == y · │ -55 │ │ assert p.x() == y and p.y == 100 -56 │ │ return p.y - │ ╰──────────────^ attributes hash: 14881144643149919691 +58 │ │ return p.y +59 │ │ } + │ ╰─────^ attributes hash: 14881144643149919691 │ = FunctionSignature { self_decl: None, @@ -613,128 +616,127 @@ note: } note: - ┌─ struct_fns.fe:51:12 + ┌─ struct_fns.fe:53:16 │ -51 │ let p: Point = Point::new(x, y) - │ ^^^^^ Point +53 │ let p: Point = Point::new(x, y) + │ ^^^^^ Point note: - ┌─ struct_fns.fe:49:5 + ┌─ struct_fns.fe:52:9 │ -49 │ do_pointy_things() - │ ^^^^^^^^^^^^^^^^^^ (): Value -50 │ -51 │ let p: Point = Point::new(x, y) - │ ^ ^ u64: Value - │ │ - │ u64: Value +52 │ do_pointy_things() + │ ^^^^^^^^^^^^^^^^^^ (): Value +53 │ let p: Point = Point::new(x, y) + │ ^ ^ u64: Value + │ │ + │ u64: Value note: - ┌─ struct_fns.fe:51:20 + ┌─ struct_fns.fe:53:24 │ -51 │ let p: Point = Point::new(x, y) - │ ^^^^^^^^^^^^^^^^ Point: Memory -52 │ assert p.x == x and p.y == y - │ ^ Point: Memory +53 │ let p: Point = Point::new(x, y) + │ ^^^^^^^^^^^^^^^^ Point: Memory +54 │ assert p.x == x and p.y == y + │ ^ Point: Memory note: - ┌─ struct_fns.fe:52:12 + ┌─ struct_fns.fe:54:16 │ -52 │ assert p.x == x and p.y == y - │ ^^^ ^ u64: Value - │ │ - │ u64: Memory => Value +54 │ assert p.x == x and p.y == y + │ ^^^ ^ u64: Value + │ │ + │ u64: Memory => Value note: - ┌─ struct_fns.fe:52:12 + ┌─ struct_fns.fe:54:16 │ -52 │ assert p.x == x and p.y == y - │ ^^^^^^^^ ^ Point: Memory - │ │ - │ bool: Value +54 │ assert p.x == x and p.y == y + │ ^^^^^^^^ ^ Point: Memory + │ │ + │ bool: Value note: - ┌─ struct_fns.fe:52:25 + ┌─ struct_fns.fe:54:29 │ -52 │ assert p.x == x and p.y == y - │ ^^^ ^ u64: Value - │ │ - │ u64: Memory => Value +54 │ assert p.x == x and p.y == y + │ ^^^ ^ u64: Value + │ │ + │ u64: Memory => Value note: - ┌─ struct_fns.fe:52:25 + ┌─ struct_fns.fe:54:29 │ -52 │ assert p.x == x and p.y == y - │ ^^^^^^^^ bool: Value +54 │ assert p.x == x and p.y == y + │ ^^^^^^^^ bool: Value note: - ┌─ struct_fns.fe:52:12 + ┌─ struct_fns.fe:54:16 │ -52 │ assert p.x == x and p.y == y - │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value -53 │ p.set_x(100) - │ ^ ^^^ u64: Value - │ │ - │ Point: Memory +54 │ assert p.x == x and p.y == y + │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value +55 │ p.set_x(100) + │ ^ ^^^ u64: Value + │ │ + │ Point: Memory note: - ┌─ struct_fns.fe:53:5 + ┌─ struct_fns.fe:55:9 │ -53 │ p.set_x(100) - │ ^^^^^^^^^^^^ u64: Value -54 │ p.reflect() - │ ^ Point: Memory +55 │ p.set_x(100) + │ ^^^^^^^^^^^^ u64: Value +56 │ p.reflect() + │ ^ Point: Memory note: - ┌─ struct_fns.fe:54:5 + ┌─ struct_fns.fe:56:9 │ -54 │ p.reflect() - │ ^^^^^^^^^^^ (): Value -55 │ assert p.x() == y and p.y == 100 - │ ^ Point: Memory +56 │ p.reflect() + │ ^^^^^^^^^^^ (): Value +57 │ assert p.x() == y and p.y == 100 + │ ^ Point: Memory note: - ┌─ struct_fns.fe:55:12 + ┌─ struct_fns.fe:57:16 │ -55 │ assert p.x() == y and p.y == 100 - │ ^^^^^ ^ u64: Value - │ │ - │ u64: Value +57 │ assert p.x() == y and p.y == 100 + │ ^^^^^ ^ u64: Value + │ │ + │ u64: Value note: - ┌─ struct_fns.fe:55:12 + ┌─ struct_fns.fe:57:16 │ -55 │ assert p.x() == y and p.y == 100 - │ ^^^^^^^^^^ ^ Point: Memory - │ │ - │ bool: Value +57 │ assert p.x() == y and p.y == 100 + │ ^^^^^^^^^^ ^ Point: Memory + │ │ + │ bool: Value note: - ┌─ struct_fns.fe:55:27 + ┌─ struct_fns.fe:57:31 │ -55 │ assert p.x() == y and p.y == 100 - │ ^^^ ^^^ u64: Value - │ │ - │ u64: Memory => Value +57 │ assert p.x() == y and p.y == 100 + │ ^^^ ^^^ u64: Value + │ │ + │ u64: Memory => Value note: - ┌─ struct_fns.fe:55:27 + ┌─ struct_fns.fe:57:31 │ -55 │ assert p.x() == y and p.y == 100 - │ ^^^^^^^^^^ bool: Value +57 │ assert p.x() == y and p.y == 100 + │ ^^^^^^^^^^ bool: Value note: - ┌─ struct_fns.fe:55:12 + ┌─ struct_fns.fe:57:16 │ -55 │ assert p.x() == y and p.y == 100 - │ ^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -56 │ return p.y - │ ^ Point: Memory +57 │ assert p.x() == y and p.y == 100 + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value +58 │ return p.y + │ ^ Point: Memory note: - ┌─ struct_fns.fe:56:12 + ┌─ struct_fns.fe:58:16 │ -56 │ return p.y - │ ^^^ u64: Memory => Value +58 │ return p.y + │ ^^^ u64: Memory => Value diff --git a/crates/analyzer/tests/snapshots/analysis__structs.snap b/crates/analyzer/tests/snapshots/analysis__structs.snap index 6a7c612e03..3a067ab23f 100644 --- a/crates/analyzer/tests/snapshots/analysis__structs.snap +++ b/crates/analyzer/tests/snapshots/analysis__structs.snap @@ -12,31 +12,32 @@ note: │ ^^^^^^^^^^^ u256 note: - ┌─ structs.fe:6:5 - │ -6 │ pub name: String<3> - │ ^^^^^^^^^^^^^^^^^^^ String<3> -7 │ pub numbers: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array -8 │ pub point: Point - │ ^^^^^^^^^^^^^^^^ Point -9 │ pub something: (u256, bool) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ (u256, bool) + ┌─ structs.fe:7:5 + │ + 7 │ pub name: String<3> + │ ^^^^^^^^^^^^^^^^^^^ String<3> + 8 │ pub numbers: Array + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + 9 │ pub point: Point + │ ^^^^^^^^^^^^^^^^ Point +10 │ pub something: (u256, bool) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ (u256, bool) note: - ┌─ structs.fe:12:5 + ┌─ structs.fe:14:5 │ -12 │ pub foo: u256 +14 │ pub foo: u256 │ ^^^^^^^^^^^^^ u256 -13 │ bar: bool +15 │ bar: bool │ ^^^^^^^^^ bool note: - ┌─ structs.fe:15:5 + ┌─ structs.fe:17:5 │ -15 │ ╭ pub fn new(val: u256) -> Mixed: -16 │ │ return Mixed(foo: val, bar: false) - │ ╰──────────────────────────────────────────^ attributes hash: 2524938698704972422 +17 │ ╭ pub fn new(val: u256) -> Mixed { +18 │ │ return Mixed(foo: val, bar: false) +19 │ │ } + │ ╰─────^ attributes hash: 2524938698704972422 │ = FunctionSignature { self_decl: None, @@ -65,37 +66,38 @@ note: } note: - ┌─ structs.fe:16:27 + ┌─ structs.fe:18:27 │ -16 │ return Mixed(foo: val, bar: false) +18 │ return Mixed(foo: val, bar: false) │ ^^^ ^^^^^ bool: Value │ │ │ u256: Value note: - ┌─ structs.fe:16:16 + ┌─ structs.fe:18:16 │ -16 │ return Mixed(foo: val, bar: false) +18 │ return Mixed(foo: val, bar: false) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Mixed: Memory note: - ┌─ structs.fe:19:5 + ┌─ structs.fe:23:5 │ -19 │ pub price: u256 +23 │ pub price: u256 │ ^^^^^^^^^^^^^^^ u256 -20 │ pub size: u256 +24 │ pub size: u256 │ ^^^^^^^^^^^^^^ u256 -21 │ pub rooms: u8 +25 │ pub rooms: u8 │ ^^^^^^^^^^^^^ u8 -22 │ pub vacant: bool +26 │ pub vacant: bool │ ^^^^^^^^^^^^^^^^ bool note: - ┌─ structs.fe:24:5 + ┌─ structs.fe:28:5 │ -24 │ ╭ pub fn encode(self) -> Array: -25 │ │ return self.abi_encode() - │ ╰────────────────────────────────^ attributes hash: 2052929893622941907 +28 │ ╭ pub fn encode(self) -> Array { +29 │ │ return self.abi_encode() +30 │ │ } + │ ╰─────^ attributes hash: 2052929893622941907 │ = FunctionSignature { self_decl: Some( @@ -116,23 +118,24 @@ note: } note: - ┌─ structs.fe:25:16 + ┌─ structs.fe:29:16 │ -25 │ return self.abi_encode() +29 │ return self.abi_encode() │ ^^^^ House: Memory note: - ┌─ structs.fe:25:16 + ┌─ structs.fe:29:16 │ -25 │ return self.abi_encode() +29 │ return self.abi_encode() │ ^^^^^^^^^^^^^^^^^ Array: Memory note: - ┌─ structs.fe:27:5 + ┌─ structs.fe:32:5 │ -27 │ ╭ pub fn hash(self) -> u256: -28 │ │ return keccak256(self.encode()) - │ ╰───────────────────────────────────────^ attributes hash: 11773348765973600208 +32 │ ╭ pub fn hash(self) -> u256 { +33 │ │ return keccak256(self.encode()) +34 │ │ } + │ ╰─────^ attributes hash: 11773348765973600208 │ = FunctionSignature { self_decl: Some( @@ -150,29 +153,30 @@ note: } note: - ┌─ structs.fe:28:26 + ┌─ structs.fe:33:26 │ -28 │ return keccak256(self.encode()) +33 │ return keccak256(self.encode()) │ ^^^^ House: Memory note: - ┌─ structs.fe:28:26 + ┌─ structs.fe:33:26 │ -28 │ return keccak256(self.encode()) +33 │ return keccak256(self.encode()) │ ^^^^^^^^^^^^^ Array: Memory note: - ┌─ structs.fe:28:16 + ┌─ structs.fe:33:16 │ -28 │ return keccak256(self.encode()) +33 │ return keccak256(self.encode()) │ ^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ structs.fe:30:5 + ┌─ structs.fe:36:5 │ -30 │ ╭ pub fn price_per_sqft(self) -> u256: -31 │ │ return self.price / self.size - │ ╰─────────────────────────────────────^ attributes hash: 11773348765973600208 +36 │ ╭ pub fn price_per_sqft(self) -> u256 { +37 │ │ return self.price / self.size +38 │ │ } + │ ╰─────^ attributes hash: 11773348765973600208 │ = FunctionSignature { self_decl: Some( @@ -190,38 +194,39 @@ note: } note: - ┌─ structs.fe:31:16 + ┌─ structs.fe:37:16 │ -31 │ return self.price / self.size +37 │ return self.price / self.size │ ^^^^ House: Memory note: - ┌─ structs.fe:31:16 + ┌─ structs.fe:37:16 │ -31 │ return self.price / self.size +37 │ return self.price / self.size │ ^^^^^^^^^^ ^^^^ House: Memory │ │ │ u256: Memory => Value note: - ┌─ structs.fe:31:29 + ┌─ structs.fe:37:29 │ -31 │ return self.price / self.size +37 │ return self.price / self.size │ ^^^^^^^^^ u256: Memory => Value note: - ┌─ structs.fe:31:16 + ┌─ structs.fe:37:16 │ -31 │ return self.price / self.size +37 │ return self.price / self.size │ ^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ structs.fe:33:5 + ┌─ structs.fe:40:5 │ -33 │ ╭ pub fn expand(self): -34 │ │ self.rooms += 1 -35 │ │ self.size += 100 - │ ╰────────────────────────^ attributes hash: 18235041182630809162 +40 │ ╭ pub fn expand(self) { +41 │ │ self.rooms += 1 +42 │ │ self.size += 100 +43 │ │ } + │ ╰─────^ attributes hash: 18235041182630809162 │ = FunctionSignature { self_decl: Some( @@ -237,48 +242,48 @@ note: } note: - ┌─ structs.fe:34:9 + ┌─ structs.fe:41:9 │ -34 │ self.rooms += 1 +41 │ self.rooms += 1 │ ^^^^ House: Memory note: - ┌─ structs.fe:34:9 + ┌─ structs.fe:41:9 │ -34 │ self.rooms += 1 +41 │ self.rooms += 1 │ ^^^^^^^^^^ ^ u8: Value │ │ │ u8: Memory -35 │ self.size += 100 +42 │ self.size += 100 │ ^^^^ House: Memory note: - ┌─ structs.fe:35:9 + ┌─ structs.fe:42:9 │ -35 │ self.size += 100 +42 │ self.size += 100 │ ^^^^^^^^^ ^^^ u256: Value │ │ │ u256: Memory note: - ┌─ structs.fe:38:5 + ┌─ structs.fe:47:5 │ -38 │ my_house: House +47 │ my_house: House │ ^^^^^^^^^^^^^^^ House -39 │ my_bar: Bar +48 │ my_bar: Bar │ ^^^^^^^^^^^ Bar note: - ┌─ structs.fe:41:5 + ┌─ structs.fe:50:5 │ -41 │ ╭ pub fn complex_struct_in_storage(self) -> String<3>: -42 │ │ self.my_bar = Bar( -43 │ │ name: "foo", -44 │ │ numbers: [1, 2], +50 │ ╭ pub fn complex_struct_in_storage(self) -> String<3> { +51 │ │ self.my_bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) +52 │ │ assert self.my_bar.numbers[0] == 1 +53 │ │ assert self.my_bar.numbers[1] == 2 · │ -86 │ │ -87 │ │ return self.my_bar.name.to_mem() - │ ╰────────────────────────────────────────^ attributes hash: 7100809906483982919 +79 │ │ return self.my_bar.name.to_mem() +80 │ │ } + │ ╰─────^ attributes hash: 7100809906483982919 │ = FunctionSignature { self_decl: Some( @@ -296,226 +301,214 @@ note: } note: - ┌─ structs.fe:42:9 + ┌─ structs.fe:51:9 │ -42 │ self.my_bar = Bar( +51 │ self.my_bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) │ ^^^^ Foo: Value note: - ┌─ structs.fe:42:9 + ┌─ structs.fe:51:9 │ -42 │ self.my_bar = Bar( - │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } -43 │ name: "foo", - │ ^^^^^ String<3>: Memory -44 │ numbers: [1, 2], - │ ^ ^ u256: Value - │ │ - │ u256: Value +51 │ self.my_bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) + │ ^^^^^^^^^^^ ^^^^^ ^ ^ u256: Value + │ │ │ │ + │ │ │ u256: Value + │ │ String<3>: Memory + │ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:44:22 + ┌─ structs.fe:51:49 │ -44 │ numbers: [1, 2], - │ ^^^^^^ Array: Memory -45 │ point: Point(x: 100, y: 200), - │ ^^^ ^^^ u256: Value - │ │ - │ u256: Value +51 │ self.my_bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) + │ ^^^^^^ ^^^ ^^^ u256: Value + │ │ │ + │ │ u256: Value + │ Array: Memory note: - ┌─ structs.fe:45:20 + ┌─ structs.fe:51:64 │ -45 │ point: Point(x: 100, y: 200), - │ ^^^^^^^^^^^^^^^^^^^^^ Point: Memory -46 │ something: (1, true), - │ ^ ^^^^ bool: Value - │ │ - │ u256: Value +51 │ self.my_bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) + │ ^^^^^^^^^^^^^^^^^^^^^ ^ ^^^^ bool: Value + │ │ │ + │ │ u256: Value + │ Point: Memory note: - ┌─ structs.fe:46:24 + ┌─ structs.fe:51:98 │ -46 │ something: (1, true), - │ ^^^^^^^^^ (u256, bool): Memory +51 │ self.my_bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) + │ ^^^^^^^^^ (u256, bool): Memory note: - ┌─ structs.fe:42:23 - │ -42 │ self.my_bar = Bar( - │ ╭───────────────────────^ -43 │ │ name: "foo", -44 │ │ numbers: [1, 2], -45 │ │ point: Point(x: 100, y: 200), -46 │ │ something: (1, true), -47 │ │ ) - │ ╰─────────^ Bar: Memory - · │ -50 │ assert self.my_bar.numbers[0] == 1 - │ ^^^^ Foo: Value + ┌─ structs.fe:51:23 + │ +51 │ self.my_bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Bar: Memory +52 │ assert self.my_bar.numbers[0] == 1 + │ ^^^^ Foo: Value note: - ┌─ structs.fe:50:16 + ┌─ structs.fe:52:16 │ -50 │ assert self.my_bar.numbers[0] == 1 +52 │ assert self.my_bar.numbers[0] == 1 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:50:16 + ┌─ structs.fe:52:16 │ -50 │ assert self.my_bar.numbers[0] == 1 +52 │ assert self.my_bar.numbers[0] == 1 │ ^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Storage { nonce: Some(1) } note: - ┌─ structs.fe:50:16 + ┌─ structs.fe:52:16 │ -50 │ assert self.my_bar.numbers[0] == 1 +52 │ assert self.my_bar.numbers[0] == 1 │ ^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ structs.fe:50:16 + ┌─ structs.fe:52:16 │ -50 │ assert self.my_bar.numbers[0] == 1 +52 │ assert self.my_bar.numbers[0] == 1 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -51 │ assert self.my_bar.numbers[1] == 2 +53 │ assert self.my_bar.numbers[1] == 2 │ ^^^^ Foo: Value note: - ┌─ structs.fe:51:16 + ┌─ structs.fe:53:16 │ -51 │ assert self.my_bar.numbers[1] == 2 +53 │ assert self.my_bar.numbers[1] == 2 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:51:16 + ┌─ structs.fe:53:16 │ -51 │ assert self.my_bar.numbers[1] == 2 +53 │ assert self.my_bar.numbers[1] == 2 │ ^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Storage { nonce: Some(1) } note: - ┌─ structs.fe:51:16 + ┌─ structs.fe:53:16 │ -51 │ assert self.my_bar.numbers[1] == 2 +53 │ assert self.my_bar.numbers[1] == 2 │ ^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ structs.fe:51:16 + ┌─ structs.fe:53:16 │ -51 │ assert self.my_bar.numbers[1] == 2 +53 │ assert self.my_bar.numbers[1] == 2 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -52 │ assert self.my_bar.point.x == 100 +54 │ assert self.my_bar.point.x == 100 │ ^^^^ Foo: Value note: - ┌─ structs.fe:52:16 + ┌─ structs.fe:54:16 │ -52 │ assert self.my_bar.point.x == 100 +54 │ assert self.my_bar.point.x == 100 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:52:16 + ┌─ structs.fe:54:16 │ -52 │ assert self.my_bar.point.x == 100 +54 │ assert self.my_bar.point.x == 100 │ ^^^^^^^^^^^^^^^^^ Point: Storage { nonce: Some(1) } note: - ┌─ structs.fe:52:16 + ┌─ structs.fe:54:16 │ -52 │ assert self.my_bar.point.x == 100 +54 │ assert self.my_bar.point.x == 100 │ ^^^^^^^^^^^^^^^^^^^ ^^^ u256: Value │ │ │ u256: Storage { nonce: Some(1) } => Value note: - ┌─ structs.fe:52:16 + ┌─ structs.fe:54:16 │ -52 │ assert self.my_bar.point.x == 100 +54 │ assert self.my_bar.point.x == 100 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -53 │ assert self.my_bar.point.y == 200 +55 │ assert self.my_bar.point.y == 200 │ ^^^^ Foo: Value note: - ┌─ structs.fe:53:16 + ┌─ structs.fe:55:16 │ -53 │ assert self.my_bar.point.y == 200 +55 │ assert self.my_bar.point.y == 200 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:53:16 + ┌─ structs.fe:55:16 │ -53 │ assert self.my_bar.point.y == 200 +55 │ assert self.my_bar.point.y == 200 │ ^^^^^^^^^^^^^^^^^ Point: Storage { nonce: Some(1) } note: - ┌─ structs.fe:53:16 + ┌─ structs.fe:55:16 │ -53 │ assert self.my_bar.point.y == 200 +55 │ assert self.my_bar.point.y == 200 │ ^^^^^^^^^^^^^^^^^^^ ^^^ u256: Value │ │ │ u256: Storage { nonce: Some(1) } => Value note: - ┌─ structs.fe:53:16 + ┌─ structs.fe:55:16 │ -53 │ assert self.my_bar.point.y == 200 +55 │ assert self.my_bar.point.y == 200 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -54 │ assert self.my_bar.something.item0 == 1 +56 │ assert self.my_bar.something.item0 == 1 │ ^^^^ Foo: Value note: - ┌─ structs.fe:54:16 + ┌─ structs.fe:56:16 │ -54 │ assert self.my_bar.something.item0 == 1 +56 │ assert self.my_bar.something.item0 == 1 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:54:16 + ┌─ structs.fe:56:16 │ -54 │ assert self.my_bar.something.item0 == 1 +56 │ assert self.my_bar.something.item0 == 1 │ ^^^^^^^^^^^^^^^^^^^^^ (u256, bool): Storage { nonce: Some(1) } note: - ┌─ structs.fe:54:16 + ┌─ structs.fe:56:16 │ -54 │ assert self.my_bar.something.item0 == 1 +56 │ assert self.my_bar.something.item0 == 1 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: Some(1) } => Value note: - ┌─ structs.fe:54:16 + ┌─ structs.fe:56:16 │ -54 │ assert self.my_bar.something.item0 == 1 +56 │ assert self.my_bar.something.item0 == 1 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -55 │ assert self.my_bar.something.item1 +57 │ assert self.my_bar.something.item1 │ ^^^^ Foo: Value note: - ┌─ structs.fe:55:16 + ┌─ structs.fe:57:16 │ -55 │ assert self.my_bar.something.item1 +57 │ assert self.my_bar.something.item1 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:55:16 + ┌─ structs.fe:57:16 │ -55 │ assert self.my_bar.something.item1 +57 │ assert self.my_bar.something.item1 │ ^^^^^^^^^^^^^^^^^^^^^ (u256, bool): Storage { nonce: Some(1) } note: - ┌─ structs.fe:55:16 + ┌─ structs.fe:57:16 │ -55 │ assert self.my_bar.something.item1 +57 │ assert self.my_bar.something.item1 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Storage { nonce: Some(1) } => Value - · 58 │ self.my_bar.numbers[0] = 10 │ ^^^^ Foo: Value @@ -624,475 +617,469 @@ note: │ 61 │ assert self.my_bar.numbers[1] == 20 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -62 │ # We can set the array itself -63 │ self.my_bar.numbers = [1, 2] +62 │ self.my_bar.numbers = [1, 2] │ ^^^^ Foo: Value note: - ┌─ structs.fe:63:9 + ┌─ structs.fe:62:9 │ -63 │ self.my_bar.numbers = [1, 2] +62 │ self.my_bar.numbers = [1, 2] │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:63:9 + ┌─ structs.fe:62:9 │ -63 │ self.my_bar.numbers = [1, 2] +62 │ self.my_bar.numbers = [1, 2] │ ^^^^^^^^^^^^^^^^^^^ ^ ^ u256: Value │ │ │ │ │ u256: Value │ Array: Storage { nonce: Some(1) } note: - ┌─ structs.fe:63:31 + ┌─ structs.fe:62:31 │ -63 │ self.my_bar.numbers = [1, 2] +62 │ self.my_bar.numbers = [1, 2] │ ^^^^^^ Array: Memory -64 │ assert self.my_bar.numbers[0] == 1 +63 │ assert self.my_bar.numbers[0] == 1 │ ^^^^ Foo: Value note: - ┌─ structs.fe:64:16 + ┌─ structs.fe:63:16 │ -64 │ assert self.my_bar.numbers[0] == 1 +63 │ assert self.my_bar.numbers[0] == 1 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:64:16 + ┌─ structs.fe:63:16 │ -64 │ assert self.my_bar.numbers[0] == 1 +63 │ assert self.my_bar.numbers[0] == 1 │ ^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Storage { nonce: Some(1) } note: - ┌─ structs.fe:64:16 + ┌─ structs.fe:63:16 │ -64 │ assert self.my_bar.numbers[0] == 1 +63 │ assert self.my_bar.numbers[0] == 1 │ ^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ structs.fe:64:16 + ┌─ structs.fe:63:16 │ -64 │ assert self.my_bar.numbers[0] == 1 +63 │ assert self.my_bar.numbers[0] == 1 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -65 │ assert self.my_bar.numbers[1] == 2 +64 │ assert self.my_bar.numbers[1] == 2 │ ^^^^ Foo: Value note: - ┌─ structs.fe:65:16 + ┌─ structs.fe:64:16 │ -65 │ assert self.my_bar.numbers[1] == 2 +64 │ assert self.my_bar.numbers[1] == 2 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:65:16 + ┌─ structs.fe:64:16 │ -65 │ assert self.my_bar.numbers[1] == 2 +64 │ assert self.my_bar.numbers[1] == 2 │ ^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Storage { nonce: Some(1) } note: - ┌─ structs.fe:65:16 + ┌─ structs.fe:64:16 │ -65 │ assert self.my_bar.numbers[1] == 2 +64 │ assert self.my_bar.numbers[1] == 2 │ ^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ structs.fe:65:16 + ┌─ structs.fe:64:16 │ -65 │ assert self.my_bar.numbers[1] == 2 +64 │ assert self.my_bar.numbers[1] == 2 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value - · -68 │ self.my_bar.point.x = 1000 +65 │ self.my_bar.point.x = 1000 │ ^^^^ Foo: Value note: - ┌─ structs.fe:68:9 + ┌─ structs.fe:65:9 │ -68 │ self.my_bar.point.x = 1000 +65 │ self.my_bar.point.x = 1000 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:68:9 + ┌─ structs.fe:65:9 │ -68 │ self.my_bar.point.x = 1000 +65 │ self.my_bar.point.x = 1000 │ ^^^^^^^^^^^^^^^^^ Point: Storage { nonce: Some(1) } note: - ┌─ structs.fe:68:9 + ┌─ structs.fe:65:9 │ -68 │ self.my_bar.point.x = 1000 +65 │ self.my_bar.point.x = 1000 │ ^^^^^^^^^^^^^^^^^^^ ^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(1) } -69 │ self.my_bar.point.y = 2000 +66 │ self.my_bar.point.y = 2000 │ ^^^^ Foo: Value note: - ┌─ structs.fe:69:9 + ┌─ structs.fe:66:9 │ -69 │ self.my_bar.point.y = 2000 +66 │ self.my_bar.point.y = 2000 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:69:9 + ┌─ structs.fe:66:9 │ -69 │ self.my_bar.point.y = 2000 +66 │ self.my_bar.point.y = 2000 │ ^^^^^^^^^^^^^^^^^ Point: Storage { nonce: Some(1) } note: - ┌─ structs.fe:69:9 + ┌─ structs.fe:66:9 │ -69 │ self.my_bar.point.y = 2000 +66 │ self.my_bar.point.y = 2000 │ ^^^^^^^^^^^^^^^^^^^ ^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(1) } -70 │ assert self.my_bar.point.x == 1000 +67 │ assert self.my_bar.point.x == 1000 │ ^^^^ Foo: Value note: - ┌─ structs.fe:70:16 + ┌─ structs.fe:67:16 │ -70 │ assert self.my_bar.point.x == 1000 +67 │ assert self.my_bar.point.x == 1000 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:70:16 + ┌─ structs.fe:67:16 │ -70 │ assert self.my_bar.point.x == 1000 +67 │ assert self.my_bar.point.x == 1000 │ ^^^^^^^^^^^^^^^^^ Point: Storage { nonce: Some(1) } note: - ┌─ structs.fe:70:16 + ┌─ structs.fe:67:16 │ -70 │ assert self.my_bar.point.x == 1000 +67 │ assert self.my_bar.point.x == 1000 │ ^^^^^^^^^^^^^^^^^^^ ^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(1) } => Value note: - ┌─ structs.fe:70:16 + ┌─ structs.fe:67:16 │ -70 │ assert self.my_bar.point.x == 1000 +67 │ assert self.my_bar.point.x == 1000 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -71 │ assert self.my_bar.point.y == 2000 +68 │ assert self.my_bar.point.y == 2000 │ ^^^^ Foo: Value note: - ┌─ structs.fe:71:16 + ┌─ structs.fe:68:16 │ -71 │ assert self.my_bar.point.y == 2000 +68 │ assert self.my_bar.point.y == 2000 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:71:16 + ┌─ structs.fe:68:16 │ -71 │ assert self.my_bar.point.y == 2000 +68 │ assert self.my_bar.point.y == 2000 │ ^^^^^^^^^^^^^^^^^ Point: Storage { nonce: Some(1) } note: - ┌─ structs.fe:71:16 + ┌─ structs.fe:68:16 │ -71 │ assert self.my_bar.point.y == 2000 +68 │ assert self.my_bar.point.y == 2000 │ ^^^^^^^^^^^^^^^^^^^ ^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(1) } => Value note: - ┌─ structs.fe:71:16 + ┌─ structs.fe:68:16 │ -71 │ assert self.my_bar.point.y == 2000 +68 │ assert self.my_bar.point.y == 2000 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -72 │ # We can set the point itself -73 │ self.my_bar.point = Point(x: 100, y: 200) +69 │ self.my_bar.point = Point(x: 100, y: 200) │ ^^^^ Foo: Value note: - ┌─ structs.fe:73:9 + ┌─ structs.fe:69:9 │ -73 │ self.my_bar.point = Point(x: 100, y: 200) +69 │ self.my_bar.point = Point(x: 100, y: 200) │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:73:9 + ┌─ structs.fe:69:9 │ -73 │ self.my_bar.point = Point(x: 100, y: 200) +69 │ self.my_bar.point = Point(x: 100, y: 200) │ ^^^^^^^^^^^^^^^^^ ^^^ ^^^ u256: Value │ │ │ │ │ u256: Value │ Point: Storage { nonce: Some(1) } note: - ┌─ structs.fe:73:29 + ┌─ structs.fe:69:29 │ -73 │ self.my_bar.point = Point(x: 100, y: 200) +69 │ self.my_bar.point = Point(x: 100, y: 200) │ ^^^^^^^^^^^^^^^^^^^^^ Point: Memory -74 │ assert self.my_bar.point.x == 100 +70 │ assert self.my_bar.point.x == 100 │ ^^^^ Foo: Value note: - ┌─ structs.fe:74:16 + ┌─ structs.fe:70:16 │ -74 │ assert self.my_bar.point.x == 100 +70 │ assert self.my_bar.point.x == 100 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:74:16 + ┌─ structs.fe:70:16 │ -74 │ assert self.my_bar.point.x == 100 +70 │ assert self.my_bar.point.x == 100 │ ^^^^^^^^^^^^^^^^^ Point: Storage { nonce: Some(1) } note: - ┌─ structs.fe:74:16 + ┌─ structs.fe:70:16 │ -74 │ assert self.my_bar.point.x == 100 +70 │ assert self.my_bar.point.x == 100 │ ^^^^^^^^^^^^^^^^^^^ ^^^ u256: Value │ │ │ u256: Storage { nonce: Some(1) } => Value note: - ┌─ structs.fe:74:16 + ┌─ structs.fe:70:16 │ -74 │ assert self.my_bar.point.x == 100 +70 │ assert self.my_bar.point.x == 100 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -75 │ assert self.my_bar.point.y == 200 +71 │ assert self.my_bar.point.y == 200 │ ^^^^ Foo: Value note: - ┌─ structs.fe:75:16 + ┌─ structs.fe:71:16 │ -75 │ assert self.my_bar.point.y == 200 +71 │ assert self.my_bar.point.y == 200 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:75:16 + ┌─ structs.fe:71:16 │ -75 │ assert self.my_bar.point.y == 200 +71 │ assert self.my_bar.point.y == 200 │ ^^^^^^^^^^^^^^^^^ Point: Storage { nonce: Some(1) } note: - ┌─ structs.fe:75:16 + ┌─ structs.fe:71:16 │ -75 │ assert self.my_bar.point.y == 200 +71 │ assert self.my_bar.point.y == 200 │ ^^^^^^^^^^^^^^^^^^^ ^^^ u256: Value │ │ │ u256: Storage { nonce: Some(1) } => Value note: - ┌─ structs.fe:75:16 + ┌─ structs.fe:71:16 │ -75 │ assert self.my_bar.point.y == 200 +71 │ assert self.my_bar.point.y == 200 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value - · -78 │ self.my_bar.something.item0 = 10 +72 │ self.my_bar.something.item0 = 10 │ ^^^^ Foo: Value note: - ┌─ structs.fe:78:9 + ┌─ structs.fe:72:9 │ -78 │ self.my_bar.something.item0 = 10 +72 │ self.my_bar.something.item0 = 10 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:78:9 + ┌─ structs.fe:72:9 │ -78 │ self.my_bar.something.item0 = 10 +72 │ self.my_bar.something.item0 = 10 │ ^^^^^^^^^^^^^^^^^^^^^ (u256, bool): Storage { nonce: Some(1) } note: - ┌─ structs.fe:78:9 + ┌─ structs.fe:72:9 │ -78 │ self.my_bar.something.item0 = 10 +72 │ self.my_bar.something.item0 = 10 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Storage { nonce: Some(1) } -79 │ self.my_bar.something.item1 = false +73 │ self.my_bar.something.item1 = false │ ^^^^ Foo: Value note: - ┌─ structs.fe:79:9 + ┌─ structs.fe:73:9 │ -79 │ self.my_bar.something.item1 = false +73 │ self.my_bar.something.item1 = false │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:79:9 + ┌─ structs.fe:73:9 │ -79 │ self.my_bar.something.item1 = false +73 │ self.my_bar.something.item1 = false │ ^^^^^^^^^^^^^^^^^^^^^ (u256, bool): Storage { nonce: Some(1) } note: - ┌─ structs.fe:79:9 + ┌─ structs.fe:73:9 │ -79 │ self.my_bar.something.item1 = false +73 │ self.my_bar.something.item1 = false │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ bool: Value │ │ │ bool: Storage { nonce: Some(1) } -80 │ assert self.my_bar.something.item0 == 10 +74 │ assert self.my_bar.something.item0 == 10 │ ^^^^ Foo: Value note: - ┌─ structs.fe:80:16 + ┌─ structs.fe:74:16 │ -80 │ assert self.my_bar.something.item0 == 10 +74 │ assert self.my_bar.something.item0 == 10 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:80:16 + ┌─ structs.fe:74:16 │ -80 │ assert self.my_bar.something.item0 == 10 +74 │ assert self.my_bar.something.item0 == 10 │ ^^^^^^^^^^^^^^^^^^^^^ (u256, bool): Storage { nonce: Some(1) } note: - ┌─ structs.fe:80:16 + ┌─ structs.fe:74:16 │ -80 │ assert self.my_bar.something.item0 == 10 +74 │ assert self.my_bar.something.item0 == 10 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Storage { nonce: Some(1) } => Value note: - ┌─ structs.fe:80:16 + ┌─ structs.fe:74:16 │ -80 │ assert self.my_bar.something.item0 == 10 +74 │ assert self.my_bar.something.item0 == 10 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -81 │ assert not self.my_bar.something.item1 +75 │ assert not self.my_bar.something.item1 │ ^^^^ Foo: Value note: - ┌─ structs.fe:81:20 + ┌─ structs.fe:75:20 │ -81 │ assert not self.my_bar.something.item1 +75 │ assert not self.my_bar.something.item1 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:81:20 + ┌─ structs.fe:75:20 │ -81 │ assert not self.my_bar.something.item1 +75 │ assert not self.my_bar.something.item1 │ ^^^^^^^^^^^^^^^^^^^^^ (u256, bool): Storage { nonce: Some(1) } note: - ┌─ structs.fe:81:20 + ┌─ structs.fe:75:20 │ -81 │ assert not self.my_bar.something.item1 +75 │ assert not self.my_bar.something.item1 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Storage { nonce: Some(1) } => Value note: - ┌─ structs.fe:81:16 + ┌─ structs.fe:75:16 │ -81 │ assert not self.my_bar.something.item1 +75 │ assert not self.my_bar.something.item1 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -82 │ # We can set the tuple itself -83 │ self.my_bar.something = (1, true) +76 │ self.my_bar.something = (1, true) │ ^^^^ Foo: Value note: - ┌─ structs.fe:83:9 + ┌─ structs.fe:76:9 │ -83 │ self.my_bar.something = (1, true) +76 │ self.my_bar.something = (1, true) │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:83:9 + ┌─ structs.fe:76:9 │ -83 │ self.my_bar.something = (1, true) +76 │ self.my_bar.something = (1, true) │ ^^^^^^^^^^^^^^^^^^^^^ ^ ^^^^ bool: Value │ │ │ │ │ u256: Value │ (u256, bool): Storage { nonce: Some(1) } note: - ┌─ structs.fe:83:33 + ┌─ structs.fe:76:33 │ -83 │ self.my_bar.something = (1, true) +76 │ self.my_bar.something = (1, true) │ ^^^^^^^^^ (u256, bool): Memory -84 │ assert self.my_bar.something.item0 == 1 +77 │ assert self.my_bar.something.item0 == 1 │ ^^^^ Foo: Value note: - ┌─ structs.fe:84:16 + ┌─ structs.fe:77:16 │ -84 │ assert self.my_bar.something.item0 == 1 +77 │ assert self.my_bar.something.item0 == 1 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:84:16 + ┌─ structs.fe:77:16 │ -84 │ assert self.my_bar.something.item0 == 1 +77 │ assert self.my_bar.something.item0 == 1 │ ^^^^^^^^^^^^^^^^^^^^^ (u256, bool): Storage { nonce: Some(1) } note: - ┌─ structs.fe:84:16 + ┌─ structs.fe:77:16 │ -84 │ assert self.my_bar.something.item0 == 1 +77 │ assert self.my_bar.something.item0 == 1 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: Some(1) } => Value note: - ┌─ structs.fe:84:16 + ┌─ structs.fe:77:16 │ -84 │ assert self.my_bar.something.item0 == 1 +77 │ assert self.my_bar.something.item0 == 1 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -85 │ assert self.my_bar.something.item1 +78 │ assert self.my_bar.something.item1 │ ^^^^ Foo: Value note: - ┌─ structs.fe:85:16 + ┌─ structs.fe:78:16 │ -85 │ assert self.my_bar.something.item1 +78 │ assert self.my_bar.something.item1 │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:85:16 + ┌─ structs.fe:78:16 │ -85 │ assert self.my_bar.something.item1 +78 │ assert self.my_bar.something.item1 │ ^^^^^^^^^^^^^^^^^^^^^ (u256, bool): Storage { nonce: Some(1) } note: - ┌─ structs.fe:85:16 + ┌─ structs.fe:78:16 │ -85 │ assert self.my_bar.something.item1 +78 │ assert self.my_bar.something.item1 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Storage { nonce: Some(1) } => Value -86 │ -87 │ return self.my_bar.name.to_mem() +79 │ return self.my_bar.name.to_mem() │ ^^^^ Foo: Value note: - ┌─ structs.fe:87:16 + ┌─ structs.fe:79:16 │ -87 │ return self.my_bar.name.to_mem() +79 │ return self.my_bar.name.to_mem() │ ^^^^^^^^^^^ Bar: Storage { nonce: Some(1) } note: - ┌─ structs.fe:87:16 + ┌─ structs.fe:79:16 │ -87 │ return self.my_bar.name.to_mem() +79 │ return self.my_bar.name.to_mem() │ ^^^^^^^^^^^^^^^^ String<3>: Storage { nonce: Some(1) } note: - ┌─ structs.fe:87:16 + ┌─ structs.fe:79:16 │ -87 │ return self.my_bar.name.to_mem() +79 │ return self.my_bar.name.to_mem() │ ^^^^^^^^^^^^^^^^^^^^^^^^^ String<3>: Storage { nonce: Some(1) } => Memory note: - ┌─ structs.fe:89:5 + ┌─ structs.fe:82:5 │ - 89 │ ╭ pub fn complex_struct_in_memory(self) -> String<3>: - 90 │ │ let val: Bar = Bar( - 91 │ │ name: "foo", - 92 │ │ numbers: [1, 2], + 82 │ ╭ pub fn complex_struct_in_memory(self) -> String<3> { + 83 │ │ let val: Bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) + 84 │ │ assert val.numbers[0] == 1 + 85 │ │ assert val.numbers[1] == 2 · │ -134 │ │ -135 │ │ return val.name - │ ╰───────────────────────^ attributes hash: 7100809906483982919 +111 │ │ return val.name +112 │ │ } + │ ╰─────^ attributes hash: 7100809906483982919 │ = FunctionSignature { self_decl: Some( @@ -1110,623 +1097,607 @@ note: } note: - ┌─ structs.fe:90:18 + ┌─ structs.fe:83:18 │ -90 │ let val: Bar = Bar( +83 │ let val: Bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) │ ^^^ Bar note: - ┌─ structs.fe:91:19 + ┌─ structs.fe:83:34 │ -91 │ name: "foo", - │ ^^^^^ String<3>: Memory -92 │ numbers: [1, 2], - │ ^ ^ u256: Value - │ │ - │ u256: Value +83 │ let val: Bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) + │ ^^^^^ ^ ^ u256: Value + │ │ │ + │ │ u256: Value + │ String<3>: Memory note: - ┌─ structs.fe:92:22 + ┌─ structs.fe:83:50 │ -92 │ numbers: [1, 2], - │ ^^^^^^ Array: Memory -93 │ point: Point(x: 100, y: 200), - │ ^^^ ^^^ u256: Value - │ │ - │ u256: Value +83 │ let val: Bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) + │ ^^^^^^ ^^^ ^^^ u256: Value + │ │ │ + │ │ u256: Value + │ Array: Memory note: - ┌─ structs.fe:93:20 + ┌─ structs.fe:83:65 │ -93 │ point: Point(x: 100, y: 200), - │ ^^^^^^^^^^^^^^^^^^^^^ Point: Memory -94 │ something: (1, true), - │ ^ ^^^^ bool: Value - │ │ - │ u256: Value +83 │ let val: Bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) + │ ^^^^^^^^^^^^^^^^^^^^^ ^ ^^^^ bool: Value + │ │ │ + │ │ u256: Value + │ Point: Memory note: - ┌─ structs.fe:94:24 + ┌─ structs.fe:83:99 │ -94 │ something: (1, true), - │ ^^^^^^^^^ (u256, bool): Memory +83 │ let val: Bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) + │ ^^^^^^^^^ (u256, bool): Memory note: - ┌─ structs.fe:90:24 - │ -90 │ let val: Bar = Bar( - │ ╭────────────────────────^ -91 │ │ name: "foo", -92 │ │ numbers: [1, 2], -93 │ │ point: Point(x: 100, y: 200), -94 │ │ something: (1, true), -95 │ │ ) - │ ╰─────────^ Bar: Memory - · │ -98 │ assert val.numbers[0] == 1 - │ ^^^ Bar: Memory + ┌─ structs.fe:83:24 + │ +83 │ let val: Bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Bar: Memory +84 │ assert val.numbers[0] == 1 + │ ^^^ Bar: Memory note: - ┌─ structs.fe:98:16 + ┌─ structs.fe:84:16 │ -98 │ assert val.numbers[0] == 1 +84 │ assert val.numbers[0] == 1 │ ^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ structs.fe:98:16 + ┌─ structs.fe:84:16 │ -98 │ assert val.numbers[0] == 1 +84 │ assert val.numbers[0] == 1 │ ^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ structs.fe:98:16 + ┌─ structs.fe:84:16 │ -98 │ assert val.numbers[0] == 1 +84 │ assert val.numbers[0] == 1 │ ^^^^^^^^^^^^^^^^^^^ bool: Value -99 │ assert val.numbers[1] == 2 +85 │ assert val.numbers[1] == 2 │ ^^^ Bar: Memory note: - ┌─ structs.fe:99:16 + ┌─ structs.fe:85:16 │ -99 │ assert val.numbers[1] == 2 +85 │ assert val.numbers[1] == 2 │ ^^^^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ structs.fe:99:16 + ┌─ structs.fe:85:16 │ -99 │ assert val.numbers[1] == 2 +85 │ assert val.numbers[1] == 2 │ ^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ structs.fe:99:16 - │ - 99 │ assert val.numbers[1] == 2 - │ ^^^^^^^^^^^^^^^^^^^ bool: Value -100 │ assert val.point.x == 100 - │ ^^^ Bar: Memory + ┌─ structs.fe:85:16 + │ +85 │ assert val.numbers[1] == 2 + │ ^^^^^^^^^^^^^^^^^^^ bool: Value +86 │ assert val.point.x == 100 + │ ^^^ Bar: Memory note: - ┌─ structs.fe:100:16 - │ -100 │ assert val.point.x == 100 - │ ^^^^^^^^^ Point: Memory + ┌─ structs.fe:86:16 + │ +86 │ assert val.point.x == 100 + │ ^^^^^^^^^ Point: Memory note: - ┌─ structs.fe:100:16 - │ -100 │ assert val.point.x == 100 - │ ^^^^^^^^^^^ ^^^ u256: Value - │ │ - │ u256: Memory => Value + ┌─ structs.fe:86:16 + │ +86 │ assert val.point.x == 100 + │ ^^^^^^^^^^^ ^^^ u256: Value + │ │ + │ u256: Memory => Value note: - ┌─ structs.fe:100:16 - │ -100 │ assert val.point.x == 100 - │ ^^^^^^^^^^^^^^^^^^ bool: Value -101 │ assert val.point.y == 200 - │ ^^^ Bar: Memory + ┌─ structs.fe:86:16 + │ +86 │ assert val.point.x == 100 + │ ^^^^^^^^^^^^^^^^^^ bool: Value +87 │ assert val.point.y == 200 + │ ^^^ Bar: Memory note: - ┌─ structs.fe:101:16 - │ -101 │ assert val.point.y == 200 - │ ^^^^^^^^^ Point: Memory + ┌─ structs.fe:87:16 + │ +87 │ assert val.point.y == 200 + │ ^^^^^^^^^ Point: Memory note: - ┌─ structs.fe:101:16 - │ -101 │ assert val.point.y == 200 - │ ^^^^^^^^^^^ ^^^ u256: Value - │ │ - │ u256: Memory => Value + ┌─ structs.fe:87:16 + │ +87 │ assert val.point.y == 200 + │ ^^^^^^^^^^^ ^^^ u256: Value + │ │ + │ u256: Memory => Value note: - ┌─ structs.fe:101:16 - │ -101 │ assert val.point.y == 200 - │ ^^^^^^^^^^^^^^^^^^ bool: Value -102 │ assert val.something.item0 == 1 - │ ^^^ Bar: Memory + ┌─ structs.fe:87:16 + │ +87 │ assert val.point.y == 200 + │ ^^^^^^^^^^^^^^^^^^ bool: Value +88 │ assert val.something.item0 == 1 + │ ^^^ Bar: Memory note: - ┌─ structs.fe:102:16 - │ -102 │ assert val.something.item0 == 1 - │ ^^^^^^^^^^^^^ (u256, bool): Memory + ┌─ structs.fe:88:16 + │ +88 │ assert val.something.item0 == 1 + │ ^^^^^^^^^^^^^ (u256, bool): Memory note: - ┌─ structs.fe:102:16 - │ -102 │ assert val.something.item0 == 1 - │ ^^^^^^^^^^^^^^^^^^^ ^ u256: Value - │ │ - │ u256: Memory => Value + ┌─ structs.fe:88:16 + │ +88 │ assert val.something.item0 == 1 + │ ^^^^^^^^^^^^^^^^^^^ ^ u256: Value + │ │ + │ u256: Memory => Value note: - ┌─ structs.fe:102:16 - │ -102 │ assert val.something.item0 == 1 - │ ^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -103 │ assert val.something.item1 - │ ^^^ Bar: Memory + ┌─ structs.fe:88:16 + │ +88 │ assert val.something.item0 == 1 + │ ^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value +89 │ assert val.something.item1 + │ ^^^ Bar: Memory note: - ┌─ structs.fe:103:16 - │ -103 │ assert val.something.item1 - │ ^^^^^^^^^^^^^ (u256, bool): Memory + ┌─ structs.fe:89:16 + │ +89 │ assert val.something.item1 + │ ^^^^^^^^^^^^^ (u256, bool): Memory note: - ┌─ structs.fe:103:16 - │ -103 │ assert val.something.item1 - │ ^^^^^^^^^^^^^^^^^^^ bool: Memory => Value - · -106 │ val.numbers[0] = 10 - │ ^^^ Bar: Memory + ┌─ structs.fe:89:16 + │ +89 │ assert val.something.item1 + │ ^^^^^^^^^^^^^^^^^^^ bool: Memory => Value +90 │ val.numbers[0] = 10 + │ ^^^ Bar: Memory note: - ┌─ structs.fe:106:9 - │ -106 │ val.numbers[0] = 10 - │ ^^^^^^^^^^^ ^ u256: Value - │ │ - │ Array: Memory + ┌─ structs.fe:90:9 + │ +90 │ val.numbers[0] = 10 + │ ^^^^^^^^^^^ ^ u256: Value + │ │ + │ Array: Memory note: - ┌─ structs.fe:106:9 - │ -106 │ val.numbers[0] = 10 - │ ^^^^^^^^^^^^^^ ^^ u256: Value - │ │ - │ u256: Memory -107 │ val.numbers[1] = 20 - │ ^^^ Bar: Memory + ┌─ structs.fe:90:9 + │ +90 │ val.numbers[0] = 10 + │ ^^^^^^^^^^^^^^ ^^ u256: Value + │ │ + │ u256: Memory +91 │ val.numbers[1] = 20 + │ ^^^ Bar: Memory note: - ┌─ structs.fe:107:9 - │ -107 │ val.numbers[1] = 20 - │ ^^^^^^^^^^^ ^ u256: Value - │ │ - │ Array: Memory + ┌─ structs.fe:91:9 + │ +91 │ val.numbers[1] = 20 + │ ^^^^^^^^^^^ ^ u256: Value + │ │ + │ Array: Memory note: - ┌─ structs.fe:107:9 - │ -107 │ val.numbers[1] = 20 - │ ^^^^^^^^^^^^^^ ^^ u256: Value - │ │ - │ u256: Memory -108 │ assert val.numbers[0] == 10 - │ ^^^ Bar: Memory + ┌─ structs.fe:91:9 + │ +91 │ val.numbers[1] = 20 + │ ^^^^^^^^^^^^^^ ^^ u256: Value + │ │ + │ u256: Memory +92 │ assert val.numbers[0] == 10 + │ ^^^ Bar: Memory note: - ┌─ structs.fe:108:16 - │ -108 │ assert val.numbers[0] == 10 - │ ^^^^^^^^^^^ ^ u256: Value - │ │ - │ Array: Memory + ┌─ structs.fe:92:16 + │ +92 │ assert val.numbers[0] == 10 + │ ^^^^^^^^^^^ ^ u256: Value + │ │ + │ Array: Memory note: - ┌─ structs.fe:108:16 - │ -108 │ assert val.numbers[0] == 10 - │ ^^^^^^^^^^^^^^ ^^ u256: Value - │ │ - │ u256: Memory => Value + ┌─ structs.fe:92:16 + │ +92 │ assert val.numbers[0] == 10 + │ ^^^^^^^^^^^^^^ ^^ u256: Value + │ │ + │ u256: Memory => Value note: - ┌─ structs.fe:108:16 - │ -108 │ assert val.numbers[0] == 10 - │ ^^^^^^^^^^^^^^^^^^^^ bool: Value -109 │ assert val.numbers[1] == 20 - │ ^^^ Bar: Memory + ┌─ structs.fe:92:16 + │ +92 │ assert val.numbers[0] == 10 + │ ^^^^^^^^^^^^^^^^^^^^ bool: Value +93 │ assert val.numbers[1] == 20 + │ ^^^ Bar: Memory note: - ┌─ structs.fe:109:16 - │ -109 │ assert val.numbers[1] == 20 - │ ^^^^^^^^^^^ ^ u256: Value - │ │ - │ Array: Memory + ┌─ structs.fe:93:16 + │ +93 │ assert val.numbers[1] == 20 + │ ^^^^^^^^^^^ ^ u256: Value + │ │ + │ Array: Memory note: - ┌─ structs.fe:109:16 - │ -109 │ assert val.numbers[1] == 20 - │ ^^^^^^^^^^^^^^ ^^ u256: Value - │ │ - │ u256: Memory => Value + ┌─ structs.fe:93:16 + │ +93 │ assert val.numbers[1] == 20 + │ ^^^^^^^^^^^^^^ ^^ u256: Value + │ │ + │ u256: Memory => Value note: - ┌─ structs.fe:109:16 - │ -109 │ assert val.numbers[1] == 20 - │ ^^^^^^^^^^^^^^^^^^^^ bool: Value -110 │ # We can set the array itself -111 │ val.numbers = [1, 2] - │ ^^^ Bar: Memory + ┌─ structs.fe:93:16 + │ +93 │ assert val.numbers[1] == 20 + │ ^^^^^^^^^^^^^^^^^^^^ bool: Value +94 │ val.numbers = [1, 2] + │ ^^^ Bar: Memory note: - ┌─ structs.fe:111:9 - │ -111 │ val.numbers = [1, 2] - │ ^^^^^^^^^^^ ^ ^ u256: Value - │ │ │ - │ │ u256: Value - │ Array: Memory + ┌─ structs.fe:94:9 + │ +94 │ val.numbers = [1, 2] + │ ^^^^^^^^^^^ ^ ^ u256: Value + │ │ │ + │ │ u256: Value + │ Array: Memory note: - ┌─ structs.fe:111:23 - │ -111 │ val.numbers = [1, 2] - │ ^^^^^^ Array: Memory -112 │ assert val.numbers[0] == 1 - │ ^^^ Bar: Memory + ┌─ structs.fe:94:23 + │ +94 │ val.numbers = [1, 2] + │ ^^^^^^ Array: Memory +95 │ assert val.numbers[0] == 1 + │ ^^^ Bar: Memory note: - ┌─ structs.fe:112:16 - │ -112 │ assert val.numbers[0] == 1 - │ ^^^^^^^^^^^ ^ u256: Value - │ │ - │ Array: Memory + ┌─ structs.fe:95:16 + │ +95 │ assert val.numbers[0] == 1 + │ ^^^^^^^^^^^ ^ u256: Value + │ │ + │ Array: Memory note: - ┌─ structs.fe:112:16 - │ -112 │ assert val.numbers[0] == 1 - │ ^^^^^^^^^^^^^^ ^ u256: Value - │ │ - │ u256: Memory => Value + ┌─ structs.fe:95:16 + │ +95 │ assert val.numbers[0] == 1 + │ ^^^^^^^^^^^^^^ ^ u256: Value + │ │ + │ u256: Memory => Value note: - ┌─ structs.fe:112:16 - │ -112 │ assert val.numbers[0] == 1 - │ ^^^^^^^^^^^^^^^^^^^ bool: Value -113 │ assert val.numbers[1] == 2 - │ ^^^ Bar: Memory + ┌─ structs.fe:95:16 + │ +95 │ assert val.numbers[0] == 1 + │ ^^^^^^^^^^^^^^^^^^^ bool: Value +96 │ assert val.numbers[1] == 2 + │ ^^^ Bar: Memory note: - ┌─ structs.fe:113:16 - │ -113 │ assert val.numbers[1] == 2 - │ ^^^^^^^^^^^ ^ u256: Value - │ │ - │ Array: Memory + ┌─ structs.fe:96:16 + │ +96 │ assert val.numbers[1] == 2 + │ ^^^^^^^^^^^ ^ u256: Value + │ │ + │ Array: Memory note: - ┌─ structs.fe:113:16 - │ -113 │ assert val.numbers[1] == 2 - │ ^^^^^^^^^^^^^^ ^ u256: Value - │ │ - │ u256: Memory => Value + ┌─ structs.fe:96:16 + │ +96 │ assert val.numbers[1] == 2 + │ ^^^^^^^^^^^^^^ ^ u256: Value + │ │ + │ u256: Memory => Value note: - ┌─ structs.fe:113:16 - │ -113 │ assert val.numbers[1] == 2 - │ ^^^^^^^^^^^^^^^^^^^ bool: Value - · -116 │ val.point.x = 1000 - │ ^^^ Bar: Memory + ┌─ structs.fe:96:16 + │ +96 │ assert val.numbers[1] == 2 + │ ^^^^^^^^^^^^^^^^^^^ bool: Value +97 │ val.point.x = 1000 + │ ^^^ Bar: Memory note: - ┌─ structs.fe:116:9 - │ -116 │ val.point.x = 1000 - │ ^^^^^^^^^ Point: Memory + ┌─ structs.fe:97:9 + │ +97 │ val.point.x = 1000 + │ ^^^^^^^^^ Point: Memory note: - ┌─ structs.fe:116:9 - │ -116 │ val.point.x = 1000 - │ ^^^^^^^^^^^ ^^^^ u256: Value - │ │ - │ u256: Memory -117 │ val.point.y = 2000 - │ ^^^ Bar: Memory + ┌─ structs.fe:97:9 + │ +97 │ val.point.x = 1000 + │ ^^^^^^^^^^^ ^^^^ u256: Value + │ │ + │ u256: Memory +98 │ val.point.y = 2000 + │ ^^^ Bar: Memory note: - ┌─ structs.fe:117:9 - │ -117 │ val.point.y = 2000 - │ ^^^^^^^^^ Point: Memory + ┌─ structs.fe:98:9 + │ +98 │ val.point.y = 2000 + │ ^^^^^^^^^ Point: Memory note: - ┌─ structs.fe:117:9 - │ -117 │ val.point.y = 2000 - │ ^^^^^^^^^^^ ^^^^ u256: Value - │ │ - │ u256: Memory -118 │ assert val.point.x == 1000 - │ ^^^ Bar: Memory + ┌─ structs.fe:98:9 + │ +98 │ val.point.y = 2000 + │ ^^^^^^^^^^^ ^^^^ u256: Value + │ │ + │ u256: Memory +99 │ assert val.point.x == 1000 + │ ^^^ Bar: Memory note: - ┌─ structs.fe:118:16 - │ -118 │ assert val.point.x == 1000 - │ ^^^^^^^^^ Point: Memory + ┌─ structs.fe:99:16 + │ +99 │ assert val.point.x == 1000 + │ ^^^^^^^^^ Point: Memory note: - ┌─ structs.fe:118:16 - │ -118 │ assert val.point.x == 1000 - │ ^^^^^^^^^^^ ^^^^ u256: Value - │ │ - │ u256: Memory => Value + ┌─ structs.fe:99:16 + │ +99 │ assert val.point.x == 1000 + │ ^^^^^^^^^^^ ^^^^ u256: Value + │ │ + │ u256: Memory => Value note: - ┌─ structs.fe:118:16 + ┌─ structs.fe:99:16 │ -118 │ assert val.point.x == 1000 + 99 │ assert val.point.x == 1000 │ ^^^^^^^^^^^^^^^^^^^ bool: Value -119 │ assert val.point.y == 2000 +100 │ assert val.point.y == 2000 │ ^^^ Bar: Memory note: - ┌─ structs.fe:119:16 + ┌─ structs.fe:100:16 │ -119 │ assert val.point.y == 2000 +100 │ assert val.point.y == 2000 │ ^^^^^^^^^ Point: Memory note: - ┌─ structs.fe:119:16 + ┌─ structs.fe:100:16 │ -119 │ assert val.point.y == 2000 +100 │ assert val.point.y == 2000 │ ^^^^^^^^^^^ ^^^^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ structs.fe:119:16 + ┌─ structs.fe:100:16 │ -119 │ assert val.point.y == 2000 +100 │ assert val.point.y == 2000 │ ^^^^^^^^^^^^^^^^^^^ bool: Value -120 │ # We can set the point itself -121 │ val.point = Point(x: 100, y: 200) +101 │ val.point = Point(x: 100, y: 200) │ ^^^ Bar: Memory note: - ┌─ structs.fe:121:9 + ┌─ structs.fe:101:9 │ -121 │ val.point = Point(x: 100, y: 200) +101 │ val.point = Point(x: 100, y: 200) │ ^^^^^^^^^ ^^^ ^^^ u256: Value │ │ │ │ │ u256: Value │ Point: Memory note: - ┌─ structs.fe:121:21 + ┌─ structs.fe:101:21 │ -121 │ val.point = Point(x: 100, y: 200) +101 │ val.point = Point(x: 100, y: 200) │ ^^^^^^^^^^^^^^^^^^^^^ Point: Memory -122 │ assert val.point.x == 100 +102 │ assert val.point.x == 100 │ ^^^ Bar: Memory note: - ┌─ structs.fe:122:16 + ┌─ structs.fe:102:16 │ -122 │ assert val.point.x == 100 +102 │ assert val.point.x == 100 │ ^^^^^^^^^ Point: Memory note: - ┌─ structs.fe:122:16 + ┌─ structs.fe:102:16 │ -122 │ assert val.point.x == 100 +102 │ assert val.point.x == 100 │ ^^^^^^^^^^^ ^^^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ structs.fe:122:16 + ┌─ structs.fe:102:16 │ -122 │ assert val.point.x == 100 +102 │ assert val.point.x == 100 │ ^^^^^^^^^^^^^^^^^^ bool: Value -123 │ assert val.point.y == 200 +103 │ assert val.point.y == 200 │ ^^^ Bar: Memory note: - ┌─ structs.fe:123:16 + ┌─ structs.fe:103:16 │ -123 │ assert val.point.y == 200 +103 │ assert val.point.y == 200 │ ^^^^^^^^^ Point: Memory note: - ┌─ structs.fe:123:16 + ┌─ structs.fe:103:16 │ -123 │ assert val.point.y == 200 +103 │ assert val.point.y == 200 │ ^^^^^^^^^^^ ^^^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ structs.fe:123:16 + ┌─ structs.fe:103:16 │ -123 │ assert val.point.y == 200 +103 │ assert val.point.y == 200 │ ^^^^^^^^^^^^^^^^^^ bool: Value - · -126 │ val.something.item0 = 10 +104 │ val.something.item0 = 10 │ ^^^ Bar: Memory note: - ┌─ structs.fe:126:9 + ┌─ structs.fe:104:9 │ -126 │ val.something.item0 = 10 +104 │ val.something.item0 = 10 │ ^^^^^^^^^^^^^ (u256, bool): Memory note: - ┌─ structs.fe:126:9 + ┌─ structs.fe:104:9 │ -126 │ val.something.item0 = 10 +104 │ val.something.item0 = 10 │ ^^^^^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Memory -127 │ val.something.item1 = false +105 │ val.something.item1 = false │ ^^^ Bar: Memory note: - ┌─ structs.fe:127:9 + ┌─ structs.fe:105:9 │ -127 │ val.something.item1 = false +105 │ val.something.item1 = false │ ^^^^^^^^^^^^^ (u256, bool): Memory note: - ┌─ structs.fe:127:9 + ┌─ structs.fe:105:9 │ -127 │ val.something.item1 = false +105 │ val.something.item1 = false │ ^^^^^^^^^^^^^^^^^^^ ^^^^^ bool: Value │ │ │ bool: Memory -128 │ assert val.something.item0 == 10 +106 │ assert val.something.item0 == 10 │ ^^^ Bar: Memory note: - ┌─ structs.fe:128:16 + ┌─ structs.fe:106:16 │ -128 │ assert val.something.item0 == 10 +106 │ assert val.something.item0 == 10 │ ^^^^^^^^^^^^^ (u256, bool): Memory note: - ┌─ structs.fe:128:16 + ┌─ structs.fe:106:16 │ -128 │ assert val.something.item0 == 10 +106 │ assert val.something.item0 == 10 │ ^^^^^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ structs.fe:128:16 + ┌─ structs.fe:106:16 │ -128 │ assert val.something.item0 == 10 +106 │ assert val.something.item0 == 10 │ ^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -129 │ assert not val.something.item1 +107 │ assert not val.something.item1 │ ^^^ Bar: Memory note: - ┌─ structs.fe:129:20 + ┌─ structs.fe:107:20 │ -129 │ assert not val.something.item1 +107 │ assert not val.something.item1 │ ^^^^^^^^^^^^^ (u256, bool): Memory note: - ┌─ structs.fe:129:20 + ┌─ structs.fe:107:20 │ -129 │ assert not val.something.item1 +107 │ assert not val.something.item1 │ ^^^^^^^^^^^^^^^^^^^ bool: Memory => Value note: - ┌─ structs.fe:129:16 + ┌─ structs.fe:107:16 │ -129 │ assert not val.something.item1 +107 │ assert not val.something.item1 │ ^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -130 │ # We can set the tuple itself -131 │ val.something = (1, true) +108 │ val.something = (1, true) │ ^^^ Bar: Memory note: - ┌─ structs.fe:131:9 + ┌─ structs.fe:108:9 │ -131 │ val.something = (1, true) +108 │ val.something = (1, true) │ ^^^^^^^^^^^^^ ^ ^^^^ bool: Value │ │ │ │ │ u256: Value │ (u256, bool): Memory note: - ┌─ structs.fe:131:25 + ┌─ structs.fe:108:25 │ -131 │ val.something = (1, true) +108 │ val.something = (1, true) │ ^^^^^^^^^ (u256, bool): Memory -132 │ assert val.something.item0 == 1 +109 │ assert val.something.item0 == 1 │ ^^^ Bar: Memory note: - ┌─ structs.fe:132:16 + ┌─ structs.fe:109:16 │ -132 │ assert val.something.item0 == 1 +109 │ assert val.something.item0 == 1 │ ^^^^^^^^^^^^^ (u256, bool): Memory note: - ┌─ structs.fe:132:16 + ┌─ structs.fe:109:16 │ -132 │ assert val.something.item0 == 1 +109 │ assert val.something.item0 == 1 │ ^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ structs.fe:132:16 + ┌─ structs.fe:109:16 │ -132 │ assert val.something.item0 == 1 +109 │ assert val.something.item0 == 1 │ ^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -133 │ assert val.something.item1 +110 │ assert val.something.item1 │ ^^^ Bar: Memory note: - ┌─ structs.fe:133:16 + ┌─ structs.fe:110:16 │ -133 │ assert val.something.item1 +110 │ assert val.something.item1 │ ^^^^^^^^^^^^^ (u256, bool): Memory note: - ┌─ structs.fe:133:16 + ┌─ structs.fe:110:16 │ -133 │ assert val.something.item1 +110 │ assert val.something.item1 │ ^^^^^^^^^^^^^^^^^^^ bool: Memory => Value -134 │ -135 │ return val.name +111 │ return val.name │ ^^^ Bar: Memory note: - ┌─ structs.fe:135:16 + ┌─ structs.fe:111:16 │ -135 │ return val.name +111 │ return val.name │ ^^^^^^^^ String<3>: Memory note: - ┌─ structs.fe:137:5 + ┌─ structs.fe:114:5 │ -137 │ ╭ pub fn create_mixed(self) -> u256: -138 │ │ let mixed: Mixed = Mixed::new(val:1) -139 │ │ return mixed.foo - │ ╰────────────────────────^ attributes hash: 11773348765973600208 +114 │ ╭ pub fn create_mixed(self) -> u256 { +115 │ │ let mixed: Mixed = Mixed::new(val: 1) +116 │ │ return mixed.foo +117 │ │ } + │ ╰─────^ attributes hash: 11773348765973600208 │ = FunctionSignature { self_decl: Some( @@ -1744,37 +1715,38 @@ note: } note: - ┌─ structs.fe:138:20 + ┌─ structs.fe:115:20 │ -138 │ let mixed: Mixed = Mixed::new(val:1) +115 │ let mixed: Mixed = Mixed::new(val: 1) │ ^^^^^ Mixed note: - ┌─ structs.fe:138:43 + ┌─ structs.fe:115:44 │ -138 │ let mixed: Mixed = Mixed::new(val:1) - │ ^ u256: Value +115 │ let mixed: Mixed = Mixed::new(val: 1) + │ ^ u256: Value note: - ┌─ structs.fe:138:28 + ┌─ structs.fe:115:28 │ -138 │ let mixed: Mixed = Mixed::new(val:1) - │ ^^^^^^^^^^^^^^^^^ Mixed: Memory -139 │ return mixed.foo +115 │ let mixed: Mixed = Mixed::new(val: 1) + │ ^^^^^^^^^^^^^^^^^^ Mixed: Memory +116 │ return mixed.foo │ ^^^^^ Mixed: Memory note: - ┌─ structs.fe:139:16 + ┌─ structs.fe:116:16 │ -139 │ return mixed.foo +116 │ return mixed.foo │ ^^^^^^^^^ u256: Memory => Value note: - ┌─ structs.fe:141:5 + ┌─ structs.fe:119:5 │ -141 │ ╭ pub fn set_house(self, data: House): -142 │ │ self.my_house = data - │ ╰────────────────────────────^ attributes hash: 571714015924720006 +119 │ ╭ pub fn set_house(self, data: House) { +120 │ │ self.my_house = data +121 │ │ } + │ ╰─────^ attributes hash: 571714015924720006 │ = FunctionSignature { self_decl: Some( @@ -1803,25 +1775,26 @@ note: } note: - ┌─ structs.fe:142:9 + ┌─ structs.fe:120:9 │ -142 │ self.my_house = data +120 │ self.my_house = data │ ^^^^ Foo: Value note: - ┌─ structs.fe:142:9 + ┌─ structs.fe:120:9 │ -142 │ self.my_house = data +120 │ self.my_house = data │ ^^^^^^^^^^^^^ ^^^^ House: Memory │ │ │ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:144:5 + ┌─ structs.fe:123:5 │ -144 │ ╭ pub fn get_house(self) -> House: -145 │ │ return self.my_house.to_mem() - │ ╰─────────────────────────────────────^ attributes hash: 18226871377775469920 +123 │ ╭ pub fn get_house(self) -> House { +124 │ │ return self.my_house.to_mem() +125 │ │ } + │ ╰─────^ attributes hash: 18226871377775469920 │ = FunctionSignature { self_decl: Some( @@ -1840,34 +1813,34 @@ note: } note: - ┌─ structs.fe:145:16 + ┌─ structs.fe:124:16 │ -145 │ return self.my_house.to_mem() +124 │ return self.my_house.to_mem() │ ^^^^ Foo: Value note: - ┌─ structs.fe:145:16 + ┌─ structs.fe:124:16 │ -145 │ return self.my_house.to_mem() +124 │ return self.my_house.to_mem() │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:145:16 + ┌─ structs.fe:124:16 │ -145 │ return self.my_house.to_mem() +124 │ return self.my_house.to_mem() │ ^^^^^^^^^^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } => Memory note: - ┌─ structs.fe:147:5 + ┌─ structs.fe:127:5 │ -147 │ ╭ pub fn create_house(self): -148 │ │ self.my_house = House( -149 │ │ price: 1, -150 │ │ size: 2, +127 │ ╭ pub fn create_house(self) { +128 │ │ self.my_house = House(price: 1, size: 2, rooms: u8(5), vacant: false) +129 │ │ assert self.my_house.price == 1 +130 │ │ assert self.my_house.size == 2 · │ -178 │ │ assert self.my_house.rooms == u8(100) -179 │ │ assert self.my_house.vacant - │ ╰───────────────────────────────────^ attributes hash: 18235041182630809162 +152 │ │ assert self.my_house.vacant +153 │ │ } + │ ╰─────^ attributes hash: 18235041182630809162 │ = FunctionSignature { self_decl: Some( @@ -1883,580 +1856,570 @@ note: } note: - ┌─ structs.fe:148:9 + ┌─ structs.fe:128:9 │ -148 │ self.my_house = House( +128 │ self.my_house = House(price: 1, size: 2, rooms: u8(5), vacant: false) │ ^^^^ Foo: Value note: - ┌─ structs.fe:148:9 + ┌─ structs.fe:128:9 │ -148 │ self.my_house = House( - │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } -149 │ price: 1, - │ ^ u256: Value -150 │ size: 2, - │ ^ u256: Value -151 │ rooms: u8(5), - │ ^ u8: Value +128 │ self.my_house = House(price: 1, size: 2, rooms: u8(5), vacant: false) + │ ^^^^^^^^^^^^^ ^ ^ ^ u8: Value + │ │ │ │ + │ │ │ u256: Value + │ │ u256: Value + │ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:151:20 + ┌─ structs.fe:128:57 │ -151 │ rooms: u8(5), - │ ^^^^^ u8: Value -152 │ vacant: false, - │ ^^^^^ bool: Value +128 │ self.my_house = House(price: 1, size: 2, rooms: u8(5), vacant: false) + │ ^^^^^ ^^^^^ bool: Value + │ │ + │ u8: Value note: - ┌─ structs.fe:148:25 - │ -148 │ self.my_house = House( - │ ╭─────────────────────────^ -149 │ │ price: 1, -150 │ │ size: 2, -151 │ │ rooms: u8(5), -152 │ │ vacant: false, -153 │ │ ) - │ ╰─────────^ House: Memory -154 │ assert self.my_house.price == 1 - │ ^^^^ Foo: Value + ┌─ structs.fe:128:25 + │ +128 │ self.my_house = House(price: 1, size: 2, rooms: u8(5), vacant: false) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ House: Memory +129 │ assert self.my_house.price == 1 + │ ^^^^ Foo: Value note: - ┌─ structs.fe:154:16 + ┌─ structs.fe:129:16 │ -154 │ assert self.my_house.price == 1 +129 │ assert self.my_house.price == 1 │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:154:16 + ┌─ structs.fe:129:16 │ -154 │ assert self.my_house.price == 1 +129 │ assert self.my_house.price == 1 │ ^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:154:16 + ┌─ structs.fe:129:16 │ -154 │ assert self.my_house.price == 1 +129 │ assert self.my_house.price == 1 │ ^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -155 │ assert self.my_house.size == 2 +130 │ assert self.my_house.size == 2 │ ^^^^ Foo: Value note: - ┌─ structs.fe:155:16 + ┌─ structs.fe:130:16 │ -155 │ assert self.my_house.size == 2 +130 │ assert self.my_house.size == 2 │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:155:16 + ┌─ structs.fe:130:16 │ -155 │ assert self.my_house.size == 2 +130 │ assert self.my_house.size == 2 │ ^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:155:16 + ┌─ structs.fe:130:16 │ -155 │ assert self.my_house.size == 2 +130 │ assert self.my_house.size == 2 │ ^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -156 │ assert self.my_house.rooms == u8(5) +131 │ assert self.my_house.rooms == u8(5) │ ^^^^ Foo: Value note: - ┌─ structs.fe:156:16 + ┌─ structs.fe:131:16 │ -156 │ assert self.my_house.rooms == u8(5) +131 │ assert self.my_house.rooms == u8(5) │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:156:16 + ┌─ structs.fe:131:16 │ -156 │ assert self.my_house.rooms == u8(5) +131 │ assert self.my_house.rooms == u8(5) │ ^^^^^^^^^^^^^^^^^^^ ^ u8: Value │ │ │ u8: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:156:39 + ┌─ structs.fe:131:39 │ -156 │ assert self.my_house.rooms == u8(5) +131 │ assert self.my_house.rooms == u8(5) │ ^^^^^ u8: Value note: - ┌─ structs.fe:156:16 + ┌─ structs.fe:131:16 │ -156 │ assert self.my_house.rooms == u8(5) +131 │ assert self.my_house.rooms == u8(5) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -157 │ assert self.my_house.vacant == false +132 │ assert self.my_house.vacant == false │ ^^^^ Foo: Value note: - ┌─ structs.fe:157:16 + ┌─ structs.fe:132:16 │ -157 │ assert self.my_house.vacant == false +132 │ assert self.my_house.vacant == false │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:157:16 + ┌─ structs.fe:132:16 │ -157 │ assert self.my_house.vacant == false +132 │ assert self.my_house.vacant == false │ ^^^^^^^^^^^^^^^^^^^^ ^^^^^ bool: Value │ │ │ bool: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:157:16 + ┌─ structs.fe:132:16 │ -157 │ assert self.my_house.vacant == false +132 │ assert self.my_house.vacant == false │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -158 │ # We change only the size and check other fields are unchanged -159 │ self.my_house.size = 50 +133 │ self.my_house.size = 50 │ ^^^^ Foo: Value note: - ┌─ structs.fe:159:9 + ┌─ structs.fe:133:9 │ -159 │ self.my_house.size = 50 +133 │ self.my_house.size = 50 │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:159:9 + ┌─ structs.fe:133:9 │ -159 │ self.my_house.size = 50 +133 │ self.my_house.size = 50 │ ^^^^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } -160 │ assert self.my_house.size == 50 +134 │ assert self.my_house.size == 50 │ ^^^^ Foo: Value note: - ┌─ structs.fe:160:16 + ┌─ structs.fe:134:16 │ -160 │ assert self.my_house.size == 50 +134 │ assert self.my_house.size == 50 │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:160:16 + ┌─ structs.fe:134:16 │ -160 │ assert self.my_house.size == 50 +134 │ assert self.my_house.size == 50 │ ^^^^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:160:16 + ┌─ structs.fe:134:16 │ -160 │ assert self.my_house.size == 50 +134 │ assert self.my_house.size == 50 │ ^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -161 │ assert self.my_house.price == 1 +135 │ assert self.my_house.price == 1 │ ^^^^ Foo: Value note: - ┌─ structs.fe:161:16 + ┌─ structs.fe:135:16 │ -161 │ assert self.my_house.price == 1 +135 │ assert self.my_house.price == 1 │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:161:16 + ┌─ structs.fe:135:16 │ -161 │ assert self.my_house.price == 1 +135 │ assert self.my_house.price == 1 │ ^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:161:16 + ┌─ structs.fe:135:16 │ -161 │ assert self.my_house.price == 1 +135 │ assert self.my_house.price == 1 │ ^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -162 │ assert self.my_house.rooms == u8(5) +136 │ assert self.my_house.rooms == u8(5) │ ^^^^ Foo: Value note: - ┌─ structs.fe:162:16 + ┌─ structs.fe:136:16 │ -162 │ assert self.my_house.rooms == u8(5) +136 │ assert self.my_house.rooms == u8(5) │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:162:16 + ┌─ structs.fe:136:16 │ -162 │ assert self.my_house.rooms == u8(5) +136 │ assert self.my_house.rooms == u8(5) │ ^^^^^^^^^^^^^^^^^^^ ^ u8: Value │ │ │ u8: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:162:39 + ┌─ structs.fe:136:39 │ -162 │ assert self.my_house.rooms == u8(5) +136 │ assert self.my_house.rooms == u8(5) │ ^^^^^ u8: Value note: - ┌─ structs.fe:162:16 + ┌─ structs.fe:136:16 │ -162 │ assert self.my_house.rooms == u8(5) +136 │ assert self.my_house.rooms == u8(5) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -163 │ assert self.my_house.vacant == false +137 │ assert self.my_house.vacant == false │ ^^^^ Foo: Value note: - ┌─ structs.fe:163:16 + ┌─ structs.fe:137:16 │ -163 │ assert self.my_house.vacant == false +137 │ assert self.my_house.vacant == false │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:163:16 + ┌─ structs.fe:137:16 │ -163 │ assert self.my_house.vacant == false +137 │ assert self.my_house.vacant == false │ ^^^^^^^^^^^^^^^^^^^^ ^^^^^ bool: Value │ │ │ bool: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:163:16 + ┌─ structs.fe:137:16 │ -163 │ assert self.my_house.vacant == false +137 │ assert self.my_house.vacant == false │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -164 │ # We change only the price and check other fields are unchanged -165 │ self.my_house.price = 1000 +138 │ self.my_house.price = 1000 │ ^^^^ Foo: Value note: - ┌─ structs.fe:165:9 + ┌─ structs.fe:138:9 │ -165 │ self.my_house.price = 1000 +138 │ self.my_house.price = 1000 │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:165:9 + ┌─ structs.fe:138:9 │ -165 │ self.my_house.price = 1000 +138 │ self.my_house.price = 1000 │ ^^^^^^^^^^^^^^^^^^^ ^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } -166 │ assert self.my_house.size == 50 +139 │ assert self.my_house.size == 50 │ ^^^^ Foo: Value note: - ┌─ structs.fe:166:16 + ┌─ structs.fe:139:16 │ -166 │ assert self.my_house.size == 50 +139 │ assert self.my_house.size == 50 │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:166:16 + ┌─ structs.fe:139:16 │ -166 │ assert self.my_house.size == 50 +139 │ assert self.my_house.size == 50 │ ^^^^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:166:16 + ┌─ structs.fe:139:16 │ -166 │ assert self.my_house.size == 50 +139 │ assert self.my_house.size == 50 │ ^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -167 │ assert self.my_house.price == 1000 +140 │ assert self.my_house.price == 1000 │ ^^^^ Foo: Value note: - ┌─ structs.fe:167:16 + ┌─ structs.fe:140:16 │ -167 │ assert self.my_house.price == 1000 +140 │ assert self.my_house.price == 1000 │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:167:16 + ┌─ structs.fe:140:16 │ -167 │ assert self.my_house.price == 1000 +140 │ assert self.my_house.price == 1000 │ ^^^^^^^^^^^^^^^^^^^ ^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:167:16 + ┌─ structs.fe:140:16 │ -167 │ assert self.my_house.price == 1000 +140 │ assert self.my_house.price == 1000 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -168 │ assert self.my_house.rooms == u8(5) +141 │ assert self.my_house.rooms == u8(5) │ ^^^^ Foo: Value note: - ┌─ structs.fe:168:16 + ┌─ structs.fe:141:16 │ -168 │ assert self.my_house.rooms == u8(5) +141 │ assert self.my_house.rooms == u8(5) │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:168:16 + ┌─ structs.fe:141:16 │ -168 │ assert self.my_house.rooms == u8(5) +141 │ assert self.my_house.rooms == u8(5) │ ^^^^^^^^^^^^^^^^^^^ ^ u8: Value │ │ │ u8: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:168:39 + ┌─ structs.fe:141:39 │ -168 │ assert self.my_house.rooms == u8(5) +141 │ assert self.my_house.rooms == u8(5) │ ^^^^^ u8: Value note: - ┌─ structs.fe:168:16 + ┌─ structs.fe:141:16 │ -168 │ assert self.my_house.rooms == u8(5) +141 │ assert self.my_house.rooms == u8(5) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -169 │ assert self.my_house.vacant == false +142 │ assert self.my_house.vacant == false │ ^^^^ Foo: Value note: - ┌─ structs.fe:169:16 + ┌─ structs.fe:142:16 │ -169 │ assert self.my_house.vacant == false +142 │ assert self.my_house.vacant == false │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:169:16 + ┌─ structs.fe:142:16 │ -169 │ assert self.my_house.vacant == false +142 │ assert self.my_house.vacant == false │ ^^^^^^^^^^^^^^^^^^^^ ^^^^^ bool: Value │ │ │ bool: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:169:16 + ┌─ structs.fe:142:16 │ -169 │ assert self.my_house.vacant == false +142 │ assert self.my_house.vacant == false │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -170 │ self.my_house.vacant = true +143 │ self.my_house.vacant = true │ ^^^^ Foo: Value note: - ┌─ structs.fe:170:9 + ┌─ structs.fe:143:9 │ -170 │ self.my_house.vacant = true +143 │ self.my_house.vacant = true │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:170:9 + ┌─ structs.fe:143:9 │ -170 │ self.my_house.vacant = true +143 │ self.my_house.vacant = true │ ^^^^^^^^^^^^^^^^^^^^ ^^^^ bool: Value │ │ │ bool: Storage { nonce: Some(0) } -171 │ assert self.my_house.size == 50 +144 │ assert self.my_house.size == 50 │ ^^^^ Foo: Value note: - ┌─ structs.fe:171:16 + ┌─ structs.fe:144:16 │ -171 │ assert self.my_house.size == 50 +144 │ assert self.my_house.size == 50 │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:171:16 + ┌─ structs.fe:144:16 │ -171 │ assert self.my_house.size == 50 +144 │ assert self.my_house.size == 50 │ ^^^^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:171:16 + ┌─ structs.fe:144:16 │ -171 │ assert self.my_house.size == 50 +144 │ assert self.my_house.size == 50 │ ^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -172 │ assert self.my_house.price == 1000 +145 │ assert self.my_house.price == 1000 │ ^^^^ Foo: Value note: - ┌─ structs.fe:172:16 + ┌─ structs.fe:145:16 │ -172 │ assert self.my_house.price == 1000 +145 │ assert self.my_house.price == 1000 │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:172:16 + ┌─ structs.fe:145:16 │ -172 │ assert self.my_house.price == 1000 +145 │ assert self.my_house.price == 1000 │ ^^^^^^^^^^^^^^^^^^^ ^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:172:16 + ┌─ structs.fe:145:16 │ -172 │ assert self.my_house.price == 1000 +145 │ assert self.my_house.price == 1000 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -173 │ assert self.my_house.rooms == u8(5) +146 │ assert self.my_house.rooms == u8(5) │ ^^^^ Foo: Value note: - ┌─ structs.fe:173:16 + ┌─ structs.fe:146:16 │ -173 │ assert self.my_house.rooms == u8(5) +146 │ assert self.my_house.rooms == u8(5) │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:173:16 + ┌─ structs.fe:146:16 │ -173 │ assert self.my_house.rooms == u8(5) +146 │ assert self.my_house.rooms == u8(5) │ ^^^^^^^^^^^^^^^^^^^ ^ u8: Value │ │ │ u8: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:173:39 + ┌─ structs.fe:146:39 │ -173 │ assert self.my_house.rooms == u8(5) +146 │ assert self.my_house.rooms == u8(5) │ ^^^^^ u8: Value note: - ┌─ structs.fe:173:16 + ┌─ structs.fe:146:16 │ -173 │ assert self.my_house.rooms == u8(5) +146 │ assert self.my_house.rooms == u8(5) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -174 │ assert self.my_house.vacant +147 │ assert self.my_house.vacant │ ^^^^ Foo: Value note: - ┌─ structs.fe:174:16 + ┌─ structs.fe:147:16 │ -174 │ assert self.my_house.vacant +147 │ assert self.my_house.vacant │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:174:16 + ┌─ structs.fe:147:16 │ -174 │ assert self.my_house.vacant +147 │ assert self.my_house.vacant │ ^^^^^^^^^^^^^^^^^^^^ bool: Storage { nonce: Some(0) } => Value -175 │ self.my_house.rooms = u8(100) +148 │ self.my_house.rooms = u8(100) │ ^^^^ Foo: Value note: - ┌─ structs.fe:175:9 + ┌─ structs.fe:148:9 │ -175 │ self.my_house.rooms = u8(100) +148 │ self.my_house.rooms = u8(100) │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:175:9 + ┌─ structs.fe:148:9 │ -175 │ self.my_house.rooms = u8(100) +148 │ self.my_house.rooms = u8(100) │ ^^^^^^^^^^^^^^^^^^^ ^^^ u8: Value │ │ │ u8: Storage { nonce: Some(0) } note: - ┌─ structs.fe:175:31 + ┌─ structs.fe:148:31 │ -175 │ self.my_house.rooms = u8(100) +148 │ self.my_house.rooms = u8(100) │ ^^^^^^^ u8: Value -176 │ assert self.my_house.size == 50 +149 │ assert self.my_house.size == 50 │ ^^^^ Foo: Value note: - ┌─ structs.fe:176:16 + ┌─ structs.fe:149:16 │ -176 │ assert self.my_house.size == 50 +149 │ assert self.my_house.size == 50 │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:176:16 + ┌─ structs.fe:149:16 │ -176 │ assert self.my_house.size == 50 +149 │ assert self.my_house.size == 50 │ ^^^^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:176:16 + ┌─ structs.fe:149:16 │ -176 │ assert self.my_house.size == 50 +149 │ assert self.my_house.size == 50 │ ^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -177 │ assert self.my_house.price == 1000 +150 │ assert self.my_house.price == 1000 │ ^^^^ Foo: Value note: - ┌─ structs.fe:177:16 + ┌─ structs.fe:150:16 │ -177 │ assert self.my_house.price == 1000 +150 │ assert self.my_house.price == 1000 │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:177:16 + ┌─ structs.fe:150:16 │ -177 │ assert self.my_house.price == 1000 +150 │ assert self.my_house.price == 1000 │ ^^^^^^^^^^^^^^^^^^^ ^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:177:16 + ┌─ structs.fe:150:16 │ -177 │ assert self.my_house.price == 1000 +150 │ assert self.my_house.price == 1000 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -178 │ assert self.my_house.rooms == u8(100) +151 │ assert self.my_house.rooms == u8(100) │ ^^^^ Foo: Value note: - ┌─ structs.fe:178:16 + ┌─ structs.fe:151:16 │ -178 │ assert self.my_house.rooms == u8(100) +151 │ assert self.my_house.rooms == u8(100) │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:178:16 + ┌─ structs.fe:151:16 │ -178 │ assert self.my_house.rooms == u8(100) +151 │ assert self.my_house.rooms == u8(100) │ ^^^^^^^^^^^^^^^^^^^ ^^^ u8: Value │ │ │ u8: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:178:39 + ┌─ structs.fe:151:39 │ -178 │ assert self.my_house.rooms == u8(100) +151 │ assert self.my_house.rooms == u8(100) │ ^^^^^^^ u8: Value note: - ┌─ structs.fe:178:16 + ┌─ structs.fe:151:16 │ -178 │ assert self.my_house.rooms == u8(100) +151 │ assert self.my_house.rooms == u8(100) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -179 │ assert self.my_house.vacant +152 │ assert self.my_house.vacant │ ^^^^ Foo: Value note: - ┌─ structs.fe:179:16 + ┌─ structs.fe:152:16 │ -179 │ assert self.my_house.vacant +152 │ assert self.my_house.vacant │ ^^^^^^^^^^^^^ House: Storage { nonce: Some(0) } note: - ┌─ structs.fe:179:16 + ┌─ structs.fe:152:16 │ -179 │ assert self.my_house.vacant +152 │ assert self.my_house.vacant │ ^^^^^^^^^^^^^^^^^^^^ bool: Storage { nonce: Some(0) } => Value note: - ┌─ structs.fe:181:5 + ┌─ structs.fe:155:5 │ -181 │ ╭ pub fn bar() -> u256: -182 │ │ let building: House = House( -183 │ │ price: 300, -184 │ │ size: 500, +155 │ ╭ pub fn bar() -> u256 { +156 │ │ let building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) +157 │ │ assert building.size == 500 +158 │ │ assert building.price == 300 · │ -206 │ │ -207 │ │ return building.size - │ ╰────────────────────────────^ attributes hash: 6115314201970082834 +172 │ │ return building.size +173 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -2472,282 +2435,268 @@ note: } note: - ┌─ structs.fe:182:23 + ┌─ structs.fe:156:23 │ -182 │ let building: House = House( +156 │ let building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) │ ^^^^^ House note: - ┌─ structs.fe:183:20 + ┌─ structs.fe:156:44 │ -183 │ price: 300, - │ ^^^ u256: Value -184 │ size: 500, - │ ^^^ u256: Value -185 │ rooms: u8(20), - │ ^^ u8: Value +156 │ let building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) + │ ^^^ ^^^ ^^ u8: Value + │ │ │ + │ │ u256: Value + │ u256: Value note: - ┌─ structs.fe:185:20 + ┌─ structs.fe:156:67 │ -185 │ rooms: u8(20), - │ ^^^^^^ u8: Value -186 │ vacant: true, - │ ^^^^ bool: Value +156 │ let building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) + │ ^^^^^^ ^^^^ bool: Value + │ │ + │ u8: Value note: - ┌─ structs.fe:182:31 - │ -182 │ let building: House = House( - │ ╭───────────────────────────────^ -183 │ │ price: 300, -184 │ │ size: 500, -185 │ │ rooms: u8(20), -186 │ │ vacant: true, -187 │ │ ) - │ ╰─────────^ House: Memory -188 │ assert building.size == 500 - │ ^^^^^^^^ House: Memory + ┌─ structs.fe:156:31 + │ +156 │ let building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ House: Memory +157 │ assert building.size == 500 + │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:188:16 + ┌─ structs.fe:157:16 │ -188 │ assert building.size == 500 +157 │ assert building.size == 500 │ ^^^^^^^^^^^^^ ^^^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ structs.fe:188:16 + ┌─ structs.fe:157:16 │ -188 │ assert building.size == 500 +157 │ assert building.size == 500 │ ^^^^^^^^^^^^^^^^^^^^ bool: Value -189 │ assert building.price == 300 +158 │ assert building.price == 300 │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:189:16 + ┌─ structs.fe:158:16 │ -189 │ assert building.price == 300 +158 │ assert building.price == 300 │ ^^^^^^^^^^^^^^ ^^^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ structs.fe:189:16 + ┌─ structs.fe:158:16 │ -189 │ assert building.price == 300 +158 │ assert building.price == 300 │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value -190 │ assert building.rooms == u8(20) +159 │ assert building.rooms == u8(20) │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:190:16 + ┌─ structs.fe:159:16 │ -190 │ assert building.rooms == u8(20) +159 │ assert building.rooms == u8(20) │ ^^^^^^^^^^^^^^ ^^ u8: Value │ │ │ u8: Memory => Value note: - ┌─ structs.fe:190:34 + ┌─ structs.fe:159:34 │ -190 │ assert building.rooms == u8(20) +159 │ assert building.rooms == u8(20) │ ^^^^^^ u8: Value note: - ┌─ structs.fe:190:16 + ┌─ structs.fe:159:16 │ -190 │ assert building.rooms == u8(20) +159 │ assert building.rooms == u8(20) │ ^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -191 │ assert building.vacant +160 │ assert building.vacant │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:191:16 + ┌─ structs.fe:160:16 │ -191 │ assert building.vacant +160 │ assert building.vacant │ ^^^^^^^^^^^^^^^ bool: Memory => Value -192 │ -193 │ building.vacant = false +161 │ building.vacant = false │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:193:9 + ┌─ structs.fe:161:9 │ -193 │ building.vacant = false +161 │ building.vacant = false │ ^^^^^^^^^^^^^^^ ^^^^^ bool: Value │ │ │ bool: Memory -194 │ building.price = 1 +162 │ building.price = 1 │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:194:9 + ┌─ structs.fe:162:9 │ -194 │ building.price = 1 +162 │ building.price = 1 │ ^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -195 │ building.size = 2 +163 │ building.size = 2 │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:195:9 + ┌─ structs.fe:163:9 │ -195 │ building.size = 2 +163 │ building.size = 2 │ ^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -196 │ building.rooms = u8(10) +164 │ building.rooms = u8(10) │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:196:9 + ┌─ structs.fe:164:9 │ -196 │ building.rooms = u8(10) +164 │ building.rooms = u8(10) │ ^^^^^^^^^^^^^^ ^^ u8: Value │ │ │ u8: Memory note: - ┌─ structs.fe:196:26 + ┌─ structs.fe:164:26 │ -196 │ building.rooms = u8(10) +164 │ building.rooms = u8(10) │ ^^^^^^ u8: Value -197 │ -198 │ assert building.vacant == false +165 │ assert building.vacant == false │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:198:16 + ┌─ structs.fe:165:16 │ -198 │ assert building.vacant == false +165 │ assert building.vacant == false │ ^^^^^^^^^^^^^^^ ^^^^^ bool: Value │ │ │ bool: Memory => Value note: - ┌─ structs.fe:198:16 + ┌─ structs.fe:165:16 │ -198 │ assert building.vacant == false +165 │ assert building.vacant == false │ ^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -199 │ assert building.price == 1 +166 │ assert building.price == 1 │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:199:16 + ┌─ structs.fe:166:16 │ -199 │ assert building.price == 1 +166 │ assert building.price == 1 │ ^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ structs.fe:199:16 + ┌─ structs.fe:166:16 │ -199 │ assert building.price == 1 +166 │ assert building.price == 1 │ ^^^^^^^^^^^^^^^^^^^ bool: Value -200 │ assert building.size == 2 +167 │ assert building.size == 2 │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:200:16 + ┌─ structs.fe:167:16 │ -200 │ assert building.size == 2 +167 │ assert building.size == 2 │ ^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ structs.fe:200:16 + ┌─ structs.fe:167:16 │ -200 │ assert building.size == 2 +167 │ assert building.size == 2 │ ^^^^^^^^^^^^^^^^^^ bool: Value -201 │ assert building.rooms == u8(10) +168 │ assert building.rooms == u8(10) │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:201:16 + ┌─ structs.fe:168:16 │ -201 │ assert building.rooms == u8(10) +168 │ assert building.rooms == u8(10) │ ^^^^^^^^^^^^^^ ^^ u8: Value │ │ │ u8: Memory => Value note: - ┌─ structs.fe:201:34 + ┌─ structs.fe:168:34 │ -201 │ assert building.rooms == u8(10) +168 │ assert building.rooms == u8(10) │ ^^^^^^ u8: Value note: - ┌─ structs.fe:201:16 + ┌─ structs.fe:168:16 │ -201 │ assert building.rooms == u8(10) +168 │ assert building.rooms == u8(10) │ ^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -202 │ -203 │ building.expand() +169 │ building.expand() │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:203:9 + ┌─ structs.fe:169:9 │ -203 │ building.expand() +169 │ building.expand() │ ^^^^^^^^^^^^^^^^^ (): Value -204 │ assert building.size == 102 +170 │ assert building.size == 102 │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:204:16 + ┌─ structs.fe:170:16 │ -204 │ assert building.size == 102 +170 │ assert building.size == 102 │ ^^^^^^^^^^^^^ ^^^ u256: Value │ │ │ u256: Memory => Value note: - ┌─ structs.fe:204:16 + ┌─ structs.fe:170:16 │ -204 │ assert building.size == 102 +170 │ assert building.size == 102 │ ^^^^^^^^^^^^^^^^^^^^ bool: Value -205 │ assert building.rooms == 11 +171 │ assert building.rooms == 11 │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:205:16 + ┌─ structs.fe:171:16 │ -205 │ assert building.rooms == 11 +171 │ assert building.rooms == 11 │ ^^^^^^^^^^^^^^ ^^ u8: Value │ │ │ u8: Memory => Value note: - ┌─ structs.fe:205:16 + ┌─ structs.fe:171:16 │ -205 │ assert building.rooms == 11 +171 │ assert building.rooms == 11 │ ^^^^^^^^^^^^^^^^^^^^ bool: Value -206 │ -207 │ return building.size +172 │ return building.size │ ^^^^^^^^ House: Memory note: - ┌─ structs.fe:207:16 + ┌─ structs.fe:172:16 │ -207 │ return building.size +172 │ return building.size │ ^^^^^^^^^^^^^ u256: Memory => Value note: - ┌─ structs.fe:209:5 + ┌─ structs.fe:175:5 │ -209 │ ╭ pub fn encode_house() -> Array: -210 │ │ let house: House = House( -211 │ │ price: 300, -212 │ │ size: 500, - · │ -215 │ │ ) -216 │ │ return house.encode() - │ ╰─────────────────────────────^ attributes hash: 9174136327042912890 +175 │ ╭ pub fn encode_house() -> Array { +176 │ │ let house: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) +177 │ │ return house.encode() +178 │ │ } + │ ╰─────^ attributes hash: 9174136327042912890 │ = FunctionSignature { self_decl: None, @@ -2766,60 +2715,50 @@ note: } note: - ┌─ structs.fe:210:20 + ┌─ structs.fe:176:20 │ -210 │ let house: House = House( +176 │ let house: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) │ ^^^^^ House note: - ┌─ structs.fe:211:20 + ┌─ structs.fe:176:41 │ -211 │ price: 300, - │ ^^^ u256: Value -212 │ size: 500, - │ ^^^ u256: Value -213 │ rooms: u8(20), - │ ^^ u8: Value +176 │ let house: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) + │ ^^^ ^^^ ^^ u8: Value + │ │ │ + │ │ u256: Value + │ u256: Value note: - ┌─ structs.fe:213:20 + ┌─ structs.fe:176:64 │ -213 │ rooms: u8(20), - │ ^^^^^^ u8: Value -214 │ vacant: true, - │ ^^^^ bool: Value +176 │ let house: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) + │ ^^^^^^ ^^^^ bool: Value + │ │ + │ u8: Value note: - ┌─ structs.fe:210:28 - │ -210 │ let house: House = House( - │ ╭────────────────────────────^ -211 │ │ price: 300, -212 │ │ size: 500, -213 │ │ rooms: u8(20), -214 │ │ vacant: true, -215 │ │ ) - │ ╰─────────^ House: Memory -216 │ return house.encode() - │ ^^^^^ House: Memory + ┌─ structs.fe:176:28 + │ +176 │ let house: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ House: Memory +177 │ return house.encode() + │ ^^^^^ House: Memory note: - ┌─ structs.fe:216:16 + ┌─ structs.fe:177:16 │ -216 │ return house.encode() +177 │ return house.encode() │ ^^^^^^^^^^^^^^ Array: Memory note: - ┌─ structs.fe:218:5 + ┌─ structs.fe:180:5 │ -218 │ ╭ pub fn hashed_house() -> u256: -219 │ │ let house: House = House( -220 │ │ price: 300, -221 │ │ size: 500, - · │ -224 │ │ ) -225 │ │ return house.hash() - │ ╰───────────────────────────^ attributes hash: 6115314201970082834 +180 │ ╭ pub fn hashed_house() -> u256 { +181 │ │ let house: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) +182 │ │ return house.hash() +183 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -2835,47 +2774,40 @@ note: } note: - ┌─ structs.fe:219:20 + ┌─ structs.fe:181:20 │ -219 │ let house: House = House( +181 │ let house: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) │ ^^^^^ House note: - ┌─ structs.fe:220:20 + ┌─ structs.fe:181:41 │ -220 │ price: 300, - │ ^^^ u256: Value -221 │ size: 500, - │ ^^^ u256: Value -222 │ rooms: u8(20), - │ ^^ u8: Value +181 │ let house: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) + │ ^^^ ^^^ ^^ u8: Value + │ │ │ + │ │ u256: Value + │ u256: Value note: - ┌─ structs.fe:222:20 + ┌─ structs.fe:181:64 │ -222 │ rooms: u8(20), - │ ^^^^^^ u8: Value -223 │ vacant: true, - │ ^^^^ bool: Value +181 │ let house: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) + │ ^^^^^^ ^^^^ bool: Value + │ │ + │ u8: Value note: - ┌─ structs.fe:219:28 - │ -219 │ let house: House = House( - │ ╭────────────────────────────^ -220 │ │ price: 300, -221 │ │ size: 500, -222 │ │ rooms: u8(20), -223 │ │ vacant: true, -224 │ │ ) - │ ╰─────────^ House: Memory -225 │ return house.hash() - │ ^^^^^ House: Memory + ┌─ structs.fe:181:28 + │ +181 │ let house: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ House: Memory +182 │ return house.hash() + │ ^^^^^ House: Memory note: - ┌─ structs.fe:225:16 + ┌─ structs.fe:182:16 │ -225 │ return house.hash() +182 │ return house.hash() │ ^^^^^^^^^^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__ternary_expression.snap b/crates/analyzer/tests/snapshots/analysis__ternary_expression.snap index 5fe012325b..4b44929786 100644 --- a/crates/analyzer/tests/snapshots/analysis__ternary_expression.snap +++ b/crates/analyzer/tests/snapshots/analysis__ternary_expression.snap @@ -4,11 +4,12 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ ternary_expression.fe:3:5 + ┌─ ternary_expression.fe:2:5 │ -3 │ ╭ pub fn bar(input: u256) -> u256: -4 │ │ return 1 if input > 5 else 0 - │ ╰────────────────────────────────────^ attributes hash: 10660199954095577886 +2 │ ╭ pub fn bar(input: u256) -> u256 { +3 │ │ return 1 if input > 5 else 0 +4 │ │ } + │ ╰─────^ attributes hash: 10660199954095577886 │ = FunctionSignature { self_decl: None, @@ -36,26 +37,26 @@ note: } note: - ┌─ ternary_expression.fe:4:21 + ┌─ ternary_expression.fe:3:21 │ -4 │ return 1 if input > 5 else 0 +3 │ return 1 if input > 5 else 0 │ ^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ ternary_expression.fe:4:16 + ┌─ ternary_expression.fe:3:16 │ -4 │ return 1 if input > 5 else 0 +3 │ return 1 if input > 5 else 0 │ ^ ^^^^^^^^^ ^ u256: Value │ │ │ │ │ bool: Value │ u256: Value note: - ┌─ ternary_expression.fe:4:16 + ┌─ ternary_expression.fe:3:16 │ -4 │ return 1 if input > 5 else 0 +3 │ return 1 if input > 5 else 0 │ ^^^^^^^^^^^^^^^^^^^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap b/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap index 23d28b5748..aed5bda90e 100644 --- a/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap +++ b/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap @@ -16,15 +16,12 @@ note: │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (u256, bool, address) note: - ┌─ tuple_stress.fe:9:5 + ┌─ tuple_stress.fe:10:5 │ - 9 │ ╭ pub fn build_my_tuple( -10 │ │ my_num: u256, -11 │ │ my_bool: bool, -12 │ │ my_address: address -13 │ │ ) -> (u256, bool, address): -14 │ │ return (my_num, my_bool, my_address) - │ ╰────────────────────────────────────────────^ attributes hash: 10223738621782129186 +10 │ ╭ pub fn build_my_tuple(my_num: u256, my_bool: bool, my_address: address) -> (u256, bool, address) { +11 │ │ return (my_num, my_bool, my_address) +12 │ │ } + │ ╰─────^ attributes hash: 10223738621782129186 │ = FunctionSignature { self_decl: None, @@ -82,26 +79,27 @@ note: } note: - ┌─ tuple_stress.fe:14:17 + ┌─ tuple_stress.fe:11:17 │ -14 │ return (my_num, my_bool, my_address) +11 │ return (my_num, my_bool, my_address) │ ^^^^^^ ^^^^^^^ ^^^^^^^^^^ address: Value │ │ │ │ │ bool: Value │ u256: Value note: - ┌─ tuple_stress.fe:14:16 + ┌─ tuple_stress.fe:11:16 │ -14 │ return (my_num, my_bool, my_address) +11 │ return (my_num, my_bool, my_address) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (u256, bool, address): Memory note: - ┌─ tuple_stress.fe:16:5 + ┌─ tuple_stress.fe:14:5 │ -16 │ ╭ pub fn read_my_tuple_item0(my_tuple: (u256, bool, address)) -> u256: -17 │ │ return my_tuple.item0 - │ ╰─────────────────────────────^ attributes hash: 1005385906871296536 +14 │ ╭ pub fn read_my_tuple_item0(my_tuple: (u256, bool, address)) -> u256 { +15 │ │ return my_tuple.item0 +16 │ │ } + │ ╰─────^ attributes hash: 1005385906871296536 │ = FunctionSignature { self_decl: None, @@ -141,23 +139,24 @@ note: } note: - ┌─ tuple_stress.fe:17:16 + ┌─ tuple_stress.fe:15:16 │ -17 │ return my_tuple.item0 +15 │ return my_tuple.item0 │ ^^^^^^^^ (u256, bool, address): Memory note: - ┌─ tuple_stress.fe:17:16 + ┌─ tuple_stress.fe:15:16 │ -17 │ return my_tuple.item0 +15 │ return my_tuple.item0 │ ^^^^^^^^^^^^^^ u256: Memory => Value note: - ┌─ tuple_stress.fe:19:5 + ┌─ tuple_stress.fe:18:5 │ -19 │ ╭ pub fn read_my_tuple_item1(my_tuple: (u256, bool, address)) -> bool: -20 │ │ return my_tuple.item1 - │ ╰─────────────────────────────^ attributes hash: 5615774585289781220 +18 │ ╭ pub fn read_my_tuple_item1(my_tuple: (u256, bool, address)) -> bool { +19 │ │ return my_tuple.item1 +20 │ │ } + │ ╰─────^ attributes hash: 5615774585289781220 │ = FunctionSignature { self_decl: None, @@ -195,23 +194,24 @@ note: } note: - ┌─ tuple_stress.fe:20:16 + ┌─ tuple_stress.fe:19:16 │ -20 │ return my_tuple.item1 +19 │ return my_tuple.item1 │ ^^^^^^^^ (u256, bool, address): Memory note: - ┌─ tuple_stress.fe:20:16 + ┌─ tuple_stress.fe:19:16 │ -20 │ return my_tuple.item1 +19 │ return my_tuple.item1 │ ^^^^^^^^^^^^^^ bool: Memory => Value note: ┌─ tuple_stress.fe:22:5 │ -22 │ ╭ pub fn read_my_tuple_item2(my_tuple: (u256, bool, address)) -> address: +22 │ ╭ pub fn read_my_tuple_item2(my_tuple: (u256, bool, address)) -> address { 23 │ │ return my_tuple.item2 - │ ╰─────────────────────────────^ attributes hash: 13024428391414866682 +24 │ │ } + │ ╰─────^ attributes hash: 13024428391414866682 │ = FunctionSignature { self_decl: None, @@ -261,11 +261,12 @@ note: │ ^^^^^^^^^^^^^^ address: Memory => Value note: - ┌─ tuple_stress.fe:25:5 + ┌─ tuple_stress.fe:26:5 │ -25 │ ╭ pub fn read_my_tuple_item10(my_tuple: (u256, u256, u256, u256, u256, u256, u256, u256, u256, u256, address)) -> address: -26 │ │ return my_tuple.item10 - │ ╰──────────────────────────────^ attributes hash: 11830390438544540912 +26 │ ╭ pub fn read_my_tuple_item10(my_tuple: (u256, u256, u256, u256, u256, u256, u256, u256, u256, u256, address)) -> address { +27 │ │ return my_tuple.item10 +28 │ │ } + │ ╰─────^ attributes hash: 11830390438544540912 │ = FunctionSignature { self_decl: None, @@ -345,23 +346,24 @@ note: } note: - ┌─ tuple_stress.fe:26:16 + ┌─ tuple_stress.fe:27:16 │ -26 │ return my_tuple.item10 +27 │ return my_tuple.item10 │ ^^^^^^^^ (u256, u256, u256, u256, u256, u256, u256, u256, u256, u256, address): Memory note: - ┌─ tuple_stress.fe:26:16 + ┌─ tuple_stress.fe:27:16 │ -26 │ return my_tuple.item10 +27 │ return my_tuple.item10 │ ^^^^^^^^^^^^^^^ address: Memory => Value note: - ┌─ tuple_stress.fe:28:5 + ┌─ tuple_stress.fe:30:5 │ -28 │ ╭ pub fn emit_my_event(ctx: Context, my_tuple: (u256, bool, address)): -29 │ │ emit MyEvent(ctx, my_tuple) - │ ╰───────────────────────────────────^ attributes hash: 10535390144430265813 +30 │ ╭ pub fn emit_my_event(ctx: Context, my_tuple: (u256, bool, address)) { +31 │ │ emit MyEvent(ctx, my_tuple) +32 │ │ } + │ ╰─────^ attributes hash: 10535390144430265813 │ = FunctionSignature { self_decl: None, @@ -413,17 +415,17 @@ note: } note: - ┌─ tuple_stress.fe:29:22 + ┌─ tuple_stress.fe:31:22 │ -29 │ emit MyEvent(ctx, my_tuple) +31 │ emit MyEvent(ctx, my_tuple) │ ^^^ ^^^^^^^^ (u256, bool, address): Memory │ │ │ Context: Memory note: - ┌─ tuple_stress.fe:29:9 + ┌─ tuple_stress.fe:31:9 │ -29 │ emit MyEvent(ctx, my_tuple) +31 │ emit MyEvent(ctx, my_tuple) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 12913536175581177750 │ = Event { @@ -456,12 +458,13 @@ note: } note: - ┌─ tuple_stress.fe:31:5 + ┌─ tuple_stress.fe:34:5 │ -31 │ ╭ pub fn set_my_sto_tuple(self, my_u256: u256, my_i32: i32): -32 │ │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) -33 │ │ self.my_sto_tuple = (my_u256, my_i32) - │ ╰─────────────────────────────────────────────^ attributes hash: 14404502892103280650 +34 │ ╭ pub fn set_my_sto_tuple(self, my_u256: u256, my_i32: i32) { +35 │ │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) +36 │ │ self.my_sto_tuple = (my_u256, my_i32) +37 │ │ } + │ ╰─────^ attributes hash: 14404502892103280650 │ = FunctionSignature { self_decl: Some( @@ -500,94 +503,95 @@ note: } note: - ┌─ tuple_stress.fe:32:16 + ┌─ tuple_stress.fe:35:16 │ -32 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) +35 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) │ ^^^^ Foo: Value note: - ┌─ tuple_stress.fe:32:16 + ┌─ tuple_stress.fe:35:16 │ -32 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) +35 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) │ ^^^^^^^^^^^^^^^^^ (u256, i32): Storage { nonce: Some(0) } note: - ┌─ tuple_stress.fe:32:16 + ┌─ tuple_stress.fe:35:16 │ -32 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) +35 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) │ ^^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: Some(0) } => Value note: - ┌─ tuple_stress.fe:32:43 + ┌─ tuple_stress.fe:35:43 │ -32 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) +35 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) │ ^^^^^^^ u256: Value note: - ┌─ tuple_stress.fe:32:16 + ┌─ tuple_stress.fe:35:16 │ -32 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) +35 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ Foo: Value │ │ │ bool: Value note: - ┌─ tuple_stress.fe:32:55 + ┌─ tuple_stress.fe:35:55 │ -32 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) +35 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) │ ^^^^^^^^^^^^^^^^^ (u256, i32): Storage { nonce: Some(0) } note: - ┌─ tuple_stress.fe:32:55 + ┌─ tuple_stress.fe:35:55 │ -32 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) +35 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) │ ^^^^^^^^^^^^^^^^^^^^^^^ ^ i32: Value │ │ │ i32: Storage { nonce: Some(0) } => Value note: - ┌─ tuple_stress.fe:32:82 + ┌─ tuple_stress.fe:35:82 │ -32 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) +35 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) │ ^^^^^^ i32: Value note: - ┌─ tuple_stress.fe:32:55 + ┌─ tuple_stress.fe:35:55 │ -32 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) +35 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value note: - ┌─ tuple_stress.fe:32:16 + ┌─ tuple_stress.fe:35:16 │ -32 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) +35 │ assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -33 │ self.my_sto_tuple = (my_u256, my_i32) +36 │ self.my_sto_tuple = (my_u256, my_i32) │ ^^^^ Foo: Value note: - ┌─ tuple_stress.fe:33:9 + ┌─ tuple_stress.fe:36:9 │ -33 │ self.my_sto_tuple = (my_u256, my_i32) +36 │ self.my_sto_tuple = (my_u256, my_i32) │ ^^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^^ i32: Value │ │ │ │ │ u256: Value │ (u256, i32): Storage { nonce: Some(0) } note: - ┌─ tuple_stress.fe:33:29 + ┌─ tuple_stress.fe:36:29 │ -33 │ self.my_sto_tuple = (my_u256, my_i32) +36 │ self.my_sto_tuple = (my_u256, my_i32) │ ^^^^^^^^^^^^^^^^^ (u256, i32): Memory note: - ┌─ tuple_stress.fe:35:5 + ┌─ tuple_stress.fe:39:5 │ -35 │ ╭ pub fn get_my_sto_tuple(self) -> (u256, i32): -36 │ │ return self.my_sto_tuple.to_mem() - │ ╰─────────────────────────────────────────^ attributes hash: 6833980121040096883 +39 │ ╭ pub fn get_my_sto_tuple(self) -> (u256, i32) { +40 │ │ return self.my_sto_tuple.to_mem() +41 │ │ } + │ ╰─────^ attributes hash: 6833980121040096883 │ = FunctionSignature { self_decl: Some( @@ -616,34 +620,32 @@ note: } note: - ┌─ tuple_stress.fe:36:16 + ┌─ tuple_stress.fe:40:16 │ -36 │ return self.my_sto_tuple.to_mem() +40 │ return self.my_sto_tuple.to_mem() │ ^^^^ Foo: Value note: - ┌─ tuple_stress.fe:36:16 + ┌─ tuple_stress.fe:40:16 │ -36 │ return self.my_sto_tuple.to_mem() +40 │ return self.my_sto_tuple.to_mem() │ ^^^^^^^^^^^^^^^^^ (u256, i32): Storage { nonce: Some(0) } note: - ┌─ tuple_stress.fe:36:16 + ┌─ tuple_stress.fe:40:16 │ -36 │ return self.my_sto_tuple.to_mem() +40 │ return self.my_sto_tuple.to_mem() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ (u256, i32): Storage { nonce: Some(0) } => Memory note: - ┌─ tuple_stress.fe:38:5 + ┌─ tuple_stress.fe:43:5 │ -38 │ ╭ pub fn build_tuple_and_emit(self, ctx: Context): -39 │ │ let my_num: u256 = self.my_sto_tuple.item0 -40 │ │ let my_tuple: (u256, bool, address) = ( -41 │ │ self.my_sto_tuple.item0, - · │ -44 │ │ ) -45 │ │ emit_my_event(ctx, my_tuple) - │ ╰────────────────────────────────────^ attributes hash: 1731341862738941170 +43 │ ╭ pub fn build_tuple_and_emit(self, ctx: Context) { +44 │ │ let my_num: u256 = self.my_sto_tuple.item0 +45 │ │ let my_tuple: (u256, bool, address) = (self.my_sto_tuple.item0, true and false, address(26)) +46 │ │ emit_my_event(ctx, my_tuple) +47 │ │ } + │ ╰─────^ attributes hash: 1731341862738941170 │ = FunctionSignature { self_decl: Some( @@ -674,91 +676,85 @@ note: } note: - ┌─ tuple_stress.fe:39:21 + ┌─ tuple_stress.fe:44:21 │ -39 │ let my_num: u256 = self.my_sto_tuple.item0 +44 │ let my_num: u256 = self.my_sto_tuple.item0 │ ^^^^ u256 -40 │ let my_tuple: (u256, bool, address) = ( +45 │ let my_tuple: (u256, bool, address) = (self.my_sto_tuple.item0, true and false, address(26)) │ ^^^^^^^^^^^^^^^^^^^^^ (u256, bool, address) note: - ┌─ tuple_stress.fe:39:28 + ┌─ tuple_stress.fe:44:28 │ -39 │ let my_num: u256 = self.my_sto_tuple.item0 +44 │ let my_num: u256 = self.my_sto_tuple.item0 │ ^^^^ Foo: Value note: - ┌─ tuple_stress.fe:39:28 + ┌─ tuple_stress.fe:44:28 │ -39 │ let my_num: u256 = self.my_sto_tuple.item0 +44 │ let my_num: u256 = self.my_sto_tuple.item0 │ ^^^^^^^^^^^^^^^^^ (u256, i32): Storage { nonce: Some(0) } note: - ┌─ tuple_stress.fe:39:28 + ┌─ tuple_stress.fe:44:28 │ -39 │ let my_num: u256 = self.my_sto_tuple.item0 +44 │ let my_num: u256 = self.my_sto_tuple.item0 │ ^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(0) } => Value -40 │ let my_tuple: (u256, bool, address) = ( -41 │ self.my_sto_tuple.item0, - │ ^^^^ Foo: Value +45 │ let my_tuple: (u256, bool, address) = (self.my_sto_tuple.item0, true and false, address(26)) + │ ^^^^ Foo: Value note: - ┌─ tuple_stress.fe:41:13 + ┌─ tuple_stress.fe:45:48 │ -41 │ self.my_sto_tuple.item0, - │ ^^^^^^^^^^^^^^^^^ (u256, i32): Storage { nonce: Some(0) } +45 │ let my_tuple: (u256, bool, address) = (self.my_sto_tuple.item0, true and false, address(26)) + │ ^^^^^^^^^^^^^^^^^ (u256, i32): Storage { nonce: Some(0) } note: - ┌─ tuple_stress.fe:41:13 + ┌─ tuple_stress.fe:45:48 │ -41 │ self.my_sto_tuple.item0, - │ ^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(0) } => Value -42 │ true and false, - │ ^^^^ ^^^^^ bool: Value - │ │ - │ bool: Value +45 │ let my_tuple: (u256, bool, address) = (self.my_sto_tuple.item0, true and false, address(26)) + │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^^^^ bool: Value + │ │ │ + │ │ bool: Value + │ u256: Storage { nonce: Some(0) } => Value note: - ┌─ tuple_stress.fe:42:13 + ┌─ tuple_stress.fe:45:73 │ -42 │ true and false, - │ ^^^^^^^^^^^^^^ bool: Value -43 │ address(26) - │ ^^ u256: Value +45 │ let my_tuple: (u256, bool, address) = (self.my_sto_tuple.item0, true and false, address(26)) + │ ^^^^^^^^^^^^^^ ^^ u256: Value + │ │ + │ bool: Value note: - ┌─ tuple_stress.fe:43:13 + ┌─ tuple_stress.fe:45:89 │ -43 │ address(26) - │ ^^^^^^^^^^^ address: Value +45 │ let my_tuple: (u256, bool, address) = (self.my_sto_tuple.item0, true and false, address(26)) + │ ^^^^^^^^^^^ address: Value note: - ┌─ tuple_stress.fe:40:47 - │ -40 │ let my_tuple: (u256, bool, address) = ( - │ ╭───────────────────────────────────────────────^ -41 │ │ self.my_sto_tuple.item0, -42 │ │ true and false, -43 │ │ address(26) -44 │ │ ) - │ ╰─────────^ (u256, bool, address): Memory -45 │ emit_my_event(ctx, my_tuple) - │ ^^^ ^^^^^^^^ (u256, bool, address): Memory - │ │ - │ Context: Memory - -note: - ┌─ tuple_stress.fe:45:9 - │ -45 │ emit_my_event(ctx, my_tuple) + ┌─ tuple_stress.fe:45:47 + │ +45 │ let my_tuple: (u256, bool, address) = (self.my_sto_tuple.item0, true and false, address(26)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (u256, bool, address): Memory +46 │ emit_my_event(ctx, my_tuple) + │ ^^^ ^^^^^^^^ (u256, bool, address): Memory + │ │ + │ Context: Memory + +note: + ┌─ tuple_stress.fe:46:9 + │ +46 │ emit_my_event(ctx, my_tuple) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value note: - ┌─ tuple_stress.fe:47:5 + ┌─ tuple_stress.fe:49:5 │ -47 │ ╭ pub fn encode_my_tuple(my_tuple: (u256, bool, address)) -> Array: -48 │ │ return my_tuple.abi_encode() - │ ╰────────────────────────────────────^ attributes hash: 3539305055628398466 +49 │ ╭ pub fn encode_my_tuple(my_tuple: (u256, bool, address)) -> Array { +50 │ │ return my_tuple.abi_encode() +51 │ │ } + │ ╰─────^ attributes hash: 3539305055628398466 │ = FunctionSignature { self_decl: None, @@ -801,15 +797,15 @@ note: } note: - ┌─ tuple_stress.fe:48:16 + ┌─ tuple_stress.fe:50:16 │ -48 │ return my_tuple.abi_encode() +50 │ return my_tuple.abi_encode() │ ^^^^^^^^ (u256, bool, address): Memory note: - ┌─ tuple_stress.fe:48:16 + ┌─ tuple_stress.fe:50:16 │ -48 │ return my_tuple.abi_encode() +50 │ return my_tuple.abi_encode() │ ^^^^^^^^^^^^^^^^^^^^^ Array: Memory diff --git a/crates/analyzer/tests/snapshots/analysis__two_contracts.snap b/crates/analyzer/tests/snapshots/analysis__two_contracts.snap index 47d205afe3..eb5476cbcd 100644 --- a/crates/analyzer/tests/snapshots/analysis__two_contracts.snap +++ b/crates/analyzer/tests/snapshots/analysis__two_contracts.snap @@ -10,12 +10,13 @@ note: │ ^^^^^^^^^^ Bar note: - ┌─ two_contracts.fe:9:5 + ┌─ two_contracts.fe:10:5 │ - 9 │ ╭ pub fn foo(self, ctx: Context) -> u256: -10 │ │ self.other.set_foo_addr(ctx.self_address()) -11 │ │ return self.other.answer() - │ ╰──────────────────────────────────^ attributes hash: 3247318976601732237 +10 │ ╭ pub fn foo(self, ctx: Context) -> u256 { +11 │ │ self.other.set_foo_addr(ctx.self_address()) +12 │ │ return self.other.answer() +13 │ │ } + │ ╰─────^ attributes hash: 3247318976601732237 │ = FunctionSignature { self_decl: Some( @@ -48,51 +49,52 @@ note: } note: - ┌─ two_contracts.fe:10:9 + ┌─ two_contracts.fe:11:9 │ -10 │ self.other.set_foo_addr(ctx.self_address()) +11 │ self.other.set_foo_addr(ctx.self_address()) │ ^^^^ Foo: Value note: - ┌─ two_contracts.fe:10:9 + ┌─ two_contracts.fe:11:9 │ -10 │ self.other.set_foo_addr(ctx.self_address()) +11 │ self.other.set_foo_addr(ctx.self_address()) │ ^^^^^^^^^^ ^^^ Context: Memory │ │ │ Bar: Storage { nonce: Some(0) } => Value note: - ┌─ two_contracts.fe:10:33 + ┌─ two_contracts.fe:11:33 │ -10 │ self.other.set_foo_addr(ctx.self_address()) +11 │ self.other.set_foo_addr(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ two_contracts.fe:10:9 + ┌─ two_contracts.fe:11:9 │ -10 │ self.other.set_foo_addr(ctx.self_address()) +11 │ self.other.set_foo_addr(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -11 │ return self.other.answer() +12 │ return self.other.answer() │ ^^^^ Foo: Value note: - ┌─ two_contracts.fe:11:16 + ┌─ two_contracts.fe:12:16 │ -11 │ return self.other.answer() +12 │ return self.other.answer() │ ^^^^^^^^^^ Bar: Storage { nonce: Some(0) } => Value note: - ┌─ two_contracts.fe:11:16 + ┌─ two_contracts.fe:12:16 │ -11 │ return self.other.answer() +12 │ return self.other.answer() │ ^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ two_contracts.fe:13:5 + ┌─ two_contracts.fe:15:5 │ -13 │ ╭ pub fn add(_ x: u256, _ y: u256) -> u256: -14 │ │ return x + y - │ ╰────────────────────^ attributes hash: 4448606202021980030 +15 │ ╭ pub fn add(_ x: u256, _ y: u256) -> u256 { +16 │ │ return x + y +17 │ │ } + │ ╰─────^ attributes hash: 4448606202021980030 │ = FunctionSignature { self_decl: None, @@ -135,31 +137,32 @@ note: } note: - ┌─ two_contracts.fe:14:16 + ┌─ two_contracts.fe:16:16 │ -14 │ return x + y +16 │ return x + y │ ^ ^ u256: Value │ │ │ u256: Value note: - ┌─ two_contracts.fe:14:16 + ┌─ two_contracts.fe:16:16 │ -14 │ return x + y +16 │ return x + y │ ^^^^^ u256: Value note: - ┌─ two_contracts.fe:17:5 + ┌─ two_contracts.fe:21:5 │ -17 │ other: Foo +21 │ other: Foo │ ^^^^^^^^^^ Foo note: - ┌─ two_contracts.fe:19:5 + ┌─ two_contracts.fe:23:5 │ -19 │ ╭ pub fn set_foo_addr(self, ctx: Context, _ addr: address): -20 │ │ self.other = Foo(ctx, addr) - │ ╰───────────────────────────────────^ attributes hash: 736575608159807992 +23 │ ╭ pub fn set_foo_addr(self, ctx: Context, _ addr: address) { +24 │ │ self.other = Foo(ctx, addr) +25 │ │ } + │ ╰─────^ attributes hash: 736575608159807992 │ = FunctionSignature { self_decl: Some( @@ -201,32 +204,33 @@ note: } note: - ┌─ two_contracts.fe:20:9 + ┌─ two_contracts.fe:24:9 │ -20 │ self.other = Foo(ctx, addr) +24 │ self.other = Foo(ctx, addr) │ ^^^^ Bar: Value note: - ┌─ two_contracts.fe:20:9 + ┌─ two_contracts.fe:24:9 │ -20 │ self.other = Foo(ctx, addr) +24 │ self.other = Foo(ctx, addr) │ ^^^^^^^^^^ ^^^ ^^^^ address: Value │ │ │ │ │ Context: Memory │ Foo: Storage { nonce: Some(0) } note: - ┌─ two_contracts.fe:20:22 + ┌─ two_contracts.fe:24:22 │ -20 │ self.other = Foo(ctx, addr) +24 │ self.other = Foo(ctx, addr) │ ^^^^^^^^^^^^^^ Foo: Value note: - ┌─ two_contracts.fe:22:5 + ┌─ two_contracts.fe:27:5 │ -22 │ ╭ pub fn answer(self) -> u256: -23 │ │ return self.other.add(20, 22) - │ ╰─────────────────────────────────────^ attributes hash: 11773348765973600208 +27 │ ╭ pub fn answer(self) -> u256 { +28 │ │ return self.other.add(20, 22) +29 │ │ } + │ ╰─────^ attributes hash: 11773348765973600208 │ = FunctionSignature { self_decl: Some( @@ -244,24 +248,24 @@ note: } note: - ┌─ two_contracts.fe:23:16 + ┌─ two_contracts.fe:28:16 │ -23 │ return self.other.add(20, 22) +28 │ return self.other.add(20, 22) │ ^^^^ Bar: Value note: - ┌─ two_contracts.fe:23:16 + ┌─ two_contracts.fe:28:16 │ -23 │ return self.other.add(20, 22) +28 │ return self.other.add(20, 22) │ ^^^^^^^^^^ ^^ ^^ u256: Value │ │ │ │ │ u256: Value │ Foo: Storage { nonce: Some(0) } => Value note: - ┌─ two_contracts.fe:23:16 + ┌─ two_contracts.fe:28:16 │ -23 │ return self.other.add(20, 22) +28 │ return self.other.add(20, 22) │ ^^^^^^^^^^^^^^^^^^^^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__type_aliases.snap b/crates/analyzer/tests/snapshots/analysis__type_aliases.snap index 9cc8423219..b3aca71cfc 100644 --- a/crates/analyzer/tests/snapshots/analysis__type_aliases.snap +++ b/crates/analyzer/tests/snapshots/analysis__type_aliases.snap @@ -10,61 +10,61 @@ note: │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map> note: - ┌─ type_aliases.fe:4:1 + ┌─ type_aliases.fe:5:1 │ -4 │ type Scoreboard = Map +5 │ type Scoreboard = Map │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map note: - ┌─ type_aliases.fe:5:1 + ┌─ type_aliases.fe:7:1 │ -5 │ type AuthorPosts = Map +7 │ type AuthorPosts = Map │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map note: - ┌─ type_aliases.fe:7:1 + ┌─ type_aliases.fe:9:1 │ -7 │ type Author = address +9 │ type Author = address │ ^^^^^^^^^^^^^^^^^^^^^ address note: - ┌─ type_aliases.fe:8:1 - │ -8 │ type Score = u64 - │ ^^^^^^^^^^^^^^^^ u64 + ┌─ type_aliases.fe:11:1 + │ +11 │ type Score = u64 + │ ^^^^^^^^^^^^^^^^ u64 note: - ┌─ type_aliases.fe:9:1 - │ -9 │ type PostId = u256 - │ ^^^^^^^^^^^^^^^^^^ u256 + ┌─ type_aliases.fe:13:1 + │ +13 │ type PostId = u256 + │ ^^^^^^^^^^^^^^^^^^ u256 note: - ┌─ type_aliases.fe:10:1 + ┌─ type_aliases.fe:15:1 │ -10 │ type PostBody = String<32> +15 │ type PostBody = String<32> │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ String<32> note: - ┌─ type_aliases.fe:13:5 + ┌─ type_aliases.fe:18:5 │ -13 │ posts: Posts +18 │ posts: Posts │ ^^^^^^^^^^^^ Map> -14 │ authors: AuthorPosts +19 │ authors: AuthorPosts │ ^^^^^^^^^^^^^^^^^^^^ Map -15 │ scoreboard: Scoreboard +20 │ scoreboard: Scoreboard │ ^^^^^^^^^^^^^^^^^^^^^^ Map note: - ┌─ type_aliases.fe:17:5 + ┌─ type_aliases.fe:22:5 │ -17 │ ╭ pub fn post(self, ctx: Context, body: PostBody): -18 │ │ # id: PostId = keccak256(body.abi_encode()) -19 │ │ let id: PostId = 0 -20 │ │ self.posts[id] = body -21 │ │ self.authors[ctx.msg_sender()] -22 │ │ self.scoreboard[id] = 0 - │ ╰───────────────────────────────^ attributes hash: 4649056442968527631 +22 │ ╭ pub fn post(self, ctx: Context, body: PostBody) { +23 │ │ let id: PostId = 0 +24 │ │ self.posts[id] = body +25 │ │ self.authors[ctx.msg_sender()] +26 │ │ self.scoreboard[id] = 0 +27 │ │ } + │ ╰─────^ attributes hash: 4649056442968527631 │ = FunctionSignature { self_decl: Some( @@ -106,83 +106,84 @@ note: } note: - ┌─ type_aliases.fe:19:17 + ┌─ type_aliases.fe:23:17 │ -19 │ let id: PostId = 0 +23 │ let id: PostId = 0 │ ^^^^^^ u256 note: - ┌─ type_aliases.fe:19:26 + ┌─ type_aliases.fe:23:26 │ -19 │ let id: PostId = 0 +23 │ let id: PostId = 0 │ ^ u256: Value -20 │ self.posts[id] = body +24 │ self.posts[id] = body │ ^^^^ Forum: Value note: - ┌─ type_aliases.fe:20:9 + ┌─ type_aliases.fe:24:9 │ -20 │ self.posts[id] = body +24 │ self.posts[id] = body │ ^^^^^^^^^^ ^^ u256: Value │ │ │ Map>: Storage { nonce: Some(0) } note: - ┌─ type_aliases.fe:20:9 + ┌─ type_aliases.fe:24:9 │ -20 │ self.posts[id] = body +24 │ self.posts[id] = body │ ^^^^^^^^^^^^^^ ^^^^ String<32>: Memory │ │ │ String<32>: Storage { nonce: None } -21 │ self.authors[ctx.msg_sender()] +25 │ self.authors[ctx.msg_sender()] │ ^^^^ Forum: Value note: - ┌─ type_aliases.fe:21:9 + ┌─ type_aliases.fe:25:9 │ -21 │ self.authors[ctx.msg_sender()] +25 │ self.authors[ctx.msg_sender()] │ ^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: Some(1) } note: - ┌─ type_aliases.fe:21:22 + ┌─ type_aliases.fe:25:22 │ -21 │ self.authors[ctx.msg_sender()] +25 │ self.authors[ctx.msg_sender()] │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ type_aliases.fe:21:9 + ┌─ type_aliases.fe:25:9 │ -21 │ self.authors[ctx.msg_sender()] +25 │ self.authors[ctx.msg_sender()] │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: None } -22 │ self.scoreboard[id] = 0 +26 │ self.scoreboard[id] = 0 │ ^^^^ Forum: Value note: - ┌─ type_aliases.fe:22:9 + ┌─ type_aliases.fe:26:9 │ -22 │ self.scoreboard[id] = 0 +26 │ self.scoreboard[id] = 0 │ ^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ Map: Storage { nonce: Some(2) } note: - ┌─ type_aliases.fe:22:9 + ┌─ type_aliases.fe:26:9 │ -22 │ self.scoreboard[id] = 0 +26 │ self.scoreboard[id] = 0 │ ^^^^^^^^^^^^^^^^^^^ ^ u64: Value │ │ │ u64: Storage { nonce: None } note: - ┌─ type_aliases.fe:24:5 + ┌─ type_aliases.fe:29:5 │ -24 │ ╭ pub fn upvote(self, id: PostId) -> Score: -25 │ │ let score: Score = self.scoreboard[id] + 1 -26 │ │ self.scoreboard[id] = score -27 │ │ return score - │ ╰────────────────────^ attributes hash: 4383698668262923633 +29 │ ╭ pub fn upvote(self, id: PostId) -> Score { +30 │ │ let score: Score = self.scoreboard[id] + 1 +31 │ │ self.scoreboard[id] = score +32 │ │ return score +33 │ │ } + │ ╰─────^ attributes hash: 4383698668262923633 │ = FunctionSignature { self_decl: Some( @@ -212,65 +213,66 @@ note: } note: - ┌─ type_aliases.fe:25:20 + ┌─ type_aliases.fe:30:20 │ -25 │ let score: Score = self.scoreboard[id] + 1 +30 │ let score: Score = self.scoreboard[id] + 1 │ ^^^^^ u64 note: - ┌─ type_aliases.fe:25:28 + ┌─ type_aliases.fe:30:28 │ -25 │ let score: Score = self.scoreboard[id] + 1 +30 │ let score: Score = self.scoreboard[id] + 1 │ ^^^^ Forum: Value note: - ┌─ type_aliases.fe:25:28 + ┌─ type_aliases.fe:30:28 │ -25 │ let score: Score = self.scoreboard[id] + 1 +30 │ let score: Score = self.scoreboard[id] + 1 │ ^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ Map: Storage { nonce: Some(2) } note: - ┌─ type_aliases.fe:25:28 + ┌─ type_aliases.fe:30:28 │ -25 │ let score: Score = self.scoreboard[id] + 1 +30 │ let score: Score = self.scoreboard[id] + 1 │ ^^^^^^^^^^^^^^^^^^^ ^ u64: Value │ │ │ u64: Storage { nonce: None } => Value note: - ┌─ type_aliases.fe:25:28 + ┌─ type_aliases.fe:30:28 │ -25 │ let score: Score = self.scoreboard[id] + 1 +30 │ let score: Score = self.scoreboard[id] + 1 │ ^^^^^^^^^^^^^^^^^^^^^^^ u64: Value -26 │ self.scoreboard[id] = score +31 │ self.scoreboard[id] = score │ ^^^^ Forum: Value note: - ┌─ type_aliases.fe:26:9 + ┌─ type_aliases.fe:31:9 │ -26 │ self.scoreboard[id] = score +31 │ self.scoreboard[id] = score │ ^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ Map: Storage { nonce: Some(2) } note: - ┌─ type_aliases.fe:26:9 + ┌─ type_aliases.fe:31:9 │ -26 │ self.scoreboard[id] = score +31 │ self.scoreboard[id] = score │ ^^^^^^^^^^^^^^^^^^^ ^^^^^ u64: Value │ │ │ u64: Storage { nonce: None } -27 │ return score +32 │ return score │ ^^^^^ u64: Value note: - ┌─ type_aliases.fe:29:5 + ┌─ type_aliases.fe:35:5 │ -29 │ ╭ pub fn get_post(self, id: PostId) -> PostBody: -30 │ │ return self.posts[id].to_mem() - │ ╰──────────────────────────────────────^ attributes hash: 6772945894090223199 +35 │ ╭ pub fn get_post(self, id: PostId) -> PostBody { +36 │ │ return self.posts[id].to_mem() +37 │ │ } + │ ╰─────^ attributes hash: 6772945894090223199 │ = FunctionSignature { self_decl: Some( @@ -300,29 +302,29 @@ note: } note: - ┌─ type_aliases.fe:30:16 + ┌─ type_aliases.fe:36:16 │ -30 │ return self.posts[id].to_mem() +36 │ return self.posts[id].to_mem() │ ^^^^ Forum: Value note: - ┌─ type_aliases.fe:30:16 + ┌─ type_aliases.fe:36:16 │ -30 │ return self.posts[id].to_mem() +36 │ return self.posts[id].to_mem() │ ^^^^^^^^^^ ^^ u256: Value │ │ │ Map>: Storage { nonce: Some(0) } note: - ┌─ type_aliases.fe:30:16 + ┌─ type_aliases.fe:36:16 │ -30 │ return self.posts[id].to_mem() +36 │ return self.posts[id].to_mem() │ ^^^^^^^^^^^^^^ String<32>: Storage { nonce: None } note: - ┌─ type_aliases.fe:30:16 + ┌─ type_aliases.fe:36:16 │ -30 │ return self.posts[id].to_mem() +36 │ return self.posts[id].to_mem() │ ^^^^^^^^^^^^^^^^^^^^^^^ String<32>: Storage { nonce: None } => Memory diff --git a/crates/analyzer/tests/snapshots/analysis__u128_u128_map.snap b/crates/analyzer/tests/snapshots/analysis__u128_u128_map.snap index 14cc193d04..f35fe0a28b 100644 --- a/crates/analyzer/tests/snapshots/analysis__u128_u128_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__u128_u128_map.snap @@ -12,9 +12,10 @@ note: note: ┌─ u128_u128_map.fe:4:5 │ -4 │ ╭ pub fn read_bar(self, key: u128) -> u128: +4 │ ╭ pub fn read_bar(self, key: u128) -> u128 { 5 │ │ return self.bar[key] - │ ╰────────────────────────────^ attributes hash: 1939765458140608268 +6 │ │ } + │ ╰─────^ attributes hash: 1939765458140608268 │ = FunctionSignature { self_decl: Some( @@ -64,66 +65,67 @@ note: │ ^^^^^^^^^^^^^ u128: Storage { nonce: None } => Value note: - ┌─ u128_u128_map.fe:7:5 - │ -7 │ ╭ pub fn write_bar(self, key: u128, value: u128): -8 │ │ self.bar[key] = value - │ ╰─────────────────────────────^ attributes hash: 9126735252114279653 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "key", - typ: Ok( - Base( - Numeric( - U128, - ), - ), - ), - }, - FunctionParam { - label: None, - name: "value", - typ: Ok( - Base( - Numeric( - U128, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } + ┌─ u128_u128_map.fe:8:5 + │ + 8 │ ╭ pub fn write_bar(self, key: u128, value: u128) { + 9 │ │ self.bar[key] = value +10 │ │ } + │ ╰─────^ attributes hash: 9126735252114279653 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "key", + typ: Ok( + Base( + Numeric( + U128, + ), + ), + ), + }, + FunctionParam { + label: None, + name: "value", + typ: Ok( + Base( + Numeric( + U128, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } note: - ┌─ u128_u128_map.fe:8:9 + ┌─ u128_u128_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^ Foo: Value note: - ┌─ u128_u128_map.fe:8:9 + ┌─ u128_u128_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^^^^^ ^^^ u128: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ u128_u128_map.fe:8:9 + ┌─ u128_u128_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^^^^^^^^^^ ^^^^^ u128: Value │ │ │ u128: Storage { nonce: None } diff --git a/crates/analyzer/tests/snapshots/analysis__u16_u16_map.snap b/crates/analyzer/tests/snapshots/analysis__u16_u16_map.snap index e110cd6f23..2fabdb8920 100644 --- a/crates/analyzer/tests/snapshots/analysis__u16_u16_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__u16_u16_map.snap @@ -12,9 +12,10 @@ note: note: ┌─ u16_u16_map.fe:4:5 │ -4 │ ╭ pub fn read_bar(self, key: u16) -> u16: +4 │ ╭ pub fn read_bar(self, key: u16) -> u16 { 5 │ │ return self.bar[key] - │ ╰────────────────────────────^ attributes hash: 18312053447303862075 +6 │ │ } + │ ╰─────^ attributes hash: 18312053447303862075 │ = FunctionSignature { self_decl: Some( @@ -64,66 +65,67 @@ note: │ ^^^^^^^^^^^^^ u16: Storage { nonce: None } => Value note: - ┌─ u16_u16_map.fe:7:5 - │ -7 │ ╭ pub fn write_bar(self, key: u16, value: u16): -8 │ │ self.bar[key] = value - │ ╰─────────────────────────────^ attributes hash: 8088868709641766820 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "key", - typ: Ok( - Base( - Numeric( - U16, - ), - ), - ), - }, - FunctionParam { - label: None, - name: "value", - typ: Ok( - Base( - Numeric( - U16, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } + ┌─ u16_u16_map.fe:8:5 + │ + 8 │ ╭ pub fn write_bar(self, key: u16, value: u16) { + 9 │ │ self.bar[key] = value +10 │ │ } + │ ╰─────^ attributes hash: 8088868709641766820 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "key", + typ: Ok( + Base( + Numeric( + U16, + ), + ), + ), + }, + FunctionParam { + label: None, + name: "value", + typ: Ok( + Base( + Numeric( + U16, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } note: - ┌─ u16_u16_map.fe:8:9 + ┌─ u16_u16_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^ Foo: Value note: - ┌─ u16_u16_map.fe:8:9 + ┌─ u16_u16_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^^^^^ ^^^ u16: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ u16_u16_map.fe:8:9 + ┌─ u16_u16_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^^^^^^^^^^ ^^^^^ u16: Value │ │ │ u16: Storage { nonce: None } diff --git a/crates/analyzer/tests/snapshots/analysis__u256_u256_map.snap b/crates/analyzer/tests/snapshots/analysis__u256_u256_map.snap index d418f7f77f..c7faa32d20 100644 --- a/crates/analyzer/tests/snapshots/analysis__u256_u256_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__u256_u256_map.snap @@ -12,9 +12,10 @@ note: note: ┌─ u256_u256_map.fe:4:5 │ -4 │ ╭ pub fn read_bar(self, key: u256) -> u256: +4 │ ╭ pub fn read_bar(self, key: u256) -> u256 { 5 │ │ return self.bar[key] - │ ╰────────────────────────────^ attributes hash: 14897000516975740248 +6 │ │ } + │ ╰─────^ attributes hash: 14897000516975740248 │ = FunctionSignature { self_decl: Some( @@ -64,66 +65,67 @@ note: │ ^^^^^^^^^^^^^ u256: Storage { nonce: None } => Value note: - ┌─ u256_u256_map.fe:7:5 - │ -7 │ ╭ pub fn write_bar(self, key: u256, value: u256): -8 │ │ self.bar[key] = value - │ ╰─────────────────────────────^ attributes hash: 17030413653610901743 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "key", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - }, - FunctionParam { - label: None, - name: "value", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } + ┌─ u256_u256_map.fe:8:5 + │ + 8 │ ╭ pub fn write_bar(self, key: u256, value: u256) { + 9 │ │ self.bar[key] = value +10 │ │ } + │ ╰─────^ attributes hash: 17030413653610901743 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "key", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + }, + FunctionParam { + label: None, + name: "value", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } note: - ┌─ u256_u256_map.fe:8:9 + ┌─ u256_u256_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^ Foo: Value note: - ┌─ u256_u256_map.fe:8:9 + ┌─ u256_u256_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^^^^^ ^^^ u256: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ u256_u256_map.fe:8:9 + ┌─ u256_u256_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } diff --git a/crates/analyzer/tests/snapshots/analysis__u32_u32_map.snap b/crates/analyzer/tests/snapshots/analysis__u32_u32_map.snap index ba117283f7..f8973f21e7 100644 --- a/crates/analyzer/tests/snapshots/analysis__u32_u32_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__u32_u32_map.snap @@ -12,9 +12,10 @@ note: note: ┌─ u32_u32_map.fe:4:5 │ -4 │ ╭ pub fn read_bar(self, key: u32) -> u32: +4 │ ╭ pub fn read_bar(self, key: u32) -> u32 { 5 │ │ return self.bar[key] - │ ╰────────────────────────────^ attributes hash: 17684751964541454304 +6 │ │ } + │ ╰─────^ attributes hash: 17684751964541454304 │ = FunctionSignature { self_decl: Some( @@ -64,66 +65,67 @@ note: │ ^^^^^^^^^^^^^ u32: Storage { nonce: None } => Value note: - ┌─ u32_u32_map.fe:7:5 - │ -7 │ ╭ pub fn write_bar(self, key: u32, value: u32): -8 │ │ self.bar[key] = value - │ ╰─────────────────────────────^ attributes hash: 9068646997358780798 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "key", - typ: Ok( - Base( - Numeric( - U32, - ), - ), - ), - }, - FunctionParam { - label: None, - name: "value", - typ: Ok( - Base( - Numeric( - U32, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } + ┌─ u32_u32_map.fe:8:5 + │ + 8 │ ╭ pub fn write_bar(self, key: u32, value: u32) { + 9 │ │ self.bar[key] = value +10 │ │ } + │ ╰─────^ attributes hash: 9068646997358780798 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "key", + typ: Ok( + Base( + Numeric( + U32, + ), + ), + ), + }, + FunctionParam { + label: None, + name: "value", + typ: Ok( + Base( + Numeric( + U32, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } note: - ┌─ u32_u32_map.fe:8:9 + ┌─ u32_u32_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^ Foo: Value note: - ┌─ u32_u32_map.fe:8:9 + ┌─ u32_u32_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^^^^^ ^^^ u32: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ u32_u32_map.fe:8:9 + ┌─ u32_u32_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^^^^^^^^^^ ^^^^^ u32: Value │ │ │ u32: Storage { nonce: None } diff --git a/crates/analyzer/tests/snapshots/analysis__u64_u64_map.snap b/crates/analyzer/tests/snapshots/analysis__u64_u64_map.snap index 93d44e2ddf..5bebd390a5 100644 --- a/crates/analyzer/tests/snapshots/analysis__u64_u64_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__u64_u64_map.snap @@ -12,9 +12,10 @@ note: note: ┌─ u64_u64_map.fe:4:5 │ -4 │ ╭ pub fn read_bar(self, key: u64) -> u64: +4 │ ╭ pub fn read_bar(self, key: u64) -> u64 { 5 │ │ return self.bar[key] - │ ╰────────────────────────────^ attributes hash: 5490397784598880129 +6 │ │ } + │ ╰─────^ attributes hash: 5490397784598880129 │ = FunctionSignature { self_decl: Some( @@ -64,66 +65,67 @@ note: │ ^^^^^^^^^^^^^ u64: Storage { nonce: None } => Value note: - ┌─ u64_u64_map.fe:7:5 - │ -7 │ ╭ pub fn write_bar(self, key: u64, value: u64): -8 │ │ self.bar[key] = value - │ ╰─────────────────────────────^ attributes hash: 2182326649216136625 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "key", - typ: Ok( - Base( - Numeric( - U64, - ), - ), - ), - }, - FunctionParam { - label: None, - name: "value", - typ: Ok( - Base( - Numeric( - U64, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } + ┌─ u64_u64_map.fe:8:5 + │ + 8 │ ╭ pub fn write_bar(self, key: u64, value: u64) { + 9 │ │ self.bar[key] = value +10 │ │ } + │ ╰─────^ attributes hash: 2182326649216136625 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "key", + typ: Ok( + Base( + Numeric( + U64, + ), + ), + ), + }, + FunctionParam { + label: None, + name: "value", + typ: Ok( + Base( + Numeric( + U64, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } note: - ┌─ u64_u64_map.fe:8:9 + ┌─ u64_u64_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^ Foo: Value note: - ┌─ u64_u64_map.fe:8:9 + ┌─ u64_u64_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^^^^^ ^^^ u64: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ u64_u64_map.fe:8:9 + ┌─ u64_u64_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^^^^^^^^^^ ^^^^^ u64: Value │ │ │ u64: Storage { nonce: None } diff --git a/crates/analyzer/tests/snapshots/analysis__u8_u8_map.snap b/crates/analyzer/tests/snapshots/analysis__u8_u8_map.snap index 09a887aab4..9d0442f2ba 100644 --- a/crates/analyzer/tests/snapshots/analysis__u8_u8_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__u8_u8_map.snap @@ -12,9 +12,10 @@ note: note: ┌─ u8_u8_map.fe:4:5 │ -4 │ ╭ pub fn read_bar(self, key: u8) -> u8: +4 │ ╭ pub fn read_bar(self, key: u8) -> u8 { 5 │ │ return self.bar[key] - │ ╰────────────────────────────^ attributes hash: 3828358868158950430 +6 │ │ } + │ ╰─────^ attributes hash: 3828358868158950430 │ = FunctionSignature { self_decl: Some( @@ -64,66 +65,67 @@ note: │ ^^^^^^^^^^^^^ u8: Storage { nonce: None } => Value note: - ┌─ u8_u8_map.fe:7:5 - │ -7 │ ╭ pub fn write_bar(self, key: u8, value: u8): -8 │ │ self.bar[key] = value - │ ╰─────────────────────────────^ attributes hash: 1989504953336313430 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "key", - typ: Ok( - Base( - Numeric( - U8, - ), - ), - ), - }, - FunctionParam { - label: None, - name: "value", - typ: Ok( - Base( - Numeric( - U8, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } + ┌─ u8_u8_map.fe:8:5 + │ + 8 │ ╭ pub fn write_bar(self, key: u8, value: u8) { + 9 │ │ self.bar[key] = value +10 │ │ } + │ ╰─────^ attributes hash: 1989504953336313430 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "key", + typ: Ok( + Base( + Numeric( + U8, + ), + ), + ), + }, + FunctionParam { + label: None, + name: "value", + typ: Ok( + Base( + Numeric( + U8, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } note: - ┌─ u8_u8_map.fe:8:9 + ┌─ u8_u8_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^ Foo: Value note: - ┌─ u8_u8_map.fe:8:9 + ┌─ u8_u8_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^^^^^ ^^^ u8: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ u8_u8_map.fe:8:9 + ┌─ u8_u8_map.fe:9:9 │ -8 │ self.bar[key] = value +9 │ self.bar[key] = value │ ^^^^^^^^^^^^^ ^^^^^ u8: Value │ │ │ u8: Storage { nonce: None } diff --git a/crates/analyzer/tests/snapshots/analysis__uniswap.snap b/crates/analyzer/tests/snapshots/analysis__uniswap.snap index 5b22432f23..8e33374d76 100644 --- a/crates/analyzer/tests/snapshots/analysis__uniswap.snap +++ b/crates/analyzer/tests/snapshots/analysis__uniswap.snap @@ -6,9 +6,10 @@ expression: "build_snapshot(&db, module)" note: ┌─ uniswap.fe:4:5 │ -4 │ ╭ pub fn balanceOf(_ account: address) -> u256: +4 │ ╭ pub fn balanceOf(_ account: address) -> u256 { 5 │ │ return 0 - │ ╰────────────────^ attributes hash: 4709511530683498418 +6 │ │ } + │ ╰─────^ attributes hash: 4709511530683498418 │ = FunctionSignature { self_decl: None, @@ -42,158 +43,160 @@ note: │ ^ u256: Value note: - ┌─ uniswap.fe:7:5 - │ -7 │ ╭ pub fn transfer(to: address, _ amount: u256) -> bool: -8 │ │ return false - │ ╰────────────────────^ attributes hash: 12261720285838819896 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [ - FunctionParam { - label: None, - name: "to", - typ: Ok( - Base( - Address, - ), - ), - }, - FunctionParam { - label: Some( - "_", - ), - name: "amount", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Bool, - ), - ), - } + ┌─ uniswap.fe:8:5 + │ + 8 │ ╭ pub fn transfer(to: address, _ amount: u256) -> bool { + 9 │ │ return false +10 │ │ } + │ ╰─────^ attributes hash: 12261720285838819896 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [ + FunctionParam { + label: None, + name: "to", + typ: Ok( + Base( + Address, + ), + ), + }, + FunctionParam { + label: Some( + "_", + ), + name: "amount", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Bool, + ), + ), + } note: - ┌─ uniswap.fe:8:16 + ┌─ uniswap.fe:9:16 │ -8 │ return false +9 │ return false │ ^^^^^ bool: Value note: - ┌─ uniswap.fe:14:5 + ┌─ uniswap.fe:17:5 │ -14 │ balances: Map +17 │ balances: Map │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map -15 │ allowances: Map> +18 │ allowances: Map> │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map> -16 │ total_supply: u256 +19 │ total_supply: u256 │ ^^^^^^^^^^^^^^^^^^ u256 -17 │ -18 │ nonces: Map +20 │ +21 │ nonces: Map │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Map -19 │ -20 │ factory: address +22 │ +23 │ factory: address │ ^^^^^^^^^^^^^^^^ address -21 │ token0: address +24 │ token0: address │ ^^^^^^^^^^^^^^^ address -22 │ token1: address +25 │ token1: address │ ^^^^^^^^^^^^^^^ address -23 │ -24 │ reserve0: u256 +26 │ +27 │ reserve0: u256 │ ^^^^^^^^^^^^^^ u256 -25 │ reserve1: u256 +28 │ reserve1: u256 │ ^^^^^^^^^^^^^^ u256 -26 │ block_timestamp_last: u256 +29 │ block_timestamp_last: u256 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ u256 -27 │ -28 │ price0_cumulative_last: u256 +30 │ +31 │ price0_cumulative_last: u256 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256 -29 │ price1_cumulative_last: u256 +32 │ price1_cumulative_last: u256 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256 -30 │ k_last: u256 +33 │ k_last: u256 │ ^^^^^^^^^^^^ u256 note: - ┌─ uniswap.fe:33:9 + ┌─ uniswap.fe:36:9 │ -33 │ idx owner: address +36 │ idx owner: address │ ^^^^^^^^^^^^^^^^^^ address -34 │ idx spender: address +37 │ idx spender: address │ ^^^^^^^^^^^^^^^^^^^^ address -35 │ value: u256 +38 │ value: u256 │ ^^^^^^^^^^^ u256 note: - ┌─ uniswap.fe:38:9 + ┌─ uniswap.fe:42:9 │ -38 │ idx from: address +42 │ idx from: address │ ^^^^^^^^^^^^^^^^^ address -39 │ idx to: address +43 │ idx to: address │ ^^^^^^^^^^^^^^^ address -40 │ value: u256 +44 │ value: u256 │ ^^^^^^^^^^^ u256 note: - ┌─ uniswap.fe:43:9 + ┌─ uniswap.fe:48:9 │ -43 │ idx sender: address +48 │ idx sender: address │ ^^^^^^^^^^^^^^^^^^^ address -44 │ amount0: u256 +49 │ amount0: u256 │ ^^^^^^^^^^^^^ u256 -45 │ amount1: u256 +50 │ amount1: u256 │ ^^^^^^^^^^^^^ u256 note: - ┌─ uniswap.fe:48:9 + ┌─ uniswap.fe:54:9 │ -48 │ idx sender: address +54 │ idx sender: address │ ^^^^^^^^^^^^^^^^^^^ address -49 │ amount0: u256 +55 │ amount0: u256 │ ^^^^^^^^^^^^^ u256 -50 │ amount1: u256 +56 │ amount1: u256 │ ^^^^^^^^^^^^^ u256 -51 │ idx to: address +57 │ idx to: address │ ^^^^^^^^^^^^^^^ address note: - ┌─ uniswap.fe:54:9 + ┌─ uniswap.fe:61:9 │ -54 │ idx sender: address +61 │ idx sender: address │ ^^^^^^^^^^^^^^^^^^^ address -55 │ amount0_in: u256 +62 │ amount0_in: u256 │ ^^^^^^^^^^^^^^^^ u256 -56 │ amount1_in: u256 +63 │ amount1_in: u256 │ ^^^^^^^^^^^^^^^^ u256 -57 │ amount0_out: u256 +64 │ amount0_out: u256 │ ^^^^^^^^^^^^^^^^^ u256 -58 │ amount1_out: u256 +65 │ amount1_out: u256 │ ^^^^^^^^^^^^^^^^^ u256 -59 │ idx to: address +66 │ idx to: address │ ^^^^^^^^^^^^^^^ address note: - ┌─ uniswap.fe:62:9 + ┌─ uniswap.fe:70:9 │ -62 │ reserve0: u256 +70 │ reserve0: u256 │ ^^^^^^^^^^^^^^ u256 -63 │ reserve1: u256 +71 │ reserve1: u256 │ ^^^^^^^^^^^^^^ u256 note: - ┌─ uniswap.fe:68:5 + ┌─ uniswap.fe:78:5 │ -68 │ ╭ pub fn factory(self) -> address: -69 │ │ return self.factory - │ ╰───────────────────────────^ attributes hash: 227275695522088782 +78 │ ╭ pub fn factory(self) -> address { +79 │ │ return self.factory +80 │ │ } + │ ╰─────^ attributes hash: 227275695522088782 │ = FunctionSignature { self_decl: Some( @@ -209,23 +212,24 @@ note: } note: - ┌─ uniswap.fe:69:16 + ┌─ uniswap.fe:79:16 │ -69 │ return self.factory +79 │ return self.factory │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:69:16 + ┌─ uniswap.fe:79:16 │ -69 │ return self.factory +79 │ return self.factory │ ^^^^^^^^^^^^ address: Storage { nonce: Some(4) } => Value note: - ┌─ uniswap.fe:71:5 + ┌─ uniswap.fe:82:5 │ -71 │ ╭ pub fn token0(self) -> address: -72 │ │ return self.token0 - │ ╰──────────────────────────^ attributes hash: 227275695522088782 +82 │ ╭ pub fn token0(self) -> address { +83 │ │ return self.token0 +84 │ │ } + │ ╰─────^ attributes hash: 227275695522088782 │ = FunctionSignature { self_decl: Some( @@ -241,23 +245,24 @@ note: } note: - ┌─ uniswap.fe:72:16 + ┌─ uniswap.fe:83:16 │ -72 │ return self.token0 +83 │ return self.token0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:72:16 + ┌─ uniswap.fe:83:16 │ -72 │ return self.token0 +83 │ return self.token0 │ ^^^^^^^^^^^ address: Storage { nonce: Some(5) } => Value note: - ┌─ uniswap.fe:74:5 + ┌─ uniswap.fe:86:5 │ -74 │ ╭ pub fn token1(self) -> address: -75 │ │ return self.token1 - │ ╰──────────────────────────^ attributes hash: 227275695522088782 +86 │ ╭ pub fn token1(self) -> address { +87 │ │ return self.token1 +88 │ │ } + │ ╰─────^ attributes hash: 227275695522088782 │ = FunctionSignature { self_decl: Some( @@ -273,25 +278,26 @@ note: } note: - ┌─ uniswap.fe:75:16 + ┌─ uniswap.fe:87:16 │ -75 │ return self.token1 +87 │ return self.token1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:75:16 + ┌─ uniswap.fe:87:16 │ -75 │ return self.token1 +87 │ return self.token1 │ ^^^^^^^^^^^ address: Storage { nonce: Some(6) } => Value note: - ┌─ uniswap.fe:77:5 + ┌─ uniswap.fe:90:5 │ -77 │ ╭ fn _mint(self, ctx: Context, to: address, value: u256): -78 │ │ self.total_supply = self.total_supply + value -79 │ │ self.balances[to] = self.balances[to] + value -80 │ │ emit Transfer(ctx, from: address(0), to, value) - │ ╰───────────────────────────────────────────────────────^ attributes hash: 12650409809079895726 +90 │ ╭ fn _mint(self, ctx: Context, to: address, value: u256) { +91 │ │ self.total_supply = self.total_supply + value +92 │ │ self.balances[to] = self.balances[to] + value +93 │ │ emit Transfer(ctx, from: address(0), to, value) +94 │ │ } + │ ╰─────^ attributes hash: 12650409809079895726 │ = FunctionSignature { self_decl: Some( @@ -342,90 +348,90 @@ note: } note: - ┌─ uniswap.fe:78:9 + ┌─ uniswap.fe:91:9 │ -78 │ self.total_supply = self.total_supply + value +91 │ self.total_supply = self.total_supply + value │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:78:9 + ┌─ uniswap.fe:91:9 │ -78 │ self.total_supply = self.total_supply + value +91 │ self.total_supply = self.total_supply + value │ ^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: Some(2) } note: - ┌─ uniswap.fe:78:29 + ┌─ uniswap.fe:91:29 │ -78 │ self.total_supply = self.total_supply + value +91 │ self.total_supply = self.total_supply + value │ ^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(2) } => Value note: - ┌─ uniswap.fe:78:29 + ┌─ uniswap.fe:91:29 │ -78 │ self.total_supply = self.total_supply + value +91 │ self.total_supply = self.total_supply + value │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -79 │ self.balances[to] = self.balances[to] + value +92 │ self.balances[to] = self.balances[to] + value │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:79:9 + ┌─ uniswap.fe:92:9 │ -79 │ self.balances[to] = self.balances[to] + value +92 │ self.balances[to] = self.balances[to] + value │ ^^^^^^^^^^^^^ ^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:79:9 + ┌─ uniswap.fe:92:9 │ -79 │ self.balances[to] = self.balances[to] + value +92 │ self.balances[to] = self.balances[to] + value │ ^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: None } note: - ┌─ uniswap.fe:79:29 + ┌─ uniswap.fe:92:29 │ -79 │ self.balances[to] = self.balances[to] + value +92 │ self.balances[to] = self.balances[to] + value │ ^^^^^^^^^^^^^ ^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:79:29 + ┌─ uniswap.fe:92:29 │ -79 │ self.balances[to] = self.balances[to] + value +92 │ self.balances[to] = self.balances[to] + value │ ^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:79:29 + ┌─ uniswap.fe:92:29 │ -79 │ self.balances[to] = self.balances[to] + value +92 │ self.balances[to] = self.balances[to] + value │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -80 │ emit Transfer(ctx, from: address(0), to, value) +93 │ emit Transfer(ctx, from: address(0), to, value) │ ^^^ ^ u256: Value │ │ │ Context: Memory note: - ┌─ uniswap.fe:80:34 + ┌─ uniswap.fe:93:34 │ -80 │ emit Transfer(ctx, from: address(0), to, value) +93 │ emit Transfer(ctx, from: address(0), to, value) │ ^^^^^^^^^^ ^^ ^^^^^ u256: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ uniswap.fe:80:9 + ┌─ uniswap.fe:93:9 │ -80 │ emit Transfer(ctx, from: address(0), to, value) +93 │ emit Transfer(ctx, from: address(0), to, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 5533489995250141934 │ = Event { @@ -464,147 +470,148 @@ note: } note: - ┌─ uniswap.fe:82:5 - │ -82 │ ╭ fn _burn(self, ctx: Context, from: address, value: u256): -83 │ │ self.balances[from] = self.balances[from] - value -84 │ │ self.total_supply = self.total_supply - value -85 │ │ emit Transfer(ctx, from, to: address(0), value) - │ ╰───────────────────────────────────────────────────────^ attributes hash: 16245072311291560743 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: Some( - Mutable, - ), - params: [ - FunctionParam { - label: None, - name: "ctx", - typ: Ok( - Struct( - Struct { - name: "Context", - field_count: 0, - }, - ), - ), - }, - FunctionParam { - label: None, - name: "from", - typ: Ok( - Base( - Address, - ), - ), - }, - FunctionParam { - label: None, - name: "value", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } + ┌─ uniswap.fe:96:5 + │ + 96 │ ╭ fn _burn(self, ctx: Context, from: address, value: u256) { + 97 │ │ self.balances[from] = self.balances[from] - value + 98 │ │ self.total_supply = self.total_supply - value + 99 │ │ emit Transfer(ctx, from, to: address(0), value) +100 │ │ } + │ ╰─────^ attributes hash: 16245072311291560743 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: Some( + Mutable, + ), + params: [ + FunctionParam { + label: None, + name: "ctx", + typ: Ok( + Struct( + Struct { + name: "Context", + field_count: 0, + }, + ), + ), + }, + FunctionParam { + label: None, + name: "from", + typ: Ok( + Base( + Address, + ), + ), + }, + FunctionParam { + label: None, + name: "value", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } note: - ┌─ uniswap.fe:83:9 + ┌─ uniswap.fe:97:9 │ -83 │ self.balances[from] = self.balances[from] - value +97 │ self.balances[from] = self.balances[from] - value │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:83:9 + ┌─ uniswap.fe:97:9 │ -83 │ self.balances[from] = self.balances[from] - value +97 │ self.balances[from] = self.balances[from] - value │ ^^^^^^^^^^^^^ ^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:83:9 + ┌─ uniswap.fe:97:9 │ -83 │ self.balances[from] = self.balances[from] - value +97 │ self.balances[from] = self.balances[from] - value │ ^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: None } note: - ┌─ uniswap.fe:83:31 + ┌─ uniswap.fe:97:31 │ -83 │ self.balances[from] = self.balances[from] - value +97 │ self.balances[from] = self.balances[from] - value │ ^^^^^^^^^^^^^ ^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:83:31 + ┌─ uniswap.fe:97:31 │ -83 │ self.balances[from] = self.balances[from] - value +97 │ self.balances[from] = self.balances[from] - value │ ^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:83:31 + ┌─ uniswap.fe:97:31 │ -83 │ self.balances[from] = self.balances[from] - value +97 │ self.balances[from] = self.balances[from] - value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -84 │ self.total_supply = self.total_supply - value +98 │ self.total_supply = self.total_supply - value │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:84:9 + ┌─ uniswap.fe:98:9 │ -84 │ self.total_supply = self.total_supply - value +98 │ self.total_supply = self.total_supply - value │ ^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: Some(2) } note: - ┌─ uniswap.fe:84:29 + ┌─ uniswap.fe:98:29 │ -84 │ self.total_supply = self.total_supply - value +98 │ self.total_supply = self.total_supply - value │ ^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(2) } => Value note: - ┌─ uniswap.fe:84:29 + ┌─ uniswap.fe:98:29 │ -84 │ self.total_supply = self.total_supply - value +98 │ self.total_supply = self.total_supply - value │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -85 │ emit Transfer(ctx, from, to: address(0), value) +99 │ emit Transfer(ctx, from, to: address(0), value) │ ^^^ ^^^^ ^ u256: Value │ │ │ │ │ address: Value │ Context: Memory note: - ┌─ uniswap.fe:85:38 + ┌─ uniswap.fe:99:38 │ -85 │ emit Transfer(ctx, from, to: address(0), value) +99 │ emit Transfer(ctx, from, to: address(0), value) │ ^^^^^^^^^^ ^^^^^ u256: Value │ │ │ address: Value note: - ┌─ uniswap.fe:85:9 + ┌─ uniswap.fe:99:9 │ -85 │ emit Transfer(ctx, from, to: address(0), value) +99 │ emit Transfer(ctx, from, to: address(0), value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 5533489995250141934 │ = Event { @@ -643,351 +650,354 @@ note: } note: - ┌─ uniswap.fe:88:5 - │ -88 │ ╭ fn _approve(self, ctx: Context, owner: address, spender: address, value: u256): -89 │ │ self.allowances[owner][spender] = value -90 │ │ emit Approval(ctx, owner, spender, value) - │ ╰─────────────────────────────────────────────────^ attributes hash: 1630416716014819616 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: Some( - Mutable, - ), - params: [ - FunctionParam { - label: None, - name: "ctx", - typ: Ok( - Struct( - Struct { - name: "Context", - field_count: 0, - }, - ), - ), - }, - FunctionParam { - label: None, - name: "owner", - typ: Ok( - Base( - Address, - ), - ), - }, - FunctionParam { - label: None, - name: "spender", - typ: Ok( - Base( - Address, - ), - ), - }, - FunctionParam { - label: None, - name: "value", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } - -note: - ┌─ uniswap.fe:89:9 - │ -89 │ self.allowances[owner][spender] = value - │ ^^^^ UniswapV2Pair: Value + ┌─ uniswap.fe:102:5 + │ +102 │ ╭ fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { +103 │ │ self.allowances[owner][spender] = value +104 │ │ emit Approval(ctx, owner, spender, value) +105 │ │ } + │ ╰─────^ attributes hash: 1630416716014819616 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: Some( + Mutable, + ), + params: [ + FunctionParam { + label: None, + name: "ctx", + typ: Ok( + Struct( + Struct { + name: "Context", + field_count: 0, + }, + ), + ), + }, + FunctionParam { + label: None, + name: "owner", + typ: Ok( + Base( + Address, + ), + ), + }, + FunctionParam { + label: None, + name: "spender", + typ: Ok( + Base( + Address, + ), + ), + }, + FunctionParam { + label: None, + name: "value", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } note: - ┌─ uniswap.fe:89:9 - │ -89 │ self.allowances[owner][spender] = value - │ ^^^^^^^^^^^^^^^ ^^^^^ address: Value - │ │ - │ Map>: Storage { nonce: Some(1) } + ┌─ uniswap.fe:103:9 + │ +103 │ self.allowances[owner][spender] = value + │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:89:9 - │ -89 │ self.allowances[owner][spender] = value - │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value - │ │ - │ Map: Storage { nonce: None } + ┌─ uniswap.fe:103:9 + │ +103 │ self.allowances[owner][spender] = value + │ ^^^^^^^^^^^^^^^ ^^^^^ address: Value + │ │ + │ Map>: Storage { nonce: Some(1) } note: - ┌─ uniswap.fe:89:9 - │ -89 │ self.allowances[owner][spender] = value - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value - │ │ - │ u256: Storage { nonce: None } -90 │ emit Approval(ctx, owner, spender, value) - │ ^^^ ^^^^^ ^^^^^^^ ^^^^^ u256: Value - │ │ │ │ - │ │ │ address: Value - │ │ address: Value - │ Context: Memory + ┌─ uniswap.fe:103:9 + │ +103 │ self.allowances[owner][spender] = value + │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value + │ │ + │ Map: Storage { nonce: None } note: - ┌─ uniswap.fe:90:9 - │ -90 │ emit Approval(ctx, owner, spender, value) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 8893313742751514912 - │ - = Event { - name: "Approval", - fields: [ - EventField { - name: "owner", - typ: Ok( - Base( - Address, - ), - ), - is_indexed: true, - }, - EventField { - name: "spender", - typ: Ok( - Base( - Address, - ), - ), - is_indexed: true, - }, - EventField { - name: "value", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - is_indexed: false, - }, - ], - } + ┌─ uniswap.fe:103:9 + │ +103 │ self.allowances[owner][spender] = value + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value + │ │ + │ u256: Storage { nonce: None } +104 │ emit Approval(ctx, owner, spender, value) + │ ^^^ ^^^^^ ^^^^^^^ ^^^^^ u256: Value + │ │ │ │ + │ │ │ address: Value + │ │ address: Value + │ Context: Memory note: - ┌─ uniswap.fe:93:5 - │ -93 │ ╭ fn _transfer(self, ctx: Context, from: address, to: address, value: u256): -94 │ │ self.balances[from] = self.balances[from] - value -95 │ │ self.balances[to] = self.balances[to] + value -96 │ │ emit Transfer(ctx, from, to, value) - │ ╰───────────────────────────────────────────^ attributes hash: 1442617122763943794 - │ - = FunctionSignature { - self_decl: Some( - Mutable, - ), - ctx_decl: Some( - Mutable, - ), - params: [ - FunctionParam { - label: None, - name: "ctx", - typ: Ok( - Struct( - Struct { - name: "Context", - field_count: 0, - }, - ), - ), - }, - FunctionParam { - label: None, - name: "from", - typ: Ok( - Base( - Address, - ), - ), - }, - FunctionParam { - label: None, - name: "to", - typ: Ok( - Base( - Address, - ), - ), - }, - FunctionParam { - label: None, - name: "value", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - }, - ], - return_type: Ok( - Base( - Unit, - ), - ), - } + ┌─ uniswap.fe:104:9 + │ +104 │ emit Approval(ctx, owner, spender, value) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 8893313742751514912 + │ + = Event { + name: "Approval", + fields: [ + EventField { + name: "owner", + typ: Ok( + Base( + Address, + ), + ), + is_indexed: true, + }, + EventField { + name: "spender", + typ: Ok( + Base( + Address, + ), + ), + is_indexed: true, + }, + EventField { + name: "value", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + is_indexed: false, + }, + ], + } note: - ┌─ uniswap.fe:94:9 - │ -94 │ self.balances[from] = self.balances[from] - value - │ ^^^^ UniswapV2Pair: Value + ┌─ uniswap.fe:107:5 + │ +107 │ ╭ fn _transfer(self, ctx: Context, from: address, to: address, value: u256) { +108 │ │ self.balances[from] = self.balances[from] - value +109 │ │ self.balances[to] = self.balances[to] + value +110 │ │ emit Transfer(ctx, from, to, value) +111 │ │ } + │ ╰─────^ attributes hash: 1442617122763943794 + │ + = FunctionSignature { + self_decl: Some( + Mutable, + ), + ctx_decl: Some( + Mutable, + ), + params: [ + FunctionParam { + label: None, + name: "ctx", + typ: Ok( + Struct( + Struct { + name: "Context", + field_count: 0, + }, + ), + ), + }, + FunctionParam { + label: None, + name: "from", + typ: Ok( + Base( + Address, + ), + ), + }, + FunctionParam { + label: None, + name: "to", + typ: Ok( + Base( + Address, + ), + ), + }, + FunctionParam { + label: None, + name: "value", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + }, + ], + return_type: Ok( + Base( + Unit, + ), + ), + } note: - ┌─ uniswap.fe:94:9 - │ -94 │ self.balances[from] = self.balances[from] - value - │ ^^^^^^^^^^^^^ ^^^^ address: Value - │ │ - │ Map: Storage { nonce: Some(0) } + ┌─ uniswap.fe:108:9 + │ +108 │ self.balances[from] = self.balances[from] - value + │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:94:9 - │ -94 │ self.balances[from] = self.balances[from] - value - │ ^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value - │ │ - │ u256: Storage { nonce: None } + ┌─ uniswap.fe:108:9 + │ +108 │ self.balances[from] = self.balances[from] - value + │ ^^^^^^^^^^^^^ ^^^^ address: Value + │ │ + │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:94:31 - │ -94 │ self.balances[from] = self.balances[from] - value - │ ^^^^^^^^^^^^^ ^^^^ address: Value - │ │ - │ Map: Storage { nonce: Some(0) } + ┌─ uniswap.fe:108:9 + │ +108 │ self.balances[from] = self.balances[from] - value + │ ^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value + │ │ + │ u256: Storage { nonce: None } note: - ┌─ uniswap.fe:94:31 - │ -94 │ self.balances[from] = self.balances[from] - value - │ ^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value - │ │ - │ u256: Storage { nonce: None } => Value + ┌─ uniswap.fe:108:31 + │ +108 │ self.balances[from] = self.balances[from] - value + │ ^^^^^^^^^^^^^ ^^^^ address: Value + │ │ + │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:94:31 - │ -94 │ self.balances[from] = self.balances[from] - value - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -95 │ self.balances[to] = self.balances[to] + value - │ ^^^^ UniswapV2Pair: Value + ┌─ uniswap.fe:108:31 + │ +108 │ self.balances[from] = self.balances[from] - value + │ ^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value + │ │ + │ u256: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:95:9 - │ -95 │ self.balances[to] = self.balances[to] + value - │ ^^^^^^^^^^^^^ ^^ address: Value - │ │ - │ Map: Storage { nonce: Some(0) } + ┌─ uniswap.fe:108:31 + │ +108 │ self.balances[from] = self.balances[from] - value + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +109 │ self.balances[to] = self.balances[to] + value + │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:95:9 - │ -95 │ self.balances[to] = self.balances[to] + value - │ ^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value - │ │ - │ u256: Storage { nonce: None } + ┌─ uniswap.fe:109:9 + │ +109 │ self.balances[to] = self.balances[to] + value + │ ^^^^^^^^^^^^^ ^^ address: Value + │ │ + │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:95:29 - │ -95 │ self.balances[to] = self.balances[to] + value - │ ^^^^^^^^^^^^^ ^^ address: Value - │ │ - │ Map: Storage { nonce: Some(0) } + ┌─ uniswap.fe:109:9 + │ +109 │ self.balances[to] = self.balances[to] + value + │ ^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value + │ │ + │ u256: Storage { nonce: None } note: - ┌─ uniswap.fe:95:29 - │ -95 │ self.balances[to] = self.balances[to] + value - │ ^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value - │ │ - │ u256: Storage { nonce: None } => Value + ┌─ uniswap.fe:109:29 + │ +109 │ self.balances[to] = self.balances[to] + value + │ ^^^^^^^^^^^^^ ^^ address: Value + │ │ + │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:95:29 - │ -95 │ self.balances[to] = self.balances[to] + value - │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -96 │ emit Transfer(ctx, from, to, value) - │ ^^^ ^^^^ ^^ ^^^^^ u256: Value - │ │ │ │ - │ │ │ address: Value - │ │ address: Value - │ Context: Memory + ┌─ uniswap.fe:109:29 + │ +109 │ self.balances[to] = self.balances[to] + value + │ ^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value + │ │ + │ u256: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:96:9 - │ -96 │ emit Transfer(ctx, from, to, value) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 5533489995250141934 - │ - = Event { - name: "Transfer", - fields: [ - EventField { - name: "from", - typ: Ok( - Base( - Address, - ), - ), - is_indexed: true, - }, - EventField { - name: "to", - typ: Ok( - Base( - Address, - ), - ), - is_indexed: true, - }, - EventField { - name: "value", - typ: Ok( - Base( - Numeric( - U256, - ), - ), - ), - is_indexed: false, - }, - ], - } + ┌─ uniswap.fe:109:29 + │ +109 │ self.balances[to] = self.balances[to] + value + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +110 │ emit Transfer(ctx, from, to, value) + │ ^^^ ^^^^ ^^ ^^^^^ u256: Value + │ │ │ │ + │ │ │ address: Value + │ │ address: Value + │ Context: Memory + +note: + ┌─ uniswap.fe:110:9 + │ +110 │ emit Transfer(ctx, from, to, value) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 5533489995250141934 + │ + = Event { + name: "Transfer", + fields: [ + EventField { + name: "from", + typ: Ok( + Base( + Address, + ), + ), + is_indexed: true, + }, + EventField { + name: "to", + typ: Ok( + Base( + Address, + ), + ), + is_indexed: true, + }, + EventField { + name: "value", + typ: Ok( + Base( + Numeric( + U256, + ), + ), + ), + is_indexed: false, + }, + ], + } note: - ┌─ uniswap.fe:98:5 + ┌─ uniswap.fe:113:5 │ - 98 │ ╭ pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool: - 99 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) -100 │ │ return true - │ ╰───────────────────^ attributes hash: 8309406699454253603 +113 │ ╭ pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool { +114 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) +115 │ │ return true +116 │ │ } + │ ╰─────^ attributes hash: 8309406699454253603 │ = FunctionSignature { self_decl: Some( @@ -1038,38 +1048,39 @@ note: } note: - ┌─ uniswap.fe:99:9 - │ -99 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) - │ ^^^^ ^^^ ^^^ Context: Memory - │ │ │ - │ │ Context: Memory - │ UniswapV2Pair: Value + ┌─ uniswap.fe:114:9 + │ +114 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) + │ ^^^^ ^^^ ^^^ Context: Memory + │ │ │ + │ │ Context: Memory + │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:99:35 - │ -99 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) - │ ^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^ u256: Value - │ │ │ - │ │ address: Value - │ address: Value + ┌─ uniswap.fe:114:35 + │ +114 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) + │ ^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^ u256: Value + │ │ │ + │ │ address: Value + │ address: Value note: - ┌─ uniswap.fe:99:9 + ┌─ uniswap.fe:114:9 │ - 99 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) +114 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -100 │ return true +115 │ return true │ ^^^^ bool: Value note: - ┌─ uniswap.fe:102:5 + ┌─ uniswap.fe:118:5 │ -102 │ ╭ pub fn transfer(self, ctx: Context, to: address, value: u256) -> bool: -103 │ │ self._transfer(ctx, from: ctx.msg_sender(), to, value) -104 │ │ return true - │ ╰───────────────────^ attributes hash: 14718526948940966913 +118 │ ╭ pub fn transfer(self, ctx: Context, to: address, value: u256) -> bool { +119 │ │ self._transfer(ctx, from: ctx.msg_sender(), to, value) +120 │ │ return true +121 │ │ } + │ ╰─────^ attributes hash: 14718526948940966913 │ = FunctionSignature { self_decl: Some( @@ -1120,40 +1131,41 @@ note: } note: - ┌─ uniswap.fe:103:9 + ┌─ uniswap.fe:119:9 │ -103 │ self._transfer(ctx, from: ctx.msg_sender(), to, value) +119 │ self._transfer(ctx, from: ctx.msg_sender(), to, value) │ ^^^^ ^^^ ^^^ Context: Memory │ │ │ │ │ Context: Memory │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:103:35 + ┌─ uniswap.fe:119:35 │ -103 │ self._transfer(ctx, from: ctx.msg_sender(), to, value) +119 │ self._transfer(ctx, from: ctx.msg_sender(), to, value) │ ^^^^^^^^^^^^^^^^ ^^ ^^^^^ u256: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ uniswap.fe:103:9 + ┌─ uniswap.fe:119:9 │ -103 │ self._transfer(ctx, from: ctx.msg_sender(), to, value) +119 │ self._transfer(ctx, from: ctx.msg_sender(), to, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -104 │ return true +120 │ return true │ ^^^^ bool: Value note: - ┌─ uniswap.fe:106:5 + ┌─ uniswap.fe:123:5 │ -106 │ ╭ pub fn transferFrom(self, ctx: Context, from: address, to: address, value: u256) -> bool: -107 │ │ assert self.allowances[from][ctx.msg_sender()] >= value -108 │ │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value -109 │ │ self._transfer(ctx, from, to, value) -110 │ │ return true - │ ╰───────────────────^ attributes hash: 3284161617958543499 +123 │ ╭ pub fn transferFrom(self, ctx: Context, from: address, to: address, value: u256) -> bool { +124 │ │ assert self.allowances[from][ctx.msg_sender()] >= value +125 │ │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +126 │ │ self._transfer(ctx, from, to, value) +127 │ │ return true +128 │ │ } + │ ╰─────^ attributes hash: 3284161617958543499 │ = FunctionSignature { self_decl: Some( @@ -1213,115 +1225,115 @@ note: } note: - ┌─ uniswap.fe:107:16 + ┌─ uniswap.fe:124:16 │ -107 │ assert self.allowances[from][ctx.msg_sender()] >= value +124 │ assert self.allowances[from][ctx.msg_sender()] >= value │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:107:16 + ┌─ uniswap.fe:124:16 │ -107 │ assert self.allowances[from][ctx.msg_sender()] >= value +124 │ assert self.allowances[from][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^ ^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ uniswap.fe:107:16 + ┌─ uniswap.fe:124:16 │ -107 │ assert self.allowances[from][ctx.msg_sender()] >= value +124 │ assert self.allowances[from][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: None } note: - ┌─ uniswap.fe:107:38 + ┌─ uniswap.fe:124:38 │ -107 │ assert self.allowances[from][ctx.msg_sender()] >= value +124 │ assert self.allowances[from][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:107:16 + ┌─ uniswap.fe:124:16 │ -107 │ assert self.allowances[from][ctx.msg_sender()] >= value +124 │ assert self.allowances[from][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:107:16 + ┌─ uniswap.fe:124:16 │ -107 │ assert self.allowances[from][ctx.msg_sender()] >= value +124 │ assert self.allowances[from][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -108 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +125 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:108:9 + ┌─ uniswap.fe:125:9 │ -108 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +125 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^ ^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ uniswap.fe:108:9 + ┌─ uniswap.fe:125:9 │ -108 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +125 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: None } note: - ┌─ uniswap.fe:108:31 + ┌─ uniswap.fe:125:31 │ -108 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +125 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:108:9 + ┌─ uniswap.fe:125:9 │ -108 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +125 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: None } note: - ┌─ uniswap.fe:108:51 + ┌─ uniswap.fe:125:51 │ -108 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +125 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^ ^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ uniswap.fe:108:51 + ┌─ uniswap.fe:125:51 │ -108 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +125 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: None } note: - ┌─ uniswap.fe:108:73 + ┌─ uniswap.fe:125:73 │ -108 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +125 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:108:51 + ┌─ uniswap.fe:125:51 │ -108 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +125 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:108:51 + ┌─ uniswap.fe:125:51 │ -108 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +125 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -109 │ self._transfer(ctx, from, to, value) +126 │ self._transfer(ctx, from, to, value) │ ^^^^ ^^^ ^^^^ ^^ ^^^^^ u256: Value │ │ │ │ │ │ │ │ │ address: Value @@ -1330,19 +1342,20 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:109:9 + ┌─ uniswap.fe:126:9 │ -109 │ self._transfer(ctx, from, to, value) +126 │ self._transfer(ctx, from, to, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -110 │ return true +127 │ return true │ ^^^^ bool: Value note: - ┌─ uniswap.fe:112:5 + ┌─ uniswap.fe:130:5 │ -112 │ ╭ pub fn balanceOf(self, _ account: address) -> u256: -113 │ │ return self.balances[account] - │ ╰─────────────────────────────────────^ attributes hash: 5993653573135321647 +130 │ ╭ pub fn balanceOf(self, _ account: address) -> u256 { +131 │ │ return self.balances[account] +132 │ │ } + │ ╰─────^ attributes hash: 5993653573135321647 │ = FunctionSignature { self_decl: Some( @@ -1372,31 +1385,32 @@ note: } note: - ┌─ uniswap.fe:113:16 + ┌─ uniswap.fe:131:16 │ -113 │ return self.balances[account] +131 │ return self.balances[account] │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:113:16 + ┌─ uniswap.fe:131:16 │ -113 │ return self.balances[account] +131 │ return self.balances[account] │ ^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:113:16 + ┌─ uniswap.fe:131:16 │ -113 │ return self.balances[account] +131 │ return self.balances[account] │ ^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:115:5 + ┌─ uniswap.fe:134:5 │ -115 │ ╭ pub fn get_reserves(self) -> (u256, u256, u256): -116 │ │ return (self.reserve0, self.reserve1, self.block_timestamp_last) - │ ╰────────────────────────────────────────────────────────────────────────^ attributes hash: 3743538709625240197 +134 │ ╭ pub fn get_reserves(self) -> (u256, u256, u256) { +135 │ │ return (self.reserve0, self.reserve1, self.block_timestamp_last) +136 │ │ } + │ ╰─────^ attributes hash: 3743538709625240197 │ = FunctionSignature { self_decl: Some( @@ -1430,47 +1444,48 @@ note: } note: - ┌─ uniswap.fe:116:17 + ┌─ uniswap.fe:135:17 │ -116 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) +135 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:116:17 + ┌─ uniswap.fe:135:17 │ -116 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) +135 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) │ ^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: Some(7) } => Value note: - ┌─ uniswap.fe:116:32 + ┌─ uniswap.fe:135:32 │ -116 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) +135 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) │ ^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: Some(8) } => Value note: - ┌─ uniswap.fe:116:47 + ┌─ uniswap.fe:135:47 │ -116 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) +135 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(9) } => Value note: - ┌─ uniswap.fe:116:16 + ┌─ uniswap.fe:135:16 │ -116 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) +135 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (u256, u256, u256): Memory note: - ┌─ uniswap.fe:119:5 + ┌─ uniswap.fe:139:5 │ -119 │ ╭ pub fn initialize(self, ctx: Context, token0: address, token1: address): -120 │ │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" -121 │ │ self.token0 = token0 -122 │ │ self.token1 = token1 - │ ╰────────────────────────────^ attributes hash: 10460756106041683522 +139 │ ╭ pub fn initialize(self, ctx: Context, token0: address, token1: address) { +140 │ │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" +141 │ │ self.token0 = token0 +142 │ │ self.token1 = token1 +143 │ │ } + │ ╰─────^ attributes hash: 10460756106041683522 │ = FunctionSignature { self_decl: Some( @@ -1519,64 +1534,64 @@ note: } note: - ┌─ uniswap.fe:120:16 + ┌─ uniswap.fe:140:16 │ -120 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" +140 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" │ ^^^ Context: Memory note: - ┌─ uniswap.fe:120:16 + ┌─ uniswap.fe:140:16 │ -120 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" +140 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ address: Value note: - ┌─ uniswap.fe:120:36 + ┌─ uniswap.fe:140:36 │ -120 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" +140 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^ address: Storage { nonce: Some(4) } => Value note: - ┌─ uniswap.fe:120:16 + ┌─ uniswap.fe:140:16 │ -120 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" +140 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ String<20>: Memory │ │ │ bool: Value -121 │ self.token0 = token0 +141 │ self.token0 = token0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:121:9 + ┌─ uniswap.fe:141:9 │ -121 │ self.token0 = token0 +141 │ self.token0 = token0 │ ^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ address: Storage { nonce: Some(5) } -122 │ self.token1 = token1 +142 │ self.token1 = token1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:122:9 + ┌─ uniswap.fe:142:9 │ -122 │ self.token1 = token1 +142 │ self.token1 = token1 │ ^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ address: Storage { nonce: Some(6) } note: - ┌─ uniswap.fe:125:5 + ┌─ uniswap.fe:146:5 │ -125 │ ╭ fn _update(self, ctx: Context, balance0: u256, balance1: u256, reserve0: u256, reserve1: u256): -126 │ │ # changed from u32s -127 │ │ let block_timestamp: u256 = ctx.block_timestamp() % 2**32 -128 │ │ # TODO: reproduce desired overflow (https://github.com/ethereum/fe/issues/286) +146 │ ╭ fn _update(self, ctx: Context, balance0: u256, balance1: u256, reserve0: u256, reserve1: u256) { +147 │ │ # changed from u32s +148 │ │ # TODO: reproduce desired overflow (https://github.com/ethereum/fe/issues/286) +149 │ │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 · │ -137 │ │ self.block_timestamp_last = block_timestamp -138 │ │ emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) - │ ╰────────────────────────────────────────────────────────────────────────^ attributes hash: 14441581101409065213 +158 │ │ emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) +159 │ │ } + │ ╰─────^ attributes hash: 14441581101409065213 │ = FunctionSignature { self_decl: Some( @@ -1651,230 +1666,227 @@ note: } note: - ┌─ uniswap.fe:127:30 + ┌─ uniswap.fe:149:30 │ -127 │ let block_timestamp: u256 = ctx.block_timestamp() % 2**32 +149 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 │ ^^^^ u256 -128 │ # TODO: reproduce desired overflow (https://github.com/ethereum/fe/issues/286) -129 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last # overflow is desired +150 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last │ ^^^^ u256 note: - ┌─ uniswap.fe:127:37 + ┌─ uniswap.fe:149:37 │ -127 │ let block_timestamp: u256 = ctx.block_timestamp() % 2**32 +149 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 │ ^^^ Context: Memory note: - ┌─ uniswap.fe:127:37 + ┌─ uniswap.fe:149:37 │ -127 │ let block_timestamp: u256 = ctx.block_timestamp() % 2**32 - │ ^^^^^^^^^^^^^^^^^^^^^ ^ ^^ u256: Value - │ │ │ +149 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 + │ ^^^^^^^^^^^^^^^^^^^^^ ^ ^^ u256: Value + │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:127:61 + ┌─ uniswap.fe:149:61 │ -127 │ let block_timestamp: u256 = ctx.block_timestamp() % 2**32 - │ ^^^^^ u256: Value +149 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 + │ ^^^^^^^ u256: Value note: - ┌─ uniswap.fe:127:37 + ┌─ uniswap.fe:149:37 │ -127 │ let block_timestamp: u256 = ctx.block_timestamp() % 2**32 - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -128 │ # TODO: reproduce desired overflow (https://github.com/ethereum/fe/issues/286) -129 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last # overflow is desired +149 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +150 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last │ ^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:129:52 + ┌─ uniswap.fe:150:52 │ -129 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last # overflow is desired +150 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(9) } => Value note: - ┌─ uniswap.fe:129:34 + ┌─ uniswap.fe:150:34 │ -129 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last # overflow is desired +150 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -130 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0: +151 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { │ ^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:130:12 + ┌─ uniswap.fe:151:12 │ -130 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0: +151 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { │ ^^^^^^^^^^^^^^^^ ^^^^^^^^ ^ u256: Value │ │ │ │ │ u256: Value │ bool: Value note: - ┌─ uniswap.fe:130:33 + ┌─ uniswap.fe:151:33 │ -130 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0: +151 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { │ ^^^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:130:12 + ┌─ uniswap.fe:151:12 │ -130 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0: +151 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^ u256: Value │ │ │ │ │ u256: Value │ bool: Value note: - ┌─ uniswap.fe:130:51 + ┌─ uniswap.fe:151:51 │ -130 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0: +151 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { │ ^^^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:130:12 + ┌─ uniswap.fe:151:12 │ -130 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0: +151 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -131 │ # `*` never overflows, and + overflow is desired -132 │ self.price0_cumulative_last = self.price0_cumulative_last + (reserve1 / reserve0) * time_elapsed +152 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:132:13 + ┌─ uniswap.fe:152:13 │ -132 │ self.price0_cumulative_last = self.price0_cumulative_last + (reserve1 / reserve0) * time_elapsed +152 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: Some(10) } note: - ┌─ uniswap.fe:132:43 + ┌─ uniswap.fe:152:43 │ -132 │ self.price0_cumulative_last = self.price0_cumulative_last + (reserve1 / reserve0) * time_elapsed - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value - │ │ │ - │ │ u256: Value +152 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value + │ │ │ + │ │ u256: Value │ u256: Storage { nonce: Some(10) } => Value note: - ┌─ uniswap.fe:132:73 + ┌─ uniswap.fe:152:73 │ -132 │ self.price0_cumulative_last = self.price0_cumulative_last + (reserve1 / reserve0) * time_elapsed - │ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ u256: Value - │ │ +152 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed + │ ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ u256: Value + │ │ │ u256: Value note: - ┌─ uniswap.fe:132:73 + ┌─ uniswap.fe:152:73 │ -132 │ self.price0_cumulative_last = self.price0_cumulative_last + (reserve1 / reserve0) * time_elapsed - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +152 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:132:43 + ┌─ uniswap.fe:152:43 │ -132 │ self.price0_cumulative_last = self.price0_cumulative_last + (reserve1 / reserve0) * time_elapsed - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -133 │ self.price1_cumulative_last = self.price1_cumulative_last + (reserve0 / reserve1) * time_elapsed +152 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +153 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:133:13 + ┌─ uniswap.fe:153:13 │ -133 │ self.price1_cumulative_last = self.price1_cumulative_last + (reserve0 / reserve1) * time_elapsed +153 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: Some(11) } note: - ┌─ uniswap.fe:133:43 + ┌─ uniswap.fe:153:43 │ -133 │ self.price1_cumulative_last = self.price1_cumulative_last + (reserve0 / reserve1) * time_elapsed - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value - │ │ │ - │ │ u256: Value +153 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value + │ │ │ + │ │ u256: Value │ u256: Storage { nonce: Some(11) } => Value note: - ┌─ uniswap.fe:133:73 + ┌─ uniswap.fe:153:73 │ -133 │ self.price1_cumulative_last = self.price1_cumulative_last + (reserve0 / reserve1) * time_elapsed - │ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ u256: Value - │ │ +153 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed + │ ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ u256: Value + │ │ │ u256: Value note: - ┌─ uniswap.fe:133:73 + ┌─ uniswap.fe:153:73 │ -133 │ self.price1_cumulative_last = self.price1_cumulative_last + (reserve0 / reserve1) * time_elapsed - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +153 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:133:43 + ┌─ uniswap.fe:153:43 │ -133 │ self.price1_cumulative_last = self.price1_cumulative_last + (reserve0 / reserve1) * time_elapsed - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -134 │ -135 │ self.reserve0 = balance0 +153 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +154 │ } +155 │ self.reserve0 = balance0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:135:9 + ┌─ uniswap.fe:155:9 │ -135 │ self.reserve0 = balance0 +155 │ self.reserve0 = balance0 │ ^^^^^^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(7) } -136 │ self.reserve1 = balance1 +156 │ self.reserve1 = balance1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:136:9 + ┌─ uniswap.fe:156:9 │ -136 │ self.reserve1 = balance1 +156 │ self.reserve1 = balance1 │ ^^^^^^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(8) } -137 │ self.block_timestamp_last = block_timestamp +157 │ self.block_timestamp_last = block_timestamp │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:137:9 + ┌─ uniswap.fe:157:9 │ -137 │ self.block_timestamp_last = block_timestamp +157 │ self.block_timestamp_last = block_timestamp │ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(9) } -138 │ emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) +158 │ emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) │ ^^^ ^^^^ UniswapV2Pair: Value │ │ │ Context: Memory note: - ┌─ uniswap.fe:138:34 + ┌─ uniswap.fe:158:34 │ -138 │ emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) +158 │ emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) │ ^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: Some(7) } => Value note: - ┌─ uniswap.fe:138:59 + ┌─ uniswap.fe:158:59 │ -138 │ emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) +158 │ emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(8) } => Value note: - ┌─ uniswap.fe:138:9 + ┌─ uniswap.fe:158:9 │ -138 │ emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) +158 │ emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 11491202868117077488 │ = Event { @@ -1906,16 +1918,16 @@ note: } note: - ┌─ uniswap.fe:141:5 + ┌─ uniswap.fe:161:5 │ -141 │ ╭ fn _mint_fee(self, ctx: Context, reserve0: u256, reserve1: u256) -> bool: -142 │ │ let fee_to: address = UniswapV2Factory(ctx, self.factory).fee_to() -143 │ │ let fee_on: bool = fee_to != address(0) -144 │ │ let k_last: u256 = self.k_last # gas savings +161 │ ╭ fn _mint_fee(self, ctx: Context, reserve0: u256, reserve1: u256) -> bool { +162 │ │ let fee_to: address = UniswapV2Factory(ctx, self.factory).fee_to() +163 │ │ let fee_on: bool = fee_to != address(0) +164 │ │ let k_last: u256 = self.k_last · │ -157 │ │ -158 │ │ return fee_on - │ ╰─────────────────────^ attributes hash: 12335666382859496931 +181 │ │ return fee_on +182 │ │ } + │ ╰─────^ attributes hash: 12335666382859496931 │ = FunctionSignature { self_decl: Some( @@ -1968,185 +1980,185 @@ note: } note: - ┌─ uniswap.fe:142:21 + ┌─ uniswap.fe:162:21 │ -142 │ let fee_to: address = UniswapV2Factory(ctx, self.factory).fee_to() +162 │ let fee_to: address = UniswapV2Factory(ctx, self.factory).fee_to() │ ^^^^^^^ address -143 │ let fee_on: bool = fee_to != address(0) +163 │ let fee_on: bool = fee_to != address(0) │ ^^^^ bool -144 │ let k_last: u256 = self.k_last # gas savings +164 │ let k_last: u256 = self.k_last │ ^^^^ u256 · -147 │ let root_k: u256 = sqrt(reserve0 * reserve1) +167 │ let root_k: u256 = sqrt(reserve0 * reserve1) │ ^^^^ u256 -148 │ let root_k_last: u256 = sqrt(k_last) +168 │ let root_k_last: u256 = sqrt(k_last) │ ^^^^ u256 -149 │ if root_k > root_k_last: -150 │ let numerator: u256 = self.total_supply * root_k - root_k_last +169 │ if root_k > root_k_last { +170 │ let numerator: u256 = self.total_supply * root_k - root_k_last │ ^^^^ u256 -151 │ let denominator: u256 = root_k * 5 + root_k_last +171 │ let denominator: u256 = root_k * 5 + root_k_last │ ^^^^ u256 -152 │ let liquidity: u256 = numerator / denominator +172 │ let liquidity: u256 = numerator / denominator │ ^^^^ u256 note: - ┌─ uniswap.fe:142:48 + ┌─ uniswap.fe:162:48 │ -142 │ let fee_to: address = UniswapV2Factory(ctx, self.factory).fee_to() +162 │ let fee_to: address = UniswapV2Factory(ctx, self.factory).fee_to() │ ^^^ ^^^^ UniswapV2Pair: Value │ │ │ Context: Memory note: - ┌─ uniswap.fe:142:53 + ┌─ uniswap.fe:162:53 │ -142 │ let fee_to: address = UniswapV2Factory(ctx, self.factory).fee_to() +162 │ let fee_to: address = UniswapV2Factory(ctx, self.factory).fee_to() │ ^^^^^^^^^^^^ address: Storage { nonce: Some(4) } => Value note: - ┌─ uniswap.fe:142:31 + ┌─ uniswap.fe:162:31 │ -142 │ let fee_to: address = UniswapV2Factory(ctx, self.factory).fee_to() +162 │ let fee_to: address = UniswapV2Factory(ctx, self.factory).fee_to() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:142:31 + ┌─ uniswap.fe:162:31 │ -142 │ let fee_to: address = UniswapV2Factory(ctx, self.factory).fee_to() +162 │ let fee_to: address = UniswapV2Factory(ctx, self.factory).fee_to() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ address: Value -143 │ let fee_on: bool = fee_to != address(0) +163 │ let fee_on: bool = fee_to != address(0) │ ^^^^^^ ^ u256: Value │ │ │ address: Value note: - ┌─ uniswap.fe:143:38 + ┌─ uniswap.fe:163:38 │ -143 │ let fee_on: bool = fee_to != address(0) +163 │ let fee_on: bool = fee_to != address(0) │ ^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:143:28 + ┌─ uniswap.fe:163:28 │ -143 │ let fee_on: bool = fee_to != address(0) +163 │ let fee_on: bool = fee_to != address(0) │ ^^^^^^^^^^^^^^^^^^^^ bool: Value -144 │ let k_last: u256 = self.k_last # gas savings +164 │ let k_last: u256 = self.k_last │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:144:28 + ┌─ uniswap.fe:164:28 │ -144 │ let k_last: u256 = self.k_last # gas savings +164 │ let k_last: u256 = self.k_last │ ^^^^^^^^^^^ u256: Storage { nonce: Some(12) } => Value -145 │ if fee_on: +165 │ if fee_on { │ ^^^^^^ bool: Value -146 │ if k_last != 0: +166 │ if k_last != 0 { │ ^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:146:16 + ┌─ uniswap.fe:166:16 │ -146 │ if k_last != 0: +166 │ if k_last != 0 { │ ^^^^^^^^^^^ bool: Value -147 │ let root_k: u256 = sqrt(reserve0 * reserve1) +167 │ let root_k: u256 = sqrt(reserve0 * reserve1) │ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:147:41 + ┌─ uniswap.fe:167:41 │ -147 │ let root_k: u256 = sqrt(reserve0 * reserve1) +167 │ let root_k: u256 = sqrt(reserve0 * reserve1) │ ^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:147:36 + ┌─ uniswap.fe:167:36 │ -147 │ let root_k: u256 = sqrt(reserve0 * reserve1) +167 │ let root_k: u256 = sqrt(reserve0 * reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -148 │ let root_k_last: u256 = sqrt(k_last) +168 │ let root_k_last: u256 = sqrt(k_last) │ ^^^^^^ u256: Value note: - ┌─ uniswap.fe:148:41 + ┌─ uniswap.fe:168:41 │ -148 │ let root_k_last: u256 = sqrt(k_last) +168 │ let root_k_last: u256 = sqrt(k_last) │ ^^^^^^^^^^^^ u256: Value -149 │ if root_k > root_k_last: +169 │ if root_k > root_k_last { │ ^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:149:20 + ┌─ uniswap.fe:169:20 │ -149 │ if root_k > root_k_last: +169 │ if root_k > root_k_last { │ ^^^^^^^^^^^^^^^^^^^^ bool: Value -150 │ let numerator: u256 = self.total_supply * root_k - root_k_last +170 │ let numerator: u256 = self.total_supply * root_k - root_k_last │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:150:43 + ┌─ uniswap.fe:170:43 │ -150 │ let numerator: u256 = self.total_supply * root_k - root_k_last +170 │ let numerator: u256 = self.total_supply * root_k - root_k_last │ ^^^^^^^^^^^^^^^^^ ^^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(2) } => Value note: - ┌─ uniswap.fe:150:43 + ┌─ uniswap.fe:170:43 │ -150 │ let numerator: u256 = self.total_supply * root_k - root_k_last +170 │ let numerator: u256 = self.total_supply * root_k - root_k_last │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:150:43 + ┌─ uniswap.fe:170:43 │ -150 │ let numerator: u256 = self.total_supply * root_k - root_k_last +170 │ let numerator: u256 = self.total_supply * root_k - root_k_last │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -151 │ let denominator: u256 = root_k * 5 + root_k_last +171 │ let denominator: u256 = root_k * 5 + root_k_last │ ^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:151:45 + ┌─ uniswap.fe:171:45 │ -151 │ let denominator: u256 = root_k * 5 + root_k_last +171 │ let denominator: u256 = root_k * 5 + root_k_last │ ^^^^^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:151:45 + ┌─ uniswap.fe:171:45 │ -151 │ let denominator: u256 = root_k * 5 + root_k_last +171 │ let denominator: u256 = root_k * 5 + root_k_last │ ^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -152 │ let liquidity: u256 = numerator / denominator +172 │ let liquidity: u256 = numerator / denominator │ ^^^^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:152:43 + ┌─ uniswap.fe:172:43 │ -152 │ let liquidity: u256 = numerator / denominator +172 │ let liquidity: u256 = numerator / denominator │ ^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -153 │ if liquidity > 0: +173 │ if liquidity > 0 { │ ^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:153:24 + ┌─ uniswap.fe:173:24 │ -153 │ if liquidity > 0: +173 │ if liquidity > 0 { │ ^^^^^^^^^^^^^ bool: Value -154 │ self._mint(ctx, to: fee_to, value: liquidity) +174 │ self._mint(ctx, to: fee_to, value: liquidity) │ ^^^^ ^^^ ^^^^^^ ^^^^^^^^^ u256: Value │ │ │ │ │ │ │ address: Value @@ -2154,45 +2166,46 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:154:25 + ┌─ uniswap.fe:174:25 │ -154 │ self._mint(ctx, to: fee_to, value: liquidity) +174 │ self._mint(ctx, to: fee_to, value: liquidity) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -155 │ elif k_last != 0: - │ ^^^^^^ ^ u256: Value - │ │ - │ u256: Value + · +178 │ } else if k_last != 0 { + │ ^^^^^^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ uniswap.fe:155:14 + ┌─ uniswap.fe:178:19 │ -155 │ elif k_last != 0: - │ ^^^^^^^^^^^ bool: Value -156 │ self.k_last = 0 +178 │ } else if k_last != 0 { + │ ^^^^^^^^^^^ bool: Value +179 │ self.k_last = 0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:156:13 + ┌─ uniswap.fe:179:13 │ -156 │ self.k_last = 0 +179 │ self.k_last = 0 │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: Some(12) } -157 │ -158 │ return fee_on +180 │ } +181 │ return fee_on │ ^^^^^^ bool: Value note: - ┌─ uniswap.fe:161:5 + ┌─ uniswap.fe:185:5 │ -161 │ ╭ pub fn mint(self, ctx: Context, to: address) -> u256: -162 │ │ let MINIMUM_LIQUIDITY: u256 = 1000 -163 │ │ let reserve0: u256 = self.reserve0 -164 │ │ let reserve1: u256 = self.reserve1 +185 │ ╭ pub fn mint(self, ctx: Context, to: address) -> u256 { +186 │ │ let MINIMUM_LIQUIDITY: u256 = 1000 +187 │ │ let reserve0: u256 = self.reserve0 +188 │ │ let reserve1: u256 = self.reserve1 · │ -187 │ │ emit Mint(ctx, sender: ctx.msg_sender(), amount0, amount1) -188 │ │ return liquidity - │ ╰────────────────────────^ attributes hash: 11513995717553818344 +209 │ │ return liquidity +210 │ │ } + │ ╰─────^ attributes hash: 11513995717553818344 │ = FunctionSignature { self_decl: Some( @@ -2234,145 +2247,143 @@ note: } note: - ┌─ uniswap.fe:162:32 + ┌─ uniswap.fe:186:32 │ -162 │ let MINIMUM_LIQUIDITY: u256 = 1000 +186 │ let MINIMUM_LIQUIDITY: u256 = 1000 │ ^^^^ u256 -163 │ let reserve0: u256 = self.reserve0 +187 │ let reserve0: u256 = self.reserve0 │ ^^^^ u256 -164 │ let reserve1: u256 = self.reserve1 +188 │ let reserve1: u256 = self.reserve1 │ ^^^^ u256 -165 │ let balance0: u256 = ERC20(ctx, self.token0).balanceOf(ctx.self_address()) +189 │ let balance0: u256 = ERC20(ctx, self.token0).balanceOf(ctx.self_address()) │ ^^^^ u256 -166 │ let balance1: u256 = ERC20(ctx, self.token1).balanceOf(ctx.self_address()) +190 │ let balance1: u256 = ERC20(ctx, self.token1).balanceOf(ctx.self_address()) │ ^^^^ u256 -167 │ let amount0: u256 = balance0 - self.reserve0 +191 │ let amount0: u256 = balance0 - self.reserve0 │ ^^^^ u256 -168 │ let amount1: u256 = balance1 - self.reserve1 +192 │ let amount1: u256 = balance1 - self.reserve1 │ ^^^^ u256 -169 │ -170 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) +193 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) │ ^^^^ bool -171 │ let total_supply: u256 = self.total_supply # gas savings, must be defined here since totalSupply can update in _mintFee +194 │ let total_supply: u256 = self.total_supply # gas savings, must be defined here since totalSupply can update in _mintFee │ ^^^^ u256 -172 │ let liquidity: u256 = 0 +195 │ let liquidity: u256 = 0 │ ^^^^ u256 note: - ┌─ uniswap.fe:162:39 + ┌─ uniswap.fe:186:39 │ -162 │ let MINIMUM_LIQUIDITY: u256 = 1000 +186 │ let MINIMUM_LIQUIDITY: u256 = 1000 │ ^^^^ u256: Value -163 │ let reserve0: u256 = self.reserve0 +187 │ let reserve0: u256 = self.reserve0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:163:30 + ┌─ uniswap.fe:187:30 │ -163 │ let reserve0: u256 = self.reserve0 +187 │ let reserve0: u256 = self.reserve0 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(7) } => Value -164 │ let reserve1: u256 = self.reserve1 +188 │ let reserve1: u256 = self.reserve1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:164:30 + ┌─ uniswap.fe:188:30 │ -164 │ let reserve1: u256 = self.reserve1 +188 │ let reserve1: u256 = self.reserve1 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(8) } => Value -165 │ let balance0: u256 = ERC20(ctx, self.token0).balanceOf(ctx.self_address()) +189 │ let balance0: u256 = ERC20(ctx, self.token0).balanceOf(ctx.self_address()) │ ^^^ ^^^^ UniswapV2Pair: Value │ │ │ Context: Memory note: - ┌─ uniswap.fe:165:41 + ┌─ uniswap.fe:189:41 │ -165 │ let balance0: u256 = ERC20(ctx, self.token0).balanceOf(ctx.self_address()) +189 │ let balance0: u256 = ERC20(ctx, self.token0).balanceOf(ctx.self_address()) │ ^^^^^^^^^^^ address: Storage { nonce: Some(5) } => Value note: - ┌─ uniswap.fe:165:30 + ┌─ uniswap.fe:189:30 │ -165 │ let balance0: u256 = ERC20(ctx, self.token0).balanceOf(ctx.self_address()) +189 │ let balance0: u256 = ERC20(ctx, self.token0).balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Value note: - ┌─ uniswap.fe:165:64 + ┌─ uniswap.fe:189:64 │ -165 │ let balance0: u256 = ERC20(ctx, self.token0).balanceOf(ctx.self_address()) +189 │ let balance0: u256 = ERC20(ctx, self.token0).balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:165:30 + ┌─ uniswap.fe:189:30 │ -165 │ let balance0: u256 = ERC20(ctx, self.token0).balanceOf(ctx.self_address()) +189 │ let balance0: u256 = ERC20(ctx, self.token0).balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -166 │ let balance1: u256 = ERC20(ctx, self.token1).balanceOf(ctx.self_address()) +190 │ let balance1: u256 = ERC20(ctx, self.token1).balanceOf(ctx.self_address()) │ ^^^ ^^^^ UniswapV2Pair: Value │ │ │ Context: Memory note: - ┌─ uniswap.fe:166:41 + ┌─ uniswap.fe:190:41 │ -166 │ let balance1: u256 = ERC20(ctx, self.token1).balanceOf(ctx.self_address()) +190 │ let balance1: u256 = ERC20(ctx, self.token1).balanceOf(ctx.self_address()) │ ^^^^^^^^^^^ address: Storage { nonce: Some(6) } => Value note: - ┌─ uniswap.fe:166:30 + ┌─ uniswap.fe:190:30 │ -166 │ let balance1: u256 = ERC20(ctx, self.token1).balanceOf(ctx.self_address()) +190 │ let balance1: u256 = ERC20(ctx, self.token1).balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Value note: - ┌─ uniswap.fe:166:64 + ┌─ uniswap.fe:190:64 │ -166 │ let balance1: u256 = ERC20(ctx, self.token1).balanceOf(ctx.self_address()) +190 │ let balance1: u256 = ERC20(ctx, self.token1).balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:166:30 + ┌─ uniswap.fe:190:30 │ -166 │ let balance1: u256 = ERC20(ctx, self.token1).balanceOf(ctx.self_address()) +190 │ let balance1: u256 = ERC20(ctx, self.token1).balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -167 │ let amount0: u256 = balance0 - self.reserve0 +191 │ let amount0: u256 = balance0 - self.reserve0 │ ^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:167:40 + ┌─ uniswap.fe:191:40 │ -167 │ let amount0: u256 = balance0 - self.reserve0 +191 │ let amount0: u256 = balance0 - self.reserve0 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(7) } => Value note: - ┌─ uniswap.fe:167:29 + ┌─ uniswap.fe:191:29 │ -167 │ let amount0: u256 = balance0 - self.reserve0 +191 │ let amount0: u256 = balance0 - self.reserve0 │ ^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -168 │ let amount1: u256 = balance1 - self.reserve1 +192 │ let amount1: u256 = balance1 - self.reserve1 │ ^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:168:40 + ┌─ uniswap.fe:192:40 │ -168 │ let amount1: u256 = balance1 - self.reserve1 +192 │ let amount1: u256 = balance1 - self.reserve1 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(8) } => Value note: - ┌─ uniswap.fe:168:29 + ┌─ uniswap.fe:192:29 │ -168 │ let amount1: u256 = balance1 - self.reserve1 +192 │ let amount1: u256 = balance1 - self.reserve1 │ ^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -169 │ -170 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) +193 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) │ ^^^^ ^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ │ │ u256: Value @@ -2380,132 +2391,131 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:170:28 + ┌─ uniswap.fe:193:28 │ -170 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) +193 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -171 │ let total_supply: u256 = self.total_supply # gas savings, must be defined here since totalSupply can update in _mintFee +194 │ let total_supply: u256 = self.total_supply # gas savings, must be defined here since totalSupply can update in _mintFee │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:171:34 + ┌─ uniswap.fe:194:34 │ -171 │ let total_supply: u256 = self.total_supply # gas savings, must be defined here since totalSupply can update in _mintFee +194 │ let total_supply: u256 = self.total_supply # gas savings, must be defined here since totalSupply can update in _mintFee │ ^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(2) } => Value -172 │ let liquidity: u256 = 0 +195 │ let liquidity: u256 = 0 │ ^ u256: Value -173 │ if total_supply == 0: +196 │ if total_supply == 0 { │ ^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:173:12 + ┌─ uniswap.fe:196:12 │ -173 │ if total_supply == 0: +196 │ if total_supply == 0 { │ ^^^^^^^^^^^^^^^^^ bool: Value -174 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY +197 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY │ ^^^^^^^^^ ^^^^^^^ ^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:174:30 + ┌─ uniswap.fe:197:30 │ -174 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY +197 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY │ ^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:174:25 + ┌─ uniswap.fe:197:25 │ -174 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY +197 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:174:25 + ┌─ uniswap.fe:197:25 │ -174 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY +197 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -175 │ self._mint(ctx, to: address(0), value: MINIMUM_LIQUIDITY) # permanently lock the first MINIMUM_LIQUIDITY tokens +198 │ self._mint(ctx, to: address(0), value: MINIMUM_LIQUIDITY) # permanently lock the first MINIMUM_LIQUIDITY tokens │ ^^^^ ^^^ ^ u256: Value │ │ │ │ │ Context: Memory │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:175:33 + ┌─ uniswap.fe:198:33 │ -175 │ self._mint(ctx, to: address(0), value: MINIMUM_LIQUIDITY) # permanently lock the first MINIMUM_LIQUIDITY tokens +198 │ self._mint(ctx, to: address(0), value: MINIMUM_LIQUIDITY) # permanently lock the first MINIMUM_LIQUIDITY tokens │ ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ u256: Value │ │ │ address: Value note: - ┌─ uniswap.fe:175:13 + ┌─ uniswap.fe:198:13 │ -175 │ self._mint(ctx, to: address(0), value: MINIMUM_LIQUIDITY) # permanently lock the first MINIMUM_LIQUIDITY tokens +198 │ self._mint(ctx, to: address(0), value: MINIMUM_LIQUIDITY) # permanently lock the first MINIMUM_LIQUIDITY tokens │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -176 │ else: -177 │ liquidity = min((amount0 * total_supply) / reserve0, (amount1 * total_supply) / reserve1) - │ ^^^^^^^^^ ^^^^^^^ ^^^^^^^^^^^^ u256: Value - │ │ │ - │ │ u256: Value +199 │ } else { +200 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) + │ ^^^^^^^^^ ^^^^^^^ ^^^^^^^^^^^^ u256: Value + │ │ │ + │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:177:29 + ┌─ uniswap.fe:200:29 │ -177 │ liquidity = min((amount0 * total_supply) / reserve0, (amount1 * total_supply) / reserve1) - │ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ u256: Value - │ │ +200 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) + │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ u256: Value + │ │ │ u256: Value note: - ┌─ uniswap.fe:177:29 + ┌─ uniswap.fe:200:29 │ -177 │ liquidity = min((amount0 * total_supply) / reserve0, (amount1 * total_supply) / reserve1) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^^^^^^^^ u256: Value - │ │ │ - │ │ u256: Value +200 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^^^^^^^^ u256: Value + │ │ │ + │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:177:66 + ┌─ uniswap.fe:200:64 │ -177 │ liquidity = min((amount0 * total_supply) / reserve0, (amount1 * total_supply) / reserve1) - │ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ u256: Value - │ │ - │ u256: Value +200 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) + │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ u256: Value + │ │ + │ u256: Value note: - ┌─ uniswap.fe:177:66 + ┌─ uniswap.fe:200:64 │ -177 │ liquidity = min((amount0 * total_supply) / reserve0, (amount1 * total_supply) / reserve1) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +200 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:177:25 + ┌─ uniswap.fe:200:25 │ -177 │ liquidity = min((amount0 * total_supply) / reserve0, (amount1 * total_supply) / reserve1) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -178 │ -179 │ assert liquidity > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED" +200 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +201 │ } +202 │ assert liquidity > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED" │ ^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:179:16 + ┌─ uniswap.fe:202:16 │ -179 │ assert liquidity > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED" +202 │ assert liquidity > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED" │ ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<40>: Memory │ │ │ bool: Value -180 │ -181 │ self._mint(ctx, to, value: liquidity) +203 │ self._mint(ctx, to, value: liquidity) │ ^^^^ ^^^ ^^ ^^^^^^^^^ u256: Value │ │ │ │ │ │ │ address: Value @@ -2513,11 +2523,11 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:181:9 + ┌─ uniswap.fe:203:9 │ -181 │ self._mint(ctx, to, value: liquidity) +203 │ self._mint(ctx, to, value: liquidity) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -182 │ self._update(ctx, balance0, balance1, reserve0, reserve1) +204 │ self._update(ctx, balance0, balance1, reserve0, reserve1) │ ^^^^ ^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ │ │ │ │ │ │ u256: Value @@ -2527,51 +2537,50 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:182:9 + ┌─ uniswap.fe:204:9 │ -182 │ self._update(ctx, balance0, balance1, reserve0, reserve1) +204 │ self._update(ctx, balance0, balance1, reserve0, reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -183 │ -184 │ if fee_on: +205 │ if fee_on { │ ^^^^^^ bool: Value -185 │ self.k_last = reserve0 * reserve1 # reserve0 and reserve1 are up-to-date +206 │ self.k_last = reserve0 * reserve1 # reserve0 and reserve1 are up-to-date │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:185:13 + ┌─ uniswap.fe:206:13 │ -185 │ self.k_last = reserve0 * reserve1 # reserve0 and reserve1 are up-to-date +206 │ self.k_last = reserve0 * reserve1 # reserve0 and reserve1 are up-to-date │ ^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Storage { nonce: Some(12) } note: - ┌─ uniswap.fe:185:27 + ┌─ uniswap.fe:206:27 │ -185 │ self.k_last = reserve0 * reserve1 # reserve0 and reserve1 are up-to-date +206 │ self.k_last = reserve0 * reserve1 # reserve0 and reserve1 are up-to-date │ ^^^^^^^^^^^^^^^^^^^ u256: Value -186 │ -187 │ emit Mint(ctx, sender: ctx.msg_sender(), amount0, amount1) +207 │ } +208 │ emit Mint(ctx, sender: ctx.msg_sender(), amount0, amount1) │ ^^^ ^^^ Context: Memory │ │ │ Context: Memory note: - ┌─ uniswap.fe:187:32 + ┌─ uniswap.fe:208:32 │ -187 │ emit Mint(ctx, sender: ctx.msg_sender(), amount0, amount1) +208 │ emit Mint(ctx, sender: ctx.msg_sender(), amount0, amount1) │ ^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ address: Value -188 │ return liquidity +209 │ return liquidity │ ^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:187:9 + ┌─ uniswap.fe:208:9 │ -187 │ emit Mint(ctx, sender: ctx.msg_sender(), amount0, amount1) +208 │ emit Mint(ctx, sender: ctx.msg_sender(), amount0, amount1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 4243961805717991435 │ = Event { @@ -2612,16 +2621,16 @@ note: } note: - ┌─ uniswap.fe:191:5 + ┌─ uniswap.fe:213:5 │ -191 │ ╭ pub fn burn(self, ctx: Context, to: address) -> (u256, u256): -192 │ │ let reserve0: u256 = self.reserve0 -193 │ │ let reserve1: u256 = self.reserve1 -194 │ │ let token0: ERC20 = ERC20(ctx, self.token0) +213 │ ╭ pub fn burn(self, ctx: Context, to: address) -> (u256, u256) { +214 │ │ let reserve0: u256 = self.reserve0 +215 │ │ let reserve1: u256 = self.reserve1 +216 │ │ let token0: ERC20 = ERC20(ctx, self.token0) · │ -216 │ │ emit Burn(ctx, sender: ctx.msg_sender(), amount0, amount1, to) -217 │ │ return (amount0, amount1) - │ ╰─────────────────────────────────^ attributes hash: 4652297158603848356 +237 │ │ return (amount0, amount1) +238 │ │ } + │ ╰─────^ attributes hash: 4652297158603848356 │ = FunctionSignature { self_decl: Some( @@ -2674,139 +2683,139 @@ note: } note: - ┌─ uniswap.fe:192:23 + ┌─ uniswap.fe:214:23 │ -192 │ let reserve0: u256 = self.reserve0 +214 │ let reserve0: u256 = self.reserve0 │ ^^^^ u256 -193 │ let reserve1: u256 = self.reserve1 +215 │ let reserve1: u256 = self.reserve1 │ ^^^^ u256 -194 │ let token0: ERC20 = ERC20(ctx, self.token0) +216 │ let token0: ERC20 = ERC20(ctx, self.token0) │ ^^^^^ ERC20 -195 │ let token1: ERC20 = ERC20(ctx, self.token1) +217 │ let token1: ERC20 = ERC20(ctx, self.token1) │ ^^^^^ ERC20 -196 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +218 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^ u256 -197 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +219 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^ u256 -198 │ let liquidity: u256 = self.balances[ctx.self_address()] +220 │ let liquidity: u256 = self.balances[ctx.self_address()] │ ^^^^ u256 -199 │ -200 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) +221 │ +222 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) │ ^^^^ bool -201 │ let total_supply: u256 = self.total_supply # gas savings, must be defined here since total_supply can update in _mintFee +223 │ let total_supply: u256 = self.total_supply # gas savings, must be defined here since total_supply can update in _mintFee │ ^^^^ u256 -202 │ let amount0: u256 = (liquidity * balance0) / total_supply # using balances ensures pro-rata distribution +224 │ let amount0: u256 = (liquidity * balance0) / total_supply # using balances ensures pro-rata distribution │ ^^^^ u256 -203 │ let amount1: u256 = (liquidity * balance1) / total_supply # using balances ensures pro-rata distribution +225 │ let amount1: u256 = (liquidity * balance1) / total_supply # using balances ensures pro-rata distribution │ ^^^^ u256 note: - ┌─ uniswap.fe:192:30 + ┌─ uniswap.fe:214:30 │ -192 │ let reserve0: u256 = self.reserve0 +214 │ let reserve0: u256 = self.reserve0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:192:30 + ┌─ uniswap.fe:214:30 │ -192 │ let reserve0: u256 = self.reserve0 +214 │ let reserve0: u256 = self.reserve0 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(7) } => Value -193 │ let reserve1: u256 = self.reserve1 +215 │ let reserve1: u256 = self.reserve1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:193:30 + ┌─ uniswap.fe:215:30 │ -193 │ let reserve1: u256 = self.reserve1 +215 │ let reserve1: u256 = self.reserve1 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(8) } => Value -194 │ let token0: ERC20 = ERC20(ctx, self.token0) +216 │ let token0: ERC20 = ERC20(ctx, self.token0) │ ^^^ ^^^^ UniswapV2Pair: Value │ │ │ Context: Memory note: - ┌─ uniswap.fe:194:40 + ┌─ uniswap.fe:216:40 │ -194 │ let token0: ERC20 = ERC20(ctx, self.token0) +216 │ let token0: ERC20 = ERC20(ctx, self.token0) │ ^^^^^^^^^^^ address: Storage { nonce: Some(5) } => Value note: - ┌─ uniswap.fe:194:29 + ┌─ uniswap.fe:216:29 │ -194 │ let token0: ERC20 = ERC20(ctx, self.token0) +216 │ let token0: ERC20 = ERC20(ctx, self.token0) │ ^^^^^^^^^^^^^^^^^^^^^^^ ERC20: Value -195 │ let token1: ERC20 = ERC20(ctx, self.token1) +217 │ let token1: ERC20 = ERC20(ctx, self.token1) │ ^^^ ^^^^ UniswapV2Pair: Value │ │ │ Context: Memory note: - ┌─ uniswap.fe:195:40 + ┌─ uniswap.fe:217:40 │ -195 │ let token1: ERC20 = ERC20(ctx, self.token1) +217 │ let token1: ERC20 = ERC20(ctx, self.token1) │ ^^^^^^^^^^^ address: Storage { nonce: Some(6) } => Value note: - ┌─ uniswap.fe:195:29 + ┌─ uniswap.fe:217:29 │ -195 │ let token1: ERC20 = ERC20(ctx, self.token1) +217 │ let token1: ERC20 = ERC20(ctx, self.token1) │ ^^^^^^^^^^^^^^^^^^^^^^^ ERC20: Value -196 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +218 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Value note: - ┌─ uniswap.fe:196:47 + ┌─ uniswap.fe:218:47 │ -196 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +218 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:196:30 + ┌─ uniswap.fe:218:30 │ -196 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +218 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -197 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +219 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Value note: - ┌─ uniswap.fe:197:47 + ┌─ uniswap.fe:219:47 │ -197 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +219 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:197:30 + ┌─ uniswap.fe:219:30 │ -197 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +219 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -198 │ let liquidity: u256 = self.balances[ctx.self_address()] +220 │ let liquidity: u256 = self.balances[ctx.self_address()] │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:198:31 + ┌─ uniswap.fe:220:31 │ -198 │ let liquidity: u256 = self.balances[ctx.self_address()] +220 │ let liquidity: u256 = self.balances[ctx.self_address()] │ ^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:198:45 + ┌─ uniswap.fe:220:45 │ -198 │ let liquidity: u256 = self.balances[ctx.self_address()] +220 │ let liquidity: u256 = self.balances[ctx.self_address()] │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:198:31 + ┌─ uniswap.fe:220:31 │ -198 │ let liquidity: u256 = self.balances[ctx.self_address()] +220 │ let liquidity: u256 = self.balances[ctx.self_address()] │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: None } => Value -199 │ -200 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) +221 │ +222 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) │ ^^^^ ^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ │ │ u256: Value @@ -2814,158 +2823,157 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:200:28 + ┌─ uniswap.fe:222:28 │ -200 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) +222 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -201 │ let total_supply: u256 = self.total_supply # gas savings, must be defined here since total_supply can update in _mintFee +223 │ let total_supply: u256 = self.total_supply # gas savings, must be defined here since total_supply can update in _mintFee │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:201:34 + ┌─ uniswap.fe:223:34 │ -201 │ let total_supply: u256 = self.total_supply # gas savings, must be defined here since total_supply can update in _mintFee +223 │ let total_supply: u256 = self.total_supply # gas savings, must be defined here since total_supply can update in _mintFee │ ^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(2) } => Value -202 │ let amount0: u256 = (liquidity * balance0) / total_supply # using balances ensures pro-rata distribution +224 │ let amount0: u256 = (liquidity * balance0) / total_supply # using balances ensures pro-rata distribution │ ^^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:202:29 + ┌─ uniswap.fe:224:29 │ -202 │ let amount0: u256 = (liquidity * balance0) / total_supply # using balances ensures pro-rata distribution +224 │ let amount0: u256 = (liquidity * balance0) / total_supply # using balances ensures pro-rata distribution │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:202:29 + ┌─ uniswap.fe:224:29 │ -202 │ let amount0: u256 = (liquidity * balance0) / total_supply # using balances ensures pro-rata distribution +224 │ let amount0: u256 = (liquidity * balance0) / total_supply # using balances ensures pro-rata distribution │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -203 │ let amount1: u256 = (liquidity * balance1) / total_supply # using balances ensures pro-rata distribution +225 │ let amount1: u256 = (liquidity * balance1) / total_supply # using balances ensures pro-rata distribution │ ^^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:203:29 + ┌─ uniswap.fe:225:29 │ -203 │ let amount1: u256 = (liquidity * balance1) / total_supply # using balances ensures pro-rata distribution +225 │ let amount1: u256 = (liquidity * balance1) / total_supply # using balances ensures pro-rata distribution │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:203:29 + ┌─ uniswap.fe:225:29 │ -203 │ let amount1: u256 = (liquidity * balance1) / total_supply # using balances ensures pro-rata distribution +225 │ let amount1: u256 = (liquidity * balance1) / total_supply # using balances ensures pro-rata distribution │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -204 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" +226 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" │ ^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:204:16 + ┌─ uniswap.fe:226:16 │ -204 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" +226 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" │ ^^^^^^^^^^^ ^^^^^^^ ^ u256: Value │ │ │ │ │ u256: Value │ bool: Value note: - ┌─ uniswap.fe:204:32 + ┌─ uniswap.fe:226:32 │ -204 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" +226 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" │ ^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:204:16 + ┌─ uniswap.fe:226:16 │ -204 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" +226 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<40>: Memory │ │ │ bool: Value -205 │ self._burn(ctx, from: ctx.self_address(), value: liquidity) +227 │ self._burn(ctx, from: ctx.self_address(), value: liquidity) │ ^^^^ ^^^ ^^^ Context: Memory │ │ │ │ │ Context: Memory │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:205:31 + ┌─ uniswap.fe:227:31 │ -205 │ self._burn(ctx, from: ctx.self_address(), value: liquidity) +227 │ self._burn(ctx, from: ctx.self_address(), value: liquidity) │ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^ u256: Value │ │ │ address: Value note: - ┌─ uniswap.fe:205:9 + ┌─ uniswap.fe:227:9 │ -205 │ self._burn(ctx, from: ctx.self_address(), value: liquidity) +227 │ self._burn(ctx, from: ctx.self_address(), value: liquidity) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -206 │ token0.transfer(to, amount0) +228 │ token0.transfer(to, amount0) │ ^^^^^^ ^^ ^^^^^^^ u256: Value │ │ │ │ │ address: Value │ ERC20: Value note: - ┌─ uniswap.fe:206:9 + ┌─ uniswap.fe:228:9 │ -206 │ token0.transfer(to, amount0) +228 │ token0.transfer(to, amount0) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -207 │ token1.transfer(to, amount1) +229 │ token1.transfer(to, amount1) │ ^^^^^^ ^^ ^^^^^^^ u256: Value │ │ │ │ │ address: Value │ ERC20: Value note: - ┌─ uniswap.fe:207:9 + ┌─ uniswap.fe:229:9 │ -207 │ token1.transfer(to, amount1) +229 │ token1.transfer(to, amount1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -208 │ balance0 = token0.balanceOf(ctx.self_address()) +230 │ balance0 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^ ^^^^^^ ^^^ Context: Memory │ │ │ │ │ ERC20: Value │ u256: Value note: - ┌─ uniswap.fe:208:37 + ┌─ uniswap.fe:230:37 │ -208 │ balance0 = token0.balanceOf(ctx.self_address()) +230 │ balance0 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:208:20 + ┌─ uniswap.fe:230:20 │ -208 │ balance0 = token0.balanceOf(ctx.self_address()) +230 │ balance0 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -209 │ balance1 = token1.balanceOf(ctx.self_address()) +231 │ balance1 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^ ^^^^^^ ^^^ Context: Memory │ │ │ │ │ ERC20: Value │ u256: Value note: - ┌─ uniswap.fe:209:37 + ┌─ uniswap.fe:231:37 │ -209 │ balance1 = token1.balanceOf(ctx.self_address()) +231 │ balance1 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:209:20 + ┌─ uniswap.fe:231:20 │ -209 │ balance1 = token1.balanceOf(ctx.self_address()) +231 │ balance1 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -210 │ -211 │ self._update(ctx, balance0, balance1, reserve0, reserve1) +232 │ self._update(ctx, balance0, balance1, reserve0, reserve1) │ ^^^^ ^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ │ │ │ │ │ │ u256: Value @@ -2975,60 +2983,59 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:211:9 + ┌─ uniswap.fe:232:9 │ -211 │ self._update(ctx, balance0, balance1, reserve0, reserve1) +232 │ self._update(ctx, balance0, balance1, reserve0, reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -212 │ -213 │ if fee_on: +233 │ if fee_on { │ ^^^^^^ bool: Value -214 │ self.k_last = reserve0 * reserve1 # reserve0 and reserve1 are up-to-date +234 │ self.k_last = reserve0 * reserve1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:214:13 + ┌─ uniswap.fe:234:13 │ -214 │ self.k_last = reserve0 * reserve1 # reserve0 and reserve1 are up-to-date +234 │ self.k_last = reserve0 * reserve1 │ ^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Storage { nonce: Some(12) } note: - ┌─ uniswap.fe:214:27 + ┌─ uniswap.fe:234:27 │ -214 │ self.k_last = reserve0 * reserve1 # reserve0 and reserve1 are up-to-date +234 │ self.k_last = reserve0 * reserve1 │ ^^^^^^^^^^^^^^^^^^^ u256: Value -215 │ -216 │ emit Burn(ctx, sender: ctx.msg_sender(), amount0, amount1, to) +235 │ } +236 │ emit Burn(ctx, sender: ctx.msg_sender(), amount0, amount1, to) │ ^^^ ^^^ Context: Memory │ │ │ Context: Memory note: - ┌─ uniswap.fe:216:32 + ┌─ uniswap.fe:236:32 │ -216 │ emit Burn(ctx, sender: ctx.msg_sender(), amount0, amount1, to) +236 │ emit Burn(ctx, sender: ctx.msg_sender(), amount0, amount1, to) │ ^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^^^ ^^ address: Value │ │ │ │ │ │ │ u256: Value │ │ u256: Value │ address: Value -217 │ return (amount0, amount1) +237 │ return (amount0, amount1) │ ^^^^^^^ ^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:217:16 + ┌─ uniswap.fe:237:16 │ -217 │ return (amount0, amount1) +237 │ return (amount0, amount1) │ ^^^^^^^^^^^^^^^^^^ (u256, u256): Memory note: - ┌─ uniswap.fe:216:9 + ┌─ uniswap.fe:236:9 │ -216 │ emit Burn(ctx, sender: ctx.msg_sender(), amount0, amount1, to) +236 │ emit Burn(ctx, sender: ctx.msg_sender(), amount0, amount1, to) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 10738919684795162003 │ = Event { @@ -3078,16 +3085,16 @@ note: } note: - ┌─ uniswap.fe:222:5 + ┌─ uniswap.fe:243:5 │ -222 │ ╭ pub fn swap(self, ctx: Context, amount0_out: u256, amount1_out: u256, to: address): -223 │ │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" -224 │ │ let reserve0: u256 = self.reserve0 -225 │ │ let reserve1: u256 = self.reserve1 +243 │ ╭ pub fn swap(self, ctx: Context, amount0_out: u256, amount1_out: u256, to: address) { +244 │ │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" +245 │ │ let reserve0: u256 = self.reserve0 +246 │ │ let reserve1: u256 = self.reserve1 · │ -255 │ │ self._update(ctx, balance0, balance1, reserve0, reserve1) -256 │ │ emit Swap(ctx, sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to) - │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────^ attributes hash: 18411078236281700131 +279 │ │ emit Swap(ctx, sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to) +280 │ │ } + │ ╰─────^ attributes hash: 18411078236281700131 │ = FunctionSignature { self_decl: Some( @@ -3149,467 +3156,468 @@ note: } note: - ┌─ uniswap.fe:224:23 + ┌─ uniswap.fe:245:23 │ -224 │ let reserve0: u256 = self.reserve0 +245 │ let reserve0: u256 = self.reserve0 │ ^^^^ u256 -225 │ let reserve1: u256 = self.reserve1 +246 │ let reserve1: u256 = self.reserve1 │ ^^^^ u256 · -228 │ let token0: ERC20 = ERC20(ctx, self.token0) +249 │ let token0: ERC20 = ERC20(ctx, self.token0) │ ^^^^^ ERC20 -229 │ let token1: ERC20 = ERC20(ctx, self.token1) +250 │ let token1: ERC20 = ERC20(ctx, self.token1) │ ^^^^^ ERC20 · -242 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +265 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^ u256 -243 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +266 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^ u256 -244 │ -245 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +267 │ +268 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^ u256 -246 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +269 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^ u256 · -250 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 +273 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 │ ^^^^ u256 -251 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 +274 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 │ ^^^^ u256 note: - ┌─ uniswap.fe:223:16 + ┌─ uniswap.fe:244:16 │ -223 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" +244 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:223:16 + ┌─ uniswap.fe:244:16 │ -223 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" +244 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" │ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^ u256: Value │ │ │ │ │ u256: Value │ bool: Value note: - ┌─ uniswap.fe:223:35 + ┌─ uniswap.fe:244:35 │ -223 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" +244 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" │ ^^^^^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:223:16 + ┌─ uniswap.fe:244:16 │ -223 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" +244 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<37>: Memory │ │ │ bool: Value -224 │ let reserve0: u256 = self.reserve0 +245 │ let reserve0: u256 = self.reserve0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:224:30 + ┌─ uniswap.fe:245:30 │ -224 │ let reserve0: u256 = self.reserve0 +245 │ let reserve0: u256 = self.reserve0 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(7) } => Value -225 │ let reserve1: u256 = self.reserve1 +246 │ let reserve1: u256 = self.reserve1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:225:30 + ┌─ uniswap.fe:246:30 │ -225 │ let reserve1: u256 = self.reserve1 +246 │ let reserve1: u256 = self.reserve1 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(8) } => Value -226 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" +247 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" │ ^^^^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:226:16 + ┌─ uniswap.fe:247:16 │ -226 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" +247 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ bool: Value note: - ┌─ uniswap.fe:226:43 + ┌─ uniswap.fe:247:43 │ -226 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" +247 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" │ ^^^^^^^^^^^^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:226:16 + ┌─ uniswap.fe:247:16 │ -226 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" +247 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<33>: Memory │ │ │ bool: Value -227 │ -228 │ let token0: ERC20 = ERC20(ctx, self.token0) +248 │ +249 │ let token0: ERC20 = ERC20(ctx, self.token0) │ ^^^ ^^^^ UniswapV2Pair: Value │ │ │ Context: Memory note: - ┌─ uniswap.fe:228:40 + ┌─ uniswap.fe:249:40 │ -228 │ let token0: ERC20 = ERC20(ctx, self.token0) +249 │ let token0: ERC20 = ERC20(ctx, self.token0) │ ^^^^^^^^^^^ address: Storage { nonce: Some(5) } => Value note: - ┌─ uniswap.fe:228:29 + ┌─ uniswap.fe:249:29 │ -228 │ let token0: ERC20 = ERC20(ctx, self.token0) +249 │ let token0: ERC20 = ERC20(ctx, self.token0) │ ^^^^^^^^^^^^^^^^^^^^^^^ ERC20: Value -229 │ let token1: ERC20 = ERC20(ctx, self.token1) +250 │ let token1: ERC20 = ERC20(ctx, self.token1) │ ^^^ ^^^^ UniswapV2Pair: Value │ │ │ Context: Memory note: - ┌─ uniswap.fe:229:40 + ┌─ uniswap.fe:250:40 │ -229 │ let token1: ERC20 = ERC20(ctx, self.token1) +250 │ let token1: ERC20 = ERC20(ctx, self.token1) │ ^^^^^^^^^^^ address: Storage { nonce: Some(6) } => Value note: - ┌─ uniswap.fe:229:29 + ┌─ uniswap.fe:250:29 │ -229 │ let token1: ERC20 = ERC20(ctx, self.token1) +250 │ let token1: ERC20 = ERC20(ctx, self.token1) │ ^^^^^^^^^^^^^^^^^^^^^^^ ERC20: Value · -232 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" +253 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" │ ^^ ^^^^^^ ERC20: Value │ │ │ address: Value note: - ┌─ uniswap.fe:232:22 + ┌─ uniswap.fe:253:22 │ -232 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" +253 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" │ ^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:232:16 + ┌─ uniswap.fe:253:16 │ -232 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" +253 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" │ ^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^ ERC20: Value │ │ │ │ │ address: Value │ bool: Value note: - ┌─ uniswap.fe:232:48 + ┌─ uniswap.fe:253:48 │ -232 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" +253 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" │ ^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:232:42 + ┌─ uniswap.fe:253:42 │ -232 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" +253 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:232:16 + ┌─ uniswap.fe:253:16 │ -232 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" +253 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ String<21>: Memory │ │ │ bool: Value -233 │ -234 │ if amount0_out > 0: +254 │ +255 │ if amount0_out > 0 { │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:234:12 + ┌─ uniswap.fe:255:12 │ -234 │ if amount0_out > 0: +255 │ if amount0_out > 0 { │ ^^^^^^^^^^^^^^^ bool: Value -235 │ token0.transfer(to, amount0_out) # optimistically transfer tokens +256 │ token0.transfer(to, amount0_out) # optimistically transfer tokens │ ^^^^^^ ^^ ^^^^^^^^^^^ u256: Value │ │ │ │ │ address: Value │ ERC20: Value note: - ┌─ uniswap.fe:235:13 + ┌─ uniswap.fe:256:13 │ -235 │ token0.transfer(to, amount0_out) # optimistically transfer tokens +256 │ token0.transfer(to, amount0_out) # optimistically transfer tokens │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -236 │ if amount1_out > 0: +257 │ } +258 │ if amount1_out > 0 { │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:236:12 + ┌─ uniswap.fe:258:12 │ -236 │ if amount1_out > 0: +258 │ if amount1_out > 0 { │ ^^^^^^^^^^^^^^^ bool: Value -237 │ token1.transfer(to, amount1_out) # optimistically transfer tokens +259 │ token1.transfer(to, amount1_out) # optimistically transfer tokens │ ^^^^^^ ^^ ^^^^^^^^^^^ u256: Value │ │ │ │ │ address: Value │ ERC20: Value note: - ┌─ uniswap.fe:237:13 + ┌─ uniswap.fe:259:13 │ -237 │ token1.transfer(to, amount1_out) # optimistically transfer tokens +259 │ token1.transfer(to, amount1_out) # optimistically transfer tokens │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value · -242 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +265 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Value note: - ┌─ uniswap.fe:242:47 + ┌─ uniswap.fe:265:47 │ -242 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +265 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:242:30 + ┌─ uniswap.fe:265:30 │ -242 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +265 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -243 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +266 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Value note: - ┌─ uniswap.fe:243:47 + ┌─ uniswap.fe:266:47 │ -243 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +266 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:243:30 + ┌─ uniswap.fe:266:30 │ -243 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +266 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -244 │ -245 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +267 │ +268 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:245:82 + ┌─ uniswap.fe:268:82 │ -245 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +268 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:245:32 + ┌─ uniswap.fe:268:32 │ -245 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +268 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:245:44 + ┌─ uniswap.fe:268:44 │ -245 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +268 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:245:43 + ┌─ uniswap.fe:268:43 │ -245 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +268 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:245:32 + ┌─ uniswap.fe:268:32 │ -245 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +268 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:245:32 + ┌─ uniswap.fe:268:32 │ -245 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +268 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -246 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +269 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:246:82 + ┌─ uniswap.fe:269:82 │ -246 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +269 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:246:32 + ┌─ uniswap.fe:269:32 │ -246 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +269 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:246:44 + ┌─ uniswap.fe:269:44 │ -246 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +269 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:246:43 + ┌─ uniswap.fe:269:43 │ -246 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +269 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:246:32 + ┌─ uniswap.fe:269:32 │ -246 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +269 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:246:32 + ┌─ uniswap.fe:269:32 │ -246 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +269 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -247 │ -248 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" +270 │ +271 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" │ ^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:248:16 + ┌─ uniswap.fe:271:16 │ -248 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" +271 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" │ ^^^^^^^^^^^^^^ ^^^^^^^^^^ ^ u256: Value │ │ │ │ │ u256: Value │ bool: Value note: - ┌─ uniswap.fe:248:34 + ┌─ uniswap.fe:271:34 │ -248 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" +271 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" │ ^^^^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:248:16 + ┌─ uniswap.fe:271:16 │ -248 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" +271 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<36>: Memory │ │ │ bool: Value -249 │ -250 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 +272 │ +273 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 │ ^^^^^^^^ ^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:250:39 + ┌─ uniswap.fe:273:39 │ -250 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 +273 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 │ ^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:250:57 + ┌─ uniswap.fe:273:57 │ -250 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 +273 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 │ ^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:250:39 + ┌─ uniswap.fe:273:39 │ -250 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 +273 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -251 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 +274 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 │ ^^^^^^^^ ^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:251:39 + ┌─ uniswap.fe:274:39 │ -251 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 +274 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 │ ^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:251:57 + ┌─ uniswap.fe:274:57 │ -251 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 +274 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 │ ^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:251:39 + ┌─ uniswap.fe:274:39 │ -251 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 +274 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -252 │ -253 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" +275 │ +276 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" │ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:253:16 + ┌─ uniswap.fe:276:16 │ -253 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" +276 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:253:57 + ┌─ uniswap.fe:276:57 │ -253 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" +276 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" │ ^^^^^^^^^^^^^^^^^^^ ^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:253:57 + ┌─ uniswap.fe:276:57 │ -253 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" +276 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:253:16 + ┌─ uniswap.fe:276:16 │ -253 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" +276 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ String<12>: Memory │ │ │ bool: Value -254 │ -255 │ self._update(ctx, balance0, balance1, reserve0, reserve1) +277 │ +278 │ self._update(ctx, balance0, balance1, reserve0, reserve1) │ ^^^^ ^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ │ │ │ │ │ │ u256: Value @@ -3619,19 +3627,19 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:255:9 + ┌─ uniswap.fe:278:9 │ -255 │ self._update(ctx, balance0, balance1, reserve0, reserve1) +278 │ self._update(ctx, balance0, balance1, reserve0, reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -256 │ emit Swap(ctx, sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to) +279 │ emit Swap(ctx, sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to) │ ^^^ ^^^ Context: Memory │ │ │ Context: Memory note: - ┌─ uniswap.fe:256:32 + ┌─ uniswap.fe:279:32 │ -256 │ emit Swap(ctx, sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to) +279 │ emit Swap(ctx, sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to) │ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ address: Value │ │ │ │ │ │ │ │ │ │ │ u256: Value @@ -3641,9 +3649,9 @@ note: │ address: Value note: - ┌─ uniswap.fe:256:9 + ┌─ uniswap.fe:279:9 │ -256 │ emit Swap(ctx, sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to) +279 │ emit Swap(ctx, sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 16055667627771619025 │ = Event { @@ -3715,15 +3723,15 @@ note: } note: - ┌─ uniswap.fe:259:5 + ┌─ uniswap.fe:283:5 │ -259 │ ╭ pub fn skim(self, ctx: Context, to: address): -260 │ │ let token0: ERC20 = ERC20(ctx, self.token0) # gas savings -261 │ │ let token1: ERC20 = ERC20(ctx, self.token1) # gas savings -262 │ │ -263 │ │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) -264 │ │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) - │ ╰─────────────────────────────────────────────────────────────────────────────────^ attributes hash: 9469713119497359790 +283 │ ╭ pub fn skim(self, ctx: Context, to: address) { +284 │ │ let token0: ERC20 = ERC20(ctx, self.token0) # gas savings +285 │ │ let token1: ERC20 = ERC20(ctx, self.token1) # gas savings +286 │ │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) +287 │ │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) +288 │ │ } + │ ╰─────^ attributes hash: 9469713119497359790 │ = FunctionSignature { self_decl: Some( @@ -3763,50 +3771,49 @@ note: } note: - ┌─ uniswap.fe:260:21 + ┌─ uniswap.fe:284:21 │ -260 │ let token0: ERC20 = ERC20(ctx, self.token0) # gas savings +284 │ let token0: ERC20 = ERC20(ctx, self.token0) # gas savings │ ^^^^^ ERC20 -261 │ let token1: ERC20 = ERC20(ctx, self.token1) # gas savings +285 │ let token1: ERC20 = ERC20(ctx, self.token1) # gas savings │ ^^^^^ ERC20 note: - ┌─ uniswap.fe:260:35 + ┌─ uniswap.fe:284:35 │ -260 │ let token0: ERC20 = ERC20(ctx, self.token0) # gas savings +284 │ let token0: ERC20 = ERC20(ctx, self.token0) # gas savings │ ^^^ ^^^^ UniswapV2Pair: Value │ │ │ Context: Memory note: - ┌─ uniswap.fe:260:40 + ┌─ uniswap.fe:284:40 │ -260 │ let token0: ERC20 = ERC20(ctx, self.token0) # gas savings +284 │ let token0: ERC20 = ERC20(ctx, self.token0) # gas savings │ ^^^^^^^^^^^ address: Storage { nonce: Some(5) } => Value note: - ┌─ uniswap.fe:260:29 + ┌─ uniswap.fe:284:29 │ -260 │ let token0: ERC20 = ERC20(ctx, self.token0) # gas savings +284 │ let token0: ERC20 = ERC20(ctx, self.token0) # gas savings │ ^^^^^^^^^^^^^^^^^^^^^^^ ERC20: Value -261 │ let token1: ERC20 = ERC20(ctx, self.token1) # gas savings +285 │ let token1: ERC20 = ERC20(ctx, self.token1) # gas savings │ ^^^ ^^^^ UniswapV2Pair: Value │ │ │ Context: Memory note: - ┌─ uniswap.fe:261:40 + ┌─ uniswap.fe:285:40 │ -261 │ let token1: ERC20 = ERC20(ctx, self.token1) # gas savings +285 │ let token1: ERC20 = ERC20(ctx, self.token1) # gas savings │ ^^^^^^^^^^^ address: Storage { nonce: Some(6) } => Value note: - ┌─ uniswap.fe:261:29 + ┌─ uniswap.fe:285:29 │ -261 │ let token1: ERC20 = ERC20(ctx, self.token1) # gas savings +285 │ let token1: ERC20 = ERC20(ctx, self.token1) # gas savings │ ^^^^^^^^^^^^^^^^^^^^^^^ ERC20: Value -262 │ -263 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) +286 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) │ ^^^^^^ ^^ ^^^^^^ ^^^ Context: Memory │ │ │ │ │ │ │ ERC20: Value @@ -3814,37 +3821,37 @@ note: │ ERC20: Value note: - ┌─ uniswap.fe:263:46 + ┌─ uniswap.fe:286:46 │ -263 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) +286 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:263:29 + ┌─ uniswap.fe:286:29 │ -263 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) +286 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:263:68 + ┌─ uniswap.fe:286:68 │ -263 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) +286 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(7) } => Value note: - ┌─ uniswap.fe:263:29 + ┌─ uniswap.fe:286:29 │ -263 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) +286 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:263:9 + ┌─ uniswap.fe:286:9 │ -263 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) +286 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -264 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) +287 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) │ ^^^^^^ ^^ ^^^^^^ ^^^ Context: Memory │ │ │ │ │ │ │ ERC20: Value @@ -3852,48 +3859,48 @@ note: │ ERC20: Value note: - ┌─ uniswap.fe:264:46 + ┌─ uniswap.fe:287:46 │ -264 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) +287 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:264:29 + ┌─ uniswap.fe:287:29 │ -264 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) +287 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:264:68 + ┌─ uniswap.fe:287:68 │ -264 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) +287 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(8) } => Value note: - ┌─ uniswap.fe:264:29 + ┌─ uniswap.fe:287:29 │ -264 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) +287 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:264:9 + ┌─ uniswap.fe:287:9 │ -264 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) +287 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:267:5 + ┌─ uniswap.fe:291:5 │ -267 │ ╭ pub fn sync(self, ctx: Context): -268 │ │ let token0: ERC20 = ERC20(ctx, self.token0) -269 │ │ let token1: ERC20 = ERC20(ctx, self.token1) -270 │ │ self._update(ctx, +291 │ ╭ pub fn sync(self, ctx: Context) { +292 │ │ let token0: ERC20 = ERC20(ctx, self.token0) +293 │ │ let token1: ERC20 = ERC20(ctx, self.token1) +294 │ │ self._update(ctx, · │ -273 │ │ reserve0: self.reserve0, -274 │ │ reserve1: self.reserve1) - │ ╰─────────────────────────────────────────────^ attributes hash: 1731341862738941170 +298 │ │ reserve1: self.reserve1) +299 │ │ } + │ ╰─────^ attributes hash: 1731341862738941170 │ = FunctionSignature { self_decl: Some( @@ -3924,145 +3931,146 @@ note: } note: - ┌─ uniswap.fe:268:21 + ┌─ uniswap.fe:292:21 │ -268 │ let token0: ERC20 = ERC20(ctx, self.token0) +292 │ let token0: ERC20 = ERC20(ctx, self.token0) │ ^^^^^ ERC20 -269 │ let token1: ERC20 = ERC20(ctx, self.token1) +293 │ let token1: ERC20 = ERC20(ctx, self.token1) │ ^^^^^ ERC20 note: - ┌─ uniswap.fe:268:35 + ┌─ uniswap.fe:292:35 │ -268 │ let token0: ERC20 = ERC20(ctx, self.token0) +292 │ let token0: ERC20 = ERC20(ctx, self.token0) │ ^^^ ^^^^ UniswapV2Pair: Value │ │ │ Context: Memory note: - ┌─ uniswap.fe:268:40 + ┌─ uniswap.fe:292:40 │ -268 │ let token0: ERC20 = ERC20(ctx, self.token0) +292 │ let token0: ERC20 = ERC20(ctx, self.token0) │ ^^^^^^^^^^^ address: Storage { nonce: Some(5) } => Value note: - ┌─ uniswap.fe:268:29 + ┌─ uniswap.fe:292:29 │ -268 │ let token0: ERC20 = ERC20(ctx, self.token0) +292 │ let token0: ERC20 = ERC20(ctx, self.token0) │ ^^^^^^^^^^^^^^^^^^^^^^^ ERC20: Value -269 │ let token1: ERC20 = ERC20(ctx, self.token1) +293 │ let token1: ERC20 = ERC20(ctx, self.token1) │ ^^^ ^^^^ UniswapV2Pair: Value │ │ │ Context: Memory note: - ┌─ uniswap.fe:269:40 + ┌─ uniswap.fe:293:40 │ -269 │ let token1: ERC20 = ERC20(ctx, self.token1) +293 │ let token1: ERC20 = ERC20(ctx, self.token1) │ ^^^^^^^^^^^ address: Storage { nonce: Some(6) } => Value note: - ┌─ uniswap.fe:269:29 + ┌─ uniswap.fe:293:29 │ -269 │ let token1: ERC20 = ERC20(ctx, self.token1) +293 │ let token1: ERC20 = ERC20(ctx, self.token1) │ ^^^^^^^^^^^^^^^^^^^^^^^ ERC20: Value -270 │ self._update(ctx, +294 │ self._update(ctx, │ ^^^^ ^^^ Context: Memory │ │ │ UniswapV2Pair: Value -271 │ balance0: token0.balanceOf(ctx.self_address()), +295 │ balance0: token0.balanceOf(ctx.self_address()), │ ^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Value note: - ┌─ uniswap.fe:271:49 + ┌─ uniswap.fe:295:49 │ -271 │ balance0: token0.balanceOf(ctx.self_address()), +295 │ balance0: token0.balanceOf(ctx.self_address()), │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:271:32 + ┌─ uniswap.fe:295:32 │ -271 │ balance0: token0.balanceOf(ctx.self_address()), +295 │ balance0: token0.balanceOf(ctx.self_address()), │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -272 │ balance1: token1.balanceOf(ctx.self_address()), +296 │ balance1: token1.balanceOf(ctx.self_address()), │ ^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Value note: - ┌─ uniswap.fe:272:49 + ┌─ uniswap.fe:296:49 │ -272 │ balance1: token1.balanceOf(ctx.self_address()), +296 │ balance1: token1.balanceOf(ctx.self_address()), │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:272:32 + ┌─ uniswap.fe:296:32 │ -272 │ balance1: token1.balanceOf(ctx.self_address()), +296 │ balance1: token1.balanceOf(ctx.self_address()), │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -273 │ reserve0: self.reserve0, +297 │ reserve0: self.reserve0, │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:273:32 + ┌─ uniswap.fe:297:32 │ -273 │ reserve0: self.reserve0, +297 │ reserve0: self.reserve0, │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(7) } => Value -274 │ reserve1: self.reserve1) +298 │ reserve1: self.reserve1) │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:274:32 + ┌─ uniswap.fe:298:32 │ -274 │ reserve1: self.reserve1) +298 │ reserve1: self.reserve1) │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(8) } => Value note: - ┌─ uniswap.fe:270:9 + ┌─ uniswap.fe:294:9 │ -270 │ ╭ self._update(ctx, -271 │ │ balance0: token0.balanceOf(ctx.self_address()), -272 │ │ balance1: token1.balanceOf(ctx.self_address()), -273 │ │ reserve0: self.reserve0, -274 │ │ reserve1: self.reserve1) +294 │ ╭ self._update(ctx, +295 │ │ balance0: token0.balanceOf(ctx.self_address()), +296 │ │ balance1: token1.balanceOf(ctx.self_address()), +297 │ │ reserve0: self.reserve0, +298 │ │ reserve1: self.reserve1) │ ╰─────────────────────────────────────────────^ (): Value note: - ┌─ uniswap.fe:277:5 + ┌─ uniswap.fe:303:5 │ -277 │ fee_to: address +303 │ fee_to: address │ ^^^^^^^^^^^^^^^ address -278 │ fee_to_setter: address +304 │ fee_to_setter: address │ ^^^^^^^^^^^^^^^^^^^^^^ address -279 │ -280 │ pairs: Map> +305 │ +306 │ pairs: Map> │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map> -281 │ -282 │ all_pairs: Array +307 │ +308 │ all_pairs: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array -283 │ pair_counter: u256 +309 │ pair_counter: u256 │ ^^^^^^^^^^^^^^^^^^ u256 note: - ┌─ uniswap.fe:286:9 + ┌─ uniswap.fe:312:9 │ -286 │ idx token0: address +312 │ idx token0: address │ ^^^^^^^^^^^^^^^^^^^ address -287 │ idx token1: address +313 │ idx token1: address │ ^^^^^^^^^^^^^^^^^^^ address -288 │ pair: address +314 │ pair: address │ ^^^^^^^^^^^^^ address -289 │ index: u256 +315 │ index: u256 │ ^^^^^^^^^^^ u256 note: - ┌─ uniswap.fe:294:5 + ┌─ uniswap.fe:322:5 │ -294 │ ╭ pub fn fee_to(self) -> address: -295 │ │ return self.fee_to - │ ╰──────────────────────────^ attributes hash: 227275695522088782 +322 │ ╭ pub fn fee_to(self) -> address { +323 │ │ return self.fee_to +324 │ │ } + │ ╰─────^ attributes hash: 227275695522088782 │ = FunctionSignature { self_decl: Some( @@ -4078,23 +4086,24 @@ note: } note: - ┌─ uniswap.fe:295:16 + ┌─ uniswap.fe:323:16 │ -295 │ return self.fee_to +323 │ return self.fee_to │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:295:16 + ┌─ uniswap.fe:323:16 │ -295 │ return self.fee_to +323 │ return self.fee_to │ ^^^^^^^^^^^ address: Storage { nonce: Some(0) } => Value note: - ┌─ uniswap.fe:297:5 + ┌─ uniswap.fe:326:5 │ -297 │ ╭ pub fn fee_to_setter(self) -> address: -298 │ │ return self.fee_to_setter - │ ╰─────────────────────────────────^ attributes hash: 227275695522088782 +326 │ ╭ pub fn fee_to_setter(self) -> address { +327 │ │ return self.fee_to_setter +328 │ │ } + │ ╰─────^ attributes hash: 227275695522088782 │ = FunctionSignature { self_decl: Some( @@ -4110,23 +4119,24 @@ note: } note: - ┌─ uniswap.fe:298:16 + ┌─ uniswap.fe:327:16 │ -298 │ return self.fee_to_setter +327 │ return self.fee_to_setter │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:298:16 + ┌─ uniswap.fe:327:16 │ -298 │ return self.fee_to_setter +327 │ return self.fee_to_setter │ ^^^^^^^^^^^^^^^^^^ address: Storage { nonce: Some(1) } => Value note: - ┌─ uniswap.fe:300:5 + ┌─ uniswap.fe:330:5 │ -300 │ ╭ pub fn all_pairs_length(self) -> u256: -301 │ │ return self.pair_counter - │ ╰────────────────────────────────^ attributes hash: 11773348765973600208 +330 │ ╭ pub fn all_pairs_length(self) -> u256 { +331 │ │ return self.pair_counter +332 │ │ } + │ ╰─────^ attributes hash: 11773348765973600208 │ = FunctionSignature { self_decl: Some( @@ -4144,28 +4154,28 @@ note: } note: - ┌─ uniswap.fe:301:16 + ┌─ uniswap.fe:331:16 │ -301 │ return self.pair_counter +331 │ return self.pair_counter │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:301:16 + ┌─ uniswap.fe:331:16 │ -301 │ return self.pair_counter +331 │ return self.pair_counter │ ^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(4) } => Value note: - ┌─ uniswap.fe:303:5 + ┌─ uniswap.fe:334:5 │ -303 │ ╭ pub fn create_pair(self, ctx: Context, _ token_a: address, _ token_b: address) -> address: -304 │ │ assert token_a != token_b, "UniswapV2: IDENTICAL_ADDRESSES" -305 │ │ -306 │ │ let token0: address = token_a if token_a < token_b else token_b +334 │ ╭ pub fn create_pair(self, ctx: Context, _ token_a: address, _ token_b: address) -> address { +335 │ │ assert token_a != token_b, "UniswapV2: IDENTICAL_ADDRESSES" +336 │ │ +337 │ │ let token0: address = token_a if token_a < token_b else token_b · │ -320 │ │ emit PairCreated(ctx, token0, token1, pair: address(pair), index: self.pair_counter) -321 │ │ return address(pair) - │ ╰────────────────────────────^ attributes hash: 8455575078477255668 +352 │ │ return address(pair) +353 │ │ } + │ ╰─────^ attributes hash: 8455575078477255668 │ = FunctionSignature { self_decl: Some( @@ -4218,296 +4228,296 @@ note: } note: - ┌─ uniswap.fe:306:21 + ┌─ uniswap.fe:337:21 │ -306 │ let token0: address = token_a if token_a < token_b else token_b +337 │ let token0: address = token_a if token_a < token_b else token_b │ ^^^^^^^ address -307 │ let token1: address = token_a if token_a > token_b else token_b +338 │ let token1: address = token_a if token_a > token_b else token_b │ ^^^^^^^ address · -311 │ let salt: u256 = keccak256((token0, token1).abi_encode()) +342 │ let salt: u256 = keccak256((token0, token1).abi_encode()) │ ^^^^ u256 -312 │ let pair: UniswapV2Pair = UniswapV2Pair.create2(ctx, 0, salt) +343 │ let pair: UniswapV2Pair = UniswapV2Pair.create2(ctx, 0, salt) │ ^^^^^^^^^^^^^ UniswapV2Pair note: - ┌─ uniswap.fe:304:16 + ┌─ uniswap.fe:335:16 │ -304 │ assert token_a != token_b, "UniswapV2: IDENTICAL_ADDRESSES" +335 │ assert token_a != token_b, "UniswapV2: IDENTICAL_ADDRESSES" │ ^^^^^^^ ^^^^^^^ address: Value │ │ │ address: Value note: - ┌─ uniswap.fe:304:16 + ┌─ uniswap.fe:335:16 │ -304 │ assert token_a != token_b, "UniswapV2: IDENTICAL_ADDRESSES" +335 │ assert token_a != token_b, "UniswapV2: IDENTICAL_ADDRESSES" │ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<30>: Memory │ │ │ bool: Value -305 │ -306 │ let token0: address = token_a if token_a < token_b else token_b +336 │ +337 │ let token0: address = token_a if token_a < token_b else token_b │ ^^^^^^^ ^^^^^^^ address: Value │ │ │ address: Value note: - ┌─ uniswap.fe:306:31 + ┌─ uniswap.fe:337:31 │ -306 │ let token0: address = token_a if token_a < token_b else token_b +337 │ let token0: address = token_a if token_a < token_b else token_b │ ^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ │ │ bool: Value │ address: Value note: - ┌─ uniswap.fe:306:31 + ┌─ uniswap.fe:337:31 │ -306 │ let token0: address = token_a if token_a < token_b else token_b +337 │ let token0: address = token_a if token_a < token_b else token_b │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ address: Value -307 │ let token1: address = token_a if token_a > token_b else token_b +338 │ let token1: address = token_a if token_a > token_b else token_b │ ^^^^^^^ ^^^^^^^ address: Value │ │ │ address: Value note: - ┌─ uniswap.fe:307:31 + ┌─ uniswap.fe:338:31 │ -307 │ let token1: address = token_a if token_a > token_b else token_b +338 │ let token1: address = token_a if token_a > token_b else token_b │ ^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ │ │ bool: Value │ address: Value note: - ┌─ uniswap.fe:307:31 + ┌─ uniswap.fe:338:31 │ -307 │ let token1: address = token_a if token_a > token_b else token_b +338 │ let token1: address = token_a if token_a > token_b else token_b │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ address: Value -308 │ assert token0 != address(0), "UniswapV2: ZERO_ADDRESS" +339 │ assert token0 != address(0), "UniswapV2: ZERO_ADDRESS" │ ^^^^^^ ^ u256: Value │ │ │ address: Value note: - ┌─ uniswap.fe:308:26 + ┌─ uniswap.fe:339:26 │ -308 │ assert token0 != address(0), "UniswapV2: ZERO_ADDRESS" +339 │ assert token0 != address(0), "UniswapV2: ZERO_ADDRESS" │ ^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:308:16 + ┌─ uniswap.fe:339:16 │ -308 │ assert token0 != address(0), "UniswapV2: ZERO_ADDRESS" +339 │ assert token0 != address(0), "UniswapV2: ZERO_ADDRESS" │ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ String<23>: Memory │ │ │ bool: Value -309 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" +340 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:309:16 + ┌─ uniswap.fe:340:16 │ -309 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" +340 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" │ ^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(2) } note: - ┌─ uniswap.fe:309:16 + ┌─ uniswap.fe:340:16 │ -309 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" +340 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" │ ^^^^^^^^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ uniswap.fe:309:16 + ┌─ uniswap.fe:340:16 │ -309 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" +340 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ address: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:309:46 + ┌─ uniswap.fe:340:46 │ -309 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" +340 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" │ ^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:309:16 + ┌─ uniswap.fe:340:16 │ -309 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" +340 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ String<22>: Memory │ │ │ bool: Value -310 │ -311 │ let salt: u256 = keccak256((token0, token1).abi_encode()) +341 │ +342 │ let salt: u256 = keccak256((token0, token1).abi_encode()) │ ^^^^^^ ^^^^^^ address: Value │ │ │ address: Value note: - ┌─ uniswap.fe:311:36 + ┌─ uniswap.fe:342:36 │ -311 │ let salt: u256 = keccak256((token0, token1).abi_encode()) +342 │ let salt: u256 = keccak256((token0, token1).abi_encode()) │ ^^^^^^^^^^^^^^^^ (address, address): Memory note: - ┌─ uniswap.fe:311:36 + ┌─ uniswap.fe:342:36 │ -311 │ let salt: u256 = keccak256((token0, token1).abi_encode()) +342 │ let salt: u256 = keccak256((token0, token1).abi_encode()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array: Memory note: - ┌─ uniswap.fe:311:26 + ┌─ uniswap.fe:342:26 │ -311 │ let salt: u256 = keccak256((token0, token1).abi_encode()) +342 │ let salt: u256 = keccak256((token0, token1).abi_encode()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -312 │ let pair: UniswapV2Pair = UniswapV2Pair.create2(ctx, 0, salt) +343 │ let pair: UniswapV2Pair = UniswapV2Pair.create2(ctx, 0, salt) │ ^^^ ^ ^^^^ u256: Value │ │ │ │ │ u256: Value │ Context: Memory note: - ┌─ uniswap.fe:312:35 + ┌─ uniswap.fe:343:35 │ -312 │ let pair: UniswapV2Pair = UniswapV2Pair.create2(ctx, 0, salt) +343 │ let pair: UniswapV2Pair = UniswapV2Pair.create2(ctx, 0, salt) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UniswapV2Pair: Value -313 │ pair.initialize(token0, token1) +344 │ pair.initialize(token0, token1) │ ^^^^ ^^^^^^ ^^^^^^ address: Value │ │ │ │ │ address: Value │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:313:9 + ┌─ uniswap.fe:344:9 │ -313 │ pair.initialize(token0, token1) +344 │ pair.initialize(token0, token1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -314 │ -315 │ self.pairs[token0][token1] = address(pair) +345 │ +346 │ self.pairs[token0][token1] = address(pair) │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:315:9 + ┌─ uniswap.fe:346:9 │ -315 │ self.pairs[token0][token1] = address(pair) +346 │ self.pairs[token0][token1] = address(pair) │ ^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(2) } note: - ┌─ uniswap.fe:315:9 + ┌─ uniswap.fe:346:9 │ -315 │ self.pairs[token0][token1] = address(pair) +346 │ self.pairs[token0][token1] = address(pair) │ ^^^^^^^^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ uniswap.fe:315:9 + ┌─ uniswap.fe:346:9 │ -315 │ self.pairs[token0][token1] = address(pair) +346 │ self.pairs[token0][token1] = address(pair) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ address: Storage { nonce: None } note: - ┌─ uniswap.fe:315:38 + ┌─ uniswap.fe:346:38 │ -315 │ self.pairs[token0][token1] = address(pair) +346 │ self.pairs[token0][token1] = address(pair) │ ^^^^^^^^^^^^^ address: Value -316 │ self.pairs[token1][token0] = address(pair) +347 │ self.pairs[token1][token0] = address(pair) │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:316:9 + ┌─ uniswap.fe:347:9 │ -316 │ self.pairs[token1][token0] = address(pair) +347 │ self.pairs[token1][token0] = address(pair) │ ^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(2) } note: - ┌─ uniswap.fe:316:9 + ┌─ uniswap.fe:347:9 │ -316 │ self.pairs[token1][token0] = address(pair) +347 │ self.pairs[token1][token0] = address(pair) │ ^^^^^^^^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ uniswap.fe:316:9 + ┌─ uniswap.fe:347:9 │ -316 │ self.pairs[token1][token0] = address(pair) +347 │ self.pairs[token1][token0] = address(pair) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ address: Storage { nonce: None } note: - ┌─ uniswap.fe:316:38 + ┌─ uniswap.fe:347:38 │ -316 │ self.pairs[token1][token0] = address(pair) +347 │ self.pairs[token1][token0] = address(pair) │ ^^^^^^^^^^^^^ address: Value -317 │ self.all_pairs[self.pair_counter] = address(pair) +348 │ self.all_pairs[self.pair_counter] = address(pair) │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:317:9 + ┌─ uniswap.fe:348:9 │ -317 │ self.all_pairs[self.pair_counter] = address(pair) +348 │ self.all_pairs[self.pair_counter] = address(pair) │ ^^^^^^^^^^^^^^ ^^^^ UniswapV2Factory: Value │ │ │ Array: Storage { nonce: Some(3) } note: - ┌─ uniswap.fe:317:24 + ┌─ uniswap.fe:348:24 │ -317 │ self.all_pairs[self.pair_counter] = address(pair) +348 │ self.all_pairs[self.pair_counter] = address(pair) │ ^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(4) } => Value note: - ┌─ uniswap.fe:317:9 + ┌─ uniswap.fe:348:9 │ -317 │ self.all_pairs[self.pair_counter] = address(pair) +348 │ self.all_pairs[self.pair_counter] = address(pair) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ address: Storage { nonce: None } note: - ┌─ uniswap.fe:317:45 + ┌─ uniswap.fe:348:45 │ -317 │ self.all_pairs[self.pair_counter] = address(pair) +348 │ self.all_pairs[self.pair_counter] = address(pair) │ ^^^^^^^^^^^^^ address: Value -318 │ self.pair_counter = self.pair_counter + 1 +349 │ self.pair_counter = self.pair_counter + 1 │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:318:9 + ┌─ uniswap.fe:349:9 │ -318 │ self.pair_counter = self.pair_counter + 1 +349 │ self.pair_counter = self.pair_counter + 1 │ ^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Factory: Value │ │ │ u256: Storage { nonce: Some(4) } note: - ┌─ uniswap.fe:318:29 + ┌─ uniswap.fe:349:29 │ -318 │ self.pair_counter = self.pair_counter + 1 +349 │ self.pair_counter = self.pair_counter + 1 │ ^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: Some(4) } => Value note: - ┌─ uniswap.fe:318:29 + ┌─ uniswap.fe:349:29 │ -318 │ self.pair_counter = self.pair_counter + 1 +349 │ self.pair_counter = self.pair_counter + 1 │ ^^^^^^^^^^^^^^^^^^^^^ u256: Value -319 │ -320 │ emit PairCreated(ctx, token0, token1, pair: address(pair), index: self.pair_counter) +350 │ +351 │ emit PairCreated(ctx, token0, token1, pair: address(pair), index: self.pair_counter) │ ^^^ ^^^^^^ ^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ │ │ │ │ address: Value @@ -4515,31 +4525,31 @@ note: │ Context: Memory note: - ┌─ uniswap.fe:320:53 + ┌─ uniswap.fe:351:53 │ -320 │ emit PairCreated(ctx, token0, token1, pair: address(pair), index: self.pair_counter) +351 │ emit PairCreated(ctx, token0, token1, pair: address(pair), index: self.pair_counter) │ ^^^^^^^^^^^^^ ^^^^ UniswapV2Factory: Value │ │ │ address: Value note: - ┌─ uniswap.fe:320:75 + ┌─ uniswap.fe:351:75 │ -320 │ emit PairCreated(ctx, token0, token1, pair: address(pair), index: self.pair_counter) +351 │ emit PairCreated(ctx, token0, token1, pair: address(pair), index: self.pair_counter) │ ^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(4) } => Value -321 │ return address(pair) +352 │ return address(pair) │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:321:16 + ┌─ uniswap.fe:352:16 │ -321 │ return address(pair) +352 │ return address(pair) │ ^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:320:9 + ┌─ uniswap.fe:351:9 │ -320 │ emit PairCreated(ctx, token0, token1, pair: address(pair), index: self.pair_counter) +351 │ emit PairCreated(ctx, token0, token1, pair: address(pair), index: self.pair_counter) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 13094055123344570742 │ = Event { @@ -4587,12 +4597,13 @@ note: } note: - ┌─ uniswap.fe:323:5 + ┌─ uniswap.fe:355:5 │ -323 │ ╭ pub fn set_fee_to(self, ctx: Context, fee_to: address): -324 │ │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" -325 │ │ self.fee_to = fee_to - │ ╰────────────────────────────^ attributes hash: 9061125162615165722 +355 │ ╭ pub fn set_fee_to(self, ctx: Context, fee_to: address) { +356 │ │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" +357 │ │ self.fee_to = fee_to +358 │ │ } + │ ╰─────^ attributes hash: 9061125162615165722 │ = FunctionSignature { self_decl: Some( @@ -4632,50 +4643,51 @@ note: } note: - ┌─ uniswap.fe:324:16 + ┌─ uniswap.fe:356:16 │ -324 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" +356 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" │ ^^^ Context: Memory note: - ┌─ uniswap.fe:324:16 + ┌─ uniswap.fe:356:16 │ -324 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" +356 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Factory: Value │ │ │ address: Value note: - ┌─ uniswap.fe:324:36 + ┌─ uniswap.fe:356:36 │ -324 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" +356 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^^^^^^^ address: Storage { nonce: Some(1) } => Value note: - ┌─ uniswap.fe:324:16 + ┌─ uniswap.fe:356:16 │ -324 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" +356 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ String<20>: Memory │ │ │ bool: Value -325 │ self.fee_to = fee_to +357 │ self.fee_to = fee_to │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:325:9 + ┌─ uniswap.fe:357:9 │ -325 │ self.fee_to = fee_to +357 │ self.fee_to = fee_to │ ^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ address: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:327:5 + ┌─ uniswap.fe:360:5 │ -327 │ ╭ pub fn set_fee_to_setter(self, ctx: Context, fee_to_setter: address): -328 │ │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" -329 │ │ self.fee_to_setter = fee_to_setter - │ ╰──────────────────────────────────────────^ attributes hash: 16865322734649050051 +360 │ ╭ pub fn set_fee_to_setter(self, ctx: Context, fee_to_setter: address) { +361 │ │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" +362 │ │ self.fee_to_setter = fee_to_setter +363 │ │ } + │ ╰─────^ attributes hash: 16865322734649050051 │ = FunctionSignature { self_decl: Some( @@ -4715,48 +4727,48 @@ note: } note: - ┌─ uniswap.fe:328:16 + ┌─ uniswap.fe:361:16 │ -328 │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" +361 │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" │ ^^^ Context: Memory note: - ┌─ uniswap.fe:328:16 + ┌─ uniswap.fe:361:16 │ -328 │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" +361 │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ address: Value │ │ │ address: Value note: - ┌─ uniswap.fe:328:16 + ┌─ uniswap.fe:361:16 │ -328 │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" +361 │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ String<20>: Memory │ │ │ bool: Value -329 │ self.fee_to_setter = fee_to_setter +362 │ self.fee_to_setter = fee_to_setter │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:329:9 + ┌─ uniswap.fe:362:9 │ -329 │ self.fee_to_setter = fee_to_setter +362 │ self.fee_to_setter = fee_to_setter │ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ address: Value │ │ │ address: Storage { nonce: Some(1) } note: - ┌─ uniswap.fe:332:1 + ┌─ uniswap.fe:366:1 │ -332 │ ╭ fn sqrt(_ val: u256) -> u256: -333 │ │ let z: u256 -334 │ │ if (val > 3): -335 │ │ z = val +366 │ ╭ fn sqrt(_ val: u256) -> u256 { +367 │ │ let z: u256 +368 │ │ if val > 3 { +369 │ │ z = val · │ -341 │ │ z = 1 -342 │ │ return z - │ ╰────────────^ attributes hash: 4892692935064256824 +378 │ │ return z +379 │ │ } + │ ╰─^ attributes hash: 4892692935064256824 │ = FunctionSignature { self_decl: None, @@ -4786,113 +4798,116 @@ note: } note: - ┌─ uniswap.fe:333:12 + ┌─ uniswap.fe:367:12 │ -333 │ let z: u256 +367 │ let z: u256 │ ^^^^ u256 · -336 │ let x: u256 = val / 2 + 1 +370 │ let x: u256 = val / 2 + 1 │ ^^^^ u256 note: - ┌─ uniswap.fe:334:9 + ┌─ uniswap.fe:368:8 │ -334 │ if (val > 3): - │ ^^^ ^ u256: Value - │ │ - │ u256: Value +368 │ if val > 3 { + │ ^^^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ uniswap.fe:334:8 + ┌─ uniswap.fe:368:8 │ -334 │ if (val > 3): - │ ^^^^^^^^^ bool: Value -335 │ z = val +368 │ if val > 3 { + │ ^^^^^^^ bool: Value +369 │ z = val │ ^ ^^^ u256: Value │ │ │ u256: Value -336 │ let x: u256 = val / 2 + 1 +370 │ let x: u256 = val / 2 + 1 │ ^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:336:23 + ┌─ uniswap.fe:370:23 │ -336 │ let x: u256 = val / 2 + 1 +370 │ let x: u256 = val / 2 + 1 │ ^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:336:23 + ┌─ uniswap.fe:370:23 │ -336 │ let x: u256 = val / 2 + 1 +370 │ let x: u256 = val / 2 + 1 │ ^^^^^^^^^^^ u256: Value -337 │ while (x < z): - │ ^ ^ u256: Value - │ │ - │ u256: Value +371 │ while x < z { + │ ^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ uniswap.fe:337:15 + ┌─ uniswap.fe:371:15 │ -337 │ while (x < z): - │ ^^^^^^^ bool: Value -338 │ z = x +371 │ while x < z { + │ ^^^^^ bool: Value +372 │ z = x │ ^ ^ u256: Value │ │ │ u256: Value -339 │ x = (val / x + x) / 2 +373 │ x = (val / x + x) / 2 │ ^ ^^^ ^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:339:18 + ┌─ uniswap.fe:373:18 │ -339 │ x = (val / x + x) / 2 +373 │ x = (val / x + x) / 2 │ ^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:339:17 + ┌─ uniswap.fe:373:17 │ -339 │ x = (val / x + x) / 2 +373 │ x = (val / x + x) / 2 │ ^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:339:17 + ┌─ uniswap.fe:373:17 │ -339 │ x = (val / x + x) / 2 +373 │ x = (val / x + x) / 2 │ ^^^^^^^^^^^^^^^^^ u256: Value -340 │ elif (val != 0): - │ ^^^ ^ u256: Value - │ │ - │ u256: Value +374 │ } +375 │ } else if val != 0 { + │ ^^^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ uniswap.fe:340:10 + ┌─ uniswap.fe:375:15 │ -340 │ elif (val != 0): - │ ^^^^^^^^^^ bool: Value -341 │ z = 1 +375 │ } else if val != 0 { + │ ^^^^^^^^ bool: Value +376 │ z = 1 │ ^ ^ u256: Value │ │ │ u256: Value -342 │ return z +377 │ } +378 │ return z │ ^ u256: Value note: - ┌─ uniswap.fe:344:1 + ┌─ uniswap.fe:381:1 │ -344 │ ╭ fn min(_ x: u256, _ y: u256) -> u256: -345 │ │ return x if x < y else y - │ ╰────────────────────────────^ attributes hash: 4448606202021980030 +381 │ ╭ fn min(_ x: u256, _ y: u256) -> u256 { +382 │ │ return x if x < y else y +383 │ │ } + │ ╰─^ attributes hash: 4448606202021980030 │ = FunctionSignature { self_decl: None, @@ -4935,26 +4950,26 @@ note: } note: - ┌─ uniswap.fe:345:17 + ┌─ uniswap.fe:382:17 │ -345 │ return x if x < y else y +382 │ return x if x < y else y │ ^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:345:12 + ┌─ uniswap.fe:382:12 │ -345 │ return x if x < y else y +382 │ return x if x < y else y │ ^ ^^^^^ ^ u256: Value │ │ │ │ │ bool: Value │ u256: Value note: - ┌─ uniswap.fe:345:12 + ┌─ uniswap.fe:382:12 │ -345 │ return x if x < y else y +382 │ return x if x < y else y │ ^^^^^^^^^^^^^^^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__while_loop.snap b/crates/analyzer/tests/snapshots/analysis__while_loop.snap index d86e016338..8d8879e6ac 100644 --- a/crates/analyzer/tests/snapshots/analysis__while_loop.snap +++ b/crates/analyzer/tests/snapshots/analysis__while_loop.snap @@ -4,29 +4,29 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ while_loop.fe:2:5 - │ -2 │ ╭ pub fn bar() -> u256: -3 │ │ let val: u256 = 0 -4 │ │ while val < 2: -5 │ │ val = val + 1 -6 │ │ if val == 2: -7 │ │ val = 3 -8 │ │ return val - │ ╰──────────────────^ attributes hash: 6115314201970082834 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [], - return_type: Ok( - Base( - Numeric( - U256, - ), - ), - ), - } + ┌─ while_loop.fe:2:5 + │ + 2 │ ╭ pub fn bar() -> u256 { + 3 │ │ let val: u256 = 0 + 4 │ │ while val < 2 { + 5 │ │ val = val + 1 + · │ +10 │ │ return val +11 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [], + return_type: Ok( + Base( + Numeric( + U256, + ), + ), + ), + } note: ┌─ while_loop.fe:3:18 @@ -39,7 +39,7 @@ note: │ 3 │ let val: u256 = 0 │ ^ u256: Value -4 │ while val < 2: +4 │ while val < 2 { │ ^^^ ^ u256: Value │ │ │ u256: Value @@ -47,7 +47,7 @@ note: note: ┌─ while_loop.fe:4:15 │ -4 │ while val < 2: +4 │ while val < 2 { │ ^^^^^^^ bool: Value 5 │ val = val + 1 │ ^^^ ^^^ ^ u256: Value @@ -60,21 +60,22 @@ note: │ 5 │ val = val + 1 │ ^^^^^^^ u256: Value -6 │ if val == 2: +6 │ if val == 2 { │ ^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ while_loop.fe:6:16 - │ -6 │ if val == 2: - │ ^^^^^^^^ bool: Value -7 │ val = 3 - │ ^^^ ^ u256: Value - │ │ - │ u256: Value -8 │ return val - │ ^^^ u256: Value + ┌─ while_loop.fe:6:16 + │ + 6 │ if val == 2 { + │ ^^^^^^^^ bool: Value + 7 │ val = 3 + │ ^^^ ^ u256: Value + │ │ + │ u256: Value + · +10 │ return val + │ ^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__while_loop_with_break.snap b/crates/analyzer/tests/snapshots/analysis__while_loop_with_break.snap index 0d63533196..29ea6a30fd 100644 --- a/crates/analyzer/tests/snapshots/analysis__while_loop_with_break.snap +++ b/crates/analyzer/tests/snapshots/analysis__while_loop_with_break.snap @@ -6,13 +6,14 @@ expression: "build_snapshot(&db, module)" note: ┌─ while_loop_with_break.fe:2:5 │ -2 │ ╭ pub fn bar() -> u256: +2 │ ╭ pub fn bar() -> u256 { 3 │ │ let val: u256 = 0 -4 │ │ while val < 2: +4 │ │ while val < 2 { 5 │ │ val = val + 1 -6 │ │ break -7 │ │ return val - │ ╰──────────────────^ attributes hash: 6115314201970082834 + · │ +8 │ │ return val +9 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -38,7 +39,7 @@ note: │ 3 │ let val: u256 = 0 │ ^ u256: Value -4 │ while val < 2: +4 │ while val < 2 { │ ^^^ ^ u256: Value │ │ │ u256: Value @@ -46,7 +47,7 @@ note: note: ┌─ while_loop_with_break.fe:4:15 │ -4 │ while val < 2: +4 │ while val < 2 { │ ^^^^^^^ bool: Value 5 │ val = val + 1 │ ^^^ ^^^ ^ u256: Value @@ -59,8 +60,8 @@ note: │ 5 │ val = val + 1 │ ^^^^^^^ u256: Value -6 │ break -7 │ return val + · +8 │ return val │ ^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__while_loop_with_break_2.snap b/crates/analyzer/tests/snapshots/analysis__while_loop_with_break_2.snap index fdb03b312d..5cb31858a3 100644 --- a/crates/analyzer/tests/snapshots/analysis__while_loop_with_break_2.snap +++ b/crates/analyzer/tests/snapshots/analysis__while_loop_with_break_2.snap @@ -4,29 +4,29 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ while_loop_with_break_2.fe:2:5 - │ -2 │ ╭ pub fn bar() -> u256: -3 │ │ let val: u256 = 0 -4 │ │ while val < 2: -5 │ │ val = val + 1 -6 │ │ if val == 1: -7 │ │ break -8 │ │ return val - │ ╰──────────────────^ attributes hash: 6115314201970082834 - │ - = FunctionSignature { - self_decl: None, - ctx_decl: None, - params: [], - return_type: Ok( - Base( - Numeric( - U256, - ), - ), - ), - } + ┌─ while_loop_with_break_2.fe:2:5 + │ + 2 │ ╭ pub fn bar() -> u256 { + 3 │ │ let val: u256 = 0 + 4 │ │ while val < 2 { + 5 │ │ val = val + 1 + · │ +10 │ │ return val +11 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 + │ + = FunctionSignature { + self_decl: None, + ctx_decl: None, + params: [], + return_type: Ok( + Base( + Numeric( + U256, + ), + ), + ), + } note: ┌─ while_loop_with_break_2.fe:3:18 @@ -39,7 +39,7 @@ note: │ 3 │ let val: u256 = 0 │ ^ u256: Value -4 │ while val < 2: +4 │ while val < 2 { │ ^^^ ^ u256: Value │ │ │ u256: Value @@ -47,7 +47,7 @@ note: note: ┌─ while_loop_with_break_2.fe:4:15 │ -4 │ while val < 2: +4 │ while val < 2 { │ ^^^^^^^ bool: Value 5 │ val = val + 1 │ ^^^ ^^^ ^ u256: Value @@ -60,18 +60,18 @@ note: │ 5 │ val = val + 1 │ ^^^^^^^ u256: Value -6 │ if val == 1: +6 │ if val == 1 { │ ^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ while_loop_with_break_2.fe:6:16 - │ -6 │ if val == 1: - │ ^^^^^^^^ bool: Value -7 │ break -8 │ return val - │ ^^^ u256: Value + ┌─ while_loop_with_break_2.fe:6:16 + │ + 6 │ if val == 1 { + │ ^^^^^^^^ bool: Value + · +10 │ return val + │ ^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__while_loop_with_continue.snap b/crates/analyzer/tests/snapshots/analysis__while_loop_with_continue.snap index 4c8b02724d..3ad21cdf94 100644 --- a/crates/analyzer/tests/snapshots/analysis__while_loop_with_continue.snap +++ b/crates/analyzer/tests/snapshots/analysis__while_loop_with_continue.snap @@ -6,14 +6,14 @@ expression: "build_snapshot(&db, module)" note: ┌─ while_loop_with_continue.fe:2:5 │ - 2 │ ╭ pub fn bar() -> u256: + 2 │ ╭ pub fn bar() -> u256 { 3 │ │ let i: u256 = 0 4 │ │ let counter: u256 = 0 - 5 │ │ + 5 │ │ while i < 2 { · │ -10 │ │ counter = counter + 1 -11 │ │ return counter - │ ╰──────────────────────^ attributes hash: 6115314201970082834 +12 │ │ return counter +13 │ │ } + │ ╰─────^ attributes hash: 6115314201970082834 │ = FunctionSignature { self_decl: None, @@ -43,39 +43,38 @@ note: │ ^ u256: Value 4 │ let counter: u256 = 0 │ ^ u256: Value -5 │ -6 │ while i < 2: +5 │ while i < 2 { │ ^ ^ u256: Value │ │ │ u256: Value note: - ┌─ while_loop_with_continue.fe:6:15 + ┌─ while_loop_with_continue.fe:5:15 │ -6 │ while i < 2: +5 │ while i < 2 { │ ^^^^^ bool: Value -7 │ i = i + 1 +6 │ i = i + 1 │ ^ ^ ^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ while_loop_with_continue.fe:7:17 + ┌─ while_loop_with_continue.fe:6:17 │ -7 │ i = i + 1 +6 │ i = i + 1 │ ^^^^^ u256: Value -8 │ if i == 1: +7 │ if i == 1 { │ ^ ^ u256: Value │ │ │ u256: Value note: - ┌─ while_loop_with_continue.fe:8:16 + ┌─ while_loop_with_continue.fe:7:16 │ - 8 │ if i == 1: + 7 │ if i == 1 { │ ^^^^^^ bool: Value - 9 │ continue + · 10 │ counter = counter + 1 │ ^^^^^^^ ^^^^^^^ ^ u256: Value │ │ │ @@ -87,7 +86,8 @@ note: │ 10 │ counter = counter + 1 │ ^^^^^^^^^^^ u256: Value -11 │ return counter +11 │ } +12 │ return counter │ ^^^^^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/errors__bad_ingot.snap b/crates/analyzer/tests/snapshots/errors__bad_ingot.snap index 52a29e4426..c57a325fef 100644 --- a/crates/analyzer/tests/snapshots/errors__bad_ingot.snap +++ b/crates/analyzer/tests/snapshots/errors__bad_ingot.snap @@ -57,47 +57,47 @@ error: a type with the same name has already been imported 2 │ use biz::bad::{Bur, Bud as Bar, Boo} │ ^^^ `Bar` first defined here · -6 │ contract Bar: +6 │ contract Bar { │ --- `Bar` redefined here error: function name conflicts with the ingot named "std" - ┌─ compile_errors/bad_ingot/src/main.fe:11:4 + ┌─ compile_errors/bad_ingot/src/main.fe:12:4 │ -11 │ fn std(): +12 │ fn std() {} │ ^^^ `std` is already defined error: the type `Foo` is private - ┌─ compile_errors/bad_ingot/src/main.fe:8:19 + ┌─ compile_errors/bad_ingot/src/main.fe:7:19 │ -8 │ pub fn a() -> foo::Foo: +7 │ pub fn a() -> foo::Foo { │ ^^^^^^^^ this type is not `pub` │ ┌─ compile_errors/bad_ingot/src/foo.fe:5:8 │ -5 │ struct Foo: +5 │ struct Foo { │ --- `Foo` is defined here │ = `Foo` can only be used within `foo` = Hint: use `pub` to make `Foo` visible from outside of `foo` error: the type `Foo` is private - ┌─ compile_errors/bad_ingot/src/main.fe:9:16 + ┌─ compile_errors/bad_ingot/src/main.fe:8:16 │ -9 │ return foo::Foo(my_num: true) +8 │ return foo::Foo(my_num: true) │ ^^^^^^^^ this type is not `pub` │ ┌─ compile_errors/bad_ingot/src/foo.fe:5:8 │ -5 │ struct Foo: +5 │ struct Foo { │ --- `Foo` is defined here │ = `Foo` can only be used within `foo` = Hint: use `pub` to make `Foo` visible from outside of `foo` error: incorrect type for `Foo` argument `my_num` - ┌─ compile_errors/bad_ingot/src/main.fe:9:33 + ┌─ compile_errors/bad_ingot/src/main.fe:8:33 │ -9 │ return foo::Foo(my_num: true) +8 │ return foo::Foo(my_num: true) │ ^^^^ this has type `bool`; expected type `u256` diff --git a/crates/analyzer/tests/snapshots/errors__bad_visibility.snap b/crates/analyzer/tests/snapshots/errors__bad_visibility.snap index c908031945..c3a0da1ab1 100644 --- a/crates/analyzer/tests/snapshots/errors__bad_visibility.snap +++ b/crates/analyzer/tests/snapshots/errors__bad_visibility.snap @@ -6,7 +6,7 @@ expression: error_string_ingot(&path) error: the type `MyInt` is private ┌─ compile_errors/bad_visibility/src/main.fe:5:33 │ -5 │ pub fn priv_type_alias() -> MyInt: +5 │ pub fn priv_type_alias() -> MyInt { │ ^^^^^ this type is not `pub` │ ┌─ compile_errors/bad_visibility/src/foo.fe:1:6 @@ -32,9 +32,9 @@ error: the type `MyInt` is private = Hint: use `pub` to make `MyInt` visible from outside of `foo` error: the constant `MY_CONST` is private - ┌─ compile_errors/bad_visibility/src/main.fe:10:16 + ┌─ compile_errors/bad_visibility/src/main.fe:11:16 │ -10 │ return MY_CONST +11 │ return MY_CONST │ ^^^^^^^^ this constant is not `pub` │ ┌─ compile_errors/bad_visibility/src/foo.fe:3:7 @@ -46,9 +46,9 @@ error: the constant `MY_CONST` is private = Hint: use `pub` to make `MY_CONST` visible from outside of `foo` error: the constant `MY_CONST` is private - ┌─ compile_errors/bad_visibility/src/main.fe:10:16 + ┌─ compile_errors/bad_visibility/src/main.fe:11:16 │ -10 │ return MY_CONST +11 │ return MY_CONST │ ^^^^^^^^ this constant is not `pub` │ ┌─ compile_errors/bad_visibility/src/foo.fe:3:1 @@ -60,127 +60,128 @@ error: the constant `MY_CONST` is private = Hint: use `pub const MY_CONST` to make `MY_CONST` visible from outside of `foo` error: the event `MyEvent` is private - ┌─ compile_errors/bad_visibility/src/main.fe:13:14 + ┌─ compile_errors/bad_visibility/src/main.fe:15:14 │ -13 │ emit MyEvent(ctx, x: 1) +15 │ emit MyEvent(ctx, x: 1) │ ^^^^^^^ this event is not `pub` │ ┌─ compile_errors/bad_visibility/src/foo.fe:5:7 │ - 5 │ event MyEvent: + 5 │ event MyEvent { │ ------- `MyEvent` is defined here │ = `MyEvent` can only be used within `foo` = Hint: use `pub` to make `MyEvent` visible from outside of `foo` error: the event `MyEvent` is private - ┌─ compile_errors/bad_visibility/src/main.fe:13:14 + ┌─ compile_errors/bad_visibility/src/main.fe:15:14 │ -13 │ emit MyEvent(ctx, x: 1) +15 │ emit MyEvent(ctx, x: 1) │ ^^^^^^^ this event is not `pub` │ ┌─ compile_errors/bad_visibility/src/foo.fe:5:1 │ - 5 │ ╭ event MyEvent: + 5 │ ╭ event MyEvent { 6 │ │ x: i32 - │ ╰──────────' `MyEvent` is defined here + 7 │ │ } + │ ╰─' `MyEvent` is defined here │ = `MyEvent` can only be used within `foo` = Hint: use `pub event MyEvent` to make `MyEvent` visible from outside of `foo` error: cannot find value `ctx` in this scope - ┌─ compile_errors/bad_visibility/src/main.fe:13:22 + ┌─ compile_errors/bad_visibility/src/main.fe:15:22 │ -13 │ emit MyEvent(ctx, x: 1) +15 │ emit MyEvent(ctx, x: 1) │ ^^^ undefined error: the type `MyStruct` is private - ┌─ compile_errors/bad_visibility/src/main.fe:16:16 + ┌─ compile_errors/bad_visibility/src/main.fe:19:16 │ -16 │ let s: MyStruct = MyStruct(x: 1) +19 │ let s: MyStruct = MyStruct(x: 1) │ ^^^^^^^^ this type is not `pub` │ - ┌─ compile_errors/bad_visibility/src/foo.fe:8:8 + ┌─ compile_errors/bad_visibility/src/foo.fe:9:8 │ - 8 │ struct MyStruct: + 9 │ struct MyStruct { │ -------- `MyStruct` is defined here │ = `MyStruct` can only be used within `foo` = Hint: use `pub` to make `MyStruct` visible from outside of `foo` error: the type `MyStruct` is private - ┌─ compile_errors/bad_visibility/src/main.fe:16:27 + ┌─ compile_errors/bad_visibility/src/main.fe:19:27 │ -16 │ let s: MyStruct = MyStruct(x: 1) +19 │ let s: MyStruct = MyStruct(x: 1) │ ^^^^^^^^ this type is not `pub` │ - ┌─ compile_errors/bad_visibility/src/foo.fe:8:8 + ┌─ compile_errors/bad_visibility/src/foo.fe:9:8 │ - 8 │ struct MyStruct: + 9 │ struct MyStruct { │ -------- `MyStruct` is defined here │ = `MyStruct` can only be used within `foo` = Hint: use `pub` to make `MyStruct` visible from outside of `foo` error: Can not call private constructor of struct `MyStruct` - ┌─ compile_errors/bad_visibility/src/foo.fe:9:5 - │ -9 │ x: i32 - │ ^^^^^^ Field `x` is private - │ - = Suggestion: implement a method `new(...)` on struct `MyStruct` to call the constructor and return the struct + ┌─ compile_errors/bad_visibility/src/foo.fe:10:5 + │ +10 │ x: i32 + │ ^^^^^^ Field `x` is private + │ + = Suggestion: implement a method `new(...)` on struct `MyStruct` to call the constructor and return the struct error: the function `my_func` is private - ┌─ compile_errors/bad_visibility/src/main.fe:19:9 + ┌─ compile_errors/bad_visibility/src/main.fe:23:9 │ -19 │ my_func() +23 │ my_func() │ ^^^^^^^ this function is not `pub` │ - ┌─ compile_errors/bad_visibility/src/foo.fe:11:4 + ┌─ compile_errors/bad_visibility/src/foo.fe:13:4 │ -11 │ fn my_func(): +13 │ fn my_func() {} │ ------- `my_func` is defined here │ = `my_func` can only be used within `foo` = Hint: use `pub` to make `my_func` visible from outside of `foo` error: the type `MyContract` is private - ┌─ compile_errors/bad_visibility/src/main.fe:22:16 + ┌─ compile_errors/bad_visibility/src/main.fe:27:16 │ -22 │ let _: MyContract = MyContract(ctx, addr) +27 │ let _: MyContract = MyContract(ctx, addr) │ ^^^^^^^^^^ this type is not `pub` │ - ┌─ compile_errors/bad_visibility/src/foo.fe:14:10 + ┌─ compile_errors/bad_visibility/src/foo.fe:15:10 │ -14 │ contract MyContract: +15 │ contract MyContract { │ ---------- `MyContract` is defined here │ = `MyContract` can only be used within `foo` = Hint: use `pub` to make `MyContract` visible from outside of `foo` error: the type `MyContract` is private - ┌─ compile_errors/bad_visibility/src/main.fe:22:29 + ┌─ compile_errors/bad_visibility/src/main.fe:27:29 │ -22 │ let _: MyContract = MyContract(ctx, addr) +27 │ let _: MyContract = MyContract(ctx, addr) │ ^^^^^^^^^^ this type is not `pub` │ - ┌─ compile_errors/bad_visibility/src/foo.fe:14:10 + ┌─ compile_errors/bad_visibility/src/foo.fe:15:10 │ -14 │ contract MyContract: +15 │ contract MyContract { │ ---------- `MyContract` is defined here │ = `MyContract` can only be used within `foo` = Hint: use `pub` to make `MyContract` visible from outside of `foo` error: the type `MyContract` is private - ┌─ compile_errors/bad_visibility/src/main.fe:23:9 + ┌─ compile_errors/bad_visibility/src/main.fe:28:9 │ -23 │ MyContract.create(ctx, 1) +28 │ MyContract.create(ctx, 1) │ ^^^^^^^^^^ this type is not `pub` │ - ┌─ compile_errors/bad_visibility/src/foo.fe:14:10 + ┌─ compile_errors/bad_visibility/src/foo.fe:15:10 │ -14 │ contract MyContract: +15 │ contract MyContract { │ ---------- `MyContract` is defined here │ = `MyContract` can only be used within `foo` diff --git a/crates/analyzer/tests/snapshots/errors__break_without_loop_2.snap b/crates/analyzer/tests/snapshots/errors__break_without_loop_2.snap index ac501de3bf..5170bbdaf1 100644 --- a/crates/analyzer/tests/snapshots/errors__break_without_loop_2.snap +++ b/crates/analyzer/tests/snapshots/errors__break_without_loop_2.snap @@ -4,9 +4,9 @@ expression: "error_string(\"[snippet]\", &src)" --- error: `break` outside of a loop - ┌─ [snippet]:4:5 + ┌─ [snippet]:3:13 │ -4 │ break - │ ^^^^^ `break` can only be used inside of a `for` or `while` loop +3 │ if true { break } + │ ^^^^^ `break` can only be used inside of a `for` or `while` loop diff --git a/crates/analyzer/tests/snapshots/errors__call_balance_of_with_2_args.snap b/crates/analyzer/tests/snapshots/errors__call_balance_of_with_2_args.snap index 97a17ce6f5..ebd0ec09f2 100644 --- a/crates/analyzer/tests/snapshots/errors__call_balance_of_with_2_args.snap +++ b/crates/analyzer/tests/snapshots/errors__call_balance_of_with_2_args.snap @@ -4,14 +4,14 @@ expression: "error_string(\"[snippet]\", &src)" --- error: `balance_of` expects 1 argument, but 2 were provided - ┌─ src/evm.fe:38:15 + ┌─ src/evm.fe:50:15 │ -38 │ pub unsafe fn balance_of(_ addr: address) -> u256: +50 │ pub unsafe fn balance_of(_ addr: address) -> u256 { │ ^^^^^^^^^^ expects 1 argument │ - ┌─ [snippet]:4:26 + ┌─ [snippet]:3:33 │ - 4 │ std::evm::balance_of(address(0), 2) - │ ---------- - supplied 2 arguments + 3 │ unsafe { std::evm::balance_of(address(0), 2) } + │ ---------- - supplied 2 arguments diff --git a/crates/analyzer/tests/snapshots/errors__call_balance_of_with_wrong_type.snap b/crates/analyzer/tests/snapshots/errors__call_balance_of_with_wrong_type.snap index ddd8ab137f..b1b6d46710 100644 --- a/crates/analyzer/tests/snapshots/errors__call_balance_of_with_wrong_type.snap +++ b/crates/analyzer/tests/snapshots/errors__call_balance_of_with_wrong_type.snap @@ -4,9 +4,9 @@ expression: "error_string(\"[snippet]\", &src)" --- error: incorrect type for `balance_of` argument at position 0 - ┌─ [snippet]:4:26 + ┌─ [snippet]:3:33 │ -4 │ std::evm::balance_of(true) - │ ^^^^ this has type `bool`; expected type `address` +3 │ unsafe { std::evm::balance_of(true) } + │ ^^^^ this has type `bool`; expected type `address` diff --git a/crates/analyzer/tests/snapshots/errors__call_balance_of_without_parameter.snap b/crates/analyzer/tests/snapshots/errors__call_balance_of_without_parameter.snap index 4568a33546..9602329664 100644 --- a/crates/analyzer/tests/snapshots/errors__call_balance_of_without_parameter.snap +++ b/crates/analyzer/tests/snapshots/errors__call_balance_of_without_parameter.snap @@ -4,14 +4,14 @@ expression: "error_string(\"[snippet]\", &src)" --- error: `balance_of` expects 1 argument, but 0 were provided - ┌─ src/evm.fe:38:15 + ┌─ src/evm.fe:50:15 │ -38 │ pub unsafe fn balance_of(_ addr: address) -> u256: +50 │ pub unsafe fn balance_of(_ addr: address) -> u256 { │ ^^^^^^^^^^ expects 1 argument │ - ┌─ [snippet]:4:25 + ┌─ [snippet]:3:32 │ - 4 │ std::evm::balance_of() - │ -- supplied 0 arguments + 3 │ unsafe { std::evm::balance_of() } + │ -- supplied 0 arguments diff --git a/crates/analyzer/tests/snapshots/errors__call_balance_with_arg.snap b/crates/analyzer/tests/snapshots/errors__call_balance_with_arg.snap index 4e4224c2bf..6b0564205f 100644 --- a/crates/analyzer/tests/snapshots/errors__call_balance_with_arg.snap +++ b/crates/analyzer/tests/snapshots/errors__call_balance_with_arg.snap @@ -4,14 +4,14 @@ expression: "error_string(\"[snippet]\", &src)" --- error: `balance` expects 0 arguments, but 1 was provided - ┌─ src/evm.fe:41:15 + ┌─ src/evm.fe:54:15 │ -41 │ pub unsafe fn balance() -> u256: +54 │ pub unsafe fn balance() -> u256 { │ ^^^^^^^ expects 0 arguments │ - ┌─ [snippet]:4:23 + ┌─ [snippet]:3:30 │ - 4 │ std::evm::balance(address(0)) - │ ---------- supplied 1 argument + 3 │ unsafe { std::evm::balance(address(0)) } + │ ---------- supplied 1 argument diff --git a/crates/analyzer/tests/snapshots/errors__call_builtin_object.snap b/crates/analyzer/tests/snapshots/errors__call_builtin_object.snap index dfd8942624..ae8b1d4a90 100644 --- a/crates/analyzer/tests/snapshots/errors__call_builtin_object.snap +++ b/crates/analyzer/tests/snapshots/errors__call_builtin_object.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: cannot find value `block` in this scope - ┌─ compile_errors/call_builtin_object.fe:4:5 + ┌─ compile_errors/call_builtin_object.fe:3:9 │ -4 │ block.foo() - │ ^^^^^ undefined +3 │ block.foo() + │ ^^^^^ undefined diff --git a/crates/analyzer/tests/snapshots/errors__call_call_on_external_contract.snap b/crates/analyzer/tests/snapshots/errors__call_call_on_external_contract.snap index 66b7a19efb..e390932ebb 100644 --- a/crates/analyzer/tests/snapshots/errors__call_call_on_external_contract.snap +++ b/crates/analyzer/tests/snapshots/errors__call_call_on_external_contract.snap @@ -4,10 +4,10 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `__call__()` is not directly callable - ┌─ compile_errors/call_call_on_external_contract.fe:13:9 + ┌─ compile_errors/call_call_on_external_contract.fe:12:13 │ -13 │ foo.__call__() - │ ^^^^^^^^ +12 │ foo.__call__() + │ ^^^^^^^^ │ = Note: `__call__` is not part of the contract's interface, and can't be called. diff --git a/crates/analyzer/tests/snapshots/errors__call_call_on_self.snap b/crates/analyzer/tests/snapshots/errors__call_call_on_self.snap index b313abce71..d0e16c98e5 100644 --- a/crates/analyzer/tests/snapshots/errors__call_call_on_self.snap +++ b/crates/analyzer/tests/snapshots/errors__call_call_on_self.snap @@ -4,10 +4,10 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `__call__()` is not directly callable - ┌─ compile_errors/call_call_on_self.fe:6:10 + ┌─ compile_errors/call_call_on_self.fe:5:14 │ -6 │ self.__call__() - │ ^^^^^^^^ +5 │ self.__call__() + │ ^^^^^^^^ │ = Note: `__call__` is not part of the contract's interface, and can't be called. diff --git a/crates/analyzer/tests/snapshots/errors__call_create2_with_wrong_type.snap b/crates/analyzer/tests/snapshots/errors__call_create2_with_wrong_type.snap index e410afaf2d..c2fb8837e6 100644 --- a/crates/analyzer/tests/snapshots/errors__call_create2_with_wrong_type.snap +++ b/crates/analyzer/tests/snapshots/errors__call_create2_with_wrong_type.snap @@ -4,25 +4,25 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: incorrect type for argument to `Bar.create2` - ┌─ compile_errors/call_create2_with_wrong_type.fe:9:26 + ┌─ compile_errors/call_create2_with_wrong_type.fe:7:26 │ -9 │ Bar.create2(ctx, true, 1) +7 │ Bar.create2(ctx, true, 1) │ ^^^^ this has type `bool`; expected a number error: `create2` expects 3 arguments, but 2 were provided - ┌─ compile_errors/call_create2_with_wrong_type.fe:10:13 - │ -10 │ Bar.create2(ctx, 1) # agroce #447 - │ ^^^^^^^ --- - supplied 2 arguments - │ │ - │ expects 3 arguments + ┌─ compile_errors/call_create2_with_wrong_type.fe:8:13 + │ +8 │ Bar.create2(ctx, 1) # agroce #447 + │ ^^^^^^^ --- - supplied 2 arguments + │ │ + │ expects 3 arguments error: `create2` expects 3 arguments, but 1 was provided - ┌─ compile_errors/call_create2_with_wrong_type.fe:11:13 - │ -11 │ Bar.create2(ctx) - │ ^^^^^^^ --- supplied 1 argument - │ │ - │ expects 3 arguments + ┌─ compile_errors/call_create2_with_wrong_type.fe:9:13 + │ +9 │ Bar.create2(ctx) + │ ^^^^^^^ --- supplied 1 argument + │ │ + │ expects 3 arguments diff --git a/crates/analyzer/tests/snapshots/errors__call_create_with_wrong_type.snap b/crates/analyzer/tests/snapshots/errors__call_create_with_wrong_type.snap index 2583a8c8ff..47dabbc1d9 100644 --- a/crates/analyzer/tests/snapshots/errors__call_create_with_wrong_type.snap +++ b/crates/analyzer/tests/snapshots/errors__call_create_with_wrong_type.snap @@ -4,15 +4,15 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: incorrect type for argument to `Bar.create` - ┌─ compile_errors/call_create_with_wrong_type.fe:8:25 + ┌─ compile_errors/call_create_with_wrong_type.fe:7:25 │ -8 │ Bar.create(ctx, true) +7 │ Bar.create(ctx, true) │ ^^^^ this has type `bool`; expected a number error: `create` expects 2 arguments, but 1 was provided - ┌─ compile_errors/call_create_with_wrong_type.fe:9:13 + ┌─ compile_errors/call_create_with_wrong_type.fe:8:13 │ -9 │ Bar.create(ctx) # agroce #447 +8 │ Bar.create(ctx) # agroce #447 │ ^^^^^^ --- supplied 1 argument │ │ │ expects 2 arguments diff --git a/crates/analyzer/tests/snapshots/errors__call_duplicate_def.snap b/crates/analyzer/tests/snapshots/errors__call_duplicate_def.snap index f26b02e5df..05cb820590 100644 --- a/crates/analyzer/tests/snapshots/errors__call_duplicate_def.snap +++ b/crates/analyzer/tests/snapshots/errors__call_duplicate_def.snap @@ -5,17 +5,18 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `fn __call__()` is defined multiple times in `contract Foo` ┌─ compile_errors/call_duplicate_def.fe:2:5 - │ - 2 │ ╭ pub fn __call__(): - 3 │ │ pass - │ ╰────────────────^ `__call__` first defined here - · │ - 8 │ ╭ pub fn __call__(): - 9 │ │ 1 + 2 - │ ╰───────────────' `__call__` redefined here -10 │ -11 │ ╭ pub fn __call__(): -12 │ │ 3 + 4 - │ ╰─────────────' `__call__` redefined here + │ + 2 │ pub fn __call__() {} + │ ^^^^^^^^^^^^^^^^^^^^ `__call__` first defined here + · + 6 │ ╭ pub fn __call__() { + 7 │ │ 1 + 2 + 8 │ │ } + │ ╰───────' `__call__` redefined here + 9 │ +10 │ ╭ pub fn __call__() { +11 │ │ 3 + 4 +12 │ │ } + │ ╰─────' `__call__` redefined here diff --git a/crates/analyzer/tests/snapshots/errors__call_event_with_wrong_types.snap b/crates/analyzer/tests/snapshots/errors__call_event_with_wrong_types.snap index 0758375f42..561556a3da 100644 --- a/crates/analyzer/tests/snapshots/errors__call_event_with_wrong_types.snap +++ b/crates/analyzer/tests/snapshots/errors__call_event_with_wrong_types.snap @@ -4,15 +4,15 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: incorrect type for `MyEvent` argument `val_1` - ┌─ compile_errors/call_event_with_wrong_types.fe:9:34 - │ -9 │ emit MyEvent(ctx, val_1: "foo bar", val_2: 1000) - │ ^^^^^^^^^ this has type `String<7>`; expected type `String<5>` + ┌─ compile_errors/call_event_with_wrong_types.fe:10:34 + │ +10 │ emit MyEvent(ctx, val_1: "foo bar", val_2: 1000) + │ ^^^^^^^^^ this has type `String<7>`; expected type `String<5>` error: literal out of range for `u8` - ┌─ compile_errors/call_event_with_wrong_types.fe:9:52 - │ -9 │ emit MyEvent(ctx, val_1: "foo bar", val_2: 1000) - │ ^^^^ does not fit into type `u8` + ┌─ compile_errors/call_event_with_wrong_types.fe:10:52 + │ +10 │ emit MyEvent(ctx, val_1: "foo bar", val_2: 1000) + │ ^^^^ does not fit into type `u8` diff --git a/crates/analyzer/tests/snapshots/errors__call_non_pub_fn_on_external_contract.snap b/crates/analyzer/tests/snapshots/errors__call_non_pub_fn_on_external_contract.snap index 08f85c4dcb..a902afe449 100644 --- a/crates/analyzer/tests/snapshots/errors__call_non_pub_fn_on_external_contract.snap +++ b/crates/analyzer/tests/snapshots/errors__call_non_pub_fn_on_external_contract.snap @@ -4,13 +4,14 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: the function `do_private_thingz` on `contract Foo` is private - ┌─ compile_errors/call_non_pub_fn_on_external_contract.fe:10:26 + ┌─ compile_errors/call_non_pub_fn_on_external_contract.fe:13:30 │ - 5 │ ╭ fn do_private_thingz(self): - 6 │ │ self.val = 100 - │ ╰───────────────────' `do_private_thingz` is defined here + 6 │ ╭ fn do_private_thingz(self) { + 7 │ │ self.val = 100 + 8 │ │ } + │ ╰─────' `do_private_thingz` is defined here · │ -10 │ Foo(ctx, address(0)).do_private_thingz() - │ ^^^^^^^^^^^^^^^^^ this function is not `pub` +13 │ Foo(ctx, address(0)).do_private_thingz() + │ ^^^^^^^^^^^^^^^^^ this function is not `pub` diff --git a/crates/analyzer/tests/snapshots/errors__call_static_function_without_double_colon.snap b/crates/analyzer/tests/snapshots/errors__call_static_function_without_double_colon.snap index 2a1ba20623..78e443efdf 100644 --- a/crates/analyzer/tests/snapshots/errors__call_static_function_without_double_colon.snap +++ b/crates/analyzer/tests/snapshots/errors__call_static_function_without_double_colon.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: Static functions need to be called with `::` not `.` - ┌─ compile_errors/call_static_function_without_double_colon.fe:8:13 + ┌─ compile_errors/call_static_function_without_double_colon.fe:7:13 │ -8 │ Bar.call_me() +7 │ Bar.call_me() │ ^^^^^^^ This is a static function (doesn't take a `self` parameter) │ = Try `Bar::call_me(...)` instead diff --git a/crates/analyzer/tests/snapshots/errors__call_to_mut_fn_without_self.snap b/crates/analyzer/tests/snapshots/errors__call_to_mut_fn_without_self.snap index cb49d062c3..66dbbdf1d6 100644 --- a/crates/analyzer/tests/snapshots/errors__call_to_mut_fn_without_self.snap +++ b/crates/analyzer/tests/snapshots/errors__call_to_mut_fn_without_self.snap @@ -8,8 +8,8 @@ error: `baz` must be called via `self` │ 3 │ baz() │ ^^^ `baz` is called here as a standalone function -4 │ -5 │ fn baz(self): + · +6 │ fn baz(self) {} │ ^^^ `baz` is defined here as a function that takes `self` │ = Suggestion: use `self.baz(...)` instead of `baz(...)` diff --git a/crates/analyzer/tests/snapshots/errors__call_to_pure_fn_on_self.snap b/crates/analyzer/tests/snapshots/errors__call_to_pure_fn_on_self.snap index 27625c0ab9..0fe9a4c629 100644 --- a/crates/analyzer/tests/snapshots/errors__call_to_pure_fn_on_self.snap +++ b/crates/analyzer/tests/snapshots/errors__call_to_pure_fn_on_self.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `pure` must be called without `self` - ┌─ compile_errors/call_to_pure_fn_on_self.fe:6:14 + ┌─ compile_errors/call_to_pure_fn_on_self.fe:5:14 │ -6 │ self.pure() +5 │ self.pure() │ ^^^^ function does not take self │ = Suggestion: try `pure(...)` instead of `self.pure(...)` diff --git a/crates/analyzer/tests/snapshots/errors__call_undefined_function_on_external_contract.snap b/crates/analyzer/tests/snapshots/errors__call_undefined_function_on_external_contract.snap index 1e1dd874b0..efbbf739ad 100644 --- a/crates/analyzer/tests/snapshots/errors__call_undefined_function_on_external_contract.snap +++ b/crates/analyzer/tests/snapshots/errors__call_undefined_function_on_external_contract.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: No function `doesnt_exist` exists on type `Foo` - ┌─ compile_errors/call_undefined_function_on_external_contract.fe:8:26 + ┌─ compile_errors/call_undefined_function_on_external_contract.fe:9:30 │ -8 │ Foo(ctx, address(0)).doesnt_exist() - │ ^^^^^^^^^^^^ undefined function +9 │ Foo(ctx, address(0)).doesnt_exist() + │ ^^^^^^^^^^^^ undefined function diff --git a/crates/analyzer/tests/snapshots/errors__call_undefined_function_on_memory_struct.snap b/crates/analyzer/tests/snapshots/errors__call_undefined_function_on_memory_struct.snap index d3b75a66c5..afbd0f442f 100644 --- a/crates/analyzer/tests/snapshots/errors__call_undefined_function_on_memory_struct.snap +++ b/crates/analyzer/tests/snapshots/errors__call_undefined_function_on_memory_struct.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: No function `doesnt_exist` exists on type `Something` - ┌─ compile_errors/call_undefined_function_on_memory_struct.fe:7:12 + ┌─ compile_errors/call_undefined_function_on_memory_struct.fe:8:16 │ -7 │ thingy.doesnt_exist() - │ ^^^^^^^^^^^^ undefined function +8 │ thingy.doesnt_exist() + │ ^^^^^^^^^^^^ undefined function diff --git a/crates/analyzer/tests/snapshots/errors__call_undefined_function_on_storage_struct.snap b/crates/analyzer/tests/snapshots/errors__call_undefined_function_on_storage_struct.snap index 07d7d0c7d7..c315608b0e 100644 --- a/crates/analyzer/tests/snapshots/errors__call_undefined_function_on_storage_struct.snap +++ b/crates/analyzer/tests/snapshots/errors__call_undefined_function_on_storage_struct.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: No function `doesnt_exist` exists on type `Something` - ┌─ compile_errors/call_undefined_function_on_storage_struct.fe:8:17 + ┌─ compile_errors/call_undefined_function_on_storage_struct.fe:9:21 │ -8 │ self.thingy.doesnt_exist() - │ ^^^^^^^^^^^^ undefined function +9 │ self.thingy.doesnt_exist() + │ ^^^^^^^^^^^^ undefined function diff --git a/crates/analyzer/tests/snapshots/errors__call_with_pub_fns.snap b/crates/analyzer/tests/snapshots/errors__call_with_pub_fns.snap index b3f1696a2e..726a854650 100644 --- a/crates/analyzer/tests/snapshots/errors__call_with_pub_fns.snap +++ b/crates/analyzer/tests/snapshots/errors__call_with_pub_fns.snap @@ -4,29 +4,27 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `pub` not allowed if `__call__` is defined - ┌─ compile_errors/call_with_pub_fns.fe:8:12 - │ -2 │ ╭ pub fn __call__(): -3 │ │ pass - │ ╰────────────' `__call__` defined here - · │ -8 │ pub fn baz(): - │ ^^^ `baz` can't be public - │ + ┌─ compile_errors/call_with_pub_fns.fe:6:12 + │ +2 │ pub fn __call__() {} + │ -------------------- `__call__` defined here + · +6 │ pub fn baz() {} + │ ^^^ `baz` can't be public + │ = The `__call__` function replaces the default function dispatcher, which makes `pub` modifiers obsolete. = Hint: Remove the `pub` modifier or `__call__` function. error: `pub` not allowed if `__call__` is defined - ┌─ compile_errors/call_with_pub_fns.fe:11:12 - │ - 2 │ ╭ pub fn __call__(): - 3 │ │ pass - │ ╰────────────' `__call__` defined here - · │ -11 │ pub fn bing(): - │ ^^^^ `bing` can't be public - │ - = The `__call__` function replaces the default function dispatcher, which makes `pub` modifiers obsolete. - = Hint: Remove the `pub` modifier or `__call__` function. + ┌─ compile_errors/call_with_pub_fns.fe:8:12 + │ +2 │ pub fn __call__() {} + │ -------------------- `__call__` defined here + · +8 │ pub fn bing() {} + │ ^^^^ `bing` can't be public + │ + = The `__call__` function replaces the default function dispatcher, which makes `pub` modifiers obsolete. + = Hint: Remove the `pub` modifier or `__call__` function. diff --git a/crates/analyzer/tests/snapshots/errors__call_wrong_return_type.snap b/crates/analyzer/tests/snapshots/errors__call_wrong_return_type.snap index a560426a9f..e27799efb5 100644 --- a/crates/analyzer/tests/snapshots/errors__call_wrong_return_type.snap +++ b/crates/analyzer/tests/snapshots/errors__call_wrong_return_type.snap @@ -6,7 +6,7 @@ expression: "error_string(&path, test_files::fixture(path))" error: `__call__` function has incorrect return type ┌─ compile_errors/call_wrong_return_type.fe:2:26 │ -2 │ pub fn __call__() -> u64: +2 │ pub fn __call__() -> u64 { │ ^^^ return type should be `()` │ = Hint: Remove the return type specification. diff --git a/crates/analyzer/tests/snapshots/errors__cannot_move2.snap b/crates/analyzer/tests/snapshots/errors__cannot_move2.snap index 05ce089651..d2b7c30b9c 100644 --- a/crates/analyzer/tests/snapshots/errors__cannot_move2.snap +++ b/crates/analyzer/tests/snapshots/errors__cannot_move2.snap @@ -4,10 +4,10 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: can't move value onto stack - ┌─ compile_errors/cannot_move2.fe:6:30 + ┌─ compile_errors/cannot_move2.fe:5:34 │ -6 │ let c: Array = x + y - │ ^ Value to be moved +5 │ let c: Array = x + y + │ ^ Value to be moved │ = Note: Can't move `Array` types on the stack diff --git a/crates/analyzer/tests/snapshots/errors__circular_type_alias.snap b/crates/analyzer/tests/snapshots/errors__circular_type_alias.snap index 114812d2d3..8f7afb71ed 100644 --- a/crates/analyzer/tests/snapshots/errors__circular_type_alias.snap +++ b/crates/analyzer/tests/snapshots/errors__circular_type_alias.snap @@ -10,15 +10,15 @@ error: recursive type definition │ ^^^^^^^^^^^^^^^^^^^^^^^^ error: recursive type definition - ┌─ compile_errors/circular_type_alias.fe:2:1 + ┌─ compile_errors/circular_type_alias.fe:3:1 │ -2 │ type B = Map +3 │ type B = Map │ ^^^^^^^^^^^^^^^^^^^^^^^^ error: recursive type definition - ┌─ compile_errors/circular_type_alias.fe:3:1 + ┌─ compile_errors/circular_type_alias.fe:5:1 │ -3 │ type C = Map +5 │ type C = Map │ ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/crates/analyzer/tests/snapshots/errors__const_assign.snap b/crates/analyzer/tests/snapshots/errors__const_assign.snap index 8da2057284..bb7d1cf627 100644 --- a/crates/analyzer/tests/snapshots/errors__const_assign.snap +++ b/crates/analyzer/tests/snapshots/errors__const_assign.snap @@ -12,11 +12,11 @@ error: invalid assignment target = The left side of an assignment can be a variable name, attribute, subscript, or tuple. error: cannot assign to constant variable - ┌─ compile_errors/const_assign.fe:9:9 - │ -9 │ LOCAL = 1 - │ ^^^^^ - │ - = The left side of an assignment can be a variable name, attribute, subscript, or tuple. + ┌─ compile_errors/const_assign.fe:10:9 + │ +10 │ LOCAL = 1 + │ ^^^^^ + │ + = The left side of an assignment can be a variable name, attribute, subscript, or tuple. diff --git a/crates/analyzer/tests/snapshots/errors__const_generics_param.snap b/crates/analyzer/tests/snapshots/errors__const_generics_param.snap index dbf04f8584..d20909281e 100644 --- a/crates/analyzer/tests/snapshots/errors__const_generics_param.snap +++ b/crates/analyzer/tests/snapshots/errors__const_generics_param.snap @@ -10,33 +10,33 @@ error: expression is not a constant │ ^^^^^^ expression is required to be constant here error: feature not yet implemented: non numeric type const generics - ┌─ compile_errors/const_generics_param.fe:6:33 + ┌─ compile_errors/const_generics_param.fe:7:33 │ -6 │ let array: Array +7 │ let array: Array │ ^^^^^ not yet implemented error: zero division error - ┌─ compile_errors/const_generics_param.fe:9:38 - │ -9 │ let array: Array - │ ^^^^^ zero division occurred during constant evaluation + ┌─ compile_errors/const_generics_param.fe:11:38 + │ +11 │ let array: Array + │ ^^^^^ zero division occurred during constant evaluation error: zero division error - ┌─ compile_errors/const_generics_param.fe:12:38 + ┌─ compile_errors/const_generics_param.fe:15:38 │ -12 │ let array: Array +15 │ let array: Array │ ^^^^^ zero division occurred during constant evaluation error: overflow error - ┌─ compile_errors/const_generics_param.fe:15:33 + ┌─ compile_errors/const_generics_param.fe:19:33 │ -15 │ let array: Array +19 │ let array: Array │ ^^^^^^^^ overflow occurred during constant evaluation error: overflow error - ┌─ compile_errors/const_generics_param.fe:18:33 + ┌─ compile_errors/const_generics_param.fe:23:33 │ -18 │ let array: Array +23 │ let array: Array │ ^^^^^ overflow occurred during constant evaluation diff --git a/crates/analyzer/tests/snapshots/errors__const_local.snap b/crates/analyzer/tests/snapshots/errors__const_local.snap index 3292d90b9a..da94937890 100644 --- a/crates/analyzer/tests/snapshots/errors__const_local.snap +++ b/crates/analyzer/tests/snapshots/errors__const_local.snap @@ -10,33 +10,33 @@ error: expression is not a constant │ ^^^^^^ expression is required to be constant here error: expression is not a constant - ┌─ compile_errors/const_local.fe:7:25 + ┌─ compile_errors/const_local.fe:8:26 │ -7 │ const FOO:i32 = foo + 1 - │ ^^^ expression is required to be constant here +8 │ const FOO: i32 = foo + 1 + │ ^^^ expression is required to be constant here error: overflow error - ┌─ compile_errors/const_local.fe:12:26 + ┌─ compile_errors/const_local.fe:14:26 │ -12 │ const FOO3: u8 = FOO1 + FOO2 +14 │ const FOO3: u8 = FOO1 + FOO2 │ ^^^^^^^^^^^ overflow occurred during constant evaluation error: cannot find value `BAR` in this scope - ┌─ compile_errors/const_local.fe:15:25 + ┌─ compile_errors/const_local.fe:18:25 │ -15 │ const FOO: u8 = BAR +18 │ const FOO: u8 = BAR │ ^^^ undefined error: expression is not a constant - ┌─ compile_errors/const_local.fe:15:25 + ┌─ compile_errors/const_local.fe:18:25 │ -15 │ const FOO: u8 = BAR +18 │ const FOO: u8 = BAR │ ^^^ expression is required to be constant here error: type mismatch - ┌─ compile_errors/const_local.fe:18:26 + ┌─ compile_errors/const_local.fe:22:26 │ -18 │ const FOO: i32 = "FOO" +22 │ const FOO: i32 = "FOO" │ ^^^^^ this has type `String<3>`; expected type `i32` diff --git a/crates/analyzer/tests/snapshots/errors__continue_without_loop_2.snap b/crates/analyzer/tests/snapshots/errors__continue_without_loop_2.snap index bc1e082a14..f9850a8dd8 100644 --- a/crates/analyzer/tests/snapshots/errors__continue_without_loop_2.snap +++ b/crates/analyzer/tests/snapshots/errors__continue_without_loop_2.snap @@ -4,9 +4,9 @@ expression: "error_string(\"[snippet]\", &src)" --- error: `continue` outside of a loop - ┌─ [snippet]:4:5 + ┌─ [snippet]:3:13 │ -4 │ continue - │ ^^^^^^^^ `continue` can only be used inside of a `for` or `while` loop +3 │ if true { continue } + │ ^^^^^^^^ `continue` can only be used inside of a `for` or `while` loop diff --git a/crates/analyzer/tests/snapshots/errors__ctx_builtins_param_incorrect_type.snap b/crates/analyzer/tests/snapshots/errors__ctx_builtins_param_incorrect_type.snap index 962225fc10..385926345b 100644 --- a/crates/analyzer/tests/snapshots/errors__ctx_builtins_param_incorrect_type.snap +++ b/crates/analyzer/tests/snapshots/errors__ctx_builtins_param_incorrect_type.snap @@ -4,29 +4,29 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: type mismatch - ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:12:40 + ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:13:40 │ -12 │ let existing_barn: Barn = Barn("hello world", address(0)) +13 │ let existing_barn: Barn = Barn("hello world", address(0)) │ ^^^^^^^^^^^^^ this has type `String<11>`; expected type `Context` error: incorrect type for argument to `Barn.create` - ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:13:46 + ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:14:46 │ -13 │ let created_barn: Barn = Barn.create(address(26), 0) +14 │ let created_barn: Barn = Barn.create(address(26), 0) │ ^^^^^^^^^^^ this has type `address`; expected `Context` error: missing argument label - ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:14:27 + ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:15:27 │ -14 │ emit WorldMessage(42, message: "hello world") +15 │ emit WorldMessage(42, message: "hello world") │ ^ add `ctx:` here │ = Note: this label is optional if the argument is a variable named `ctx`. error: incorrect type for `WorldMessage` argument `ctx` - ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:14:27 + ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:15:27 │ -14 │ emit WorldMessage(42, message: "hello world") +15 │ emit WorldMessage(42, message: "hello world") │ ^^ this has type `u256`; expected type `Context` diff --git a/crates/analyzer/tests/snapshots/errors__ctx_missing_event.snap b/crates/analyzer/tests/snapshots/errors__ctx_missing_event.snap index 9edab54d21..0004a26eb3 100644 --- a/crates/analyzer/tests/snapshots/errors__ctx_missing_event.snap +++ b/crates/analyzer/tests/snapshots/errors__ctx_missing_event.snap @@ -4,25 +4,25 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `HelloWorld` expects 2 arguments, but 1 was provided - ┌─ compile_errors/ctx_missing_event.fe:8:14 + ┌─ compile_errors/ctx_missing_event.fe:9:14 │ -8 │ emit HelloWorld(message: "hello world") +9 │ emit HelloWorld(message: "hello world") │ ^^^^^^^^^^ ---------------------- supplied 1 argument │ │ │ expects 2 arguments error: argument label mismatch - ┌─ compile_errors/ctx_missing_event.fe:8:25 + ┌─ compile_errors/ctx_missing_event.fe:9:25 │ -8 │ emit HelloWorld(message: "hello world") +9 │ emit HelloWorld(message: "hello world") │ ^^^^^^^ expected `ctx` │ = Note: arguments must be provided in order. error: incorrect type for `HelloWorld` argument `ctx` - ┌─ compile_errors/ctx_missing_event.fe:8:34 + ┌─ compile_errors/ctx_missing_event.fe:9:34 │ -8 │ emit HelloWorld(message: "hello world") +9 │ emit HelloWorld(message: "hello world") │ ^^^^^^^^^^^^^ this has type `String<11>`; expected type `Context` diff --git a/crates/analyzer/tests/snapshots/errors__ctx_missing_internal_call.snap b/crates/analyzer/tests/snapshots/errors__ctx_missing_internal_call.snap index 9b291de008..c8b1be4a84 100644 --- a/crates/analyzer/tests/snapshots/errors__ctx_missing_internal_call.snap +++ b/crates/analyzer/tests/snapshots/errors__ctx_missing_internal_call.snap @@ -6,10 +6,10 @@ expression: "error_string(&path, test_files::fixture(path))" error: `bar` expects 1 argument, but 0 were provided ┌─ compile_errors/ctx_missing_internal_call.fe:6:12 │ - 6 │ pub fn bar(ctx: Context) -> u256: + 6 │ pub fn bar(ctx: Context) -> u256 { │ ^^^ expects 1 argument · -10 │ self.favorite_number = bar() +11 │ self.favorite_number = bar() │ -- supplied 0 arguments diff --git a/crates/analyzer/tests/snapshots/errors__ctx_not_after_self.snap b/crates/analyzer/tests/snapshots/errors__ctx_not_after_self.snap index fb78cee931..14d003954c 100644 --- a/crates/analyzer/tests/snapshots/errors__ctx_not_after_self.snap +++ b/crates/analyzer/tests/snapshots/errors__ctx_not_after_self.snap @@ -6,7 +6,7 @@ expression: "error_string(&path, test_files::fixture(path))" error: invalid parameter order ┌─ compile_errors/ctx_not_after_self.fe:4:33 │ -4 │ pub fn bar(self, baz: u256, ctx: Context): +4 │ pub fn bar(self, baz: u256, ctx: Context) {} │ ^^^^^^^^^^^^ `ctx: Context` must be placed after the `self` parameter diff --git a/crates/analyzer/tests/snapshots/errors__ctx_not_first.snap b/crates/analyzer/tests/snapshots/errors__ctx_not_first.snap index fcd6bbf4a3..3405fa141d 100644 --- a/crates/analyzer/tests/snapshots/errors__ctx_not_first.snap +++ b/crates/analyzer/tests/snapshots/errors__ctx_not_first.snap @@ -6,7 +6,7 @@ expression: "error_string(&path, test_files::fixture(path))" error: invalid parameter order ┌─ compile_errors/ctx_not_first.fe:4:27 │ -4 │ pub fn bar(baz: u256, ctx: Context): +4 │ pub fn bar(baz: u256, ctx: Context) {} │ ^^^^^^^^^^^^ `ctx: Context` must be the first parameter diff --git a/crates/analyzer/tests/snapshots/errors__ctx_passed_external_call.snap b/crates/analyzer/tests/snapshots/errors__ctx_passed_external_call.snap index ae0746c083..8db02d3720 100644 --- a/crates/analyzer/tests/snapshots/errors__ctx_passed_external_call.snap +++ b/crates/analyzer/tests/snapshots/errors__ctx_passed_external_call.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `bar` expects 0 arguments, but 1 was provided - ┌─ compile_errors/ctx_passed_external_call.fe:13:36 + ┌─ compile_errors/ctx_passed_external_call.fe:14:36 │ -13 │ self.favorite_number = foo.bar(ctx) +14 │ self.favorite_number = foo.bar(ctx) │ ^^^ --- supplied 1 argument │ │ │ expects 0 arguments diff --git a/crates/analyzer/tests/snapshots/errors__ctx_pure.snap b/crates/analyzer/tests/snapshots/errors__ctx_pure.snap index 2d52ec142b..7c371844c2 100644 --- a/crates/analyzer/tests/snapshots/errors__ctx_pure.snap +++ b/crates/analyzer/tests/snapshots/errors__ctx_pure.snap @@ -6,7 +6,7 @@ expression: "error_string(&path, test_files::fixture(path))" error: `ctx` cannot be passed into pure functions ┌─ compile_errors/ctx_pure.fe:3:12 │ -3 │ pub fn foo(ctx: Context): +3 │ pub fn foo(ctx: Context) {} │ ^^^^^^^^^^^^ `ctx` can only be passed into contract functions diff --git a/crates/analyzer/tests/snapshots/errors__ctx_undefined_contract_init.snap b/crates/analyzer/tests/snapshots/errors__ctx_undefined_contract_init.snap index bb869f1b53..ffefd35073 100644 --- a/crates/analyzer/tests/snapshots/errors__ctx_undefined_contract_init.snap +++ b/crates/analyzer/tests/snapshots/errors__ctx_undefined_contract_init.snap @@ -4,22 +4,22 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `Bar` expects 2 arguments, but 1 was provided - ┌─ compile_errors/ctx_undefined_contract_init.fe:6:9 + ┌─ compile_errors/ctx_undefined_contract_init.fe:5:9 │ -6 │ Bar(address(0)) +5 │ Bar(address(0)) │ ^^^ ---------- supplied 1 argument │ │ │ expects 2 arguments error: `Context` is not defined - ┌─ compile_errors/ctx_undefined_contract_init.fe:6:12 + ┌─ compile_errors/ctx_undefined_contract_init.fe:5:12 │ -5 │ pub fn baz(): +4 │ pub fn baz() { │ --- │ │ │ Note: declare `ctx` in this function signature │ Example: `pub fn foo(ctx: Context, ...)` -6 │ Bar(address(0)) +5 │ Bar(address(0)) │ ^^^^^^^^^^^^ `ctx` must be defined and passed into the contract constructor │ = Note: import context with `use std::context::Context` diff --git a/crates/analyzer/tests/snapshots/errors__ctx_undefined_create.snap b/crates/analyzer/tests/snapshots/errors__ctx_undefined_create.snap index 70aeb08ff8..3086aec51b 100644 --- a/crates/analyzer/tests/snapshots/errors__ctx_undefined_create.snap +++ b/crates/analyzer/tests/snapshots/errors__ctx_undefined_create.snap @@ -4,22 +4,22 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `create` expects 2 arguments, but 1 was provided - ┌─ compile_errors/ctx_undefined_create.fe:6:13 + ┌─ compile_errors/ctx_undefined_create.fe:5:13 │ -6 │ Bar.create(0) +5 │ Bar.create(0) │ ^^^^^^ - supplied 1 argument │ │ │ expects 2 arguments error: `Context` is not defined - ┌─ compile_errors/ctx_undefined_create.fe:6:19 + ┌─ compile_errors/ctx_undefined_create.fe:5:19 │ -5 │ pub fn baz(): +4 │ pub fn baz() { │ --- │ │ │ Note: declare `ctx` in this function signature │ Example: `pub fn foo(ctx: Context, ...)` -6 │ Bar.create(0) +5 │ Bar.create(0) │ ^^^ `ctx` must be defined and passed into the function │ = Note: import context with `use std::context::Context` diff --git a/crates/analyzer/tests/snapshots/errors__ctx_undefined_create2.snap b/crates/analyzer/tests/snapshots/errors__ctx_undefined_create2.snap index 30e40fce29..af6fca9109 100644 --- a/crates/analyzer/tests/snapshots/errors__ctx_undefined_create2.snap +++ b/crates/analyzer/tests/snapshots/errors__ctx_undefined_create2.snap @@ -4,22 +4,22 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `create2` expects 3 arguments, but 2 were provided - ┌─ compile_errors/ctx_undefined_create2.fe:6:13 + ┌─ compile_errors/ctx_undefined_create2.fe:5:13 │ -6 │ Bar.create2(0, 0) +5 │ Bar.create2(0, 0) │ ^^^^^^^ - - supplied 2 arguments │ │ │ expects 3 arguments error: `Context` is not defined - ┌─ compile_errors/ctx_undefined_create2.fe:6:20 + ┌─ compile_errors/ctx_undefined_create2.fe:5:20 │ -5 │ pub fn baz(): +4 │ pub fn baz() { │ --- │ │ │ Note: declare `ctx` in this function signature │ Example: `pub fn foo(ctx: Context, ...)` -6 │ Bar.create2(0, 0) +5 │ Bar.create2(0, 0) │ ^^^^^^ `ctx` must be defined and passed into the function │ = Note: import context with `use std::context::Context` diff --git a/crates/analyzer/tests/snapshots/errors__ctx_undefined_event.snap b/crates/analyzer/tests/snapshots/errors__ctx_undefined_event.snap index ea7825bef0..056d03b5fe 100644 --- a/crates/analyzer/tests/snapshots/errors__ctx_undefined_event.snap +++ b/crates/analyzer/tests/snapshots/errors__ctx_undefined_event.snap @@ -4,14 +4,14 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `Context` is not defined - ┌─ compile_errors/ctx_undefined_event.fe:6:9 + ┌─ compile_errors/ctx_undefined_event.fe:7:9 │ -5 │ pub fn bar(): +6 │ pub fn bar() { │ --- │ │ │ Note: declare `ctx` in this function signature │ Example: `pub fn foo(ctx: Context, ...)` -6 │ emit YouWin(amount: 42) +7 │ emit YouWin(amount: 42) │ ^^^^^^^^^^^^^^^^^^^^^^^ `ctx` must be defined and passed into the event │ = Note: import context with `use std::context::Context` diff --git a/crates/analyzer/tests/snapshots/errors__duplicate_arg_in_contract_method.snap b/crates/analyzer/tests/snapshots/errors__duplicate_arg_in_contract_method.snap index 92b81b2b42..7edf0596ad 100644 --- a/crates/analyzer/tests/snapshots/errors__duplicate_arg_in_contract_method.snap +++ b/crates/analyzer/tests/snapshots/errors__duplicate_arg_in_contract_method.snap @@ -6,8 +6,8 @@ expression: "error_string(&path, test_files::fixture(path))" error: duplicate parameter names in function `bar` ┌─ compile_errors/duplicate_arg_in_contract_method.fe:2:16 │ -2 │ pub fn bar(foo: u8, foo:u8): - │ ^^^^^^^ ------ `foo` redefined here +2 │ pub fn bar(foo: u8, foo: u8) {} + │ ^^^^^^^ ------- `foo` redefined here │ │ │ `foo` first defined here diff --git a/crates/analyzer/tests/snapshots/errors__duplicate_contract_in_module.snap b/crates/analyzer/tests/snapshots/errors__duplicate_contract_in_module.snap index 1f9fa2f33e..33eb5301ed 100644 --- a/crates/analyzer/tests/snapshots/errors__duplicate_contract_in_module.snap +++ b/crates/analyzer/tests/snapshots/errors__duplicate_contract_in_module.snap @@ -6,10 +6,10 @@ expression: "error_string(&path, test_files::fixture(path))" error: a type named "Foo" has already been defined ┌─ compile_errors/duplicate_contract_in_module.fe:1:10 │ -1 │ contract Foo: +1 │ contract Foo { │ ^^^ `Foo` first defined here · -6 │ contract Foo: +5 │ contract Foo { │ --- `Foo` redefined here diff --git a/crates/analyzer/tests/snapshots/errors__duplicate_event_in_contract.snap b/crates/analyzer/tests/snapshots/errors__duplicate_event_in_contract.snap index 0c3d0fabb1..c9b1eb5daf 100644 --- a/crates/analyzer/tests/snapshots/errors__duplicate_event_in_contract.snap +++ b/crates/analyzer/tests/snapshots/errors__duplicate_event_in_contract.snap @@ -6,12 +6,14 @@ expression: "error_string(&path, test_files::fixture(path))" error: duplicate event names in `contract Foo` ┌─ compile_errors/duplicate_event_in_contract.fe:2:5 │ -2 │ ╭ event MyEvent: +2 │ ╭ event MyEvent { 3 │ │ idx addr1: address - │ ╰────────────────────────────^ `MyEvent` first defined here -4 │ -5 │ ╭ event MyEvent: -6 │ │ idx addr1: address - │ ╰──────────────────────────' `MyEvent` redefined here +4 │ │ } + │ ╰───────^ `MyEvent` first defined here +5 │ +6 │ ╭ event MyEvent { +7 │ │ idx addr1: address +8 │ │ } + │ ╰─────' `MyEvent` redefined here diff --git a/crates/analyzer/tests/snapshots/errors__duplicate_method_in_contract.snap b/crates/analyzer/tests/snapshots/errors__duplicate_method_in_contract.snap index 137d542ed3..27a058a630 100644 --- a/crates/analyzer/tests/snapshots/errors__duplicate_method_in_contract.snap +++ b/crates/analyzer/tests/snapshots/errors__duplicate_method_in_contract.snap @@ -4,14 +4,12 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: duplicate function names in `contract Foo` - ┌─ compile_errors/duplicate_method_in_contract.fe:3:5 - │ -3 │ ╭ pub fn bar(): -4 │ │ pass - │ ╰──────────────^ `bar` first defined here -5 │ -6 │ ╭ pub fn bar(): -7 │ │ pass - │ ╰────────────' `bar` redefined here + ┌─ compile_errors/duplicate_method_in_contract.fe:2:5 + │ +2 │ pub fn bar() {} + │ ^^^^^^^^^^^^^^^ `bar` first defined here +3 │ +4 │ pub fn bar() {} + │ --------------- `bar` redefined here diff --git a/crates/analyzer/tests/snapshots/errors__duplicate_struct_in_module.snap b/crates/analyzer/tests/snapshots/errors__duplicate_struct_in_module.snap index c31e482094..e22ae027da 100644 --- a/crates/analyzer/tests/snapshots/errors__duplicate_struct_in_module.snap +++ b/crates/analyzer/tests/snapshots/errors__duplicate_struct_in_module.snap @@ -6,10 +6,10 @@ expression: "error_string(&path, test_files::fixture(path))" error: a type named "MyStruct" has already been defined ┌─ compile_errors/duplicate_struct_in_module.fe:1:8 │ -1 │ struct MyStruct: +1 │ struct MyStruct { │ ^^^^^^^^ `MyStruct` first defined here · -4 │ struct MyStruct: +5 │ struct MyStruct { │ -------- `MyStruct` redefined here diff --git a/crates/analyzer/tests/snapshots/errors__duplicate_typedef_in_module.snap b/crates/analyzer/tests/snapshots/errors__duplicate_typedef_in_module.snap index 7cdaccc803..712590d674 100644 --- a/crates/analyzer/tests/snapshots/errors__duplicate_typedef_in_module.snap +++ b/crates/analyzer/tests/snapshots/errors__duplicate_typedef_in_module.snap @@ -4,21 +4,21 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: a type named "bar" has already been defined - ┌─ compile_errors/duplicate_typedef_in_module.fe:2:6 + ┌─ compile_errors/duplicate_typedef_in_module.fe:1:6 │ -2 │ type bar = u8 +1 │ type bar = u8 │ ^^^ `bar` first defined here -3 │ -4 │ type bar = u8 +2 │ +3 │ type bar = u8 │ --- `bar` redefined here error: function name `bar` conflicts with previously defined type - ┌─ compile_errors/duplicate_typedef_in_module.fe:2:6 + ┌─ compile_errors/duplicate_typedef_in_module.fe:1:6 │ -2 │ type bar = u8 +1 │ type bar = u8 │ ^^^ `bar` first defined here · -8 │ pub fn bar(): +6 │ pub fn bar() {} │ --- `bar` redefined here diff --git a/crates/analyzer/tests/snapshots/errors__duplicate_var_in_child_scope.snap b/crates/analyzer/tests/snapshots/errors__duplicate_var_in_child_scope.snap index 25ff2a735c..ec25eb8e9b 100644 --- a/crates/analyzer/tests/snapshots/errors__duplicate_var_in_child_scope.snap +++ b/crates/analyzer/tests/snapshots/errors__duplicate_var_in_child_scope.snap @@ -8,7 +8,7 @@ error: duplicate definition of variable `sum` │ 4 │ let sum: u256 = 0 │ ^^^ `sum` first defined here -5 │ for i in my_array: +5 │ for i in my_array { 6 │ let sum: u64 = 0 │ --- `sum` redefined here diff --git a/crates/analyzer/tests/snapshots/errors__duplicate_var_in_for_loop.snap b/crates/analyzer/tests/snapshots/errors__duplicate_var_in_for_loop.snap index facf7efcd3..39482d2c89 100644 --- a/crates/analyzer/tests/snapshots/errors__duplicate_var_in_for_loop.snap +++ b/crates/analyzer/tests/snapshots/errors__duplicate_var_in_for_loop.snap @@ -4,20 +4,20 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: duplicate definition of variable `x` - ┌─ compile_errors/duplicate_var_in_for_loop.fe:3:9 + ┌─ compile_errors/duplicate_var_in_for_loop.fe:3:13 │ -3 │ let x: u256 = 10 - │ ^ `x` first defined here +3 │ let x: u256 = 10 + │ ^ `x` first defined here · -7 │ for x in xs: - │ - `x` redefined here +6 │ for x in xs { + │ - `x` redefined here error: `+` operand types must be equal - ┌─ compile_errors/duplicate_var_in_for_loop.fe:8:7 + ┌─ compile_errors/duplicate_var_in_for_loop.fe:7:13 │ -8 │ sum += x - │ ^^^ ^ this has type `u256` - │ │ - │ this has type `u8` +7 │ sum += x + │ ^^^ ^ this has type `u256` + │ │ + │ this has type `u8` diff --git a/crates/analyzer/tests/snapshots/errors__emit_bad_args.snap b/crates/analyzer/tests/snapshots/errors__emit_bad_args.snap index 7098b810ed..da64b2371c 100644 --- a/crates/analyzer/tests/snapshots/errors__emit_bad_args.snap +++ b/crates/analyzer/tests/snapshots/errors__emit_bad_args.snap @@ -4,40 +4,40 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `Foo` expects 4 arguments, but 5 were provided - ┌─ compile_errors/emit_bad_args.fe:10:10 + ┌─ compile_errors/emit_bad_args.fe:11:14 │ -10 │ emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) - │ ^^^ --- ------ ----- ------- ---- supplied 5 arguments - │ │ - │ expects 4 arguments +11 │ emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) + │ ^^^ --- ------ ----- ------- ---- supplied 5 arguments + │ │ + │ expects 4 arguments error: missing argument label - ┌─ compile_errors/emit_bad_args.fe:10:19 + ┌─ compile_errors/emit_bad_args.fe:11:23 │ -10 │ emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) - │ ^ add `x:` here +11 │ emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) + │ ^ add `x:` here │ = Note: this label is optional if the argument is a variable named `x`. error: incorrect type for `Foo` argument `x` - ┌─ compile_errors/emit_bad_args.fe:10:19 + ┌─ compile_errors/emit_bad_args.fe:11:23 │ -10 │ emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) - │ ^^^^^^ this has type `(u256, u256)`; expected type `address` +11 │ emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) + │ ^^^^^^ this has type `(u256, u256)`; expected type `address` error: argument label mismatch - ┌─ compile_errors/emit_bad_args.fe:10:27 + ┌─ compile_errors/emit_bad_args.fe:11:31 │ -10 │ emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) - │ ^ expected `y` +11 │ emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) + │ ^ expected `y` │ = Note: arguments must be provided in order. error: argument label mismatch - ┌─ compile_errors/emit_bad_args.fe:10:34 + ┌─ compile_errors/emit_bad_args.fe:11:38 │ -10 │ emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) - │ ^ expected `z` +11 │ emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) + │ ^ expected `z` │ = Note: arguments must be provided in order. diff --git a/crates/analyzer/tests/snapshots/errors__for_loop_sto_iter_no_copy.snap b/crates/analyzer/tests/snapshots/errors__for_loop_sto_iter_no_copy.snap index 627a1ac05f..ae42c96f52 100644 --- a/crates/analyzer/tests/snapshots/errors__for_loop_sto_iter_no_copy.snap +++ b/crates/analyzer/tests/snapshots/errors__for_loop_sto_iter_no_copy.snap @@ -6,7 +6,7 @@ expression: "error_string(&path, test_files::fixture(path))" error: value must be copied to memory ┌─ compile_errors/for_loop_sto_iter_no_copy.fe:5:18 │ -5 │ for i in self.my_array: +5 │ for i in self.my_array { │ ^^^^^^^^^^^^^ this value is in storage │ = Hint: values located in storage can be copied to memory using the `to_mem` function. diff --git a/crates/analyzer/tests/snapshots/errors__init_call_on_external_contract.snap b/crates/analyzer/tests/snapshots/errors__init_call_on_external_contract.snap index 5abbb094a8..5f3d4a2d82 100644 --- a/crates/analyzer/tests/snapshots/errors__init_call_on_external_contract.snap +++ b/crates/analyzer/tests/snapshots/errors__init_call_on_external_contract.snap @@ -4,10 +4,10 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `__init__()` is not directly callable - ┌─ compile_errors/init_call_on_external_contract.fe:14:9 + ┌─ compile_errors/init_call_on_external_contract.fe:13:13 │ -14 │ foo.__init__() - │ ^^^^^^^^ +13 │ foo.__init__() + │ ^^^^^^^^ │ = Note: `__init__` is the constructor function, and can't be called at runtime. diff --git a/crates/analyzer/tests/snapshots/errors__init_call_on_self.snap b/crates/analyzer/tests/snapshots/errors__init_call_on_self.snap index f16850871f..ec3b41debc 100644 --- a/crates/analyzer/tests/snapshots/errors__init_call_on_self.snap +++ b/crates/analyzer/tests/snapshots/errors__init_call_on_self.snap @@ -4,10 +4,10 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `__init__()` is not directly callable - ┌─ compile_errors/init_call_on_self.fe:6:10 + ┌─ compile_errors/init_call_on_self.fe:5:14 │ -6 │ self.__init__() - │ ^^^^^^^^ +5 │ self.__init__() + │ ^^^^^^^^ │ = Note: `__init__` is the constructor function, and can't be called at runtime. diff --git a/crates/analyzer/tests/snapshots/errors__init_duplicate_def.snap b/crates/analyzer/tests/snapshots/errors__init_duplicate_def.snap index 9730de43f7..7cf87c27e1 100644 --- a/crates/analyzer/tests/snapshots/errors__init_duplicate_def.snap +++ b/crates/analyzer/tests/snapshots/errors__init_duplicate_def.snap @@ -5,17 +5,18 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `fn __init__()` is defined multiple times in `contract Foo` ┌─ compile_errors/init_duplicate_def.fe:2:5 - │ - 2 │ ╭ pub fn __init__(): - 3 │ │ pass - │ ╰────────────────^ `__init__` first defined here - · │ - 8 │ ╭ pub fn __init__(): - 9 │ │ 1 + 2 - │ ╰───────────────' `init` redefined here -10 │ -11 │ ╭ pub fn __init__(): -12 │ │ 3 + 4 - │ ╰─────────────' `__init__` redefined here + │ + 2 │ pub fn __init__() {} + │ ^^^^^^^^^^^^^^^^^^^^ `__init__` first defined here + · + 6 │ ╭ pub fn __init__() { + 7 │ │ 1 + 2 + 8 │ │ } + │ ╰───────' `init` redefined here + 9 │ +10 │ ╭ pub fn __init__() { +11 │ │ 3 + 4 +12 │ │ } + │ ╰─────' `__init__` redefined here diff --git a/crates/analyzer/tests/snapshots/errors__init_wrong_return_type.snap b/crates/analyzer/tests/snapshots/errors__init_wrong_return_type.snap index bc13f483c2..c08bc7e059 100644 --- a/crates/analyzer/tests/snapshots/errors__init_wrong_return_type.snap +++ b/crates/analyzer/tests/snapshots/errors__init_wrong_return_type.snap @@ -6,7 +6,7 @@ expression: "error_string(&path, test_files::fixture(path))" error: `__init__` function has incorrect return type ┌─ compile_errors/init_wrong_return_type.fe:2:26 │ -2 │ pub fn __init__() -> u64: +2 │ pub fn __init__() -> u64 { │ ^^^ return type should be `()` │ = Hint: Remove the return type specification. diff --git a/crates/analyzer/tests/snapshots/errors__invalid_block_field.snap b/crates/analyzer/tests/snapshots/errors__invalid_block_field.snap index 94d3554a7d..be764cc3b3 100644 --- a/crates/analyzer/tests/snapshots/errors__invalid_block_field.snap +++ b/crates/analyzer/tests/snapshots/errors__invalid_block_field.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: cannot find value `block` in this scope - ┌─ compile_errors/invalid_block_field.fe:4:5 + ┌─ compile_errors/invalid_block_field.fe:3:9 │ -4 │ block.foo - │ ^^^^^ undefined +3 │ block.foo + │ ^^^^^ undefined diff --git a/crates/analyzer/tests/snapshots/errors__invalid_chain_field.snap b/crates/analyzer/tests/snapshots/errors__invalid_chain_field.snap index 6b687f24b4..5b5b4bac5c 100644 --- a/crates/analyzer/tests/snapshots/errors__invalid_chain_field.snap +++ b/crates/analyzer/tests/snapshots/errors__invalid_chain_field.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: cannot find value `chain` in this scope - ┌─ compile_errors/invalid_chain_field.fe:4:5 + ┌─ compile_errors/invalid_chain_field.fe:3:9 │ -4 │ chain.foo - │ ^^^^^ undefined +3 │ chain.foo + │ ^^^^^ undefined diff --git a/crates/analyzer/tests/snapshots/errors__invalid_contract_field.snap b/crates/analyzer/tests/snapshots/errors__invalid_contract_field.snap index d933b6efc7..efc9a03615 100644 --- a/crates/analyzer/tests/snapshots/errors__invalid_contract_field.snap +++ b/crates/analyzer/tests/snapshots/errors__invalid_contract_field.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: No field `bar` exists on this contract - ┌─ compile_errors/invalid_contract_field.fe:5:10 + ┌─ compile_errors/invalid_contract_field.fe:5:14 │ -5 │ self.bar - │ ^^^ undefined field +5 │ self.bar + │ ^^^ undefined field diff --git a/crates/analyzer/tests/snapshots/errors__invalid_msg_field.snap b/crates/analyzer/tests/snapshots/errors__invalid_msg_field.snap index 08b5f31cba..625fc10866 100644 --- a/crates/analyzer/tests/snapshots/errors__invalid_msg_field.snap +++ b/crates/analyzer/tests/snapshots/errors__invalid_msg_field.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: cannot find value `msg` in this scope - ┌─ compile_errors/invalid_msg_field.fe:4:5 + ┌─ compile_errors/invalid_msg_field.fe:3:9 │ -4 │ msg.foo - │ ^^^ undefined +3 │ msg.foo + │ ^^^ undefined diff --git a/crates/analyzer/tests/snapshots/errors__invalid_string_field.snap b/crates/analyzer/tests/snapshots/errors__invalid_string_field.snap index cbad5a79cc..908d2f5fd9 100644 --- a/crates/analyzer/tests/snapshots/errors__invalid_string_field.snap +++ b/crates/analyzer/tests/snapshots/errors__invalid_string_field.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: No field `does_not_exist` exists on type String<0> - ┌─ compile_errors/invalid_string_field.fe:4:8 + ┌─ compile_errors/invalid_string_field.fe:3:12 │ -4 │ "".does_not_exist - │ ^^^^^^^^^^^^^^ unknown field +3 │ "".does_not_exist + │ ^^^^^^^^^^^^^^ unknown field diff --git a/crates/analyzer/tests/snapshots/errors__invalid_struct_field.snap b/crates/analyzer/tests/snapshots/errors__invalid_struct_field.snap index f28c7608fc..60577d03d3 100644 --- a/crates/analyzer/tests/snapshots/errors__invalid_struct_field.snap +++ b/crates/analyzer/tests/snapshots/errors__invalid_struct_field.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: No field `foo` exists on struct `Bar` - ┌─ compile_errors/invalid_struct_field.fe:8:14 + ┌─ compile_errors/invalid_struct_field.fe:9:18 │ -8 │ self.val.foo - │ ^^^ undefined field +9 │ self.val.foo + │ ^^^ undefined field diff --git a/crates/analyzer/tests/snapshots/errors__invalid_tuple_field.snap b/crates/analyzer/tests/snapshots/errors__invalid_tuple_field.snap index 1d4f1f19bd..1ec5cd376b 100644 --- a/crates/analyzer/tests/snapshots/errors__invalid_tuple_field.snap +++ b/crates/analyzer/tests/snapshots/errors__invalid_tuple_field.snap @@ -4,10 +4,10 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: No field `item5` exists on this tuple - ┌─ compile_errors/invalid_tuple_field.fe:5:14 + ┌─ compile_errors/invalid_tuple_field.fe:5:18 │ -5 │ self.val.item5 - │ ^^^^^ unknown field +5 │ self.val.item5 + │ ^^^^^ unknown field │ = Note: The highest possible field for this tuple is `item1` diff --git a/crates/analyzer/tests/snapshots/errors__invalid_tx_field.snap b/crates/analyzer/tests/snapshots/errors__invalid_tx_field.snap index 98ab8ccb96..1ca1268c22 100644 --- a/crates/analyzer/tests/snapshots/errors__invalid_tx_field.snap +++ b/crates/analyzer/tests/snapshots/errors__invalid_tx_field.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: cannot find value `tx` in this scope - ┌─ compile_errors/invalid_tx_field.fe:4:5 + ┌─ compile_errors/invalid_tx_field.fe:3:9 │ -4 │ tx.foo - │ ^^ undefined +3 │ tx.foo + │ ^^ undefined diff --git a/crates/analyzer/tests/snapshots/errors__invalid_var_declaration_1.snap b/crates/analyzer/tests/snapshots/errors__invalid_var_declaration_1.snap index 1f072b2f21..799ff91fa2 100644 --- a/crates/analyzer/tests/snapshots/errors__invalid_var_declaration_1.snap +++ b/crates/analyzer/tests/snapshots/errors__invalid_var_declaration_1.snap @@ -4,10 +4,10 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: invalid declaration - ┌─ compile_errors/invalid_var_declaration_1.fe:3:9 + ┌─ compile_errors/invalid_var_declaration_1.fe:3:13 │ -3 │ let (x,): Array = [1,2,3,4,5,6,7,8,9,0,2,1,3,4,5,6,7,8,9,0] - │ ^^^^ +3 │ let (x,): Array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 2, 1, 3, 4, 5, 6, 7, 8, 9, 0] + │ ^^^^ │ = Tuple declaration targets need to be declared with the tuple type but here the type is Array diff --git a/crates/analyzer/tests/snapshots/errors__invalid_var_declaration_2.snap b/crates/analyzer/tests/snapshots/errors__invalid_var_declaration_2.snap index d5a3b9bfff..1591e69763 100644 --- a/crates/analyzer/tests/snapshots/errors__invalid_var_declaration_2.snap +++ b/crates/analyzer/tests/snapshots/errors__invalid_var_declaration_2.snap @@ -4,10 +4,10 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: invalid declaration - ┌─ compile_errors/invalid_var_declaration_2.fe:3:9 + ┌─ compile_errors/invalid_var_declaration_2.fe:3:13 │ -3 │ let (x, y):(u256,)=(1,) - │ ^^^^^^ +3 │ let (x, y): (u256,) = (1,) + │ ^^^^^^ │ = Tuple declaration has 2 items but the specified tuple type has 1 item diff --git a/crates/analyzer/tests/snapshots/errors__issue_451.snap b/crates/analyzer/tests/snapshots/errors__issue_451.snap index 42091fe8b7..1ff6800d2c 100644 --- a/crates/analyzer/tests/snapshots/errors__issue_451.snap +++ b/crates/analyzer/tests/snapshots/errors__issue_451.snap @@ -6,23 +6,26 @@ expression: "error_string(&path, test_files::fixture(path))" error: duplicate function names in `contract o` ┌─ compile_errors/issue_451.fe:2:5 │ -2 │ ╭ pub fn bar(x:u256,y:u256)->bool: -3 │ │ return - │ ╰─────────────^ `bar` first defined here -4 │ ╭ pub fn bar(): -5 │ │ s - │ ╰──────' `bar` redefined here +2 │ ╭ pub fn bar(x: u256, y: u256) -> bool { +3 │ │ return +4 │ │ } + │ ╰───────^ `bar` first defined here +5 │ +6 │ ╭ pub fn bar() { +7 │ │ s +8 │ │ } + │ ╰─────' `bar` redefined here error: expected function to return `bool` but was `()` - ┌─ compile_errors/issue_451.fe:3:6 + ┌─ compile_errors/issue_451.fe:3:9 │ -3 │ return - │ ^^^^^^ +3 │ return + │ ^^^^^^ error: cannot find value `s` in this scope - ┌─ compile_errors/issue_451.fe:5:6 + ┌─ compile_errors/issue_451.fe:7:9 │ -5 │ s - │ ^ undefined +7 │ s + │ ^ undefined diff --git a/crates/analyzer/tests/snapshots/errors__mislabeled_call_args.snap b/crates/analyzer/tests/snapshots/errors__mislabeled_call_args.snap index 15617085aa..16b7d24e6f 100644 --- a/crates/analyzer/tests/snapshots/errors__mislabeled_call_args.snap +++ b/crates/analyzer/tests/snapshots/errors__mislabeled_call_args.snap @@ -4,15 +4,15 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: argument label mismatch - ┌─ compile_errors/mislabeled_call_args.fe:4:13 + ┌─ compile_errors/mislabeled_call_args.fe:3:13 │ -4 │ bar(doesnt_exist: 1, me_neither: 2) +3 │ bar(doesnt_exist: 1, me_neither: 2) │ ^^^^^^^^^^^^ expected `val1` error: argument label mismatch - ┌─ compile_errors/mislabeled_call_args.fe:4:30 + ┌─ compile_errors/mislabeled_call_args.fe:3:30 │ -4 │ bar(doesnt_exist: 1, me_neither: 2) +3 │ bar(doesnt_exist: 1, me_neither: 2) │ ^^^^^^^^^^ expected `val2` diff --git a/crates/analyzer/tests/snapshots/errors__mislabeled_call_args_external_contract_call.snap b/crates/analyzer/tests/snapshots/errors__mislabeled_call_args_external_contract_call.snap index 9b3deb4859..0102c190d4 100644 --- a/crates/analyzer/tests/snapshots/errors__mislabeled_call_args_external_contract_call.snap +++ b/crates/analyzer/tests/snapshots/errors__mislabeled_call_args_external_contract_call.snap @@ -4,15 +4,15 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: argument label mismatch - ┌─ compile_errors/mislabeled_call_args_external_contract_call.fe:11:30 + ┌─ compile_errors/mislabeled_call_args_external_contract_call.fe:11:34 │ -11 │ Foo(ctx, address(0)).baz(doesnt_exist: 1, me_neither: 4) - │ ^^^^^^^^^^^^ expected `val1` +11 │ Foo(ctx, address(0)).baz(doesnt_exist: 1, me_neither: 4) + │ ^^^^^^^^^^^^ expected `val1` error: argument label mismatch - ┌─ compile_errors/mislabeled_call_args_external_contract_call.fe:11:47 + ┌─ compile_errors/mislabeled_call_args_external_contract_call.fe:11:51 │ -11 │ Foo(ctx, address(0)).baz(doesnt_exist: 1, me_neither: 4) - │ ^^^^^^^^^^ expected `val2` +11 │ Foo(ctx, address(0)).baz(doesnt_exist: 1, me_neither: 4) + │ ^^^^^^^^^^ expected `val2` diff --git a/crates/analyzer/tests/snapshots/errors__mislabeled_call_args_self.snap b/crates/analyzer/tests/snapshots/errors__mislabeled_call_args_self.snap index 85395d0850..8b664f05d7 100644 --- a/crates/analyzer/tests/snapshots/errors__mislabeled_call_args_self.snap +++ b/crates/analyzer/tests/snapshots/errors__mislabeled_call_args_self.snap @@ -4,15 +4,15 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: argument label mismatch - ┌─ compile_errors/mislabeled_call_args_self.fe:4:18 + ┌─ compile_errors/mislabeled_call_args_self.fe:3:18 │ -4 │ self.bar(doesnt_exist: 1, me_neither: 2) +3 │ self.bar(doesnt_exist: 1, me_neither: 2) │ ^^^^^^^^^^^^ expected `val1` error: argument label mismatch - ┌─ compile_errors/mislabeled_call_args_self.fe:4:35 + ┌─ compile_errors/mislabeled_call_args_self.fe:3:35 │ -4 │ self.bar(doesnt_exist: 1, me_neither: 2) +3 │ self.bar(doesnt_exist: 1, me_neither: 2) │ ^^^^^^^^^^ expected `val2` diff --git a/crates/analyzer/tests/snapshots/errors__mismatch_return_type.snap b/crates/analyzer/tests/snapshots/errors__mismatch_return_type.snap index 3ae965ed45..18e4973cec 100644 --- a/crates/analyzer/tests/snapshots/errors__mismatch_return_type.snap +++ b/crates/analyzer/tests/snapshots/errors__mismatch_return_type.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: expected function to return `address` but was `u256` - ┌─ compile_errors/mismatch_return_type.fe:4:9 + ┌─ compile_errors/mismatch_return_type.fe:3:9 │ -4 │ return 1 +3 │ return 1 │ ^^^^^^^^ diff --git a/crates/analyzer/tests/snapshots/errors__missing_return.snap b/crates/analyzer/tests/snapshots/errors__missing_return.snap index 4f4085dce9..2870b741e5 100644 --- a/crates/analyzer/tests/snapshots/errors__missing_return.snap +++ b/crates/analyzer/tests/snapshots/errors__missing_return.snap @@ -6,7 +6,7 @@ expression: "error_string(&path, test_files::fixture(path))" error: function body is missing a return or revert statement ┌─ compile_errors/missing_return.fe:4:12 │ -4 │ pub fn bar(self) -> u256: +4 │ pub fn bar(self) -> u256 { │ ^^^ ---- expected function to return `u256` │ │ │ all paths of this function must `return` or `revert` diff --git a/crates/analyzer/tests/snapshots/errors__missing_return_after_if.snap b/crates/analyzer/tests/snapshots/errors__missing_return_after_if.snap index a82fa06464..5259f972fb 100644 --- a/crates/analyzer/tests/snapshots/errors__missing_return_after_if.snap +++ b/crates/analyzer/tests/snapshots/errors__missing_return_after_if.snap @@ -6,7 +6,7 @@ expression: "error_string(&path, test_files::fixture(path))" error: function body is missing a return or revert statement ┌─ compile_errors/missing_return_after_if.fe:2:12 │ -2 │ pub fn bar(val: u256) -> u256: +2 │ pub fn bar(val: u256) -> u256 { │ ^^^ ---- expected function to return `u256` │ │ │ all paths of this function must `return` or `revert` diff --git a/crates/analyzer/tests/snapshots/errors__missing_return_in_else.snap b/crates/analyzer/tests/snapshots/errors__missing_return_in_else.snap index 16e86e3295..6232cd4943 100644 --- a/crates/analyzer/tests/snapshots/errors__missing_return_in_else.snap +++ b/crates/analyzer/tests/snapshots/errors__missing_return_in_else.snap @@ -6,7 +6,7 @@ expression: "error_string(&path, test_files::fixture(path))" error: function body is missing a return or revert statement ┌─ compile_errors/missing_return_in_else.fe:2:12 │ -2 │ pub fn bar(val: u256) -> u256: +2 │ pub fn bar(val: u256) -> u256 { │ ^^^ ---- expected function to return `u256` │ │ │ all paths of this function must `return` or `revert` diff --git a/crates/analyzer/tests/snapshots/errors__missing_self.snap b/crates/analyzer/tests/snapshots/errors__missing_self.snap index 604181338c..1814b1c549 100644 --- a/crates/analyzer/tests/snapshots/errors__missing_self.snap +++ b/crates/analyzer/tests/snapshots/errors__missing_self.snap @@ -13,9 +13,9 @@ error: `self` is not defined = Example: `fn pure_fn(self, foo: bool)` error: `self` is not defined - ┌─ compile_errors/missing_self.fe:12:16 + ┌─ compile_errors/missing_self.fe:13:16 │ -12 │ return self.x +13 │ return self.x │ ^^^^ undefined value │ = add `self` to the scope by including it in the function signature diff --git a/crates/analyzer/tests/snapshots/errors__module_const_call.snap b/crates/analyzer/tests/snapshots/errors__module_const_call.snap index 52cac4b98d..2f727a20f3 100644 --- a/crates/analyzer/tests/snapshots/errors__module_const_call.snap +++ b/crates/analyzer/tests/snapshots/errors__module_const_call.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `FOO` is not callable - ┌─ compile_errors/module_const_call.fe:5:5 + ┌─ compile_errors/module_const_call.fe:5:9 │ -5 │ FOO() - │ ^^^ `FOO` is a constant of type `u8`, and can't be used as a function +5 │ FOO() + │ ^^^ `FOO` is a constant of type `u8`, and can't be used as a function diff --git a/crates/analyzer/tests/snapshots/errors__needs_mem_copy.snap b/crates/analyzer/tests/snapshots/errors__needs_mem_copy.snap index 06e888d2a7..642ed3982b 100644 --- a/crates/analyzer/tests/snapshots/errors__needs_mem_copy.snap +++ b/crates/analyzer/tests/snapshots/errors__needs_mem_copy.snap @@ -15,9 +15,9 @@ error: location mismatch = Example: `self.my_array.to_mem()` error: value must be copied to memory - ┌─ compile_errors/needs_mem_copy.fe:8:16 + ┌─ compile_errors/needs_mem_copy.fe:9:16 │ -8 │ return self.my_sto_array +9 │ return self.my_sto_array │ ^^^^^^^^^^^^^^^^^ this value is in storage │ = Hint: values located in storage can be copied to memory using the `to_mem` function. diff --git a/crates/analyzer/tests/snapshots/errors__non_pub_init.snap b/crates/analyzer/tests/snapshots/errors__non_pub_init.snap index 180b00b426..0744a3d70e 100644 --- a/crates/analyzer/tests/snapshots/errors__non_pub_init.snap +++ b/crates/analyzer/tests/snapshots/errors__non_pub_init.snap @@ -5,11 +5,10 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `__init__` function is not public ┌─ compile_errors/non_pub_init.fe:2:5 - │ -2 │ ╭ fn __init__(): -3 │ │ pass - │ ╰────────────^ `__init__` function must be public - │ + │ +2 │ fn __init__() {} + │ ^^^^^^^^^^^^^^^^ `__init__` function must be public + │ = Hint: Add the `pub` modifier. = Example: `pub fn __init__():` diff --git a/crates/analyzer/tests/snapshots/errors__not_callable.snap b/crates/analyzer/tests/snapshots/errors__not_callable.snap index a5a1100146..4d01f65c4f 100644 --- a/crates/analyzer/tests/snapshots/errors__not_callable.snap +++ b/crates/analyzer/tests/snapshots/errors__not_callable.snap @@ -4,23 +4,23 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `u256` type is not callable - ┌─ compile_errors/not_callable.fe:7:5 + ┌─ compile_errors/not_callable.fe:7:9 │ -7 │ 5() - │ ^ this has type `u256` +7 │ 5() + │ ^ this has type `u256` error: `MyEvent` is not callable - ┌─ compile_errors/not_callable.fe:10:5 + ┌─ compile_errors/not_callable.fe:11:9 │ -10 │ MyEvent(x: 10) - │ ^^^^^^^ `MyEvent` is an event, and can't be constructed in this context +11 │ MyEvent(x: 10) + │ ^^^^^^^ `MyEvent` is an event, and can't be constructed in this context │ = Hint: to emit an event, use `emit MyEvent(..)` error: `self` is not callable - ┌─ compile_errors/not_callable.fe:13:5 + ┌─ compile_errors/not_callable.fe:15:9 │ -13 │ self() - │ ^^^^ can't be used as a function +15 │ self() + │ ^^^^ can't be used as a function diff --git a/crates/analyzer/tests/snapshots/errors__private_struct_field.snap b/crates/analyzer/tests/snapshots/errors__private_struct_field.snap index bb326d05b4..3073fcf05c 100644 --- a/crates/analyzer/tests/snapshots/errors__private_struct_field.snap +++ b/crates/analyzer/tests/snapshots/errors__private_struct_field.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: Can not access private field `id` on struct `Bar` - ┌─ compile_errors/private_struct_field.fe:8:14 + ┌─ compile_errors/private_struct_field.fe:9:18 │ -8 │ self.val.id - │ ^^ private field +9 │ self.val.id + │ ^^ private field diff --git a/crates/analyzer/tests/snapshots/errors__return_complex_struct.snap b/crates/analyzer/tests/snapshots/errors__return_complex_struct.snap index ff3fc4d470..c0479c54e8 100644 --- a/crates/analyzer/tests/snapshots/errors__return_complex_struct.snap +++ b/crates/analyzer/tests/snapshots/errors__return_complex_struct.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: feature not yet implemented: structs with complex fields can't be returned from public functions yet - ┌─ compile_errors/return_complex_struct.fe:5:17 + ┌─ compile_errors/return_complex_struct.fe:6:19 │ -5 │ pub fn f() -> Foo: - │ ^^^ not yet implemented +6 │ pub fn f() -> Foo { + │ ^^^ not yet implemented diff --git a/crates/analyzer/tests/snapshots/errors__return_from_init.snap b/crates/analyzer/tests/snapshots/errors__return_from_init.snap index bf23a42bb2..6208fabf96 100644 --- a/crates/analyzer/tests/snapshots/errors__return_from_init.snap +++ b/crates/analyzer/tests/snapshots/errors__return_from_init.snap @@ -6,7 +6,7 @@ expression: "error_string(&path, test_files::fixture(path))" error: `__init__` function has incorrect return type ┌─ compile_errors/return_from_init.fe:2:26 │ -2 │ pub fn __init__() -> i32: +2 │ pub fn __init__() -> i32 { │ ^^^ return type should be `()` │ = Hint: Remove the return type specification. diff --git a/crates/analyzer/tests/snapshots/errors__return_type_not_fixedsize.snap b/crates/analyzer/tests/snapshots/errors__return_type_not_fixedsize.snap index 5aa6bf5c10..1c4a7ae170 100644 --- a/crates/analyzer/tests/snapshots/errors__return_type_not_fixedsize.snap +++ b/crates/analyzer/tests/snapshots/errors__return_type_not_fixedsize.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: function return type must have a fixed size - ┌─ compile_errors/return_type_not_fixedsize.fe:2:17 + ┌─ compile_errors/return_type_not_fixedsize.fe:2:19 │ -2 │ pub fn f() -> Map: - │ ^^^^^^^^^^^^^^^^^^ this can't be returned from a function +2 │ pub fn f() -> Map {} + │ ^^^^^^^^^^^^^^^^^^ this can't be returned from a function diff --git a/crates/analyzer/tests/snapshots/errors__return_type_undefined.snap b/crates/analyzer/tests/snapshots/errors__return_type_undefined.snap index 55bebd206c..8184e0f0c7 100644 --- a/crates/analyzer/tests/snapshots/errors__return_type_undefined.snap +++ b/crates/analyzer/tests/snapshots/errors__return_type_undefined.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: undefined type - ┌─ compile_errors/return_type_undefined.fe:2:17 + ┌─ compile_errors/return_type_undefined.fe:2:19 │ -2 │ pub fn f() -> Foo: - │ ^^^ `Foo` has not been defined +2 │ pub fn f() -> Foo {} + │ ^^^ `Foo` has not been defined diff --git a/crates/analyzer/tests/snapshots/errors__revert_sto_error_no_copy.snap b/crates/analyzer/tests/snapshots/errors__revert_sto_error_no_copy.snap index 20894e2bbb..3f2430b92f 100644 --- a/crates/analyzer/tests/snapshots/errors__revert_sto_error_no_copy.snap +++ b/crates/analyzer/tests/snapshots/errors__revert_sto_error_no_copy.snap @@ -4,9 +4,9 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: value must be copied to memory - ┌─ compile_errors/revert_sto_error_no_copy.fe:8:16 + ┌─ compile_errors/revert_sto_error_no_copy.fe:7:16 │ -8 │ revert self.my_error +7 │ revert self.my_error │ ^^^^^^^^^^^^^ this value is in storage │ = Hint: values located in storage can be copied to memory using the `to_mem` function. diff --git a/crates/analyzer/tests/snapshots/errors__self_in_standalone_fn.snap b/crates/analyzer/tests/snapshots/errors__self_in_standalone_fn.snap index b578dd6678..631dbca777 100644 --- a/crates/analyzer/tests/snapshots/errors__self_in_standalone_fn.snap +++ b/crates/analyzer/tests/snapshots/errors__self_in_standalone_fn.snap @@ -6,7 +6,7 @@ expression: "error_string(&path, test_files::fixture(path))" error: `self` can only be used in contract or struct functions ┌─ compile_errors/self_in_standalone_fn.fe:1:12 │ -1 │ fn pure_fn(self): +1 │ fn pure_fn(self) { │ ^^^^ not allowed in functions defined outside of a contract or struct error: `self` can only be used in contract or struct functions @@ -18,7 +18,7 @@ error: `self` can only be used in contract or struct functions error: `pure_fn` expects 0 arguments, but 1 was provided ┌─ compile_errors/self_in_standalone_fn.fe:1:4 │ -1 │ fn pure_fn(self): +1 │ fn pure_fn(self) { │ ^^^^^^^ expects 0 arguments · 7 │ pure_fn(self) diff --git a/crates/analyzer/tests/snapshots/errors__self_misuse.snap b/crates/analyzer/tests/snapshots/errors__self_misuse.snap index accc6743f4..fc5da27038 100644 --- a/crates/analyzer/tests/snapshots/errors__self_misuse.snap +++ b/crates/analyzer/tests/snapshots/errors__self_misuse.snap @@ -4,38 +4,38 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `self` can't be used as a variable name - ┌─ compile_errors/self_misuse.fe:2:7 + ┌─ compile_errors/self_misuse.fe:2:9 │ -2 │ let self: u8 = 10 - │ ^^^^ expected a name, found keyword `self` +2 │ let self: u8 = 10 + │ ^^^^ expected a name, found keyword `self` error: `self` can only be used in contract or struct functions - ┌─ compile_errors/self_misuse.fe:3:3 + ┌─ compile_errors/self_misuse.fe:3:5 │ -3 │ self = 5 - │ ^^^^ not allowed in functions defined outside of a contract or struct +3 │ self = 5 + │ ^^^^ not allowed in functions defined outside of a contract or struct error: `self` is not callable - ┌─ compile_errors/self_misuse.fe:15:5 + ┌─ compile_errors/self_misuse.fe:16:9 │ -15 │ self() - │ ^^^^ can't be used as a function +16 │ self() + │ ^^^^ can't be used as a function error: `g` must be called via `self` - ┌─ compile_errors/self_misuse.fe:26:6 + ┌─ compile_errors/self_misuse.fe:31:8 │ -26 │ fn g(self): - │ ^ `g` is defined here as a function that takes `self` +31 │ fn g(self) {} + │ ^ `g` is defined here as a function that takes `self` · -30 │ g(self) - │ ^ `g` is called here as a standalone function +34 │ g(self) + │ ^ `g` is called here as a standalone function │ = Suggestion: use `self.g(...)` instead of `g(...)` error: invalid use of contract `self` - ┌─ compile_errors/self_misuse.fe:33:9 + ┌─ compile_errors/self_misuse.fe:38:13 │ -33 │ bar(self) - │ ^^^^ `self` can't be used here +38 │ bar(self) + │ ^^^^ `self` can't be used here diff --git a/crates/analyzer/tests/snapshots/errors__self_not_first.snap b/crates/analyzer/tests/snapshots/errors__self_not_first.snap index fda2a0ac40..afd6235403 100644 --- a/crates/analyzer/tests/snapshots/errors__self_not_first.snap +++ b/crates/analyzer/tests/snapshots/errors__self_not_first.snap @@ -6,7 +6,7 @@ expression: "error_string(&path, test_files::fixture(path))" error: `self` is not the first parameter ┌─ compile_errors/self_not_first.fe:2:28 │ -2 │ pub fn bar(my_num: u8, self): +2 │ pub fn bar(my_num: u8, self) {} │ ^^^^ `self` may only be used as the first parameter diff --git a/crates/analyzer/tests/snapshots/errors__shadow_builtin_function.snap b/crates/analyzer/tests/snapshots/errors__shadow_builtin_function.snap index e65301aa98..8c640b4358 100644 --- a/crates/analyzer/tests/snapshots/errors__shadow_builtin_function.snap +++ b/crates/analyzer/tests/snapshots/errors__shadow_builtin_function.snap @@ -4,21 +4,21 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: function name `keccak256` conflicts with built-in function - ┌─ compile_errors/shadow_builtin_function.fe:2:10 + ┌─ compile_errors/shadow_builtin_function.fe:2:12 │ -2 │ pub fn keccak256(bytes: Array) -> Array: - │ ^^^^^^^^^ `keccak256` is a built-in function +2 │ pub fn keccak256(bytes: Array) -> Array { + │ ^^^^^^^^^ `keccak256` is a built-in function error: function name `u256` conflicts with built-in type - ┌─ compile_errors/shadow_builtin_function.fe:5:10 + ┌─ compile_errors/shadow_builtin_function.fe:6:12 │ -5 │ pub fn u256(x: u8) -> u256: - │ ^^^^ `u256` is a built-in type +6 │ pub fn u256(x: u8) -> u256 { + │ ^^^^ `u256` is a built-in type error: function name `bool` conflicts with built-in type - ┌─ compile_errors/shadow_builtin_function.fe:8:10 - │ -8 │ pub fn bool(x: u8) -> bool: - │ ^^^^ `bool` is a built-in type + ┌─ compile_errors/shadow_builtin_function.fe:10:12 + │ +10 │ pub fn bool(x: u8) -> bool { + │ ^^^^ `bool` is a built-in type diff --git a/crates/analyzer/tests/snapshots/errors__shadow_builtin_type.snap b/crates/analyzer/tests/snapshots/errors__shadow_builtin_type.snap index 60836e139e..62ab45e08f 100644 --- a/crates/analyzer/tests/snapshots/errors__shadow_builtin_type.snap +++ b/crates/analyzer/tests/snapshots/errors__shadow_builtin_type.snap @@ -10,39 +10,39 @@ error: type name conflicts with the type named "u256" │ ^^^^ `u256` is already defined error: type name conflicts with the type named "String" - ┌─ compile_errors/shadow_builtin_type.fe:2:6 + ┌─ compile_errors/shadow_builtin_type.fe:3:6 │ -2 │ type String = u256 +3 │ type String = u256 │ ^^^^^^ `String` is already defined error: type name conflicts with the type named "Map" - ┌─ compile_errors/shadow_builtin_type.fe:3:6 + ┌─ compile_errors/shadow_builtin_type.fe:5:6 │ -3 │ type Map = u256 +5 │ type Map = u256 │ ^^^ `Map` is already defined error: type name conflicts with the type named "bool" - ┌─ compile_errors/shadow_builtin_type.fe:4:6 + ┌─ compile_errors/shadow_builtin_type.fe:7:6 │ -4 │ type bool = u256 +7 │ type bool = u256 │ ^^^^ `bool` is already defined error: type name conflicts with the function named "keccak256" - ┌─ compile_errors/shadow_builtin_type.fe:6:6 + ┌─ compile_errors/shadow_builtin_type.fe:9:6 │ -6 │ type keccak256 = u8 +9 │ type keccak256 = u8 │ ^^^^^^^^^ `keccak256` is already defined error: function parameter name `u8` conflicts with built-in type - ┌─ compile_errors/shadow_builtin_type.fe:12:8 + ┌─ compile_errors/shadow_builtin_type.fe:18:10 │ -12 │ fn f(u8: u256): - │ ^^ `u8` is a built-in type +18 │ fn f(u8: u256) {} + │ ^^ `u8` is a built-in type error: function parameter name `keccak256` conflicts with built-in function - ┌─ compile_errors/shadow_builtin_type.fe:15:8 + ┌─ compile_errors/shadow_builtin_type.fe:20:10 │ -15 │ fn g(keccak256: u8): - │ ^^^^^^^^^ `keccak256` is a built-in function +20 │ fn g(keccak256: u8) {} + │ ^^^^^^^^^ `keccak256` is a built-in function diff --git a/crates/analyzer/tests/snapshots/errors__strict_boolean_if_else.snap b/crates/analyzer/tests/snapshots/errors__strict_boolean_if_else.snap index d2f8525c06..cff196c587 100644 --- a/crates/analyzer/tests/snapshots/errors__strict_boolean_if_else.snap +++ b/crates/analyzer/tests/snapshots/errors__strict_boolean_if_else.snap @@ -6,7 +6,7 @@ expression: "error_string(&path, test_files::fixture(path))" error: `if` statement condition is not bool ┌─ compile_errors/strict_boolean_if_else.fe:3:12 │ -3 │ if val: +3 │ if val { │ ^^^ this has type `u256`; expected type `bool` diff --git a/crates/analyzer/tests/snapshots/errors__struct_recursive_cycles.snap b/crates/analyzer/tests/snapshots/errors__struct_recursive_cycles.snap index cad9b7eefa..89660ab38b 100644 --- a/crates/analyzer/tests/snapshots/errors__struct_recursive_cycles.snap +++ b/crates/analyzer/tests/snapshots/errors__struct_recursive_cycles.snap @@ -1,23 +1,24 @@ --- source: crates/analyzer/tests/errors.rs expression: "error_string(&path, test_files::fixture(path))" + --- error: recursive struct `Foo` - ┌─ compile_errors/struct_recursive_cycles.fe:4:8 + ┌─ compile_errors/struct_recursive_cycles.fe:3:8 │ -4 │ struct Foo: +3 │ struct Foo { │ ^^^ struct `Foo` has infinite size due to recursive definition error: recursive struct `Bar` ┌─ compile_errors/struct_recursive_cycles.fe:8:8 │ -8 │ struct Bar: +8 │ struct Bar { │ ^^^ struct `Bar` has infinite size due to recursive definition error: recursive struct `Foo2` - ┌─ compile_errors/struct_recursive_cycles.fe:12:8 + ┌─ compile_errors/struct_recursive_cycles.fe:13:8 │ -12 │ struct Foo2: +13 │ struct Foo2 { │ ^^^^ struct `Foo2` has infinite size due to recursive definition diff --git a/crates/analyzer/tests/snapshots/errors__undefined_type_param.snap b/crates/analyzer/tests/snapshots/errors__undefined_type_param.snap index 02da0a7cf6..b27627d5d4 100644 --- a/crates/analyzer/tests/snapshots/errors__undefined_type_param.snap +++ b/crates/analyzer/tests/snapshots/errors__undefined_type_param.snap @@ -12,7 +12,7 @@ error: undefined type error: undefined type ┌─ compile_errors/undefined_type_param.fe:8:21 │ -8 │ pub fn a(_ val: DoesntExist): +8 │ pub fn a(_ val: DoesntExist) { │ ^^^^^^^^^^^ `DoesntExist` has not been defined diff --git a/crates/analyzer/tests/snapshots/errors__unsafe_misuse.snap b/crates/analyzer/tests/snapshots/errors__unsafe_misuse.snap index 130b1462f9..50f0b85525 100644 --- a/crates/analyzer/tests/snapshots/errors__unsafe_misuse.snap +++ b/crates/analyzer/tests/snapshots/errors__unsafe_misuse.snap @@ -1,37 +1,38 @@ --- source: crates/analyzer/tests/errors.rs expression: "error_string(&path, test_files::fixture(path))" + --- error: unsafe function `mod_priv` can only be called in an unsafe function or block - ┌─ compile_errors/unsafe_misuse.fe:10:3 - │ - 3 │ unsafe fn mod_priv(): # OK - │ ------------------ `mod_priv` is defined here as unsafe - · -10 │ mod_priv() # BAD - │ ^^^^^^^^ call to unsafe function - │ - = Hint: put this call in an `unsafe` block if you're confident that it's safe to use here + ┌─ compile_errors/unsafe_misuse.fe:8:5 + │ +1 │ unsafe fn mod_priv() {} + │ ------------------ `mod_priv` is defined here as unsafe + · +8 │ mod_priv() + │ ^^^^^^^^ call to unsafe function + │ + = Hint: put this call in an `unsafe` block if you're confident that it's safe to use here error: unsafe function `priv_self` can only be called in an unsafe function or block - ┌─ compile_errors/unsafe_misuse.fe:38:5 + ┌─ compile_errors/unsafe_misuse.fe:35:9 │ -31 │ unsafe fn priv_self(self): # OK - │ ------------------- `priv_self` is defined here as unsafe +28 │ unsafe fn priv_self(self) { + │ ------------------- `priv_self` is defined here as unsafe · -38 │ self.priv_self() # BAD - │ ^^^^^^^^^^^^^^ call to unsafe function +35 │ self.priv_self() + │ ^^^^^^^^^^^^^^ call to unsafe function │ = Hint: put this call in an `unsafe` block if you're confident that it's safe to use here error: unsafe function `priv_nonself` can only be called in an unsafe function or block - ┌─ compile_errors/unsafe_misuse.fe:39:5 + ┌─ compile_errors/unsafe_misuse.fe:36:9 │ -24 │ unsafe fn priv_nonself(): # OK - │ ---------------------- `priv_nonself` is defined here as unsafe +22 │ unsafe fn priv_nonself() { + │ ---------------------- `priv_nonself` is defined here as unsafe · -39 │ priv_nonself() # BAD - │ ^^^^^^^^^^^^ call to unsafe function +36 │ priv_nonself() + │ ^^^^^^^^^^^^ call to unsafe function │ = Hint: put this call in an `unsafe` block if you're confident that it's safe to use here diff --git a/crates/analyzer/tests/snapshots/errors__unsafe_nesting.snap b/crates/analyzer/tests/snapshots/errors__unsafe_nesting.snap index fc7ee3e0ac..456e235280 100644 --- a/crates/analyzer/tests/snapshots/errors__unsafe_nesting.snap +++ b/crates/analyzer/tests/snapshots/errors__unsafe_nesting.snap @@ -4,17 +4,15 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: unnecessary `unsafe` block - ┌─ compile_errors/unsafe_nesting.fe:2:3 - │ -2 │ ╭ unsafe: -3 │ │ g() - │ ╰───────^ this `unsafe` block is nested inside another `unsafe` context + ┌─ compile_errors/unsafe_nesting.fe:2:5 + │ +2 │ unsafe { g() } + │ ^^^^^^^^^^^^^^ this `unsafe` block is nested inside another `unsafe` context error: unnecessary `unsafe` block - ┌─ compile_errors/unsafe_nesting.fe:8:5 - │ -8 │ ╭ unsafe: -9 │ │ h() - │ ╰─────────^ this `unsafe` block is nested inside another `unsafe` context + ┌─ compile_errors/unsafe_nesting.fe:8:9 + │ +8 │ unsafe { h() } + │ ^^^^^^^^^^^^^^ this `unsafe` block is nested inside another `unsafe` context diff --git a/crates/library/std/src/context.fe b/crates/library/std/src/context.fe index 47c5df345d..222cdf7353 100644 --- a/crates/library/std/src/context.fe +++ b/crates/library/std/src/context.fe @@ -5,70 +5,75 @@ use ingot::error::{ Error } -pub struct Context: - pub fn base_fee(self) -> u256: - unsafe: - return evm::base_fee() - - pub fn block_coinbase(self) -> address: - unsafe: - return evm::coinbase() - - pub fn block_difficulty(self) -> u256: - unsafe: - return evm::difficulty() - - pub fn block_number(self) -> u256: - unsafe: - return evm::block_number() - - pub fn block_timestamp(self) -> u256: - unsafe: - return evm::timestamp() - - pub fn chain_id(self) -> u256: - unsafe: - return evm::chain_id() - - pub fn msg_sender(self) -> address: - unsafe: - return evm::caller() - - pub fn msg_value(self) -> u256: - unsafe: - return evm::call_value() - - pub fn tx_gas_price(self) -> u256: - unsafe: - return evm::gas_price() - - pub fn tx_origin(self) -> address: - unsafe: - return evm::origin() - - pub fn msg_sig(self) -> u256: - unsafe: - return evm::shr(224, evm::call_data_load(offset: 0)) - - pub fn balance_of(self, _ account: address) -> u256: - unsafe: - return evm::balance_of(account) - - pub fn self_balance(self) -> u256: - unsafe: - return evm::balance() - - pub fn self_address(self) -> address: - unsafe: - return address(__address()) - - pub fn send_value(self, to: address, wei: u256): - unsafe: - if evm::balance() < wei: - revert Error(code: ERROR_INSUFFICIENT_FUNDS_TO_SEND_VALUE) - - let success: u256 = evm::call(gas: evm::gas_remaining(), addr: to, value: wei, - input_offset: 0, input_len: 0, - output_offset: 0, output_len: 0) - if success == 0: - revert Error(code: ERROR_FAILED_SEND_VALUE) +pub struct Context { + pub fn base_fee(self) -> u256 { + unsafe { return evm::base_fee() } + } + + pub fn block_coinbase(self) -> address { + unsafe { return evm::coinbase() } + } + + pub fn block_difficulty(self) -> u256 { + unsafe { return evm::difficulty() } + } + + pub fn block_number(self) -> u256 { + unsafe { return evm::block_number() } + } + + pub fn block_timestamp(self) -> u256 { + unsafe { return evm::timestamp() } + } + + pub fn chain_id(self) -> u256 { + unsafe { return evm::chain_id() } + } + + pub fn msg_sender(self) -> address { + unsafe { return evm::caller() } + } + + pub fn msg_value(self) -> u256 { + unsafe { return evm::call_value() } + } + + pub fn tx_gas_price(self) -> u256 { + unsafe { return evm::gas_price() } + } + + pub fn tx_origin(self) -> address { + unsafe { return evm::origin() } + } + + pub fn msg_sig(self) -> u256 { + unsafe { return evm::shr(224, evm::call_data_load(offset: 0)) } + } + + pub fn balance_of(self, _ account: address) -> u256 { + unsafe { return evm::balance_of(account) } + } + + pub fn self_balance(self) -> u256 { + unsafe { return evm::balance() } + } + + pub fn self_address(self) -> address { + unsafe { return address(__address()) } + } + + pub fn send_value(self, to: address, wei: u256) { + unsafe { + if evm::balance() < wei { + revert Error(code: ERROR_INSUFFICIENT_FUNDS_TO_SEND_VALUE) + } + + let success: u256 = evm::call(gas: evm::gas_remaining(), addr: to, value: wei, + input_offset: 0, input_len: 0, + output_offset: 0, output_len: 0) + if success == 0 { + revert Error(code: ERROR_FAILED_SEND_VALUE) + } + } + } +} \ No newline at end of file diff --git a/crates/library/std/src/error.fe b/crates/library/std/src/error.fe index b44e9fe58b..7ae066af4c 100644 --- a/crates/library/std/src/error.fe +++ b/crates/library/std/src/error.fe @@ -1,5 +1,6 @@ pub const ERROR_INSUFFICIENT_FUNDS_TO_SEND_VALUE: u256 = 0x100 pub const ERROR_FAILED_SEND_VALUE: u256 = 0x101 -pub struct Error: +pub struct Error { pub code: u256 +} \ No newline at end of file diff --git a/crates/library/std/src/evm.fe b/crates/library/std/src/evm.fe index 55551fcf00..eff5c0dae9 100644 --- a/crates/library/std/src/evm.fe +++ b/crates/library/std/src/evm.fe @@ -1,273 +1,324 @@ # Basic context accessor functions. -pub unsafe fn chain_id() -> u256: +pub unsafe fn chain_id() -> u256 { return __chainid() +} -pub unsafe fn base_fee() -> u256: +pub unsafe fn base_fee() -> u256 { return __basefee() +} -pub unsafe fn origin() -> address: +pub unsafe fn origin() -> address { return address(__origin()) +} -pub unsafe fn gas_price() -> u256: +pub unsafe fn gas_price() -> u256 { return __gasprice() +} -pub unsafe fn gas_limit() -> u256: +pub unsafe fn gas_limit() -> u256 { return __gaslimit() +} -pub unsafe fn gas_remaining() -> u256: +pub unsafe fn gas_remaining() -> u256 { return __gas() +} -pub unsafe fn block_hash(_ b: u256) -> u256: +pub unsafe fn block_hash(_ b: u256) -> u256 { return __blockhash(b) +} -pub unsafe fn coinbase() -> address: +pub unsafe fn coinbase() -> address { return address(__coinbase()) +} -pub unsafe fn timestamp() -> u256: +pub unsafe fn timestamp() -> u256 { return __timestamp() +} -pub unsafe fn block_number() -> u256: +pub unsafe fn block_number() -> u256 { return __number() +} -pub unsafe fn difficulty() -> u256: +pub unsafe fn difficulty() -> u256 { return __difficulty() +} -pub unsafe fn self_address() -> address: +pub unsafe fn self_address() -> address { return address(__address()) +} -pub unsafe fn balance_of(_ addr: address) -> u256: +pub unsafe fn balance_of(_ addr: address) -> u256 { return __balance(u256(addr)) +} -pub unsafe fn balance() -> u256: +pub unsafe fn balance() -> u256 { return __selfbalance() +} -pub unsafe fn caller() -> address: +pub unsafe fn caller() -> address { return address(__caller()) +} -pub unsafe fn call_value() -> u256: +pub unsafe fn call_value() -> u256 { return __callvalue() +} # Overflowing math ops. Should these be unsafe or named # `overflowing_add`, etc? -pub fn add(_ x: u256, _ y: u256) -> u256: - unsafe: - return __add(x, y) +pub fn add(_ x: u256, _ y: u256) -> u256 { + unsafe { return __add(x, y) } +} -pub fn sub(_ x: u256, _ y: u256) -> u256: - unsafe: - return __sub(x, y) +pub fn sub(_ x: u256, _ y: u256) -> u256 { + unsafe { return __sub(x, y) } +} -pub fn mul(_ x: u256, _ y: u256) -> u256: - unsafe: - return __mul(x, y) +pub fn mul(_ x: u256, _ y: u256) -> u256 { + unsafe { return __mul(x, y) } +} -pub fn div(_ x: u256, _ y: u256) -> u256: - unsafe: - return __div(x, y) +pub fn div(_ x: u256, _ y: u256) -> u256 { + unsafe { return __div(x, y) } +} -pub fn sdiv(_ x: u256, _ y: u256) -> u256: - unsafe: - return __sdiv(x, y) +pub fn sdiv(_ x: u256, _ y: u256) -> u256 { + unsafe { return __sdiv(x, y) } +} -pub fn mod(_ x: u256, _ y: u256) -> u256: - unsafe: - return __mod(x, y) +pub fn mod(_ x: u256, _ y: u256) -> u256 { + unsafe { return __mod(x, y) } +} -pub fn smod(_ x: u256, _ y: u256) -> u256: - unsafe: - return __smod(x, y) +pub fn smod(_ x: u256, _ y: u256) -> u256 { + unsafe { return __smod(x, y) } +} -pub fn exp(_ x: u256, _ y: u256) -> u256: - unsafe: - return __exp(x, y) +pub fn exp(_ x: u256, _ y: u256) -> u256 { + unsafe { return __exp(x, y) } +} -pub fn addmod(_ x: u256, _ y: u256, _ m: u256) -> u256: - unsafe: - return __addmod(x, y, m) +pub fn addmod(_ x: u256, _ y: u256, _ m: u256) -> u256 { + unsafe { return __addmod(x, y, m) } +} -pub fn mulmod(_ x: u256, _ y: u256, _ m: u256) -> u256: - unsafe: - return __mulmod(x, y, m) +pub fn mulmod(_ x: u256, _ y: u256, _ m: u256) -> u256 { + unsafe { return __mulmod(x, y, m) } +} -pub fn sign_extend(_ i: u256, _ x: u256) -> u256: - unsafe: - return __signextend(i, x) +pub fn sign_extend(_ i: u256, _ x: u256) -> u256 { + unsafe { return __signextend(i, x) } +} # Comparison ops # TODO: return bool (see issue #653) -pub fn lt(_ x: u256, _ y: u256) -> u256: - unsafe: - return __lt(x, y) +pub fn lt(_ x: u256, _ y: u256) -> u256 { + unsafe { return __lt(x, y) } +} -pub fn gt(_ x: u256, _ y: u256) -> u256: - unsafe: - return __gt(x, y) +pub fn gt(_ x: u256, _ y: u256) -> u256 { + unsafe { return __gt(x, y) } +} -pub fn slt(_ x: u256, _ y: u256) -> u256: - unsafe: - return __slt(x, y) +pub fn slt(_ x: u256, _ y: u256) -> u256 { + unsafe { return __slt(x, y) } +} -pub fn sgt(_ x: u256, _ y: u256) -> u256: - unsafe: - return __sgt(x, y) +pub fn sgt(_ x: u256, _ y: u256) -> u256 { + unsafe { return __sgt(x, y) } +} -pub fn eq(_ x: u256, _ y: u256) -> u256: - unsafe: - return __eq(x, y) +pub fn eq(_ x: u256, _ y: u256) -> u256 { + unsafe { return __eq(x, y) } +} -pub fn is_zero(_ x: u256) -> u256: - unsafe: - return __iszero(x) +pub fn is_zero(_ x: u256) -> u256 { + unsafe { return __iszero(x) } +} # Bitwise ops -pub fn bitwise_and(_ x: u256, _ y: u256) -> u256: - unsafe: - return __and(x, y) +pub fn bitwise_and(_ x: u256, _ y: u256) -> u256 { + unsafe { return __and(x, y) } +} -pub fn bitwise_or(_ x: u256, _ y: u256) -> u256: - unsafe: - return __or(x, y) +pub fn bitwise_or(_ x: u256, _ y: u256) -> u256 { + unsafe { return __or(x, y) } +} -pub fn bitwise_not(_ x: u256) -> u256: - unsafe: - return __not(x) +pub fn bitwise_not(_ x: u256) -> u256 { + unsafe { return __not(x) } +} -pub fn xor(_ x: u256, _ y: u256) -> u256: - unsafe: - return __xor(x, y) +pub fn xor(_ x: u256, _ y: u256) -> u256 { + unsafe { return __xor(x, y) } +} -pub fn byte(offset: u256, _ x: u256) -> u256: - unsafe: - return __byte(offset, x) +pub fn byte(offset: u256, _ x: u256) -> u256 { + unsafe { return __byte(offset, x) } +} -pub fn shl(_ x: u256, _ y: u256) -> u256: - unsafe: - return __shl(x, y) +pub fn shl(_ x: u256, _ y: u256) -> u256 { + unsafe { return __shl(x, y) } +} -pub fn shr(_ x: u256, _ y: u256) -> u256: - unsafe: - return __shr(x, y) +pub fn shr(_ x: u256, _ y: u256) -> u256 { + unsafe { return __shr(x, y) } +} -pub fn sar(_ x: u256, _ y: u256) -> u256: - unsafe: - return __sar(x, y) +pub fn sar(_ x: u256, _ y: u256) -> u256 { + unsafe { return __sar(x, y) } +} # Evm state access and control -pub unsafe fn return_mem(offset: u256, len: u256): +pub unsafe fn return_mem(offset: u256, len: u256) { __return(offset, len) +} -pub unsafe fn revert_mem(offset: u256, len: u256): +pub unsafe fn revert_mem(offset: u256, len: u256) { __revert(offset, len) +} -pub unsafe fn selfdestruct(_ addr: address): +pub unsafe fn selfdestruct(_ addr: address) { __selfdestruct(u256(addr)) +} # Invalid opcode. Equivalent to revert(0, 0), # except that all remaining gas in the current context # is consumed. -pub unsafe fn invalid(): +pub unsafe fn invalid() { __invalid() +} -pub unsafe fn stop(): +pub unsafe fn stop() { __stop() +} -pub unsafe fn pc() -> u256: +pub unsafe fn pc() -> u256 { return __pc() +} # TODO: dunno if we should enable this -# pub unsafe fn pop(_ x: u256): +# pub unsafe fn pop(_ x: u256) { # return __pop(x) +# } -pub unsafe fn mload(offset p: u256) -> u256: +pub unsafe fn mload(offset p: u256) -> u256 { return __mload(p) +} -pub unsafe fn mstore(offset p: u256, value v: u256): +pub unsafe fn mstore(offset p: u256, value v: u256) { __mstore(p, v) +} -pub unsafe fn mstore8(offset p: u256, value v: u256): +pub unsafe fn mstore8(offset p: u256, value v: u256) { __mstore8(p, v) +} -pub unsafe fn sload(offset p: u256) -> u256: +pub unsafe fn sload(offset p: u256) -> u256 { return __sload(p) +} -pub unsafe fn sstore(offset p: u256, value v: u256): +pub unsafe fn sstore(offset p: u256, value v: u256) { __sstore(p, v) +} -pub unsafe fn msize() -> u256: +pub unsafe fn msize() -> u256 { return __msize() +} -pub unsafe fn call_data_load(offset p: u256) -> u256: +pub unsafe fn call_data_load(offset p: u256) -> u256 { return __calldataload(p) +} -pub unsafe fn call_data_size() -> u256: +pub unsafe fn call_data_size() -> u256 { return __calldatasize() +} -pub unsafe fn call_data_copy(to_offset t: u256, from_offset f: u256, len: u256): +pub unsafe fn call_data_copy(to_offset t: u256, from_offset f: u256, len: u256) { __calldatacopy(t, f, len) +} -pub unsafe fn code_size() -> u256: +pub unsafe fn code_size() -> u256 { return __codesize() +} -pub unsafe fn code_copy(to_offset t: u256, from_offset f: u256, len: u256): +pub unsafe fn code_copy(to_offset t: u256, from_offset f: u256, len: u256) { __codecopy(t, f, len) +} -pub unsafe fn return_data_size() -> u256: +pub unsafe fn return_data_size() -> u256 { return __returndatasize() +} -pub unsafe fn return_data_copy(to_offset t: u256, from_offset f: u256, len: u256): +pub unsafe fn return_data_copy(to_offset t: u256, from_offset f: u256, len: u256) { __returndatacopy(t, f, len) +} -pub unsafe fn extcodesize(_ addr: address) -> u256: +pub unsafe fn extcodesize(_ addr: address) -> u256 { return __extcodesize(u256(addr)) +} -pub unsafe fn ext_code_copy(_ addr: address, to_offset t: u256, from_offset f: u256, len: u256): +pub unsafe fn ext_code_copy(_ addr: address, to_offset t: u256, from_offset f: u256, len: u256) { __extcodecopy(u256(addr), t, f, len) +} -pub unsafe fn ext_code_hash(_ addr: address) -> u256: +pub unsafe fn ext_code_hash(_ addr: address) -> u256 { return __extcodehash(u256(addr)) +} -pub unsafe fn keccak256_mem(offset: u256, len: u256) -> u256: +pub unsafe fn keccak256_mem(offset: u256, len: u256) -> u256 { return __keccak256(offset, len) +} # Contract creation and calling -pub unsafe fn create(value v: u256, offset p: u256, len n: u256) -> address: +pub unsafe fn create(value v: u256, offset p: u256, len n: u256) -> address { return address(__create(v, p, n)) +} -pub unsafe fn create2(value v: u256, offset p: u256, len n: u256, salt s: u256) -> address: +pub unsafe fn create2(value v: u256, offset p: u256, len n: u256, salt s: u256) -> address { return address(__create2(v, p, n, s)) +} # TODO: return bool (success) -pub unsafe fn call(gas: u256, addr: address, value: u256, input_offset: u256, input_len: u256, output_offset: u256, output_len: u256) -> u256: +pub unsafe fn call(gas: u256, addr: address, value: u256, input_offset: u256, input_len: u256, output_offset: u256, output_len: u256) -> u256 { return __call(gas, u256(addr), value, input_offset, input_len, output_offset, output_len) +} -pub unsafe fn call_code(gas: u256, addr: address, value: u256, input_offset: u256, input_len: u256, output_offset: u256, output_len: u256) -> u256: +pub unsafe fn call_code(gas: u256, addr: address, value: u256, input_offset: u256, input_len: u256, output_offset: u256, output_len: u256) -> u256 { return __callcode(gas, u256(addr), value, input_offset, input_len, output_offset, output_len) +} -pub unsafe fn delegate_call(gas: u256, addr: address, value: u256, input_offset: u256, input_len: u256, output_offset: u256, output_len: u256) -> u256: +pub unsafe fn delegate_call(gas: u256, addr: address, value: u256, input_offset: u256, input_len: u256, output_offset: u256, output_len: u256) -> u256 { return __delegatecall(gas, u256(addr), input_offset, input_len, output_offset, output_len) +} -pub unsafe fn static_call(gas: u256, addr: address, input_offset: u256, input_len: u256, output_offset: u256, output_len: u256) -> u256: +pub unsafe fn static_call(gas: u256, addr: address, input_offset: u256, input_len: u256, output_offset: u256, output_len: u256) -> u256 { return __staticcall(gas, u256(addr), input_offset, input_len, output_offset, output_len) +} # Logging functions -pub unsafe fn log0(offset p: u256, len s: u256): +pub unsafe fn log0(offset p: u256, len s: u256) { return __log0(p, s) +} -pub unsafe fn log1(offset p: u256, len s: u256, topic1 t1: u256): +pub unsafe fn log1(offset p: u256, len s: u256, topic1 t1: u256) { return __log1(p, s, t1) +} -pub unsafe fn log2(offset p: u256, len s: u256, topic1 t1: u256, topic2 t2: u256): +pub unsafe fn log2(offset p: u256, len s: u256, topic1 t1: u256, topic2 t2: u256) { return __log2(p, s, t1, t2) +} -pub unsafe fn log3(offset p: u256, len s: u256, topic1 t1: u256, topic2 t2: u256, topic3 t3: u256): +pub unsafe fn log3(offset p: u256, len s: u256, topic1 t1: u256, topic2 t2: u256, topic3 t3: u256) { return __log3(p, s, t1, t2, t3) +} -pub unsafe fn log4(offset p: u256, len s: u256, topic1 t1: u256, topic2 t2: u256, topic3 t3: u256, topic4 t4: u256): - return __log4(p, s, t1, t2, t3, t4) \ No newline at end of file +pub unsafe fn log4(offset p: u256, len s: u256, topic1 t1: u256, topic2 t2: u256, topic3 t3: u256, topic4 t4: u256) { + return __log4(p, s, t1, t2, t3, t4) +} diff --git a/crates/library/std/src/lib.fe b/crates/library/std/src/lib.fe index bdf64a76ca..8a94dde71d 100644 --- a/crates/library/std/src/lib.fe +++ b/crates/library/std/src/lib.fe @@ -1,2 +1,3 @@ -pub fn get_42() -> u256: +pub fn get_42() -> u256 { return 42 +} \ No newline at end of file diff --git a/crates/mir/src/lower/function.rs b/crates/mir/src/lower/function.rs index d0b743cbe7..2c0fd7a0fb 100644 --- a/crates/mir/src/lower/function.rs +++ b/crates/mir/src/lower/function.rs @@ -247,13 +247,6 @@ impl<'db, 'a> BodyLowerHelper<'db, 'a> { self.lower_expr_to_value(value); } - ast::FuncStmt::Pass => { - // TODO: Generate appropriate error message. - self.builder.revert(None, stmt.into()); - let next_block = self.builder.make_block(); - self.builder.move_to_block(next_block); - } - ast::FuncStmt::Break => { let exit = self.scope().loop_exit(&self.scopes); self.builder.jump(exit, stmt.into()); diff --git a/crates/parser/src/ast.rs b/crates/parser/src/ast.rs index f27a4a055d..d1e27d8e12 100644 --- a/crates/parser/src/ast.rs +++ b/crates/parser/src/ast.rs @@ -247,7 +247,6 @@ pub enum FuncStmt { Expr { value: Node, }, - Pass, Break, Continue, Revert { @@ -447,7 +446,22 @@ impl Spanned for ContractStmt { impl fmt::Display for Module { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - writeln!(f, "{}", double_line_joined(&self.body)) + let (uses, rest): (Vec<&ModuleStmt>, Vec<&ModuleStmt>) = self + .body + .iter() + .partition(|&stmt| matches!(stmt, ModuleStmt::Use(_) | ModuleStmt::Pragma(_))); + for stmt in &uses { + writeln!(f, "{}", stmt)?; + } + if !uses.is_empty() && !rest.is_empty() { + writeln!(f)?; + } + let mut delim = ""; + for stmt in rest { + writeln!(f, "{}{}", delim, stmt)?; + delim = "\n"; + } + Ok(()) } } @@ -477,6 +491,7 @@ impl fmt::Display for Pragma { impl fmt::Display for Use { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + // TODO pub use write!(f, "use {}", self.tree.kind) } } @@ -515,46 +530,86 @@ impl fmt::Display for Path { impl fmt::Display for ConstantDecl { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - write!( - f, - "const {}: {} = {}", - self.name.kind, self.typ.kind, self.value.kind - ) + let ConstantDecl { + name, + typ, + value, + pub_qual, + } = self; + if pub_qual.is_some() { + write!(f, "pub ")?; + } + write!(f, "const {}: {} = {}", name.kind, typ.kind, value.kind) } } impl fmt::Display for TypeAlias { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - write!(f, "type {} = {}", self.name.kind, self.typ.kind) + let TypeAlias { + name, + typ, + pub_qual, + } = self; + if pub_qual.is_some() { + write!(f, "pub ")?; + } + write!(f, "type {} = {}", name.kind, typ.kind) } } impl fmt::Display for Contract { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - writeln!(f, "contract {}:", self.name.kind)?; - if !self.fields.is_empty() { - write!(indented(f), "{}\n\n", node_line_joined(&self.fields))?; - } - if !self.body.is_empty() { - write!(indented(f), "{}", double_line_joined(&self.body))?; + let Contract { + name, + fields, + body, + pub_qual, + } = self; + + if pub_qual.is_some() { + write!(f, "pub ")?; } + write!(f, "contract {} {{", name.kind)?; - Ok(()) + if !fields.is_empty() { + for field in fields { + writeln!(f)?; + write!(indented(f), "{}", field.kind)?; + } + writeln!(f)?; + } + if !body.is_empty() { + writeln!(f)?; + write!(indented(f), "{}", double_line_joined(body))?; + writeln!(f)?; + } + write!(f, "}}") } } impl fmt::Display for Struct { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - writeln!(f, "struct {}:", self.name.kind)?; - if self.fields.is_empty() && self.functions.is_empty() { - write!(indented(f), "pass") - } else { - write!(indented(f), "{}", node_line_joined(&self.fields))?; - if !self.fields.is_empty() && !self.functions.is_empty() { - write!(f, "\n\n")?; - } - write!(indented(f), "{}", double_line_joined(&self.functions)) + let Struct { + name, + fields, + functions, + pub_qual, + } = self; + + if pub_qual.is_some() { + write!(f, "pub ")?; } + write!(f, "struct {} ", name.kind)?; + write!(f, "{{")?; + write_nodes_line_wrapped(&mut indented(f), fields)?; + + if !self.fields.is_empty() && !functions.is_empty() { + writeln!(f)?; + } + if !functions.is_empty() { + writeln!(indented(f), "{}", double_line_joined(functions))?; + } + write!(f, "}}") } } @@ -564,7 +619,13 @@ impl fmt::Display for TypeDesc { TypeDesc::Unit => write!(f, "()"), TypeDesc::Base { base } => write!(f, "{}", base), TypeDesc::Path(path) => write!(f, "{}", path), - TypeDesc::Tuple { items } => write!(f, "({})", node_comma_joined(items)), + TypeDesc::Tuple { items } => { + if items.len() == 1 { + write!(f, "({},)", items[0].kind) + } else { + write!(f, "({})", node_comma_joined(items)) + } + } TypeDesc::Generic { base, args } => { write!(f, "{}<{}>", base.kind, comma_joined(&args.kind)) } @@ -572,12 +633,21 @@ impl fmt::Display for TypeDesc { } } +impl fmt::Display for GenericParameter { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + match self { + GenericParameter::Unbounded(name) => write!(f, "{}", name.kind), + GenericParameter::Bounded { name, bound } => write!(f, "{}: {}", name.kind, bound.kind), + } + } +} + impl fmt::Display for GenericArg { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { GenericArg::TypeDesc(node) => write!(f, "{}", node.kind), GenericArg::Int(node) => write!(f, "{}", node.kind), - GenericArg::ConstExpr(node) => write!(f, "{}", node.kind), + GenericArg::ConstExpr(node) => write!(f, "{{ {} }}", node.kind), } } } @@ -605,11 +675,13 @@ impl fmt::Display for ContractStmt { impl fmt::Display for Event { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - writeln!(f, "event {}:", self.name.kind)?; + write!(f, "event {} ", self.name.kind)?; if self.fields.is_empty() { - write!(indented(f), "pass") + write!(f, "{{}}") } else { - write!(indented(f), "{}", node_line_joined(&self.fields)) + writeln!(f, "{{")?; + writeln!(indented(f), "{}", node_line_joined(&self.fields))?; + write!(f, "}}") } } } @@ -622,21 +694,34 @@ impl fmt::Display for Node { impl fmt::Display for Function { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - if self.is_pub() { + let Function { + pub_, + unsafe_, + name, + generic_params, + args, + return_type, + body, + } = self; + + if pub_.is_some() { write!(f, "pub ")?; } - write!( - f, - "fn {}({})", - self.name.kind, - node_comma_joined(&self.args) - )?; - if let Some(return_type) = self.return_type.as_ref() { - writeln!(f, " -> {}:", return_type.kind)?; - } else { - writeln!(f, ":")?; + if unsafe_.is_some() { + write!(f, "unsafe ")?; + } + write!(f, "fn {}", name.kind)?; + if !generic_params.kind.is_empty() { + write!(f, "<{}>", comma_joined(&generic_params.kind))?; + } + write!(f, "({})", node_comma_joined(args))?; + + if let Some(return_type) = return_type.as_ref() { + write!(f, " -> {}", return_type.kind)?; } - write!(indented(f), "{}", node_line_joined(&self.body)) + write!(f, " {{")?; + write_nodes_line_wrapped(&mut indented(f), body)?; + write!(f, "}}") } } @@ -692,25 +777,44 @@ impl fmt::Display for FuncStmt { write!(f, "{} {}= {}", target.kind, op.kind, value.kind) } FuncStmt::For { target, iter, body } => { - writeln!(f, "for {} in {}:", target.kind, iter.kind)?; - writeln!(indented(f), "{}", node_line_joined(body)) + write!(f, "for {} in {} {{", target.kind, iter.kind)?; + write_nodes_line_wrapped(&mut indented(f), body)?; + write!(f, "}}") } FuncStmt::While { test, body } => { - writeln!(f, "while {}:", test.kind)?; - writeln!(indented(f), "{}", node_line_joined(body)) + write!(f, "while {} {{", test.kind)?; + write_nodes_line_wrapped(&mut indented(f), body)?; + write!(f, "}}") } FuncStmt::If { test, body, or_else, } => { - writeln!(f, "if {}:", test.kind)?; - writeln!(indented(f), "{}", node_line_joined(body))?; + write!(f, "if {} {{", test.kind)?; + write_nodes_line_wrapped(&mut indented(f), body)?; + if or_else.is_empty() { - Ok(()) + write!(f, "}}") } else { - writeln!(f, "else:")?; - writeln!(indented(f), "{}", node_line_joined(or_else)) + if body.is_empty() { + writeln!(f)?; + } + + if matches!( + &or_else[..], + &[Node { + kind: FuncStmt::If { .. }, + .. + }] + ) { + write!(f, "}} else ")?; + write!(f, "{}", or_else[0].kind) + } else { + write!(f, "}} else {{")?; + write_nodes_line_wrapped(&mut indented(f), or_else)?; + write!(f, "}}") + } } } FuncStmt::Assert { test, msg } => { @@ -724,7 +828,6 @@ impl fmt::Display for FuncStmt { write!(f, "emit {}({})", name.kind, node_comma_joined(&args.kind)) } FuncStmt::Expr { value } => write!(f, "{}", value.kind), - FuncStmt::Pass => write!(f, "pass"), FuncStmt::Break => write!(f, "break"), FuncStmt::Continue => write!(f, "continue"), FuncStmt::Revert { error } => { @@ -735,8 +838,9 @@ impl fmt::Display for FuncStmt { } } FuncStmt::Unsafe(body) => { - writeln!(f, "unsafe:")?; - writeln!(indented(f), "{}", node_line_joined(body)) + write!(f, "unsafe {{")?; + write_nodes_line_wrapped(&mut indented(f), body)?; + write!(f, "}}") } } } @@ -746,7 +850,13 @@ impl fmt::Display for VarDeclTarget { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { VarDeclTarget::Name(name) => write!(f, "{}", name), - VarDeclTarget::Tuple(elts) => write!(f, "{}", node_comma_joined(elts)), + VarDeclTarget::Tuple(elts) => { + if elts.len() == 1 { + write!(f, "({},)", elts[0].kind) + } else { + write!(f, "({})", node_comma_joined(elts)) + } + } } } } @@ -800,7 +910,13 @@ impl fmt::Display for Expr { write!(f, "({})", node_comma_joined(&args.kind)) } Expr::List { elts } => write!(f, "[{}]", node_comma_joined(elts)), - Expr::Tuple { elts } => write!(f, "({})", node_comma_joined(elts)), + Expr::Tuple { elts } => { + if elts.len() == 1 { + write!(f, "({},)", elts[0].kind) + } else { + write!(f, "({})", node_comma_joined(elts)) + } + } Expr::Bool(bool) => write!(f, "{}", bool), Expr::Name(name) => write!(f, "{}", name), Expr::Path(path) => write!(f, "{}", path), @@ -892,6 +1008,16 @@ fn comma_joined(items: &[impl fmt::Display]) -> String { .join(", ") } +fn write_nodes_line_wrapped(f: &mut impl Write, nodes: &[Node]) -> fmt::Result { + if !nodes.is_empty() { + writeln!(f)?; + } + for n in nodes { + writeln!(f, "{}", n.kind)?; + } + Ok(()) +} + fn node_line_joined(nodes: &[Node]) -> String { line_joined(&nodes.iter().map(|node| &node.kind).collect::>()) } diff --git a/crates/parser/src/grammar/Fe.grammar b/crates/parser/src/grammar/Fe.grammar index ffa385f93c..9d8d931b7c 100644 --- a/crates/parser/src/grammar/Fe.grammar +++ b/crates/parser/src/grammar/Fe.grammar @@ -24,21 +24,11 @@ type_def: 'type' NAME '=' type_desc NEWLINE ########################### contract_def ############################# -contract_def: - 'contract' NAME ':' NEWLINE - INDENT - contract_stmt+ - DEDENT - +contract_def: 'contract' NAME '{' contract_stmt* '}' contract_stmt: contract_field | event_def | func_def - contract_field: [contract_field_qual] NAME ':' type_desc NEWLINE -event_def: - 'event' NAME ':' NEWLINE - INDENT - event_field+ - DEDENT +event_def: 'event' NAME '{' event_field* '}' event_field: [event_field_qual] NAME ':' type_desc NEWLINE func_def: @@ -61,9 +51,9 @@ func_qual: 'pub' ########################### func_stmt ############################### func_stmt: compound_stmt | simple_stmt -simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE +simple_stmt: small_stmt (';' small_stmt)* [';'] -small_stmt: return_stmt | assert_stmt | emit_stmt | pass_stmt | break_stmt | +small_stmt: return_stmt | assert_stmt | emit_stmt | break_stmt | continue_stmt | revert_stmt | vardecl_stmt | assign_stmt | augassign_stmt | exprs @@ -71,7 +61,6 @@ return_stmt: 'return' [exprs] assert_stmt: 'assert' expr [',' expr] emit_stmt: 'emit' expr -pass_stmt: 'pass' break_stmt: 'break' continue_stmt: 'continue' revert_stmt: 'revert' @@ -85,17 +74,14 @@ augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' compound_stmt: if_stmt | while_stmt | for_stmt -if_stmt: 'if' expr ':' block elif_stmt | - 'if' expr ':' block [else_block] -elif_stmt: 'elif' expr ':' block elif_stmt | - 'elif' expr ':' block [else_block] -else_block: 'else' ':' block +if_stmt: 'if' expr block [else_block] +else_block: 'else' block -while_stmt: 'while' expr ':' block [else_block] +while_stmt: 'while' expr block [else_block] -for_stmt: 'for' targets 'in' exprs ':' block [else_block] +for_stmt: 'for' targets 'in' exprs block [else_block] -block: simple_stmt | NEWLINE INDENT func_stmt+ DEDENT +block: '{' (simple_stmt | func_stmt+) '}' exprs: expr (',' expr)* [','] diff --git a/crates/parser/src/grammar/Python.asdl b/crates/parser/src/grammar/Python.asdl deleted file mode 100644 index e54b882341..0000000000 --- a/crates/parser/src/grammar/Python.asdl +++ /dev/null @@ -1,130 +0,0 @@ --- ASDL's 7 builtin types are: --- identifier, int, string, bytes, object, singleton, constant --- --- singleton: None, True or False --- constant can be None, whereas None means "no value" for object. - -module Python -{ - mod = Module(stmt* body) - | Interactive(stmt* body) - | Expression(expr body) - - -- not really an actual node but useful in Jython's typesystem. - | Suite(stmt* body) - - stmt = FunctionDef(identifier name, arguments args, - stmt* body, expr* decorator_list, expr? returns) - | AsyncFunctionDef(identifier name, arguments args, - stmt* body, expr* decorator_list, expr? returns) - - | ClassDef(identifier name, - expr* bases, - keyword* keywords, - stmt* body, - expr* decorator_list) - | Return(expr? value) - - | Delete(expr* targets) - | Assign(expr* targets, expr value) - | AugAssign(expr target, operator op, expr value) - -- 'simple' indicates that we annotate simple name without parens - | AnnAssign(expr target, expr annotation, expr? value, int simple) - - -- use 'orelse' because else is a keyword in target languages - | For(expr target, expr iter, stmt* body, stmt* orelse) - | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse) - | While(expr test, stmt* body, stmt* orelse) - | If(expr test, stmt* body, stmt* orelse) - | With(withitem* items, stmt* body) - | AsyncWith(withitem* items, stmt* body) - - | Raise(expr? exc, expr? cause) - | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody) - | Assert(expr test, expr? msg) - - | Import(alias* names) - | ImportFrom(identifier? module, alias* names, int? level) - - | Global(identifier* names) - | Nonlocal(identifier* names) - | Expr(expr value) - | Pass | Break | Continue - - -- XXX Jython will be different - -- col_offset is the byte offset in the utf8 string the parser uses - attributes (int lineno, int col_offset) - - -- BoolOp() can use left & right? - expr = BoolOp(boolop op, expr* values) - | BinOp(expr left, operator op, expr right) - | UnaryOp(unaryop op, expr operand) - | Lambda(arguments args, expr body) - | IfExp(expr test, expr body, expr orelse) - | Dict(expr* keys, expr* values) - | Set(expr* elts) - | SetComp(expr elt, comprehension* generators) - | DictComp(expr key, expr value, comprehension* generators) - | GeneratorExp(expr elt, comprehension* generators) - -- the grammar constrains where yield expressions can occur - | Await(expr value) - | Yield(expr? value) - | YieldFrom(expr value) - -- need sequences for compare to distinguish between - -- x < 4 < 3 and (x < 4) < 3 - | Compare(expr left, cmpop* ops, expr* comparators) - | Call(expr func, expr* args, keyword* keywords) - | Num(object n) -- a number as a PyObject. - | Str(string s) -- need to specify raw, unicode, etc? - | FormattedValue(expr value, int? conversion, expr? format_spec) - | JoinedStr(expr* values) - | Bytes(bytes s) - | NameConstant(singleton value) - | Ellipsis - | Constant(constant value) - - -- the following expression can appear in assignment context - | Attribute(expr value, identifier attr, expr_context ctx) - | Subscript(expr value, slice slice, expr_context ctx) - | Starred(expr value, expr_context ctx) - | Name(identifier id, expr_context ctx) - | List(expr* elts, expr_context ctx) - | Tuple(expr* elts, expr_context ctx) - - -- col_offset is the byte offset in the utf8 string the parser uses - attributes (int lineno, int col_offset) - - expr_context = Load | Store | Del | AugLoad | AugStore | Param - - slice = Slice(expr? lower, expr? upper, expr? step) - | ExtSlice(slice* dims) - | Index(expr value) - - boolop = And | Or - - operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift - | RShift | BitOr | BitXor | BitAnd | FloorDiv - - unaryop = Invert | Not | UAdd | USub - - cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn - - comprehension = (expr target, expr iter, expr* ifs, int is_async) - - excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body) - attributes (int lineno, int col_offset) - - arguments = (arg* args, arg? vararg, arg* kwonlyargs, expr* kw_defaults, - arg? kwarg, expr* defaults) - - arg = (identifier arg, expr? annotation) - attributes (int lineno, int col_offset) - - -- keyword arguments supplied to call (NULL identifier for **kwargs) - keyword = (identifier? arg, expr value) - - -- import name with optional 'as' alias. - alias = (identifier name, identifier? asname) - - withitem = (expr context_expr, expr? optional_vars) -} diff --git a/crates/parser/src/grammar/SimPy.grammar b/crates/parser/src/grammar/SimPy.grammar deleted file mode 100644 index c0428f8095..0000000000 --- a/crates/parser/src/grammar/SimPy.grammar +++ /dev/null @@ -1,164 +0,0 @@ -# Simplified grammar for Python - -start: [statements] ENDMARKER -statements: statement+ - -statement: compound_stmt | simple_stmt -simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE -# NOTE: assignment MUST precede expression, else the parser will get stuck; -# but it must follow all others, else reserved words will match a simple NAME. -small_stmt: ( return_stmt | import_stmt | 'pass' | raise_stmt | yield_stmt | assert_stmt | del_stmt | global_stmt | nonlocal_stmt - | assignment | expressions - ) -compound_stmt: if_stmt | while_stmt | for_stmt | with_stmt | try_stmt | function_def | class_def - -# NOTE: yield_expression may start with 'yield'; yield_expr must start with 'yield' -assignment: target ':' expression ['=' yield_expression] | (star_targets '=')+ (yield_expr | expressions) | target augassign (yield_expr | expressions) -augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//=') - -global_stmt: 'global' NAME (',' NAME)* -nonlocal_stmt: 'nonlocal' NAME (',' NAME)* - -yield_stmt: yield_expr - -assert_stmt: 'assert' expression [',' expression] - -del_stmt: 'del' targets # TODO: exclude *target - -import_stmt: import_name | import_from -import_name: 'import' dotted_as_names -# note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS -import_from: ('from' (('.' | '...')* !'import' dotted_name | ('.' | '...')+) - 'import' ('*' | '(' import_as_names ')' | import_as_names)) -import_as_name: NAME ['as' NAME] -dotted_as_name: dotted_name ['as' NAME] -import_as_names: import_as_name (',' import_as_name)* [','] -dotted_as_names: dotted_as_name (',' dotted_as_name)* -dotted_name: NAME ('.' NAME)* - -if_stmt: 'if' full_expression ':' block elif_block* [else_block] -elif_block: 'elif' full_expression ':' block -else_block: 'else' ':' block - -while_stmt: 'while' full_expression ':' block [else_block] - -for_stmt: [ASYNC] 'for' star_targets 'in' expressions ':' block [else_block] - -with_stmt: [ASYNC] 'with' expression ['as' target] (',' [expression ['as' target]])* ':' block - -try_stmt: try_block finally_block | try_block except_block+ [else_block] [finally_block] -try_block: 'try' ':' block -except_block: 'except' [expression ['as' target]] ':' block -finally_block: 'finally' ':' block - -return_stmt: 'return' [expressions] - -raise_stmt: 'raise' [expression ['from' expression]] - -function_def: [decorators] [ASYNC] 'def' NAME '(' [parameters] ')' ['->' annotation] ':' block - -parameters: ( slash_without_default [',' plain_names] [',' names_with_default] [',' [star_etc]] - | slash_with_default [',' names_with_default] [',' [star_etc]] - | plain_names [',' names_with_default] [',' [star_etc]] - | names_with_default [',' [star_etc]] - | star_etc - ) -slash_without_default: plain_names ',' '/' -slash_with_default: [plain_names ','] names_with_default ',' '/' -names_with_default: name_with_default (',' name_with_default)* -plain_names: plain_name !'=' (',' plain_name !'=')* -star_etc: ( '*' NAME [':' annotation] (',' plain_name ['=' expression])* [',' kwds] [','] - | '*' (',' plain_name ['=' expression])+ [',' kwds] [','] - | kwds [','] - ) -name_with_default: plain_name '=' expression -plain_name: NAME [':' annotation] -kwds: '**' NAME [':' annotation] -annotation: expression - -decorators: ('@' factor NEWLINE)+ - -class_def: [decorators] 'class' NAME ['(' [arguments] ')'] ':' block - -block: simple_stmt | NEWLINE INDENT statements DEDENT - -star_full_expressions: (star_full_expression) (',' (star_full_expression))* [','] -expressions: ('*' bitwise_or | expression) (',' ('*' bitwise_or | expression))* [','] - -star_full_expression: '*' bitwise_or | full_expression -full_expression: NAME ':=' expression | expression -yield_expression: yield_expr | expression -expression: lambdef | disjunction ['if' disjunction 'else' expression] -lambdef: 'lambda' [lambda_parameters] ':' expression - -lambda_parameters: ( lambda_slash_without_default [',' lambda_plain_names] [',' lambda_names_with_default] [',' [lambda_star_etc]] - | lambda_slash_with_default [',' lambda_names_with_default] [',' [lambda_star_etc]] - | lambda_plain_names [',' lambda_names_with_default] [',' [lambda_star_etc]] - | lambda_names_with_default [',' [lambda_star_etc]] - | lambda_star_etc - ) -lambda_slash_without_default: lambda_plain_names ',' '/' -lambda_slash_with_default: [lambda_plain_names ','] lambda_names_with_default ',' '/' -lambda_names_with_default: lambda_name_with_default (',' lambda_name_with_default)* -lambda_plain_names: NAME !'=' (',' NAME !'=')* -lambda_star_etc: ( '*' NAME (',' NAME ['=' expression])* [',' '**' NAME] [','] - | '*' (',' NAME ['=' expression])+ [',' '**' NAME] [','] - | '**' NAME [','] - ) -lambda_name_with_default: NAME '=' expression - -disjunction: conjunction ('or' conjunction)* -conjunction: comparison ('and' comparison)* -comparison: 'not'* bitwise_or (compare_op bitwise_or)* -compare_op: '<' | '<=' | '==' | '>=' | '>' | '!=' | ['not'] 'in' | 'is' ['not'] - -bitwise_or: bitwise_xor ('|' bitwise_xor)* -bitwise_xor: bitwise_and ('^' bitwise_and)* -bitwise_and: shift_expr ('&' shift_expr)* -shift_expr: sum (('<<'|'>>') sum)* - -sum: term (('+' term | '-' term))* -term: factor (('*' factor | '/' factor | '//' factor | '%' factor | '@' factor))* -factor: ('+' | '-' | '~') factor | power -power: primary '**' factor | primary -primary: [AWAIT] atom ('.' NAME | '[' slices ']' | '(' [arguments] ')')* - -slices: slice (',' slice)* [','] -slice: [expression] ':' [expression] [':' [expression]] | expression -atom: list | listcomp | tuple | group | genexp | set | setcomp | dict | dictcomp | NAME | STRING+ | NUMBER | '...' -list: '[' [star_full_expressions] ']' -listcomp: '[' full_expression for_if_clauses ']' -tuple: '(' [star_full_expression ',' [star_full_expressions]] ')' -group: '(' (yield_expr | full_expression) ')' -genexp: '(' expression for_if_clauses ')' -set: '{' expressions '}' -setcomp: '{' expression for_if_clauses '}' -dict: '{' [kvpairs] '}' -dictcomp: '{' kvpair for_if_clauses '}' -kvpairs: kvpair (',' kvpair)* [','] -kvpair: '**' bitwise_or | expression ':' expression -for_if_clauses: ([ASYNC] 'for' star_targets 'in' expression ('if' expression)*)+ - -yield_expr: 'yield' 'from' expression | 'yield' [expressions] - -arguments: expression for_if_clauses | args [','] -args: '*' expression [',' args] | kwargs | posarg [',' args] # Weird to make it work -kwargs: kwarg (',' kwarg)* -posarg: full_expression | '*' expression -kwarg: NAME '=' expression | '*' expression | '**' expression - -# NOTE: star_targets may contain *NAME, targets may not. -# NOTE: the !'in' is to handle "for x, in ...". -# TODO: things like {k: v}[k] = v should also be acceptable [star] targets. -star_targets: star_target (',' !'in' star_target)* [','] -star_target: '*' bitwise_or | atom t_tail+ | star_atom t_tail* -star_atom: NAME | '(' [star_targets] ')' | '[' [star_targets] ']' - -targets: target (',' target)* [','] -target: atom t_tail+ | t_atom t_tail* -t_atom: NAME | '(' [targets] ')' | '[' [targets] ']' - -t_tail: call_tail* (attr_tail | index_tail) -call_tail: '(' [arguments] ')' -attr_tail: '.' NAME -index_tail: '[' slices ']' diff --git a/crates/parser/src/grammar/contracts.rs b/crates/parser/src/grammar/contracts.rs index 9a75269bd2..5841c6c949 100644 --- a/crates/parser/src/grammar/contracts.rs +++ b/crates/parser/src/grammar/contracts.rs @@ -2,7 +2,6 @@ use super::functions::parse_fn_def; use super::types::{parse_event_def, parse_field, parse_opt_qualifier}; use crate::ast::{Contract, ContractStmt}; -use crate::grammar::functions::parse_single_word_stmt; use crate::node::{Node, Span}; use crate::{ParseFailed, ParseResult, Parser, TokenKind}; @@ -20,33 +19,20 @@ pub fn parse_contract_def( contract_pub_qual: Option, ) -> ParseResult> { let contract_tok = par.assert(TokenKind::Contract); - - // contract Foo: - // x: Map - // pub y: u8 - // const z: u256 = 10 - // - // event Sent: - // idx sender: address - // val: u256 - // - // pub fn foo() -> address: - // return abc - // - let contract_name = par.expect_with_notes( TokenKind::Name, "failed to parse contract definition", |_| vec!["Note: `contract` must be followed by a name, which must start with a letter and contain only letters, numbers, or underscores".into()], )?; - let header_span = contract_tok.span + contract_name.span; - par.enter_block(header_span, "contract definition")?; + let mut span = contract_tok.span + contract_name.span; + par.enter_block(span, "contract definition")?; let mut fields = vec![]; let mut defs = vec![]; loop { + par.eat_newlines(); let mut pub_qual = parse_opt_qualifier(par, TokenKind::Pub); let const_qual = parse_opt_qualifier(par, TokenKind::Const); if pub_qual.is_none() && const_qual.is_some() && par.peek() == Some(TokenKind::Pub) { @@ -57,15 +43,15 @@ pub fn parse_contract_def( ); } - match par.peek() { - Some(TokenKind::Name) => { + match par.peek_or_err()? { + TokenKind::Name => { let field = parse_field(par, pub_qual, const_qual)?; if !defs.is_empty() { par.error(field.span, "contract field definitions must come before any function or event definitions"); } fields.push(field); } - Some(TokenKind::Fn | TokenKind::Unsafe) => { + TokenKind::Fn | TokenKind::Unsafe => { if let Some(span) = const_qual { par.error( span, @@ -74,7 +60,7 @@ pub fn parse_contract_def( } defs.push(ContractStmt::Function(parse_fn_def(par, pub_qual)?)); } - Some(TokenKind::Event) => { + TokenKind::Event => { if let Some(span) = pub_qual { par.error( span, @@ -89,18 +75,14 @@ pub fn parse_contract_def( } defs.push(ContractStmt::Event(parse_event_def(par, None)?)); } - Some(TokenKind::Pass) => { - parse_single_word_stmt(par)?; - } - Some(TokenKind::Dedent) => { - par.next()?; + TokenKind::BraceClose => { + span += par.next()?.span; break; } - None => break, - Some(_) => { + _ => { let tok = par.next()?; par.unexpected_token_error( - tok.span, + &tok, "failed to parse contract definition body", vec![], ); @@ -109,7 +91,6 @@ pub fn parse_contract_def( }; } - let span = header_span + contract_pub_qual + fields.last() + defs.last(); Ok(Node::new( Contract { name: Node::new(contract_name.text.into(), contract_name.span), diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs index 746821aac4..8ced7ebb61 100644 --- a/crates/parser/src/grammar/expressions.rs +++ b/crates/parser/src/grammar/expressions.rs @@ -234,7 +234,7 @@ fn parse_expr_head(par: &mut Parser) -> ParseResult> { _ => { let tok = par.next()?; par.unexpected_token_error( - tok.span, + &tok, format!("Unexpected token while parsing expression: `{}`", tok.text), vec![], ); @@ -336,7 +336,7 @@ fn parse_group_or_tuple(par: &mut Parser) -> ParseResult> { _ => { let tok = par.next()?; par.unexpected_token_error( - tok.span, + &tok, "Unexpected token while parsing expression in parentheses", vec![], ); @@ -370,7 +370,7 @@ fn parse_expr_list( _ => { let tok = par.next()?; par.unexpected_token_error( - tok.span, + &tok, "Unexpected token while parsing list of expressions", vec![], ); diff --git a/crates/parser/src/grammar/functions.rs b/crates/parser/src/grammar/functions.rs index 53b797f2bc..0ab78b9028 100644 --- a/crates/parser/src/grammar/functions.rs +++ b/crates/parser/src/grammar/functions.rs @@ -29,21 +29,21 @@ pub fn parse_fn_def(par: &mut Parser, mut pub_qual: Option) -> ParseResult let fn_tok = par.expect(TokenKind::Fn, "failed to parse function definition")?; let name = par.expect(TokenKind::Name, "failed to parse function definition")?; + let mut span = fn_tok.span + name.span + unsafe_qual + pub_qual; + let generic_params = if par.peek() == Some(TokenKind::Lt) { parse_generic_params(par)? } else { Node::new(vec![], name.span) }; - let mut span = fn_tok.span + unsafe_qual + pub_qual + name.span + generic_params.span; - let args = match par.peek_or_err()? { TokenKind::ParenOpen => { let node = parse_fn_param_list(par)?; span += node.span; node.kind } - TokenKind::Colon | TokenKind::Arrow => { + TokenKind::BraceOpen | TokenKind::Arrow => { par.fancy_error( "function definition requires a list of parameters", vec![Label::primary( @@ -65,7 +65,7 @@ pub fn parse_fn_def(par: &mut Parser, mut pub_qual: Option) -> ParseResult _ => { let tok = par.next()?; par.unexpected_token_error( - tok.span, + &tok, "failed to parse function definition", vec![ "function name must be followed by a list of parameters".into(), @@ -77,17 +77,18 @@ pub fn parse_fn_def(par: &mut Parser, mut pub_qual: Option) -> ParseResult }; let return_type = if par.peek() == Some(TokenKind::Arrow) { par.next()?; - Some(parse_type_desc(par)?) + let typ = parse_type_desc(par)?; + span += typ.span; + Some(typ) } else { None }; - span += return_type.as_ref(); // TODO: allow multi-line return type? `fn f()\n ->\n u8` - // TODO: allow single-line fn defs? par.enter_block(span, "function definition")?; let body = parse_block_stmts(par)?; - span += body.last(); + let rbrace = par.expect(TokenKind::BraceClose, "missing `}` in fn definition")?; + Ok(Node::new( Function { pub_: pub_qual, @@ -98,7 +99,7 @@ pub fn parse_fn_def(par: &mut Parser, mut pub_qual: Option) -> ParseResult return_type, body, }, - span, + span + rbrace.span, )) } @@ -140,7 +141,7 @@ pub fn parse_generic_params(par: &mut Parser) -> ParseResult { let tok = par.next()?; par.unexpected_token_error( - tok.span, + &tok, "Unexpected token while parsing generic arg list", vec!["Expected a `>` here".to_string()], ); @@ -170,7 +171,7 @@ pub fn parse_generic_params(par: &mut Parser) -> ParseResult { let tok = par.next()?; par.unexpected_token_error( - tok.span, + &tok, "failed to parse list of generic function parameters", vec!["Expected a generic parameter name such as `T` here".to_string()], ); @@ -241,11 +242,7 @@ fn parse_fn_param_list(par: &mut Parser) -> ParseResult { let tok = par.next()?; - par.unexpected_token_error( - tok.span, - "failed to parse function parameter list", - vec![], - ); + par.unexpected_token_error(&tok, "failed to parse function parameter list", vec![]); return Err(ParseFailed); } } @@ -253,17 +250,14 @@ fn parse_fn_param_list(par: &mut Parser) -> ParseResult ParseResult>> { let mut body = vec![]; loop { - match par.peek() { - None => break, - Some(TokenKind::Dedent) => { - par.next()?; - break; - } - Some(_) => body.push(parse_stmt(par)?), + par.eat_newlines(); + match par.peek_or_err()? { + TokenKind::BraceClose => break, + _ => body.push(parse_stmt(par)?), } } Ok(body) @@ -296,11 +290,10 @@ fn aug_assign_op(tk: TokenKind) -> Option { /// Panics if the next token isn't one of the above. pub fn parse_single_word_stmt(par: &mut Parser) -> ParseResult> { let tok = par.next()?; - par.expect_newline(tok.kind.describe())?; + par.expect_stmt_end(tok.kind.describe())?; let stmt = match tok.kind { TokenKind::Continue => FuncStmt::Continue, TokenKind::Break => FuncStmt::Break, - TokenKind::Pass => FuncStmt::Pass, _ => panic!(), }; Ok(Node::new(stmt, tok.span)) @@ -310,7 +303,7 @@ pub fn parse_single_word_stmt(par: &mut Parser) -> ParseResult> { pub fn parse_stmt(par: &mut Parser) -> ParseResult> { use TokenKind::*; - // rule: stmt parsing fns eat the trailing separator (newline, semi, eof) + // rule: stmt parsing fns eat the trailing separator (newline, semi) match par.peek_or_err()? { For => parse_for_stmt(par), If => parse_if_stmt(par), @@ -318,7 +311,7 @@ pub fn parse_stmt(par: &mut Parser) -> ParseResult> { Return => parse_return_stmt(par), Assert => parse_assert_stmt(par), Revert => parse_revert_stmt(par), - Continue | Break | Pass => parse_single_word_stmt(par), + Continue | Break => parse_single_word_stmt(par), Emit => parse_emit_statement(par), Let => parse_var_decl(par), Const => parse_const_decl(par), @@ -342,7 +335,7 @@ fn parse_var_decl(par: &mut Parser) -> ParseResult> { None }; let span = let_tkn.span + target.span + typ.span + value.as_ref(); - par.expect_newline("variable declaration")?; + par.expect_stmt_end("variable declaration")?; Node::new(FuncStmt::VarDecl { target, typ, value }, span) } _ => { @@ -390,7 +383,7 @@ fn parse_const_decl(par: &mut Parser) -> ParseResult> { )?; let value = parse_expr(par)?; - par.expect_newline("variable declaration")?; + par.expect_stmt_end("variable declaration")?; let span = const_tok.span + value.span; Ok(Node::new( @@ -409,7 +402,7 @@ fn parse_expr_stmt(par: &mut Parser) -> ParseResult> { use TokenKind::*; let expr = parse_expr(par)?; let node = match par.peek() { - None | Some(Newline) => { + None | Some(Newline | Semi | BraceClose) => { let span = expr.span; Node::new(FuncStmt::Expr { value: expr }, span) } @@ -448,12 +441,12 @@ fn parse_expr_stmt(par: &mut Parser) -> ParseResult> { span, ) } else { - par.unexpected_token_error(tok.span, "invalid syntax in function body", vec![]); + par.unexpected_token_error(&tok, "invalid syntax in function body", vec![]); return Err(ParseFailed); } } }; - par.expect_newline("statement")?; + par.expect_stmt_end("statement")?; Ok(node) } @@ -485,26 +478,29 @@ fn expr_to_vardecl_target(par: &mut Parser, expr: Node) -> ParseResult ParseResult> { - let if_tok = par.next()?; - assert!(matches!(if_tok.kind, TokenKind::If | TokenKind::Elif)); - + let if_tok = par.assert(TokenKind::If); let test = parse_expr(par)?; par.enter_block(if_tok.span + test.span, "`if` statement")?; let body = parse_block_stmts(par)?; + par.expect(TokenKind::BraceClose, "`if` statement")?; + par.eat_newlines(); let else_block = match par.peek() { Some(TokenKind::Else) => { let else_tok = par.next()?; - par.enter_block(else_tok.span, "`if` statement `else` branch")?; - parse_block_stmts(par)? - } - Some(TokenKind::Elif) => { - vec![parse_if_stmt(par)?] + if par.peek() == Some(TokenKind::If) { + vec![parse_if_stmt(par)?] + } else { + par.enter_block(else_tok.span, "`if` statement `else` branch")?; + let else_body = parse_block_stmts(par)?; + par.expect(TokenKind::BraceClose, "`if` statement")?; + else_body + } } _ => vec![], }; @@ -530,7 +526,8 @@ pub fn parse_while_stmt(par: &mut Parser) -> ParseResult> { let test = parse_expr(par)?; par.enter_block(while_tok.span + test.span, "`while` statement")?; let body = parse_block_stmts(par)?; - let span = while_tok.span + test.span + body.last(); + let end = par.expect(TokenKind::BraceClose, "`while` statement")?; + let span = while_tok.span + test.span + end.span; Ok(Node::new(FuncStmt::While { test, body }, span)) } @@ -549,7 +546,9 @@ pub fn parse_for_stmt(par: &mut Parser) -> ParseResult> { let iter = parse_expr(par)?; par.enter_block(for_tok.span + iter.span, "`for` statement")?; let body = parse_block_stmts(par)?; - let span = for_tok.span + iter.span + body.last(); + let end = par.expect(TokenKind::BraceClose, "`for` statement")?; + par.expect_stmt_end("`for` statement")?; + let span = for_tok.span + iter.span + end.span; Ok(Node::new(FuncStmt::For { target, iter, body }, span)) } @@ -564,7 +563,7 @@ pub fn parse_return_stmt(par: &mut Parser) -> ParseResult> { None | Some(TokenKind::Newline) => None, Some(_) => Some(parse_expr(par)?), }; - par.expect_newline("return statement")?; + par.expect_stmt_end("return statement")?; let span = ret.span + value.as_ref(); Ok(Node::new(FuncStmt::Return { value }, span)) } @@ -584,11 +583,11 @@ pub fn parse_assert_stmt(par: &mut Parser) -> ParseResult> { } Some(_) => { let tok = par.next()?; - par.unexpected_token_error(tok.span, "failed to parse `assert` statement", vec![]); + par.unexpected_token_error(&tok, "failed to parse `assert` statement", vec![]); return Err(ParseFailed); } }; - par.expect_newline("assert statement")?; + par.expect_stmt_end("assert statement")?; let span = assert_tok.span + test.span + msg.as_ref(); Ok(Node::new(FuncStmt::Assert { test, msg }, span)) } @@ -603,7 +602,7 @@ pub fn parse_revert_stmt(par: &mut Parser) -> ParseResult> { None | Some(TokenKind::Newline) => None, Some(_) => Some(parse_expr(par)?), }; - par.expect_newline("revert statement")?; + par.expect_stmt_end("revert statement")?; let span = revert_tok.span + error.as_ref(); Ok(Node::new(FuncStmt::Revert { error }, span)) } @@ -618,7 +617,7 @@ pub fn parse_emit_statement(par: &mut Parser) -> ParseResult> { if let Some(TokenKind::ParenOpen) = par.peek() { let args = parse_call_args(par)?; - par.expect_newline("emit statement")?; + par.expect_stmt_end("emit statement")?; let span = emit_tok.span + args.span; return Ok(Node::new( FuncStmt::Emit { @@ -645,7 +644,8 @@ pub fn parse_unsafe_block(par: &mut Parser) -> ParseResult> { let kw_tok = par.assert(TokenKind::Unsafe); par.enter_block(kw_tok.span, "`unsafe` block")?; let body = parse_block_stmts(par)?; - let span = kw_tok.span + body.last(); + let end = par.expect(TokenKind::BraceClose, "`unsafe` block")?; + let span = kw_tok.span + end.span; Ok(Node::new(FuncStmt::Unsafe(body), span)) } diff --git a/crates/parser/src/grammar/module.rs b/crates/parser/src/grammar/module.rs index d7e49cd126..e4c1023224 100644 --- a/crates/parser/src/grammar/module.rs +++ b/crates/parser/src/grammar/module.rs @@ -15,10 +15,8 @@ pub fn parse_module(par: &mut Parser) -> Node { let mut body = vec![]; loop { match par.peek() { - Some(TokenKind::Newline) => par.expect_newline("module").unwrap(), - Some(TokenKind::Dedent) => { + Some(TokenKind::Newline) => { par.next().unwrap(); - break; } None => break, Some(_) => { @@ -66,7 +64,7 @@ pub fn parse_module_stmt(par: &mut Parser) -> ParseResult { _ => { let tok = par.next()?; par.unexpected_token_error( - tok.span, + &tok, "failed to parse module", vec!["Note: expected `fn`".into()], ); @@ -78,7 +76,7 @@ pub fn parse_module_stmt(par: &mut Parser) -> ParseResult { _ => { let tok = par.next()?; par.unexpected_token_error( - tok.span, + &tok, "failed to parse module", vec!["Note: expected import, contract, struct, type, const or event".into()], ); @@ -180,7 +178,7 @@ pub fn parse_use_tree(par: &mut Parser) -> ParseResult> { } _ => { par.unexpected_token_error( - tok.span, + &tok, "failed to parse `use` tree", vec!["Note: expected a `,` or `}` token".to_string()], ); @@ -204,7 +202,7 @@ pub fn parse_use_tree(par: &mut Parser) -> ParseResult> { _ => { let tok = par.next()?; par.unexpected_token_error( - tok.span, + &tok, "failed to parse `use` tree", vec!["Note: expected a `*`, `{` or name token".to_string()], ); diff --git a/crates/parser/src/grammar/types.rs b/crates/parser/src/grammar/types.rs index f927582577..3353df8245 100644 --- a/crates/parser/src/grammar/types.rs +++ b/crates/parser/src/grammar/types.rs @@ -1,6 +1,6 @@ use crate::ast::{self, EventField, Field, GenericArg, Path, TypeAlias, TypeDesc}; use crate::grammar::expressions::parse_expr; -use crate::grammar::functions::{parse_fn_def, parse_single_word_stmt}; +use crate::grammar::functions::parse_fn_def; use crate::node::{Node, Span}; use crate::Token; use crate::{ParseFailed, ParseResult, Parser, TokenKind}; @@ -21,13 +21,15 @@ pub fn parse_struct_def( vec!["Note: a struct name must start with a letter or underscore, and contain letters, numbers, or underscores".into()] })?; + let mut span = struct_tok.span + name.span; let mut fields = vec![]; let mut functions = vec![]; - par.enter_block(struct_tok.span + name.span, "struct definition")?; + par.enter_block(span, "struct body must start with `{`")?; loop { + par.eat_newlines(); let pub_qual = par.optional(TokenKind::Pub).map(|tok| tok.span); - match par.peek() { - Some(TokenKind::Name) => { + match par.peek_or_err()? { + TokenKind::Name => { let field = parse_field(par, pub_qual, None)?; if !functions.is_empty() { par.error( @@ -37,25 +39,20 @@ pub fn parse_struct_def( } fields.push(field); } - Some(TokenKind::Fn | TokenKind::Unsafe) => { + TokenKind::Fn | TokenKind::Unsafe => { functions.push(parse_fn_def(par, pub_qual)?); } - Some(TokenKind::Dedent) => { - par.next()?; + TokenKind::BraceClose => { + span += par.next()?.span; break; } - Some(TokenKind::Pass) => { - parse_single_word_stmt(par)?; - } - None => break, - Some(_) => { + _ => { let tok = par.next()?; - par.unexpected_token_error(tok.span, "failed to parse struct definition", vec![]); + par.unexpected_token_error(&tok, "failed to parse struct definition", vec![]); return Err(ParseFailed); } } } - let span = struct_tok.span + struct_pub_qual + name.span + fields.last(); Ok(Node::new( ast::Struct { name: name.into(), @@ -100,30 +97,26 @@ pub fn parse_event_def(par: &mut Parser, pub_qual: Option) -> ParseResult< let event_tok = par.assert(Event); let name = par.expect(Name, "failed to parse event definition")?; + par.enter_block(event_tok.span + name.span, "event definition")?; + let mut span = event_tok.span; let mut fields = vec![]; - par.enter_block(event_tok.span + name.span, "event definition")?; loop { - match par.peek() { - Some(Name | Idx) => { + match par.peek_or_err()? { + Name | Idx => { fields.push(parse_event_field(par)?); } - Some(Pass) => { - parse_single_word_stmt(par)?; - } - Some(Dedent) => { - par.next()?; + BraceClose => { + span += par.next()?.span; break; } - None => break, - Some(_) => { + _ => { let tok = par.next()?; - par.unexpected_token_error(tok.span, "failed to parse event definition", vec![]); + par.unexpected_token_error(&tok, "failed to parse event definition", vec![]); return Err(ParseFailed); } } } - let span = event_tok.span + pub_qual + name.span + fields.last(); Ok(Node::new( ast::Event { name: name.into(), @@ -150,7 +143,7 @@ pub fn parse_event_field(par: &mut Parser) -> ParseResult> { })?; let typ = parse_type_desc(par)?; - par.expect_newline("event field")?; + par.expect_stmt_end("event field")?; let span = name.span + idx_qual + &typ; Ok(Node::new( EventField { @@ -203,7 +196,7 @@ pub fn parse_field( } else { None }; - par.expect_newline("field definition")?; + par.expect_stmt_end("field definition")?; let span = name.span + pub_qual + const_qual + &typ; Ok(Node::new( Field { @@ -245,7 +238,7 @@ pub fn parse_generic_args(par: &mut Parser) -> ParseResult> _ => { let tok = par.next()?; par.unexpected_token_error( - tok.span, + &tok, "Unexpected token while parsing generic arg list", vec![], ); @@ -314,7 +307,7 @@ pub fn parse_generic_args(par: &mut Parser) -> ParseResult> _ => { let tok = par.next()?; par.unexpected_token_error( - tok.span, + &tok, "failed to parse generic type argument list", vec![], ); @@ -346,7 +339,6 @@ pub fn parse_path_tail<'a>( /// Parse a type description, e.g. `u8` or `Map`. pub fn parse_type_desc(par: &mut Parser) -> ParseResult> { use TokenKind::*; - let mut typ = match par.peek_or_err()? { Name => { let name = par.next()?; @@ -416,7 +408,7 @@ pub fn parse_type_desc(par: &mut Parser) -> ParseResult> { _ => { let tok = par.next()?; par.unexpected_token_error( - tok.span, + &tok, "failed to parse type description", vec![], ); @@ -437,7 +429,7 @@ pub fn parse_type_desc(par: &mut Parser) -> ParseResult> { } _ => { let tok = par.next()?; - par.unexpected_token_error(tok.span, "failed to parse type description", vec![]); + par.unexpected_token_error(&tok, "failed to parse type description", vec![]); return Err(ParseFailed); } }; diff --git a/crates/parser/src/lexer.rs b/crates/parser/src/lexer.rs index c074a88917..50dec85ed4 100644 --- a/crates/parser/src/lexer.rs +++ b/crates/parser/src/lexer.rs @@ -32,7 +32,6 @@ impl<'a> Iterator for Lexer<'a> { let kind = self.inner.next()?; let text = self.inner.slice(); let span = self.inner.span(); - Some(Token { kind, text, diff --git a/crates/parser/src/lexer/token.rs b/crates/parser/src/lexer/token.rs index 4861114f40..c5d8d65f3c 100644 --- a/crates/parser/src/lexer/token.rs +++ b/crates/parser/src/lexer/token.rs @@ -37,10 +37,6 @@ pub enum TokenKind { #[regex(r"\n[ \t]*")] Newline, - /// Virtual tokens emitted by the parser - Indent, - Dedent, - #[regex("[a-zA-Z_][a-zA-Z0-9_]*")] Name, #[regex("[0-9]+(?:_[0-9]+)*")] @@ -73,8 +69,6 @@ pub enum TokenKind { Fn, #[token("const")] Const, - #[token("elif")] - Elif, #[token("else")] Else, #[token("emit")] @@ -87,8 +81,6 @@ pub enum TokenKind { If, #[token("pragma")] Pragma, - #[token("pass")] - Pass, #[token("for")] For, #[token("pub")] @@ -217,8 +209,6 @@ impl TokenKind { use TokenKind::*; match self { Newline => "a newline", - Dedent => "a dedent", - Indent => "an indentation", Name => "a name", Int => "a number", Hex => "a hexadecimal number", @@ -235,14 +225,12 @@ impl TokenKind { Fn => "keyword `fn`", Const => "keyword `const`", Let => "keyword `let`", - Elif => "keyword `elif`", Else => "keyword `else`", Emit => "keyword `emit`", Event => "keyword `event`", Idx => "keyword `idx`", If => "keyword `if`", Pragma => "keyword `pragma`", - Pass => "keyword `pass`", For => "keyword `for`", Pub => "keyword `pub`", Return => "keyword `return`", @@ -301,7 +289,7 @@ impl TokenKind { GtGtEq => "symbol `>>=`", Arrow => "symbol `->`", - Error => unreachable!(), + Error => unreachable!(), // TODO this is reachable } } } diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs index f75f59e041..74930859da 100644 --- a/crates/parser/src/parser.rs +++ b/crates/parser/src/parser.rs @@ -1,10 +1,7 @@ -#![allow(unused_variables, dead_code, unused_imports)] - pub use fe_common::diagnostics::Label; use fe_common::diagnostics::{Diagnostic, Severity}; use fe_common::files::SourceFileId; -use crate::ast::Module; use crate::lexer::{Lexer, Token, TokenKind}; use crate::node::Span; use std::{error, fmt}; @@ -21,7 +18,7 @@ impl error::Error for ParseFailed {} pub type ParseResult = Result; /// `Parser` maintains the parsing state, such as the token stream, -/// indent stack, paren stack, diagnostics, etc. +/// "enclosure" (paren, brace, ..) stack, diagnostics, etc. /// Syntax parsing logic is in the [`crate::grammar`] module. /// /// See [`BTParser`] if you need backtrackable parser. @@ -34,9 +31,7 @@ pub struct Parser<'a> { /// generic type parameter list (eg. `Map>`). buffered: Vec>, - enclosure_stack: Vec, - indent_stack: Vec>, - indent_style: Option, + enclosure_stack: Vec, /// The diagnostics (errors and warnings) emitted during parsing. pub diagnostics: Vec, @@ -50,13 +45,6 @@ impl<'a> Parser<'a> { lexer: Lexer::new(file_id, content), buffered: vec![], enclosure_stack: vec![], - indent_stack: vec![BlockIndent { - context_span: Span::zero(file_id), - context_name: "module".into(), - indent: "", - indent_span: Span::zero(file_id), - }], - indent_style: None, diagnostics: vec![], } } @@ -69,33 +57,24 @@ impl<'a> Parser<'a> { /// Return the next token, or an error if we've reached the end of the file. #[allow(clippy::should_implement_trait)] // next() is a nice short name for a common task pub fn next(&mut self) -> ParseResult> { - // TODO: allow newlines inside square brackets - // TODO: allow newlines inside angle brackets? - // eg `fn f(x: map\n <\n u8\n, ...` - if !self.enclosure_stack.is_empty() { - self.eat_newlines(); - } + self.eat_newlines_if_in_nonblock_enclosure(); if let Some(tok) = self.next_raw() { - if [ - TokenKind::ParenOpen, - TokenKind::BraceOpen, - TokenKind::BracketOpen, - ] - .contains(&tok.kind) - { - self.enclosure_stack.push(tok.span); - } else if [ - TokenKind::ParenClose, - TokenKind::BraceClose, - TokenKind::BracketClose, - ] - .contains(&tok.kind) - && self.enclosure_stack.pop().is_none() - { - self.error(tok.span, "Unmatched right parenthesis"); - if self.peek_raw() == Some(TokenKind::ParenClose) { - // another unmatched closing paren; fail. - return Err(ParseFailed); + if is_enclosure_open(tok.kind) { + self.enclosure_stack + .push(Enclosure::non_block(tok.kind, tok.span)); + } else if is_enclosure_close(tok.kind) { + if let Some(open) = self.enclosure_stack.pop() { + if !enclosure_tokens_match(open.token_kind, tok.kind) { + // TODO: we should search the enclosure_stack + // for the last matching enclosure open token. + // If any enclosures are unclosed, we should emit an + // error, and somehow close their respective ast nodes. + // We could synthesize the correct close token, or emit + // a special TokenKind::UnclosedEnclosure or whatever. + todo!() + } + } else { + self.error(tok.span, format!("Unmatched `{}`", tok.text)); } } Ok(tok) @@ -119,9 +98,7 @@ impl<'a> Parser<'a> { /// Take a peek at the next token kind without consuming it, or return an /// error if we've reached the end of the file. pub fn peek_or_err(&mut self) -> ParseResult { - if !self.enclosure_stack.is_empty() { - self.eat_newlines(); - } + self.eat_newlines_if_in_nonblock_enclosure(); if let Some(tk) = self.peek_raw() { Ok(tk) } else { @@ -137,9 +114,7 @@ impl<'a> Parser<'a> { /// Take a peek at the next token kind. Returns `None` if we've reached the /// end of the file. pub fn peek(&mut self) -> Option { - if !self.enclosure_stack.is_empty() { - self.eat_newlines(); - } + self.eat_newlines_if_in_nonblock_enclosure(); self.peek_raw() } @@ -167,6 +142,16 @@ impl<'a> Parser<'a> { Some(self.buffered.last().unwrap().kind) } + fn eat_newlines_if_in_nonblock_enclosure(&mut self) { + // TODO: allow newlines inside angle brackets? + // eg `fn f(x: map\n <\n u8\n, ...` + if let Some(enc) = self.enclosure_stack.last() { + if !enc.is_block { + self.eat_newlines(); + } + } + } + /// Split the next token into two tokens, returning the first. Only supports /// splitting the `>>` token into two `>` tokens, specifically for /// parsing the closing angle bracket of a generic type argument list @@ -197,13 +182,7 @@ impl<'a> Parser<'a> { self.peek_raw() == None } - /// The leading whitespace string of the last-seen indented line. - /// This does not include lines inside of parentheses. - pub fn last_indent(&self) -> &'a str { - self.indent_stack.last().unwrap().indent - } - - fn eat_newlines(&mut self) { + pub fn eat_newlines(&mut self) { while self.peek_raw() == Some(TokenKind::Newline) { self.next_raw(); } @@ -277,62 +256,32 @@ impl<'a> Parser<'a> { /// Emit an "unexpected token" error diagnostic with the given message. pub fn unexpected_token_error>( &mut self, - span: Span, + tok: &Token, message: S, notes: Vec, ) { self.fancy_error( message, - vec![Label::primary(span, "unexpected token".to_string())], + vec![Label::primary(tok.span, "unexpected token")], notes, ); } - /// Enter an indented block, which is expected to be non-empty. This checks - /// for and consumes the colon that precedes the block. If no colon is - /// found, it emits an error and keeps parsing. Any number of - /// newlines are allowed before the first non-empty indented line. - /// Returns an error if the block has no non-empty indented line. - /// - /// # Panics - /// Panics if called while the parser is inside a set of parentheses. + /// Enter a "block", which is a brace-enclosed list of statements, + /// separated by newlines and/or semicolons. + /// This checks for and consumes the `{` that precedes the block. pub fn enter_block(&mut self, context_span: Span, context_name: &str) -> ParseResult<()> { - assert!(self.enclosure_stack.is_empty()); - - let colon = if self.peek_raw() == Some(TokenKind::Colon) { - self.next_raw() - } else { - self.fancy_error( - format!("missing colon in {}", context_name), - vec![Label::primary( - Span::new(self.file_id, context_span.end, context_span.end), - "expected `:` here", - )], - vec![], - ); - None - }; - - self.handle_newline_indent(context_name)?; - - let indent = self.next()?; - if indent.kind == TokenKind::Indent { - self.indent_stack.push(BlockIndent { - context_span, - context_name: context_name.into(), - indent: indent.text, - indent_span: indent.span, - }); + if self.peek_raw() == Some(TokenKind::BraceOpen) { + let tok = self.next_raw().unwrap(); + self.enclosure_stack.push(Enclosure::block(tok.span)); + self.eat_newlines(); Ok(()) } else { self.fancy_error( - format!("failed to parse {} body", context_name), + format!("{} must start with `{{`", context_name), vec![Label::primary( - context_span + colon.as_ref(), - format!( - "the body of this {} must be indented and non-empty", - context_name, - ), + Span::new(self.file_id, context_span.end, context_span.end), + "expected `{` here", )], vec![], ); @@ -340,85 +289,32 @@ impl<'a> Parser<'a> { } } - /// Expect and consume one or more newlines, without returning them. - /// Returns an error if the next token isn't a newline or the end of the - /// file, or if the indent of the next non-empty line doesn't match the - /// current indentation. - /// - /// # Panics - /// Panics if called while the parser is inside a set of parentheses. - pub fn expect_newline(&mut self, context_name: &str) -> ParseResult<()> { - self.handle_newline_indent(context_name)?; - if self.peek() == Some(TokenKind::Indent) { - let indent = self.next()?; - self.fancy_error( - "unexpected indentation", - vec![Label::primary( - indent.span, - "this line indented further than other lines in the current block", - )], - vec![], - ); - Err(ParseFailed) - } else { - Ok(()) + /// Consumes newlines and semicolons. Returns Ok if one or more newlines or semicolons + /// are consumed, or if the next token is a `}`. + pub fn expect_stmt_end(&mut self, context_name: &str) -> ParseResult<()> { + let mut newline = false; + while matches!(self.peek_raw(), Some(TokenKind::Newline | TokenKind::Semi)) { + newline = true; + self.next_raw().unwrap(); + } + if newline { + return Ok(()); } - } - - fn handle_newline_indent(&mut self, context_name: &str) -> ParseResult<()> { - assert!( - self.enclosure_stack.is_empty(), - "Parser::handle_newline_indent called within parens" - ); - match self.peek_raw() { - None => Ok(()), // eof is an acceptable newline - Some(TokenKind::Newline) => { - let mut last_nl = self.next_raw().unwrap(); - while self.peek_raw() == Some(TokenKind::Newline) { - last_nl = self.next_raw().unwrap(); - } - if self.done() { - return Ok(()); - } - - let (indent, indent_span) = indent_str(self.file_id, &last_nl); - self.check_indent_style(indent, indent_span)?; - - if indent.len() > self.last_indent().len() { - self.buffered.push(Token { - kind: TokenKind::Indent, - text: indent, - span: indent_span, - }); - return Ok(()); - } - while indent.len() < self.last_indent().len() { - self.buffered.push(Token { - kind: TokenKind::Dedent, - text: indent, - span: indent_span, - }); - self.indent_stack.pop(); - } - if indent.len() != self.last_indent().len() { - self.indentation_error( - indent_span, - "this indentation doesn't match other lines in the current block or an enclosing block" - ); - return Err(ParseFailed); - } - Ok(()) - } + Some(TokenKind::BraceClose) => Ok(()), Some(_) => { let tok = self.next()?; self.unexpected_token_error( - tok.span, + &tok, format!("unexpected token while parsing {}", context_name), - vec!["expected a newline".into()], + vec![format!( + "expected a newline; found {} instead", + tok.kind.describe() + )], ); Err(ParseFailed) } + None => Ok(()), // unexpect eof error will be generated be parent block } } @@ -447,38 +343,6 @@ impl<'a> Parser<'a> { notes, }) } - - fn indentation_error>(&mut self, span: Span, message: S) { - self.fancy_error( - "inconsistent indentation", - vec![Label::primary(span, message.into())], - vec![], - ); - } - - fn check_indent_style(&mut self, indent: &str, span: Span) -> ParseResult<()> { - if indent.is_empty() { - Ok(()) - } else if indent.find(' ').is_some() && indent.find('\t').is_some() { - self.indentation_error(span, "this indent contains both tabs and spaces"); - Err(ParseFailed) - } else if self.indent_style.is_none() { - self.indent_style = Some(indent.chars().next().unwrap()); - Ok(()) - } else if indent.chars().next() == self.indent_style { - Ok(()) - } else { - self.indentation_error( - span, - format!( - "This line is indented with {}s, while prior lines are indented with {}s.", - indent_char_name(indent.chars().next().unwrap()), - indent_char_name(self.indent_style.unwrap()) - ), - ); - Err(ParseFailed) - } - } } /// A thin wrapper that makes [`Parser`] backtrackable. @@ -494,8 +358,6 @@ impl<'a, 'b> BTParser<'a, 'b> { lexer: snapshot.lexer.clone(), buffered: snapshot.buffered.clone(), enclosure_stack: snapshot.enclosure_stack.clone(), - indent_stack: snapshot.indent_stack.clone(), - indent_style: snapshot.indent_style, diagnostics: Vec::new(), }; Self { snapshot, parser } @@ -505,8 +367,6 @@ impl<'a, 'b> BTParser<'a, 'b> { self.snapshot.lexer = self.parser.lexer; self.snapshot.buffered = self.parser.buffered; self.snapshot.enclosure_stack = self.parser.enclosure_stack; - self.snapshot.indent_stack = self.parser.indent_stack; - self.snapshot.indent_style = self.parser.indent_style; self.snapshot.diagnostics.extend(self.parser.diagnostics); } } @@ -525,29 +385,57 @@ impl<'a, 'b> std::ops::DerefMut for BTParser<'a, 'b> { } } -fn indent_char_name(c: char) -> &'static str { - match c { - ' ' => "space", - '\t' => "tab", - _ => panic!(), +/// The start position of a chunk of code enclosed by (), [], or {}. +/// (This has nothing to do with "closures".) +/// +/// Note that <> isn't currently considered an enclosure, as `<` might be +/// a less-than operator, while the rest are unambiguous. +/// +/// A `{}` enclosure may or may not be a block. A block contains a list of +/// statements, separated by newlines or semicolons (or both). +/// Semicolons and newlines are consumed by `par.expect_stmt_end()`. +/// +/// Non-block enclosures contains zero or more expressions, maybe separated by +/// commas. When the top-most enclosure is a non-block, newlines are ignored +/// (by `par.next()`), and semicolons are just normal tokens that'll be +/// rejected by the parsing fns in grammar/. +#[derive(Clone, Debug)] +struct Enclosure { + token_kind: TokenKind, + _token_span: Span, // TODO: mark mismatched tokens + is_block: bool, +} +impl Enclosure { + pub fn block(token_span: Span) -> Self { + Self { + token_kind: TokenKind::BraceOpen, + _token_span: token_span, + is_block: true, + } + } + pub fn non_block(token_kind: TokenKind, token_span: Span) -> Self { + Self { + token_kind, + _token_span: token_span, + is_block: false, + } } } -fn indent_str<'a>(file_id: SourceFileId, tok: &Token<'a>) -> (&'a str, Span) { - assert_eq!(tok.kind, TokenKind::Newline); - let text = tok.text.trim_start_matches(&['\r', '\n'][..]); - let span = Span::new( - file_id, - tok.span.start + (tok.text.len() - text.len()), - tok.span.end, - ); - (text, span) +fn is_enclosure_open(tk: TokenKind) -> bool { + use TokenKind::*; + matches!(tk, ParenOpen | BraceOpen | BracketOpen) +} + +fn is_enclosure_close(tk: TokenKind) -> bool { + use TokenKind::*; + matches!(tk, ParenClose | BraceClose | BracketClose) } -#[derive(Clone)] -struct BlockIndent<'a> { - context_span: Span, - context_name: String, - indent: &'a str, - indent_span: Span, +fn enclosure_tokens_match(open: TokenKind, close: TokenKind) -> bool { + use TokenKind::*; + matches!( + (open, close), + (ParenOpen, ParenClose) | (BraceOpen, BraceClose) | (BracketOpen, BracketClose) + ) } diff --git a/crates/parser/tests/cases/errors.rs b/crates/parser/tests/cases/errors.rs index 4602ed7d7f..e2f48f173e 100644 --- a/crates/parser/tests/cases/errors.rs +++ b/crates/parser/tests/cases/errors.rs @@ -48,33 +48,28 @@ macro_rules! test_parse_err { test_parse_err! { contract_invalid_version_requirement, module::parse_module, r#" pragma 0.o -contract C: - pass -"# +contract C {}"# } test_parse_err! { contract_missing_version_requirement, module::parse_module, r#" pragma -contract C: - pass +contract C {} "# } -test_parse_err! { contract_bad_name, module::parse_module, "contract 1X:\n x: u8" } -test_parse_err! { contract_empty_body, module::parse_module, "contract X:\n \n \ncontract Y:\n x: u8" } +test_parse_err! { contract_bad_name, module::parse_module, "contract 1X {\n x: u8 \n}" } test_parse_err! { contract_field_after_def, module::parse_module, r#" -contract C: - fn f(): - pass +contract C { + fn f() {} x: u8 -"# +}"# } test_parse_err! { type_desc_path_number, module::parse_module, "type Foo = some::mod::Foo::5000" } -test_parse_err! { module_pub_event, module::parse_module, "pub event E:\n x: u8" } -test_parse_err! { contract_pub_event, module::parse_module, "contract C:\n pub event E:\n x: u8" } -test_parse_err! { contract_const_pub, module::parse_module, "contract C:\n const pub x: u8" } -test_parse_err! { contract_const_fn, module::parse_module, "contract C:\n const fn f():\n pass" } +test_parse_err! { module_pub_event, module::parse_module, "pub event E{\n x: u8}" } +test_parse_err! { contract_pub_event, module::parse_module, "contract C {\n pub event E{\n x: u8 \n}}" } +test_parse_err! { contract_const_pub, module::parse_module, "contract C {\n const pub x: u8\n}" } +test_parse_err! { contract_const_fn, module::parse_module, "contract C {\n const fn f() {}\n}" } test_parse_err! { emit_no_args, functions::parse_stmt, "emit x" } test_parse_err! { emit_expr, functions::parse_stmt, "emit x + 1" } test_parse_err! { emit_bad_call, functions::parse_stmt, "emit MyEvent(1)()" } @@ -84,15 +79,14 @@ test_parse_err! { expr_path_right, expressions::parse_expr, "foo::10::bar" } test_parse_err! { expr_dotted_number, expressions::parse_expr, "3.14" } test_parse_err! { expr_call_eq_label, expressions::parse_expr, "foo(bar=1, baz = 2)" } test_parse_err! { expr_assignment, expressions::parse_expr, "1 + (x = y)" } -test_parse_err! { for_no_in, functions::parse_stmt, "for x:\n pass" } -test_parse_err! { fn_no_args, module::parse_module, "fn f:\n return 5" } -test_parse_err! { fn_unsafe_pub, module::parse_module, "unsafe pub fn f():\n return 5" } -test_parse_err! { fn_def_kw, module::parse_module, "contract C:\n pub def f(x: u8):\n return x" } -test_parse_err! { if_no_body, functions::parse_stmt, "if x:\nelse:\n x" } +test_parse_err! { for_no_in, functions::parse_stmt, "for x {}" } +test_parse_err! { fn_no_args, module::parse_module, "fn f {\n return 5\n}" } +test_parse_err! { fn_unsafe_pub, module::parse_module, "unsafe pub fn f() {\n return 5 }" } +test_parse_err! { fn_def_kw, module::parse_module, "contract C {\n pub def f(x: u8){\n return x \n}\n}" } test_parse_err! { use_bad_name, module::parse_use, "use x as 123" } -test_parse_err! { module_bad_stmt, module::parse_module, "if x:\n y" } +test_parse_err! { module_bad_stmt, module::parse_module, "if x { y }" } test_parse_err! { module_nonsense, module::parse_module, "))" } -test_parse_err! { struct_bad_field_name, module::parse_module, "struct f:\n pub event" } +test_parse_err! { struct_bad_field_name, module::parse_module, "struct f {\n pub event }" } test_parse_err! { stmt_vardecl_attr, functions::parse_stmt, "f.s : u" } test_parse_err! { stmt_vardecl_tuple, functions::parse_stmt, "(a, x+1) : u256" } test_parse_err! { stmt_vardecl_tuple_empty, functions::parse_stmt, "(a, ()) : u256" } @@ -106,9 +100,9 @@ test_parse_err! { number_end_with_underscore, functions::parse_stmt, "42_42_"} test_parse_err! { array_old_syntax, functions::parse_stmt, "let x: u8[10]" } test_parse_err! { array_old_syntax_invalid, functions::parse_stmt, "let x: u8[10" } test_parse_err! { self_const, module::parse_module, "const self: u8 = 10" } -test_parse_err! { self_contract, module::parse_module, "contract self:\n pass" } -test_parse_err! { self_struct, module::parse_module, "struct self:\n pass" } -test_parse_err! { self_fn, module::parse_module, "pub fn self():\n pass" } +test_parse_err! { self_contract, module::parse_module, "contract self {}" } +test_parse_err! { self_struct, module::parse_module, "struct self {}" } +test_parse_err! { self_fn, module::parse_module, "pub fn self() {}" } test_parse_err! { self_use1, module::parse_module, "use self as bar" } test_parse_err! { self_use2, module::parse_module, "use bar as self" } diff --git a/crates/parser/tests/cases/parse_ast.rs b/crates/parser/tests/cases/parse_ast.rs index be8c1f1fb4..70d8c59c9a 100644 --- a/crates/parser/tests/cases/parse_ast.rs +++ b/crates/parser/tests/cases/parse_ast.rs @@ -121,13 +121,14 @@ test_parse! { stmt_return3, functions::parse_stmt, "return not x" } test_parse! { stmt_revert1, functions::parse_stmt, "revert" } test_parse! { stmt_revert2, functions::parse_stmt, "revert something" } -test_parse! { stmt_if, functions::parse_stmt, "if a:\n b" } -test_parse! { stmt_if2, functions::parse_stmt, "if a:\n b \nelif c:\n d \nelif e: \n f \nelse:\n g" } -test_parse! { stmt_while, functions::parse_stmt, "while a > 5:\n a -= 1" } -test_parse! { stmt_for, functions::parse_stmt, "for a in b[0]:\n pass" } +test_parse! { stmt_if, functions::parse_stmt, "if a { \n b }" } +test_parse! { stmt_if2, functions::parse_stmt, "if a { b } else if c { d } else if e { \n f } \n else {\n g }" } +test_parse! { stmt_while, functions::parse_stmt, "while a > 5 { \n a -= 1 }" } +test_parse! { stmt_for, functions::parse_stmt, "for a in b[0] {}" } test_parse! { stmt_var_decl_name, functions::parse_stmt, "let foo: u256 = 1" } test_parse! { stmt_var_decl_tuple, functions::parse_stmt, "let (foo, bar): (u256, u256) = (10, 10)" } test_parse! { stmt_var_decl_tuples, functions::parse_stmt, "let (a, (b, (c, d))): x" } +test_parse! { stmt_semicolons, functions::parse_stmt, "if a { b; c; d; for x in y {}; }" } test_parse! { type_def, try_parse_module, "type X = Map" } test_parse! { pub_type_def, try_parse_module, "pub type X = Map" } test_parse! { type_name, types::parse_type_desc, "MyType" } @@ -143,15 +144,15 @@ test_parse! { type_map4, types::parse_type_desc, "map < address , map < u8, u256 test_parse! { type_tuple, types::parse_type_desc, "(u8, u16, address, Map)" } test_parse! { type_unit, types::parse_type_desc, "()" } -test_parse! { fn_def, try_parse_module, "fn transfer(from sender: address, to recip: address, _ val: u64) -> bool:\n false"} +test_parse! { fn_def, try_parse_module, "fn transfer(from sender: address, to recip: address, _ val: u64) -> bool {\n false \n}"} -test_parse! { fn_def_generic, try_parse_module, "fn foo(this: T, that: R, _ val: u64) -> bool:\n false"} -test_parse! { fn_def_pub, try_parse_module, "pub fn foo21(x: bool, y: address,) -> bool:\n x"} -test_parse! { fn_def_unsafe, try_parse_module, "unsafe fn foo21(x: bool, y: address,) -> bool:\n x"} -test_parse! { fn_def_pub_unsafe, try_parse_module, "pub unsafe fn foo21(x: bool, y: address,) -> bool:\n x"} -test_parse! { event_def, try_parse_module, "event Foo:\n x: address\n idx y: u8" } -test_parse! { empty_event_def, try_parse_module, "event Foo:\n pass" } -test_parse! { pub_event_def, try_parse_module, "event Foo:\n x: address\n idx y: u8" } +test_parse! { fn_def_generic, try_parse_module, "fn foo(this: T, that: R, _ val: u64) -> bool { false }"} +test_parse! { fn_def_pub, try_parse_module, "pub fn foo21(x: bool, y: address,) -> bool { x }"} +test_parse! { fn_def_unsafe, try_parse_module, "unsafe fn foo21(x: bool, y: address,) -> bool {\n x\n}"} +test_parse! { fn_def_pub_unsafe, try_parse_module, "pub unsafe fn foo21(x: bool, y: address,) -> bool{x}"} +test_parse! { event_def, try_parse_module, "event Foo {\n x: address\n idx y: u8\n}" } +test_parse! { empty_event_def, try_parse_module, "event Foo {}" } +test_parse! { pub_event_def, try_parse_module, "pub event Foo {\nx: address\nidx y: u8\n}" } test_parse! { const_def, try_parse_module, "const FOO: i32 = 1" } test_parse! { pub_const_def, try_parse_module, "pub const FOO: i32 = 1" } test_parse! { pragma1, module::parse_pragma, "pragma 0.1.0" } @@ -168,39 +169,41 @@ test_parse! { use_nested2, module::parse_use, r#"use std::bar::{ evm as mve }"# } -test_parse! { struct_def, try_parse_module, r#"struct S: +test_parse! { struct_def, try_parse_module, r#"struct S { x: address pub y: u8 z: u8 pub a: Map - pub fn foo(self) -> u8: + pub fn foo(self) -> u8 { return self.z + self.y - unsafe fn bar(): - pass -"# } -test_parse! { empty_struct_def, try_parse_module, r#"struct S: - pass -"# } + } + unsafe fn bar() {} +}"# } +test_parse! { empty_struct_def, try_parse_module, "struct S {}" } -test_parse! { contract_def, try_parse_module, r#"contract Foo: +test_parse! { contract_def, try_parse_module, r#"contract Foo { x: address pub y: u8 pub const z: Map - pub fn foo() -> u8: + + pub fn foo() -> u8 { return 10 - event Bar: + } + event Bar { idx from: address + } +} "# } -test_parse! { empty_contract_def, try_parse_module, r#"contract Foo: - pass -"# } +test_parse! { empty_contract_def, try_parse_module, "contract Foo {}" } -test_parse! { pub_contract_def, try_parse_module, r#"pub contract Foo: - pub fn foo() -> u8: +test_parse! { pub_contract_def, try_parse_module, r#" +pub contract Foo { + pub fn foo() -> u8 { return 10 -"# } + } +}"# } test_parse! { module_stmts, try_parse_module, r#" pragma 0.5.0 @@ -212,46 +215,51 @@ use foo::bar::{ type X = Map -pub fn double(x: u8) -> u8: +pub fn double(x: u8) -> u8 { return x * 2 +} -fn secret() -> u8: - return 0xBEEF +fn secret() -> u8 { return 0xBEEF } -contract A: +contract A { pub const x: u256 = 10 +} -contract B: +contract B { pub x: X -"# } +}"# } test_parse! { guest_book, try_parse_module, r#" type BookMsg = Array -contract GuestBook: +contract GuestBook { pub guest_book: Map - event Signed: + event Signed { idx book_msg: BookMsg + } - pub fn sign(self, book_msg: BookMsg): + pub fn sign(self, book_msg: BookMsg) { self.guest_book[msg.sender] = book_msg emit Signed(book_msg: book_msg) - - pub fn get_msg(self, addr: address) -> BookMsg: + } + pub fn get_msg(self, addr: address) -> BookMsg { return self.guest_book[addr] -"# } + } +}"# } test_parse! { module_level_events, try_parse_module, r#" use std::context::Context -event Transfer: +event Transfer { idx sender: address idx receiver: address value: u256 - -contract Foo: - fn transfer(ctx: Context, to: address, value: u256): +} +contract Foo { + fn transfer(ctx: Context, to: address, value: u256) { emit Transfer(ctx, sender: msg.sender, receiver: to, value) + } +} "# } diff --git a/crates/parser/tests/cases/print_ast.rs b/crates/parser/tests/cases/print_ast.rs index 8763e0e388..b777d6f092 100644 --- a/crates/parser/tests/cases/print_ast.rs +++ b/crates/parser/tests/cases/print_ast.rs @@ -3,6 +3,7 @@ use fe_common::diagnostics::print_diagnostics; use fe_common::SourceFileId; use fe_parser::parse_file; use fe_test_files::fixture; +use insta::assert_snapshot; use wasm_bindgen_test::wasm_bindgen_test; fn parse_and_print(path: &str, src: &str) -> String { @@ -24,12 +25,24 @@ macro_rules! test_print { #[wasm_bindgen_test] fn $name() { let src = fixture($path); - pretty_assertions::assert_eq!(src, parse_and_print($path, src)) + if cfg!(target_arch = "wasm32") { + fe_common::assert_snapshot_wasm!( + concat!("snapshots/cases__print_ast__", stringify!($name), ".snap"), + parse_and_print($path, src) + ); + } else { + assert_snapshot!(parse_and_print($path, src)) + } + + // These tests used to assert that the source text and the formatted + // text are equal, which is probably more likely to catch errors, + // but the diffs from `pretty_assertions` made it hard to debug. + // Feel free to change it back or find a better diff printer. } }; } test_print! { erc20, "demos/erc20_token.fe" } -test_print! { guest_book, "printing/guest_book_no_comments.fe" } +test_print! { guest_book, "demos/guest_book.fe" } test_print! { expr_parens, "printing/expr_parens.fe" } test_print! { defs, "printing/defs.fe" } diff --git a/crates/parser/tests/cases/snapshots/cases__errors__contract_bad_name.snap b/crates/parser/tests/cases/snapshots/cases__errors__contract_bad_name.snap index 62ff100724..701fab48ce 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__contract_bad_name.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__contract_bad_name.snap @@ -1,12 +1,12 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(contract_bad_name), contracts::parse_contract_def, true,\n \"contract 1X:\\n x: u8\")" +expression: "err_string(stringify!(contract_bad_name), module::parse_module,\n \"contract 1X {\\n x: u8 \\n}\")" --- error: failed to parse contract definition ┌─ contract_bad_name:1:10 │ -1 │ contract 1X: +1 │ contract 1X { │ ^ expected a name, found a number │ = Note: `contract` must be followed by a name, which must start with a letter and contain only letters, numbers, or underscores diff --git a/crates/parser/tests/cases/snapshots/cases__errors__contract_const_fn.snap b/crates/parser/tests/cases/snapshots/cases__errors__contract_const_fn.snap index a0548cd796..7e5b3c3bf4 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__contract_const_fn.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__contract_const_fn.snap @@ -1,12 +1,12 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(contract_const_fn), contracts::parse_contract_def,\n false, \"contract C:\\n const fn f():\\n pass\")" +expression: "err_string(stringify!(contract_const_fn), module::parse_module,\n \"contract C {\\n const fn f() {}\\n}\")" --- error: `const` qualifier can't be used with function definitions ┌─ contract_const_fn:2:2 │ -2 │ const fn f(): +2 │ const fn f() {} │ ^^^^^ diff --git a/crates/parser/tests/cases/snapshots/cases__errors__contract_empty_body.snap b/crates/parser/tests/cases/snapshots/cases__errors__contract_empty_body.snap index 057ad7963e..a8ab66646a 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__contract_empty_body.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__contract_empty_body.snap @@ -1,12 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(contract_empty_body), module::parse_module, true,\n \"contract X:\\n \\n \\ncontract Y:\\n x: u8\")" +expression: "err_string(stringify!(contract_empty_body), module::parse_module,\n \"contract X {} \\ncontract Y {\\n x: u8 \\n}\")" --- -error: failed to parse contract definition body - ┌─ contract_empty_body:1:1 - │ -1 │ contract X: - │ ^^^^^^^^^^^ the body of this contract definition must be indented and non-empty - diff --git a/crates/parser/tests/cases/snapshots/cases__errors__contract_field_after_def.snap b/crates/parser/tests/cases/snapshots/cases__errors__contract_field_after_def.snap index cfba743a63..0fe3d767d9 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__contract_field_after_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__contract_field_after_def.snap @@ -1,12 +1,12 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(contract_field_after_def), module::parse_module, false,\n r#\"\ncontract C:\n fn f():\n pass\n x: u8\n\"#)" +expression: "err_string(stringify!(contract_field_after_def), module::parse_module,\n r#\"\ncontract C {\n fn f() {}\n x: u8\n}\"#)" --- error: contract field definitions must come before any function or event definitions - ┌─ contract_field_after_def:5:3 + ┌─ contract_field_after_def:4:3 │ -5 │ x: u8 +4 │ x: u8 │ ^^^^^ diff --git a/crates/parser/tests/cases/snapshots/cases__errors__contract_pub_event.snap b/crates/parser/tests/cases/snapshots/cases__errors__contract_pub_event.snap index e2518f5f4d..4f756465b5 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__contract_pub_event.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__contract_pub_event.snap @@ -1,12 +1,12 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(contract_pub_event), module::parse_module, false,\n \"contract C:\\n pub event E:\\n x: u8\")" +expression: "err_string(stringify!(contract_pub_event), module::parse_module,\n \"contract C {\\n pub event E{\\n x: u8 \\n}}\")" --- error: `pub` qualifier can't be used with contract-level event definitions ┌─ contract_pub_event:2:2 │ -2 │ pub event E: +2 │ pub event E{ │ ^^^ diff --git a/crates/parser/tests/cases/snapshots/cases__errors__emit_bad_call.snap b/crates/parser/tests/cases/snapshots/cases__errors__emit_bad_call.snap index 280f0080c8..162aac79d5 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__emit_bad_call.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__emit_bad_call.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(emit_bad_call), functions::parse_stmt, true,\n \"emit MyEvent(1)()\")" +expression: "err_string(stringify!(emit_bad_call), functions::parse_stmt,\n \"emit MyEvent(1)()\")" --- error: unexpected token while parsing emit statement @@ -9,6 +9,6 @@ error: unexpected token while parsing emit statement 1 │ emit MyEvent(1)() │ ^ unexpected token │ - = expected a newline + = expected a newline; found symbol `(` instead diff --git a/crates/parser/tests/cases/snapshots/cases__errors__fn_def_kw.snap b/crates/parser/tests/cases/snapshots/cases__errors__fn_def_kw.snap index 8b78b93706..5aed9e3fea 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__fn_def_kw.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__fn_def_kw.snap @@ -1,12 +1,12 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(fn_def_kw), contracts::parse_contract_def, true,\n \"contract C:\\n pub def f(x: u8):\\n return x\")" +expression: "err_string(stringify!(fn_def_kw), module::parse_module,\n \"contract C {\\n pub def f(x: u8){\\n return x \\n}\\n}\")" --- error: failed to parse field definition ┌─ fn_def_kw:2:10 │ -2 │ pub def f(x: u8): +2 │ pub def f(x: u8){ │ ^ expected symbol `:`, found a name │ = Hint: use `fn` to define a function diff --git a/crates/parser/tests/cases/snapshots/cases__errors__fn_no_args.snap b/crates/parser/tests/cases/snapshots/cases__errors__fn_no_args.snap index 61dd42514c..c3ea8fe4c0 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__fn_no_args.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__fn_no_args.snap @@ -1,12 +1,12 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(fn_no_args), |par| functions::parse_fn_def(par, None),\n false, \"fn f:\\n return 5\")" +expression: "err_string(stringify!(fn_no_args), module::parse_module,\n \"fn f {\\n return 5\\n}\")" --- error: function definition requires a list of parameters ┌─ fn_no_args:1:4 │ -1 │ fn f: +1 │ fn f { │ ^ function name must be followed by `(` │ = Note: if the function `f` takes no parameters, use an empty set of parentheses. diff --git a/crates/parser/tests/cases/snapshots/cases__errors__fn_unsafe_pub.snap b/crates/parser/tests/cases/snapshots/cases__errors__fn_unsafe_pub.snap index fbf5175c49..5b60da1b8a 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__fn_unsafe_pub.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__fn_unsafe_pub.snap @@ -1,12 +1,12 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(fn_unsafe_pub), module::parse_module, false,\n \"unsafe pub fn f():\\n return 5\")" +expression: "err_string(stringify!(fn_unsafe_pub), module::parse_module,\n \"unsafe pub fn f() {\\n return 5 }\")" --- error: `pub` visibility modifier must come before `unsafe` ┌─ fn_unsafe_pub:1:1 │ -1 │ unsafe pub fn f(): +1 │ unsafe pub fn f() { │ ^^^^^^^^^^ use `pub unsafe` here diff --git a/crates/parser/tests/cases/snapshots/cases__errors__for_no_in.snap b/crates/parser/tests/cases/snapshots/cases__errors__for_no_in.snap index 51370aac6b..9fdfe5dc41 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__for_no_in.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__for_no_in.snap @@ -1,12 +1,12 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(for_no_in), functions::parse_stmt, true,\n \"for x:\\n pass\")" +expression: "err_string(stringify!(for_no_in), functions::parse_stmt, \"for x {}\")" --- error: failed to parse `for` statement - ┌─ for_no_in:1:6 + ┌─ for_no_in:1:7 │ -1 │ for x: - │ ^ expected keyword `in`, found symbol `:` +1 │ for x {} + │ ^ expected keyword `in`, found symbol `{` diff --git a/crates/parser/tests/cases/snapshots/cases__errors__if_no_body.snap b/crates/parser/tests/cases/snapshots/cases__errors__if_no_body.snap index 895fe252d4..5231063b3e 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__if_no_body.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__if_no_body.snap @@ -1,12 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(if_no_body), functions::parse_stmt, true,\n \"if x:\\nelse:\\n x\")" +expression: "err_string(stringify!(if_no_body), functions::parse_stmt,\n \"if x {} else { x }\")" --- -error: failed to parse `if` statement body - ┌─ if_no_body:1:1 - │ -1 │ if x: - │ ^^^^^ the body of this `if` statement must be indented and non-empty - diff --git a/crates/parser/tests/cases/snapshots/cases__errors__module_bad_stmt.snap b/crates/parser/tests/cases/snapshots/cases__errors__module_bad_stmt.snap index ec1698efa4..a0ae7cec6e 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__module_bad_stmt.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__module_bad_stmt.snap @@ -1,12 +1,12 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(module_bad_stmt), module::parse_module, true,\n \"if x:\\n y\")" +expression: "err_string(stringify!(module_bad_stmt), module::parse_module, \"if x { y }\")" --- error: failed to parse module ┌─ module_bad_stmt:1:1 │ -1 │ if x: +1 │ if x { y } │ ^^ unexpected token │ = Note: expected import, contract, struct, type, const or event diff --git a/crates/parser/tests/cases/snapshots/cases__errors__module_nonsense.snap b/crates/parser/tests/cases/snapshots/cases__errors__module_nonsense.snap index e45ed04f74..1ac7b8ae48 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__module_nonsense.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__module_nonsense.snap @@ -1,12 +1,20 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(module_nonsense), module::parse_module, true, \"))\")" +expression: "err_string(stringify!(module_nonsense), module::parse_module, \"))\")" --- -error: Unmatched right parenthesis +error: Unmatched `)` ┌─ module_nonsense:1:1 │ 1 │ )) │ ^ +error: failed to parse module + ┌─ module_nonsense:1:1 + │ +1 │ )) + │ ^ unexpected token + │ + = Note: expected import, contract, struct, type, const or event + diff --git a/crates/parser/tests/cases/snapshots/cases__errors__self_contract.snap b/crates/parser/tests/cases/snapshots/cases__errors__self_contract.snap index 7045e408ba..f877986d7a 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__self_contract.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__self_contract.snap @@ -1,12 +1,12 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(self_contract), module::parse_module, true,\n \"contract self:\\n pass\")" +expression: "err_string(stringify!(self_contract), module::parse_module,\n \"contract self {}\")" --- error: failed to parse contract definition ┌─ self_contract:1:10 │ -1 │ contract self: +1 │ contract self {} │ ^^^^ expected a name, found keyword `self` │ = Note: `contract` must be followed by a name, which must start with a letter and contain only letters, numbers, or underscores diff --git a/crates/parser/tests/cases/snapshots/cases__errors__self_fn.snap b/crates/parser/tests/cases/snapshots/cases__errors__self_fn.snap index 4d19021175..350ea40e8c 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__self_fn.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__self_fn.snap @@ -1,12 +1,12 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(self_fn), module::parse_module, true,\n \"pub fn self():\\n pass\")" +expression: "err_string(stringify!(self_fn), module::parse_module, \"pub fn self() {}\")" --- error: failed to parse function definition ┌─ self_fn:1:8 │ -1 │ pub fn self(): +1 │ pub fn self() {} │ ^^^^ expected a name, found keyword `self` diff --git a/crates/parser/tests/cases/snapshots/cases__errors__self_struct.snap b/crates/parser/tests/cases/snapshots/cases__errors__self_struct.snap index f160eccf6f..70cd412d50 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__self_struct.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__self_struct.snap @@ -1,12 +1,12 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(self_struct), module::parse_module, true,\n \"struct self:\\n pass\")" +expression: "err_string(stringify!(self_struct), module::parse_module, \"struct self {}\")" --- error: failed to parse struct definition ┌─ self_struct:1:8 │ -1 │ struct self: +1 │ struct self {} │ ^^^^ expected a name, found keyword `self` │ = Note: a struct name must start with a letter or underscore, and contain letters, numbers, or underscores diff --git a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_invalid_type_annotation.snap b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_invalid_type_annotation.snap index 0b5bdfb137..2199d5131c 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_invalid_type_annotation.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_invalid_type_annotation.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(stmt_vardecl_invalid_type_annotation),\n functions::parse_stmt, true, \"let x: y + z\")" +expression: "err_string(stringify!(stmt_vardecl_invalid_type_annotation),\n functions::parse_stmt, \"let x: y + z\")" --- error: unexpected token while parsing variable declaration @@ -9,6 +9,6 @@ error: unexpected token while parsing variable declaration 1 │ let x: y + z │ ^ unexpected token │ - = expected a newline + = expected a newline; found symbol `+` instead diff --git a/crates/parser/tests/cases/snapshots/cases__errors__struct_bad_field_name.snap b/crates/parser/tests/cases/snapshots/cases__errors__struct_bad_field_name.snap index b8700f886c..616996aed7 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__struct_bad_field_name.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__struct_bad_field_name.snap @@ -1,12 +1,12 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(struct_bad_field_name), types::parse_struct_def, true,\n \"struct f:\\n pub event\")" +expression: "err_string(stringify!(struct_bad_field_name), module::parse_module,\n \"struct f {\\n pub event }\")" --- error: failed to parse struct definition ┌─ struct_bad_field_name:2:6 │ -2 │ pub event +2 │ pub event } │ ^^^^^ unexpected token diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__contract_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__contract_def.snap index 0d61f5867f..9155669950 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__contract_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__contract_def.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(contract_def), try_parse_module,\n r#\"contract Foo:\n x: address\n pub y: u8\n pub const z: Map\n pub fn foo() -> u8:\n return 10\n event Bar:\n idx from: address\n\"#)" +expression: "ast_string(stringify!(contract_def), try_parse_module,\n r#\"contract Foo {\n x: address\n pub y: u8\n pub const z: Map\n\n pub fn foo() -> u8 {\n return 10\n }\n event Bar {\n idx from: address\n }\n}\n\"#)" --- Node( @@ -23,8 +23,8 @@ Node( name: Node( kind: "x", span: Span( - start: 16, - end: 17, + start: 17, + end: 18, ), ), typ: Node( @@ -32,15 +32,15 @@ Node( base: "address", ), span: Span( - start: 19, - end: 26, + start: 20, + end: 27, ), ), value: None, ), span: Span( - start: 16, - end: 26, + start: 17, + end: 27, ), ), Node( @@ -50,8 +50,8 @@ Node( name: Node( kind: "y", span: Span( - start: 33, - end: 34, + start: 34, + end: 35, ), ), typ: Node( @@ -59,15 +59,15 @@ Node( base: "u8", ), span: Span( - start: 36, - end: 38, + start: 37, + end: 39, ), ), value: None, ), span: Span( - start: 29, - end: 38, + start: 30, + end: 39, ), ), Node( @@ -77,8 +77,8 @@ Node( name: Node( kind: "z", span: Span( - start: 51, - end: 52, + start: 52, + end: 53, ), ), typ: Node( @@ -86,8 +86,8 @@ Node( base: Node( kind: "Map", span: Span( - start: 54, - end: 57, + start: 55, + end: 58, ), ), args: Node( @@ -97,8 +97,8 @@ Node( base: "u8", ), span: Span( - start: 58, - end: 60, + start: 59, + end: 61, ), )), TypeDesc(Node( @@ -106,27 +106,27 @@ Node( base: "address", ), span: Span( - start: 62, - end: 69, + start: 63, + end: 70, ), )), ], span: Span( - start: 57, - end: 70, + start: 58, + end: 71, ), ), ), span: Span( - start: 54, - end: 70, + start: 55, + end: 71, ), ), value: None, ), span: Span( - start: 41, - end: 70, + start: 42, + end: 71, ), ), ], @@ -134,22 +134,22 @@ Node( Function(Node( kind: Function( pub_: Some(Span( - start: 73, - end: 76, + start: 75, + end: 78, )), unsafe_: None, name: Node( kind: "foo", span: Span( - start: 80, - end: 83, + start: 82, + end: 85, ), ), generic_params: Node( kind: [], span: Span( - start: 80, - end: 83, + start: 82, + end: 85, ), ), args: [], @@ -158,8 +158,8 @@ Node( base: "u8", ), span: Span( - start: 89, - end: 91, + start: 91, + end: 93, ), )), body: [ @@ -168,21 +168,21 @@ Node( value: Some(Node( kind: Num("10"), span: Span( - start: 104, - end: 106, + start: 107, + end: 109, ), )), ), span: Span( - start: 97, - end: 106, + start: 100, + end: 109, ), ), ], ), span: Span( - start: 73, - end: 106, + start: 75, + end: 113, ), )), Event(Node( @@ -190,8 +190,8 @@ Node( name: Node( kind: "Bar", span: Span( - start: 115, - end: 118, + start: 122, + end: 125, ), ), fields: [ @@ -201,8 +201,8 @@ Node( name: Node( kind: "from", span: Span( - start: 128, - end: 132, + start: 136, + end: 140, ), ), typ: Node( @@ -210,22 +210,22 @@ Node( base: "address", ), span: Span( - start: 134, - end: 141, + start: 142, + end: 149, ), ), ), span: Span( - start: 124, - end: 141, + start: 132, + end: 149, ), ), ], pub_qual: None, ), span: Span( - start: 109, - end: 141, + start: 116, + end: 153, ), )), ], @@ -233,13 +233,13 @@ Node( ), span: Span( start: 0, - end: 141, + end: 155, ), )), ], ), span: Span( start: 0, - end: 141, + end: 155, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_contract_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_contract_def.snap index a481bda481..7c064f97da 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_contract_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_contract_def.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(empty_contract_def), module::parse_module,\n r#\"contract Foo:\n pass\n\"#)" +expression: "ast_string(stringify!(empty_contract_def), try_parse_module,\n \"contract Foo {}\")" --- Node( @@ -21,13 +21,13 @@ Node( ), span: Span( start: 0, - end: 12, + end: 15, ), )), ], ), span: Span( start: 0, - end: 12, + end: 15, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_event_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_event_def.snap index ab854ac2c2..29d785698c 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_event_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_event_def.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(empty_event_def), module::parse_module,\n \"event Foo:\\n pass\")" +expression: "ast_string(stringify!(empty_event_def), try_parse_module, \"event Foo {}\")" --- Node( @@ -20,13 +20,13 @@ Node( ), span: Span( start: 0, - end: 9, + end: 12, ), )), ], ), span: Span( start: 0, - end: 9, + end: 12, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_struct_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_struct_def.snap index 07c121595c..d2dff98b7a 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_struct_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_struct_def.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(empty_struct_def), module::parse_module,\n r#\"struct S:\n pass\n\"#)" +expression: "ast_string(stringify!(empty_struct_def), try_parse_module, \"struct S {}\")" --- Node( @@ -21,13 +21,13 @@ Node( ), span: Span( start: 0, - end: 8, + end: 11, ), )), ], ), span: Span( start: 0, - end: 8, + end: 11, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__event_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__event_def.snap index 8fc8c8fa5e..23b5b63790 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__event_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__event_def.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(event_def), module::parse_module,\n \"event Foo:\\n x: address\\n idx y: u8\")" +expression: "ast_string(stringify!(event_def), try_parse_module,\n \"event Foo {\\n x: address\\n idx y: u8\\n}\")" --- Node( @@ -22,8 +22,8 @@ Node( name: Node( kind: "x", span: Span( - start: 13, - end: 14, + start: 14, + end: 15, ), ), typ: Node( @@ -31,14 +31,14 @@ Node( base: "address", ), span: Span( - start: 16, - end: 23, + start: 17, + end: 24, ), ), ), span: Span( - start: 13, - end: 23, + start: 14, + end: 24, ), ), Node( @@ -47,8 +47,8 @@ Node( name: Node( kind: "y", span: Span( - start: 30, - end: 31, + start: 31, + end: 32, ), ), typ: Node( @@ -56,14 +56,14 @@ Node( base: "u8", ), span: Span( - start: 33, - end: 35, + start: 34, + end: 36, ), ), ), span: Span( - start: 26, - end: 35, + start: 27, + end: 36, ), ), ], @@ -71,13 +71,13 @@ Node( ), span: Span( start: 0, - end: 35, + end: 38, ), )), ], ), span: Span( start: 0, - end: 35, + end: 38, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def.snap index 24be74401c..9805e19812 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(fn_def), try_parse_module,\n \"fn transfer(from sender: address, to recip: address, _ val: u64) -> bool:\\n false\")" +expression: "ast_string(stringify!(fn_def), try_parse_module,\n \"fn transfer(from sender: address, to recip: address, _ val: u64) -> bool {\\n false \\n}\")" --- Node( @@ -134,27 +134,27 @@ Node( value: Node( kind: Bool(false), span: Span( - start: 75, - end: 80, + start: 76, + end: 81, ), ), ), span: Span( - start: 75, - end: 80, + start: 76, + end: 81, ), ), ], ), span: Span( start: 0, - end: 80, + end: 84, ), )), ], ), span: Span( start: 0, - end: 80, + end: 84, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_generic.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_generic.snap index 15e16ae572..ae957dd09f 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_generic.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_generic.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(fn_def_generic), try_parse_module,\n \"fn foo(this: T, that: R, _ val: u64) -> bool:\\n false\")" +expression: "ast_string(stringify!(fn_def_generic), try_parse_module,\n \"fn foo(this: T, that: R, _ val: u64) -> bool { false }\")" --- Node( @@ -160,13 +160,13 @@ Node( ), span: Span( start: 0, - end: 65, + end: 67, ), )), ], ), span: Span( start: 0, - end: 65, + end: 67, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_pub.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_pub.snap index aba7965c16..ce4cf5375b 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_pub.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_pub.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(fn_def_pub), try_parse_module,\n \"pub fn foo21(x: bool, y: address,) -> bool:\\n x\")" +expression: "ast_string(stringify!(fn_def_pub), try_parse_module,\n \"pub fn foo21(x: bool, y: address,) -> bool { x }\")" --- Node( @@ -108,13 +108,13 @@ Node( ), span: Span( start: 0, - end: 46, + end: 48, ), )), ], ), span: Span( start: 0, - end: 46, + end: 48, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_pub_unsafe.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_pub_unsafe.snap index 23de356ec9..40008a51ad 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_pub_unsafe.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_pub_unsafe.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(fn_def_pub_unsafe), try_parse_module,\n \"pub unsafe fn foo21(x: bool, y: address,) -> bool:\\n x\")" +expression: "ast_string(stringify!(fn_def_pub_unsafe), try_parse_module,\n \"pub unsafe fn foo21(x: bool, y: address,) -> bool{x}\")" --- Node( @@ -97,27 +97,27 @@ Node( value: Node( kind: Name("x"), span: Span( - start: 52, - end: 53, + start: 50, + end: 51, ), ), ), span: Span( - start: 52, - end: 53, + start: 50, + end: 51, ), ), ], ), span: Span( start: 0, - end: 53, + end: 52, ), )), ], ), span: Span( start: 0, - end: 53, + end: 52, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_unsafe.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_unsafe.snap index c63c32db1e..c381419f85 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_unsafe.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_unsafe.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(fn_def_unsafe), try_parse_module,\n \"unsafe fn foo21(x: bool, y: address,) -> bool:\\n x\")" +expression: "ast_string(stringify!(fn_def_unsafe), try_parse_module,\n \"unsafe fn foo21(x: bool, y: address,) -> bool {\\n x\\n}\")" --- Node( @@ -94,27 +94,27 @@ Node( value: Node( kind: Name("x"), span: Span( - start: 48, - end: 49, + start: 49, + end: 50, ), ), ), span: Span( - start: 48, - end: 49, + start: 49, + end: 50, ), ), ], ), span: Span( start: 0, - end: 49, + end: 52, ), )), ], ), span: Span( start: 0, - end: 49, + end: 52, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__guest_book.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__guest_book.snap index 34e8edca12..268c529205 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__guest_book.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__guest_book.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(guest_book), try_parse_module,\n r#\"\ntype BookMsg = Array\n\ncontract GuestBook:\n pub guest_book: Map\n\n event Signed:\n idx book_msg: BookMsg\n\n pub fn sign(self, book_msg: BookMsg):\n self.guest_book[msg.sender] = book_msg\n\n emit Signed(book_msg: book_msg)\n\n pub fn get_msg(self, addr: address) -> BookMsg:\n return self.guest_book[addr]\n\"#)" +expression: "ast_string(stringify!(guest_book), try_parse_module,\n r#\"\ntype BookMsg = Array\n\ncontract GuestBook {\n pub guest_book: Map\n\n event Signed {\n idx book_msg: BookMsg\n }\n\n pub fn sign(self, book_msg: BookMsg) {\n self.guest_book[msg.sender] = book_msg\n\n emit Signed(book_msg: book_msg)\n }\n pub fn get_msg(self, addr: address) -> BookMsg {\n return self.guest_book[addr]\n }\n}\"#)" --- Node( @@ -78,8 +78,8 @@ Node( name: Node( kind: "guest_book", span: Span( - start: 63, - end: 73, + start: 64, + end: 74, ), ), typ: Node( @@ -87,8 +87,8 @@ Node( base: Node( kind: "Map", span: Span( - start: 75, - end: 78, + start: 76, + end: 79, ), ), args: Node( @@ -98,8 +98,8 @@ Node( base: "address", ), span: Span( - start: 79, - end: 86, + start: 80, + end: 87, ), )), TypeDesc(Node( @@ -107,27 +107,27 @@ Node( base: "BookMsg", ), span: Span( - start: 88, - end: 95, + start: 89, + end: 96, ), )), ], span: Span( - start: 78, - end: 96, + start: 79, + end: 97, ), ), ), span: Span( - start: 75, - end: 96, + start: 76, + end: 97, ), ), value: None, ), span: Span( - start: 59, - end: 96, + start: 60, + end: 97, ), ), ], @@ -137,8 +137,8 @@ Node( name: Node( kind: "Signed", span: Span( - start: 108, - end: 114, + start: 109, + end: 115, ), ), fields: [ @@ -148,8 +148,8 @@ Node( name: Node( kind: "book_msg", span: Span( - start: 128, - end: 136, + start: 130, + end: 138, ), ), typ: Node( @@ -157,51 +157,51 @@ Node( base: "BookMsg", ), span: Span( - start: 138, - end: 145, + start: 140, + end: 147, ), ), ), span: Span( - start: 124, - end: 145, + start: 126, + end: 147, ), ), ], pub_qual: None, ), span: Span( - start: 102, - end: 145, + start: 103, + end: 153, ), )), Function(Node( kind: Function( pub_: Some(Span( - start: 151, - end: 154, + start: 159, + end: 162, )), unsafe_: None, name: Node( kind: "sign", span: Span( - start: 158, - end: 162, + start: 166, + end: 170, ), ), generic_params: Node( kind: [], span: Span( - start: 158, - end: 162, + start: 166, + end: 170, ), ), args: [ Node( kind: Self_, span: Span( - start: 163, - end: 167, + start: 171, + end: 175, ), ), Node( @@ -210,8 +210,8 @@ Node( name: Node( kind: "book_msg", span: Span( - start: 169, - end: 177, + start: 177, + end: 185, ), ), typ: Node( @@ -219,14 +219,14 @@ Node( base: "BookMsg", ), span: Span( - start: 179, - end: 186, + start: 187, + end: 194, ), ), )), span: Span( - start: 169, - end: 186, + start: 177, + end: 194, ), ), ], @@ -241,21 +241,21 @@ Node( value: Node( kind: Name("self"), span: Span( - start: 197, - end: 201, + start: 206, + end: 210, ), ), attr: Node( kind: "guest_book", span: Span( - start: 202, - end: 212, + start: 211, + end: 221, ), ), ), span: Span( - start: 197, - end: 212, + start: 206, + end: 221, ), ), index: Node( @@ -263,40 +263,40 @@ Node( value: Node( kind: Name("msg"), span: Span( - start: 213, - end: 216, + start: 222, + end: 225, ), ), attr: Node( kind: "sender", span: Span( - start: 217, - end: 223, + start: 226, + end: 232, ), ), ), span: Span( - start: 213, - end: 223, + start: 222, + end: 232, ), ), ), span: Span( - start: 197, - end: 224, + start: 206, + end: 233, ), ), value: Node( kind: Name("book_msg"), span: Span( - start: 227, - end: 235, + start: 236, + end: 244, ), ), ), span: Span( - start: 197, - end: 235, + start: 206, + end: 244, ), ), Node( @@ -304,8 +304,8 @@ Node( name: Node( kind: "Signed", span: Span( - start: 250, - end: 256, + start: 259, + end: 265, ), ), args: Node( @@ -315,69 +315,69 @@ Node( label: Some(Node( kind: "book_msg", span: Span( - start: 257, - end: 265, + start: 266, + end: 274, ), )), value: Node( kind: Name("book_msg"), span: Span( - start: 267, - end: 275, + start: 276, + end: 284, ), ), ), span: Span( - start: 257, - end: 275, + start: 266, + end: 284, ), ), ], span: Span( - start: 256, - end: 276, + start: 265, + end: 285, ), ), ), span: Span( - start: 245, - end: 276, + start: 254, + end: 285, ), ), ], ), span: Span( - start: 151, - end: 276, + start: 159, + end: 291, ), )), Function(Node( kind: Function( pub_: Some(Span( - start: 282, - end: 285, + start: 296, + end: 299, )), unsafe_: None, name: Node( kind: "get_msg", span: Span( - start: 289, - end: 296, + start: 303, + end: 310, ), ), generic_params: Node( kind: [], span: Span( - start: 289, - end: 296, + start: 303, + end: 310, ), ), args: [ Node( kind: Self_, span: Span( - start: 297, - end: 301, + start: 311, + end: 315, ), ), Node( @@ -386,8 +386,8 @@ Node( name: Node( kind: "addr", span: Span( - start: 303, - end: 307, + start: 317, + end: 321, ), ), typ: Node( @@ -395,14 +395,14 @@ Node( base: "address", ), span: Span( - start: 309, - end: 316, + start: 323, + end: 330, ), ), )), span: Span( - start: 303, - end: 316, + start: 317, + end: 330, ), ), ], @@ -411,8 +411,8 @@ Node( base: "BookMsg", ), span: Span( - start: 321, - end: 328, + start: 335, + end: 342, ), )), body: [ @@ -425,47 +425,47 @@ Node( value: Node( kind: Name("self"), span: Span( - start: 345, - end: 349, + start: 360, + end: 364, ), ), attr: Node( kind: "guest_book", span: Span( - start: 350, - end: 360, + start: 365, + end: 375, ), ), ), span: Span( - start: 345, - end: 360, + start: 360, + end: 375, ), ), index: Node( kind: Name("addr"), span: Span( - start: 361, - end: 365, + start: 376, + end: 380, ), ), ), span: Span( - start: 345, - end: 366, + start: 360, + end: 381, ), )), ), span: Span( - start: 338, - end: 366, + start: 353, + end: 381, ), ), ], ), span: Span( - start: 282, - end: 366, + start: 296, + end: 387, ), )), ], @@ -473,13 +473,13 @@ Node( ), span: Span( start: 35, - end: 366, + end: 389, ), )), ], ), span: Span( start: 0, - end: 366, + end: 389, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__module_level_events.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__module_level_events.snap index cbad5e032e..90e00d2467 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__module_level_events.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__module_level_events.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(module_level_events), try_parse_module,\n r#\"\nuse std::context::Context\n\nevent Transfer:\n idx sender: address\n idx receiver: address\n value: u256\n\ncontract Foo:\n fn transfer(ctx: Context, to: address, value: u256):\n emit Transfer(ctx, sender: msg.sender, receiver: to, value)\n\"#)" +expression: "ast_string(stringify!(module_level_events), try_parse_module,\n r#\"\nuse std::context::Context\n\nevent Transfer {\n idx sender: address\n idx receiver: address\n value: u256\n}\ncontract Foo {\n fn transfer(ctx: Context, to: address, value: u256) {\n emit Transfer(ctx, sender: msg.sender, receiver: to, value)\n }\n}\n\"#)" --- Node( @@ -64,8 +64,8 @@ Node( name: Node( kind: "sender", span: Span( - start: 52, - end: 58, + start: 53, + end: 59, ), ), typ: Node( @@ -73,14 +73,14 @@ Node( base: "address", ), span: Span( - start: 60, - end: 67, + start: 61, + end: 68, ), ), ), span: Span( - start: 48, - end: 67, + start: 49, + end: 68, ), ), Node( @@ -89,8 +89,8 @@ Node( name: Node( kind: "receiver", span: Span( - start: 76, - end: 84, + start: 77, + end: 85, ), ), typ: Node( @@ -98,14 +98,14 @@ Node( base: "address", ), span: Span( - start: 86, - end: 93, + start: 87, + end: 94, ), ), ), span: Span( - start: 72, - end: 93, + start: 73, + end: 94, ), ), Node( @@ -114,8 +114,8 @@ Node( name: Node( kind: "value", span: Span( - start: 98, - end: 103, + start: 99, + end: 104, ), ), typ: Node( @@ -123,14 +123,14 @@ Node( base: "u256", ), span: Span( - start: 105, - end: 109, + start: 106, + end: 110, ), ), ), span: Span( - start: 98, - end: 109, + start: 99, + end: 110, ), ), ], @@ -138,7 +138,7 @@ Node( ), span: Span( start: 28, - end: 109, + end: 112, ), )), Contract(Node( @@ -146,8 +146,8 @@ Node( name: Node( kind: "Foo", span: Span( - start: 120, - end: 123, + start: 122, + end: 125, ), ), fields: [], @@ -159,15 +159,15 @@ Node( name: Node( kind: "transfer", span: Span( - start: 132, - end: 140, + start: 135, + end: 143, ), ), generic_params: Node( kind: [], span: Span( - start: 132, - end: 140, + start: 135, + end: 143, ), ), args: [ @@ -177,8 +177,8 @@ Node( name: Node( kind: "ctx", span: Span( - start: 141, - end: 144, + start: 144, + end: 147, ), ), typ: Node( @@ -186,14 +186,14 @@ Node( base: "Context", ), span: Span( - start: 146, - end: 153, + start: 149, + end: 156, ), ), )), span: Span( - start: 141, - end: 153, + start: 144, + end: 156, ), ), Node( @@ -202,8 +202,8 @@ Node( name: Node( kind: "to", span: Span( - start: 155, - end: 157, + start: 158, + end: 160, ), ), typ: Node( @@ -211,14 +211,14 @@ Node( base: "address", ), span: Span( - start: 159, - end: 166, + start: 162, + end: 169, ), ), )), span: Span( - start: 155, - end: 166, + start: 158, + end: 169, ), ), Node( @@ -227,8 +227,8 @@ Node( name: Node( kind: "value", span: Span( - start: 168, - end: 173, + start: 171, + end: 176, ), ), typ: Node( @@ -236,14 +236,14 @@ Node( base: "u256", ), span: Span( - start: 175, - end: 179, + start: 178, + end: 182, ), ), )), span: Span( - start: 168, - end: 179, + start: 171, + end: 182, ), ), ], @@ -254,8 +254,8 @@ Node( name: Node( kind: "Transfer", span: Span( - start: 195, - end: 203, + start: 199, + end: 207, ), ), args: Node( @@ -266,14 +266,14 @@ Node( value: Node( kind: Name("ctx"), span: Span( - start: 204, - end: 207, + start: 208, + end: 211, ), ), ), span: Span( - start: 204, - end: 207, + start: 208, + end: 211, ), ), Node( @@ -281,8 +281,8 @@ Node( label: Some(Node( kind: "sender", span: Span( - start: 209, - end: 215, + start: 213, + end: 219, ), )), value: Node( @@ -290,27 +290,27 @@ Node( value: Node( kind: Name("msg"), span: Span( - start: 217, - end: 220, + start: 221, + end: 224, ), ), attr: Node( kind: "sender", span: Span( - start: 221, - end: 227, + start: 225, + end: 231, ), ), ), span: Span( - start: 217, - end: 227, + start: 221, + end: 231, ), ), ), span: Span( - start: 209, - end: 227, + start: 213, + end: 231, ), ), Node( @@ -318,21 +318,21 @@ Node( label: Some(Node( kind: "receiver", span: Span( - start: 229, - end: 237, + start: 233, + end: 241, ), )), value: Node( kind: Name("to"), span: Span( - start: 239, - end: 241, + start: 243, + end: 245, ), ), ), span: Span( - start: 229, - end: 241, + start: 233, + end: 245, ), ), Node( @@ -341,47 +341,47 @@ Node( value: Node( kind: Name("value"), span: Span( - start: 243, - end: 248, + start: 247, + end: 252, ), ), ), span: Span( - start: 243, - end: 248, + start: 247, + end: 252, ), ), ], span: Span( - start: 203, - end: 249, + start: 207, + end: 253, ), ), ), span: Span( - start: 190, - end: 249, + start: 194, + end: 253, ), ), ], ), span: Span( - start: 129, - end: 249, + start: 132, + end: 259, ), )), ], pub_qual: None, ), span: Span( - start: 111, - end: 249, + start: 113, + end: 261, ), )), ], ), span: Span( start: 0, - end: 249, + end: 261, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__module_stmts.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__module_stmts.snap index a00a095876..95c9accc16 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__module_stmts.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__module_stmts.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(module_stmts), try_parse_module,\n r#\"\npragma 0.5.0\n\nuse foo::bar::{\n bing as bong,\n food::*\n}\n\ntype X = Map\n\npub fn double(x: u8) -> u8:\n return x * 2\n\nfn secret() -> u8:\n return 0xBEEF\n\ncontract A:\n pub const x: u256 = 10\n\ncontract B:\n pub x: X\n\"#)" +expression: "ast_string(stringify!(module_stmts), try_parse_module,\n r#\"\npragma 0.5.0\n\nuse foo::bar::{\n bing as bong,\n food::*\n}\n\ntype X = Map\n\npub fn double(x: u8) -> u8 {\n return x * 2\n}\n\nfn secret() -> u8 { return 0xBEEF }\n\ncontract A {\n pub const x: u256 = 10\n}\n\ncontract B {\n pub x: X\n}\"#)" --- Node( @@ -224,41 +224,41 @@ Node( left: Node( kind: Name("x"), span: Span( - start: 126, - end: 127, + start: 127, + end: 128, ), ), op: Node( kind: Mult, span: Span( - start: 128, - end: 129, + start: 129, + end: 130, ), ), right: Node( kind: Num("2"), span: Span( - start: 130, - end: 131, + start: 131, + end: 132, ), ), ), span: Span( - start: 126, - end: 131, + start: 127, + end: 132, ), )), ), span: Span( - start: 119, - end: 131, + start: 120, + end: 132, ), ), ], ), span: Span( start: 87, - end: 131, + end: 134, ), )), Function(Node( @@ -268,15 +268,15 @@ Node( name: Node( kind: "secret", span: Span( - start: 136, - end: 142, + start: 139, + end: 145, ), ), generic_params: Node( kind: [], span: Span( - start: 136, - end: 142, + start: 139, + end: 145, ), ), args: [], @@ -285,8 +285,8 @@ Node( base: "u8", ), span: Span( - start: 148, - end: 150, + start: 151, + end: 153, ), )), body: [ @@ -308,8 +308,8 @@ Node( ], ), span: Span( - start: 133, - end: 169, + start: 136, + end: 171, ), )), Contract(Node( @@ -317,8 +317,8 @@ Node( name: Node( kind: "A", span: Span( - start: 180, - end: 181, + start: 182, + end: 183, ), ), fields: [ @@ -329,8 +329,8 @@ Node( name: Node( kind: "x", span: Span( - start: 197, - end: 198, + start: 200, + end: 201, ), ), typ: Node( @@ -338,21 +338,21 @@ Node( base: "u256", ), span: Span( - start: 200, - end: 204, + start: 203, + end: 207, ), ), value: Some(Node( kind: Num("10"), span: Span( - start: 207, - end: 209, + start: 210, + end: 212, ), )), ), span: Span( - start: 187, - end: 204, + start: 190, + end: 207, ), ), ], @@ -360,8 +360,8 @@ Node( pub_qual: None, ), span: Span( - start: 171, - end: 204, + start: 173, + end: 214, ), )), Contract(Node( @@ -369,8 +369,8 @@ Node( name: Node( kind: "B", span: Span( - start: 220, - end: 221, + start: 225, + end: 226, ), ), fields: [ @@ -381,8 +381,8 @@ Node( name: Node( kind: "x", span: Span( - start: 231, - end: 232, + start: 237, + end: 238, ), ), typ: Node( @@ -390,15 +390,15 @@ Node( base: "X", ), span: Span( - start: 234, - end: 235, + start: 240, + end: 241, ), ), value: None, ), span: Span( - start: 227, - end: 235, + start: 233, + end: 241, ), ), ], @@ -406,14 +406,14 @@ Node( pub_qual: None, ), span: Span( - start: 211, - end: 235, + start: 216, + end: 243, ), )), ], ), span: Span( start: 0, - end: 235, + end: 243, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_contract_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_contract_def.snap index 584a66f1a3..21cc0bead1 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_contract_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_contract_def.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(pub_contract_def), try_parse_module,\n r#\"pub contract Foo:\n pub fn foo() -> u8:\n return 10\n\"#)" +expression: "ast_string(stringify!(pub_contract_def), try_parse_module,\n r#\"\npub contract Foo {\n pub fn foo() -> u8 {\n return 10\n }\n}\"#)" --- Node( @@ -11,8 +11,8 @@ Node( name: Node( kind: "Foo", span: Span( - start: 13, - end: 16, + start: 14, + end: 17, ), ), fields: [], @@ -20,22 +20,22 @@ Node( Function(Node( kind: Function( pub_: Some(Span( - start: 22, - end: 25, + start: 24, + end: 27, )), unsafe_: None, name: Node( kind: "foo", span: Span( - start: 29, - end: 32, + start: 31, + end: 34, ), ), generic_params: Node( kind: [], span: Span( - start: 29, - end: 32, + start: 31, + end: 34, ), ), args: [], @@ -44,8 +44,8 @@ Node( base: "u8", ), span: Span( - start: 38, - end: 40, + start: 40, + end: 42, ), )), body: [ @@ -54,38 +54,38 @@ Node( value: Some(Node( kind: Num("10"), span: Span( - start: 55, - end: 57, + start: 58, + end: 60, ), )), ), span: Span( - start: 48, - end: 57, + start: 51, + end: 60, ), ), ], ), span: Span( - start: 22, - end: 57, + start: 24, + end: 66, ), )), ], pub_qual: Some(Span( - start: 0, - end: 3, + start: 1, + end: 4, )), ), span: Span( - start: 0, - end: 57, + start: 5, + end: 68, ), )), ], ), span: Span( start: 0, - end: 57, + end: 68, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_event_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_event_def.snap index 6cf869d4cd..486e9c4837 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_event_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_event_def.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(pub_event_def), module::parse_module,\n \"event Foo:\\n x: address\\n idx y: u8\")" +expression: "ast_string(stringify!(pub_event_def), try_parse_module,\n \"pub event Foo {\\nx: address\\nidx y: u8\\n}\")" --- Node( @@ -11,8 +11,8 @@ Node( name: Node( kind: "Foo", span: Span( - start: 6, - end: 9, + start: 10, + end: 13, ), ), fields: [ @@ -22,8 +22,8 @@ Node( name: Node( kind: "x", span: Span( - start: 13, - end: 14, + start: 16, + end: 17, ), ), typ: Node( @@ -31,14 +31,14 @@ Node( base: "address", ), span: Span( - start: 16, - end: 23, + start: 19, + end: 26, ), ), ), span: Span( - start: 13, - end: 23, + start: 16, + end: 26, ), ), Node( @@ -47,8 +47,8 @@ Node( name: Node( kind: "y", span: Span( - start: 30, - end: 31, + start: 31, + end: 32, ), ), typ: Node( @@ -56,28 +56,31 @@ Node( base: "u8", ), span: Span( - start: 33, - end: 35, + start: 34, + end: 36, ), ), ), span: Span( - start: 26, - end: 35, + start: 27, + end: 36, ), ), ], - pub_qual: None, + pub_qual: Some(Span( + start: 0, + end: 3, + )), ), span: Span( - start: 0, - end: 35, + start: 4, + end: 38, ), )), ], ), span: Span( start: 0, - end: 35, + end: 38, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_for.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_for.snap index 724d2abe5a..ad1c5a8893 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_for.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_for.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_for), functions::parse_stmt,\n \"for a in b[0]:\\n pass\")" +expression: "ast_string(stringify!(stmt_for), functions::parse_stmt, \"for a in b[0] {}\")" --- Node( @@ -34,18 +34,10 @@ Node( end: 13, ), ), - body: [ - Node( - kind: Pass, - span: Span( - start: 16, - end: 20, - ), - ), - ], + body: [], ), span: Span( start: 0, - end: 20, + end: 16, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_if.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_if.snap index abcfa3111a..14e04d1cb1 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_if.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_if.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_if), functions::parse_stmt, \"if a:\\n b\")" +expression: "ast_string(stringify!(stmt_if), functions::parse_stmt, \"if a { \\n b }\")" --- Node( @@ -18,14 +18,14 @@ Node( value: Node( kind: Name("b"), span: Span( - start: 7, - end: 8, + start: 9, + end: 10, ), ), ), span: Span( - start: 7, - end: 8, + start: 9, + end: 10, ), ), ], @@ -33,6 +33,6 @@ Node( ), span: Span( start: 0, - end: 8, + end: 10, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_if2.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_if2.snap index 026feb86a6..f57594e327 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_if2.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_if2.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_if2), functions::parse_stmt,\n \"if a:\\n b \\nelif c:\\n d \\nelif e: \\n f \\nelse:\\n g\")" +expression: "ast_string(stringify!(stmt_if2), functions::parse_stmt,\n \"if a { b } else if c { d } else if e { \\n f } \\n else {\\n g }\")" --- Node( @@ -35,8 +35,8 @@ Node( test: Node( kind: Name("c"), span: Span( - start: 15, - end: 16, + start: 19, + end: 20, ), ), body: [ @@ -45,14 +45,14 @@ Node( value: Node( kind: Name("d"), span: Span( - start: 19, - end: 20, + start: 23, + end: 24, ), ), ), span: Span( - start: 19, - end: 20, + start: 23, + end: 24, ), ), ], @@ -62,8 +62,8 @@ Node( test: Node( kind: Name("e"), span: Span( - start: 27, - end: 28, + start: 35, + end: 36, ), ), body: [ @@ -72,14 +72,14 @@ Node( value: Node( kind: Name("f"), span: Span( - start: 32, - end: 33, + start: 41, + end: 42, ), ), ), span: Span( - start: 32, - end: 33, + start: 41, + end: 42, ), ), ], @@ -89,34 +89,34 @@ Node( value: Node( kind: Name("g"), span: Span( - start: 42, - end: 43, + start: 55, + end: 56, ), ), ), span: Span( - start: 42, - end: 43, + start: 55, + end: 56, ), ), ], ), span: Span( - start: 22, - end: 43, + start: 32, + end: 56, ), ), ], ), span: Span( - start: 10, - end: 43, + start: 16, + end: 56, ), ), ], ), span: Span( start: 0, - end: 43, + end: 56, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_semicolons.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_semicolons.snap new file mode 100644 index 0000000000..abd92a54c1 --- /dev/null +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_semicolons.snap @@ -0,0 +1,91 @@ +--- +source: crates/parser/tests/cases/parse_ast.rs +expression: "ast_string(stringify!(stmt_semicolons), functions::parse_stmt,\n \"if a { b; c; d; for x in y {}; }\")" + +--- +Node( + kind: If( + test: Node( + kind: Name("a"), + span: Span( + start: 3, + end: 4, + ), + ), + body: [ + Node( + kind: Expr( + value: Node( + kind: Name("b"), + span: Span( + start: 7, + end: 8, + ), + ), + ), + span: Span( + start: 7, + end: 8, + ), + ), + Node( + kind: Expr( + value: Node( + kind: Name("c"), + span: Span( + start: 10, + end: 11, + ), + ), + ), + span: Span( + start: 10, + end: 11, + ), + ), + Node( + kind: Expr( + value: Node( + kind: Name("d"), + span: Span( + start: 13, + end: 14, + ), + ), + ), + span: Span( + start: 13, + end: 14, + ), + ), + Node( + kind: For( + target: Node( + kind: "x", + span: Span( + start: 20, + end: 21, + ), + ), + iter: Node( + kind: Name("y"), + span: Span( + start: 25, + end: 26, + ), + ), + body: [], + ), + span: Span( + start: 16, + end: 29, + ), + ), + ], + or_else: [], + ), + span: Span( + start: 0, + end: 29, + ), +) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_while.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_while.snap index db01ccd96a..64a685f7ba 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_while.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_while.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_while), functions::parse_stmt,\n \"while a > 5:\\n a -= 1\")" +expression: "ast_string(stringify!(stmt_while), functions::parse_stmt,\n \"while a > 5 { \\n a -= 1 }\")" --- Node( @@ -40,34 +40,34 @@ Node( target: Node( kind: Name("a"), span: Span( - start: 14, - end: 15, + start: 16, + end: 17, ), ), op: Node( kind: Sub, span: Span( - start: 16, - end: 18, + start: 18, + end: 20, ), ), value: Node( kind: Num("1"), span: Span( - start: 19, - end: 20, + start: 21, + end: 22, ), ), ), span: Span( - start: 14, - end: 20, + start: 16, + end: 22, ), ), ], ), span: Span( start: 0, - end: 20, + end: 24, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__struct_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__struct_def.snap index f2f171ed32..c19c7f19ee 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__struct_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__struct_def.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(struct_def), try_parse_module,\n r#\"struct S:\n x: address\n pub y: u8\n z: u8\n pub a: Map\n\n pub fn foo(self) -> u8:\n return self.z + self.y\n unsafe fn bar():\n pass\n\"#)" +expression: "ast_string(stringify!(struct_def), try_parse_module,\n r#\"struct S {\n x: address\n pub y: u8\n z: u8\n pub a: Map\n\n pub fn foo(self) -> u8 {\n return self.z + self.y\n }\n unsafe fn bar() {}\n}\"#)" --- Node( @@ -23,8 +23,8 @@ Node( name: Node( kind: "x", span: Span( - start: 12, - end: 13, + start: 13, + end: 14, ), ), typ: Node( @@ -32,15 +32,15 @@ Node( base: "address", ), span: Span( - start: 15, - end: 22, + start: 16, + end: 23, ), ), value: None, ), span: Span( - start: 12, - end: 22, + start: 13, + end: 23, ), ), Node( @@ -50,8 +50,8 @@ Node( name: Node( kind: "y", span: Span( - start: 29, - end: 30, + start: 30, + end: 31, ), ), typ: Node( @@ -59,15 +59,15 @@ Node( base: "u8", ), span: Span( - start: 32, - end: 34, + start: 33, + end: 35, ), ), value: None, ), span: Span( - start: 25, - end: 34, + start: 26, + end: 35, ), ), Node( @@ -77,8 +77,8 @@ Node( name: Node( kind: "z", span: Span( - start: 37, - end: 38, + start: 38, + end: 39, ), ), typ: Node( @@ -86,15 +86,15 @@ Node( base: "u8", ), span: Span( - start: 40, - end: 42, + start: 41, + end: 43, ), ), value: None, ), span: Span( - start: 37, - end: 42, + start: 38, + end: 43, ), ), Node( @@ -104,8 +104,8 @@ Node( name: Node( kind: "a", span: Span( - start: 49, - end: 50, + start: 50, + end: 51, ), ), typ: Node( @@ -113,8 +113,8 @@ Node( base: Node( kind: "Map", span: Span( - start: 52, - end: 55, + start: 53, + end: 56, ), ), args: Node( @@ -124,8 +124,8 @@ Node( base: "u8", ), span: Span( - start: 56, - end: 58, + start: 57, + end: 59, ), )), TypeDesc(Node( @@ -133,27 +133,27 @@ Node( base: "foo", ), span: Span( - start: 60, - end: 63, + start: 61, + end: 64, ), )), ], span: Span( - start: 55, - end: 64, + start: 56, + end: 65, ), ), ), span: Span( - start: 52, - end: 64, + start: 53, + end: 65, ), ), value: None, ), span: Span( - start: 45, - end: 64, + start: 46, + end: 65, ), ), ], @@ -161,30 +161,30 @@ Node( Node( kind: Function( pub_: Some(Span( - start: 68, - end: 71, + start: 69, + end: 72, )), unsafe_: None, name: Node( kind: "foo", span: Span( - start: 75, - end: 78, + start: 76, + end: 79, ), ), generic_params: Node( kind: [], span: Span( - start: 75, - end: 78, + start: 76, + end: 79, ), ), args: [ Node( kind: Self_, span: Span( - start: 79, - end: 83, + start: 80, + end: 84, ), ), ], @@ -193,8 +193,8 @@ Node( base: "u8", ), span: Span( - start: 88, - end: 90, + start: 89, + end: 91, ), )), body: [ @@ -207,28 +207,28 @@ Node( value: Node( kind: Name("self"), span: Span( - start: 103, - end: 107, + start: 105, + end: 109, ), ), attr: Node( kind: "z", span: Span( - start: 108, - end: 109, + start: 110, + end: 111, ), ), ), span: Span( - start: 103, - end: 109, + start: 105, + end: 111, ), ), op: Node( kind: Add, span: Span( - start: 110, - end: 111, + start: 112, + end: 113, ), ), right: Node( @@ -236,78 +236,70 @@ Node( value: Node( kind: Name("self"), span: Span( - start: 112, - end: 116, + start: 114, + end: 118, ), ), attr: Node( kind: "y", span: Span( - start: 117, - end: 118, + start: 119, + end: 120, ), ), ), span: Span( - start: 112, - end: 118, + start: 114, + end: 120, ), ), ), span: Span( - start: 103, - end: 118, + start: 105, + end: 120, ), )), ), span: Span( - start: 96, - end: 118, + start: 98, + end: 120, ), ), ], ), span: Span( - start: 68, - end: 118, + start: 69, + end: 124, ), ), Node( kind: Function( pub_: None, unsafe_: Some(Span( - start: 121, - end: 127, + start: 127, + end: 133, )), name: Node( kind: "bar", span: Span( - start: 131, - end: 134, + start: 137, + end: 140, ), ), generic_params: Node( kind: [], span: Span( - start: 131, - end: 134, + start: 137, + end: 140, ), ), args: [], return_type: None, - body: [ - Node( - kind: Pass, - span: Span( - start: 142, - end: 146, - ), - ), - ], + body: [], ), span: Span( - start: 121, - end: 146, + start: 127, + end: 145, ), ), ], @@ -315,13 +307,13 @@ Node( ), span: Span( start: 0, - end: 64, + end: 147, ), )), ], ), span: Span( start: 0, - end: 64, + end: 147, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__print_ast__defs.snap b/crates/parser/tests/cases/snapshots/cases__print_ast__defs.snap new file mode 100644 index 0000000000..ebe56f1eee --- /dev/null +++ b/crates/parser/tests/cases/snapshots/cases__print_ast__defs.snap @@ -0,0 +1,66 @@ +--- +source: crates/parser/tests/cases/print_ast.rs +expression: "parse_and_print(\"printing/defs.fe\", src)" + +--- +use foo::bar as baz +use foo::food +use bing::bong::* +use test1::{test1_1, test1_2::{test_1_2_1::*}} + +type MyType = String<42> + +struct MyStruct { + field1: foo::Bar + field2: u256 + field3: address + + pub fn field2_squared(self) -> u256 { + return self.field2 * self.field2 + } +} + +struct EmptyType {} + +contract Foo { + field1: Map + field2: bool + + event EmptyEvent {} + + event MyEvent { + idx field1: bool + field2: String<42> + } + + pub fn my_func() { + std::solidity::bytes2::from_array([1, 2]) + if x { + } else if y { + 2 + 1 + 3 + 4 + } else if z { + } else { + 1 + } + unsafe {} + } + + fn my_other_func() {} + + fn foo() { + while x { + y + } + while y {} + for x in y {} + for x in y { + 5 + } + } +} + +contract Bar { + pub fn __init__() {} +} + diff --git a/crates/parser/tests/cases/snapshots/cases__print_ast__erc20.snap b/crates/parser/tests/cases/snapshots/cases__print_ast__erc20.snap new file mode 100644 index 0000000000..c74fd97eac --- /dev/null +++ b/crates/parser/tests/cases/snapshots/cases__print_ast__erc20.snap @@ -0,0 +1,124 @@ +--- +source: crates/parser/tests/cases/print_ast.rs +expression: "parse_and_print(\"demos/erc20_token.fe\", src)" + +--- +use std::context::Context + +contract ERC20 { + _balances: Map + _allowances: Map> + _total_supply: u256 + _name: String<100> + _symbol: String<100> + _decimals: u8 + + event Approval { + idx owner: address + idx spender: address + value: u256 + } + + event Transfer { + idx from: address + idx to: address + value: u256 + } + + pub fn __init__(self, ctx: Context, name: String<100>, symbol: String<100>) { + self._name = name + self._symbol = symbol + self._decimals = u8(18) + self._mint(ctx, account: ctx.msg_sender(), value: 1000_000_000_000_000_000_000_000) + } + + pub fn name(self) -> String<100> { + return self._name.to_mem() + } + + pub fn symbol(self) -> String<100> { + return self._symbol.to_mem() + } + + pub fn decimals(self) -> u8 { + return self._decimals + } + + pub fn totalSupply(self) -> u256 { + return self._total_supply + } + + pub fn balanceOf(self, _ account: address) -> u256 { + return self._balances[account] + } + + pub fn transfer(self, ctx: Context, recipient: address, value: u256) -> bool { + self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) + return true + } + + pub fn allowance(self, owner: address, spender: address) -> u256 { + return self._allowances[owner][spender] + } + + pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool { + self._approve(ctx, owner: ctx.msg_sender(), spender, value) + return true + } + + pub fn transferFrom(self, ctx: Context, sender: address, recipient: address, value: u256) -> bool { + assert self._allowances[sender][ctx.msg_sender()] >= value + self._transfer(ctx, sender, recipient, value) + self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) + return true + } + + pub fn increaseAllowance(self, ctx: Context, spender: address, addedValue: u256) -> bool { + self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) + return true + } + + pub fn decreaseAllowance(self, ctx: Context, spender: address, subtractedValue: u256) -> bool { + self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) + return true + } + + fn _transfer(self, ctx: Context, sender: address, recipient: address, value: u256) { + assert sender != address(0) + assert recipient != address(0) + _before_token_transfer(from: sender, to: recipient, value) + self._balances[sender] = self._balances[sender] - value + self._balances[recipient] = self._balances[recipient] + value + emit Transfer(ctx, from: sender, to: recipient, value) + } + + fn _mint(self, ctx: Context, account: address, value: u256) { + assert account != address(0) + _before_token_transfer(from: address(0), to: account, value) + self._total_supply = self._total_supply + value + self._balances[account] = self._balances[account] + value + emit Transfer(ctx, from: address(0), to: account, value) + } + + fn _burn(self, ctx: Context, account: address, value: u256) { + assert account != address(0) + _before_token_transfer(from: account, to: address(0), value) + self._balances[account] = self._balances[account] - value + self._total_supply = self._total_supply - value + emit Transfer(ctx, from: account, to: address(0), value) + } + + fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { + assert owner != address(0) + assert spender != address(0) + self._allowances[owner][spender] = value + emit Approval(ctx, owner, spender, value) + } + + fn _setup_decimals(self, _ decimals_: u8) { + self._decimals = decimals_ + } + + fn _before_token_transfer(from: address, to: address, _ value: u256) {} +} + diff --git a/crates/parser/tests/cases/snapshots/cases__print_ast__expr_parens.snap b/crates/parser/tests/cases/snapshots/cases__print_ast__expr_parens.snap new file mode 100644 index 0000000000..101def37f8 --- /dev/null +++ b/crates/parser/tests/cases/snapshots/cases__print_ast__expr_parens.snap @@ -0,0 +1,28 @@ +--- +source: crates/parser/tests/cases/print_ast.rs +expression: "parse_and_print(\"printing/expr_parens.fe\", src)" + +--- +contract Foo { + fn bar() -> i256 { + let baz1: i256 = -(4 * (26 + 52)) + let baz2: bool = not ((true or false) and true) + let baz3: bool = not (true or false) and true + let baz4: bool = not true or false and true + let baz5: bool = not true or not (false and (true or not (32 + 26) / 5 == 0)) and false + let baz6: i256 = -(4 * (26 + 52)) + let bing: i256 + bing = (4 << 26) + 52 + self.does_not_exist + bing = (4 << 26) * (52 / does_not_exist + 32) + bing = -42 ** 52 + bing = (-42) ** 52 + let bong: bool = -call_my_func("hello") == -3 ** 41 + let bang: bool = 1 == 2 == (3 == 4) + let biz: u256 = 3 * (4 / 5) + let big: u256 = 3 * 4 / 5 + let test: u256 = 3 ** 4 ** 5 + let test2: u256 = (3 ** 4) ** 5 + return -4 * (26 + 52) + } +} + diff --git a/crates/parser/tests/cases/snapshots/cases__print_ast__guest_book.snap b/crates/parser/tests/cases/snapshots/cases__print_ast__guest_book.snap new file mode 100644 index 0000000000..d4a34739bc --- /dev/null +++ b/crates/parser/tests/cases/snapshots/cases__print_ast__guest_book.snap @@ -0,0 +1,24 @@ +--- +source: crates/parser/tests/cases/print_ast.rs +expression: "parse_and_print(\"demos/guest_book.fe\", src)" + +--- +use std::context::Context + +contract GuestBook { + messages: Map> + + event Signed { + book_msg: String<100> + } + + pub fn sign(self, ctx: Context, book_msg: String<100>) { + self.messages[ctx.msg_sender()] = book_msg + emit Signed(ctx, book_msg) + } + + pub fn get_msg(self, addr: address) -> String<100> { + return self.messages[addr].to_mem() + } +} + diff --git a/crates/test-files/fixtures/compile_errors/abi_encode_from_storage.fe b/crates/test-files/fixtures/compile_errors/abi_encode_from_storage.fe index 9647a4cca4..d790d287fa 100644 --- a/crates/test-files/fixtures/compile_errors/abi_encode_from_storage.fe +++ b/crates/test-files/fixtures/compile_errors/abi_encode_from_storage.fe @@ -1,5 +1,7 @@ -contract Foo: +contract Foo { my_field: (u256, bool) - pub fn bar(self): - self.my_field.abi_encode() \ No newline at end of file + pub fn bar(self) { + self.my_field.abi_encode() + } +} diff --git a/crates/test-files/fixtures/compile_errors/abi_encode_u256.fe b/crates/test-files/fixtures/compile_errors/abi_encode_u256.fe index 64e05e3e95..ca87c46734 100644 --- a/crates/test-files/fixtures/compile_errors/abi_encode_u256.fe +++ b/crates/test-files/fixtures/compile_errors/abi_encode_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn foo(): - 42.abi_encode() \ No newline at end of file +contract Foo { + pub fn foo() { + 42.abi_encode() + } +} diff --git a/crates/test-files/fixtures/compile_errors/assert_sto_msg_no_copy.fe b/crates/test-files/fixtures/compile_errors/assert_sto_msg_no_copy.fe index b589818952..5acb966e9c 100644 --- a/crates/test-files/fixtures/compile_errors/assert_sto_msg_no_copy.fe +++ b/crates/test-files/fixtures/compile_errors/assert_sto_msg_no_copy.fe @@ -1,5 +1,7 @@ -contract Foo: +contract Foo { my_string: String<42> - pub fn bar(self): - assert false, self.my_string \ No newline at end of file + pub fn bar(self) { + assert false, self.my_string + } +} diff --git a/crates/test-files/fixtures/compile_errors/bad_ingot/src/bing.fe b/crates/test-files/fixtures/compile_errors/bad_ingot/src/bing.fe index d3d4c58dfc..c98d5c8b3c 100644 --- a/crates/test-files/fixtures/compile_errors/bad_ingot/src/bing.fe +++ b/crates/test-files/fixtures/compile_errors/bad_ingot/src/bing.fe @@ -1,4 +1,3 @@ use std -struct Bong: - pass \ No newline at end of file +struct Bong {} diff --git a/crates/test-files/fixtures/compile_errors/bad_ingot/src/biz/bad.fe b/crates/test-files/fixtures/compile_errors/bad_ingot/src/biz/bad.fe index 44b94fcc5c..0eb4b24e59 100644 --- a/crates/test-files/fixtures/compile_errors/bad_ingot/src/biz/bad.fe +++ b/crates/test-files/fixtures/compile_errors/bad_ingot/src/biz/bad.fe @@ -1,5 +1,3 @@ -struct Bur: - pass +struct Bur {} -struct Bud: - pass \ No newline at end of file +struct Bud {} diff --git a/crates/test-files/fixtures/compile_errors/bad_ingot/src/foo.fe b/crates/test-files/fixtures/compile_errors/bad_ingot/src/foo.fe index e4782ed2ce..5b6dc4972a 100644 --- a/crates/test-files/fixtures/compile_errors/bad_ingot/src/foo.fe +++ b/crates/test-files/fixtures/compile_errors/bad_ingot/src/foo.fe @@ -2,8 +2,8 @@ use ingot::bing::Bong::* use ingot::bing::Tong use ingot::bing as std -struct Foo: +struct Foo { pub my_num: u256 +} -struct Bar: - pass \ No newline at end of file +struct Bar {} diff --git a/crates/test-files/fixtures/compile_errors/bad_ingot/src/main.fe b/crates/test-files/fixtures/compile_errors/bad_ingot/src/main.fe index 551f022150..54c403ef2a 100644 --- a/crates/test-files/fixtures/compile_errors/bad_ingot/src/main.fe +++ b/crates/test-files/fixtures/compile_errors/bad_ingot/src/main.fe @@ -3,10 +3,10 @@ use biz::bad::{Bur, Bud as Bar, Boo} use biz::Bark use none::* -contract Bar: - - pub fn a() -> foo::Foo: +contract Bar { + pub fn a() -> foo::Foo { return foo::Foo(my_num: true) + } +} -fn std(): - pass \ No newline at end of file +fn std() {} diff --git a/crates/test-files/fixtures/compile_errors/bad_string.fe b/crates/test-files/fixtures/compile_errors/bad_string.fe index 8c7d5ab82f..90e8d7d4c5 100644 --- a/crates/test-files/fixtures/compile_errors/bad_string.fe +++ b/crates/test-files/fixtures/compile_errors/bad_string.fe @@ -1,3 +1,5 @@ -contract foo: - pub fn bar(self): +contract foo { + pub fn bar(self) { let s: String<1> = "Fe" + } +} diff --git a/crates/test-files/fixtures/compile_errors/bad_tuple_attr1.fe b/crates/test-files/fixtures/compile_errors/bad_tuple_attr1.fe index 66cc49fc79..88f9f25602 100644 --- a/crates/test-files/fixtures/compile_errors/bad_tuple_attr1.fe +++ b/crates/test-files/fixtures/compile_errors/bad_tuple_attr1.fe @@ -1,6 +1,8 @@ # See ethereum/fe issue #396 -contract foo: +contract foo { my_sto_tuple: (u256, i32) - pub fn bar(self): + pub fn bar(self) { self.my_sto_tuple.iteo0 + } +} diff --git a/crates/test-files/fixtures/compile_errors/bad_tuple_attr2.fe b/crates/test-files/fixtures/compile_errors/bad_tuple_attr2.fe index fdbb95eed7..d05bbbb54c 100644 --- a/crates/test-files/fixtures/compile_errors/bad_tuple_attr2.fe +++ b/crates/test-files/fixtures/compile_errors/bad_tuple_attr2.fe @@ -1,6 +1,8 @@ # See ethereum/fe issue #399 -contract foo: +contract foo { my_sto_tuple: (u256, i32) - pub fn bar(self): - self.my_sto_tuple.m \ No newline at end of file + pub fn bar(self) { + self.my_sto_tuple.m + } +} diff --git a/crates/test-files/fixtures/compile_errors/bad_tuple_attr3.fe b/crates/test-files/fixtures/compile_errors/bad_tuple_attr3.fe index 87e15f2802..f7a5d9ed53 100644 --- a/crates/test-files/fixtures/compile_errors/bad_tuple_attr3.fe +++ b/crates/test-files/fixtures/compile_errors/bad_tuple_attr3.fe @@ -1,6 +1,8 @@ # See ethereum/fe issue #470 -contract foo: +contract foo { my_sto_tuple: (u256, i32) - pub fn bar(self): - self.my_sto_tuple.item00 \ No newline at end of file + pub fn bar(self) { + self.my_sto_tuple.item00 + } +} diff --git a/crates/test-files/fixtures/compile_errors/bad_visibility/src/foo.fe b/crates/test-files/fixtures/compile_errors/bad_visibility/src/foo.fe index 40e95bbe16..08fc81c6e4 100644 --- a/crates/test-files/fixtures/compile_errors/bad_visibility/src/foo.fe +++ b/crates/test-files/fixtures/compile_errors/bad_visibility/src/foo.fe @@ -2,14 +2,16 @@ type MyInt = i32 const MY_CONST: MyInt = 1 -event MyEvent: +event MyEvent { x: i32 - -struct MyStruct: +} + +struct MyStruct { + x: i32 +} + +fn my_func() {} + +contract MyContract { x: i32 - -fn my_func(): - pass - -contract MyContract: - x: i32 \ No newline at end of file +} diff --git a/crates/test-files/fixtures/compile_errors/bad_visibility/src/main.fe b/crates/test-files/fixtures/compile_errors/bad_visibility/src/main.fe index fe3700989c..e66ba402fb 100644 --- a/crates/test-files/fixtures/compile_errors/bad_visibility/src/main.fe +++ b/crates/test-files/fixtures/compile_errors/bad_visibility/src/main.fe @@ -1,23 +1,30 @@ use foo::{MyInt, MY_CONST, MyEvent, MyStruct, my_func, MyContract} use std::context::Context -contract Main: - pub fn priv_type_alias() -> MyInt: +contract Main { + pub fn priv_type_alias() -> MyInt { let x: MyInt = 1 return x - - pub fn priv_const() -> i32: + } + + pub fn priv_const() -> i32 { return MY_CONST - - pub fn priv_event(): + } + + pub fn priv_event() { emit MyEvent(ctx, x: 1) - - pub fn priv_struct(): + } + + pub fn priv_struct() { let s: MyStruct = MyStruct(x: 1) - - pub fn priv_func(): + } + + pub fn priv_func() { my_func() - - pub fn priv_contract(ctx: Context, addr: address): + } + + pub fn priv_contract(ctx: Context, addr: address) { let _: MyContract = MyContract(ctx, addr) MyContract.create(ctx, 1) + } +} diff --git a/crates/test-files/fixtures/compile_errors/call_builtin_object.fe b/crates/test-files/fixtures/compile_errors/call_builtin_object.fe index ffa016137a..1205522966 100644 --- a/crates/test-files/fixtures/compile_errors/call_builtin_object.fe +++ b/crates/test-files/fixtures/compile_errors/call_builtin_object.fe @@ -1,4 +1,5 @@ - -contract Bar: - pub fn test(): - block.foo() \ No newline at end of file +contract Bar { + pub fn test() { + block.foo() + } +} diff --git a/crates/test-files/fixtures/compile_errors/call_call_on_external_contract.fe b/crates/test-files/fixtures/compile_errors/call_call_on_external_contract.fe index fa77408611..1f5a704ec5 100644 --- a/crates/test-files/fixtures/compile_errors/call_call_on_external_contract.fe +++ b/crates/test-files/fixtures/compile_errors/call_call_on_external_contract.fe @@ -1,13 +1,14 @@ use std::context::Context -contract Foo: - pub fn __call__(): - pass - fn f(): - pass +contract Foo { + pub fn __call__() {} + fn f() {} +} -contract Bar: - fn b(ctx: Context): - let foo: Foo = Foo(ctx, address(0)) - foo.__call__() +contract Bar { + fn b(ctx: Context) { + let foo: Foo = Foo(ctx, address(0)) + foo.__call__() + } +} diff --git a/crates/test-files/fixtures/compile_errors/call_call_on_self.fe b/crates/test-files/fixtures/compile_errors/call_call_on_self.fe index df9445f322..33dab51277 100644 --- a/crates/test-files/fixtures/compile_errors/call_call_on_self.fe +++ b/crates/test-files/fixtures/compile_errors/call_call_on_self.fe @@ -1,6 +1,7 @@ -contract Foo: - pub fn __call__(): - pass +contract Foo { + pub fn __call__() {} - fn bar(self): - self.__call__() \ No newline at end of file + fn bar(self) { + self.__call__() + } +} diff --git a/crates/test-files/fixtures/compile_errors/call_create2_with_wrong_type.fe b/crates/test-files/fixtures/compile_errors/call_create2_with_wrong_type.fe index d0838a28e0..998f638195 100644 --- a/crates/test-files/fixtures/compile_errors/call_create2_with_wrong_type.fe +++ b/crates/test-files/fixtures/compile_errors/call_create2_with_wrong_type.fe @@ -1,11 +1,11 @@ use std::context::Context -contract Bar: - pass +contract Bar {} -contract Foo: - - pub fn foo(ctx: Context): +contract Foo { + pub fn foo(ctx: Context) { Bar.create2(ctx, true, 1) Bar.create2(ctx, 1) # agroce #447 Bar.create2(ctx) + } +} diff --git a/crates/test-files/fixtures/compile_errors/call_create_with_wrong_type.fe b/crates/test-files/fixtures/compile_errors/call_create_with_wrong_type.fe index 1d96d69a09..1f32b10311 100644 --- a/crates/test-files/fixtures/compile_errors/call_create_with_wrong_type.fe +++ b/crates/test-files/fixtures/compile_errors/call_create_with_wrong_type.fe @@ -1,9 +1,10 @@ use std::context::Context -contract Bar: - pass +contract Bar {} -contract Foo: - pub fn foo(ctx: Context): +contract Foo { + pub fn foo(ctx: Context) { Bar.create(ctx, true) Bar.create(ctx) # agroce #447 + } +} diff --git a/crates/test-files/fixtures/compile_errors/call_duplicate_def.fe b/crates/test-files/fixtures/compile_errors/call_duplicate_def.fe index 0631c11131..ed2fcb3b47 100644 --- a/crates/test-files/fixtures/compile_errors/call_duplicate_def.fe +++ b/crates/test-files/fixtures/compile_errors/call_duplicate_def.fe @@ -1,12 +1,13 @@ -contract Foo: - pub fn __call__(): - pass +contract Foo { + pub fn __call__() {} - fn bar(): - pass + fn bar() {} - pub fn __call__(): + pub fn __call__() { 1 + 2 + } - pub fn __call__(): + pub fn __call__() { 3 + 4 + } +} diff --git a/crates/test-files/fixtures/compile_errors/call_event_with_wrong_types.fe b/crates/test-files/fixtures/compile_errors/call_event_with_wrong_types.fe index acd1c26f3c..95a7137dec 100644 --- a/crates/test-files/fixtures/compile_errors/call_event_with_wrong_types.fe +++ b/crates/test-files/fixtures/compile_errors/call_event_with_wrong_types.fe @@ -1,9 +1,12 @@ use std::context::Context -contract Foo: - event MyEvent: +contract Foo { + event MyEvent { val_1: String<5> idx val_2: u8 + } - pub fn foo(ctx: Context): + pub fn foo(ctx: Context) { emit MyEvent(ctx, val_1: "foo bar", val_2: 1000) + } +} diff --git a/crates/test-files/fixtures/compile_errors/call_non_pub_fn_on_external_contract.fe b/crates/test-files/fixtures/compile_errors/call_non_pub_fn_on_external_contract.fe index e08c02f3d3..93869ae5df 100644 --- a/crates/test-files/fixtures/compile_errors/call_non_pub_fn_on_external_contract.fe +++ b/crates/test-files/fixtures/compile_errors/call_non_pub_fn_on_external_contract.fe @@ -1,10 +1,15 @@ use std::context::Context -contract Foo: - val: u8 - fn do_private_thingz(self): - self.val = 100 +contract Foo { + val: u8 -contract Bar: - fn test(ctx: Context): - Foo(ctx, address(0)).do_private_thingz() + fn do_private_thingz(self) { + self.val = 100 + } +} + +contract Bar { + fn test(ctx: Context) { + Foo(ctx, address(0)).do_private_thingz() + } +} diff --git a/crates/test-files/fixtures/compile_errors/call_static_function_without_double_colon.fe b/crates/test-files/fixtures/compile_errors/call_static_function_without_double_colon.fe index 8c01065106..5b4659ccef 100644 --- a/crates/test-files/fixtures/compile_errors/call_static_function_without_double_colon.fe +++ b/crates/test-files/fixtures/compile_errors/call_static_function_without_double_colon.fe @@ -1,8 +1,9 @@ -struct Bar: - pub fn call_me(): - pass +struct Bar { + pub fn call_me() {} +} -contract Foo: - - fn bar(self): - Bar.call_me() \ No newline at end of file +contract Foo { + fn bar(self) { + Bar.call_me() + } +} diff --git a/crates/test-files/fixtures/compile_errors/call_to_mut_fn_without_self.fe b/crates/test-files/fixtures/compile_errors/call_to_mut_fn_without_self.fe index 04f50a83a2..3b456486ec 100644 --- a/crates/test-files/fixtures/compile_errors/call_to_mut_fn_without_self.fe +++ b/crates/test-files/fixtures/compile_errors/call_to_mut_fn_without_self.fe @@ -1,6 +1,7 @@ -contract Foo: - fn bar(self): +contract Foo { + fn bar(self) { baz() + } - fn baz(self): - pass \ No newline at end of file + fn baz(self) {} +} diff --git a/crates/test-files/fixtures/compile_errors/call_to_pure_fn_on_self.fe b/crates/test-files/fixtures/compile_errors/call_to_pure_fn_on_self.fe index de2fa0f781..916acaae56 100644 --- a/crates/test-files/fixtures/compile_errors/call_to_pure_fn_on_self.fe +++ b/crates/test-files/fixtures/compile_errors/call_to_pure_fn_on_self.fe @@ -1,6 +1,7 @@ -contract Foo: - fn pure(): - pass +contract Foo { + fn pure() {} - fn bar(self): - self.pure() \ No newline at end of file + fn bar(self) { + self.pure() + } +} diff --git a/crates/test-files/fixtures/compile_errors/call_undefined_function_on_external_contract.fe b/crates/test-files/fixtures/compile_errors/call_undefined_function_on_external_contract.fe index 422a042cfe..cc108a5d7a 100644 --- a/crates/test-files/fixtures/compile_errors/call_undefined_function_on_external_contract.fe +++ b/crates/test-files/fixtures/compile_errors/call_undefined_function_on_external_contract.fe @@ -1,8 +1,11 @@ use std::context::Context -contract Foo: - val: u8 +contract Foo { + val: u8 +} -contract Bar: - pub fn test(ctx: Context): - Foo(ctx, address(0)).doesnt_exist() \ No newline at end of file +contract Bar { + pub fn test(ctx: Context) { + Foo(ctx, address(0)).doesnt_exist() + } +} diff --git a/crates/test-files/fixtures/compile_errors/call_undefined_function_on_memory_struct.fe b/crates/test-files/fixtures/compile_errors/call_undefined_function_on_memory_struct.fe index adbdd360ef..c4163afb43 100644 --- a/crates/test-files/fixtures/compile_errors/call_undefined_function_on_memory_struct.fe +++ b/crates/test-files/fixtures/compile_errors/call_undefined_function_on_memory_struct.fe @@ -1,7 +1,10 @@ -struct Something: - pub val: u8 +struct Something { + pub val: u8 +} -contract Bar: - pub fn test(): - let thingy: Something = Something(val: u8(1)) - thingy.doesnt_exist() \ No newline at end of file +contract Bar { + pub fn test() { + let thingy: Something = Something(val: u8(1)) + thingy.doesnt_exist() + } +} diff --git a/crates/test-files/fixtures/compile_errors/call_undefined_function_on_storage_struct.fe b/crates/test-files/fixtures/compile_errors/call_undefined_function_on_storage_struct.fe index 052af5ab3f..97aa91ca3c 100644 --- a/crates/test-files/fixtures/compile_errors/call_undefined_function_on_storage_struct.fe +++ b/crates/test-files/fixtures/compile_errors/call_undefined_function_on_storage_struct.fe @@ -1,8 +1,11 @@ -struct Something: - val: u8 +struct Something { + val: u8 +} -contract Bar: - thingy: Something +contract Bar { + thingy: Something - pub fn test(self): - self.thingy.doesnt_exist() \ No newline at end of file + pub fn test(self) { + self.thingy.doesnt_exist() + } +} diff --git a/crates/test-files/fixtures/compile_errors/call_with_pub_fns.fe b/crates/test-files/fixtures/compile_errors/call_with_pub_fns.fe index 3d00797fec..8a1c4cb201 100644 --- a/crates/test-files/fixtures/compile_errors/call_with_pub_fns.fe +++ b/crates/test-files/fixtures/compile_errors/call_with_pub_fns.fe @@ -1,12 +1,9 @@ -contract Foo: - pub fn __call__(): - pass +contract Foo { + pub fn __call__() {} - fn bar(): - pass + fn bar() {} - pub fn baz(): - pass + pub fn baz() {} - pub fn bing(): - pass + pub fn bing() {} +} diff --git a/crates/test-files/fixtures/compile_errors/call_wrong_return_type.fe b/crates/test-files/fixtures/compile_errors/call_wrong_return_type.fe index cbd52b6f11..687e1d02d0 100644 --- a/crates/test-files/fixtures/compile_errors/call_wrong_return_type.fe +++ b/crates/test-files/fixtures/compile_errors/call_wrong_return_type.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn __call__() -> u64: - return 10 \ No newline at end of file +contract Foo { + pub fn __call__() -> u64 { + return 10 + } +} diff --git a/crates/test-files/fixtures/compile_errors/cannot_move.fe b/crates/test-files/fixtures/compile_errors/cannot_move.fe index 441d924ce5..4ecc955b3d 100644 --- a/crates/test-files/fixtures/compile_errors/cannot_move.fe +++ b/crates/test-files/fixtures/compile_errors/cannot_move.fe @@ -1,5 +1,7 @@ -contract Foo: +contract Foo { data: Array - pub fn foo(self) -> Array: + pub fn foo(self) -> Array { return self.data + } +} diff --git a/crates/test-files/fixtures/compile_errors/cannot_move2.fe b/crates/test-files/fixtures/compile_errors/cannot_move2.fe index 0e7d483cf2..e13377770f 100644 --- a/crates/test-files/fixtures/compile_errors/cannot_move2.fe +++ b/crates/test-files/fixtures/compile_errors/cannot_move2.fe @@ -1,6 +1,7 @@ -contract Foo: - - pub fn foo(): - let x: Array - let y: Array - let c: Array = x + y +contract Foo { + pub fn foo() { + let x: Array + let y: Array + let c: Array = x + y + } +} diff --git a/crates/test-files/fixtures/compile_errors/circular_dependency_create.fe b/crates/test-files/fixtures/compile_errors/circular_dependency_create.fe index 9326c687f2..c3c9165d16 100644 --- a/crates/test-files/fixtures/compile_errors/circular_dependency_create.fe +++ b/crates/test-files/fixtures/compile_errors/circular_dependency_create.fe @@ -1,7 +1,8 @@ use std::context::Context -contract Foo: - pub fn bar(ctx: Context) -> address: +contract Foo { + pub fn bar(ctx: Context) -> address { let foo: Foo = Foo.create(ctx, 0) - - return address(foo) \ No newline at end of file + return address(foo) + } +} diff --git a/crates/test-files/fixtures/compile_errors/circular_dependency_create2.fe b/crates/test-files/fixtures/compile_errors/circular_dependency_create2.fe index d213206741..439d1878b4 100644 --- a/crates/test-files/fixtures/compile_errors/circular_dependency_create2.fe +++ b/crates/test-files/fixtures/compile_errors/circular_dependency_create2.fe @@ -1,7 +1,8 @@ use std::context::Context -contract Foo: - pub fn bar(ctx: Context) -> address: +contract Foo { + pub fn bar(ctx: Context) -> address { let foo: Foo = Foo.create2(ctx, 2, 0) - - return address(foo) \ No newline at end of file + return address(foo) + } +} diff --git a/crates/test-files/fixtures/compile_errors/circular_type_alias.fe b/crates/test-files/fixtures/compile_errors/circular_type_alias.fe index 7bb514dc76..20dbc3a23f 100644 --- a/crates/test-files/fixtures/compile_errors/circular_type_alias.fe +++ b/crates/test-files/fixtures/compile_errors/circular_type_alias.fe @@ -1,3 +1,5 @@ type A = Map + type B = Map + type C = Map diff --git a/crates/test-files/fixtures/compile_errors/const_assign.fe b/crates/test-files/fixtures/compile_errors/const_assign.fe index 72c975afaf..d2e88cd240 100644 --- a/crates/test-files/fixtures/compile_errors/const_assign.fe +++ b/crates/test-files/fixtures/compile_errors/const_assign.fe @@ -1,9 +1,12 @@ const MODULE: i32 = 10 -contract FOO: - fn assign_to_global_const(): +contract FOO { + fn assign_to_global_const() { MODULE = 1 - - fn assign_to_local_const(): + } + + fn assign_to_local_const() { const LOCAL: i32 = 10 - LOCAL = 1 \ No newline at end of file + LOCAL = 1 + } +} diff --git a/crates/test-files/fixtures/compile_errors/const_generics_param.fe b/crates/test-files/fixtures/compile_errors/const_generics_param.fe index 04b01aec93..7ae80cab97 100644 --- a/crates/test-files/fixtures/compile_errors/const_generics_param.fe +++ b/crates/test-files/fixtures/compile_errors/const_generics_param.fe @@ -1,18 +1,25 @@ -contract Foo: - fn not_a_constant(): +contract Foo { + fn not_a_constant() { let array: Array + } - fn not_a_numeric_const_generics(): + fn not_a_numeric_const_generics() { let array: Array - - fn zero_division_div(): + } + + fn zero_division_div() { let array: Array + } - fn zero_division_mod(): + fn zero_division_mod() { let array: Array - - fn shift_overflow(): + } + + fn shift_overflow() { let array: Array - - fn subtraction_overflow(): - let array: Array \ No newline at end of file + } + + fn subtraction_overflow() { + let array: Array + } +} diff --git a/crates/test-files/fixtures/compile_errors/const_local.fe b/crates/test-files/fixtures/compile_errors/const_local.fe index 992f6492bb..bf7567a6f2 100644 --- a/crates/test-files/fixtures/compile_errors/const_local.fe +++ b/crates/test-files/fixtures/compile_errors/const_local.fe @@ -1,18 +1,24 @@ -contract Foo: - fn not_a_constant(): +contract Foo { + fn not_a_constant() { const FOO: (i32, i32) = (1, 2) - - fn not_a_constant2(): + } + + fn not_a_constant2() { let foo: i32 = 1 - const FOO:i32 = foo + 1 - - fn overflow(): + const FOO: i32 = foo + 1 + } + + fn overflow() { const FOO1: u8 = 255 const FOO2: u8 = 1 const FOO3: u8 = FOO1 + FOO2 - - fn undefined(): + } + + fn undefined() { const FOO: u8 = BAR - - fn type_error(): - const FOO: i32 = "FOO" \ No newline at end of file + } + + fn type_error() { + const FOO: i32 = "FOO" + } +} diff --git a/crates/test-files/fixtures/compile_errors/ctx_builtins_param_incorrect_type.fe b/crates/test-files/fixtures/compile_errors/ctx_builtins_param_incorrect_type.fe index 68e74c4b42..9f3ef60453 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_builtins_param_incorrect_type.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_builtins_param_incorrect_type.fe @@ -1,14 +1,17 @@ use std::context::Context -event WorldMessage: +event WorldMessage { message: String<42> +} -contract Barn: - pub fn cow(): - pass +contract Barn { + pub fn cow() {} +} -contract Foo: - pub fn bar(ctx: Context): +contract Foo { + pub fn bar(ctx: Context) { let existing_barn: Barn = Barn("hello world", address(0)) let created_barn: Barn = Barn.create(address(26), 0) emit WorldMessage(42, message: "hello world") + } +} diff --git a/crates/test-files/fixtures/compile_errors/ctx_init.fe b/crates/test-files/fixtures/compile_errors/ctx_init.fe index 6d8f43f900..6cac5ce32e 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_init.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_init.fe @@ -1,5 +1,7 @@ use std::context::Context -contract Foo: - pub fn bar(): - let fake_ctx: Context = Context() \ No newline at end of file +contract Foo { + pub fn bar() { + let fake_ctx: Context = Context() + } +} diff --git a/crates/test-files/fixtures/compile_errors/ctx_missing_create.fe b/crates/test-files/fixtures/compile_errors/ctx_missing_create.fe index 737da5ba02..bc9471a328 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_missing_create.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_missing_create.fe @@ -1,9 +1,11 @@ use std::context::Context -contract Foo: - pub fn bar(): - pass +contract Foo { + pub fn bar() {} +} -contract Bar: - pub fn create_foo(ctx: Context): +contract Bar { + pub fn create_foo(ctx: Context) { Foo.create(0) + } +} diff --git a/crates/test-files/fixtures/compile_errors/ctx_missing_event.fe b/crates/test-files/fixtures/compile_errors/ctx_missing_event.fe index 5d4b92e48e..ed3621bd31 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_missing_event.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_missing_event.fe @@ -1,8 +1,11 @@ use std::context::Context -event HelloWorld: +event HelloWorld { message: String<26> +} -contract Bar: - pub fn say_hello(ctx: Context): +contract Bar { + pub fn say_hello(ctx: Context) { emit HelloWorld(message: "hello world") + } +} diff --git a/crates/test-files/fixtures/compile_errors/ctx_missing_internal_call.fe b/crates/test-files/fixtures/compile_errors/ctx_missing_internal_call.fe index 17fcaa8fe9..b209554942 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_missing_internal_call.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_missing_internal_call.fe @@ -1,10 +1,13 @@ use std::context::Context -contract Foo: +contract Foo { favorite_number: u256 - pub fn bar(ctx: Context) -> u256: + pub fn bar(ctx: Context) -> u256 { return ctx.block_number() + } - pub fn baz(self, ctx: Context): - self.favorite_number = bar() \ No newline at end of file + pub fn baz(self, ctx: Context) { + self.favorite_number = bar() + } +} diff --git a/crates/test-files/fixtures/compile_errors/ctx_missing_load.fe b/crates/test-files/fixtures/compile_errors/ctx_missing_load.fe index 56ce0bf838..78354ea44b 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_missing_load.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_missing_load.fe @@ -1,9 +1,11 @@ use std::context::Context -contract Foo: - pub fn bar(): - pass +contract Foo { + pub fn bar() {} +} -contract Bar: - pub fn create_foo(ctx: Context): +contract Bar { + pub fn create_foo(ctx: Context) { Foo(0) + } +} diff --git a/crates/test-files/fixtures/compile_errors/ctx_not_after_self.fe b/crates/test-files/fixtures/compile_errors/ctx_not_after_self.fe index bcd3eb8227..78a5c29f0b 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_not_after_self.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_not_after_self.fe @@ -1,5 +1,5 @@ use std::context::Context -contract Foo: - pub fn bar(self, baz: u256, ctx: Context): - pass \ No newline at end of file +contract Foo { + pub fn bar(self, baz: u256, ctx: Context) {} +} diff --git a/crates/test-files/fixtures/compile_errors/ctx_not_first.fe b/crates/test-files/fixtures/compile_errors/ctx_not_first.fe index ceef91dfda..7fc14087f0 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_not_first.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_not_first.fe @@ -1,5 +1,5 @@ use std::context::Context -contract Foo: - pub fn bar(baz: u256, ctx: Context): - pass \ No newline at end of file +contract Foo { + pub fn bar(baz: u256, ctx: Context) {} +} diff --git a/crates/test-files/fixtures/compile_errors/ctx_passed_external_call.fe b/crates/test-files/fixtures/compile_errors/ctx_passed_external_call.fe index 3f4db78ca8..22a1397cf8 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_passed_external_call.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_passed_external_call.fe @@ -1,13 +1,16 @@ use std::context::Context -contract Foo: - - pub fn bar(ctx: Context) -> u256: +contract Foo { + pub fn bar(ctx: Context) -> u256 { return ctx.block_number() + } +} -contract Bing: +contract Bing { favorite_number: u256 - pub fn baz(self, ctx: Context): + pub fn baz(self, ctx: Context) { let foo: Foo = Foo.create(ctx, 0) - self.favorite_number = foo.bar(ctx) \ No newline at end of file + self.favorite_number = foo.bar(ctx) + } +} diff --git a/crates/test-files/fixtures/compile_errors/ctx_pure.fe b/crates/test-files/fixtures/compile_errors/ctx_pure.fe index 1adf683fd2..47b098f3b5 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_pure.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_pure.fe @@ -1,4 +1,3 @@ use std::context::Context -pub fn foo(ctx: Context): - pass \ No newline at end of file +pub fn foo(ctx: Context) {} diff --git a/crates/test-files/fixtures/compile_errors/ctx_undeclared.fe b/crates/test-files/fixtures/compile_errors/ctx_undeclared.fe index cfabd9a812..b519e50862 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_undeclared.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_undeclared.fe @@ -1,5 +1,7 @@ use std::context::Context -contract Foo: - pub fn bar() -> u256: - return ctx.block_number() \ No newline at end of file +contract Foo { + pub fn bar() -> u256 { + return ctx.block_number() + } +} diff --git a/crates/test-files/fixtures/compile_errors/ctx_undefined_contract_init.fe b/crates/test-files/fixtures/compile_errors/ctx_undefined_contract_init.fe index 399fc360f0..916fb95cd6 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_undefined_contract_init.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_undefined_contract_init.fe @@ -1,6 +1,7 @@ -contract Bar: - pass +contract Bar {} -contract Foo: - pub fn baz(): - Bar(address(0)) \ No newline at end of file +contract Foo { + pub fn baz() { + Bar(address(0)) + } +} diff --git a/crates/test-files/fixtures/compile_errors/ctx_undefined_create.fe b/crates/test-files/fixtures/compile_errors/ctx_undefined_create.fe index bfceaf88bc..77a4bd4d1b 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_undefined_create.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_undefined_create.fe @@ -1,6 +1,7 @@ -contract Bar: - pass +contract Bar {} -contract Foo: - pub fn baz(): - Bar.create(0) \ No newline at end of file +contract Foo { + pub fn baz() { + Bar.create(0) + } +} diff --git a/crates/test-files/fixtures/compile_errors/ctx_undefined_create2.fe b/crates/test-files/fixtures/compile_errors/ctx_undefined_create2.fe index 1cbb2b34d8..ecb000893d 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_undefined_create2.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_undefined_create2.fe @@ -1,6 +1,7 @@ -contract Bar: - pass +contract Bar {} -contract Foo: - pub fn baz(): - Bar.create2(0, 0) \ No newline at end of file +contract Foo { + pub fn baz() { + Bar.create2(0, 0) + } +} diff --git a/crates/test-files/fixtures/compile_errors/ctx_undefined_event.fe b/crates/test-files/fixtures/compile_errors/ctx_undefined_event.fe index fe1e67ff26..bce08b154d 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_undefined_event.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_undefined_event.fe @@ -1,6 +1,9 @@ -event YouWin: +event YouWin { amount: u256 +} -contract Foo: - pub fn bar(): - emit YouWin(amount: 42) \ No newline at end of file +contract Foo { + pub fn bar() { + emit YouWin(amount: 42) + } +} diff --git a/crates/test-files/fixtures/compile_errors/duplicate_arg_in_contract_method.fe b/crates/test-files/fixtures/compile_errors/duplicate_arg_in_contract_method.fe index 13f12a47ce..d98855b49a 100644 --- a/crates/test-files/fixtures/compile_errors/duplicate_arg_in_contract_method.fe +++ b/crates/test-files/fixtures/compile_errors/duplicate_arg_in_contract_method.fe @@ -1,3 +1,3 @@ -contract Foo: - pub fn bar(foo: u8, foo:u8): - pass +contract Foo { + pub fn bar(foo: u8, foo: u8) {} +} diff --git a/crates/test-files/fixtures/compile_errors/duplicate_contract_in_module.fe b/crates/test-files/fixtures/compile_errors/duplicate_contract_in_module.fe index 2cf82749dc..b5a8975ddb 100644 --- a/crates/test-files/fixtures/compile_errors/duplicate_contract_in_module.fe +++ b/crates/test-files/fixtures/compile_errors/duplicate_contract_in_module.fe @@ -1,9 +1,7 @@ -contract Foo: +contract Foo { + pub fn bar() {} +} - pub fn bar(): - pass - -contract Foo: - - pub fn bar(): - pass +contract Foo { + pub fn bar() {} +} diff --git a/crates/test-files/fixtures/compile_errors/duplicate_event_in_contract.fe b/crates/test-files/fixtures/compile_errors/duplicate_event_in_contract.fe index 1618ee1bfe..49f545190c 100644 --- a/crates/test-files/fixtures/compile_errors/duplicate_event_in_contract.fe +++ b/crates/test-files/fixtures/compile_errors/duplicate_event_in_contract.fe @@ -1,6 +1,9 @@ -contract Foo: - event MyEvent: +contract Foo { + event MyEvent { idx addr1: address + } - event MyEvent: + event MyEvent { idx addr1: address + } +} diff --git a/crates/test-files/fixtures/compile_errors/duplicate_field_in_contract.fe b/crates/test-files/fixtures/compile_errors/duplicate_field_in_contract.fe index 5da1eb18a2..a7e122c9ac 100644 --- a/crates/test-files/fixtures/compile_errors/duplicate_field_in_contract.fe +++ b/crates/test-files/fixtures/compile_errors/duplicate_field_in_contract.fe @@ -1,3 +1,4 @@ -contract Foo: +contract Foo { bar: u8 bar: u8 +} diff --git a/crates/test-files/fixtures/compile_errors/duplicate_field_in_struct.fe b/crates/test-files/fixtures/compile_errors/duplicate_field_in_struct.fe index dd724b3989..382e08f530 100644 --- a/crates/test-files/fixtures/compile_errors/duplicate_field_in_struct.fe +++ b/crates/test-files/fixtures/compile_errors/duplicate_field_in_struct.fe @@ -1,6 +1,8 @@ -struct MyStruct: +struct MyStruct { foo: u8 foo: u8 +} -contract Foo: +contract Foo { bar: u8 +} diff --git a/crates/test-files/fixtures/compile_errors/duplicate_method_in_contract.fe b/crates/test-files/fixtures/compile_errors/duplicate_method_in_contract.fe index 48887c6231..5d14b377f8 100644 --- a/crates/test-files/fixtures/compile_errors/duplicate_method_in_contract.fe +++ b/crates/test-files/fixtures/compile_errors/duplicate_method_in_contract.fe @@ -1,7 +1,5 @@ -contract Foo: +contract Foo { + pub fn bar() {} - pub fn bar(): - pass - - pub fn bar(): - pass + pub fn bar() {} +} diff --git a/crates/test-files/fixtures/compile_errors/duplicate_struct_in_module.fe b/crates/test-files/fixtures/compile_errors/duplicate_struct_in_module.fe index e0d9eb8ca7..e31b291546 100644 --- a/crates/test-files/fixtures/compile_errors/duplicate_struct_in_module.fe +++ b/crates/test-files/fixtures/compile_errors/duplicate_struct_in_module.fe @@ -1,10 +1,11 @@ -struct MyStruct: +struct MyStruct { foo: u8 +} -struct MyStruct: +struct MyStruct { foo: u8 +} -contract Foo: - - pub fn bar(): - pass +contract Foo { + pub fn bar() {} +} diff --git a/crates/test-files/fixtures/compile_errors/duplicate_typedef_in_module.fe b/crates/test-files/fixtures/compile_errors/duplicate_typedef_in_module.fe index 7183f41382..4c1bb7a9c6 100644 --- a/crates/test-files/fixtures/compile_errors/duplicate_typedef_in_module.fe +++ b/crates/test-files/fixtures/compile_errors/duplicate_typedef_in_module.fe @@ -1,9 +1,7 @@ - type bar = u8 type bar = u8 -contract Foo: - - pub fn bar(): - pass +contract Foo { + pub fn bar() {} +} diff --git a/crates/test-files/fixtures/compile_errors/duplicate_var_in_child_scope.fe b/crates/test-files/fixtures/compile_errors/duplicate_var_in_child_scope.fe index bebcd50c24..58856c3e55 100644 --- a/crates/test-files/fixtures/compile_errors/duplicate_var_in_child_scope.fe +++ b/crates/test-files/fixtures/compile_errors/duplicate_var_in_child_scope.fe @@ -1,7 +1,10 @@ -contract Foo: - pub fn bar(): +contract Foo { + pub fn bar() { let my_array: Array let sum: u256 = 0 - for i in my_array: + for i in my_array { let sum: u64 = 0 sum += i + } + } +} diff --git a/crates/test-files/fixtures/compile_errors/duplicate_var_in_contract_method.fe b/crates/test-files/fixtures/compile_errors/duplicate_var_in_contract_method.fe index 2686816290..e459b777ab 100644 --- a/crates/test-files/fixtures/compile_errors/duplicate_var_in_contract_method.fe +++ b/crates/test-files/fixtures/compile_errors/duplicate_var_in_contract_method.fe @@ -1,4 +1,6 @@ -contract Foo: - pub fn bar(): +contract Foo { + pub fn bar() { let foo: u8 let foo: u8 + } +} diff --git a/crates/test-files/fixtures/compile_errors/duplicate_var_in_for_loop.fe b/crates/test-files/fixtures/compile_errors/duplicate_var_in_for_loop.fe index 3d7495ed53..773f2b8c09 100644 --- a/crates/test-files/fixtures/compile_errors/duplicate_var_in_for_loop.fe +++ b/crates/test-files/fixtures/compile_errors/duplicate_var_in_for_loop.fe @@ -1,8 +1,10 @@ -contract C: - fn f(): - let x: u256 = 10 - - let xs: Array = [1, 2, 3, 4] - let sum: u8 = 0 - for x in xs: - sum += x +contract C { + fn f() { + let x: u256 = 10 + let xs: Array = [1, 2, 3, 4] + let sum: u8 = 0 + for x in xs { + sum += x + } + } +} diff --git a/crates/test-files/fixtures/compile_errors/emit_bad_args.fe b/crates/test-files/fixtures/compile_errors/emit_bad_args.fe index 20a57fe12e..889469b1b5 100644 --- a/crates/test-files/fixtures/compile_errors/emit_bad_args.fe +++ b/crates/test-files/fixtures/compile_errors/emit_bad_args.fe @@ -1,10 +1,13 @@ use std::context::Context -contract Bar: - event Foo: - idx x: address - y: u256 - z: bool +contract Bar { + event Foo { + idx x: address + y: u256 + z: bool + } - pub fn test(ctx: Context): - emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) \ No newline at end of file + pub fn test(ctx: Context) { + emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) + } +} diff --git a/crates/test-files/fixtures/compile_errors/external_call_type_error.fe b/crates/test-files/fixtures/compile_errors/external_call_type_error.fe index 4c71c4a6be..33398e30b6 100644 --- a/crates/test-files/fixtures/compile_errors/external_call_type_error.fe +++ b/crates/test-files/fixtures/compile_errors/external_call_type_error.fe @@ -1,9 +1,11 @@ use std::context::Context -contract Foo: - pub fn bar(_ a: u256): - pass +contract Foo { + pub fn bar(_ a: u256) {} +} -contract FooProxy: - pub fn baz(ctx: Context): - Foo(ctx, address(0)).bar("hello world") \ No newline at end of file +contract FooProxy { + pub fn baz(ctx: Context) { + Foo(ctx, address(0)).bar("hello world") + } +} diff --git a/crates/test-files/fixtures/compile_errors/external_call_wrong_number_of_params.fe b/crates/test-files/fixtures/compile_errors/external_call_wrong_number_of_params.fe index a7958c29d9..29dd9b068f 100644 --- a/crates/test-files/fixtures/compile_errors/external_call_wrong_number_of_params.fe +++ b/crates/test-files/fixtures/compile_errors/external_call_wrong_number_of_params.fe @@ -1,9 +1,11 @@ use std::context::Context -contract Foo: - pub fn bar(a: u256, b: u256): - pass +contract Foo { + pub fn bar(a: u256, b: u256) {} +} -contract FooProxy: - pub fn baz(ctx: Context): +contract FooProxy { + pub fn baz(ctx: Context) { Foo(ctx, address(0)).bar(42) + } +} diff --git a/crates/test-files/fixtures/compile_errors/for_loop_sto_iter_no_copy.fe b/crates/test-files/fixtures/compile_errors/for_loop_sto_iter_no_copy.fe index 71187942ff..67b64bd8a5 100644 --- a/crates/test-files/fixtures/compile_errors/for_loop_sto_iter_no_copy.fe +++ b/crates/test-files/fixtures/compile_errors/for_loop_sto_iter_no_copy.fe @@ -1,6 +1,9 @@ -contract Foo: +contract Foo { my_array: Array - pub fn bar(self): - for i in self.my_array: - pass \ No newline at end of file + pub fn bar(self) { + for i in self.my_array { + + } + } +} diff --git a/crates/test-files/fixtures/compile_errors/indexed_event.fe b/crates/test-files/fixtures/compile_errors/indexed_event.fe index 88d5213829..9083c4df30 100644 --- a/crates/test-files/fixtures/compile_errors/indexed_event.fe +++ b/crates/test-files/fixtures/compile_errors/indexed_event.fe @@ -1,6 +1,8 @@ -contract Foo: - event MyEvent: +contract Foo { + event MyEvent { idx addr1: address idx addr2: address idx addr3: address idx addr4: address + } +} diff --git a/crates/test-files/fixtures/compile_errors/init_call_on_external_contract.fe b/crates/test-files/fixtures/compile_errors/init_call_on_external_contract.fe index 9c71f10a32..75fa1f96c0 100644 --- a/crates/test-files/fixtures/compile_errors/init_call_on_external_contract.fe +++ b/crates/test-files/fixtures/compile_errors/init_call_on_external_contract.fe @@ -1,14 +1,15 @@ use std::context::Context -contract Foo: - pub fn __init__(): - pass - pub fn f(): - pass +contract Foo { + pub fn __init__() {} + pub fn f() {} +} -contract Bar: - fn b(ctx: Context): - let foo: Foo = Foo(ctx, address(0)) - foo.f() - foo.__init__() +contract Bar { + fn b(ctx: Context) { + let foo: Foo = Foo(ctx, address(0)) + foo.f() + foo.__init__() + } +} diff --git a/crates/test-files/fixtures/compile_errors/init_call_on_self.fe b/crates/test-files/fixtures/compile_errors/init_call_on_self.fe index 9056109b28..9b158e466e 100644 --- a/crates/test-files/fixtures/compile_errors/init_call_on_self.fe +++ b/crates/test-files/fixtures/compile_errors/init_call_on_self.fe @@ -1,6 +1,7 @@ -contract Foo: - pub fn __init__(): - pass +contract Foo { + pub fn __init__() {} - fn bar(self): - self.__init__() \ No newline at end of file + fn bar(self) { + self.__init__() + } +} diff --git a/crates/test-files/fixtures/compile_errors/init_duplicate_def.fe b/crates/test-files/fixtures/compile_errors/init_duplicate_def.fe index f50a160553..d104e06f0f 100644 --- a/crates/test-files/fixtures/compile_errors/init_duplicate_def.fe +++ b/crates/test-files/fixtures/compile_errors/init_duplicate_def.fe @@ -1,12 +1,13 @@ -contract Foo: - pub fn __init__(): - pass +contract Foo { + pub fn __init__() {} - pub fn bar(): - pass + pub fn bar() {} - pub fn __init__(): + pub fn __init__() { 1 + 2 + } - pub fn __init__(): + pub fn __init__() { 3 + 4 + } +} diff --git a/crates/test-files/fixtures/compile_errors/init_wrong_return_type.fe b/crates/test-files/fixtures/compile_errors/init_wrong_return_type.fe index 56e02ab555..628942d79b 100644 --- a/crates/test-files/fixtures/compile_errors/init_wrong_return_type.fe +++ b/crates/test-files/fixtures/compile_errors/init_wrong_return_type.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn __init__() -> u64: - return 10 \ No newline at end of file +contract Foo { + pub fn __init__() -> u64 { + return 10 + } +} diff --git a/crates/test-files/fixtures/compile_errors/invalid_block_field.fe b/crates/test-files/fixtures/compile_errors/invalid_block_field.fe index 0b8164de50..a6b6651ad8 100644 --- a/crates/test-files/fixtures/compile_errors/invalid_block_field.fe +++ b/crates/test-files/fixtures/compile_errors/invalid_block_field.fe @@ -1,4 +1,5 @@ -contract Foo: - - pub fn foo(): - block.foo \ No newline at end of file +contract Foo { + pub fn foo() { + block.foo + } +} diff --git a/crates/test-files/fixtures/compile_errors/invalid_chain_field.fe b/crates/test-files/fixtures/compile_errors/invalid_chain_field.fe index 3065544f2a..8d5aa5b637 100644 --- a/crates/test-files/fixtures/compile_errors/invalid_chain_field.fe +++ b/crates/test-files/fixtures/compile_errors/invalid_chain_field.fe @@ -1,4 +1,5 @@ -contract Foo: - - pub fn foo(): - chain.foo \ No newline at end of file +contract Foo { + pub fn foo() { + chain.foo + } +} diff --git a/crates/test-files/fixtures/compile_errors/invalid_compiler_version.fe b/crates/test-files/fixtures/compile_errors/invalid_compiler_version.fe index 4c20078790..e20da6eb98 100644 --- a/crates/test-files/fixtures/compile_errors/invalid_compiler_version.fe +++ b/crates/test-files/fixtures/compile_errors/invalid_compiler_version.fe @@ -1,4 +1,3 @@ pragma <=0.1.0 -contract foo: - pass \ No newline at end of file +contract foo {} diff --git a/crates/test-files/fixtures/compile_errors/invalid_contract_field.fe b/crates/test-files/fixtures/compile_errors/invalid_contract_field.fe index 59296728f8..a4159641bd 100644 --- a/crates/test-files/fixtures/compile_errors/invalid_contract_field.fe +++ b/crates/test-files/fixtures/compile_errors/invalid_contract_field.fe @@ -1,5 +1,7 @@ -contract Foo: - val: u256 +contract Foo { + val: u256 - pub fn foo(self): - self.bar \ No newline at end of file + pub fn foo(self) { + self.bar + } +} diff --git a/crates/test-files/fixtures/compile_errors/invalid_msg_field.fe b/crates/test-files/fixtures/compile_errors/invalid_msg_field.fe index ba371ccb4d..bc0fcaa49d 100644 --- a/crates/test-files/fixtures/compile_errors/invalid_msg_field.fe +++ b/crates/test-files/fixtures/compile_errors/invalid_msg_field.fe @@ -1,4 +1,5 @@ -contract Foo: - - pub fn foo(): - msg.foo \ No newline at end of file +contract Foo { + pub fn foo() { + msg.foo + } +} diff --git a/crates/test-files/fixtures/compile_errors/invalid_string_field.fe b/crates/test-files/fixtures/compile_errors/invalid_string_field.fe index e8f1ae29dd..8c30dbaabd 100644 --- a/crates/test-files/fixtures/compile_errors/invalid_string_field.fe +++ b/crates/test-files/fixtures/compile_errors/invalid_string_field.fe @@ -1,4 +1,5 @@ -contract Foo: - - pub fn foo(): - "".does_not_exist \ No newline at end of file +contract Foo { + pub fn foo() { + "".does_not_exist + } +} diff --git a/crates/test-files/fixtures/compile_errors/invalid_struct_field.fe b/crates/test-files/fixtures/compile_errors/invalid_struct_field.fe index 3abec6909d..015be9507b 100644 --- a/crates/test-files/fixtures/compile_errors/invalid_struct_field.fe +++ b/crates/test-files/fixtures/compile_errors/invalid_struct_field.fe @@ -1,8 +1,11 @@ -struct Bar: - id: u256 +struct Bar { + id: u256 +} -contract Foo: - val: Bar +contract Foo { + val: Bar - pub fn foo(self): - self.val.foo \ No newline at end of file + pub fn foo(self) { + self.val.foo + } +} diff --git a/crates/test-files/fixtures/compile_errors/invalid_tuple_field.fe b/crates/test-files/fixtures/compile_errors/invalid_tuple_field.fe index 3cd30bb411..69382b0e1a 100644 --- a/crates/test-files/fixtures/compile_errors/invalid_tuple_field.fe +++ b/crates/test-files/fixtures/compile_errors/invalid_tuple_field.fe @@ -1,5 +1,7 @@ -contract Foo: - val: (u256, u8) +contract Foo { + val: (u256, u8) - pub fn foo(self): - self.val.item5 \ No newline at end of file + pub fn foo(self) { + self.val.item5 + } +} diff --git a/crates/test-files/fixtures/compile_errors/invalid_tx_field.fe b/crates/test-files/fixtures/compile_errors/invalid_tx_field.fe index f4fa525536..40d4b5f357 100644 --- a/crates/test-files/fixtures/compile_errors/invalid_tx_field.fe +++ b/crates/test-files/fixtures/compile_errors/invalid_tx_field.fe @@ -1,4 +1,5 @@ -contract Foo: - - pub fn foo(): - tx.foo \ No newline at end of file +contract Foo { + pub fn foo() { + tx.foo + } +} diff --git a/crates/test-files/fixtures/compile_errors/invalid_var_declaration_1.fe b/crates/test-files/fixtures/compile_errors/invalid_var_declaration_1.fe index 19ca17a281..7b3246425e 100644 --- a/crates/test-files/fixtures/compile_errors/invalid_var_declaration_1.fe +++ b/crates/test-files/fixtures/compile_errors/invalid_var_declaration_1.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(): - let (x,): Array = [1,2,3,4,5,6,7,8,9,0,2,1,3,4,5,6,7,8,9,0] \ No newline at end of file +contract Foo { + pub fn bar() { + let (x,): Array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 2, 1, 3, 4, 5, 6, 7, 8, 9, 0] + } +} diff --git a/crates/test-files/fixtures/compile_errors/invalid_var_declaration_2.fe b/crates/test-files/fixtures/compile_errors/invalid_var_declaration_2.fe index bc4058cb80..e4f57b1659 100644 --- a/crates/test-files/fixtures/compile_errors/invalid_var_declaration_2.fe +++ b/crates/test-files/fixtures/compile_errors/invalid_var_declaration_2.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(): - let (x, y):(u256,)=(1,) +contract Foo { + pub fn bar() { + let (x, y): (u256,) = (1,) + } +} diff --git a/crates/test-files/fixtures/compile_errors/issue_451.fe b/crates/test-files/fixtures/compile_errors/issue_451.fe index 318812a94f..ef6ecb104b 100644 --- a/crates/test-files/fixtures/compile_errors/issue_451.fe +++ b/crates/test-files/fixtures/compile_errors/issue_451.fe @@ -1,5 +1,9 @@ -contract o: - pub fn bar(x:u256,y:u256)->bool: - return - pub fn bar(): - s \ No newline at end of file +contract o { + pub fn bar(x: u256, y: u256) -> bool { + return + } + + pub fn bar() { + s + } +} diff --git a/crates/test-files/fixtures/compile_errors/mislabeled_call_args.fe b/crates/test-files/fixtures/compile_errors/mislabeled_call_args.fe index 130d8e69c5..1454e40a35 100644 --- a/crates/test-files/fixtures/compile_errors/mislabeled_call_args.fe +++ b/crates/test-files/fixtures/compile_errors/mislabeled_call_args.fe @@ -1,7 +1,7 @@ -contract Foo: - - pub fn baz(): +contract Foo { + pub fn baz() { bar(doesnt_exist: 1, me_neither: 2) - - pub fn bar(val1: u256, val2: u256): - pass \ No newline at end of file + } + + pub fn bar(val1: u256, val2: u256) {} +} diff --git a/crates/test-files/fixtures/compile_errors/mislabeled_call_args_external_contract_call.fe b/crates/test-files/fixtures/compile_errors/mislabeled_call_args_external_contract_call.fe index 5609b68d5f..13e568e7e7 100644 --- a/crates/test-files/fixtures/compile_errors/mislabeled_call_args_external_contract_call.fe +++ b/crates/test-files/fixtures/compile_errors/mislabeled_call_args_external_contract_call.fe @@ -1,11 +1,13 @@ use std::context::Context -contract Foo: - val: u8 +contract Foo { + val: u8 - pub fn baz(val1: u256, val2: u256): - pass + pub fn baz(val1: u256, val2: u256) {} +} -contract Bar: - pub fn test(ctx: Context): - Foo(ctx, address(0)).baz(doesnt_exist: 1, me_neither: 4) \ No newline at end of file +contract Bar { + pub fn test(ctx: Context) { + Foo(ctx, address(0)).baz(doesnt_exist: 1, me_neither: 4) + } +} diff --git a/crates/test-files/fixtures/compile_errors/mislabeled_call_args_self.fe b/crates/test-files/fixtures/compile_errors/mislabeled_call_args_self.fe index d974f83152..586fbda943 100644 --- a/crates/test-files/fixtures/compile_errors/mislabeled_call_args_self.fe +++ b/crates/test-files/fixtures/compile_errors/mislabeled_call_args_self.fe @@ -1,7 +1,7 @@ -contract Foo: - - pub fn baz(self): +contract Foo { + pub fn baz(self) { self.bar(doesnt_exist: 1, me_neither: 2) + } - pub fn bar(self, val1: u256, val2: u256): - pass \ No newline at end of file + pub fn bar(self, val1: u256, val2: u256) {} +} diff --git a/crates/test-files/fixtures/compile_errors/mismatch_return_type.fe b/crates/test-files/fixtures/compile_errors/mismatch_return_type.fe index f3070a52dd..9850dd9b5f 100644 --- a/crates/test-files/fixtures/compile_errors/mismatch_return_type.fe +++ b/crates/test-files/fixtures/compile_errors/mismatch_return_type.fe @@ -1,4 +1,5 @@ -contract Foo: - - pub fn bar() -> address: +contract Foo { + pub fn bar() -> address { return 1 + } +} diff --git a/crates/test-files/fixtures/compile_errors/missing_return.fe b/crates/test-files/fixtures/compile_errors/missing_return.fe index ae596ecc9f..6d802629f3 100644 --- a/crates/test-files/fixtures/compile_errors/missing_return.fe +++ b/crates/test-files/fixtures/compile_errors/missing_return.fe @@ -1,5 +1,7 @@ -contract Foo: +contract Foo { baz: Map - pub fn bar(self) -> u256: + pub fn bar(self) -> u256 { self.baz[0] = 1 + } +} diff --git a/crates/test-files/fixtures/compile_errors/missing_return_after_if.fe b/crates/test-files/fixtures/compile_errors/missing_return_after_if.fe index d632e4bf87..e282a9a652 100644 --- a/crates/test-files/fixtures/compile_errors/missing_return_after_if.fe +++ b/crates/test-files/fixtures/compile_errors/missing_return_after_if.fe @@ -1,4 +1,7 @@ -contract Foo: - pub fn bar(val: u256) -> u256: - if val > 1: +contract Foo { + pub fn bar(val: u256) -> u256 { + if val > 1 { return 5 + } + } +} diff --git a/crates/test-files/fixtures/compile_errors/missing_return_in_else.fe b/crates/test-files/fixtures/compile_errors/missing_return_in_else.fe index fc3f011ed6..d3ff9b6f58 100644 --- a/crates/test-files/fixtures/compile_errors/missing_return_in_else.fe +++ b/crates/test-files/fixtures/compile_errors/missing_return_in_else.fe @@ -1,6 +1,9 @@ -contract Foo: - pub fn bar(val: u256) -> u256: - if val > 1: +contract Foo { + pub fn bar(val: u256) -> u256 { + if val > 1 { return 5 - else: - let x:u256 = 1 + } else { + let x: u256 = 1 + } + } +} diff --git a/crates/test-files/fixtures/compile_errors/missing_self.fe b/crates/test-files/fixtures/compile_errors/missing_self.fe index a68870e2f9..c0be638b19 100644 --- a/crates/test-files/fixtures/compile_errors/missing_self.fe +++ b/crates/test-files/fixtures/compile_errors/missing_self.fe @@ -1,12 +1,15 @@ -contract Foo: - fn pure_fn(): +contract Foo { + fn pure_fn() { self.mut_fn() + } - fn mut_fn(self): - pass + fn mut_fn(self) {} +} -struct Bar: +struct Bar { x: u8 - fn f() -> u8: - return self.x \ No newline at end of file + fn f() -> u8 { + return self.x + } +} diff --git a/crates/test-files/fixtures/compile_errors/module_const_call.fe b/crates/test-files/fixtures/compile_errors/module_const_call.fe index 01ba54f90e..1ca7215ebe 100644 --- a/crates/test-files/fixtures/compile_errors/module_const_call.fe +++ b/crates/test-files/fixtures/compile_errors/module_const_call.fe @@ -1,5 +1,7 @@ const FOO: u8 = 1 -contract C: - fn f(): - FOO() +contract C { + fn f() { + FOO() + } +} diff --git a/crates/test-files/fixtures/compile_errors/needs_mem_copy.fe b/crates/test-files/fixtures/compile_errors/needs_mem_copy.fe index cad0c8d514..264f390b25 100644 --- a/crates/test-files/fixtures/compile_errors/needs_mem_copy.fe +++ b/crates/test-files/fixtures/compile_errors/needs_mem_copy.fe @@ -1,8 +1,11 @@ -contract Foo: +contract Foo { my_sto_array: Array - pub fn bar(self, my_array: Array): + pub fn bar(self, my_array: Array) { my_array = self.my_sto_array + } - pub fn foo(self) -> Array: + pub fn foo(self) -> Array { return self.my_sto_array + } +} diff --git a/crates/test-files/fixtures/compile_errors/non_pub_init.fe b/crates/test-files/fixtures/compile_errors/non_pub_init.fe index 88292ea504..768a7dd1d8 100644 --- a/crates/test-files/fixtures/compile_errors/non_pub_init.fe +++ b/crates/test-files/fixtures/compile_errors/non_pub_init.fe @@ -1,3 +1,3 @@ -contract Foo: - fn __init__(): - pass \ No newline at end of file +contract Foo { + fn __init__() {} +} diff --git a/crates/test-files/fixtures/compile_errors/not_callable.fe b/crates/test-files/fixtures/compile_errors/not_callable.fe index 8070130049..48c2cb1638 100644 --- a/crates/test-files/fixtures/compile_errors/not_callable.fe +++ b/crates/test-files/fixtures/compile_errors/not_callable.fe @@ -1,13 +1,17 @@ +contract Foo { + event MyEvent { + x: u8 + } -contract Foo: - event MyEvent: - x: u8 + fn call_int() { + 5() + } - fn call_int(): - 5() + fn call_event() { + MyEvent(x: 10) + } - fn call_event(): - MyEvent(x: 10) - - fn call_self(self): - self() + fn call_self(self) { + self() + } +} diff --git a/crates/test-files/fixtures/compile_errors/not_in_scope.fe b/crates/test-files/fixtures/compile_errors/not_in_scope.fe index 3320939063..3cfbe58a07 100644 --- a/crates/test-files/fixtures/compile_errors/not_in_scope.fe +++ b/crates/test-files/fixtures/compile_errors/not_in_scope.fe @@ -1,8 +1,10 @@ -contract Foo: - - pub fn bar() -> u256: - if true: +contract Foo { + pub fn bar() -> u256 { + if true { let y: u256 = 1 - else: + } else { let y: u256 = 1 - return y \ No newline at end of file + } + return y + } +} diff --git a/crates/test-files/fixtures/compile_errors/not_in_scope_2.fe b/crates/test-files/fixtures/compile_errors/not_in_scope_2.fe index 35925f0df5..db4d77afa4 100644 --- a/crates/test-files/fixtures/compile_errors/not_in_scope_2.fe +++ b/crates/test-files/fixtures/compile_errors/not_in_scope_2.fe @@ -1,8 +1,10 @@ -contract Foo: - - pub fn bar() -> u256: +contract Foo { + pub fn bar() -> u256 { let i: u256 = 0 - while i < 1: + while i < 1 { i = 1 let y: u256 = 1 - return y \ No newline at end of file + } + return y + } +} diff --git a/crates/test-files/fixtures/compile_errors/private_struct_field.fe b/crates/test-files/fixtures/compile_errors/private_struct_field.fe index b32198e308..fb21bee9d4 100644 --- a/crates/test-files/fixtures/compile_errors/private_struct_field.fe +++ b/crates/test-files/fixtures/compile_errors/private_struct_field.fe @@ -1,8 +1,11 @@ -struct Bar: - id: u256 +struct Bar { + id: u256 +} -contract Foo: - val: Bar +contract Foo { + val: Bar - pub fn foo(self): - self.val.id \ No newline at end of file + pub fn foo(self) { + self.val.id + } +} diff --git a/crates/test-files/fixtures/compile_errors/return_addition_with_mixed_types.fe b/crates/test-files/fixtures/compile_errors/return_addition_with_mixed_types.fe index 9a015c7e50..71e8b6efa3 100644 --- a/crates/test-files/fixtures/compile_errors/return_addition_with_mixed_types.fe +++ b/crates/test-files/fixtures/compile_errors/return_addition_with_mixed_types.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u128) -> u128: +contract Foo { + pub fn bar(x: u256, y: u128) -> u128 { return x + y + } +} diff --git a/crates/test-files/fixtures/compile_errors/return_call_to_fn_with_param_type_mismatch.fe b/crates/test-files/fixtures/compile_errors/return_call_to_fn_with_param_type_mismatch.fe index e1899ce412..34132a222c 100644 --- a/crates/test-files/fixtures/compile_errors/return_call_to_fn_with_param_type_mismatch.fe +++ b/crates/test-files/fixtures/compile_errors/return_call_to_fn_with_param_type_mismatch.fe @@ -1,7 +1,9 @@ -contract Foo: - - pub fn foo(_ val: address) -> u256: +contract Foo { + pub fn foo(_ val: address) -> u256 { return 42 + } - pub fn bar() -> u256: + pub fn bar() -> u256 { return foo(100) + } +} diff --git a/crates/test-files/fixtures/compile_errors/return_call_to_fn_without_return.fe b/crates/test-files/fixtures/compile_errors/return_call_to_fn_without_return.fe index d8ba4d2c04..940b667804 100644 --- a/crates/test-files/fixtures/compile_errors/return_call_to_fn_without_return.fe +++ b/crates/test-files/fixtures/compile_errors/return_call_to_fn_without_return.fe @@ -1,7 +1,9 @@ -contract Foo: - - pub fn foo(): +contract Foo { + pub fn foo() { revert + } - pub fn bar() -> u256: + pub fn bar() -> u256 { return foo() + } +} diff --git a/crates/test-files/fixtures/compile_errors/return_complex_struct.fe b/crates/test-files/fixtures/compile_errors/return_complex_struct.fe index 2d36e01e06..cb2d0d6887 100644 --- a/crates/test-files/fixtures/compile_errors/return_complex_struct.fe +++ b/crates/test-files/fixtures/compile_errors/return_complex_struct.fe @@ -1,6 +1,9 @@ -struct Foo: - pub bar: Array +struct Foo { + pub bar: Array +} -contract C: - pub fn f() -> Foo: - return Foo(bar: [1, 2]) +contract C { + pub fn f() -> Foo { + return Foo(bar: [1, 2]) + } +} diff --git a/crates/test-files/fixtures/compile_errors/return_from_init.fe b/crates/test-files/fixtures/compile_errors/return_from_init.fe index 74deb758fc..2293fbf6a1 100644 --- a/crates/test-files/fixtures/compile_errors/return_from_init.fe +++ b/crates/test-files/fixtures/compile_errors/return_from_init.fe @@ -1,3 +1,5 @@ -contract C: - pub fn __init__() -> i32: +contract C { + pub fn __init__() -> i32 { return 0 + } +} diff --git a/crates/test-files/fixtures/compile_errors/return_lt_mixed_types.fe b/crates/test-files/fixtures/compile_errors/return_lt_mixed_types.fe index 35116296af..954003b23b 100644 --- a/crates/test-files/fixtures/compile_errors/return_lt_mixed_types.fe +++ b/crates/test-files/fixtures/compile_errors/return_lt_mixed_types.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u128, y: u256) -> bool: +contract Foo { + pub fn bar(x: u128, y: u256) -> bool { return x < y + } +} diff --git a/crates/test-files/fixtures/compile_errors/return_type_not_fixedsize.fe b/crates/test-files/fixtures/compile_errors/return_type_not_fixedsize.fe index 2bbd05ec7e..aa1ba7f7ae 100644 --- a/crates/test-files/fixtures/compile_errors/return_type_not_fixedsize.fe +++ b/crates/test-files/fixtures/compile_errors/return_type_not_fixedsize.fe @@ -1,3 +1,3 @@ -contract C: - pub fn f() -> Map: - pass +contract C { + pub fn f() -> Map {} +} diff --git a/crates/test-files/fixtures/compile_errors/return_type_undefined.fe b/crates/test-files/fixtures/compile_errors/return_type_undefined.fe index 5a45e87658..d0ceb7fdee 100644 --- a/crates/test-files/fixtures/compile_errors/return_type_undefined.fe +++ b/crates/test-files/fixtures/compile_errors/return_type_undefined.fe @@ -1,3 +1,3 @@ -contract C: - pub fn f() -> Foo: - pass +contract C { + pub fn f() -> Foo {} +} diff --git a/crates/test-files/fixtures/compile_errors/revert_sto_error_no_copy.fe b/crates/test-files/fixtures/compile_errors/revert_sto_error_no_copy.fe index ab0416bb76..76bd0ba657 100644 --- a/crates/test-files/fixtures/compile_errors/revert_sto_error_no_copy.fe +++ b/crates/test-files/fixtures/compile_errors/revert_sto_error_no_copy.fe @@ -1,8 +1,9 @@ -struct MyError: - pass +struct MyError {} -contract Foo: +contract Foo { my_error: MyError - pub fn bar(self): - revert self.my_error \ No newline at end of file + pub fn bar(self) { + revert self.my_error + } +} diff --git a/crates/test-files/fixtures/compile_errors/self_in_standalone_fn.fe b/crates/test-files/fixtures/compile_errors/self_in_standalone_fn.fe index e3e66dce6e..2fb51b36f6 100644 --- a/crates/test-files/fixtures/compile_errors/self_in_standalone_fn.fe +++ b/crates/test-files/fixtures/compile_errors/self_in_standalone_fn.fe @@ -1,7 +1,9 @@ -fn pure_fn(self): +fn pure_fn(self) { self.mut_fn() +} -contract Foo: - - fn foo(self): - pure_fn(self) \ No newline at end of file +contract Foo { + fn foo(self) { + pure_fn(self) + } +} diff --git a/crates/test-files/fixtures/compile_errors/self_misuse.fe b/crates/test-files/fixtures/compile_errors/self_misuse.fe index d48b9b1281..b01490b7c8 100644 --- a/crates/test-files/fixtures/compile_errors/self_misuse.fe +++ b/crates/test-files/fixtures/compile_errors/self_misuse.fe @@ -1,33 +1,40 @@ -fn foo(): - let self: u8 = 10 - self = 5 +fn foo() { + let self: u8 = 10 + self = 5 +} -fn change_x(_ s: S): - s.x = 100 +fn change_x(_ s: S) { + s.x = 100 +} -fn bar(_ c: C): - pass +fn bar(_ c: C) {} -struct S: - pub x: u8 +struct S { + pub x: u8 - fn f(self): - self() + fn f(self) { + self() + } - fn g(self): - self = S(x: 10) + fn g(self) { + self = S(x: 10) + } - fn h(self): - change_x(self) # allowed + fn h(self) { + change_x(self) + } +} -contract C: - x: u8 +contract C { + x: u8 - fn g(self): - pass + fn g(self) {} - fn h(self): - g(self) + fn h(self) { + g(self) + } - fn i(self): - bar(self) + fn i(self) { + bar(self) + } +} diff --git a/crates/test-files/fixtures/compile_errors/self_not_first.fe b/crates/test-files/fixtures/compile_errors/self_not_first.fe index 7cf39ebc5a..f45fbe7afd 100644 --- a/crates/test-files/fixtures/compile_errors/self_not_first.fe +++ b/crates/test-files/fixtures/compile_errors/self_not_first.fe @@ -1,3 +1,3 @@ -contract Foo: - pub fn bar(my_num: u8, self): - pass \ No newline at end of file +contract Foo { + pub fn bar(my_num: u8, self) {} +} diff --git a/crates/test-files/fixtures/compile_errors/shadow_builtin_function.fe b/crates/test-files/fixtures/compile_errors/shadow_builtin_function.fe index d7fe7ce528..41f53e24ed 100644 --- a/crates/test-files/fixtures/compile_errors/shadow_builtin_function.fe +++ b/crates/test-files/fixtures/compile_errors/shadow_builtin_function.fe @@ -1,9 +1,13 @@ -contract C: - pub fn keccak256(bytes: Array) -> Array: - return [1, 2, 3, 4] +contract C { + pub fn keccak256(bytes: Array) -> Array { + return [1, 2, 3, 4] + } - pub fn u256(x: u8) -> u256: - return 10 + pub fn u256(x: u8) -> u256 { + return 10 + } - pub fn bool(x: u8) -> bool: - return x != 0 + pub fn bool(x: u8) -> bool { + return x != 0 + } +} diff --git a/crates/test-files/fixtures/compile_errors/shadow_builtin_type.fe b/crates/test-files/fixtures/compile_errors/shadow_builtin_type.fe index 237907d8a6..7598e78b2e 100644 --- a/crates/test-files/fixtures/compile_errors/shadow_builtin_type.fe +++ b/crates/test-files/fixtures/compile_errors/shadow_builtin_type.fe @@ -1,16 +1,21 @@ type u256 = u8 + type String = u256 + type Map = u256 + type bool = u256 type keccak256 = u8 + type block = u8 + type msg = u8 + type chain = u8 -contract C: - fn f(u8: u256): - pass +contract C { + fn f(u8: u256) {} - fn g(keccak256: u8): - pass + fn g(keccak256: u8) {} +} diff --git a/crates/test-files/fixtures/compile_errors/strict_boolean_if_else.fe b/crates/test-files/fixtures/compile_errors/strict_boolean_if_else.fe index 6468521a8b..e68f3d21d5 100644 --- a/crates/test-files/fixtures/compile_errors/strict_boolean_if_else.fe +++ b/crates/test-files/fixtures/compile_errors/strict_boolean_if_else.fe @@ -1,6 +1,9 @@ -contract Foo: - pub fn bar(val: u256) -> u256: - if val: +contract Foo { + pub fn bar(val: u256) -> u256 { + if val { return 5 - else: + } else { return 1 + } + } +} diff --git a/crates/test-files/fixtures/compile_errors/struct_call_bad_args.fe b/crates/test-files/fixtures/compile_errors/struct_call_bad_args.fe index 85761e9170..941c89f306 100644 --- a/crates/test-files/fixtures/compile_errors/struct_call_bad_args.fe +++ b/crates/test-files/fixtures/compile_errors/struct_call_bad_args.fe @@ -1,8 +1,10 @@ -struct House: +struct House { pub vacant: bool pub price: u256 +} -contract Foo: - - pub fn bar(): +contract Foo { + pub fn bar() { let my_house: House = House(price: false, vacant: 100, bar: address(0)) + } +} diff --git a/crates/test-files/fixtures/compile_errors/struct_call_without_kw_args.fe b/crates/test-files/fixtures/compile_errors/struct_call_without_kw_args.fe index 726059de2f..00a2ca097e 100644 --- a/crates/test-files/fixtures/compile_errors/struct_call_without_kw_args.fe +++ b/crates/test-files/fixtures/compile_errors/struct_call_without_kw_args.fe @@ -1,8 +1,10 @@ -struct House: +struct House { pub vacant: bool pub price: u256 +} -contract Foo: - - pub fn bar(): +contract Foo { + pub fn bar() { let my_house: House = House(true, price: 1000000) + } +} diff --git a/crates/test-files/fixtures/compile_errors/struct_private_constructor.fe b/crates/test-files/fixtures/compile_errors/struct_private_constructor.fe index 4efaff9369..0ac2cb12de 100644 --- a/crates/test-files/fixtures/compile_errors/struct_private_constructor.fe +++ b/crates/test-files/fixtures/compile_errors/struct_private_constructor.fe @@ -1,8 +1,10 @@ -struct House: +struct House { vacant: bool pub price: u256 +} -contract Foo: - - pub fn bar(): +contract Foo { + pub fn bar() { let my_house: House = House(vacant: true, price: 1000000) + } +} diff --git a/crates/test-files/fixtures/compile_errors/struct_recursive_cycles.fe b/crates/test-files/fixtures/compile_errors/struct_recursive_cycles.fe index a5d67c93c0..8325a04068 100644 --- a/crates/test-files/fixtures/compile_errors/struct_recursive_cycles.fe +++ b/crates/test-files/fixtures/compile_errors/struct_recursive_cycles.fe @@ -1,22 +1,25 @@ - # structs `Foo` and `Bar` contains indirect recursion # struct Foo depends on `Bar` -struct Foo: +struct Foo { x: Bar +} # struct Bar depends on `Foo` -struct Bar: +struct Bar { x: Foo +} # struct `Foo2` depends on itself - contains direct recursion -struct Foo2: +struct Foo2 { x: Foo2 +} # struct `Bar2` has no recursion -struct Bar2: +struct Bar2 { x: Foo y: Bar +} -contract MyContract: - pub fn func(foo: Foo, foo2: Foo2, bar2: Bar2): - pass +contract MyContract { + pub fn func(foo: Foo, foo2: Foo2, bar2: Bar2) {} +} diff --git a/crates/test-files/fixtures/compile_errors/undefined_type_param.fe b/crates/test-files/fixtures/compile_errors/undefined_type_param.fe index 0916484b66..69bcf0c5be 100644 --- a/crates/test-files/fixtures/compile_errors/undefined_type_param.fe +++ b/crates/test-files/fixtures/compile_errors/undefined_type_param.fe @@ -1,18 +1,20 @@ # https://github.com/ethereum/fe/issues/530 -struct BadField: +struct BadField { pub x: MysteryType +} -contract Foo: - # case 1: using arg with undefined type within the fn body - pub fn a(_ val: DoesntExist): +contract Foo { + pub fn a(_ val: DoesntExist) { val + 10 + } - # case 2: calling a fn that has undefined-type arg - pub fn b(): + pub fn b() { a(10) + } - # case 3: using a struct field that has an undefined type - pub fn c(): + pub fn c() { let x: BadField x.x = 10 + } +} diff --git a/crates/test-files/fixtures/compile_errors/unsafe_misuse.fe b/crates/test-files/fixtures/compile_errors/unsafe_misuse.fe index 84b98cd8da..a3dab0f05e 100644 --- a/crates/test-files/fixtures/compile_errors/unsafe_misuse.fe +++ b/crates/test-files/fixtures/compile_errors/unsafe_misuse.fe @@ -1,42 +1,42 @@ +unsafe fn mod_priv() {} -# unsafe module functions can be pub or not -unsafe fn mod_priv(): # OK - pass -pub unsafe fn mod_pub(): - mod_priv() # OK - -pub fn f(): - # unsafe fn called outside unsafe - mod_priv() # BAD - -pub fn g(): - unsafe: - mod_priv() # OK - -contract Foo: - # pub unsafe contract functions are allowed - pub unsafe fn pub_self(self): # Ok - pass - pub unsafe fn pub_noself(): # Ok - pass - - # non-pub contract fns can be unsafe - unsafe fn priv_nonself(): # OK - # can call any unsafe fn - mod_priv() # OK - mod_pub() # OK - priv_nonself() # OK - - # unsafe fns can take self - unsafe fn priv_self(self): # OK - self.priv_self2() # OK - unsafe fn priv_self2(self): # OK - pass - - fn bar(self): - # BAD: unsafe fn called outside unsafe - self.priv_self() # BAD - priv_nonself() # BAD - unsafe: - self.priv_self() # OK - priv_nonself() # OK +pub unsafe fn mod_pub() { + mod_priv() +} + +pub fn f() { + mod_priv() +} + +pub fn g() { + unsafe { + mod_priv() + } +} + +contract Foo { + pub unsafe fn pub_self(self) {} + + pub unsafe fn pub_noself() {} + + unsafe fn priv_nonself() { + mod_priv() + mod_pub() + priv_nonself() + } + + unsafe fn priv_self(self) { + self.priv_self2() + } + + unsafe fn priv_self2(self) {} + + fn bar(self) { + self.priv_self() + priv_nonself() + unsafe { + self.priv_self() + priv_nonself() + } + } +} diff --git a/crates/test-files/fixtures/compile_errors/unsafe_nesting.fe b/crates/test-files/fixtures/compile_errors/unsafe_nesting.fe index 914e737ac7..968785e87d 100644 --- a/crates/test-files/fixtures/compile_errors/unsafe_nesting.fe +++ b/crates/test-files/fixtures/compile_errors/unsafe_nesting.fe @@ -1,12 +1,12 @@ -unsafe fn f(): - unsafe: - g() +unsafe fn f() { + unsafe { g() } +} -fn g(): - unsafe: - h() - unsafe: - h() +fn g() { + unsafe { + h() + unsafe { h() } + } +} -fn h(): - pass \ No newline at end of file +fn h() {} diff --git a/crates/test-files/fixtures/crashes/agroce531.fe b/crates/test-files/fixtures/crashes/agroce531.fe index 47201c0047..ff3d2c6bfd 100644 --- a/crates/test-files/fixtures/crashes/agroce531.fe +++ b/crates/test-files/fixtures/crashes/agroce531.fe @@ -1,5 +1,7 @@ -struct tuple_bool_address_: - m:bool +struct tuple_bool_address_ { + m: bool +} -contract o: - e:(bool,address) +contract o { + e: (bool, address) +} diff --git a/crates/test-files/fixtures/crashes/agroce550.fe b/crates/test-files/fixtures/crashes/agroce550.fe index 030464bb09..71b67d2ef5 100644 --- a/crates/test-files/fixtures/crashes/agroce550.fe +++ b/crates/test-files/fixtures/crashes/agroce550.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn o(): - [-1>>0] \ No newline at end of file +contract Foo { + pub fn o() { + [-1 >> 0] + } +} diff --git a/crates/test-files/fixtures/crashes/agroce551.fe b/crates/test-files/fixtures/crashes/agroce551.fe index e98b2bc161..5b329e29f8 100644 --- a/crates/test-files/fixtures/crashes/agroce551.fe +++ b/crates/test-files/fixtures/crashes/agroce551.fe @@ -1,3 +1,5 @@ -contract o: - pub fn l(b:bool): - "" \ No newline at end of file +contract o { + pub fn l(b: bool) { + "" + } +} diff --git a/crates/test-files/fixtures/crashes/agroce623.fe b/crates/test-files/fixtures/crashes/agroce623.fe index a7fd6bfddf..7c9c83e3ae 100644 --- a/crates/test-files/fixtures/crashes/agroce623.fe +++ b/crates/test-files/fixtures/crashes/agroce623.fe @@ -1,3 +1,5 @@ -contract r: - pub fn t(): - [] \ No newline at end of file +contract r { + pub fn t() { + [] + } +} diff --git a/crates/test-files/fixtures/crashes/revert_const.fe b/crates/test-files/fixtures/crashes/revert_const.fe index b2ec81b4ea..55a3f885fe 100644 --- a/crates/test-files/fixtures/crashes/revert_const.fe +++ b/crates/test-files/fixtures/crashes/revert_const.fe @@ -1,7 +1,9 @@ const FOO: u256 = 0x101 -struct Error: - code: u256 +struct Error { + code: u256 +} -fn exit(): - revert Error(code = FOO) +fn exit() { + revert Error(code: FOO) +} diff --git a/crates/test-files/fixtures/demos/erc20_token.fe b/crates/test-files/fixtures/demos/erc20_token.fe index 691b5fe7d3..e2f6364b95 100644 --- a/crates/test-files/fixtures/demos/erc20_token.fe +++ b/crates/test-files/fixtures/demos/erc20_token.fe @@ -1,6 +1,6 @@ use std::context::Context -contract ERC20: +contract ERC20 { _balances: Map _allowances: Map> _total_supply: u256 @@ -8,92 +8,111 @@ contract ERC20: _symbol: String<100> _decimals: u8 - event Approval: + event Approval { idx owner: address idx spender: address value: u256 + } - event Transfer: + event Transfer { idx from: address idx to: address value: u256 + } - pub fn __init__(self, ctx: Context, name: String<100>, symbol: String<100>): + pub fn __init__(self, ctx: Context, name: String<100>, symbol: String<100>) { self._name = name self._symbol = symbol self._decimals = u8(18) self._mint(ctx, account: ctx.msg_sender(), value: 1000_000_000_000_000_000_000_000) + } - pub fn name(self) -> String<100>: + pub fn name(self) -> String<100> { return self._name.to_mem() + } - pub fn symbol(self) -> String<100>: + pub fn symbol(self) -> String<100> { return self._symbol.to_mem() + } - pub fn decimals(self) -> u8: + pub fn decimals(self) -> u8 { return self._decimals + } - pub fn totalSupply(self) -> u256: + pub fn totalSupply(self) -> u256 { return self._total_supply + } - pub fn balanceOf(self, _ account: address) -> u256: + pub fn balanceOf(self, _ account: address) -> u256 { return self._balances[account] + } - pub fn transfer(self, ctx: Context, recipient: address, value: u256) -> bool: + pub fn transfer(self, ctx: Context, recipient: address, value: u256) -> bool { self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) return true + } - pub fn allowance(self, owner: address, spender: address) -> u256: + pub fn allowance(self, owner: address, spender: address) -> u256 { return self._allowances[owner][spender] + } - pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool: + pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool { self._approve(ctx, owner: ctx.msg_sender(), spender, value) return true + } - pub fn transferFrom(self, ctx: Context, sender: address, recipient: address, value: u256) -> bool: + pub fn transferFrom(self, ctx: Context, sender: address, recipient: address, value: u256) -> bool { assert self._allowances[sender][ctx.msg_sender()] >= value self._transfer(ctx, sender, recipient, value) self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) return true + } - pub fn increaseAllowance(self, ctx: Context, spender: address, addedValue: u256) -> bool: + pub fn increaseAllowance(self, ctx: Context, spender: address, addedValue: u256) -> bool { self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) return true + } - pub fn decreaseAllowance(self, ctx: Context, spender: address, subtractedValue: u256) -> bool: + pub fn decreaseAllowance(self, ctx: Context, spender: address, subtractedValue: u256) -> bool { self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) return true + } - fn _transfer(self, ctx: Context, sender: address, recipient: address, value: u256): + fn _transfer(self, ctx: Context, sender: address, recipient: address, value: u256) { assert sender != address(0) assert recipient != address(0) _before_token_transfer(from: sender, to: recipient, value) self._balances[sender] = self._balances[sender] - value self._balances[recipient] = self._balances[recipient] + value emit Transfer(ctx, from: sender, to: recipient, value) + } - fn _mint(self, ctx: Context, account: address, value: u256): + fn _mint(self, ctx: Context, account: address, value: u256) { assert account != address(0) _before_token_transfer(from: address(0), to: account, value) self._total_supply = self._total_supply + value self._balances[account] = self._balances[account] + value emit Transfer(ctx, from: address(0), to: account, value) + } - fn _burn(self, ctx: Context, account: address, value: u256): + fn _burn(self, ctx: Context, account: address, value: u256) { assert account != address(0) _before_token_transfer(from: account, to: address(0), value) self._balances[account] = self._balances[account] - value self._total_supply = self._total_supply - value emit Transfer(ctx, from: account, to: address(0), value) + } - fn _approve(self, ctx: Context, owner: address, spender: address, value: u256): + fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { assert owner != address(0) assert spender != address(0) self._allowances[owner][spender] = value emit Approval(ctx, owner, spender, value) + } - fn _setup_decimals(self, _ decimals_: u8): + fn _setup_decimals(self, _ decimals_: u8) { self._decimals = decimals_ + } - fn _before_token_transfer(from: address, to: address, _ value: u256): - return + fn _before_token_transfer(from: address, to: address, _ value: u256) {} +} diff --git a/crates/test-files/fixtures/demos/guest_book.fe b/crates/test-files/fixtures/demos/guest_book.fe index b86b2ba649..1b20c6991f 100644 --- a/crates/test-files/fixtures/demos/guest_book.fe +++ b/crates/test-files/fixtures/demos/guest_book.fe @@ -1,23 +1,27 @@ use std::context::Context # The `contract` keyword defines a new contract type -contract GuestBook: +contract GuestBook { # Strings are generic over a constant number # that restricts its maximum size messages: Map> # Events can be defined on contract or module level - event Signed: + event Signed { book_msg: String<100> + } - pub fn sign(self, ctx: Context, book_msg: String<100>): + pub fn sign(self, ctx: Context, book_msg: String<100>) { # All storage access is explicit using `self.` self.messages[ctx.msg_sender()] = book_msg # Emit the `Signed` event emit Signed(ctx, book_msg) + } - pub fn get_msg(self, addr: address) -> String<100>: + pub fn get_msg(self, addr: address) -> String<100> { # Copying data from storage to memory # has to be done explicitly via `to_mem()` return self.messages[addr].to_mem() + } +} diff --git a/crates/test-files/fixtures/demos/simple_open_auction.fe b/crates/test-files/fixtures/demos/simple_open_auction.fe index 30042671ab..6c2a13c358 100644 --- a/crates/test-files/fixtures/demos/simple_open_auction.fe +++ b/crates/test-files/fixtures/demos/simple_open_auction.fe @@ -1,19 +1,15 @@ use std::context::Context -# errors -struct AuctionAlreadyEnded: - pass +# errors +struct AuctionAlreadyEnded {} +struct AuctionNotYetEnded {} +struct AuctionEndAlreadyCalled {} -struct BidNotHighEnough: +struct BidNotHighEnough { pub highest_bid: u256 +} -struct AuctionNotYetEnded: - pass - -struct AuctionEndAlreadyCalled: - pass - -contract SimpleOpenAuction: +contract SimpleOpenAuction { # states auction_end_time: u256 beneficiary: address @@ -23,56 +19,62 @@ contract SimpleOpenAuction: pending_returns: Map - ended: bool + ended: bool # events - event HighestBidIncreased: + event HighestBidIncreased { idx bidder: address amount: u256 - - event AuctionEnded: + } + + event AuctionEnded { idx winner: address amount: u256 + } - # constructor - pub fn __init__(self, ctx: Context, bidding_time: u256, beneficiary_addr: address): + # constructor + pub fn __init__(self, ctx: Context, bidding_time: u256, beneficiary_addr: address) { self.beneficiary = beneficiary_addr self.auction_end_time = ctx.block_timestamp() + bidding_time - + } + #method - pub fn bid(self, ctx: Context): - if ctx.block_timestamp() > self.auction_end_time: + pub fn bid(self, ctx: Context) { + if ctx.block_timestamp() > self.auction_end_time { revert AuctionAlreadyEnded() - - if ctx.msg_value() <= self.highest_bid: + } + if ctx.msg_value() <= self.highest_bid { revert BidNotHighEnough(highest_bid: self.highest_bid) - - if self.highest_bid != 0: + } + if self.highest_bid != 0 { self.pending_returns[self.highest_bidder] += self.highest_bid - + } self.highest_bidder = ctx.msg_sender() self.highest_bid = ctx.msg_value() emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) + } - pub fn withdraw(self, ctx: Context) -> bool: + pub fn withdraw(self, ctx: Context) -> bool { let amount: u256 = self.pending_returns[ctx.msg_sender()] - if amount > 0: + if amount > 0 { self.pending_returns[ctx.msg_sender()] = 0 ctx.send_value(to: ctx.msg_sender(), wei: amount) - + } return true + } - pub fn action_end(self, ctx: Context): - if ctx.block_timestamp() <= self.auction_end_time: + pub fn action_end(self, ctx: Context) { + if ctx.block_timestamp() <= self.auction_end_time { revert AuctionNotYetEnded() - - if self.ended: + } + if self.ended { revert AuctionEndAlreadyCalled() - + } self.ended = true emit AuctionEnded(ctx, winner: self.highest_bidder, amount: self.highest_bid) ctx.send_value(to: self.beneficiary, wei: self.highest_bid) - \ No newline at end of file + } +} \ No newline at end of file diff --git a/crates/test-files/fixtures/demos/uniswap.fe b/crates/test-files/fixtures/demos/uniswap.fe index a70c44de9c..7fbc0eda1e 100644 --- a/crates/test-files/fixtures/demos/uniswap.fe +++ b/crates/test-files/fixtures/demos/uniswap.fe @@ -1,13 +1,16 @@ use std::context::Context -contract ERC20: - pub fn balanceOf(_ account: address) -> u256: +contract ERC20 { + pub fn balanceOf(_ account: address) -> u256 { return 0 + } - pub fn transfer(to: address, _ amount: u256) -> bool: + pub fn transfer(to: address, _ amount: u256) -> bool { return false + } +} -contract UniswapV2Pair: +contract UniswapV2Pair { # TODO: const support (https://github.com/ethereum/fe/issues/192) # const MINIMUM_LIQUIDITY: u256 = 1000 @@ -29,136 +32,157 @@ contract UniswapV2Pair: price1_cumulative_last: u256 k_last: u256 - event Approval: + event Approval { idx owner: address idx spender: address value: u256 + } - event Transfer: + event Transfer { idx from: address idx to: address value: u256 + } - event Mint: + event Mint { idx sender: address amount0: u256 amount1: u256 + } - event Burn: + event Burn { idx sender: address amount0: u256 amount1: u256 idx to: address + } - event Swap: + event Swap { idx sender: address amount0_in: u256 amount1_in: u256 amount0_out: u256 amount1_out: u256 idx to: address + } - event Sync: + event Sync { reserve0: u256 reserve1: u256 + } - pub fn __init__(self, ctx: Context): + pub fn __init__(self, ctx: Context) { self.factory = ctx.msg_sender() + } - pub fn factory(self) -> address: + pub fn factory(self) -> address { return self.factory + } - pub fn token0(self) -> address: + pub fn token0(self) -> address { return self.token0 + } - pub fn token1(self) -> address: + pub fn token1(self) -> address { return self.token1 + } - fn _mint(self, ctx: Context, to: address, value: u256): + fn _mint(self, ctx: Context, to: address, value: u256) { self.total_supply = self.total_supply + value self.balances[to] = self.balances[to] + value emit Transfer(ctx, from: address(0), to, value) + } - fn _burn(self, ctx: Context, from: address, value: u256): + fn _burn(self, ctx: Context, from: address, value: u256) { self.balances[from] = self.balances[from] - value self.total_supply = self.total_supply - value emit Transfer(ctx, from, to: address(0), value) + } - - fn _approve(self, ctx: Context, owner: address, spender: address, value: u256): + fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { self.allowances[owner][spender] = value emit Approval(ctx, owner, spender, value) + } - - fn _transfer(self, ctx: Context, from: address, to: address, value: u256): + fn _transfer(self, ctx: Context, from: address, to: address, value: u256) { self.balances[from] = self.balances[from] - value self.balances[to] = self.balances[to] + value emit Transfer(ctx, from, to, value) + } - pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool: + pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool { self._approve(ctx, owner: ctx.msg_sender(), spender, value) return true + } - pub fn transfer(self, ctx: Context, to: address, value: u256) -> bool: + pub fn transfer(self, ctx: Context, to: address, value: u256) -> bool { self._transfer(ctx, from: ctx.msg_sender(), to, value) return true + } - pub fn transferFrom(self, ctx: Context, from: address, to: address, value: u256) -> bool: + pub fn transferFrom(self, ctx: Context, from: address, to: address, value: u256) -> bool { assert self.allowances[from][ctx.msg_sender()] >= value self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value self._transfer(ctx, from, to, value) return true + } - pub fn balanceOf(self, _ account: address) -> u256: + pub fn balanceOf(self, _ account: address) -> u256 { return self.balances[account] + } - pub fn get_reserves(self) -> (u256, u256, u256): + pub fn get_reserves(self) -> (u256, u256, u256) { return (self.reserve0, self.reserve1, self.block_timestamp_last) + } # called once by the factory at time of deployment - pub fn initialize(self, ctx: Context, token0: address, token1: address): + pub fn initialize(self, ctx: Context, token0: address, token1: address) { assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" self.token0 = token0 self.token1 = token1 + } # update reserves and, on the first call per block, price accumulators - fn _update(self, ctx: Context, balance0: u256, balance1: u256, reserve0: u256, reserve1: u256): + fn _update(self, ctx: Context, balance0: u256, balance1: u256, reserve0: u256, reserve1: u256) { # changed from u32s - let block_timestamp: u256 = ctx.block_timestamp() % 2**32 # TODO: reproduce desired overflow (https://github.com/ethereum/fe/issues/286) - let time_elapsed: u256 = block_timestamp - self.block_timestamp_last # overflow is desired - if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0: - # `*` never overflows, and + overflow is desired - self.price0_cumulative_last = self.price0_cumulative_last + (reserve1 / reserve0) * time_elapsed - self.price1_cumulative_last = self.price1_cumulative_last + (reserve0 / reserve1) * time_elapsed - + let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 + let time_elapsed: u256 = block_timestamp - self.block_timestamp_last + if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { + self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed + self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed + } self.reserve0 = balance0 self.reserve1 = balance1 self.block_timestamp_last = block_timestamp emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) + } - # if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k) - fn _mint_fee(self, ctx: Context, reserve0: u256, reserve1: u256) -> bool: + fn _mint_fee(self, ctx: Context, reserve0: u256, reserve1: u256) -> bool { let fee_to: address = UniswapV2Factory(ctx, self.factory).fee_to() let fee_on: bool = fee_to != address(0) - let k_last: u256 = self.k_last # gas savings - if fee_on: - if k_last != 0: + let k_last: u256 = self.k_last + if fee_on { + if k_last != 0 { let root_k: u256 = sqrt(reserve0 * reserve1) let root_k_last: u256 = sqrt(k_last) - if root_k > root_k_last: + if root_k > root_k_last { let numerator: u256 = self.total_supply * root_k - root_k_last let denominator: u256 = root_k * 5 + root_k_last let liquidity: u256 = numerator / denominator - if liquidity > 0: + if liquidity > 0 { self._mint(ctx, to: fee_to, value: liquidity) - elif k_last != 0: + } + } + } + } else if k_last != 0 { self.k_last = 0 - + } return fee_on + } # this low-level function should be called from a contract which performs important safety checks - pub fn mint(self, ctx: Context, to: address) -> u256: + pub fn mint(self, ctx: Context, to: address) -> u256 { let MINIMUM_LIQUIDITY: u256 = 1000 let reserve0: u256 = self.reserve0 let reserve1: u256 = self.reserve1 @@ -166,29 +190,27 @@ contract UniswapV2Pair: let balance1: u256 = ERC20(ctx, self.token1).balanceOf(ctx.self_address()) let amount0: u256 = balance0 - self.reserve0 let amount1: u256 = balance1 - self.reserve1 - let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) let total_supply: u256 = self.total_supply # gas savings, must be defined here since totalSupply can update in _mintFee let liquidity: u256 = 0 - if total_supply == 0: + if total_supply == 0 { liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY self._mint(ctx, to: address(0), value: MINIMUM_LIQUIDITY) # permanently lock the first MINIMUM_LIQUIDITY tokens - else: - liquidity = min((amount0 * total_supply) / reserve0, (amount1 * total_supply) / reserve1) - + } else { + liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) + } assert liquidity > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED" - self._mint(ctx, to, value: liquidity) self._update(ctx, balance0, balance1, reserve0, reserve1) - - if fee_on: + if fee_on { self.k_last = reserve0 * reserve1 # reserve0 and reserve1 are up-to-date - + } emit Mint(ctx, sender: ctx.msg_sender(), amount0, amount1) return liquidity + } # this low-level function should be called from a contract which performs important safety checks - pub fn burn(self, ctx: Context, to: address) -> (u256, u256): + pub fn burn(self, ctx: Context, to: address) -> (u256, u256) { let reserve0: u256 = self.reserve0 let reserve1: u256 = self.reserve1 let token0: ERC20 = ERC20(ctx, self.token0) @@ -207,19 +229,18 @@ contract UniswapV2Pair: token1.transfer(to, amount1) balance0 = token0.balanceOf(ctx.self_address()) balance1 = token1.balanceOf(ctx.self_address()) - self._update(ctx, balance0, balance1, reserve0, reserve1) - - if fee_on: - self.k_last = reserve0 * reserve1 # reserve0 and reserve1 are up-to-date - + if fee_on { + self.k_last = reserve0 * reserve1 + } emit Burn(ctx, sender: ctx.msg_sender(), amount0, amount1, to) return (amount0, amount1) + } # this low-level function should be called from a contract which performs important safety checks # TODO: add support for the bytes type (https://github.com/ethereum/fe/issues/280) # pub fn swap(amount0_out: u256, amount1_out: u256, to: address, data: bytes): - pub fn swap(self, ctx: Context, amount0_out: u256, amount1_out: u256, to: address): + pub fn swap(self, ctx: Context, amount0_out: u256, amount1_out: u256, to: address) { assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" let reserve0: u256 = self.reserve0 let reserve1: u256 = self.reserve1 @@ -231,13 +252,15 @@ contract UniswapV2Pair: # TODO: we should be using `token0.address` (https://github.com/ethereum/fe/issues/287) assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" - if amount0_out > 0: + if amount0_out > 0 { token0.transfer(to, amount0_out) # optimistically transfer tokens - if amount1_out > 0: + } + if amount1_out > 0 { token1.transfer(to, amount1_out) # optimistically transfer tokens + } # TODO: bytes support -# if data.length > 0: -# IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0_out, amount1_out, data) + # if data.length > 0: + # IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0_out, amount1_out, data) let balance0: u256 = token0.balanceOf(ctx.self_address()) let balance1: u256 = token1.balanceOf(ctx.self_address()) @@ -254,17 +277,18 @@ contract UniswapV2Pair: self._update(ctx, balance0, balance1, reserve0, reserve1) emit Swap(ctx, sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to) + } # force balances to match reserves - pub fn skim(self, ctx: Context, to: address): + pub fn skim(self, ctx: Context, to: address) { let token0: ERC20 = ERC20(ctx, self.token0) # gas savings let token1: ERC20 = ERC20(ctx, self.token1) # gas savings - token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) + } # force reserves to match balances - pub fn sync(self, ctx: Context): + pub fn sync(self, ctx: Context) { let token0: ERC20 = ERC20(ctx, self.token0) let token1: ERC20 = ERC20(ctx, self.token1) self._update(ctx, @@ -272,8 +296,10 @@ contract UniswapV2Pair: balance1: token1.balanceOf(ctx.self_address()), reserve0: self.reserve0, reserve1: self.reserve1) + } +} -contract UniswapV2Factory: +contract UniswapV2Factory { fee_to: address fee_to_setter: address @@ -282,25 +308,30 @@ contract UniswapV2Factory: all_pairs: Array pair_counter: u256 - event PairCreated: + event PairCreated { idx token0: address idx token1: address pair: address index: u256 + } - pub fn __init__(self, _ fee_to_setter: address): - self.fee_to_setter = fee_to_setter + pub fn __init__(self, _ fee_to_setter: address) { + self.fee_to_setter = fee_to_setter + } - pub fn fee_to(self) -> address: + pub fn fee_to(self) -> address { return self.fee_to + } - pub fn fee_to_setter(self) -> address: + pub fn fee_to_setter(self) -> address { return self.fee_to_setter + } - pub fn all_pairs_length(self) -> u256: + pub fn all_pairs_length(self) -> u256 { return self.pair_counter + } - pub fn create_pair(self, ctx: Context, _ token_a: address, _ token_b: address) -> address: + pub fn create_pair(self, ctx: Context, _ token_a: address, _ token_b: address) -> address { assert token_a != token_b, "UniswapV2: IDENTICAL_ADDRESSES" let token0: address = token_a if token_a < token_b else token_b @@ -319,27 +350,34 @@ contract UniswapV2Factory: emit PairCreated(ctx, token0, token1, pair: address(pair), index: self.pair_counter) return address(pair) + } - pub fn set_fee_to(self, ctx: Context, fee_to: address): + pub fn set_fee_to(self, ctx: Context, fee_to: address) { assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" self.fee_to = fee_to + } - pub fn set_fee_to_setter(self, ctx: Context, fee_to_setter: address): + pub fn set_fee_to_setter(self, ctx: Context, fee_to_setter: address) { assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" self.fee_to_setter = fee_to_setter + } +} - -fn sqrt(_ val: u256) -> u256: +fn sqrt(_ val: u256) -> u256 { let z: u256 - if (val > 3): + if val > 3 { z = val let x: u256 = val / 2 + 1 - while (x < z): + while x < z { z = x x = (val / x + x) / 2 - elif (val != 0): + } + } else if val != 0 { z = 1 + } return z +} -fn min(_ x: u256, _ y: u256) -> u256: +fn min(_ x: u256, _ y: u256) -> u256 { return x if x < y else y +} diff --git a/crates/test-files/fixtures/differential/math_i8.fe b/crates/test-files/fixtures/differential/math_i8.fe index 11cc7f5216..de819932c9 100644 --- a/crates/test-files/fixtures/differential/math_i8.fe +++ b/crates/test-files/fixtures/differential/math_i8.fe @@ -1,43 +1,57 @@ -contract Foo: - - pub fn add(val1: i8, val2: i8) -> i8: - return val1 + val2 - - pub fn subtract(val1: i8, val2: i8) -> i8: - return val1 - val2 - - pub fn multiply(val1: i8, val2: i8) -> i8: - return val1 * val2 - - pub fn divide(val1: i8, val2: i8) -> i8: - return val1 / val2 - - pub fn pow(val1: i8, val2: u8) -> i8: - return val1 ** val2 - - pub fn modulo(val1: i8, val2: i8) -> i8: - return val1 % val2 - - pub fn rightshift(val1: i8, val2: u8) -> i8: - return val1 >> val2 - - pub fn leftshift(val1: i8, val2: u8) -> i8: - return val1 << val2 - - pub fn invert(val1: i8) -> i8: - return ~val1 - - pub fn cast1(val1: i8) -> u8: - return u8(val1) - - pub fn cast2(val1: i8) -> u16: - return u16(u8(val1)) - - pub fn cast3(val1: i8) -> u16: - return u16(i16(val1)) - - pub fn order_of_operation(val1: i8, val2: i8, val3: u8) -> i8: - return val1 - val2 * (val1 + val2 / 4 * val1 - val2**val3) + val1 - - pub fn negate(val1: i8) -> i8: - return -val1 \ No newline at end of file +contract Foo { + pub fn add(val1: i8, val2: i8) -> i8 { + return val1 + val2 + } + + pub fn subtract(val1: i8, val2: i8) -> i8 { + return val1 - val2 + } + + pub fn multiply(val1: i8, val2: i8) -> i8 { + return val1 * val2 + } + + pub fn divide(val1: i8, val2: i8) -> i8 { + return val1 / val2 + } + + pub fn pow(val1: i8, val2: u8) -> i8 { + return val1 ** val2 + } + + pub fn modulo(val1: i8, val2: i8) -> i8 { + return val1 % val2 + } + + pub fn rightshift(val1: i8, val2: u8) -> i8 { + return val1 >> val2 + } + + pub fn leftshift(val1: i8, val2: u8) -> i8 { + return val1 << val2 + } + + pub fn invert(val1: i8) -> i8 { + return ~val1 + } + + pub fn cast1(val1: i8) -> u8 { + return u8(val1) + } + + pub fn cast2(val1: i8) -> u16 { + return u16(u8(val1)) + } + + pub fn cast3(val1: i8) -> u16 { + return u16(i16(val1)) + } + + pub fn order_of_operation(val1: i8, val2: i8, val3: u8) -> i8 { + return val1 - val2 * (val1 + val2 / 4 * val1 - val2 ** val3) + val1 + } + + pub fn negate(val1: i8) -> i8 { + return -val1 + } +} diff --git a/crates/test-files/fixtures/differential/math_u8.fe b/crates/test-files/fixtures/differential/math_u8.fe index 9d266de3dc..a0d2805eb3 100644 --- a/crates/test-files/fixtures/differential/math_u8.fe +++ b/crates/test-files/fixtures/differential/math_u8.fe @@ -1,61 +1,80 @@ -contract Foo: - - pub fn add(val1: u8, val2: u8) -> u8: - return val1 + val2 - - pub fn subtract(val1: u8, val2: u8) -> u8: - return val1 - val2 - - pub fn multiply(val1: u8, val2: u8) -> u8: - return val1 * val2 - - pub fn divide(val1: u8, val2: u8) -> u8: - return val1 / val2 - - pub fn pow(val1: u8, val2: u8) -> u8: - return val1 ** val2 - - pub fn modulo(val1: u8, val2: u8) -> u8: - return val1 % val2 - - pub fn rightshift(val1: u8, val2: u8) -> u8: - return val1 >> val2 - - pub fn leftshift(val1: u8, val2: u8) -> u8: - return val1 << val2 - - pub fn invert(val1: u8) -> u8: - return ~val1 - - pub fn bit_and(val1: u8, val2: u8) -> u8: - return val1 & val2 - - pub fn bit_or(val1: u8, val2: u8) -> u8: - return val1 | val2 - - pub fn bit_xor(val1: u8, val2: u8) -> u8: - return val1 ^ val2 - - pub fn cast1(val1: u8) -> i8: - return i8(val1) - - pub fn cast2(val1: u8) -> i16: - return i16(i8(val1)) - - pub fn cast3(val1: u8) -> i16: - return i16(u16(val1)) - - pub fn order_of_operation(val1: u8, val2: u8) -> u8: - return val1 - val2 * (val1 + val2 / 4 * val1 - val2**val1) + val1 - - pub fn sqrt(val: u256) -> u256: - let z: u256 - if (val > 3): - z = val - let x: u256 = val / 2 + 1 - while (x < z): - z = x - x = (val / x + x) / 2 - elif (val != 0): - z = 1 - return z \ No newline at end of file +contract Foo { + pub fn add(val1: u8, val2: u8) -> u8 { + return val1 + val2 + } + + pub fn subtract(val1: u8, val2: u8) -> u8 { + return val1 - val2 + } + + pub fn multiply(val1: u8, val2: u8) -> u8 { + return val1 * val2 + } + + pub fn divide(val1: u8, val2: u8) -> u8 { + return val1 / val2 + } + + pub fn pow(val1: u8, val2: u8) -> u8 { + return val1 ** val2 + } + + pub fn modulo(val1: u8, val2: u8) -> u8 { + return val1 % val2 + } + + pub fn rightshift(val1: u8, val2: u8) -> u8 { + return val1 >> val2 + } + + pub fn leftshift(val1: u8, val2: u8) -> u8 { + return val1 << val2 + } + + pub fn invert(val1: u8) -> u8 { + return ~val1 + } + + pub fn bit_and(val1: u8, val2: u8) -> u8 { + return val1 & val2 + } + + pub fn bit_or(val1: u8, val2: u8) -> u8 { + return val1 | val2 + } + + pub fn bit_xor(val1: u8, val2: u8) -> u8 { + return val1 ^ val2 + } + + pub fn cast1(val1: u8) -> i8 { + return i8(val1) + } + + pub fn cast2(val1: u8) -> i16 { + return i16(i8(val1)) + } + + pub fn cast3(val1: u8) -> i16 { + return i16(u16(val1)) + } + + pub fn order_of_operation(val1: u8, val2: u8) -> u8 { + return val1 - val2 * (val1 + val2 / 4 * val1 - val2 ** val1) + val1 + } + + pub fn sqrt(val: u256) -> u256 { + let z: u256 + if val > 3 { + z = val + let x: u256 = val / 2 + 1 + while x < z { + z = x + x = (val / x + x) / 2 + } + } else if val != 0 { + z = 1 + } + return z + } +} diff --git a/crates/test-files/fixtures/differential/storage_and_memory.fe b/crates/test-files/fixtures/differential/storage_and_memory.fe index e32efa0edb..e74d90524f 100644 --- a/crates/test-files/fixtures/differential/storage_and_memory.fe +++ b/crates/test-files/fixtures/differential/storage_and_memory.fe @@ -1,47 +1,57 @@ use std::context::Context -struct MyStruct: +struct MyStruct { my_num: u256 my_num2: u8 my_bool: bool my_addr: address my_num3: i8 - -contract Foo: - - data: MyStruct - items: Array - more_items: Array - some_string: String<100> - - pub fn set_data(self, val: MyStruct): - self.data = val - - pub fn get_data(self) -> MyStruct: - return self.data.to_mem() - - pub fn set_string(self, val: String<100>): - self.some_string = val - - pub fn get_string(self) -> String<100>: - return self.some_string.to_mem() - - pub fn set_item(self, index: u256, item: i8): - self.items[index] = item - - pub fn get_items(self) -> Array: - return self.items.to_mem() - - pub fn set_range(self, ctx: Context, from: u256, to: u256): - let index: u256 = from - let counter: u256 = 0 - while index < to: - self.more_items[index] = self.more_items[index] + ctx.block_number() - index += 1 - counter += 1 - - if counter > 20: - break - - pub fn get_range(self) -> Array: - return self.more_items.to_mem() +} + +contract Foo { + data: MyStruct + items: Array + more_items: Array + some_string: String<100> + + pub fn set_data(self, val: MyStruct) { + self.data = val + } + + pub fn get_data(self) -> MyStruct { + return self.data.to_mem() + } + + pub fn set_string(self, val: String<100>) { + self.some_string = val + } + + pub fn get_string(self) -> String<100> { + return self.some_string.to_mem() + } + + pub fn set_item(self, index: u256, item: i8) { + self.items[index] = item + } + + pub fn get_items(self) -> Array { + return self.items.to_mem() + } + + pub fn set_range(self, ctx: Context, from: u256, to: u256) { + let index: u256 = from + let counter: u256 = 0 + while index < to { + self.more_items[index] = self.more_items[index] + ctx.block_number() + index += 1 + counter += 1 + if counter > 20 { + break + } + } + } + + pub fn get_range(self) -> Array { + return self.more_items.to_mem() + } +} diff --git a/crates/test-files/fixtures/features/abi_decode_checks.fe b/crates/test-files/fixtures/features/abi_decode_checks.fe index f0f684b24b..93cb84d718 100644 --- a/crates/test-files/fixtures/features/abi_decode_checks.fe +++ b/crates/test-files/fixtures/features/abi_decode_checks.fe @@ -1,22 +1,9 @@ -contract Foo: - pub fn decode_u256(a: u256): - pass +contract Foo { + pub fn decode_u256(a: u256) {} - pub fn decode_u128_bool(a: u128, b: bool): - pass + pub fn decode_u128_bool(a: u128, b: bool) {} - pub fn decode_u256_bytes_tuple_array( - a: u256, - b: Array, - c: (address, u8), - d: Array - ): - pass + pub fn decode_u256_bytes_tuple_array(a: u256, b: Array, c: (address, u8), d: Array) {} - pub fn decode_string_address_bytes_bool( - a: String<80>, - b: address, - c: Array, - d: bool - ): - pass + pub fn decode_string_address_bytes_bool(a: String<80>, b: address, c: Array, d: bool) {} +} diff --git a/crates/test-files/fixtures/features/address_bytes10_map.fe b/crates/test-files/fixtures/features/address_bytes10_map.fe index a874f0bac0..6f85dd3f1a 100644 --- a/crates/test-files/fixtures/features/address_bytes10_map.fe +++ b/crates/test-files/fixtures/features/address_bytes10_map.fe @@ -1,8 +1,11 @@ -contract Foo: +contract Foo { bar: Map> - pub fn read_bar(self, key: address) -> Array: + pub fn read_bar(self, key: address) -> Array { return self.bar[key].to_mem() + } - pub fn write_bar(self, key: address, value: Array): - self.bar[key] = value \ No newline at end of file + pub fn write_bar(self, key: address, value: Array) { + self.bar[key] = value + } +} diff --git a/crates/test-files/fixtures/features/arrays.fe b/crates/test-files/fixtures/features/arrays.fe index b7b1214db6..cbd81d2c1d 100644 --- a/crates/test-files/fixtures/features/arrays.fe +++ b/crates/test-files/fixtures/features/arrays.fe @@ -1,9 +1,12 @@ -contract Foo: +contract Foo { my_array: Array - pub fn get_from_storage(self, index: u256) -> u256: + pub fn get_from_storage(self, index: u256) -> u256 { return self.my_array[index] + } - pub fn get_from_memory(index: u256) -> u256: + pub fn get_from_memory(index: u256) -> u256 { let my_array: Array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] return my_array[index] + } +} diff --git a/crates/test-files/fixtures/features/assert.fe b/crates/test-files/fixtures/features/assert.fe index e33d9f3132..96d2413f44 100644 --- a/crates/test-files/fixtures/features/assert.fe +++ b/crates/test-files/fixtures/features/assert.fe @@ -1,20 +1,26 @@ -contract Foo: +contract Foo { my_bool: bool my_string: String<5> - pub fn bar(baz: u256): + pub fn bar(baz: u256) { assert baz > 5 + } - pub fn revert_with_static_string(baz: u256): + pub fn revert_with_static_string(baz: u256) { assert baz > 5, "Must be greater than five" + } - pub fn revert_with(baz: u256, reason: String<1000>): + pub fn revert_with(baz: u256, reason: String<1000>) { assert baz > 5, reason + } - pub fn assert_sto_bool(self): + pub fn assert_sto_bool(self) { self.my_bool = false assert self.my_bool + } - pub fn assert_sto_string_msg(self): + pub fn assert_sto_string_msg(self) { self.my_string = "hello" assert false, self.my_string.to_mem() + } +} diff --git a/crates/test-files/fixtures/features/associated_fns.fe b/crates/test-files/fixtures/features/associated_fns.fe index a460e9fc74..d708b684ff 100644 --- a/crates/test-files/fixtures/features/associated_fns.fe +++ b/crates/test-files/fixtures/features/associated_fns.fe @@ -1,16 +1,22 @@ +struct Lib { + pub fn square(x: u256) -> u256 { + return x * x + } +} -struct Lib: # This can't be a contract, yet - pub fn square(x: u256) -> u256: - return x * x +struct MyStruct { + pub x: u256 -struct MyStruct: - pub x: u256 - pub fn new(x: u256) -> MyStruct: - return MyStruct(x) + pub fn new(x: u256) -> MyStruct { + return MyStruct(x) + } +} -contract Foo: - my_struct: MyStruct +contract Foo { + my_struct: MyStruct - pub fn bar(self, val: u256) -> u256: - self.my_struct = MyStruct::new(x: val) - return Lib::square(x: self.my_struct.x) + pub fn bar(self, val: u256) -> u256 { + self.my_struct = MyStruct::new(x: val) + return Lib::square(x: self.my_struct.x) + } +} diff --git a/crates/test-files/fixtures/features/aug_assign.fe b/crates/test-files/fixtures/features/aug_assign.fe index 180e92fa8f..da6bbd2e38 100644 --- a/crates/test-files/fixtures/features/aug_assign.fe +++ b/crates/test-files/fixtures/features/aug_assign.fe @@ -1,57 +1,71 @@ -contract Foo: +contract Foo { my_num: u256 - pub fn add(a: u256, b: u256) -> u256: + pub fn add(a: u256, b: u256) -> u256 { a += b return a + } - pub fn sub(a: u256, b: u256) -> u256: + pub fn sub(a: u256, b: u256) -> u256 { a -= b return a + } - pub fn mul(a: u256, b: u256) -> u256: + pub fn mul(a: u256, b: u256) -> u256 { a *= b return a + } - pub fn div(a: u256, b: u256) -> u256: + pub fn div(a: u256, b: u256) -> u256 { a /= b return a + } - pub fn mod(a: u256, b: u256) -> u256: + pub fn mod(a: u256, b: u256) -> u256 { a %= b return a + } - pub fn pow(a: u256, b: u256) -> u256: + pub fn pow(a: u256, b: u256) -> u256 { a **= b return a + } - pub fn lshift(a: u8, b: u8) -> u8: + pub fn lshift(a: u8, b: u8) -> u8 { a <<= b return a + } - pub fn rshift(a: u8, b: u8) -> u8: + pub fn rshift(a: u8, b: u8) -> u8 { a >>= b return a + } - pub fn bit_or(a: u8, b: u8) -> u8: + pub fn bit_or(a: u8, b: u8) -> u8 { a |= b return a + } - pub fn bit_xor(a: u8, b: u8) -> u8: + pub fn bit_xor(a: u8, b: u8) -> u8 { a ^= b return a + } - pub fn bit_and(a: u8, b: u8) -> u8: + pub fn bit_and(a: u8, b: u8) -> u8 { a &= b return a + } - pub fn add_from_sto(self, a: u256, b: u256) -> u256: + pub fn add_from_sto(self, a: u256, b: u256) -> u256 { self.my_num = a self.my_num += b return self.my_num + } - pub fn add_from_mem(a: u256, b: u256) -> u256: + pub fn add_from_mem(a: u256, b: u256) -> u256 { let my_array: Array my_array[7] = a my_array[7] += b return my_array[7] + } +} diff --git a/crates/test-files/fixtures/features/balances.fe b/crates/test-files/fixtures/features/balances.fe index 978489eca6..8b8d86ecb6 100644 --- a/crates/test-files/fixtures/features/balances.fe +++ b/crates/test-files/fixtures/features/balances.fe @@ -1,9 +1,12 @@ use std::evm::{balance, balance_of} use std::context::Context -contract Foo: - pub fn my_balance(self, ctx: Context) -> u256: +contract Foo { + pub fn my_balance(self, ctx: Context) -> u256 { return ctx.self_balance() + } - pub fn other_balance(self, ctx: Context, someone: address) -> u256: + pub fn other_balance(self, ctx: Context, someone: address) -> u256 { return ctx.balance_of(someone) + } +} diff --git a/crates/test-files/fixtures/features/base_tuple.fe b/crates/test-files/fixtures/features/base_tuple.fe index feb8272c8b..d4b6920cab 100644 --- a/crates/test-files/fixtures/features/base_tuple.fe +++ b/crates/test-files/fixtures/features/base_tuple.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(my_num: u256, my_bool: bool) -> (u256, bool): +contract Foo { + pub fn bar(my_num: u256, my_bool: bool) -> (u256, bool) { return (my_num, my_bool) + } +} diff --git a/crates/test-files/fixtures/features/call_fn.fe b/crates/test-files/fixtures/features/call_fn.fe index caf4606ecd..5b44dce524 100644 --- a/crates/test-files/fixtures/features/call_fn.fe +++ b/crates/test-files/fixtures/features/call_fn.fe @@ -1,7 +1,11 @@ -contract Foo: - pub fn __call__(self): - unsafe: - if __calldataload(0) == 1: +contract Foo { + pub fn __call__(self) { + unsafe { + if __calldataload(0) == 1 { __revert(0, 0) - else: - __return(0, 0) \ No newline at end of file + } else { + __return(0, 0) + } + } + } +} diff --git a/crates/test-files/fixtures/features/call_statement_with_args.fe b/crates/test-files/fixtures/features/call_statement_with_args.fe index ff312cca2f..5312046273 100644 --- a/crates/test-files/fixtures/features/call_statement_with_args.fe +++ b/crates/test-files/fixtures/features/call_statement_with_args.fe @@ -1,9 +1,12 @@ -contract Foo: +contract Foo { baz: Map - fn assign(self, _ val: u256): + fn assign(self, _ val: u256) { self.baz[0] = val + } - pub fn bar(self) -> u256: + pub fn bar(self) -> u256 { self.assign(100) return self.baz[0] + } +} diff --git a/crates/test-files/fixtures/features/call_statement_with_args_2.fe b/crates/test-files/fixtures/features/call_statement_with_args_2.fe index 44025abb30..fb7facc533 100644 --- a/crates/test-files/fixtures/features/call_statement_with_args_2.fe +++ b/crates/test-files/fixtures/features/call_statement_with_args_2.fe @@ -1,10 +1,13 @@ -contract Foo: +contract Foo { baz: Map - fn assign(self, _ val: u256) -> u256: + fn assign(self, _ val: u256) -> u256 { self.baz[0] = val return val + } - pub fn bar(self) -> u256: + pub fn bar(self) -> u256 { self.assign(100) return self.baz[0] + } +} diff --git a/crates/test-files/fixtures/features/call_statement_without_args.fe b/crates/test-files/fixtures/features/call_statement_without_args.fe index 6647fb1e98..eade30b6e8 100644 --- a/crates/test-files/fixtures/features/call_statement_without_args.fe +++ b/crates/test-files/fixtures/features/call_statement_without_args.fe @@ -1,9 +1,12 @@ -contract Foo: +contract Foo { baz: Map - fn assign(self): + fn assign(self) { self.baz[0] = 100 + } - pub fn bar(self) -> u256: + pub fn bar(self) -> u256 { self.assign() return self.baz[0] + } +} diff --git a/crates/test-files/fixtures/features/cast_address_to_u256.fe b/crates/test-files/fixtures/features/cast_address_to_u256.fe index 69f59704ef..5ab657613b 100644 --- a/crates/test-files/fixtures/features/cast_address_to_u256.fe +++ b/crates/test-files/fixtures/features/cast_address_to_u256.fe @@ -1,4 +1,6 @@ -contract Foo: - pub fn bar(a: address) -> address: - let x: u256 = u256(a) - return address(x) +contract Foo { + pub fn bar(a: address) -> address { + let x: u256 = u256(a) + return address(x) + } +} diff --git a/crates/test-files/fixtures/features/checked_arithmetic.fe b/crates/test-files/fixtures/features/checked_arithmetic.fe index 25b3975d6d..fd762e3326 100644 --- a/crates/test-files/fixtures/features/checked_arithmetic.fe +++ b/crates/test-files/fixtures/features/checked_arithmetic.fe @@ -1,217 +1,289 @@ -contract CheckedArithmetic: - - pub fn add_u256(left: u256, right: u256) -> u256: +contract CheckedArithmetic { + pub fn add_u256(left: u256, right: u256) -> u256 { return left + right + } - pub fn add_u128(left: u128, right: u128) -> u128: + pub fn add_u128(left: u128, right: u128) -> u128 { return left + right + } - pub fn add_u64(left: u64, right: u64) -> u64: + pub fn add_u64(left: u64, right: u64) -> u64 { return left + right + } - pub fn add_u32(left: u32, right: u32) -> u32: + pub fn add_u32(left: u32, right: u32) -> u32 { return left + right + } - pub fn add_u16(left: u16, right: u16) -> u16: + pub fn add_u16(left: u16, right: u16) -> u16 { return left + right + } - pub fn add_u8(left: u8, right: u8) -> u8: + pub fn add_u8(left: u8, right: u8) -> u8 { return left + right + } - pub fn add_i256(left: i256, right: i256) -> i256: + pub fn add_i256(left: i256, right: i256) -> i256 { return left + right + } - pub fn add_i128(left: i128, right: i128) -> i128: + pub fn add_i128(left: i128, right: i128) -> i128 { return left + right + } - pub fn add_i64(left: i64, right: i64) -> i64: + pub fn add_i64(left: i64, right: i64) -> i64 { return left + right + } - pub fn add_i32(left: i32, right: i32) -> i32: + pub fn add_i32(left: i32, right: i32) -> i32 { return left + right + } - pub fn add_i16(left: i16, right: i16) -> i16: + pub fn add_i16(left: i16, right: i16) -> i16 { return left + right + } - pub fn add_i8(left: i8, right: i8) -> i8: + pub fn add_i8(left: i8, right: i8) -> i8 { return left + right + } - pub fn sub_u256(left: u256, right: u256) -> u256: + pub fn sub_u256(left: u256, right: u256) -> u256 { return left - right + } - pub fn sub_u128(left: u128, right: u128) -> u128: + pub fn sub_u128(left: u128, right: u128) -> u128 { return left - right + } - pub fn sub_u64(left: u64, right: u64) -> u64: + pub fn sub_u64(left: u64, right: u64) -> u64 { return left - right + } - pub fn sub_u32(left: u32, right: u32) -> u32: + pub fn sub_u32(left: u32, right: u32) -> u32 { return left - right + } - pub fn sub_u16(left: u16, right: u16) -> u16: + pub fn sub_u16(left: u16, right: u16) -> u16 { return left - right + } - pub fn sub_u8(left: u8, right: u8) -> u8: + pub fn sub_u8(left: u8, right: u8) -> u8 { return left - right + } - pub fn sub_i256(left: i256, right: i256) -> i256: + pub fn sub_i256(left: i256, right: i256) -> i256 { return left - right + } - pub fn sub_i128(left: i128, right: i128) -> i128: + pub fn sub_i128(left: i128, right: i128) -> i128 { return left - right + } - pub fn sub_i64(left: i64, right: i64) -> i64: + pub fn sub_i64(left: i64, right: i64) -> i64 { return left - right + } - pub fn sub_i32(left: i32, right: i32) -> i32: + pub fn sub_i32(left: i32, right: i32) -> i32 { return left - right + } - pub fn sub_i16(left: i16, right: i16) -> i16: + pub fn sub_i16(left: i16, right: i16) -> i16 { return left - right + } - pub fn sub_i8(left: i8, right: i8) -> i8: + pub fn sub_i8(left: i8, right: i8) -> i8 { return left - right + } - pub fn div_u256(left: u256, right: u256) -> u256: + pub fn div_u256(left: u256, right: u256) -> u256 { return left / right + } - pub fn div_u128(left: u128, right: u128) -> u128: + pub fn div_u128(left: u128, right: u128) -> u128 { return left / right + } - pub fn div_u64(left: u64, right: u64) -> u64: + pub fn div_u64(left: u64, right: u64) -> u64 { return left / right + } - pub fn div_u32(left: u32, right: u32) -> u32: + pub fn div_u32(left: u32, right: u32) -> u32 { return left / right + } - pub fn div_u16(left: u16, right: u16) -> u16: + pub fn div_u16(left: u16, right: u16) -> u16 { return left / right + } - pub fn div_u8(left: u8, right: u8) -> u8: + pub fn div_u8(left: u8, right: u8) -> u8 { return left / right + } - pub fn div_i256(left: i256, right: i256) -> i256: + pub fn div_i256(left: i256, right: i256) -> i256 { return left / right + } - pub fn div_i128(left: i128, right: i128) -> i128: + pub fn div_i128(left: i128, right: i128) -> i128 { return left / right + } - pub fn div_i64(left: i64, right: i64) -> i64: + pub fn div_i64(left: i64, right: i64) -> i64 { return left / right + } - pub fn div_i32(left: i32, right: i32) -> i32: + pub fn div_i32(left: i32, right: i32) -> i32 { return left / right + } - pub fn div_i16(left: i16, right: i16) -> i16: + pub fn div_i16(left: i16, right: i16) -> i16 { return left / right + } - pub fn div_i8(left: i8, right: i8) -> i8: + pub fn div_i8(left: i8, right: i8) -> i8 { return left / right + } - pub fn mul_u256(left: u256, right: u256) -> u256: + pub fn mul_u256(left: u256, right: u256) -> u256 { return left * right + } - pub fn mul_u128(left: u128, right: u128) -> u128: + pub fn mul_u128(left: u128, right: u128) -> u128 { return left * right + } - pub fn mul_u64(left: u64, right: u64) -> u64: + pub fn mul_u64(left: u64, right: u64) -> u64 { return left * right + } - pub fn mul_u32(left: u32, right: u32) -> u32: + pub fn mul_u32(left: u32, right: u32) -> u32 { return left * right + } - pub fn mul_u16(left: u16, right: u16) -> u16: + pub fn mul_u16(left: u16, right: u16) -> u16 { return left * right + } - pub fn mul_u8(left: u8, right: u8) -> u8: + pub fn mul_u8(left: u8, right: u8) -> u8 { return left * right + } - pub fn mul_i256(left: i256, right: i256) -> i256: + pub fn mul_i256(left: i256, right: i256) -> i256 { return left * right + } - pub fn mul_i128(left: i128, right: i128) -> i128: + pub fn mul_i128(left: i128, right: i128) -> i128 { return left * right + } - pub fn mul_i64(left: i64, right: i64) -> i64: + pub fn mul_i64(left: i64, right: i64) -> i64 { return left * right + } - pub fn mul_i32(left: i32, right: i32) -> i32: + pub fn mul_i32(left: i32, right: i32) -> i32 { return left * right + } - pub fn mul_i16(left: i16, right: i16) -> i16: + pub fn mul_i16(left: i16, right: i16) -> i16 { return left * right + } - pub fn mul_i8(left: i8, right: i8) -> i8: + pub fn mul_i8(left: i8, right: i8) -> i8 { return left * right + } - pub fn mod_u256(left: u256, right: u256) -> u256: + pub fn mod_u256(left: u256, right: u256) -> u256 { return left % right + } - pub fn mod_u128(left: u128, right: u128) -> u128: + pub fn mod_u128(left: u128, right: u128) -> u128 { return left % right + } - pub fn mod_u64(left: u64, right: u64) -> u64: + pub fn mod_u64(left: u64, right: u64) -> u64 { return left % right + } - pub fn mod_u32(left: u32, right: u32) -> u32: + pub fn mod_u32(left: u32, right: u32) -> u32 { return left % right + } - pub fn mod_u16(left: u16, right: u16) -> u16: + pub fn mod_u16(left: u16, right: u16) -> u16 { return left % right + } - pub fn mod_u8(left: u8, right: u8) -> u8: + pub fn mod_u8(left: u8, right: u8) -> u8 { return left % right + } - pub fn mod_i256(left: i256, right: i256) -> i256: + pub fn mod_i256(left: i256, right: i256) -> i256 { return left % right + } - pub fn mod_i128(left: i128, right: i128) -> i128: + pub fn mod_i128(left: i128, right: i128) -> i128 { return left % right + } - pub fn mod_i64(left: i64, right: i64) -> i64: + pub fn mod_i64(left: i64, right: i64) -> i64 { return left % right + } - pub fn mod_i32(left: i32, right: i32) -> i32: + pub fn mod_i32(left: i32, right: i32) -> i32 { return left % right + } - pub fn mod_i16(left: i16, right: i16) -> i16: + pub fn mod_i16(left: i16, right: i16) -> i16 { return left % right + } - pub fn mod_i8(left: i8, right: i8) -> i8: + pub fn mod_i8(left: i8, right: i8) -> i8 { return left % right + } - pub fn pow_u256(left: u256, right: u256) -> u256: + pub fn pow_u256(left: u256, right: u256) -> u256 { return left ** right + } - pub fn pow_u128(left: u128, right: u128) -> u128: + pub fn pow_u128(left: u128, right: u128) -> u128 { return left ** right + } - pub fn pow_u64(left: u64, right: u64) -> u64: + pub fn pow_u64(left: u64, right: u64) -> u64 { return left ** right + } - pub fn pow_u32(left: u32, right: u32) -> u32: + pub fn pow_u32(left: u32, right: u32) -> u32 { return left ** right + } - pub fn pow_u16(left: u16, right: u16) -> u16: + pub fn pow_u16(left: u16, right: u16) -> u16 { return left ** right + } - pub fn pow_u8(left: u8, right: u8) -> u8: + pub fn pow_u8(left: u8, right: u8) -> u8 { return left ** right + } - pub fn pow_i256(left: i256, right: u256) -> i256: + pub fn pow_i256(left: i256, right: u256) -> i256 { return left ** right + } - pub fn pow_i128(left: i128, right: u128) -> i128: + pub fn pow_i128(left: i128, right: u128) -> i128 { return left ** right + } - pub fn pow_i64(left: i64, right: u64) -> i64: + pub fn pow_i64(left: i64, right: u64) -> i64 { return left ** right + } - pub fn pow_i32(left: i32, right: u32) -> i32: + pub fn pow_i32(left: i32, right: u32) -> i32 { return left ** right + } - pub fn pow_i16(left: i16, right: u16) -> i16: + pub fn pow_i16(left: i16, right: u16) -> i16 { return left ** right + } - pub fn pow_i8(left: i8, right: u8) -> i8: - return left ** right \ No newline at end of file + pub fn pow_i8(left: i8, right: u8) -> i8 { + return left ** right + } +} diff --git a/crates/test-files/fixtures/features/const_generics.fe b/crates/test-files/fixtures/features/const_generics.fe index 46508a062b..b3773c51e1 100644 --- a/crates/test-files/fixtures/features/const_generics.fe +++ b/crates/test-files/fixtures/features/const_generics.fe @@ -1,15 +1,15 @@ -contract Foo: - pub fn bar(): +contract Foo { + pub fn bar() { # const generics with literal. let array_lit: Array let array_lit2: Array # const generics with ternary expression. let array_ternary: Array - + # const generics with logical expression. - let array_logical_or: Array - let array_logical_and: Array + let array_logical_or: Array + let array_logical_and: Array # const generics with binary expression. let array_add: Array @@ -35,12 +35,14 @@ contract Foo: let array_gt2: Array 10 else 8 }> let array_gte: Array= 10 else 8 }> let array_gte2: Array= 10 else 0 }> - + # const generics with unary expression. let array_not: Array - + # const generics with const variable. const DOUBLE_ARRAY_LENGTH: u64 = 16 const TWO: u64 = 2 - let array_with_const: Array \ No newline at end of file + let array_with_const: Array + } +} \ No newline at end of file diff --git a/crates/test-files/fixtures/features/const_local.fe b/crates/test-files/fixtures/features/const_local.fe index 2967c5af4e..1800710820 100644 --- a/crates/test-files/fixtures/features/const_local.fe +++ b/crates/test-files/fixtures/features/const_local.fe @@ -1,5 +1,5 @@ -contract Foo: - pub fn bar() -> u256: +contract Foo { + pub fn bar() -> u256 { const C1: i64 = 1 const C2: i64 = 2 const C3: i64 = 10 @@ -12,4 +12,6 @@ contract Foo: const C9: bool = C8 < C7 # true const C10: u256 = 42 if C9 else 0 # 42 let _arr: Array - return C10 \ No newline at end of file + return C10 + } +} diff --git a/crates/test-files/fixtures/features/constructor.fe b/crates/test-files/fixtures/features/constructor.fe index aa3914154e..03a7af61d5 100644 --- a/crates/test-files/fixtures/features/constructor.fe +++ b/crates/test-files/fixtures/features/constructor.fe @@ -1,8 +1,11 @@ -contract Foo: +contract Foo { bar: Map - pub fn __init__(self, baz: u256, bing: u256): + pub fn __init__(self, baz: u256, bing: u256) { self.bar[42] = baz + bing + } - pub fn read_bar(self) -> u256: - return self.bar[42] \ No newline at end of file + pub fn read_bar(self) -> u256 { + return self.bar[42] + } +} diff --git a/crates/test-files/fixtures/features/create2_contract.fe b/crates/test-files/fixtures/features/create2_contract.fe index 78de6b168d..a66c301703 100644 --- a/crates/test-files/fixtures/features/create2_contract.fe +++ b/crates/test-files/fixtures/features/create2_contract.fe @@ -1,11 +1,14 @@ use std::context::Context -contract Foo: - pub fn get_my_num() -> u256: +contract Foo { + pub fn get_my_num() -> u256 { return 42 + } +} -contract FooFactory: - pub fn create2_foo(ctx: Context) -> address: - # value and salt +contract FooFactory { + pub fn create2_foo(ctx: Context) -> address { let foo: Foo = Foo.create2(ctx, 0, 52) return address(foo) + } +} diff --git a/crates/test-files/fixtures/features/create_contract.fe b/crates/test-files/fixtures/features/create_contract.fe index d41550a990..84474819aa 100644 --- a/crates/test-files/fixtures/features/create_contract.fe +++ b/crates/test-files/fixtures/features/create_contract.fe @@ -1,10 +1,14 @@ use std::context::Context -contract Foo: - pub fn get_my_num() -> u256: +contract Foo { + pub fn get_my_num() -> u256 { return 42 + } +} -contract FooFactory: - pub fn create_foo(ctx: Context) -> address: +contract FooFactory { + pub fn create_foo(ctx: Context) -> address { let foo: Foo = Foo.create(ctx, 0) return address(foo) + } +} diff --git a/crates/test-files/fixtures/features/create_contract_from_init.fe b/crates/test-files/fixtures/features/create_contract_from_init.fe index 2caf4e7c1e..72d1a7daad 100644 --- a/crates/test-files/fixtures/features/create_contract_from_init.fe +++ b/crates/test-files/fixtures/features/create_contract_from_init.fe @@ -1,14 +1,19 @@ use std::context::Context -contract Foo: - pub fn get_my_num() -> u256: +contract Foo { + pub fn get_my_num() -> u256 { return 42 + } +} -contract FooFactory: +contract FooFactory { foo_addr: address - pub fn __init__(self, ctx: Context): + pub fn __init__(self, ctx: Context) { self.foo_addr = address(Foo.create(ctx, 0)) + } - pub fn get_foo_addr(self) -> address: - return self.foo_addr \ No newline at end of file + pub fn get_foo_addr(self) -> address { + return self.foo_addr + } +} diff --git a/crates/test-files/fixtures/features/ctx_init_in_call.fe b/crates/test-files/fixtures/features/ctx_init_in_call.fe index 69c5c52644..5005fc4181 100644 --- a/crates/test-files/fixtures/features/ctx_init_in_call.fe +++ b/crates/test-files/fixtures/features/ctx_init_in_call.fe @@ -1,16 +1,17 @@ use std::context::Context use std::evm -contract Foo: - - pub fn __call__(): - unsafe: +contract Foo { + pub fn __call__() { + unsafe { let ctx: Context = Context() let value: u256 = u256(bar(ctx)) - - # return `value` evm::mstore(offset: 0, value) evm::return_mem(offset: 0, len: 32) + } + } - fn bar(ctx: Context) -> address: + fn bar(ctx: Context) -> address { return ctx.self_address() + } +} diff --git a/crates/test-files/fixtures/features/ctx_param_external_func_call.fe b/crates/test-files/fixtures/features/ctx_param_external_func_call.fe index 482cca6d32..c4e6e7c43b 100644 --- a/crates/test-files/fixtures/features/ctx_param_external_func_call.fe +++ b/crates/test-files/fixtures/features/ctx_param_external_func_call.fe @@ -1,24 +1,26 @@ use std::context::Context -contract Foo: +contract Foo { my_num: u256 - pub fn baz(ctx: Context) -> u256: + pub fn baz(ctx: Context) -> u256 { return ctx.block_number() + } - pub fn bing(self, _ new_num: u256) -> u256: + pub fn bing(self, _ new_num: u256) -> u256 { self.my_num = new_num return self.my_num + } +} - -contract Bar: - - pub fn call_baz(ctx: Context, foo_addr: address) -> u256: - # let foo = ctx.load(foo_addr) +contract Bar { + pub fn call_baz(ctx: Context, foo_addr: address) -> u256 { let foo: Foo = Foo(ctx, foo_addr) return foo.baz() + } - pub fn call_bing(ctx: Context) -> u256: - # let foo = ctx.create(0) + pub fn call_bing(ctx: Context) -> u256 { let foo: Foo = Foo.create(ctx, 0) return foo.bing(42) + } +} diff --git a/crates/test-files/fixtures/features/ctx_param_internal_func_call.fe b/crates/test-files/fixtures/features/ctx_param_internal_func_call.fe index fe130749a5..f2f7712088 100644 --- a/crates/test-files/fixtures/features/ctx_param_internal_func_call.fe +++ b/crates/test-files/fixtures/features/ctx_param_internal_func_call.fe @@ -1,13 +1,14 @@ use std::context::Context -contract Foo: +contract Foo { is_true: bool - pub fn bar(self, ctx: Context) -> u256: - # do something with self + pub fn bar(self, ctx: Context) -> u256 { self.is_true = false - return baz(ctx) + } - fn baz(ctx: Context) -> u256: - return ctx.block_number() \ No newline at end of file + fn baz(ctx: Context) -> u256 { + return ctx.block_number() + } +} diff --git a/crates/test-files/fixtures/features/ctx_param_simple.fe b/crates/test-files/fixtures/features/ctx_param_simple.fe index 305c3cac32..b46f70f081 100644 --- a/crates/test-files/fixtures/features/ctx_param_simple.fe +++ b/crates/test-files/fixtures/features/ctx_param_simple.fe @@ -1,6 +1,7 @@ use std::context::Context -contract Foo: - pub fn bar(self, ctx: Context) -> u256: - # TODO: add missing self access check - return ctx.block_number() \ No newline at end of file +contract Foo { + pub fn bar(self, ctx: Context) -> u256 { + return ctx.block_number() + } +} diff --git a/crates/test-files/fixtures/features/empty.fe b/crates/test-files/fixtures/features/empty.fe index 2dd735eac7..08732e586b 100644 --- a/crates/test-files/fixtures/features/empty.fe +++ b/crates/test-files/fixtures/features/empty.fe @@ -1,2 +1,3 @@ -contract Empty: - lonely: u256 \ No newline at end of file +contract Empty { + lonely: u256 +} diff --git a/crates/test-files/fixtures/features/events.fe b/crates/test-files/fixtures/features/events.fe index 01ea0f38f4..453ac576a6 100644 --- a/crates/test-files/fixtures/features/events.fe +++ b/crates/test-files/fixtures/features/events.fe @@ -1,34 +1,43 @@ use std::context::Context -contract Foo: - event Nums: +contract Foo { + event Nums { idx num1: u256 num2: u256 + } - event Bases: + event Bases { num: u256 addr: address + } - event Mix: + event Mix { num1: u256 idx addr: address num2: u256 my_bytes: Array + } - event Addresses: + event Addresses { addrs: Array + } - pub fn emit_nums(ctx: Context): + pub fn emit_nums(ctx: Context) { emit Nums(ctx, num1: 26, num2: 42) + } - pub fn emit_bases(ctx: Context, addr: address): + pub fn emit_bases(ctx: Context, addr: address) { emit Bases(ctx, num: 26, addr) + } - pub fn emit_mix(ctx: Context, addr: address, my_bytes: Array): + pub fn emit_mix(ctx: Context, addr: address, my_bytes: Array) { emit Mix(ctx, num1: 26, addr, num2: 42, my_bytes) + } - pub fn emit_addresses(ctx: Context, addr1: address, addr2: address): + pub fn emit_addresses(ctx: Context, addr1: address, addr2: address) { let addrs: Array addrs[0] = addr1 addrs[1] = addr2 - emit Addresses(ctx, addrs) \ No newline at end of file + emit Addresses(ctx, addrs) + } +} diff --git a/crates/test-files/fixtures/features/external_contract.fe b/crates/test-files/fixtures/features/external_contract.fe index a46468dbdb..9a04e61aa9 100644 --- a/crates/test-files/fixtures/features/external_contract.fe +++ b/crates/test-files/fixtures/features/external_contract.fe @@ -1,37 +1,33 @@ use std::context::Context -contract Foo: - event MyEvent: +contract Foo { + event MyEvent { my_num: u256 my_addrs: Array my_string: String<11> + } - pub fn emit_event(ctx: Context, my_num: u256, my_addrs: Array, my_string: String<11>): + pub fn emit_event(ctx: Context, my_num: u256, my_addrs: Array, my_string: String<11>) { emit MyEvent(ctx, my_num, my_addrs, my_string) + } - pub fn build_array(a: u256, b: u256) -> Array: + pub fn build_array(a: u256, b: u256) -> Array { let my_array: Array my_array[0] = a my_array[1] = a * b my_array[2] = b return my_array + } +} -contract FooProxy: - pub fn call_emit_event( - ctx: Context, - foo_address: address, - my_num: u256, - my_addrs: Array, - my_string: String<11> - ): +contract FooProxy { + pub fn call_emit_event(ctx: Context, foo_address: address, my_num: u256, my_addrs: Array, my_string: String<11>) { let foo: Foo = Foo(ctx, foo_address) foo.emit_event(my_num, my_addrs, my_string) + } - pub fn call_build_array( - ctx: Context, - foo_address: address, - a: u256, - b: u256, - ) -> Array: + pub fn call_build_array(ctx: Context, foo_address: address, a: u256, b: u256) -> Array { let foo: Foo = Foo(ctx, foo_address) return foo.build_array(a, b) + } +} diff --git a/crates/test-files/fixtures/features/for_loop_with_break.fe b/crates/test-files/fixtures/features/for_loop_with_break.fe index d68f11902e..25d20b5fb3 100644 --- a/crates/test-files/fixtures/features/for_loop_with_break.fe +++ b/crates/test-files/fixtures/features/for_loop_with_break.fe @@ -1,13 +1,16 @@ -contract Foo: - - pub fn bar() -> u256: +contract Foo { + pub fn bar() -> u256 { let my_array: Array my_array[0] = 5 my_array[1] = 10 my_array[2] = 15 let sum: u256 = 0 - for i in my_array: + for i in my_array { sum = sum + i - if sum == 15: + if sum == 15 { break - return sum \ No newline at end of file + } + } + return sum + } +} diff --git a/crates/test-files/fixtures/features/for_loop_with_continue.fe b/crates/test-files/fixtures/features/for_loop_with_continue.fe index aef9e407ae..b946482371 100644 --- a/crates/test-files/fixtures/features/for_loop_with_continue.fe +++ b/crates/test-files/fixtures/features/for_loop_with_continue.fe @@ -1,6 +1,5 @@ -contract Foo: - - pub fn bar() -> u256: +contract Foo { + pub fn bar() -> u256 { let my_array: Array my_array[0] = 2 my_array[1] = 3 @@ -8,8 +7,12 @@ contract Foo: my_array[3] = 6 my_array[4] = 9 let sum: u256 = 0 - for i in my_array: - if i % 2 == 0: + for i in my_array { + if i % 2 == 0 { continue + } sum = sum + i - return sum \ No newline at end of file + } + return sum + } +} diff --git a/crates/test-files/fixtures/features/for_loop_with_static_array.fe b/crates/test-files/fixtures/features/for_loop_with_static_array.fe index 07fce27bdf..632df0dfa5 100644 --- a/crates/test-files/fixtures/features/for_loop_with_static_array.fe +++ b/crates/test-files/fixtures/features/for_loop_with_static_array.fe @@ -1,11 +1,13 @@ -contract Foo: - - pub fn bar() -> u256: +contract Foo { + pub fn bar() -> u256 { let my_array: Array my_array[0] = 5 my_array[1] = 10 my_array[2] = 15 let sum: u256 = 0 - for i in my_array: + for i in my_array { sum = sum + i - return sum \ No newline at end of file + } + return sum + } +} diff --git a/crates/test-files/fixtures/features/for_loop_with_static_array_from_sto.fe b/crates/test-files/fixtures/features/for_loop_with_static_array_from_sto.fe index e7bf2d496c..901a5fd0bc 100644 --- a/crates/test-files/fixtures/features/for_loop_with_static_array_from_sto.fe +++ b/crates/test-files/fixtures/features/for_loop_with_static_array_from_sto.fe @@ -1,10 +1,12 @@ -contract Foo: +contract Foo { my_array: Array - pub fn bar(self) -> u256: - self.my_array = [1,2,3] + pub fn bar(self) -> u256 { + self.my_array = [1, 2, 3] let sum: u256 = 0 - for i in self.my_array.to_mem(): + for i in self.my_array.to_mem() { sum = sum + i - - return sum \ No newline at end of file + } + return sum + } +} diff --git a/crates/test-files/fixtures/features/if_statement.fe b/crates/test-files/fixtures/features/if_statement.fe index b853b2f6fc..72d037c5c6 100644 --- a/crates/test-files/fixtures/features/if_statement.fe +++ b/crates/test-files/fixtures/features/if_statement.fe @@ -1,7 +1,9 @@ -contract Foo: - - pub fn bar(input: u256) -> u256: - if input > 5: +contract Foo { + pub fn bar(input: u256) -> u256 { + if input > 5 { return 1 - else: + } else { return 0 + } + } +} diff --git a/crates/test-files/fixtures/features/if_statement_2.fe b/crates/test-files/fixtures/features/if_statement_2.fe index f38ad4f10a..1c1cd513a5 100644 --- a/crates/test-files/fixtures/features/if_statement_2.fe +++ b/crates/test-files/fixtures/features/if_statement_2.fe @@ -1,9 +1,10 @@ -contract Foo: - - pub fn bar(val: u256) -> u256: - if val > 5: +contract Foo { + pub fn bar(val: u256) -> u256 { + if val > 5 { return 1 - else: + } else { assert true - + } return 0 + } +} diff --git a/crates/test-files/fixtures/features/if_statement_test_from_sto.fe b/crates/test-files/fixtures/features/if_statement_test_from_sto.fe index e94633369f..6bda2ec697 100644 --- a/crates/test-files/fixtures/features/if_statement_test_from_sto.fe +++ b/crates/test-files/fixtures/features/if_statement_test_from_sto.fe @@ -1,20 +1,21 @@ -contract Foo: +contract Foo { my_bool1: bool my_bool2: bool my_bool3: bool - pub fn bar(self) -> u256: + pub fn bar(self) -> u256 { self.my_bool1 = false self.my_bool2 = false self.my_bool3 = true - - if self.my_bool1: + if self.my_bool1 { return 26 - - if self.my_bool2: + } + if self.my_bool2 { return 26 - - if self.my_bool3: + } + if self.my_bool3 { return 42 - - return 26 \ No newline at end of file + } + return 26 + } +} diff --git a/crates/test-files/fixtures/features/if_statement_with_block_declaration.fe b/crates/test-files/fixtures/features/if_statement_with_block_declaration.fe index 97761bf299..fbd519ad9d 100644 --- a/crates/test-files/fixtures/features/if_statement_with_block_declaration.fe +++ b/crates/test-files/fixtures/features/if_statement_with_block_declaration.fe @@ -1,9 +1,11 @@ -contract Foo: - - pub fn bar() -> u256: - if true: +contract Foo { + pub fn bar() -> u256 { + if true { let y: u256 = 1 return y - else: + } else { let y: u256 = 1 - return y \ No newline at end of file + return y + } + } +} diff --git a/crates/test-files/fixtures/features/int_literal_coercion.fe b/crates/test-files/fixtures/features/int_literal_coercion.fe index 31fa4ce2e6..c837a08ae0 100644 --- a/crates/test-files/fixtures/features/int_literal_coercion.fe +++ b/crates/test-files/fixtures/features/int_literal_coercion.fe @@ -1,6 +1,8 @@ -contract Foo: - pub fn bar() -> u32: +contract Foo { + pub fn bar() -> u32 { let c: u32 = 30 c = 300 let d: (u128, u64, u32) = (100, 200, c) return d.item2 + } +} diff --git a/crates/test-files/fixtures/features/intrinsics.fe b/crates/test-files/fixtures/features/intrinsics.fe index f560b426fe..ddbf835af8 100644 --- a/crates/test-files/fixtures/features/intrinsics.fe +++ b/crates/test-files/fixtures/features/intrinsics.fe @@ -1,95 +1,140 @@ - -contract Intrinsics: - - pub fn add(x: u256, y: u256) -> u256: - unsafe: - return __add(x, y) - - pub fn gas() -> u256: - unsafe: - return __gas() - - pub fn addr() -> address: - unsafe: - return address(__address()) - - pub fn self_balance() -> u256: - unsafe: - return __selfbalance() - - pub fn other_balance(a: u256) -> u256: - unsafe: - return __balance(a) - - pub fn caller() -> address: - unsafe: - return address(__caller()) - - pub fn callvalue() -> u256: - unsafe: - return __callvalue() - - pub fn calldataload(offset: u256) -> u256: - unsafe: - return __calldataload(offset) - - pub fn calldatasize() -> u256: - unsafe: - return __calldatasize() - - pub fn calldatacopy(offset: u256, len: u256) -> u256: - unsafe: - __calldatacopy(0, offset, len) - return __mload(0) - - pub fn codesize() -> u256: - unsafe: - return __codesize() - - pub fn extcodesize(addr: u256) -> u256: - unsafe: - return __extcodesize(addr) - - pub fn extcodehash(addr: u256) -> u256: - unsafe: - return __extcodehash(addr) - - pub fn chainid() -> u256: - unsafe: - return __chainid() - - pub fn basefee() -> u256: - unsafe: - return __basefee() - - pub fn origin() -> u256: - unsafe: - return __origin() - - pub fn gasprice() -> u256: - unsafe: - return __gasprice() - - pub fn blockhash(n: u256) -> u256: - unsafe: - return __blockhash(n) - - pub fn coinbase() -> u256: - unsafe: - return __coinbase() - - pub fn timestamp() -> u256: - unsafe: - return __timestamp() - - pub fn number() -> u256: - unsafe: - return __number() - - pub fn difficulty() -> u256: - unsafe: - return __difficulty() - - pub fn gaslimit() -> u256: - unsafe: - return __gaslimit() +contract Intrinsics { + pub fn add(x: u256, y: u256) -> u256 { + unsafe { + return __add(x, y) + } + } + + pub fn gas() -> u256 { + unsafe { + return __gas() + } + } + + pub fn addr() -> address { + unsafe { + return address(__address()) + } + } + + pub fn self_balance() -> u256 { + unsafe { + return __selfbalance() + } + } + + pub fn other_balance(a: u256) -> u256 { + unsafe { + return __balance(a) + } + } + + pub fn caller() -> address { + unsafe { + return address(__caller()) + } + } + + pub fn callvalue() -> u256 { + unsafe { + return __callvalue() + } + } + + pub fn calldataload(offset: u256) -> u256 { + unsafe { + return __calldataload(offset) + } + } + + pub fn calldatasize() -> u256 { + unsafe { + return __calldatasize() + } + } + + pub fn calldatacopy(offset: u256, len: u256) -> u256 { + unsafe { + __calldatacopy(0, offset, len) + return __mload(0) + } + } + + pub fn codesize() -> u256 { + unsafe { + return __codesize() + } + } + + pub fn extcodesize(addr: u256) -> u256 { + unsafe { + return __extcodesize(addr) + } + } + + pub fn extcodehash(addr: u256) -> u256 { + unsafe { + return __extcodehash(addr) + } + } + + pub fn chainid() -> u256 { + unsafe { + return __chainid() + } + } + + pub fn basefee() -> u256 { + unsafe { + return __basefee() + } + } + + pub fn origin() -> u256 { + unsafe { + return __origin() + } + } + + pub fn gasprice() -> u256 { + unsafe { + return __gasprice() + } + } + + pub fn blockhash(n: u256) -> u256 { + unsafe { + return __blockhash(n) + } + } + + pub fn coinbase() -> u256 { + unsafe { + return __coinbase() + } + } + + pub fn timestamp() -> u256 { + unsafe { + return __timestamp() + } + } + + pub fn number() -> u256 { + unsafe { + return __number() + } + } + + pub fn difficulty() -> u256 { + unsafe { + return __difficulty() + } + } + + pub fn gaslimit() -> u256 { + unsafe { + return __gaslimit() + } + } +} diff --git a/crates/test-files/fixtures/features/keccak.fe b/crates/test-files/fixtures/features/keccak.fe index a80b8b7b32..16d8dedce2 100644 --- a/crates/test-files/fixtures/features/keccak.fe +++ b/crates/test-files/fixtures/features/keccak.fe @@ -1,10 +1,13 @@ -contract Keccak: - - pub fn return_hash_from_u8(val: Array) -> u256: +contract Keccak { + pub fn return_hash_from_u8(val: Array) -> u256 { return keccak256(val) + } - pub fn return_hash_from_foo(val: Array) -> u256: + pub fn return_hash_from_foo(val: Array) -> u256 { return keccak256(val) + } - pub fn return_hash_from_u256(val: Array) -> u256: + pub fn return_hash_from_u256(val: Array) -> u256 { return keccak256(val) + } +} diff --git a/crates/test-files/fixtures/features/map_tuple.fe b/crates/test-files/fixtures/features/map_tuple.fe index 7697786c86..62341dd14c 100644 --- a/crates/test-files/fixtures/features/map_tuple.fe +++ b/crates/test-files/fixtures/features/map_tuple.fe @@ -1,6 +1,8 @@ -contract Foo: +contract Foo { tuples: Map - pub fn bar(self, x: u256) -> u256: + pub fn bar(self, x: u256) -> u256 { self.tuples[0] = (address(100), x) return self.tuples[0].item1 + } +} diff --git a/crates/test-files/fixtures/features/math.fe b/crates/test-files/fixtures/features/math.fe index 427926cfae..a6499b5238 100644 --- a/crates/test-files/fixtures/features/math.fe +++ b/crates/test-files/fixtures/features/math.fe @@ -1,17 +1,20 @@ -contract Math: - - # https://github.com/Uniswap/uniswap-v2-core/blob/4dd59067c76dea4a0e8e4bfdda41877a6b16dedc/contracts/libraries/Math.sol#L11-L22 - pub fn sqrt(val: u256) -> u256: +contract Math { + pub fn sqrt(val: u256) -> u256 { let z: u256 - if (val > 3): + if val > 3 { z = val let x: u256 = val / 2 + 1 - while (x < z): + while x < z { z = x x = (val / x + x) / 2 - elif (val != 0): + } + } else if val != 0 { z = 1 + } return z + } - pub fn min(x: u256, y: u256) -> u256: + pub fn min(x: u256, y: u256) -> u256 { return x if x < y else y + } +} diff --git a/crates/test-files/fixtures/features/module_const.fe b/crates/test-files/fixtures/features/module_const.fe index add9aa69d3..027f74caef 100644 --- a/crates/test-files/fixtures/features/module_const.fe +++ b/crates/test-files/fixtures/features/module_const.fe @@ -1,15 +1,16 @@ type MY_ARRAY = Array + const C1: i32 = 1 const C2: i32 = C1 * 3 const C3: i32 = C4 + 2 const C4: i32 = 42 -contract Foo: - fn bar() -> i32: +contract Foo { + fn bar() -> i32 { const LOCAL_CONST: i32 = C3 * 2 let _arr1: Array let _arr2: Array let _my_array: MY_ARRAY return C4 - - + } +} diff --git a/crates/test-files/fixtures/features/module_level_events.fe b/crates/test-files/fixtures/features/module_level_events.fe index a718d00070..96b59c943e 100644 --- a/crates/test-files/fixtures/features/module_level_events.fe +++ b/crates/test-files/fixtures/features/module_level_events.fe @@ -1,10 +1,13 @@ use std::context::Context -event Transfer: +event Transfer { idx sender: address idx receiver: address value: u256 +} -contract Foo: - fn transfer(ctx: Context, to : address, value : u256): - emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) \ No newline at end of file +contract Foo { + fn transfer(ctx: Context, to: address, value: u256) { + emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) + } +} diff --git a/crates/test-files/fixtures/features/multi_param.fe b/crates/test-files/fixtures/features/multi_param.fe index 48f064afe5..df5cd903b5 100644 --- a/crates/test-files/fixtures/features/multi_param.fe +++ b/crates/test-files/fixtures/features/multi_param.fe @@ -1,7 +1,9 @@ -contract Foo: - pub fn bar(x: u256, y: u256, z: u256) -> Array: +contract Foo { + pub fn bar(x: u256, y: u256, z: u256) -> Array { let my_array: Array my_array[0] = x my_array[1] = y my_array[2] = z return my_array + } +} diff --git a/crates/test-files/fixtures/features/nested_map.fe b/crates/test-files/fixtures/features/nested_map.fe index 1b6e0145a2..1271b748a2 100644 --- a/crates/test-files/fixtures/features/nested_map.fe +++ b/crates/test-files/fixtures/features/nested_map.fe @@ -1,15 +1,20 @@ -contract Foo: +contract Foo { bar: Map> baz: Map> - pub fn read_bar(self, a: address, b: address) -> u256: + pub fn read_bar(self, a: address, b: address) -> u256 { return self.bar[a][b] + } - pub fn write_bar(self, a: address, b: address, value: u256): + pub fn write_bar(self, a: address, b: address, value: u256) { self.bar[a][b] = value + } - pub fn read_baz(self, a: address, b: u256) -> bool: + pub fn read_baz(self, a: address, b: u256) -> bool { return self.baz[a][b] + } - pub fn write_baz(self, a: address, b: u256, value: bool): + pub fn write_baz(self, a: address, b: u256, value: bool) { self.baz[a][b] = value + } +} diff --git a/crates/test-files/fixtures/features/numeric_casts.fe b/crates/test-files/fixtures/features/numeric_casts.fe index 50e5f72639..34f5a84c7b 100644 --- a/crates/test-files/fixtures/features/numeric_casts.fe +++ b/crates/test-files/fixtures/features/numeric_casts.fe @@ -1,24 +1,12 @@ -contract Foo: - - pub fn bar(): - - # Fe doesn't allow casting from i8 to u16 directly because depending on the order - # in which sign and size are changed one does arrive at a different value as the - # following code demonstrates. - # This is in line with Solidity: https://docs.soliditylang.org/en/latest/080-breaking-changes.html#new-restrictions - # - # Notice that Rust does allow the transition in one - # step and apparently size is changed before the sign: - # https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cfc82437a365ca1f534a40f5182bd1e2 - +contract Foo { + pub fn bar() { let a: i8 = i8(-1) let a1: i16 = i16(a) let a2: u16 = u16(a1) - assert a2 == u16(65535) - let b: i8 = i8(-1) let b1: u8 = u8(b) let b2: u16 = u16(b1) - - assert b2 == u16(255) \ No newline at end of file + assert b2 == u16(255) + } +} diff --git a/crates/test-files/fixtures/features/numeric_sizes.fe b/crates/test-files/fixtures/features/numeric_sizes.fe index 55aaa332d1..dedd08c6da 100644 --- a/crates/test-files/fixtures/features/numeric_sizes.fe +++ b/crates/test-files/fixtures/features/numeric_sizes.fe @@ -1,73 +1,97 @@ -contract Foo: - - pub fn get_u8_min() -> u8: +contract Foo { + pub fn get_u8_min() -> u8 { return u8(0) + } - pub fn get_u16_min() -> u16: + pub fn get_u16_min() -> u16 { return u16(0) + } - pub fn get_u32_min() -> u32: + pub fn get_u32_min() -> u32 { return u32(0) + } - pub fn get_u64_min() -> u64: + pub fn get_u64_min() -> u64 { return u64(0) + } - pub fn get_u128_min() -> u128: + pub fn get_u128_min() -> u128 { return u128(0) + } - pub fn get_u256_min() -> u256: + pub fn get_u256_min() -> u256 { return u256(0) + } - pub fn get_i8_min() -> i8: + pub fn get_i8_min() -> i8 { return i8(-128) + } - pub fn get_i16_min() -> i16: + pub fn get_i16_min() -> i16 { return i16(-32768) + } - pub fn get_i32_min() -> i32: + pub fn get_i32_min() -> i32 { return i32(-2147483648) + } - pub fn get_i64_min() -> i64: + pub fn get_i64_min() -> i64 { return i64(-9223372036854775808) + } - pub fn get_i128_min() -> i128: + pub fn get_i128_min() -> i128 { return i128(-170141183460469231731687303715884105728) + } - pub fn get_i256_min() -> i256: + pub fn get_i256_min() -> i256 { return i256(-57896044618658097711785492504343953926634992332820282019728792003956564819968) + } - pub fn get_u8_max() -> u8: + pub fn get_u8_max() -> u8 { return u8(255) + } - pub fn get_u16_max() -> u16: + pub fn get_u16_max() -> u16 { return u16(65535) + } - pub fn get_u32_max() -> u32: + pub fn get_u32_max() -> u32 { return u32(4294967295) + } - pub fn get_u64_max() -> u64: + pub fn get_u64_max() -> u64 { return u64(18446744073709551615) + } - pub fn get_u128_max() -> u128: + pub fn get_u128_max() -> u128 { return u128(340282366920938463463374607431768211455) + } - pub fn get_u256_max() -> u256: + pub fn get_u256_max() -> u256 { return u256(115792089237316195423570985008687907853269984665640564039457584007913129639935) + } - pub fn get_i8_max() -> i8: + pub fn get_i8_max() -> i8 { return i8(127) + } - pub fn get_i16_max() -> i16: + pub fn get_i16_max() -> i16 { return i16(32767) + } - pub fn get_i32_max() -> i32: + pub fn get_i32_max() -> i32 { return i32(2147483647) + } - pub fn get_i64_max() -> i64: + pub fn get_i64_max() -> i64 { return i64(9223372036854775807) + } - pub fn get_i128_max() -> i128: + pub fn get_i128_max() -> i128 { return i128(170141183460469231731687303715884105727) + } - pub fn get_i256_max() -> i256: - return i256(57896044618658097711785492504343953926634992332820282019728792003956564819967) \ No newline at end of file + pub fn get_i256_max() -> i256 { + return i256(57896044618658097711785492504343953926634992332820282019728792003956564819967) + } +} diff --git a/crates/test-files/fixtures/features/ownable.fe b/crates/test-files/fixtures/features/ownable.fe index 22c7394221..fdc059c340 100644 --- a/crates/test-files/fixtures/features/ownable.fe +++ b/crates/test-files/fixtures/features/ownable.fe @@ -1,25 +1,31 @@ use std::context::Context -contract Ownable: - _owner: address +contract Ownable { + _owner: address - event OwnershipTransferred: - idx previousOwner: address - idx newOwner: address + event OwnershipTransferred { + idx previousOwner: address + idx newOwner: address + } - pub fn __init__(self, ctx: Context): - self._owner = ctx.msg_sender() + pub fn __init__(self, ctx: Context) { + self._owner = ctx.msg_sender() + } - pub fn owner(self) -> address: - return self._owner + pub fn owner(self) -> address { + return self._owner + } - pub fn renounceOwnership(self, ctx: Context): - assert ctx.msg_sender() == self._owner - self._owner = address(0) - emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) + pub fn renounceOwnership(self, ctx: Context) { + assert ctx.msg_sender() == self._owner + self._owner = address(0) + emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) + } - pub fn transferOwnership(self, ctx: Context, newOwner: address): - assert ctx.msg_sender() == self._owner - assert newOwner != address(0) - self._owner = newOwner - emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner) + pub fn transferOwnership(self, ctx: Context, newOwner: address) { + assert ctx.msg_sender() == self._owner + assert newOwner != address(0) + self._owner = newOwner + emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner) + } +} diff --git a/crates/test-files/fixtures/features/pure_fn.fe b/crates/test-files/fixtures/features/pure_fn.fe index d675392017..40213ccb09 100644 --- a/crates/test-files/fixtures/features/pure_fn.fe +++ b/crates/test-files/fixtures/features/pure_fn.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> u256: - return x + y \ No newline at end of file +contract Foo { + pub fn bar(x: u256, y: u256) -> u256 { + return x + y + } +} diff --git a/crates/test-files/fixtures/features/pure_fn_internal_call.fe b/crates/test-files/fixtures/features/pure_fn_internal_call.fe index f71155453f..ea72347dea 100644 --- a/crates/test-files/fixtures/features/pure_fn_internal_call.fe +++ b/crates/test-files/fixtures/features/pure_fn_internal_call.fe @@ -1,6 +1,9 @@ -contract Foo: - pub fn bar(self, x: u256, y: u256) -> u256: +contract Foo { + pub fn bar(self, x: u256, y: u256) -> u256 { return pure_bar(x, y) + } - pub fn pure_bar(x: u256, y: u256) -> u256: - return x + y \ No newline at end of file + pub fn pure_bar(x: u256, y: u256) -> u256 { + return x + y + } +} diff --git a/crates/test-files/fixtures/features/pure_fn_standalone.fe b/crates/test-files/fixtures/features/pure_fn_standalone.fe index 373f736e31..2b4f939a3f 100644 --- a/crates/test-files/fixtures/features/pure_fn_standalone.fe +++ b/crates/test-files/fixtures/features/pure_fn_standalone.fe @@ -1,20 +1,24 @@ - -fn add_bonus(_ x: u256) -> u256: +fn add_bonus(_ x: u256) -> u256 { return x + 10 +} -contract Foo: +contract Foo { cool_users: Map points: Map - fn add_points(self, _ user: address, _ val: u256): - if self.cool_users[user]: + fn add_points(self, _ user: address, _ val: u256) { + if self.cool_users[user] { self.points[user] += add_bonus(val) - else: + } else { self.points[user] += val + } + } - pub fn bar(self, _ x: u256) -> u256: + pub fn bar(self, _ x: u256) -> u256 { let a: address = address(x) self.add_points(a, 100) self.cool_users[a] = true self.add_points(a, 100) return self.points[a] + } +} diff --git a/crates/test-files/fixtures/features/radix_binary.fe b/crates/test-files/fixtures/features/radix_binary.fe index 661cdd2f9d..9585efe5df 100644 --- a/crates/test-files/fixtures/features/radix_binary.fe +++ b/crates/test-files/fixtures/features/radix_binary.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar() -> u8: +contract Foo { + pub fn bar() -> u8 { return u8(0b10) + } +} diff --git a/crates/test-files/fixtures/features/radix_hex.fe b/crates/test-files/fixtures/features/radix_hex.fe index 5036f04b42..0155f21dfb 100644 --- a/crates/test-files/fixtures/features/radix_hex.fe +++ b/crates/test-files/fixtures/features/radix_hex.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar() -> u8: +contract Foo { + pub fn bar() -> u8 { return u8(0xfe) + } +} diff --git a/crates/test-files/fixtures/features/radix_octal.fe b/crates/test-files/fixtures/features/radix_octal.fe index e97bd0b57b..1a54548984 100644 --- a/crates/test-files/fixtures/features/radix_octal.fe +++ b/crates/test-files/fixtures/features/radix_octal.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar() -> u8: +contract Foo { + pub fn bar() -> u8 { return u8(0o70) + } +} diff --git a/crates/test-files/fixtures/features/return_addition_i256.fe b/crates/test-files/fixtures/features/return_addition_i256.fe index 5ac7ec29c7..1c971a326f 100644 --- a/crates/test-files/fixtures/features/return_addition_i256.fe +++ b/crates/test-files/fixtures/features/return_addition_i256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i256, y: i256) -> i256: +contract Foo { + pub fn bar(x: i256, y: i256) -> i256 { return x + y + } +} diff --git a/crates/test-files/fixtures/features/return_addition_u128.fe b/crates/test-files/fixtures/features/return_addition_u128.fe index b3577edd33..b12870302f 100644 --- a/crates/test-files/fixtures/features/return_addition_u128.fe +++ b/crates/test-files/fixtures/features/return_addition_u128.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u128, y: u128) -> u128: +contract Foo { + pub fn bar(x: u128, y: u128) -> u128 { return x + y + } +} diff --git a/crates/test-files/fixtures/features/return_addition_u256.fe b/crates/test-files/fixtures/features/return_addition_u256.fe index 5e266a8a49..40213ccb09 100644 --- a/crates/test-files/fixtures/features/return_addition_u256.fe +++ b/crates/test-files/fixtures/features/return_addition_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> u256: +contract Foo { + pub fn bar(x: u256, y: u256) -> u256 { return x + y + } +} diff --git a/crates/test-files/fixtures/features/return_array.fe b/crates/test-files/fixtures/features/return_array.fe index 719f6eb272..03bbd33b54 100644 --- a/crates/test-files/fixtures/features/return_array.fe +++ b/crates/test-files/fixtures/features/return_array.fe @@ -1,5 +1,7 @@ -contract Foo: - pub fn bar(x: u256) -> Array: - let my_array: Array +contract Foo { + pub fn bar(x: u256) -> Array { + let my_array: Array my_array[3] = x return my_array + } +} diff --git a/crates/test-files/fixtures/features/return_bitwiseand_u128.fe b/crates/test-files/fixtures/features/return_bitwiseand_u128.fe index 8a46043396..83dee12415 100644 --- a/crates/test-files/fixtures/features/return_bitwiseand_u128.fe +++ b/crates/test-files/fixtures/features/return_bitwiseand_u128.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u128, y: u128) -> u128: +contract Foo { + pub fn bar(x: u128, y: u128) -> u128 { return x & y + } +} diff --git a/crates/test-files/fixtures/features/return_bitwiseand_u256.fe b/crates/test-files/fixtures/features/return_bitwiseand_u256.fe index ea62bf4291..a1e7f42a75 100644 --- a/crates/test-files/fixtures/features/return_bitwiseand_u256.fe +++ b/crates/test-files/fixtures/features/return_bitwiseand_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> u256: +contract Foo { + pub fn bar(x: u256, y: u256) -> u256 { return x & y + } +} diff --git a/crates/test-files/fixtures/features/return_bitwiseor_u256.fe b/crates/test-files/fixtures/features/return_bitwiseor_u256.fe index c2b9127841..2c764efd3a 100644 --- a/crates/test-files/fixtures/features/return_bitwiseor_u256.fe +++ b/crates/test-files/fixtures/features/return_bitwiseor_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> u256: +contract Foo { + pub fn bar(x: u256, y: u256) -> u256 { return x | y + } +} diff --git a/crates/test-files/fixtures/features/return_bitwiseshl_i64_coerced.fe b/crates/test-files/fixtures/features/return_bitwiseshl_i64_coerced.fe index 88758a0ffa..334535057d 100644 --- a/crates/test-files/fixtures/features/return_bitwiseshl_i64_coerced.fe +++ b/crates/test-files/fixtures/features/return_bitwiseshl_i64_coerced.fe @@ -1,4 +1,6 @@ -contract Foo: - pub fn bar() -> i64: +contract Foo { + pub fn bar() -> i64 { let x: i64 = -1 << 0 return x + } +} diff --git a/crates/test-files/fixtures/features/return_bitwiseshl_i8.fe b/crates/test-files/fixtures/features/return_bitwiseshl_i8.fe index f6f46b159a..a5dd82c392 100644 --- a/crates/test-files/fixtures/features/return_bitwiseshl_i8.fe +++ b/crates/test-files/fixtures/features/return_bitwiseshl_i8.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i8, y: u8) -> i8: +contract Foo { + pub fn bar(x: i8, y: u8) -> i8 { return x << y + } +} diff --git a/crates/test-files/fixtures/features/return_bitwiseshl_u256.fe b/crates/test-files/fixtures/features/return_bitwiseshl_u256.fe index 9c8f74c5e6..870c693694 100644 --- a/crates/test-files/fixtures/features/return_bitwiseshl_u256.fe +++ b/crates/test-files/fixtures/features/return_bitwiseshl_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> u256: +contract Foo { + pub fn bar(x: u256, y: u256) -> u256 { return x << y + } +} diff --git a/crates/test-files/fixtures/features/return_bitwiseshl_u8.fe b/crates/test-files/fixtures/features/return_bitwiseshl_u8.fe index 5ea9cb3b52..3b07469734 100644 --- a/crates/test-files/fixtures/features/return_bitwiseshl_u8.fe +++ b/crates/test-files/fixtures/features/return_bitwiseshl_u8.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u8, y: u8) -> u8: +contract Foo { + pub fn bar(x: u8, y: u8) -> u8 { return x << y + } +} diff --git a/crates/test-files/fixtures/features/return_bitwiseshr_i256.fe b/crates/test-files/fixtures/features/return_bitwiseshr_i256.fe index 65132ceb0e..ab36ac3538 100644 --- a/crates/test-files/fixtures/features/return_bitwiseshr_i256.fe +++ b/crates/test-files/fixtures/features/return_bitwiseshr_i256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i256, y: u256) -> i256: +contract Foo { + pub fn bar(x: i256, y: u256) -> i256 { return x >> y + } +} diff --git a/crates/test-files/fixtures/features/return_bitwiseshr_u256.fe b/crates/test-files/fixtures/features/return_bitwiseshr_u256.fe index 1a7e7f9ad7..42047198ba 100644 --- a/crates/test-files/fixtures/features/return_bitwiseshr_u256.fe +++ b/crates/test-files/fixtures/features/return_bitwiseshr_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> u256: +contract Foo { + pub fn bar(x: u256, y: u256) -> u256 { return x >> y + } +} diff --git a/crates/test-files/fixtures/features/return_bitwisexor_u256.fe b/crates/test-files/fixtures/features/return_bitwisexor_u256.fe index e5ab7643a0..7b052ef56d 100644 --- a/crates/test-files/fixtures/features/return_bitwisexor_u256.fe +++ b/crates/test-files/fixtures/features/return_bitwisexor_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> u256: +contract Foo { + pub fn bar(x: u256, y: u256) -> u256 { return x ^ y + } +} diff --git a/crates/test-files/fixtures/features/return_bool_false.fe b/crates/test-files/fixtures/features/return_bool_false.fe index 21c52d3e56..1e412d86d1 100644 --- a/crates/test-files/fixtures/features/return_bool_false.fe +++ b/crates/test-files/fixtures/features/return_bool_false.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar() -> bool: +contract Foo { + pub fn bar() -> bool { return false + } +} diff --git a/crates/test-files/fixtures/features/return_bool_inverted.fe b/crates/test-files/fixtures/features/return_bool_inverted.fe index 301863773c..c893a49c90 100644 --- a/crates/test-files/fixtures/features/return_bool_inverted.fe +++ b/crates/test-files/fixtures/features/return_bool_inverted.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(some_condition: bool) -> bool: +contract Foo { + pub fn bar(some_condition: bool) -> bool { return not some_condition + } +} diff --git a/crates/test-files/fixtures/features/return_bool_op_and.fe b/crates/test-files/fixtures/features/return_bool_op_and.fe index 19c1e9d81d..031ddde636 100644 --- a/crates/test-files/fixtures/features/return_bool_op_and.fe +++ b/crates/test-files/fixtures/features/return_bool_op_and.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: bool, y: bool) -> bool: - return x and y \ No newline at end of file +contract Foo { + pub fn bar(x: bool, y: bool) -> bool { + return x and y + } +} diff --git a/crates/test-files/fixtures/features/return_bool_op_or.fe b/crates/test-files/fixtures/features/return_bool_op_or.fe index 04790a0ee5..74f440c7d1 100644 --- a/crates/test-files/fixtures/features/return_bool_op_or.fe +++ b/crates/test-files/fixtures/features/return_bool_op_or.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: bool, y: bool) -> bool: - return x or y \ No newline at end of file +contract Foo { + pub fn bar(x: bool, y: bool) -> bool { + return x or y + } +} diff --git a/crates/test-files/fixtures/features/return_bool_true.fe b/crates/test-files/fixtures/features/return_bool_true.fe index 4f520cd69d..823dbdc4a7 100644 --- a/crates/test-files/fixtures/features/return_bool_true.fe +++ b/crates/test-files/fixtures/features/return_bool_true.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar() -> bool: +contract Foo { + pub fn bar() -> bool { return true + } +} diff --git a/crates/test-files/fixtures/features/return_builtin_attributes.fe b/crates/test-files/fixtures/features/return_builtin_attributes.fe index f615519ffc..9c01d81f52 100644 --- a/crates/test-files/fixtures/features/return_builtin_attributes.fe +++ b/crates/test-files/fixtures/features/return_builtin_attributes.fe @@ -1,33 +1,43 @@ use std::context::Context -contract Foo: - - pub fn base_fee(ctx: Context) -> u256: +contract Foo { + pub fn base_fee(ctx: Context) -> u256 { return ctx.base_fee() + } - pub fn coinbase(ctx: Context) -> address: + pub fn coinbase(ctx: Context) -> address { return ctx.block_coinbase() + } - pub fn difficulty(ctx: Context) -> u256: + pub fn difficulty(ctx: Context) -> u256 { return ctx.block_difficulty() + } - pub fn number(ctx: Context) -> u256: + pub fn number(ctx: Context) -> u256 { return ctx.block_number() + } - pub fn timestamp(ctx: Context) -> u256: + pub fn timestamp(ctx: Context) -> u256 { return ctx.block_timestamp() + } - pub fn chainid(ctx: Context) -> u256: + pub fn chainid(ctx: Context) -> u256 { return ctx.chain_id() + } - pub fn sender(ctx: Context) -> address: + pub fn sender(ctx: Context) -> address { return ctx.msg_sender() + } - pub fn value(ctx: Context) -> u256: + pub fn value(ctx: Context) -> u256 { return ctx.msg_value() + } - pub fn origin(ctx: Context) -> address: + pub fn origin(ctx: Context) -> address { return ctx.tx_origin() + } - pub fn gas_price(ctx: Context) -> u256: + pub fn gas_price(ctx: Context) -> u256 { return ctx.tx_gas_price() + } +} diff --git a/crates/test-files/fixtures/features/return_cast_i8_to_unsigned.fe b/crates/test-files/fixtures/features/return_cast_i8_to_unsigned.fe index d6c48a5399..97dfb7bbc4 100644 --- a/crates/test-files/fixtures/features/return_cast_i8_to_unsigned.fe +++ b/crates/test-files/fixtures/features/return_cast_i8_to_unsigned.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(val: i8) -> u8: +contract Foo { + pub fn bar(val: i8) -> u8 { return u8(val) + } +} diff --git a/crates/test-files/fixtures/features/return_cast_u8_to_signed.fe b/crates/test-files/fixtures/features/return_cast_u8_to_signed.fe index ce78fe5311..199de9444e 100644 --- a/crates/test-files/fixtures/features/return_cast_u8_to_signed.fe +++ b/crates/test-files/fixtures/features/return_cast_u8_to_signed.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(val: u8) -> i8: +contract Foo { + pub fn bar(val: u8) -> i8 { return i8(val) + } +} diff --git a/crates/test-files/fixtures/features/return_division_i256.fe b/crates/test-files/fixtures/features/return_division_i256.fe index 4f1ac48538..15860fc531 100644 --- a/crates/test-files/fixtures/features/return_division_i256.fe +++ b/crates/test-files/fixtures/features/return_division_i256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i256, y: i256) -> i256: +contract Foo { + pub fn bar(x: i256, y: i256) -> i256 { return x / y + } +} diff --git a/crates/test-files/fixtures/features/return_division_u256.fe b/crates/test-files/fixtures/features/return_division_u256.fe index abbded9e64..093d335881 100644 --- a/crates/test-files/fixtures/features/return_division_u256.fe +++ b/crates/test-files/fixtures/features/return_division_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> u256: +contract Foo { + pub fn bar(x: u256, y: u256) -> u256 { return x / y + } +} diff --git a/crates/test-files/fixtures/features/return_eq_u256.fe b/crates/test-files/fixtures/features/return_eq_u256.fe index ff09b01a55..9037426bb2 100644 --- a/crates/test-files/fixtures/features/return_eq_u256.fe +++ b/crates/test-files/fixtures/features/return_eq_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> bool: +contract Foo { + pub fn bar(x: u256, y: u256) -> bool { return x == y + } +} diff --git a/crates/test-files/fixtures/features/return_from_memory_i8.fe b/crates/test-files/fixtures/features/return_from_memory_i8.fe index d80c9e4d8f..b2d3478402 100644 --- a/crates/test-files/fixtures/features/return_from_memory_i8.fe +++ b/crates/test-files/fixtures/features/return_from_memory_i8.fe @@ -1,13 +1,7 @@ - - -contract Foo: - - pub fn bar(self, val: i8) -> i8: +contract Foo { + pub fn bar(self, val: i8) -> i8 { let in_memory: Array = [val, val] - # We do this to prove that we have to adjust the numerics at the point where they - # are loaded on the stack and not e.g. at the point where they are returned. Adjusting - # them at the point of the return would work for a single value that is loaded from - # storage but will fail in cases like this where we sum two values together and then - # return the result. let result: i8 = in_memory[0] + in_memory[1] - return result \ No newline at end of file + return result + } +} diff --git a/crates/test-files/fixtures/features/return_from_storage_array_i8.fe b/crates/test-files/fixtures/features/return_from_storage_array_i8.fe index 90bb599b9f..e78d92c114 100644 --- a/crates/test-files/fixtures/features/return_from_storage_array_i8.fe +++ b/crates/test-files/fixtures/features/return_from_storage_array_i8.fe @@ -1,9 +1,8 @@ - - -contract Foo: - +contract Foo { some_thing: Array - pub fn bar(self, val: i8) -> Array: + pub fn bar(self, val: i8) -> Array { self.some_thing[0] = val - return self.some_thing.to_mem() \ No newline at end of file + return self.some_thing.to_mem() + } +} diff --git a/crates/test-files/fixtures/features/return_from_storage_i8.fe b/crates/test-files/fixtures/features/return_from_storage_i8.fe index 1d2304a4e1..cda7de9670 100644 --- a/crates/test-files/fixtures/features/return_from_storage_i8.fe +++ b/crates/test-files/fixtures/features/return_from_storage_i8.fe @@ -1,17 +1,11 @@ - - -contract Foo: - +contract Foo { some_thing: i8 some_other: i8 - pub fn bar(self, val: i8) -> i8: + pub fn bar(self, val: i8) -> i8 { self.some_thing = val self.some_other = val - # We do this to prove that we have to adjust the numerics at the point where they - # are loaded on the stack and not e.g. at the point where they are returned. Adjusting - # them at the point of the return would work for a single value that is loaded from - # storage but will fail in cases like this where we sum two values together and then - # return the result. - let x:i8 = self.some_thing + self.some_other - return x \ No newline at end of file + let x: i8 = self.some_thing + self.some_other + return x + } +} diff --git a/crates/test-files/fixtures/features/return_gt_i256.fe b/crates/test-files/fixtures/features/return_gt_i256.fe index 90dd79c944..e458d9d885 100644 --- a/crates/test-files/fixtures/features/return_gt_i256.fe +++ b/crates/test-files/fixtures/features/return_gt_i256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i256, y: i256) -> bool: +contract Foo { + pub fn bar(x: i256, y: i256) -> bool { return x > y + } +} diff --git a/crates/test-files/fixtures/features/return_gt_u256.fe b/crates/test-files/fixtures/features/return_gt_u256.fe index 003c42a33f..1a3cb2233f 100644 --- a/crates/test-files/fixtures/features/return_gt_u256.fe +++ b/crates/test-files/fixtures/features/return_gt_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> bool: +contract Foo { + pub fn bar(x: u256, y: u256) -> bool { return x > y + } +} diff --git a/crates/test-files/fixtures/features/return_gte_i256.fe b/crates/test-files/fixtures/features/return_gte_i256.fe index d942749c72..97c025eced 100644 --- a/crates/test-files/fixtures/features/return_gte_i256.fe +++ b/crates/test-files/fixtures/features/return_gte_i256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i256, y: i256) -> bool: +contract Foo { + pub fn bar(x: i256, y: i256) -> bool { return x >= y + } +} diff --git a/crates/test-files/fixtures/features/return_gte_u256.fe b/crates/test-files/fixtures/features/return_gte_u256.fe index 21f81b9367..8443406d84 100644 --- a/crates/test-files/fixtures/features/return_gte_u256.fe +++ b/crates/test-files/fixtures/features/return_gte_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> bool: +contract Foo { + pub fn bar(x: u256, y: u256) -> bool { return x >= y + } +} diff --git a/crates/test-files/fixtures/features/return_i128_cast.fe b/crates/test-files/fixtures/features/return_i128_cast.fe index ff01543eb8..d508722e48 100644 --- a/crates/test-files/fixtures/features/return_i128_cast.fe +++ b/crates/test-files/fixtures/features/return_i128_cast.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar() -> i128: +contract Foo { + pub fn bar() -> i128 { return i128(-3) + } +} diff --git a/crates/test-files/fixtures/features/return_i256.fe b/crates/test-files/fixtures/features/return_i256.fe index 54d9a4de1b..6de24ec38d 100644 --- a/crates/test-files/fixtures/features/return_i256.fe +++ b/crates/test-files/fixtures/features/return_i256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar() -> i256: +contract Foo { + pub fn bar() -> i256 { return -3 + } +} diff --git a/crates/test-files/fixtures/features/return_identity_u128.fe b/crates/test-files/fixtures/features/return_identity_u128.fe index c5d19aca32..01b36df425 100644 --- a/crates/test-files/fixtures/features/return_identity_u128.fe +++ b/crates/test-files/fixtures/features/return_identity_u128.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u128) -> u128: +contract Foo { + pub fn bar(x: u128) -> u128 { return x + } +} diff --git a/crates/test-files/fixtures/features/return_identity_u16.fe b/crates/test-files/fixtures/features/return_identity_u16.fe index a42fb38a18..2a17a8f965 100644 --- a/crates/test-files/fixtures/features/return_identity_u16.fe +++ b/crates/test-files/fixtures/features/return_identity_u16.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u16) -> u16: +contract Foo { + pub fn bar(x: u16) -> u16 { return x + } +} diff --git a/crates/test-files/fixtures/features/return_identity_u256.fe b/crates/test-files/fixtures/features/return_identity_u256.fe index 44fe532ee6..62f57e717a 100644 --- a/crates/test-files/fixtures/features/return_identity_u256.fe +++ b/crates/test-files/fixtures/features/return_identity_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256) -> u256: +contract Foo { + pub fn bar(x: u256) -> u256 { return x + } +} diff --git a/crates/test-files/fixtures/features/return_identity_u32.fe b/crates/test-files/fixtures/features/return_identity_u32.fe index 5531100c12..0c8388d682 100644 --- a/crates/test-files/fixtures/features/return_identity_u32.fe +++ b/crates/test-files/fixtures/features/return_identity_u32.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u32) -> u32: +contract Foo { + pub fn bar(x: u32) -> u32 { return x + } +} diff --git a/crates/test-files/fixtures/features/return_identity_u64.fe b/crates/test-files/fixtures/features/return_identity_u64.fe index 50d1ca9cb1..07833752bd 100644 --- a/crates/test-files/fixtures/features/return_identity_u64.fe +++ b/crates/test-files/fixtures/features/return_identity_u64.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u64) -> u64: +contract Foo { + pub fn bar(x: u64) -> u64 { return x + } +} diff --git a/crates/test-files/fixtures/features/return_identity_u8.fe b/crates/test-files/fixtures/features/return_identity_u8.fe index d92fc342cc..06e234ff23 100644 --- a/crates/test-files/fixtures/features/return_identity_u8.fe +++ b/crates/test-files/fixtures/features/return_identity_u8.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u8) -> u8: +contract Foo { + pub fn bar(x: u8) -> u8 { return x + } +} diff --git a/crates/test-files/fixtures/features/return_int_array.fe b/crates/test-files/fixtures/features/return_int_array.fe index afbb390c13..02328c4ff7 100644 --- a/crates/test-files/fixtures/features/return_int_array.fe +++ b/crates/test-files/fixtures/features/return_int_array.fe @@ -1,6 +1,9 @@ -contract Foo: - pub fn i8_array(bar: Array) -> Array: +contract Foo { + pub fn i8_array(bar: Array) -> Array { return bar + } - pub fn i32_array(bar: Array) -> Array: + pub fn i32_array(bar: Array) -> Array { return bar + } +} diff --git a/crates/test-files/fixtures/features/return_invert_i128.fe b/crates/test-files/fixtures/features/return_invert_i128.fe index 0c7eeb69f3..ad2c55de1f 100644 --- a/crates/test-files/fixtures/features/return_invert_i128.fe +++ b/crates/test-files/fixtures/features/return_invert_i128.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i128) -> i128: +contract Foo { + pub fn bar(x: i128) -> i128 { return ~x + } +} diff --git a/crates/test-files/fixtures/features/return_invert_i16.fe b/crates/test-files/fixtures/features/return_invert_i16.fe index 2e1e5badd9..50466d78b0 100644 --- a/crates/test-files/fixtures/features/return_invert_i16.fe +++ b/crates/test-files/fixtures/features/return_invert_i16.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i16) -> i16: +contract Foo { + pub fn bar(x: i16) -> i16 { return ~x + } +} diff --git a/crates/test-files/fixtures/features/return_invert_i256.fe b/crates/test-files/fixtures/features/return_invert_i256.fe index 9ab522d7c8..015e9b709a 100644 --- a/crates/test-files/fixtures/features/return_invert_i256.fe +++ b/crates/test-files/fixtures/features/return_invert_i256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i256) -> i256: +contract Foo { + pub fn bar(x: i256) -> i256 { return ~x + } +} diff --git a/crates/test-files/fixtures/features/return_invert_i32.fe b/crates/test-files/fixtures/features/return_invert_i32.fe index 060386bb92..2b3a3916e5 100644 --- a/crates/test-files/fixtures/features/return_invert_i32.fe +++ b/crates/test-files/fixtures/features/return_invert_i32.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i32) -> i32: +contract Foo { + pub fn bar(x: i32) -> i32 { return ~x + } +} diff --git a/crates/test-files/fixtures/features/return_invert_i64.fe b/crates/test-files/fixtures/features/return_invert_i64.fe index 35b0e5d59f..4200350fc7 100644 --- a/crates/test-files/fixtures/features/return_invert_i64.fe +++ b/crates/test-files/fixtures/features/return_invert_i64.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i64) -> i64: +contract Foo { + pub fn bar(x: i64) -> i64 { return ~x + } +} diff --git a/crates/test-files/fixtures/features/return_invert_i8.fe b/crates/test-files/fixtures/features/return_invert_i8.fe index ffa3666309..c22af14bbd 100644 --- a/crates/test-files/fixtures/features/return_invert_i8.fe +++ b/crates/test-files/fixtures/features/return_invert_i8.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i8) -> i8: +contract Foo { + pub fn bar(x: i8) -> i8 { return ~x + } +} diff --git a/crates/test-files/fixtures/features/return_invert_u128.fe b/crates/test-files/fixtures/features/return_invert_u128.fe index 39830cd7a5..e448bab79a 100644 --- a/crates/test-files/fixtures/features/return_invert_u128.fe +++ b/crates/test-files/fixtures/features/return_invert_u128.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u128) -> u128: +contract Foo { + pub fn bar(x: u128) -> u128 { return ~x + } +} diff --git a/crates/test-files/fixtures/features/return_invert_u16.fe b/crates/test-files/fixtures/features/return_invert_u16.fe index a910bb74de..794906285c 100644 --- a/crates/test-files/fixtures/features/return_invert_u16.fe +++ b/crates/test-files/fixtures/features/return_invert_u16.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u16) -> u16: +contract Foo { + pub fn bar(x: u16) -> u16 { return ~x + } +} diff --git a/crates/test-files/fixtures/features/return_invert_u256.fe b/crates/test-files/fixtures/features/return_invert_u256.fe index 99e1cdda33..0ead4b67ba 100644 --- a/crates/test-files/fixtures/features/return_invert_u256.fe +++ b/crates/test-files/fixtures/features/return_invert_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256) -> u256: +contract Foo { + pub fn bar(x: u256) -> u256 { return ~x + } +} diff --git a/crates/test-files/fixtures/features/return_invert_u32.fe b/crates/test-files/fixtures/features/return_invert_u32.fe index 68f8f166b8..53dc778579 100644 --- a/crates/test-files/fixtures/features/return_invert_u32.fe +++ b/crates/test-files/fixtures/features/return_invert_u32.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u32) -> u32: +contract Foo { + pub fn bar(x: u32) -> u32 { return ~x + } +} diff --git a/crates/test-files/fixtures/features/return_invert_u64.fe b/crates/test-files/fixtures/features/return_invert_u64.fe index 7f10eedb92..ca26875f0b 100644 --- a/crates/test-files/fixtures/features/return_invert_u64.fe +++ b/crates/test-files/fixtures/features/return_invert_u64.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u64) -> u64: +contract Foo { + pub fn bar(x: u64) -> u64 { return ~x + } +} diff --git a/crates/test-files/fixtures/features/return_invert_u8.fe b/crates/test-files/fixtures/features/return_invert_u8.fe index a9acec5112..a18cabeea1 100644 --- a/crates/test-files/fixtures/features/return_invert_u8.fe +++ b/crates/test-files/fixtures/features/return_invert_u8.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u8) -> u8: +contract Foo { + pub fn bar(x: u8) -> u8 { return ~x + } +} diff --git a/crates/test-files/fixtures/features/return_lt_i256.fe b/crates/test-files/fixtures/features/return_lt_i256.fe index bbfebbcf05..9ad64af39d 100644 --- a/crates/test-files/fixtures/features/return_lt_i256.fe +++ b/crates/test-files/fixtures/features/return_lt_i256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i256, y: i256) -> bool: +contract Foo { + pub fn bar(x: i256, y: i256) -> bool { return x < y + } +} diff --git a/crates/test-files/fixtures/features/return_lt_u128.fe b/crates/test-files/fixtures/features/return_lt_u128.fe index 2feb2e7e36..83677391ea 100644 --- a/crates/test-files/fixtures/features/return_lt_u128.fe +++ b/crates/test-files/fixtures/features/return_lt_u128.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u128, y: u128) -> bool: +contract Foo { + pub fn bar(x: u128, y: u128) -> bool { return x < y + } +} diff --git a/crates/test-files/fixtures/features/return_lt_u256.fe b/crates/test-files/fixtures/features/return_lt_u256.fe index 6e11bd4295..d88f14e5d3 100644 --- a/crates/test-files/fixtures/features/return_lt_u256.fe +++ b/crates/test-files/fixtures/features/return_lt_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> bool: +contract Foo { + pub fn bar(x: u256, y: u256) -> bool { return x < y + } +} diff --git a/crates/test-files/fixtures/features/return_lte_i256.fe b/crates/test-files/fixtures/features/return_lte_i256.fe index f1c1285d16..e8900f4b1b 100644 --- a/crates/test-files/fixtures/features/return_lte_i256.fe +++ b/crates/test-files/fixtures/features/return_lte_i256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i256, y: i256) -> bool: +contract Foo { + pub fn bar(x: i256, y: i256) -> bool { return x <= y + } +} diff --git a/crates/test-files/fixtures/features/return_lte_u256.fe b/crates/test-files/fixtures/features/return_lte_u256.fe index ed0cfc30a9..7a5f538914 100644 --- a/crates/test-files/fixtures/features/return_lte_u256.fe +++ b/crates/test-files/fixtures/features/return_lte_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> bool: +contract Foo { + pub fn bar(x: u256, y: u256) -> bool { return x <= y + } +} diff --git a/crates/test-files/fixtures/features/return_mod_i256.fe b/crates/test-files/fixtures/features/return_mod_i256.fe index 2f4585f7fc..16b1818ec1 100644 --- a/crates/test-files/fixtures/features/return_mod_i256.fe +++ b/crates/test-files/fixtures/features/return_mod_i256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i256, y: i256) -> i256: +contract Foo { + pub fn bar(x: i256, y: i256) -> i256 { return x % y + } +} diff --git a/crates/test-files/fixtures/features/return_mod_u256.fe b/crates/test-files/fixtures/features/return_mod_u256.fe index 2996c3a93c..8b4888b97a 100644 --- a/crates/test-files/fixtures/features/return_mod_u256.fe +++ b/crates/test-files/fixtures/features/return_mod_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> u256: +contract Foo { + pub fn bar(x: u256, y: u256) -> u256 { return x % y + } +} diff --git a/crates/test-files/fixtures/features/return_msg_sig.fe b/crates/test-files/fixtures/features/return_msg_sig.fe index c3fd6d259f..8c0c3ddabc 100644 --- a/crates/test-files/fixtures/features/return_msg_sig.fe +++ b/crates/test-files/fixtures/features/return_msg_sig.fe @@ -1,5 +1,7 @@ use std::context::Context -contract Foo: - pub fn bar(ctx: Context) -> u256: +contract Foo { + pub fn bar(ctx: Context) -> u256 { return ctx.msg_sig() + } +} diff --git a/crates/test-files/fixtures/features/return_multiplication_i256.fe b/crates/test-files/fixtures/features/return_multiplication_i256.fe index 93cb31f058..49eb9faac4 100644 --- a/crates/test-files/fixtures/features/return_multiplication_i256.fe +++ b/crates/test-files/fixtures/features/return_multiplication_i256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i256, y: i256) -> i256: +contract Foo { + pub fn bar(x: i256, y: i256) -> i256 { return x * y + } +} diff --git a/crates/test-files/fixtures/features/return_multiplication_u256.fe b/crates/test-files/fixtures/features/return_multiplication_u256.fe index 108c82a16e..1041a66f55 100644 --- a/crates/test-files/fixtures/features/return_multiplication_u256.fe +++ b/crates/test-files/fixtures/features/return_multiplication_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> u256: +contract Foo { + pub fn bar(x: u256, y: u256) -> u256 { return x * y + } +} diff --git a/crates/test-files/fixtures/features/return_noteq_u256.fe b/crates/test-files/fixtures/features/return_noteq_u256.fe index 9d400c268b..4221ee1913 100644 --- a/crates/test-files/fixtures/features/return_noteq_u256.fe +++ b/crates/test-files/fixtures/features/return_noteq_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> bool: +contract Foo { + pub fn bar(x: u256, y: u256) -> bool { return x != y + } +} diff --git a/crates/test-files/fixtures/features/return_pow_i256.fe b/crates/test-files/fixtures/features/return_pow_i256.fe index 1c15e8a8fa..78e57a1c34 100644 --- a/crates/test-files/fixtures/features/return_pow_i256.fe +++ b/crates/test-files/fixtures/features/return_pow_i256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i8, y: u8) -> i8: +contract Foo { + pub fn bar(x: i8, y: u8) -> i8 { return x ** y + } +} diff --git a/crates/test-files/fixtures/features/return_pow_u256.fe b/crates/test-files/fixtures/features/return_pow_u256.fe index 83963e7ebf..6e6d6043ed 100644 --- a/crates/test-files/fixtures/features/return_pow_u256.fe +++ b/crates/test-files/fixtures/features/return_pow_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> u256: +contract Foo { + pub fn bar(x: u256, y: u256) -> u256 { return x ** y + } +} diff --git a/crates/test-files/fixtures/features/return_subtraction_i256.fe b/crates/test-files/fixtures/features/return_subtraction_i256.fe index 276e962762..a79d87574b 100644 --- a/crates/test-files/fixtures/features/return_subtraction_i256.fe +++ b/crates/test-files/fixtures/features/return_subtraction_i256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: i256, y: i256) -> i256: +contract Foo { + pub fn bar(x: i256, y: i256) -> i256 { return x - y + } +} diff --git a/crates/test-files/fixtures/features/return_subtraction_u256.fe b/crates/test-files/fixtures/features/return_subtraction_u256.fe index 5acb6e0aa0..27a052fece 100644 --- a/crates/test-files/fixtures/features/return_subtraction_u256.fe +++ b/crates/test-files/fixtures/features/return_subtraction_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar(x: u256, y: u256) -> u256: +contract Foo { + pub fn bar(x: u256, y: u256) -> u256 { return x - y + } +} diff --git a/crates/test-files/fixtures/features/return_sum_list_expression_1.fe b/crates/test-files/fixtures/features/return_sum_list_expression_1.fe index 1b1671196a..f13a272c50 100644 --- a/crates/test-files/fixtures/features/return_sum_list_expression_1.fe +++ b/crates/test-files/fixtures/features/return_sum_list_expression_1.fe @@ -1,10 +1,13 @@ -contract Foo: +contract Foo { num_two: u256 - pub fn bar(self) -> u256: + pub fn bar(self) -> u256 { self.num_two = 2 let my_array: Array = [1, self.num_two, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] let sum: u256 = 0 - for i in my_array: + for i in my_array { sum = sum + i + } return sum + } +} diff --git a/crates/test-files/fixtures/features/return_sum_list_expression_2.fe b/crates/test-files/fixtures/features/return_sum_list_expression_2.fe index bac099d8b5..edddc6a955 100644 --- a/crates/test-files/fixtures/features/return_sum_list_expression_2.fe +++ b/crates/test-files/fixtures/features/return_sum_list_expression_2.fe @@ -1,10 +1,13 @@ -contract Foo: - - pub fn bar(self) -> u256: +contract Foo { + pub fn bar(self) -> u256 { return count([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) + } - fn count(_ values: Array) -> u256: + fn count(_ values: Array) -> u256 { let sum: u256 = 0 - for i in values: + for i in values { sum = sum + i + } return sum + } +} diff --git a/crates/test-files/fixtures/features/return_u128_cast.fe b/crates/test-files/fixtures/features/return_u128_cast.fe index 7289233ddf..2956254ba4 100644 --- a/crates/test-files/fixtures/features/return_u128_cast.fe +++ b/crates/test-files/fixtures/features/return_u128_cast.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar() -> u128: +contract Foo { + pub fn bar() -> u128 { return u128(42) + } +} diff --git a/crates/test-files/fixtures/features/return_u256.fe b/crates/test-files/fixtures/features/return_u256.fe index 1cd90cdd48..fb0fcd47f0 100644 --- a/crates/test-files/fixtures/features/return_u256.fe +++ b/crates/test-files/fixtures/features/return_u256.fe @@ -1,3 +1,5 @@ -contract Foo: - pub fn bar() -> u256: +contract Foo { + pub fn bar() -> u256 { return 42 + } +} diff --git a/crates/test-files/fixtures/features/return_u256_from_called_fn.fe b/crates/test-files/fixtures/features/return_u256_from_called_fn.fe index cbfc4b7b47..37e37432ac 100644 --- a/crates/test-files/fixtures/features/return_u256_from_called_fn.fe +++ b/crates/test-files/fixtures/features/return_u256_from_called_fn.fe @@ -1,8 +1,9 @@ -contract Foo: - - # We intentionally define `bar` before `foo` to test that order isn't important - pub fn bar(self) -> u256: +contract Foo { + pub fn bar(self) -> u256 { return foo() + } - pub fn foo() -> u256: + pub fn foo() -> u256 { return 42 + } +} diff --git a/crates/test-files/fixtures/features/return_u256_from_called_fn_with_args.fe b/crates/test-files/fixtures/features/return_u256_from_called_fn_with_args.fe index 330fd6a652..fb945e4d12 100644 --- a/crates/test-files/fixtures/features/return_u256_from_called_fn_with_args.fe +++ b/crates/test-files/fixtures/features/return_u256_from_called_fn_with_args.fe @@ -1,11 +1,16 @@ -contract Foo: +contract Foo { baz: Map - pub fn foo(_ v1: u256, _ v2: u256, _ v3: u256, _ v4: u256, _ v5: u256) -> u256: + + pub fn foo(_ v1: u256, _ v2: u256, _ v3: u256, _ v4: u256, _ v5: u256) -> u256 { return v1 + v2 + v3 + v4 + v5 + } - pub fn cem() -> u256: + pub fn cem() -> u256 { return 100 + } - pub fn bar(self) -> u256: + pub fn bar(self) -> u256 { self.baz[0] = 43 return foo(5, 2, cem(), 25 + 25, self.baz[0]) + } +} diff --git a/crates/test-files/fixtures/features/return_unit.fe b/crates/test-files/fixtures/features/return_unit.fe index 58013a855a..079890199c 100644 --- a/crates/test-files/fixtures/features/return_unit.fe +++ b/crates/test-files/fixtures/features/return_unit.fe @@ -1,19 +1,21 @@ -contract Foo: +contract Foo { + pub fn explicit_return_a1() { + return + } - pub fn explicit_return_a1(): - return + pub fn explicit_return_a2() { + return () + } - pub fn explicit_return_a2(): - return () + pub fn explicit_return_b1() -> () { + return + } - pub fn explicit_return_b1() -> (): - return + pub fn explicit_return_b2() -> () { + return () + } - pub fn explicit_return_b2() -> (): - return () + pub fn implicit_a1() {} - pub fn implicit_a1(): - pass - - pub fn implicit_a2() -> (): - pass \ No newline at end of file + pub fn implicit_a2() -> () {} +} diff --git a/crates/test-files/fixtures/features/revert.fe b/crates/test-files/fixtures/features/revert.fe index e68e17eb27..3b7a69031e 100644 --- a/crates/test-files/fixtures/features/revert.fe +++ b/crates/test-files/fixtures/features/revert.fe @@ -1,21 +1,27 @@ use std::context::Context -struct OtherError: +struct OtherError { pub msg: u256 pub val: bool +} -contract Foo: +contract Foo { my_other_error: OtherError - pub fn bar() -> u256: + pub fn bar() -> u256 { revert + } - pub fn revert_custom_error(ctx: Context): + pub fn revert_custom_error(ctx: Context) { ctx.send_value(to: address(0), wei: 100) + } - pub fn revert_other_error(): + pub fn revert_other_error() { revert OtherError(msg: 1, val: true) + } - pub fn revert_other_error_from_sto(self): + pub fn revert_other_error_from_sto(self) { self.my_other_error = OtherError(msg: 1, val: true) revert self.my_other_error.to_mem() + } +} diff --git a/crates/test-files/fixtures/features/self_address.fe b/crates/test-files/fixtures/features/self_address.fe index c2ed173a78..2b9d7bfe9e 100644 --- a/crates/test-files/fixtures/features/self_address.fe +++ b/crates/test-files/fixtures/features/self_address.fe @@ -1,5 +1,7 @@ use std::context::Context -contract Foo: - pub fn my_address(ctx: Context) -> address: - return ctx.self_address() \ No newline at end of file +contract Foo { + pub fn my_address(ctx: Context) -> address { + return ctx.self_address() + } +} diff --git a/crates/test-files/fixtures/features/send_value.fe b/crates/test-files/fixtures/features/send_value.fe index abe7649dc4..c98e6537fd 100644 --- a/crates/test-files/fixtures/features/send_value.fe +++ b/crates/test-files/fixtures/features/send_value.fe @@ -1,5 +1,7 @@ use std::context::Context -contract Foo: - pub fn send_them_wei(ctx: Context, to: address, wei: u256): +contract Foo { + pub fn send_them_wei(ctx: Context, to: address, wei: u256) { ctx.send_value(to, wei) + } +} diff --git a/crates/test-files/fixtures/features/short_circuit.fe b/crates/test-files/fixtures/features/short_circuit.fe index 18ce29faca..00ccdcc9c3 100644 --- a/crates/test-files/fixtures/features/short_circuit.fe +++ b/crates/test-files/fixtures/features/short_circuit.fe @@ -1,18 +1,23 @@ -contract Foo: - - pub fn bar(input: u256) -> u256: +contract Foo { + pub fn bar(input: u256) -> u256 { return 1 if input > 5 else revert_u256() + } - fn revert_u256() -> u256: + fn revert_u256() -> u256 { revert return 0 + } - fn revert_bool() -> bool: + fn revert_bool() -> bool { revert return true + } - pub fn short_circuit_and(let_through: bool) -> bool: + pub fn short_circuit_and(let_through: bool) -> bool { return let_through and revert_bool() + } - pub fn short_circuit_or(break_early: bool) -> bool: - return break_early or revert_bool() \ No newline at end of file + pub fn short_circuit_or(break_early: bool) -> bool { + return break_early or revert_bool() + } +} diff --git a/crates/test-files/fixtures/features/sized_vals_in_sto.fe b/crates/test-files/fixtures/features/sized_vals_in_sto.fe index 151343a246..3cba528604 100644 --- a/crates/test-files/fixtures/features/sized_vals_in_sto.fe +++ b/crates/test-files/fixtures/features/sized_vals_in_sto.fe @@ -1,37 +1,41 @@ use std::context::Context -contract Foo: +contract Foo { num: u256 nums: Array str: String<26> - event MyEvent: + event MyEvent { num: u256 nums: Array str: String<26> + } - pub fn write_num(self, x: u256): + pub fn write_num(self, x: u256) { self.num = x + } - pub fn read_num(self) -> u256: + pub fn read_num(self) -> u256 { return self.num + } - pub fn write_nums(self, x: Array): + pub fn write_nums(self, x: Array) { self.nums = x + } - pub fn read_nums(self) -> Array: + pub fn read_nums(self) -> Array { return self.nums.to_mem() + } - pub fn write_str(self, x: String<26>): + pub fn write_str(self, x: String<26>) { self.str = x + } - pub fn read_str(self) -> String<26>: + pub fn read_str(self) -> String<26> { return self.str.to_mem() + } - pub fn emit_event(self, ctx: Context): - emit MyEvent( - ctx, - num: self.num, - nums: self.nums.to_mem(), - str: self.str.to_mem() - ) \ No newline at end of file + pub fn emit_event(self, ctx: Context) { + emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) + } +} diff --git a/crates/test-files/fixtures/features/strings.fe b/crates/test-files/fixtures/features/strings.fe index e4bf4e4d44..21ba67e7e8 100644 --- a/crates/test-files/fixtures/features/strings.fe +++ b/crates/test-files/fixtures/features/strings.fe @@ -1,7 +1,7 @@ use std::context::Context -contract Foo: - event MyEvent: +contract Foo { + event MyEvent { s2: String<26> u: u256 s1: String<42> @@ -9,24 +9,30 @@ contract Foo: a: address s4: String<18> s5: String<100> + } - pub fn __init__(ctx: Context, s1: String<42>, a: address, s2: String<26>, u: u256, s3: String<100>): + pub fn __init__(ctx: Context, s1: String<42>, a: address, s2: String<26>, u: u256, s3: String<100>) { emit MyEvent(ctx, s2, u, s1, s3, a, s4: "static string", s5: String<100>("foo")) + } - pub fn bar(s1: String<100>, s2: String<100>) -> String<100>: + pub fn bar(s1: String<100>, s2: String<100>) -> String<100> { return s2 + } - pub fn return_static_string() -> String<43>: + pub fn return_static_string() -> String<43> { return "The quick brown fox jumps over the lazy dog" + } - pub fn return_casted_static_string() -> String<100>: + pub fn return_casted_static_string() -> String<100> { return String<100>("foo") + } - pub fn shorter_string_assign(): + pub fn shorter_string_assign() { let s: String<18> = "fe" + } - pub fn return_special_chars() -> String<18>: + pub fn return_special_chars() -> String<18> { return "\n\"'\r\t foo\\" - - + } +} diff --git a/crates/test-files/fixtures/features/struct_fns.fe b/crates/test-files/fixtures/features/struct_fns.fe index f482218239..fbf3f5569a 100644 --- a/crates/test-files/fixtures/features/struct_fns.fe +++ b/crates/test-files/fixtures/features/struct_fns.fe @@ -1,56 +1,60 @@ -struct Point: - pub x: u64 - pub y: u64 - - pub fn new(x: u64, y: u64) -> Point: - return Point(x, y) - - pub fn origin() -> Point: - return Point(x: 0, y: 0) - - # function name can match field name - pub fn x(self) -> u64: - return self.x - - pub fn set_x(self, _ x: u64) -> u64: - let old: u64 = self.x - self.x = x - return old - - pub fn reflect(self): - let x: u64 = self.x - let y: u64 = self.y - # self.x = self.y panics. see issue #590 - self.x = y - self.y = x - - pub fn translate(self, x: u64, y: u64): - self.x += x - self.y += y - - pub fn add(self, _ other: Point) -> Point: - let x: u64 = self.x + other.x - let y: u64 = self.y + other.y - return Point(x, y) - -pub fn do_pointy_things(): - let p1: Point = Point::origin() - p1.translate(x: 5, y: 10) - - let p2: Point = Point(x: 1, y: 2) - let p3: Point = p1.add(p2) - - assert p3.x == 6 and p3.y == 12 - - -contract Foo: - - pub fn bar(x: u64, y: u64) -> u64: - do_pointy_things() - - let p: Point = Point::new(x, y) - assert p.x == x and p.y == y - p.set_x(100) - p.reflect() - assert p.x() == y and p.y == 100 - return p.y +struct Point { + pub x: u64 + pub y: u64 + + pub fn new(x: u64, y: u64) -> Point { + return Point(x, y) + } + + pub fn origin() -> Point { + return Point(x: 0, y: 0) + } + + pub fn x(self) -> u64 { + return self.x + } + + pub fn set_x(self, _ x: u64) -> u64 { + let old: u64 = self.x + self.x = x + return old + } + + pub fn reflect(self) { + let x: u64 = self.x + let y: u64 = self.y + self.x = y + self.y = x + } + + pub fn translate(self, x: u64, y: u64) { + self.x += x + self.y += y + } + + pub fn add(self, _ other: Point) -> Point { + let x: u64 = self.x + other.x + let y: u64 = self.y + other.y + return Point(x, y) + } +} + +pub fn do_pointy_things() { + let p1: Point = Point::origin() + p1.translate(x: 5, y: 10) + let p2: Point = Point(x: 1, y: 2) + let p3: Point = p1.add(p2) + assert p3.x == 6 and p3.y == 12 +} + +contract Foo { + pub fn bar(x: u64, y: u64) -> u64 { + do_pointy_things() + let p: Point = Point::new(x, y) + assert p.x == x and p.y == y + p.set_x(100) + p.reflect() + assert p.x() == y and p.y == 100 + return p.y + } +} diff --git a/crates/test-files/fixtures/features/structs.fe b/crates/test-files/fixtures/features/structs.fe index 8c31dae130..20658f748c 100644 --- a/crates/test-files/fixtures/features/structs.fe +++ b/crates/test-files/fixtures/features/structs.fe @@ -1,167 +1,140 @@ -struct Point: +struct Point { pub x: u256 pub y: u256 +} -struct Bar: +struct Bar { pub name: String<3> pub numbers: Array pub point: Point pub something: (u256, bool) +} -struct Mixed: +struct Mixed { pub foo: u256 bar: bool - pub fn new(val: u256) -> Mixed: + pub fn new(val: u256) -> Mixed { return Mixed(foo: val, bar: false) + } +} -struct House: +struct House { pub price: u256 pub size: u256 pub rooms: u8 pub vacant: bool - pub fn encode(self) -> Array: + pub fn encode(self) -> Array { return self.abi_encode() + } - pub fn hash(self) -> u256: + pub fn hash(self) -> u256 { return keccak256(self.encode()) + } - pub fn price_per_sqft(self) -> u256: + pub fn price_per_sqft(self) -> u256 { return self.price / self.size + } - pub fn expand(self): + pub fn expand(self) { self.rooms += 1 self.size += 100 + } +} -contract Foo: +contract Foo { my_house: House my_bar: Bar - pub fn complex_struct_in_storage(self) -> String<3>: - self.my_bar = Bar( - name: "foo", - numbers: [1, 2], - point: Point(x: 100, y: 200), - something: (1, true), - ) - - # Asserting the values as they were set initially + pub fn complex_struct_in_storage(self) -> String<3> { + self.my_bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) assert self.my_bar.numbers[0] == 1 assert self.my_bar.numbers[1] == 2 assert self.my_bar.point.x == 100 assert self.my_bar.point.y == 200 assert self.my_bar.something.item0 == 1 assert self.my_bar.something.item1 - - # We can change the values of the array self.my_bar.numbers[0] = 10 self.my_bar.numbers[1] = 20 assert self.my_bar.numbers[0] == 10 assert self.my_bar.numbers[1] == 20 - # We can set the array itself self.my_bar.numbers = [1, 2] assert self.my_bar.numbers[0] == 1 assert self.my_bar.numbers[1] == 2 - - # We can change the values of the Point self.my_bar.point.x = 1000 self.my_bar.point.y = 2000 assert self.my_bar.point.x == 1000 assert self.my_bar.point.y == 2000 - # We can set the point itself self.my_bar.point = Point(x: 100, y: 200) assert self.my_bar.point.x == 100 assert self.my_bar.point.y == 200 - - # We can change the value of the tuple self.my_bar.something.item0 = 10 self.my_bar.something.item1 = false assert self.my_bar.something.item0 == 10 assert not self.my_bar.something.item1 - # We can set the tuple itself self.my_bar.something = (1, true) assert self.my_bar.something.item0 == 1 assert self.my_bar.something.item1 - return self.my_bar.name.to_mem() + } - pub fn complex_struct_in_memory(self) -> String<3>: - let val: Bar = Bar( - name: "foo", - numbers: [1, 2], - point: Point(x: 100, y: 200), - something: (1, true), - ) - - # Asserting the values as they were set initially + pub fn complex_struct_in_memory(self) -> String<3> { + let val: Bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) assert val.numbers[0] == 1 assert val.numbers[1] == 2 assert val.point.x == 100 assert val.point.y == 200 assert val.something.item0 == 1 assert val.something.item1 - - # We can change the values of the array val.numbers[0] = 10 val.numbers[1] = 20 assert val.numbers[0] == 10 assert val.numbers[1] == 20 - # We can set the array itself val.numbers = [1, 2] assert val.numbers[0] == 1 assert val.numbers[1] == 2 - - # We can change the values of the Point val.point.x = 1000 val.point.y = 2000 assert val.point.x == 1000 assert val.point.y == 2000 - # We can set the point itself val.point = Point(x: 100, y: 200) assert val.point.x == 100 assert val.point.y == 200 - - # We can change the value of the tuple val.something.item0 = 10 val.something.item1 = false assert val.something.item0 == 10 assert not val.something.item1 - # We can set the tuple itself val.something = (1, true) assert val.something.item0 == 1 assert val.something.item1 - return val.name + } - pub fn create_mixed(self) -> u256: - let mixed: Mixed = Mixed::new(val:1) + pub fn create_mixed(self) -> u256 { + let mixed: Mixed = Mixed::new(val: 1) return mixed.foo + } - pub fn set_house(self, data: House): + pub fn set_house(self, data: House) { self.my_house = data + } - pub fn get_house(self) -> House: + pub fn get_house(self) -> House { return self.my_house.to_mem() + } - pub fn create_house(self): - self.my_house = House( - price: 1, - size: 2, - rooms: u8(5), - vacant: false, - ) + pub fn create_house(self) { + self.my_house = House(price: 1, size: 2, rooms: u8(5), vacant: false) assert self.my_house.price == 1 assert self.my_house.size == 2 assert self.my_house.rooms == u8(5) assert self.my_house.vacant == false - # We change only the size and check other fields are unchanged self.my_house.size = 50 assert self.my_house.size == 50 assert self.my_house.price == 1 assert self.my_house.rooms == u8(5) assert self.my_house.vacant == false - # We change only the price and check other fields are unchanged self.my_house.price = 1000 assert self.my_house.size == 50 assert self.my_house.price == 1000 @@ -177,49 +150,35 @@ contract Foo: assert self.my_house.price == 1000 assert self.my_house.rooms == u8(100) assert self.my_house.vacant + } - pub fn bar() -> u256: - let building: House = House( - price: 300, - size: 500, - rooms: u8(20), - vacant: true, - ) + pub fn bar() -> u256 { + let building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) assert building.size == 500 assert building.price == 300 assert building.rooms == u8(20) assert building.vacant - building.vacant = false building.price = 1 building.size = 2 building.rooms = u8(10) - assert building.vacant == false assert building.price == 1 assert building.size == 2 assert building.rooms == u8(10) - building.expand() assert building.size == 102 assert building.rooms == 11 - return building.size + } - pub fn encode_house() -> Array: - let house: House = House( - price: 300, - size: 500, - rooms: u8(20), - vacant: true, - ) + pub fn encode_house() -> Array { + let house: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) return house.encode() + } - pub fn hashed_house() -> u256: - let house: House = House( - price: 300, - size: 500, - rooms: u8(20), - vacant: true, - ) + pub fn hashed_house() -> u256 { + let house: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) return house.hash() + } +} diff --git a/crates/test-files/fixtures/features/ternary_expression.fe b/crates/test-files/fixtures/features/ternary_expression.fe index 6ded5c1cde..85a38bc039 100644 --- a/crates/test-files/fixtures/features/ternary_expression.fe +++ b/crates/test-files/fixtures/features/ternary_expression.fe @@ -1,4 +1,5 @@ -contract Foo: - - pub fn bar(input: u256) -> u256: - return 1 if input > 5 else 0 \ No newline at end of file +contract Foo { + pub fn bar(input: u256) -> u256 { + return 1 if input > 5 else 0 + } +} diff --git a/crates/test-files/fixtures/features/tuple_destructuring.fe b/crates/test-files/fixtures/features/tuple_destructuring.fe index 4c60e88093..b2dc186820 100644 --- a/crates/test-files/fixtures/features/tuple_destructuring.fe +++ b/crates/test-files/fixtures/features/tuple_destructuring.fe @@ -1,11 +1,15 @@ -contract Foo: - pub fn bar() -> u256: +contract Foo { + pub fn bar() -> u256 { let (x, y): (u256, bool) = (42, true) return x + } - pub fn baz(n: u256, b: bool) -> u256: + pub fn baz(n: u256, b: bool) -> u256 { let (x, y): (u256, bool) = make_tuple(n, b) return x + } - fn make_tuple(n: u256, b: bool) -> (u256, bool): + fn make_tuple(n: u256, b: bool) -> (u256, bool) { return (n, b) + } +} diff --git a/crates/test-files/fixtures/features/two_contracts.fe b/crates/test-files/fixtures/features/two_contracts.fe index 552c27fb4e..63662b4f5d 100644 --- a/crates/test-files/fixtures/features/two_contracts.fe +++ b/crates/test-files/fixtures/features/two_contracts.fe @@ -1,23 +1,30 @@ use std::context::Context -contract Foo: +contract Foo { other: Bar - pub fn __init__(self, ctx: Context): + pub fn __init__(self, ctx: Context) { self.other = Bar.create(ctx, 0) + } - pub fn foo(self, ctx: Context) -> u256: + pub fn foo(self, ctx: Context) -> u256 { self.other.set_foo_addr(ctx.self_address()) return self.other.answer() + } - pub fn add(_ x: u256, _ y: u256) -> u256: + pub fn add(_ x: u256, _ y: u256) -> u256 { return x + y + } +} -contract Bar: +contract Bar { other: Foo - pub fn set_foo_addr(self, ctx: Context, _ addr: address): + pub fn set_foo_addr(self, ctx: Context, _ addr: address) { self.other = Foo(ctx, addr) + } - pub fn answer(self) -> u256: + pub fn answer(self) -> u256 { return self.other.add(20, 22) + } +} diff --git a/crates/test-files/fixtures/features/type_aliases.fe b/crates/test-files/fixtures/features/type_aliases.fe index 80738f72b9..8b6fe86ef7 100644 --- a/crates/test-files/fixtures/features/type_aliases.fe +++ b/crates/test-files/fixtures/features/type_aliases.fe @@ -1,30 +1,38 @@ use std::context::Context type Posts = Map + type Scoreboard = Map + type AuthorPosts = Map type Author = address + type Score = u64 + type PostId = u256 + type PostBody = String<32> -contract Forum: +contract Forum { posts: Posts authors: AuthorPosts scoreboard: Scoreboard - pub fn post(self, ctx: Context, body: PostBody): - # id: PostId = keccak256(body.abi_encode()) + pub fn post(self, ctx: Context, body: PostBody) { let id: PostId = 0 self.posts[id] = body self.authors[ctx.msg_sender()] self.scoreboard[id] = 0 + } - pub fn upvote(self, id: PostId) -> Score: + pub fn upvote(self, id: PostId) -> Score { let score: Score = self.scoreboard[id] + 1 self.scoreboard[id] = score return score + } - pub fn get_post(self, id: PostId) -> PostBody: - return self.posts[id].to_mem() \ No newline at end of file + pub fn get_post(self, id: PostId) -> PostBody { + return self.posts[id].to_mem() + } +} diff --git a/crates/test-files/fixtures/features/u128_u128_map.fe b/crates/test-files/fixtures/features/u128_u128_map.fe index 1c013d4e47..d6d70b67e3 100644 --- a/crates/test-files/fixtures/features/u128_u128_map.fe +++ b/crates/test-files/fixtures/features/u128_u128_map.fe @@ -1,8 +1,11 @@ -contract Foo: +contract Foo { bar: Map - pub fn read_bar(self, key: u128) -> u128: + pub fn read_bar(self, key: u128) -> u128 { return self.bar[key] + } - pub fn write_bar(self, key: u128, value: u128): - self.bar[key] = value \ No newline at end of file + pub fn write_bar(self, key: u128, value: u128) { + self.bar[key] = value + } +} diff --git a/crates/test-files/fixtures/features/u16_u16_map.fe b/crates/test-files/fixtures/features/u16_u16_map.fe index 52df7ae2e3..6d98a40cde 100644 --- a/crates/test-files/fixtures/features/u16_u16_map.fe +++ b/crates/test-files/fixtures/features/u16_u16_map.fe @@ -1,8 +1,11 @@ -contract Foo: +contract Foo { bar: Map - pub fn read_bar(self, key: u16) -> u16: + pub fn read_bar(self, key: u16) -> u16 { return self.bar[key] + } - pub fn write_bar(self, key: u16, value: u16): - self.bar[key] = value \ No newline at end of file + pub fn write_bar(self, key: u16, value: u16) { + self.bar[key] = value + } +} diff --git a/crates/test-files/fixtures/features/u256_u256_map.fe b/crates/test-files/fixtures/features/u256_u256_map.fe index e0946fc5c4..ceedbf4e3a 100644 --- a/crates/test-files/fixtures/features/u256_u256_map.fe +++ b/crates/test-files/fixtures/features/u256_u256_map.fe @@ -1,8 +1,11 @@ -contract Foo: +contract Foo { bar: Map - pub fn read_bar(self, key: u256) -> u256: + pub fn read_bar(self, key: u256) -> u256 { return self.bar[key] + } - pub fn write_bar(self, key: u256, value: u256): - self.bar[key] = value \ No newline at end of file + pub fn write_bar(self, key: u256, value: u256) { + self.bar[key] = value + } +} diff --git a/crates/test-files/fixtures/features/u32_u32_map.fe b/crates/test-files/fixtures/features/u32_u32_map.fe index 8286418470..37730309fc 100644 --- a/crates/test-files/fixtures/features/u32_u32_map.fe +++ b/crates/test-files/fixtures/features/u32_u32_map.fe @@ -1,8 +1,11 @@ -contract Foo: +contract Foo { bar: Map - pub fn read_bar(self, key: u32) -> u32: + pub fn read_bar(self, key: u32) -> u32 { return self.bar[key] + } - pub fn write_bar(self, key: u32, value: u32): - self.bar[key] = value \ No newline at end of file + pub fn write_bar(self, key: u32, value: u32) { + self.bar[key] = value + } +} diff --git a/crates/test-files/fixtures/features/u64_u64_map.fe b/crates/test-files/fixtures/features/u64_u64_map.fe index 248377e9a4..523b0201fc 100644 --- a/crates/test-files/fixtures/features/u64_u64_map.fe +++ b/crates/test-files/fixtures/features/u64_u64_map.fe @@ -1,8 +1,11 @@ -contract Foo: +contract Foo { bar: Map - pub fn read_bar(self, key: u64) -> u64: + pub fn read_bar(self, key: u64) -> u64 { return self.bar[key] + } - pub fn write_bar(self, key: u64, value: u64): - self.bar[key] = value \ No newline at end of file + pub fn write_bar(self, key: u64, value: u64) { + self.bar[key] = value + } +} diff --git a/crates/test-files/fixtures/features/u8_u8_map.fe b/crates/test-files/fixtures/features/u8_u8_map.fe index 40e6fe90c9..d9cdd74259 100644 --- a/crates/test-files/fixtures/features/u8_u8_map.fe +++ b/crates/test-files/fixtures/features/u8_u8_map.fe @@ -1,8 +1,11 @@ -contract Foo: +contract Foo { bar: Map - pub fn read_bar(self, key: u8) -> u8: + pub fn read_bar(self, key: u8) -> u8 { return self.bar[key] + } - pub fn write_bar(self, key: u8, value: u8): - self.bar[key] = value \ No newline at end of file + pub fn write_bar(self, key: u8, value: u8) { + self.bar[key] = value + } +} diff --git a/crates/test-files/fixtures/features/while_loop.fe b/crates/test-files/fixtures/features/while_loop.fe index a34587ca9e..1eac9e0284 100644 --- a/crates/test-files/fixtures/features/while_loop.fe +++ b/crates/test-files/fixtures/features/while_loop.fe @@ -1,8 +1,12 @@ -contract Foo: - pub fn bar() -> u256: +contract Foo { + pub fn bar() -> u256 { let val: u256 = 0 - while val < 2: + while val < 2 { val = val + 1 - if val == 2: + if val == 2 { val = 3 + } + } return val + } +} diff --git a/crates/test-files/fixtures/features/while_loop_test_from_sto.fe b/crates/test-files/fixtures/features/while_loop_test_from_sto.fe index 7ee5cca8f5..865acdef86 100644 --- a/crates/test-files/fixtures/features/while_loop_test_from_sto.fe +++ b/crates/test-files/fixtures/features/while_loop_test_from_sto.fe @@ -1,10 +1,11 @@ -contract Foo: +contract Foo { my_bool: bool - pub fn bar(self) -> u256: + pub fn bar(self) -> u256 { self.my_bool = false + while self.my_bool { - while self.my_bool: - pass - - return 42 \ No newline at end of file + } + return 42 + } +} diff --git a/crates/test-files/fixtures/features/while_loop_with_break.fe b/crates/test-files/fixtures/features/while_loop_with_break.fe index c5f2f3e265..38f9fd64be 100644 --- a/crates/test-files/fixtures/features/while_loop_with_break.fe +++ b/crates/test-files/fixtures/features/while_loop_with_break.fe @@ -1,7 +1,10 @@ -contract Foo: - pub fn bar() -> u256: +contract Foo { + pub fn bar() -> u256 { let val: u256 = 0 - while val < 2: + while val < 2 { val = val + 1 break + } return val + } +} diff --git a/crates/test-files/fixtures/features/while_loop_with_break_2.fe b/crates/test-files/fixtures/features/while_loop_with_break_2.fe index e6e7412d35..e27f106540 100644 --- a/crates/test-files/fixtures/features/while_loop_with_break_2.fe +++ b/crates/test-files/fixtures/features/while_loop_with_break_2.fe @@ -1,8 +1,12 @@ -contract Foo: - pub fn bar() -> u256: +contract Foo { + pub fn bar() -> u256 { let val: u256 = 0 - while val < 2: + while val < 2 { val = val + 1 - if val == 1: + if val == 1 { break + } + } return val + } +} diff --git a/crates/test-files/fixtures/features/while_loop_with_continue.fe b/crates/test-files/fixtures/features/while_loop_with_continue.fe index ead49e76d7..8823bbf924 100644 --- a/crates/test-files/fixtures/features/while_loop_with_continue.fe +++ b/crates/test-files/fixtures/features/while_loop_with_continue.fe @@ -1,11 +1,14 @@ -contract Foo: - pub fn bar() -> u256: +contract Foo { + pub fn bar() -> u256 { let i: u256 = 0 let counter: u256 = 0 - - while i < 2: + while i < 2 { i = i + 1 - if i == 1: + if i == 1 { continue + } counter = counter + 1 + } return counter + } +} diff --git a/crates/test-files/fixtures/ingots/basic_ingot/src/bar.fe b/crates/test-files/fixtures/ingots/basic_ingot/src/bar.fe index 3cb373f595..6ab24bcb2f 100644 --- a/crates/test-files/fixtures/ingots/basic_ingot/src/bar.fe +++ b/crates/test-files/fixtures/ingots/basic_ingot/src/bar.fe @@ -1,3 +1,3 @@ - -pub fn file_items_work() -> bool: - return true +pub fn file_items_work() -> bool { + return true +} diff --git a/crates/test-files/fixtures/ingots/basic_ingot/src/bar/baz.fe b/crates/test-files/fixtures/ingots/basic_ingot/src/bar/baz.fe index 90ddb562bd..e98036c2f1 100644 --- a/crates/test-files/fixtures/ingots/basic_ingot/src/bar/baz.fe +++ b/crates/test-files/fixtures/ingots/basic_ingot/src/bar/baz.fe @@ -1,3 +1,4 @@ -pub struct Baz: +pub struct Baz { pub my_bool: bool pub my_u256: u256 +} diff --git a/crates/test-files/fixtures/ingots/basic_ingot/src/bar/mee.fe b/crates/test-files/fixtures/ingots/basic_ingot/src/bar/mee.fe index 05b8305f03..238c21dab1 100644 --- a/crates/test-files/fixtures/ingots/basic_ingot/src/bar/mee.fe +++ b/crates/test-files/fixtures/ingots/basic_ingot/src/bar/mee.fe @@ -1,6 +1,9 @@ -pub struct Mee: - pub fn kawum() -> u256: +pub struct Mee { + pub fn kawum() -> u256 { return 1 + } - pub fn rums(self) -> u256: - return 1 \ No newline at end of file + pub fn rums(self) -> u256 { + return 1 + } +} diff --git a/crates/test-files/fixtures/ingots/basic_ingot/src/bing.fe b/crates/test-files/fixtures/ingots/basic_ingot/src/bing.fe index e98cb7b3d3..0eaa9b923d 100644 --- a/crates/test-files/fixtures/ingots/basic_ingot/src/bing.fe +++ b/crates/test-files/fixtures/ingots/basic_ingot/src/bing.fe @@ -1,11 +1,15 @@ use std::error::Error -pub struct Bing: +pub struct Bing { pub my_address: address +} -pub fn get_42_backend() -> u256: +pub fn get_42_backend() -> u256 { return std::evm::add(21, 21) +} -pub contract BingContract: - pub fn add(_ x: u256, _ y: u256) -> u256: - return x + y +pub contract BingContract { + pub fn add(_ x: u256, _ y: u256) -> u256 { + return x + y + } +} diff --git a/crates/test-files/fixtures/ingots/basic_ingot/src/ding/dang.fe b/crates/test-files/fixtures/ingots/basic_ingot/src/ding/dang.fe index 050377d346..9d3f08aae1 100644 --- a/crates/test-files/fixtures/ingots/basic_ingot/src/ding/dang.fe +++ b/crates/test-files/fixtures/ingots/basic_ingot/src/ding/dang.fe @@ -1 +1 @@ -type Dang = Array \ No newline at end of file +type Dang = Array diff --git a/crates/test-files/fixtures/ingots/basic_ingot/src/ding/dong.fe b/crates/test-files/fixtures/ingots/basic_ingot/src/ding/dong.fe index 4741ddc957..b41de98145 100644 --- a/crates/test-files/fixtures/ingots/basic_ingot/src/ding/dong.fe +++ b/crates/test-files/fixtures/ingots/basic_ingot/src/ding/dong.fe @@ -1,9 +1,11 @@ use ingot::bing::Bing -pub struct Dyng: - pub my_address: address - pub my_u256: u256 - pub my_i8: i8 +pub struct Dyng { + pub my_address: address + pub my_u256: u256 + pub my_i8: i8 +} -fn get_bing() -> Bing: +fn get_bing() -> Bing { return Bing(my_address: address(0)) +} diff --git a/crates/test-files/fixtures/ingots/basic_ingot/src/main.fe b/crates/test-files/fixtures/ingots/basic_ingot/src/main.fe index 9a07c0a6ac..9db2e0a904 100644 --- a/crates/test-files/fixtures/ingots/basic_ingot/src/main.fe +++ b/crates/test-files/fixtures/ingots/basic_ingot/src/main.fe @@ -6,31 +6,35 @@ use ding::{dang::Dang as Dung, dong} use bing::BingContract use std::context::Context -contract Foo: - pub fn get_my_baz() -> Baz: +contract Foo { + pub fn get_my_baz() -> Baz { assert file_items_work() return Baz(my_bool: true, my_u256: 26) + } - pub fn get_my_bing() -> Bong: + pub fn get_my_bing() -> Bong { return Bong(my_address: address(42)) + } - pub fn get_42() -> u256: + pub fn get_42() -> u256 { return get_42_backend() + } - pub fn get_26() -> u256: + pub fn get_26() -> u256 { return std::evm::add(13, 13) + } - pub fn call_on_path(): + pub fn call_on_path() { assert bar::mee::Mee::kawum() == 1 assert bar::mee::Mee().rums() == 1 + } - pub fn get_my_dyng() -> dong::Dyng: - return dong::Dyng( - my_address: address(8), - my_u256: 42, - my_i8: -1 - ) + pub fn get_my_dyng() -> dong::Dyng { + return dong::Dyng(my_address: address(8), my_u256: 42, my_i8: -1) + } - pub fn create_bing_contract(ctx: Context) -> u256: + pub fn create_bing_contract(ctx: Context) -> u256 { let bing_contract: BingContract = BingContract.create(ctx, 0) - return bing_contract.add(40, 50) \ No newline at end of file + return bing_contract.add(40, 50) + } +} diff --git a/crates/test-files/fixtures/ingots/pub_contract_ingot/src/foo.fe b/crates/test-files/fixtures/ingots/pub_contract_ingot/src/foo.fe index a3e230c8dd..7012642796 100644 --- a/crates/test-files/fixtures/ingots/pub_contract_ingot/src/foo.fe +++ b/crates/test-files/fixtures/ingots/pub_contract_ingot/src/foo.fe @@ -1,9 +1,13 @@ -pub struct Foo: +pub struct Foo { my_address: address +} -pub struct Bar: +pub struct Bar { pub my_u256: u256 +} -pub contract FooBar: - pub fn add(_ x: u256, _ y: u256) -> u256: - return x + y \ No newline at end of file +pub contract FooBar { + pub fn add(_ x: u256, _ y: u256) -> u256 { + return x + y + } +} diff --git a/crates/test-files/fixtures/ingots/pub_contract_ingot/src/main.fe b/crates/test-files/fixtures/ingots/pub_contract_ingot/src/main.fe index ca69455de2..3631591b1c 100644 --- a/crates/test-files/fixtures/ingots/pub_contract_ingot/src/main.fe +++ b/crates/test-files/fixtures/ingots/pub_contract_ingot/src/main.fe @@ -1,12 +1,13 @@ use foo::{Foo, Bar, FooBar} use std::context::Context -contract FooBarBing: - pub fn get_bar() -> Bar: - return Bar( - my_u256: 24 - ) +contract FooBarBing { + pub fn get_bar() -> Bar { + return Bar(my_u256: 24) + } - pub fn create_foobar_contract(ctx: Context) -> u256: + pub fn create_foobar_contract(ctx: Context) -> u256 { let foo_bar: FooBar = FooBar.create(ctx, 0) return foo_bar.add(40, 50) + } +} diff --git a/crates/test-files/fixtures/ingots/visibility_ingot/src/foo.fe b/crates/test-files/fixtures/ingots/visibility_ingot/src/foo.fe index 88086f4800..9cc700fffd 100644 --- a/crates/test-files/fixtures/ingots/visibility_ingot/src/foo.fe +++ b/crates/test-files/fixtures/ingots/visibility_ingot/src/foo.fe @@ -1,11 +1,15 @@ -pub struct Bing: - pub my_address: address +pub struct Bing { + pub my_address: address +} -fn get_42_backend() -> u256: +fn get_42_backend() -> u256 { return 42 +} pub type Precision = u256 -contract BingContract: - pub fn add(x: u256, y: u256) -> u256: +contract BingContract { + pub fn add(x: u256, y: u256) -> u256 { return x + y + } +} diff --git a/crates/test-files/fixtures/ingots/visibility_ingot/src/main.fe b/crates/test-files/fixtures/ingots/visibility_ingot/src/main.fe index 4b276df221..bcc51b3858 100644 --- a/crates/test-files/fixtures/ingots/visibility_ingot/src/main.fe +++ b/crates/test-files/fixtures/ingots/visibility_ingot/src/main.fe @@ -1,8 +1,11 @@ use foo::{get_42_backend, Precision, Bing} -contract Foo: - pub fn get_addr() -> Bing: +contract Foo { + pub fn get_addr() -> Bing { return Bing(my_address: address(24)) + } - pub fn get_precision() -> Precision: - return 18 \ No newline at end of file + pub fn get_precision() -> Precision { + return 18 + } +} diff --git a/crates/test-files/fixtures/lowering/and_or.fe b/crates/test-files/fixtures/lowering/and_or.fe index 1ce17444e2..8e3b25c102 100644 --- a/crates/test-files/fixtures/lowering/and_or.fe +++ b/crates/test-files/fixtures/lowering/and_or.fe @@ -1,54 +1,65 @@ -contract Foo: - - pub fn bar() -> bool: +contract Foo { + pub fn bar() -> bool { return baz(false or true) + } - pub fn nested(): - if true: + pub fn nested() { + if true { let a: bool = true let b: bool = false let x: bool = true let y: bool = false return double_baz(a and b, x or y) + } + } - pub fn nested_ternary() -> bool: + pub fn nested_ternary() -> bool { let a: bool = true let b: bool = false let x: bool = true let y: bool = false return baz(a and b) and (x and y) + } - pub fn in_dec(): + pub fn in_dec() { let a: bool = true let b: bool = false let x: bool = true let y: bool = false - let z: (bool, bool) = (a and b, x or y) + } - pub fn short_or(_ first: bool, _ second: bool, _ third: bool, _ fourth: bool) -> bool: + pub fn short_or(_ first: bool, _ second: bool, _ third: bool, _ fourth: bool) -> bool { return first or second or third or fourth + } - pub fn short_or2(_ first: bool, _ second: bool, _ third: bool, _ fourth: bool) -> bool: - return (first or second) or (third or fourth) + pub fn short_or2(_ first: bool, _ second: bool, _ third: bool, _ fourth: bool) -> bool { + return first or second or (third or fourth) + } - pub fn short_or3(_ first: bool, _ second: bool, _ third: bool, _ fourth: bool) -> bool: - return (first or second) or third or fourth + pub fn short_or3(_ first: bool, _ second: bool, _ third: bool, _ fourth: bool) -> bool { + return first or second or third or fourth + } - pub fn short_and(_ first: bool, _ second: bool, _ third: bool, _ fourth: bool) -> bool: + pub fn short_and(_ first: bool, _ second: bool, _ third: bool, _ fourth: bool) -> bool { return first and second and third and fourth + } - pub fn short_and2(_ first: bool, _ second: bool, _ third: bool, _ fourth: bool) -> bool: - return (first and second) and (third and fourth) + pub fn short_and2(_ first: bool, _ second: bool, _ third: bool, _ fourth: bool) -> bool { + return first and second and (third and fourth) + } - pub fn short_and3(_ first: bool, _ second: bool, _ third: bool, _ fourth: bool) -> bool: - return (first and second) and third and fourth + pub fn short_and3(_ first: bool, _ second: bool, _ third: bool, _ fourth: bool) -> bool { + return first and second and third and fourth + } - pub fn short_mixed(_ first: bool, _ second: bool, _ third: bool, _ fourth: bool) -> bool: + pub fn short_mixed(_ first: bool, _ second: bool, _ third: bool, _ fourth: bool) -> bool { return (first or second) and third or fourth + } - pub fn baz(_ val: bool) -> bool: + pub fn baz(_ val: bool) -> bool { return val + } - pub fn double_baz(_ val: bool, _ val2: bool): - pass + pub fn double_baz(_ val: bool, _ val2: bool) {} +} diff --git a/crates/test-files/fixtures/lowering/array_tuple.fe b/crates/test-files/fixtures/lowering/array_tuple.fe index fef394a25b..b4ecf7b4fe 100644 --- a/crates/test-files/fixtures/lowering/array_tuple.fe +++ b/crates/test-files/fixtures/lowering/array_tuple.fe @@ -1,6 +1,8 @@ -contract Foo: - tuples: (u256, address)[10] +contract Foo { + tuples: Array<(u256, address), 10> - pub fn bar(self, x: u256) -> u256: + pub fn bar(self, x: u256) -> u256 { self.tuples[0] = (x, address(x)) return self.tuples[0].item0 + } +} diff --git a/crates/test-files/fixtures/lowering/aug_assign.fe b/crates/test-files/fixtures/lowering/aug_assign.fe index 180e92fa8f..da6bbd2e38 100644 --- a/crates/test-files/fixtures/lowering/aug_assign.fe +++ b/crates/test-files/fixtures/lowering/aug_assign.fe @@ -1,57 +1,71 @@ -contract Foo: +contract Foo { my_num: u256 - pub fn add(a: u256, b: u256) -> u256: + pub fn add(a: u256, b: u256) -> u256 { a += b return a + } - pub fn sub(a: u256, b: u256) -> u256: + pub fn sub(a: u256, b: u256) -> u256 { a -= b return a + } - pub fn mul(a: u256, b: u256) -> u256: + pub fn mul(a: u256, b: u256) -> u256 { a *= b return a + } - pub fn div(a: u256, b: u256) -> u256: + pub fn div(a: u256, b: u256) -> u256 { a /= b return a + } - pub fn mod(a: u256, b: u256) -> u256: + pub fn mod(a: u256, b: u256) -> u256 { a %= b return a + } - pub fn pow(a: u256, b: u256) -> u256: + pub fn pow(a: u256, b: u256) -> u256 { a **= b return a + } - pub fn lshift(a: u8, b: u8) -> u8: + pub fn lshift(a: u8, b: u8) -> u8 { a <<= b return a + } - pub fn rshift(a: u8, b: u8) -> u8: + pub fn rshift(a: u8, b: u8) -> u8 { a >>= b return a + } - pub fn bit_or(a: u8, b: u8) -> u8: + pub fn bit_or(a: u8, b: u8) -> u8 { a |= b return a + } - pub fn bit_xor(a: u8, b: u8) -> u8: + pub fn bit_xor(a: u8, b: u8) -> u8 { a ^= b return a + } - pub fn bit_and(a: u8, b: u8) -> u8: + pub fn bit_and(a: u8, b: u8) -> u8 { a &= b return a + } - pub fn add_from_sto(self, a: u256, b: u256) -> u256: + pub fn add_from_sto(self, a: u256, b: u256) -> u256 { self.my_num = a self.my_num += b return self.my_num + } - pub fn add_from_mem(a: u256, b: u256) -> u256: + pub fn add_from_mem(a: u256, b: u256) -> u256 { let my_array: Array my_array[7] = a my_array[7] += b return my_array[7] + } +} diff --git a/crates/test-files/fixtures/lowering/base_tuple.fe b/crates/test-files/fixtures/lowering/base_tuple.fe index 9eb4ac0f72..8f23697ea5 100644 --- a/crates/test-files/fixtures/lowering/base_tuple.fe +++ b/crates/test-files/fixtures/lowering/base_tuple.fe @@ -1,31 +1,28 @@ use std::context::Context -contract Foo: +contract Foo { my_tuple_field: (bool, address) - event MyEvent: + event MyEvent { my_tuple: (bool, bool) my_other_tuple: (address, address) + } - pub fn bar(my_num: u256, my_bool: bool) -> (u256, bool): + pub fn bar(my_num: u256, my_bool: bool) -> (u256, bool) { return (my_num, my_bool) + } - pub fn baz() -> (u256, bool, u8, address): + pub fn baz() -> (u256, bool, u8, address) { return (999999, false, u8(42), address(26)) + } - pub fn bing(): + pub fn bing() { let foo: (address, address, u16, i32, bool) = (address(0), address(0), u16(0), i32(0), false) + } - pub fn bop( - my_tuple1: (u256, bool), - my_tuple2: (u256, bool, u8, address), - my_tuple3: (address, address, u16, i32, bool) - ): - pass + pub fn bop(my_tuple1: (u256, bool), my_tuple2: (u256, bool, u8, address), my_tuple3: (address, address, u16, i32, bool)) {} - pub fn food(ctx: Context): - emit MyEvent( - ctx, - my_tuple: (false, true), - my_other_tuple: (address(0), address(1)) - ) \ No newline at end of file + pub fn food(ctx: Context) { + emit MyEvent(ctx, my_tuple: (false, true), my_other_tuple: (address(0), address(1))) + } +} diff --git a/crates/test-files/fixtures/lowering/custom_empty_type.fe b/crates/test-files/fixtures/lowering/custom_empty_type.fe index 61e9b20874..8105cbc09e 100644 --- a/crates/test-files/fixtures/lowering/custom_empty_type.fe +++ b/crates/test-files/fixtures/lowering/custom_empty_type.fe @@ -1,6 +1,7 @@ -struct MyEmptyType: - pass +struct MyEmptyType {} -contract Foo: - pub fn bar() -> MyEmptyType: - return MyEmptyType() \ No newline at end of file +contract Foo { + pub fn bar() -> MyEmptyType { + return MyEmptyType() + } +} diff --git a/crates/test-files/fixtures/lowering/init.fe b/crates/test-files/fixtures/lowering/init.fe index 816492b73a..15237ae36c 100644 --- a/crates/test-files/fixtures/lowering/init.fe +++ b/crates/test-files/fixtures/lowering/init.fe @@ -1,3 +1,3 @@ -contract Foo: - pub fn __init__(): - pass \ No newline at end of file +contract Foo { + pub fn __init__() {} +} diff --git a/crates/test-files/fixtures/lowering/list_expressions.fe b/crates/test-files/fixtures/lowering/list_expressions.fe index a41fdbbdbe..57fce2eead 100644 --- a/crates/test-files/fixtures/lowering/list_expressions.fe +++ b/crates/test-files/fixtures/lowering/list_expressions.fe @@ -1,4 +1,6 @@ -contract Foo: - pub fn foo(): +contract Foo { + pub fn foo() { let x: Array = [10, 20, 30] [] + } +} diff --git a/crates/test-files/fixtures/lowering/map_tuple.fe b/crates/test-files/fixtures/lowering/map_tuple.fe index 3f4676dea7..c4a0814960 100644 --- a/crates/test-files/fixtures/lowering/map_tuple.fe +++ b/crates/test-files/fixtures/lowering/map_tuple.fe @@ -1,6 +1,8 @@ -contract Foo: +contract Foo { tuples: Map - pub fn bar(self, x: u256) -> u256: + pub fn bar(self, x: u256) -> u256 { self.tuples[0] = (address(100), (x, 5)) return self.tuples[0].item1.item0 + } +} diff --git a/crates/test-files/fixtures/lowering/module_const.fe b/crates/test-files/fixtures/lowering/module_const.fe index 25fadb684b..dd407602b7 100644 --- a/crates/test-files/fixtures/lowering/module_const.fe +++ b/crates/test-files/fixtures/lowering/module_const.fe @@ -1,43 +1,46 @@ const THREE: u256 = 3 -const TEN: u256 = 10 -const IS_ADMIN: bool = true -const UNIT: () = () - -struct Bar: - pub val: u256 - -contract Foo: - - table: Map - - pub fn revert_with_bar(): - revert Bar(val: TEN) - - pub fn return_unit(): - return UNIT - pub fn usage(self) -> u256: - - let my_calc: u256 = THREE * TEN - let my_other_calc: u256 = THREE * 3 - - let my_array: Array = [THREE, TEN] - let my_tuple: (u256, u256) = (THREE, TEN) - let my_bar: Bar = Bar(val: THREE) - - while THREE > 4: - pass - - for x in [THREE, TEN]: - pass +const TEN: u256 = 10 - self.table[TEN] = THREE +const IS_ADMIN: bool = true - if THREE == TEN: - pass - elif TEN == 10: - return THREE * TEN - elif IS_ADMIN: - revert Bar(val: THREE) +const UNIT: () = () - return self.table[THREE] +struct Bar { + pub val: u256 +} + +contract Foo { + table: Map + + pub fn revert_with_bar() { + revert Bar(val: TEN) + } + + pub fn return_unit() { + return UNIT + } + + pub fn usage(self) -> u256 { + let my_calc: u256 = THREE * TEN + let my_other_calc: u256 = THREE * 3 + let my_array: Array = [THREE, TEN] + let my_tuple: (u256, u256) = (THREE, TEN) + let my_bar: Bar = Bar(val: THREE) + while THREE > 4 { + + } + for x in [THREE, TEN] { + + } + self.table[TEN] = THREE + if THREE == TEN { + + } else if TEN == 10 { + return THREE * TEN + } else if IS_ADMIN { + revert Bar(val: THREE) + } + return self.table[THREE] + } +} diff --git a/crates/test-files/fixtures/lowering/module_fn.fe b/crates/test-files/fixtures/lowering/module_fn.fe index bcbd553fd1..ca0c758c95 100644 --- a/crates/test-files/fixtures/lowering/module_fn.fe +++ b/crates/test-files/fixtures/lowering/module_fn.fe @@ -1,14 +1,19 @@ -fn return_tuple() -> (address, (u256, u8)): - return (address(0), (10, 20)) +fn return_tuple() -> (address, (u256, u8)) { + return (address(0), (10, 20)) +} -fn return_array() -> Array: - return [1, 2, 3] +fn return_array() -> Array { + return [1, 2, 3] +} -contract Foo: - pub fn bar(self) -> u256: +contract Foo { + pub fn bar(self) -> u256 { let tuple: (address, (u256, u8)) = return_tuple() return tuple.item1.item0 + } - pub fn sum_things() -> u8: + pub fn sum_things() -> u8 { let x: Array = return_array() return x[0] + x[1] + x[2] + } +} diff --git a/crates/test-files/fixtures/lowering/module_level_events.fe b/crates/test-files/fixtures/lowering/module_level_events.fe index 34edb7c033..96b59c943e 100644 --- a/crates/test-files/fixtures/lowering/module_level_events.fe +++ b/crates/test-files/fixtures/lowering/module_level_events.fe @@ -1,10 +1,13 @@ use std::context::Context -event Transfer: +event Transfer { idx sender: address idx receiver: address value: u256 +} -contract Foo: - fn transfer(ctx: Context, to : address, value : u256): +contract Foo { + fn transfer(ctx: Context, to: address, value: u256) { emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) + } +} diff --git a/crates/test-files/fixtures/lowering/nested_tuple.fe b/crates/test-files/fixtures/lowering/nested_tuple.fe index d006ff11a4..130ddffca7 100644 --- a/crates/test-files/fixtures/lowering/nested_tuple.fe +++ b/crates/test-files/fixtures/lowering/nested_tuple.fe @@ -1,6 +1,8 @@ -contract Foo: +contract Foo { tup: (u256, (u8, bool), (address, (u8, u8))) - pub fn bar(self, x: u256) -> u8: + pub fn bar(self, x: u256) -> u8 { self.tup = (1, (0, true), (address(0), (10, 100))) return self.tup.item2.item1.item0 + } +} diff --git a/crates/test-files/fixtures/lowering/return_unit.fe b/crates/test-files/fixtures/lowering/return_unit.fe index 30cd57db69..b7c2581b90 100644 --- a/crates/test-files/fixtures/lowering/return_unit.fe +++ b/crates/test-files/fixtures/lowering/return_unit.fe @@ -1,29 +1,35 @@ -contract Foo: - pub fn explicit_return_a1(): - return +contract Foo { + pub fn explicit_return_a1() { + return + } - pub fn explicit_return_a2(): - return () + pub fn explicit_return_a2() { + return () + } - pub fn explicit_return_b1() -> (): - return + pub fn explicit_return_b1() -> () { + return + } - pub fn explicit_return_b2() -> (): - return () + pub fn explicit_return_b2() -> () { + return () + } - pub fn implicit_a1(): - pass + pub fn implicit_a1() {} - pub fn implicit_a2() -> (): - pass + pub fn implicit_a2() -> () {} - pub fn if_elif_else() -> (): - if true: - return () - elif false: - return - else: - pass + pub fn if_elif_else() -> () { + if true { + return () + } else if false { + return + } else { + + } + } - pub fn tuple_stmt(): - () \ No newline at end of file + pub fn tuple_stmt() { + () + } +} diff --git a/crates/test-files/fixtures/lowering/struct_fn.fe b/crates/test-files/fixtures/lowering/struct_fn.fe index 318d7e130a..b4463ff4aa 100644 --- a/crates/test-files/fixtures/lowering/struct_fn.fe +++ b/crates/test-files/fixtures/lowering/struct_fn.fe @@ -1,15 +1,19 @@ -struct Foo: - pub x: u256 +struct Foo { + pub x: u256 - pub fn set_x(self, _ new: u256) -> u256: - let old: u256 = self.get_x() - self.x = new - return old + pub fn set_x(self, _ new: u256) -> u256 { + let old: u256 = self.get_x() + self.x = new + return old + } - pub fn get_x(self) -> u256: - return self.x + pub fn get_x(self) -> u256 { + return self.x + } +} -fn main(): - let foo: Foo = Foo(x: 10) - foo.set_x(100) - assert foo.get_x() == 100 +fn main() { + let foo: Foo = Foo(x: 10) + foo.set_x(100) + assert foo.get_x() == 100 +} diff --git a/crates/test-files/fixtures/lowering/ternary.fe b/crates/test-files/fixtures/lowering/ternary.fe index 88db5a17c3..6bc804e83c 100644 --- a/crates/test-files/fixtures/lowering/ternary.fe +++ b/crates/test-files/fixtures/lowering/ternary.fe @@ -1,33 +1,35 @@ -contract Foo: - - pub fn bar(): +contract Foo { + pub fn bar() { return baz(1 if true else 0) + } - pub fn nested(): - if true: + pub fn nested() { + if true { let a: u256 = 10 let b: u256 = 20 let x: u256 = 10 let y: u256 = 20 return double_baz(a if true else b, x if true else y) + } + } - pub fn nested_ternary(): + pub fn nested_ternary() { let a: u256 = 10 let b: u256 = 20 let x: u256 = 10 let y: u256 = 20 - return baz(a if true else (x if true else y)) + return baz(a if true else x if true else y) + } - pub fn in_dec(): + pub fn in_dec() { let a: u256 = 10 let b: u256 = 20 let x: u256 = 10 let y: u256 = 20 - let z: (u256, u256) = (a if true else b, x if true else y) + } - pub fn baz(_ val: u256): - pass + pub fn baz(_ val: u256) {} - pub fn double_baz(_ val1: u256, _ val2: u256): - pass + pub fn double_baz(_ val1: u256, _ val2: u256) {} +} diff --git a/crates/test-files/fixtures/lowering/tuple_destruct.fe b/crates/test-files/fixtures/lowering/tuple_destruct.fe index 028a1ad6ce..a39d4ec9a5 100644 --- a/crates/test-files/fixtures/lowering/tuple_destruct.fe +++ b/crates/test-files/fixtures/lowering/tuple_destruct.fe @@ -1,6 +1,8 @@ -contract Foo: +contract Foo { my_sto_tuple: (bool, bool, address, u8) - pub fn bar(self, my_tuple: (u256, bool)): + pub fn bar(self, my_tuple: (u256, bool)) { let (my_u256, my_bool): (u256, bool) = my_tuple - let (a, b, c, d): (bool, bool, address, u8) = self.my_sto_tuple.to_mem() \ No newline at end of file + let (a, b, c, d): (bool, bool, address, u8) = self.my_sto_tuple.to_mem() + } +} diff --git a/crates/test-files/fixtures/lowering/type_alias_tuple.fe b/crates/test-files/fixtures/lowering/type_alias_tuple.fe index 8166372f0a..8cf28a6465 100644 --- a/crates/test-files/fixtures/lowering/type_alias_tuple.fe +++ b/crates/test-files/fixtures/lowering/type_alias_tuple.fe @@ -1,4 +1,5 @@ type Tup = (u8, address) -contract Foo: +contract Foo { tup: Tup +} diff --git a/crates/test-files/fixtures/lowering/unit_implicit.fe b/crates/test-files/fixtures/lowering/unit_implicit.fe index b70abda24d..bfc0c0a6ce 100644 --- a/crates/test-files/fixtures/lowering/unit_implicit.fe +++ b/crates/test-files/fixtures/lowering/unit_implicit.fe @@ -1,3 +1,3 @@ -contract Foo: - fn bar(): - pass \ No newline at end of file +contract Foo { + fn bar() {} +} diff --git a/crates/test-files/fixtures/printing/defs.fe b/crates/test-files/fixtures/printing/defs.fe index af0d5ebd09..43a4076567 100644 --- a/crates/test-files/fixtures/printing/defs.fe +++ b/crates/test-files/fixtures/printing/defs.fe @@ -1,41 +1,55 @@ use foo::bar as baz - use foo::food - use bing::bong::* - use test1::{test1_1, test1_2::{test_1_2_1::*}} type MyType = String<42> -struct MyStruct: +struct MyStruct { field1: foo::Bar field2: u256 field3: address - pub fn field2_squared(self) -> u256: + pub fn field2_squared(self) -> u256 { return self.field2 * self.field2 + } +} -struct EmptyType: - pass +struct EmptyType {} -contract Foo: +contract Foo { field1: Map field2: bool - event EmptyEvent: - pass + event EmptyEvent {} - event MyEvent: + event MyEvent { idx field1: bool field2: String<42> + } - pub fn my_func(): + pub fn my_func() { std::solidity::bytes2::from_array([1, 2]) - - fn my_other_func(): - pass - -contract Bar: - pub fn __init__(): - pass + if x { + } else if y { + 2 + 1 + 3 + 4 + } else { + if z {} else { 1 } + } + unsafe {} + } + + fn my_other_func() {} + + fn foo() { + while x { y } + while y {} + for x in y {} + for x in y { 5 } + } +} + +contract Bar { + pub fn __init__() {} +} diff --git a/crates/test-files/fixtures/printing/expr_parens.fe b/crates/test-files/fixtures/printing/expr_parens.fe index bd46f1c89f..681e493843 100644 --- a/crates/test-files/fixtures/printing/expr_parens.fe +++ b/crates/test-files/fixtures/printing/expr_parens.fe @@ -1,5 +1,5 @@ -contract Foo: - fn bar() -> i256: +contract Foo { + fn bar() -> i256 { let baz1: i256 = -(4 * (26 + 52)) let baz2: bool = not ((true or false) and true) let baz3: bool = not (true or false) and true @@ -18,3 +18,5 @@ contract Foo: let test: u256 = 3 ** 4 ** 5 let test2: u256 = (3 ** 4) ** 5 return -4 * (26 + 52) + } +} diff --git a/crates/test-files/fixtures/printing/guest_book_no_comments.fe b/crates/test-files/fixtures/printing/guest_book_no_comments.fe index d3136d9beb..c4aeb11aa8 100644 --- a/crates/test-files/fixtures/printing/guest_book_no_comments.fe +++ b/crates/test-files/fixtures/printing/guest_book_no_comments.fe @@ -1,12 +1,16 @@ -contract GuestBook: +contract GuestBook { messages: Map> - event Signed: + event Signed { book_msg: String<100> + } - pub fn sign(self, ctx: Context, book_msg: String<100>): + pub fn sign(self, ctx: Context, book_msg: String<100>) { self.messages[msg.sender] = book_msg emit Signed(book_msg) + } - pub fn get_msg(self, addr: address) -> String<100>: + pub fn get_msg(self, addr: address) -> String<100> { return self.messages[addr].to_mem() + } +} diff --git a/crates/test-files/fixtures/stress/abi_encoding_stress.fe b/crates/test-files/fixtures/stress/abi_encoding_stress.fe index 59fcb27816..0c1e913955 100644 --- a/crates/test-files/fixtures/stress/abi_encoding_stress.fe +++ b/crates/test-files/fixtures/stress/abi_encoding_stress.fe @@ -1,12 +1,13 @@ use std::context::Context -struct MyStruct: +struct MyStruct { pub my_num: u256 pub my_num2: u8 pub my_bool: bool pub my_addr: address +} -contract Foo: +contract Foo { my_addrs: Array my_u128: u128 my_string: String<10> @@ -14,72 +15,76 @@ contract Foo: my_bool: bool my_bytes: Array - event MyEvent: + event MyEvent { my_addrs: Array my_u128: u128 my_string: String<10> my_u16s: Array my_bool: bool my_bytes: Array + } - pub fn set_my_addrs(self, my_addrs: Array): + pub fn set_my_addrs(self, my_addrs: Array) { self.my_addrs = my_addrs + } - pub fn get_my_addrs(self) -> Array: + pub fn get_my_addrs(self) -> Array { return self.my_addrs.to_mem() + } - pub fn set_my_u128(self, my_u128: u128): + pub fn set_my_u128(self, my_u128: u128) { self.my_u128 = my_u128 + } - pub fn get_my_u128(self) -> u128: + pub fn get_my_u128(self) -> u128 { return self.my_u128 + } - pub fn set_my_string(self, my_string: String<10>): + pub fn set_my_string(self, my_string: String<10>) { self.my_string = my_string + } - pub fn get_my_string(self) -> String<10>: + pub fn get_my_string(self) -> String<10> { return self.my_string.to_mem() + } - pub fn set_my_u16s(self, my_u16s: Array): + pub fn set_my_u16s(self, my_u16s: Array) { self.my_u16s = my_u16s + } - pub fn get_my_u16s(self) -> Array: + pub fn get_my_u16s(self) -> Array { return self.my_u16s.to_mem() + } - pub fn set_my_bool(self, my_bool: bool): + pub fn set_my_bool(self, my_bool: bool) { self.my_bool = my_bool + } - pub fn get_my_bool(self) -> bool: + pub fn get_my_bool(self) -> bool { return self.my_bool + } - pub fn set_my_bytes(self, my_bytes: Array): + pub fn set_my_bytes(self, my_bytes: Array) { self.my_bytes = my_bytes + } - pub fn get_my_bytes(self) -> Array: + pub fn get_my_bytes(self) -> Array { return self.my_bytes.to_mem() + } - pub fn get_my_struct() -> MyStruct: - return MyStruct( - my_num: 42, - my_num2: u8(26), - my_bool: true, - my_addr: address(123456) - ) + pub fn get_my_struct() -> MyStruct { + return MyStruct(my_num: 42, my_num2: u8(26), my_bool: true, my_addr: address(123456)) + } - pub fn mod_my_struct(my_struct: MyStruct) -> MyStruct: + pub fn mod_my_struct(my_struct: MyStruct) -> MyStruct { my_struct.my_num = 12341234 my_struct.my_num2 = u8(42) my_struct.my_bool = false my_struct.my_addr = address(9999) return my_struct + } - pub fn emit_my_event(self, ctx: Context): - emit MyEvent( - ctx, - my_addrs: self.my_addrs.to_mem(), - my_u128: self.my_u128, - my_string: self.my_string.to_mem(), - my_u16s: self.my_u16s.to_mem(), - my_bool: self.my_bool, - my_bytes: self.my_bytes.to_mem() - ) + pub fn emit_my_event(self, ctx: Context) { + emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) + } +} diff --git a/crates/test-files/fixtures/stress/data_copying_stress.fe b/crates/test-files/fixtures/stress/data_copying_stress.fe index 68d211864a..0b814aeaec 100644 --- a/crates/test-files/fixtures/stress/data_copying_stress.fe +++ b/crates/test-files/fixtures/stress/data_copying_stress.fe @@ -1,63 +1,59 @@ use std::context::Context -contract Foo: +contract Foo { my_string: String<42> my_other_string: String<42> - my_u256: u256 my_other_u256: u256 - my_nums: Array - my_addrs: Array - event MyEvent: + event MyEvent { my_string: String<42> my_u256: u256 + } - pub fn set_my_vals( - self, - my_string: String<42>, - my_other_string: String<42>, - my_u256: u256, - my_other_u256: u256 - ): + pub fn set_my_vals(self, my_string: String<42>, my_other_string: String<42>, my_u256: u256, my_other_u256: u256) { self.my_string = my_string self.my_other_string = my_other_string self.my_u256 = my_u256 self.my_other_u256 = my_other_u256 + } - pub fn set_to_my_other_vals(self): + pub fn set_to_my_other_vals(self) { self.my_string = self.my_other_string self.my_u256 = self.my_other_u256 + } - pub fn multiple_references_shared_memory(my_array: Array): + pub fn multiple_references_shared_memory(my_array: Array) { let my_2nd_array: Array = my_array let my_3rd_array: Array = my_2nd_array - assert my_array[3] != 5 my_array[3] = 5 assert my_array[3] == 5 assert my_2nd_array[3] == 5 assert my_3rd_array[3] == 5 - my_3rd_array[3] = 50 assert my_array[3] == 50 assert my_2nd_array[3] == 50 assert my_3rd_array[3] == 50 + } - pub fn mutate_and_return(my_array: Array) -> Array: + pub fn mutate_and_return(my_array: Array) -> Array { my_array[3] = 5 return my_array + } - pub fn clone_and_return(my_array: Array) -> Array: + pub fn clone_and_return(my_array: Array) -> Array { return my_array.clone() + } - pub fn clone_mutate_and_return(my_array: Array) -> Array: + pub fn clone_mutate_and_return(my_array: Array) -> Array { my_array.clone()[3] = 5 return my_array + } - pub fn assign_my_nums_and_return(self) -> Array: + pub fn assign_my_nums_and_return(self) -> Array { let my_nums_mem: Array self.my_nums[0] = 42 self.my_nums[1] = 26 @@ -66,19 +62,21 @@ contract Foo: self.my_nums[4] = 255 my_nums_mem = self.my_nums.to_mem() return my_nums_mem + } - pub fn emit_my_event(self, ctx: Context): - emit_my_event_internal( - ctx, - self.my_string.to_mem(), - self.my_u256 - ) + pub fn emit_my_event(self, ctx: Context) { + emit_my_event_internal(ctx, self.my_string.to_mem(), self.my_u256) + } - fn emit_my_event_internal(ctx: Context, _ my_string: String<42>, _ my_u256: u256): + fn emit_my_event_internal(ctx: Context, _ my_string: String<42>, _ my_u256: u256) { emit MyEvent(ctx, my_string, my_u256) + } - pub fn set_my_addrs(self, my_addrs: Array): + pub fn set_my_addrs(self, my_addrs: Array) { self.my_addrs = my_addrs + } - pub fn get_my_second_addr(self) -> address: - return self.my_addrs[1] \ No newline at end of file + pub fn get_my_second_addr(self) -> address { + return self.my_addrs[1] + } +} diff --git a/crates/test-files/fixtures/stress/external_calls.fe b/crates/test-files/fixtures/stress/external_calls.fe index 69476959d6..56dbf5c0d7 100644 --- a/crates/test-files/fixtures/stress/external_calls.fe +++ b/crates/test-files/fixtures/stress/external_calls.fe @@ -1,97 +1,119 @@ use std::context::Context -struct SomeError: +struct SomeError { pub code: u256 +} -contract Foo: +contract Foo { my_tuple: (u256, address) my_string: String<100> - pub fn get_my_string(self) -> String<100>: + pub fn get_my_string(self) -> String<100> { return self.my_string.to_mem() + } - pub fn set_my_string(self, some_string: String<100>): + pub fn set_my_string(self, some_string: String<100>) { self.my_string = some_string + } - pub fn get_my_tuple(self) -> (u256, address): + pub fn get_my_tuple(self) -> (u256, address) { return self.my_tuple.to_mem() + } - pub fn set_my_tuple(self, some_tuple: (u256, address)): + pub fn set_my_tuple(self, some_tuple: (u256, address)) { self.my_tuple = some_tuple + } - pub fn set_my_string_and_tuple(self, some_string: String<100>, some_tuple: (u256, address)): + pub fn set_my_string_and_tuple(self, some_string: String<100>, some_tuple: (u256, address)) { self.my_string = some_string self.my_tuple = some_tuple + } - pub fn get_string() -> String<10>: + pub fn get_string() -> String<10> { return String<10>("hi") + } - pub fn get_array() -> Array: + pub fn get_array() -> Array { return [u16(1), u16(2), u16(3), u16(257)] + } - pub fn get_tuple() -> (u256, u256, bool): + pub fn get_tuple() -> (u256, u256, bool) { return (42, 26, false) + } - pub fn do_revert(): + pub fn do_revert() { revert + } - # Having the return type exercises a different path in the compiler - pub fn do_revert2() -> bool: + pub fn do_revert2() -> bool { revert + } - pub fn do_revert_with_data(): + pub fn do_revert_with_data() { revert SomeError(code: 4711) + } - # Having the return type exercises a different path in the compiler - pub fn do_revert_with_data2() -> bool: + pub fn do_revert_with_data2() -> bool { revert SomeError(code: 4711) + } +} -contract FooProxy: +contract FooProxy { foo: Foo - pub fn __init__(self, ctx: Context, foo_addr: address): + pub fn __init__(self, ctx: Context, foo_addr: address) { self.foo = Foo(ctx, foo_addr) + } - pub fn call_set_my_string(self, some_string: String<100>): + pub fn call_set_my_string(self, some_string: String<100>) { self.foo.set_my_string(some_string) + } - pub fn call_get_my_string(self) -> String<100>: + pub fn call_get_my_string(self) -> String<100> { return self.foo.get_my_string() + } - pub fn call_set_my_tuple(self, some_tuple: (u256, address)): + pub fn call_set_my_tuple(self, some_tuple: (u256, address)) { self.foo.set_my_tuple(some_tuple) + } - pub fn call_get_my_tuple(self) -> (u256, address): + pub fn call_get_my_tuple(self) -> (u256, address) { return self.foo.get_my_tuple() + } - pub fn call_set_my_string_and_tuple( - self, - some_string: String<100>, - some_tuple: (u256, address) - ): + pub fn call_set_my_string_and_tuple(self, some_string: String<100>, some_tuple: (u256, address)) { self.foo.set_my_string_and_tuple(some_string, some_tuple) + } - pub fn call_get_string(self) -> String<10>: + pub fn call_get_string(self) -> String<10> { return self.foo.get_string() + } - pub fn call_get_tuple(self) -> (u256, u256, bool): + pub fn call_get_tuple(self) -> (u256, u256, bool) { return self.foo.get_tuple() + } - pub fn call_get_array(self): + pub fn call_get_array(self) { let my_array: Array = self.foo.get_array() assert my_array[0] == u16(1) assert my_array[1] == u16(2) assert my_array[2] == u16(3) assert my_array[3] == u16(257) + } - pub fn call_do_revert(self): + pub fn call_do_revert(self) { self.foo.do_revert() + } - pub fn call_do_revert2(self): + pub fn call_do_revert2(self) { self.foo.do_revert2() + } - pub fn call_do_revert_with_data(self): + pub fn call_do_revert_with_data(self) { self.foo.do_revert_with_data() + } - pub fn call_do_revert_with_data2(self): + pub fn call_do_revert_with_data2(self) { self.foo.do_revert_with_data2() + } +} diff --git a/crates/test-files/fixtures/stress/tuple_stress.fe b/crates/test-files/fixtures/stress/tuple_stress.fe index 995161ecdd..3958f33343 100644 --- a/crates/test-files/fixtures/stress/tuple_stress.fe +++ b/crates/test-files/fixtures/stress/tuple_stress.fe @@ -1,48 +1,52 @@ use std::context::Context -contract Foo: +contract Foo { my_sto_tuple: (u256, i32) - event MyEvent: + event MyEvent { my_tuple: (u256, bool, address) + } - pub fn build_my_tuple( - my_num: u256, - my_bool: bool, - my_address: address - ) -> (u256, bool, address): + pub fn build_my_tuple(my_num: u256, my_bool: bool, my_address: address) -> (u256, bool, address) { return (my_num, my_bool, my_address) + } - pub fn read_my_tuple_item0(my_tuple: (u256, bool, address)) -> u256: + pub fn read_my_tuple_item0(my_tuple: (u256, bool, address)) -> u256 { return my_tuple.item0 + } - pub fn read_my_tuple_item1(my_tuple: (u256, bool, address)) -> bool: + pub fn read_my_tuple_item1(my_tuple: (u256, bool, address)) -> bool { return my_tuple.item1 + } - pub fn read_my_tuple_item2(my_tuple: (u256, bool, address)) -> address: + pub fn read_my_tuple_item2(my_tuple: (u256, bool, address)) -> address { return my_tuple.item2 + } - pub fn read_my_tuple_item10(my_tuple: (u256, u256, u256, u256, u256, u256, u256, u256, u256, u256, address)) -> address: + pub fn read_my_tuple_item10(my_tuple: (u256, u256, u256, u256, u256, u256, u256, u256, u256, u256, address)) -> address { return my_tuple.item10 + } - pub fn emit_my_event(ctx: Context, my_tuple: (u256, bool, address)): + pub fn emit_my_event(ctx: Context, my_tuple: (u256, bool, address)) { emit MyEvent(ctx, my_tuple) + } - pub fn set_my_sto_tuple(self, my_u256: u256, my_i32: i32): + pub fn set_my_sto_tuple(self, my_u256: u256, my_i32: i32) { assert self.my_sto_tuple.item0 == u256(0) and self.my_sto_tuple.item1 == i32(0) self.my_sto_tuple = (my_u256, my_i32) + } - pub fn get_my_sto_tuple(self) -> (u256, i32): + pub fn get_my_sto_tuple(self) -> (u256, i32) { return self.my_sto_tuple.to_mem() + } - pub fn build_tuple_and_emit(self, ctx: Context): + pub fn build_tuple_and_emit(self, ctx: Context) { let my_num: u256 = self.my_sto_tuple.item0 - let my_tuple: (u256, bool, address) = ( - self.my_sto_tuple.item0, - true and false, - address(26) - ) + let my_tuple: (u256, bool, address) = (self.my_sto_tuple.item0, true and false, address(26)) emit_my_event(ctx, my_tuple) + } - pub fn encode_my_tuple(my_tuple: (u256, bool, address)) -> Array: - return my_tuple.abi_encode() \ No newline at end of file + pub fn encode_my_tuple(my_tuple: (u256, bool, address)) -> Array { + return my_tuple.abi_encode() + } +} diff --git a/docs/book.toml b/docs/book.toml index 1096e96796..0e9568e363 100644 --- a/docs/book.toml +++ b/docs/book.toml @@ -6,6 +6,7 @@ src = "src" title = "The Fe Guide" [output.html] +additional-js = ["theme/custom-highlight.js"] additional-css = ["theme/reference.css"] [output.linkcheck] diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 4e026d61ad..3d122adab4 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -39,7 +39,6 @@ * [`break` Statement](spec/statements/break.md) * [`continue` Statement](spec/statements/continue.md) * [`assert` Statement](spec/statements/assert.md) - * [`pass` Statement](spec/statements/pass.md) * [Expressions](spec/expressions/index.md) * [Call expressions](spec/expressions/call.md) * [Tuple expressions](spec/expressions/tuple.md) @@ -80,4 +79,4 @@ * [Function calls](spec/function_calls.md) * [Release Notes](release_notes.md) -* [Code of Conduct](code_of_conduct.md) \ No newline at end of file +* [Code of Conduct](code_of_conduct.md) diff --git a/docs/src/quickstart/deploy_contract.md b/docs/src/quickstart/deploy_contract.md index a0b6df08a8..b8be37140a 100644 --- a/docs/src/quickstart/deploy_contract.md +++ b/docs/src/quickstart/deploy_contract.md @@ -34,17 +34,20 @@ ethsign import --keystore ~/.ethereum/keystore/ Let's recall that we finished our guest book in the previous chapter with the following code. -```python +```fe use std::context::Context -contract GuestBook: +contract GuestBook { messages: Map> - pub fn sign(self, ctx: Context, book_msg: String<100>): - self.messages[ctx.msg_sender()] = book_msg + pub fn sign(self, ctx: Context, book_msg: String<100>) { + self.messages[ctx.msg_sender()] = book_msg + } - pub fn get_msg(self, addr: address) -> String<100>: - return self.messages[addr].to_mem() + pub fn get_msg(self, addr: address) -> String<100> { + return self.messages[addr].to_mem() + } +} ``` If you haven't already, run `./fe guest_book.fe --overwrite` to obtain the bytecode that we want to deploy. @@ -116,5 +119,3 @@ We <3 Fe As we can see in the last line of the output the signature for address `0x4E14AaF86CF0759d6Ec8C7433acd66F07D093293` is in fact *We <3 Fe*. Congratulations! You've deployed real Fe code to a live network 🤖 - - diff --git a/docs/src/quickstart/first_contract.md b/docs/src/quickstart/first_contract.md index bf8b781159..4aac27a127 100644 --- a/docs/src/quickstart/first_contract.md +++ b/docs/src/quickstart/first_contract.md @@ -1,6 +1,6 @@ ## Write your first Fe contract -Now that we have the compiler installed let's write our first contract. A contract contains the code that will be deployed to the Ethereum blockchain and resides at a specific address. +Now that we have the compiler installed let's write our first contract. A contract contains the code that will be deployed to the Ethereum blockchain and resides at a specific address. The code of the contract dictates how: - it manipulates its own state @@ -15,37 +15,17 @@ To keep things simple we will just write a basic *guestbook* where people can le Fe code is written in files ending on the `.fe` file extension. Let's create a file `guest_book.fe` and put in the following content. -```python -contract GuestBook: -``` - -Now, execute `./fe guest_book.fe` to compile the file. - -Oops, the compiler is telling us that it didn't expect our code to end here. - -``` -Unable to compile guest_book.fe. -error: unexpected end of file - ┌─ guest_book.fe:1:20 - │ -1 │ contract GuestBook: - │ ^ - -``` - -Fe follows Pythonic block indentation rules and the compiler expects us to provide a block of indented code after `GuestBook:`. - -Let's expand the code by providing a [`map`](../spec/type_system/types/map.md) where we can associate messages with Ethereum addresses. The messages will simply be a [`string`](../spec/type_system/types/string.md) of a maximum length of `100` written as `string100`. -The addresses are represented by the builtin [`address`](../spec/type_system/types/address.md) type. - -``` -contract GuestBook: +```fe +contract GuestBook { messages: Map> +} ``` -Execute `./fe guest_book.fe` again to recompile the file. +Here we're using a [`map`](../spec/type_system/types/map.md) to associate messages with Ethereum addresses. +The messages will simply be a [`string`](../spec/type_system/types/string.md) of a maximum length of `100` written as `String<100>`. +The addresses are represented by the builtin [`address`](../spec/type_system/types/address.md) type. -This time, the compiler tells us that it compiled our contract and that it has put the artifacts into a subdirectory called `output`. +Execute `./fe guest_book.fe` to compile the file. The compiler tells us that it compiled our contract and that it has put the artifacts into a subdirectory called `output`. ``` Compiled guest_book.fe. Outputs in `output` @@ -72,17 +52,19 @@ We don't need to do anything further yet with these files that the compiler prod Let's focus on the functionality of our world changing application and add a method to sign the guestbook. -```python +```fe use std::context::Context -contract GuestBook: +contract GuestBook { messages: Map> - pub fn sign(self, ctx: Context, book_msg: String<100>): + pub fn sign(self, ctx: Context, book_msg: String<100>) { self.messages[ctx.msg_sender()] = book_msg + } +} ``` -The code should look familiar to those of us that have written Python before except that in Fe every method that is defined without the [`pub`](../spec/items/visibility_and_privacy.md) keyword becomes private. Since we want people to interact with our contract and call the `sign` method we have to prefix it with `pub`. +In Fe, every method that is defined without the [`pub`](../spec/items/visibility_and_privacy.md) keyword becomes private. Since we want people to interact with our contract and call the `sign` method we have to prefix it with `pub`. Let's recompile the contract again and see what happens. @@ -118,17 +100,20 @@ Since our contract now has a public `sign` method the corresponding ABI has chan To make the guest book more useful we will also add a method `get_msg` to read entries from a given address. -```python +```fe,ignore use std::context::Context -contract GuestBook: +contract GuestBook { messages: Map> - pub fn sign(self, ctx: Context, book_msg: String<100>): + pub fn sign(self, ctx: Context, book_msg: String<100>) { self.messages[ctx.msg_sender()] = book_msg + } - pub fn get_msg(self, addr: address) -> String<100>: + pub fn get_msg(self, addr: address) -> String<100> { return self.messages[addr] + } +} ``` However, we will hit another error as we try to recompile the current code. @@ -136,7 +121,7 @@ However, we will hit another error as we try to recompile the current code. ``` Unable to compile guest_book.fe. error: value must be copied to memory - ┌─ guest_book.fe:8:14 + ┌─ guest_book.fe:10:14 │ 8 │ return self.messages[addr] │ ^^^^^^^^^^^^^^^^^^^ this value is in storage @@ -151,17 +136,20 @@ When we try to return a reference type such as an array from the storage of the The code should compile fine when we change it accordingly. -```python +```fe use std::context::Context -contract GuestBook: +contract GuestBook { messages: Map> - pub fn sign(self, ctx: Context, book_msg: String<100>): + pub fn sign(self, ctx: Context, book_msg: String<100>) { self.messages[ctx.msg_sender()] = book_msg + } - pub fn get_msg(self, addr: address) -> String<100>: + pub fn get_msg(self, addr: address) -> String<100> { return self.messages[addr].to_mem() + } +} ``` Congratulations! You finished your first little Fe project. 👏 diff --git a/docs/src/spec/data_layout/memory/clone_function.md b/docs/src/spec/data_layout/memory/clone_function.md index 3640f2d4a9..ba79db084f 100644 --- a/docs/src/spec/data_layout/memory/clone_function.md +++ b/docs/src/spec/data_layout/memory/clone_function.md @@ -4,16 +4,22 @@ Reference type values in memory can be cloned using the `clone` function. Example: -```python -# with clone -foo: Array = bar.clone() # `foo` points to a new segment of memory -assert foo[1] == bar[1] -foo[1] = 42 -assert foo[1] != bar[1] # modifying `foo` does not modify bar +```fe +fn f() { + # with clone + let bar: Array = [1, 2, 3, 4] + let foo: Array = bar.clone() # `foo` points to a new segment of memory + assert foo[1] == bar[1] + foo[1] = 42 + assert foo[1] != bar[1] # modifying `foo` does not modify bar +} -# without clone -foo: Array = bar # `foo` and `bar` point to the same segment of memory -assert foo[1] == bar[1] -foo[1] = 42 -assert foo[1] == bar[1] # modifying `foo` also modifies `bar` +fn g() { + # without clone + let bar: Array = [1, 2, 3, 4] + let foo: Array = bar # `foo` and `bar` point to the same segment of memory + assert foo[1] == bar[1] + foo[1] = 42 + assert foo[1] == bar[1] # modifying `foo` also modifies `bar` +} ``` diff --git a/docs/src/spec/data_layout/memory/sequence_types_in_memory.md b/docs/src/spec/data_layout/memory/sequence_types_in_memory.md index 081a556c4f..8cd3d2475e 100644 --- a/docs/src/spec/data_layout/memory/sequence_types_in_memory.md +++ b/docs/src/spec/data_layout/memory/sequence_types_in_memory.md @@ -5,10 +5,11 @@ reference them using pointers kept on the stack. Example: -```python -# function scope -foo: Array # foo is a pointer that references 100 * 256 bits in memory. +```fe +fn f() { + let foo: Array # foo is a pointer that references 100 * 256 bits in memory. +} ``` To find an element inside of a sequence type, the relative location of the element is added to the -given pointer. \ No newline at end of file +given pointer. diff --git a/docs/src/spec/data_layout/stack.md b/docs/src/spec/data_layout/stack.md index 90a396b0dc..0e11e57f0b 100644 --- a/docs/src/spec/data_layout/stack.md +++ b/docs/src/spec/data_layout/stack.md @@ -10,8 +10,9 @@ than or equal to 256 bits in size, we store them on the stack. Pointers to value Example: -```python -# function scope -foo: u256 = 42 # foo is stored on the stack -bar: Array # bar is a memory pointer stored on the stack +```fe +fn f() { + let foo: u256 = 42 # foo is stored on the stack + let bar: Array # bar is a memory pointer stored on the stack +} ``` diff --git a/docs/src/spec/data_layout/storage/constant_size_values_in_storage.md b/docs/src/spec/data_layout/storage/constant_size_values_in_storage.md index e76e20ac61..ca84a091fa 100644 --- a/docs/src/spec/data_layout/storage/constant_size_values_in_storage.md +++ b/docs/src/spec/data_layout/storage/constant_size_values_in_storage.md @@ -4,13 +4,14 @@ Storage pointers for constant size values are determined at compile time. Example: -```python -# contract scope -foo: u256 # foo is assigned a static pointer by the compiler +```fe +contract Cats { + population: u256 # assigned a static location by the compiler +} ``` The value of a base type in storage is found by simply loading the value from storage at the given pointer. To find an element inside of a sequence type, the relative location of the element is added to the -given pointer. \ No newline at end of file +given pointer. diff --git a/docs/src/spec/data_layout/storage/maps_in_storage.md b/docs/src/spec/data_layout/storage/maps_in_storage.md index 3943328d78..094e7d3d24 100644 --- a/docs/src/spec/data_layout/storage/maps_in_storage.md +++ b/docs/src/spec/data_layout/storage/maps_in_storage.md @@ -5,10 +5,11 @@ assigned a nonce that is used to derive the location of keyed values during runt Example: -``` python -# contract scope -bar: Map # bar is assigned a static nonce by the compiler -baz: Map> # baz is assigned a static nonce by the compiler +```fe +contract Foo { + bar: Map # bar is assigned a static nonce by the compiler + baz: Map> # baz is assigned a static nonce by the compiler +} ``` The expression `bar[0x00]` would resolve to the hash of both bar's nonce and the key value diff --git a/docs/src/spec/data_layout/storage/to_mem_function.md b/docs/src/spec/data_layout/storage/to_mem_function.md index f5f002e0af..7f8f1581f5 100644 --- a/docs/src/spec/data_layout/storage/to_mem_function.md +++ b/docs/src/spec/data_layout/storage/to_mem_function.md @@ -4,6 +4,6 @@ Reference type values can be copied from storage and into memory using the `to_m Example: -```python -my_array_var: Array = self.my_array_field.to_mem() +```fe,ignore +let my_array_var: Array = self.my_array_field.to_mem() ``` diff --git a/docs/src/spec/expressions/arithmetic_operators.md b/docs/src/spec/expressions/arithmetic_operators.md index a14bc1170e..e5d36cdbc1 100644 --- a/docs/src/spec/expressions/arithmetic_operators.md +++ b/docs/src/spec/expressions/arithmetic_operators.md @@ -37,11 +37,11 @@ primitive types. Here are examples of these operators being used. -``` +```fe,ignore 3 + 6 == 9 6 - 3 == 3 2 * 3 == 6 -6 / 3 == 2 TODO: Rest +6 / 3 == 2 5 % 4 == 1 2 ** 4 == 16 12 & 25 == 8 @@ -52,4 +52,4 @@ Here are examples of these operators being used. ``` -[_Expression_]: ./index.md \ No newline at end of file +[_Expression_]: ./index.md diff --git a/docs/src/spec/expressions/attribute.md b/docs/src/spec/expressions/attribute.md index 895f06ffd2..38f8767e14 100644 --- a/docs/src/spec/expressions/attribute.md +++ b/docs/src/spec/expressions/attribute.md @@ -11,25 +11,28 @@ The syntax for an attribute expression is an expression, then a `.` and finally Examples: -```python -struct Point: +```fe +struct Point { pub x: u256 pub y: u256 +} -contract Foo: +contract Foo { some_point: Point some_tuple: (bool, u256) - fn get_point() -> Point: + fn get_point() -> Point { return Point(x: 100, y: 500) + } - pub fn baz(some_point: Point, some_tuple: (bool, u256)): + pub fn baz(some_point: Point, some_tuple: (bool, u256)) { # Different examples of attribute expressions let bool_1: bool = some_tuple.item0 let x1: u256 = some_point.x let point1: u256 = get_point().x let point2: u256 = some_point.x - + } +} ``` [_Expression_]: ./index.md diff --git a/docs/src/spec/expressions/boolean_operators.md b/docs/src/spec/expressions/boolean_operators.md index 03cad27b56..455b9d1aca 100644 --- a/docs/src/spec/expressions/boolean_operators.md +++ b/docs/src/spec/expressions/boolean_operators.md @@ -7,17 +7,10 @@ The operators `or` and `and` may be applied to operands of boolean type. The `or` operator denotes logical 'or', and the `and` operator denotes logical 'and'. -
- -Warning: -These operators do currently not evaluate lazily which is likely to change in the future. ([See GitHub issue](https://github.com/ethereum/fe/issues/488)) - -
- Example: -``` -let x: bool = false or true # true +```fe +const x: bool = false or true # true ``` -[_Expression_]: ./index.md \ No newline at end of file +[_Expression_]: ./index.md diff --git a/docs/src/spec/expressions/call.md b/docs/src/spec/expressions/call.md index 769d6f1cf1..1dde7cd90a 100644 --- a/docs/src/spec/expressions/call.md +++ b/docs/src/spec/expressions/call.md @@ -22,16 +22,17 @@ A *call expression* calls a function. The syntax of a call expression is an [exp Example: -```python -contract Foo: +```fe +contract Foo { - pub fn demo(self): + pub fn demo(self) { let ann: address = address(0xaa) let bob: address = address(0xbb) self.transfer(from: ann, to: bob, 25) + } - pub fn transfer(self, from: address, to: address, _ val: u256): - pass + pub fn transfer(self, from: address, to: address, _ val: u256) {} +} ``` [_Expression_]: ./index.md diff --git a/docs/src/spec/expressions/comparison_operators.md b/docs/src/spec/expressions/comparison_operators.md index 7d52cf3cd1..745efd210d 100644 --- a/docs/src/spec/expressions/comparison_operators.md +++ b/docs/src/spec/expressions/comparison_operators.md @@ -21,7 +21,7 @@ Here are examples of the comparison operators being used. -``` +```fe,ignore 123 == 123 23 != -12 12 > 11 @@ -30,4 +30,4 @@ Here are examples of the comparison operators being used. 11 <= 11 ``` -[_Expression_]: ./index.md \ No newline at end of file +[_Expression_]: ./index.md diff --git a/docs/src/spec/expressions/indexing.md b/docs/src/spec/expressions/indexing.md index ae19e504c8..d268aafe80 100644 --- a/docs/src/spec/expressions/indexing.md +++ b/docs/src/spec/expressions/indexing.md @@ -9,12 +9,12 @@ Example: -```python -contract Foo: +```fe +contract Foo { balances: Map - pub fn baz(self, values: Array): + pub fn baz(self, values: Array) { # Assign value at slot 5 values[5] = 1000 # Read value at slot 5 @@ -25,8 +25,10 @@ contract Foo: # Read balance of address zero let bal: u256 = self.balances[address(0)] + } +} ``` [_Expression_]: ./index.md [Array]: ../type_system/types/array.md -[Map]: ../type_system/types/map.md \ No newline at end of file +[Map]: ../type_system/types/map.md diff --git a/docs/src/spec/expressions/list.md b/docs/src/spec/expressions/list.md index c7d74665f7..30f080cb23 100644 --- a/docs/src/spec/expressions/list.md +++ b/docs/src/spec/expressions/list.md @@ -22,16 +22,19 @@ An array item can be accessed via an [index expression]. Example: -```python -contract Foo: +```fe +contract Foo { - fn get_val3() -> u256: + fn get_val3() -> u256 { return 3 + } - pub fn baz(): + pub fn baz() { let val1: u256 = 2 # A list expression let foo: Array = [1, val1, get_val3()] + } +} ``` [_Expression_]: ./index.md diff --git a/docs/src/spec/expressions/literal.md b/docs/src/spec/expressions/literal.md index 3c4e925304..3d9b7c4957 100644 --- a/docs/src/spec/expressions/literal.md +++ b/docs/src/spec/expressions/literal.md @@ -9,7 +9,7 @@ A _literal expression_ consists of one of the [literal][LITERAL] forms described earlier. It directly describes a number, string or boolean value. -```Python +```fe,ignore "hello" # string type 5 # integer type true # boolean type @@ -18,4 +18,4 @@ true # boolean type [LITERAL]: ../lexical_structure/tokens.md#literals [STRING_LITERAL]: ../lexical_structure/tokens.md#string-literals [INTEGER_LITERAL]: ../lexical_structure/tokens.md#integer-literals -[BOOLEAN_LITERAL]: ../lexical_structure/tokens.md#boolean-literals \ No newline at end of file +[BOOLEAN_LITERAL]: ../lexical_structure/tokens.md#boolean-literals diff --git a/docs/src/spec/expressions/name.md b/docs/src/spec/expressions/name.md index b603a8defe..faa1574397 100644 --- a/docs/src/spec/expressions/name.md +++ b/docs/src/spec/expressions/name.md @@ -8,12 +8,13 @@ A *name expression* resolves to a local variable. Example: -```python -contract Foo: - - pub fn baz(foo: u256): +```fe +contract Foo { + pub fn baz(foo: u256) { # name expression resolving to the value of `foo` foo + } +} ``` [IDENTIFIER]: ../lexical_structure/identifiers.md diff --git a/docs/src/spec/expressions/tuple.md b/docs/src/spec/expressions/tuple.md index 123d0971af..b7574fa835 100644 --- a/docs/src/spec/expressions/tuple.md +++ b/docs/src/spec/expressions/tuple.md @@ -32,18 +32,17 @@ A tuple field can be accessed via an [attribute expression]. Example: -```python -contract Foo: - - pub fn bar(): +```fe +contract Foo { + pub fn bar() { # Creating a tuple via a tuple expression let some_tuple: (u256, bool) = (1, false) # Accessing the first tuple field via the `item0` field baz(input: some_tuple.item0) - - pub fn baz(input: u256): - pass + } + pub fn baz(input: u256) {} +} ``` [_Expression_]: ./index.md diff --git a/docs/src/spec/expressions/unary_operators.md b/docs/src/spec/expressions/unary_operators.md index 5fcd5e22bf..8c4578c39b 100644 --- a/docs/src/spec/expressions/unary_operators.md +++ b/docs/src/spec/expressions/unary_operators.md @@ -10,10 +10,12 @@ The unary operators are used to negate expressions. The unary `-` (minus) operat Example: -``` -let x: bool = not true # false -let y: i256 = -1 # -1 -let y: i256 = ~1 # -2 +```fe +fn f() { + let x: bool = not true # false + let y: i256 = -1 + let z: i256 = i256(~1) # -2 +} ``` -[_Expression_]: ../expressions/index.md \ No newline at end of file +[_Expression_]: ../expressions/index.md diff --git a/docs/src/spec/index.md b/docs/src/spec/index.md index e8ec3f987c..a03751584c 100644 --- a/docs/src/spec/index.md +++ b/docs/src/spec/index.md @@ -33,7 +33,6 @@ * [`break` Statement](statements/break.md) * [`continue` Statement](statements/continue.md) * [`assert` Statement](statements/assert.md) - * [`pass` Statement](statements/pass.md) * [Expressions](expressions/index.md) * [Call expressions](expressions/call.md) * [Tuple expressions](expressions/tuple.md) diff --git a/docs/src/spec/items/contracts.md b/docs/src/spec/items/contracts.md index ba57bb14a6..c8da01d9c3 100644 --- a/docs/src/spec/items/contracts.md +++ b/docs/src/spec/items/contracts.md @@ -2,10 +2,9 @@ > **Syntax**\ > _Contract_ :\ ->    `contract` [IDENTIFIER] `:` [NEWLINE]\ ->    [INDENT]\ ->    _ContractMember_\*\ ->    [DEDENT]\ +>    `contract` [IDENTIFIER] `{`\ +>   _ContractMember_\*\ +>   _`}` > > _ContractMember_:\ >    [_Visibility_]?\ @@ -28,26 +27,28 @@ An example of a `contract`: -```python +```fe use std::context::Context -contract GuestBook: +contract GuestBook { messages: Map> - event Signed: + event Signed { book_msg: String<100> + } - pub fn sign(self, ctx: Context, book_msg: String<100>): + pub fn sign(self, ctx: Context, book_msg: String<100>) { self.messages[ctx.msg_sender()] = book_msg emit Signed(ctx, book_msg: book_msg) + } - pub fn get_msg(self, addr: address) -> String<100>: + pub fn get_msg(self, addr: address) -> String<100> { return self.messages[addr].to_mem() + } +} ``` [NEWLINE]: ../lexical_structure/tokens.md#newline -[INDENT]: ../lexical_structure/tokens.md#indent -[DEDENT]: ../lexical_structure/tokens.md#dedent [IDENTIFIER]: ../lexical_structure/identifiers.md [_Visibility_]: ./visibility_and_privacy.md [_Type_]: ../type_system/types/index.md diff --git a/docs/src/spec/items/enum.md b/docs/src/spec/items/enum.md index e627be5492..b543b33af1 100644 --- a/docs/src/spec/items/enum.md +++ b/docs/src/spec/items/enum.md @@ -2,13 +2,12 @@ > **Syntax**\ > _Enumeration_ :\ ->    `enum` [IDENTIFIER] `:` [NEWLINE]\ ->    [INDENT]\ +>    `enum` [IDENTIFIER] `{`\ >    _EnumField_\*\ ->    [DEDENT]\ +>    `}` > > _EnumField_ :\ ->    [IDENTIFIER]`,` +>    [IDENTIFIER] An *enumeration*, also referred to as *enum* is a simultaneous definition of a nominal [enumerated type], that can be used to create or pattern-match values of the corresponding enumerated type. @@ -17,17 +16,20 @@ Enumerations are declared with the keyword `enum`. An example of an `enum` item and its use: -``` -enum Animal: - Dog, - Cat, +```fe,ignore +enum Animal { + Dog + Cat +} -barker = Animal.Dog +fn f() { + let barker: Animal = Animal::Dog +} ``` +NOTE: Enums are not yet implemented. + [NEWLINE]: ../lexical_structure/tokens.md#newline -[INDENT]: ../lexical_structure/tokens.md#indent -[DEDENT]: ../lexical_structure/tokens.md#dedent [IDENTIFIER]: ../lexical_structure/identifiers.md [_Type_]: ../type_system/types/index.md -[enumerated type]: ../type_system/types/enum.md \ No newline at end of file +[enumerated type]: ../type_system/types/enum.md diff --git a/docs/src/spec/items/events.md b/docs/src/spec/items/events.md index d2abb53b4d..fd18fbec27 100644 --- a/docs/src/spec/items/events.md +++ b/docs/src/spec/items/events.md @@ -2,10 +2,9 @@ > **Syntax**\ > _Event_ :\ ->    `event` [IDENTIFIER] `:` [NEWLINE]\ ->    [INDENT]\ +>    `event` [IDENTIFIER] `{` >    _EventField_\*\ ->    [DEDENT]\ +>    `}` > > _EventField_ :\ >    _EventIndexability_ [IDENTIFIER] `:` [_Type_]\ @@ -17,24 +16,25 @@ An _event_ is a nominal [event type] defined with the keyword `event`. It is emi An example of a `event` item and its use: -```python +```fe use std::context::Context -contract Foo: - event Transfer: +contract Foo { + event Transfer { idx sender: address idx receiver: address value: u256 + } - fn transfer(ctx: Context, to: address, value: u256): + fn transfer(ctx: Context, to: address, value: u256) { # Heavy logic here # All done, log the event for listeners emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) + } +} ``` [NEWLINE]: ../lexical_structure/tokens.md#newline -[INDENT]: ../lexical_structure/tokens.md#indent -[DEDENT]: ../lexical_structure/tokens.md#dedent [IDENTIFIER]: ../lexical_structure/identifiers.md [_Type_]: ../type_system/types/index.md [event type]: ../type_system/types/event.md diff --git a/docs/src/spec/items/functions.md b/docs/src/spec/items/functions.md index ee5bfcfc98..5a4861d85a 100644 --- a/docs/src/spec/items/functions.md +++ b/docs/src/spec/items/functions.md @@ -5,10 +5,9 @@ >    _FunctionQualifiers_ `fn` [IDENTIFIER]\ >       `(` _FunctionParameters_? `)`\ >       _FunctionReturnType_?\ ->       `:` [NEWLINE]\ ->       [INDENT]\ +>       `{`\ >       _FunctionStatements_*\ ->       [DEDENT]\ +>       `}` > > _FunctionQualifiers_ :\ >    `pub`? @@ -23,7 +22,6 @@ >       | [_IfStatement_]\ >       | [_AssertStatement_]\ >       | [_EmitStatement_]\ ->       | [_PassStatement_]\ >       | [_BreakStatement_]\ >       | [_ContinueStatement_]\ >       | [_RevertStatement_]\ @@ -57,9 +55,10 @@ A function header ends with a colon (`:`) after which the function body begins. For example, this is a simple function: -```python -fn add(x: u256, y: u256) -> u256: +```fe +fn add(x: u256, y: u256) -> u256 { return x + y +} ``` Functions can be defined inside of a contract, inside of a struct, or at the @@ -67,21 +66,23 @@ Functions can be defined inside of a contract, inside of a struct, or at the Example: -```python -fn add(_ x: u256, _ y: u256) -> u256: +```fe +fn add(_ x: u256, _ y: u256) -> u256 { return x + y +} -contract CoolCoin: +contract CoolCoin { balance: Map - fn transfer(self, from sender: address, to recipient: address, value: u256) -> bool: - if self.balance[sender] < value: + fn transfer(self, from sender: address, to recipient: address, value: u256) -> bool { + if self.balance[sender] < value { return false + } self.balance[sender] -= value self.balance[recipient] += value return true - - pub fn demo(self): + } + pub fn demo(self) { let ann: address = address(0xaa) let bob: address = address(0xbb) self.balance[ann] = 100 @@ -89,6 +90,8 @@ contract CoolCoin: let bonus: u256 = 2 let value: u256 = add(10, bonus) let ok: bool = self.transfer(from: ann, to: bob, value) + } +} ``` Function parameters have optional labels. When a function is called, the @@ -98,12 +101,14 @@ function definition. The label of a parameter defaults to the parameter name; a different label can be specified by adding an explicit label prior to the parameter name. For example: -``` -fn encrypt(msg cleartext: u256, key: u256) -> u256: +```fe +fn encrypt(msg cleartext: u256, key: u256) -> u256 { return cleartext ^ key +} -fn demo(): +fn demo() { let out: u256 = encrypt(msg: 0xdecafbad, key: 0xfefefefe) +} ``` Here, the first parameter of the `encrypt` function has the label `msg`, @@ -114,7 +119,8 @@ modifying any function calls, as long as the label remains the same. When calling a function, a label can be omitted when the argument is a variable with a name that matches the parameter label. Example: -``` + +```fe,ignore let msg: u256 = 0xdecafbad let cyf: u256 = encrypt(msg, key: 0x1234) ``` @@ -122,23 +128,25 @@ let cyf: u256 = encrypt(msg, key: 0x1234) A parameter can also be specified to have no label, by using `_` in place of a label in the function definition. In this case, when calling the function, the corresponding argument must not be labeled. Example: -``` -fn add(_ x: u256, _ y: u256) -> u256: +```fe +fn add(_ x: u256, _ y: u256) -> u256 { return x + y - -fn demo(): +} +fn demo() { let sum: u256 = add(16, 32) +} ``` Functions defined inside of a contract or struct may take `self` as a parameter. This gives the function the ability to read and write contract storage or struct fields, respectively. If a function takes `self` as a parameter, the function must be called via `self`. For example: -`let ok: bool = self.transfer(from, to, value)` + +```fe,ignore +let ok: bool = self.transfer(from, to, value) +``` [NEWLINE]: ../lexical_structure/tokens.md#newline -[INDENT]: ../lexical_structure/tokens.md#indent -[DEDENT]: ../lexical_structure/tokens.md#dedent [IDENTIFIER]: ../lexical_structure/identifiers.md [_Types_]: ../type_system/types/index.md [_FunctionTypes_]: ../type_system/types/function.md @@ -152,7 +160,6 @@ as a parameter, the function must be called via `self`. For example: [_IfStatement_]: ../statements/if.md [_AssertStatement_]: ../statements/assert.md [_EmitStatement_]: ../statements/emit.md -[_PassStatement_]: ../statements/pass.md [_BreakStatement_]: ../statements/break.md [_ContinueStatement_]: ../statements/continue.md [_RevertStatement_]: ../statements/revert.md diff --git a/docs/src/spec/items/structs.md b/docs/src/spec/items/structs.md index ad1f911a57..5c95c812f7 100644 --- a/docs/src/spec/items/structs.md +++ b/docs/src/spec/items/structs.md @@ -2,26 +2,28 @@ > **Syntax**\ > _Struct_ :\ ->    `struct` [IDENTIFIER] `:` [NEWLINE]\ ->    [INDENT]\ +>    `struct` [IDENTIFIER] `{`\ >    _StructField_*\ ->    [DEDENT]\ +>    `}` > > _StructField_ :\ ->    [IDENTIFIER] `:` [_Type_] +>    `pub`? [IDENTIFIER] `:` [_Type_] A _struct_ is a nominal [struct type][struct type] defined with the keyword `struct`. An example of a `struct` item and its use: -``` -struct Point: - x: u256 - y: u256 +```fe +struct Point { + pub x: u256 + pub y: u256 +} -p = Point(x: 10, y: 11) -px: u256 = p.x; +fn pointy_stuff() { + let p: Point = Point(x: 10, y: 11) + let px: u256 = p.x +} ``` @@ -31,8 +33,6 @@ Builtin functions: [NEWLINE]: ../lexical_structure/tokens.md#newline -[INDENT]: ../lexical_structure/tokens.md#indent -[DEDENT]: ../lexical_structure/tokens.md#dedent [IDENTIFIER]: ../lexical_structure/identifiers.md [struct type]: ../type_system/types/struct.md [_Type_]: ../type_system/types/index.md diff --git a/docs/src/spec/items/type_aliases.md b/docs/src/spec/items/type_aliases.md index a833f83a43..e8c3502de4 100644 --- a/docs/src/spec/items/type_aliases.md +++ b/docs/src/spec/items/type_aliases.md @@ -10,10 +10,10 @@ declared with the keyword `type`. For example, the following defines the type `BookMsg` as a synonym for the type `u8[100]`, a sequence of `100` `u8` numbers which is how sequences of bytes are represented in Fe. -``` +```fe type BookMsg = Array ``` [IDENTIFIER]: ../lexical_structure/identifiers.md [_Type_]: ../type_system/types/index.md -[type]: ../type_system/types/index.md \ No newline at end of file +[type]: ../type_system/types/index.md diff --git a/docs/src/spec/items/visibility_and_privacy.md b/docs/src/spec/items/visibility_and_privacy.md index 9a65fe3f79..ceebdb17ae 100644 --- a/docs/src/spec/items/visibility_and_privacy.md +++ b/docs/src/spec/items/visibility_and_privacy.md @@ -10,9 +10,10 @@ Fe knows two different types of visibility for functions and state variables: `p For example, this is a function that can be called externally from a transaction: -```python -pub fn answer_to_life_the_universe_and_everything() -> u256: +```fe +pub fn answer_to_life_the_universe_and_everything() -> u256 { return 42 +} ``` Top-level definitions in a Fe source file can also be specified as `pub` if the file exists within the context of an Ingot. Declaring a definition as `pub` enables other modules within an Ingot to `use` the definition. @@ -29,24 +30,27 @@ example_ingot With `ding/dong.fe` having the following contents: -```python -pub struct Dyng: - my_address: address - my_u256: u256 - my_i8: i8 +```fe +pub struct Dang { + pub my_address: address + pub my_u256: u256 + pub my_i8: i8 +} ``` -Then `main.fe` can use the `Dyng` struct since it is `pub`-qualified: +Then `main.fe` can use the `Dang` struct since it is `pub`-qualified: -```python -use ding::{dong::Dyng} +```fe,ignore +use ding::dong::Dang -contract Foo: - pub fn get_my_dyng() -> Dyng: - return Dyng( - my_address=address(8), - my_u256=42, - my_i8=-1 +contract Foo { + pub fn hot_dang() -> Dang { + return Dang( + my_address: address(8), + my_u256: 42, + my_i8: -1 ) + } +} ``` diff --git a/docs/src/spec/lexical_structure/keywords.md b/docs/src/spec/lexical_structure/keywords.md index c451e1bc45..3c98e35fff 100644 --- a/docs/src/spec/lexical_structure/keywords.md +++ b/docs/src/spec/lexical_structure/keywords.md @@ -17,7 +17,6 @@ be used as the [identifiers](./identifiers.md). > KW_CONTINUE : `continue`\ > KW_CONST : `contract`\ > KW_FN : `fn`\ -> KW_ELIF : `elif`\ > KW_ELSE : `else`\ > KW_EMIT : `emit`\ > KW_ENUM : `enum`\ @@ -29,7 +28,6 @@ be used as the [identifiers](./identifiers.md). > KW_IN : `in`\ > KW_LET : `let`\ > KW_NONPAYABLE : `nonpayable`\ -> KW_PASS : `pass`\ > KW_PAYABLE : `payable`\ > KW_PUB : `pub`\ > KW_RETURN : `return`\ diff --git a/docs/src/spec/lexical_structure/tokens.md b/docs/src/spec/lexical_structure/tokens.md index 39002676d4..b298a75786 100644 --- a/docs/src/spec/lexical_structure/tokens.md +++ b/docs/src/spec/lexical_structure/tokens.md @@ -1,21 +1,9 @@ # Tokens -## Significant whitespace - -In Fe, whitespace is not just used to guide the human eye but it also carries meaning. The rules are essentially [borrowed from Python](https://docs.python.org/2.0/ref/indentation.html). - ### `NEWLINE` A token that represents a new line. -### `INDENT` - -A token that represents adding one level of indentation. - -### `DEDENT` - -A token that represents removing one level of indentation - ## Literals A literal is an expression consisting of a single token, rather than a sequence @@ -130,15 +118,10 @@ An _integer literal_ has one of four forms: Examples of integer literals of various forms: -```python -123; // type u256 -0xff; // type u256 -0o70; // type u256 -0b1111_1111_1001_0000; // type u256 -0b1111_1111_1001_0000i64; // type u256 +```fe,ignore +123 # type u256 +0xff # type u256 +0o70 # type u256 +0b1111_1111_1001_0000 # type u256 +0b1111_1111_1001_0000i64 # type u256 ``` - -Note that the Fe syntax considers `-1` as an application of the [unary minus -operator] to an integer literal `1`, rather than a single integer literal. - -[unary minus operator]: ../expressions/unary_operators.md diff --git a/docs/src/spec/statements/assert.md b/docs/src/spec/statements/assert.md index 14ccb61c67..eaf87e038f 100644 --- a/docs/src/spec/statements/assert.md +++ b/docs/src/spec/statements/assert.md @@ -18,22 +18,26 @@ The current implementation of `assert` is under [active discussion](https://gith An example of a `assert` statement without the optional message: -```python -contract Foo: - fn bar(val: u256): +```fe +contract Foo { + fn bar(val: u256) { assert val > 5 + } +} ``` An example of a `assert` statement with an error message: -```python -contract Foo: +```fe +contract Foo { - fn bar(val: u256): + fn bar(val: u256) { assert val > 5, "Must be greater than five" + } +} ``` [_Expression_]: ../expressions/index.md [boolean]: ../type_system/types/boolean.md [string]: ../type_system/types/string.md -[error code]: https://github.com/ethereum/EIPs/issues/838 \ No newline at end of file +[error code]: https://github.com/ethereum/EIPs/issues/838 diff --git a/docs/src/spec/statements/assign.md b/docs/src/spec/statements/assign.md index 1cb7cf5739..bdf239743d 100644 --- a/docs/src/spec/statements/assign.md +++ b/docs/src/spec/statements/assign.md @@ -9,11 +9,11 @@ An assignment statement moves a value into a specified place. An assignment stat Example: -```python -contract Foo: +```fe +contract Foo { some_array: Array - pub fn bar(self): + pub fn bar(self) { let val1: u256 = 10 # Assignment of stack variable val1 = 10 @@ -24,6 +24,8 @@ contract Foo: # Assignment of storage array slot self.some_array[5] = 1000 + } +} ``` [_Expression_]: ../expressions/index.md diff --git a/docs/src/spec/statements/augassign.md b/docs/src/spec/statements/augassign.md index 9d865d4c93..812783b5b8 100644 --- a/docs/src/spec/statements/augassign.md +++ b/docs/src/spec/statements/augassign.md @@ -21,52 +21,64 @@ An augmenting assignment statement consists of an expression that holds a mutabl Example: -```python -contract Foo: +```fe +contract Foo { - pub fn add(a: u256, b: u256) -> u256: + pub fn add(a: u256, b: u256) -> u256 { a += b return a + } - pub fn sub(a: u256, b: u256) -> u256: + pub fn sub(a: u256, b: u256) -> u256 { a -= b return a + } - pub fn mul(a: u256, b: u256) -> u256: + pub fn mul(a: u256, b: u256) -> u256 { a *= b return a + } - pub fn div(a: u256, b: u256) -> u256: + pub fn div(a: u256, b: u256) -> u256 { a /= b return a + } - pub fn mod(a: u256, b: u256) -> u256: + pub fn mod(a: u256, b: u256) -> u256 { a %= b return a + } - pub fn pow(a: u256, b: u256) -> u256: + pub fn pow(a: u256, b: u256) -> u256 { a **= b return a + } - pub fn lshift(a: u8, b: u8) -> u8: + pub fn lshift(a: u8, b: u8) -> u8 { a <<= b return a + } - pub fn rshift(a: u8, b: u8) -> u8: + pub fn rshift(a: u8, b: u8) -> u8 { a >>= b return a + } - pub fn bit_or(a: u8, b: u8) -> u8: + pub fn bit_or(a: u8, b: u8) -> u8 { a |= b return a + } - pub fn bit_xor(a: u8, b: u8) -> u8: + pub fn bit_xor(a: u8, b: u8) -> u8 { a ^= b return a + } - pub fn bit_and(a: u8, b: u8) -> u8: + pub fn bit_and(a: u8, b: u8) -> u8 { a &= b return a + } +} ``` [_Expression_]: ../expressions/index.md diff --git a/docs/src/spec/statements/break.md b/docs/src/spec/statements/break.md index f2bea0659b..1099b78aaa 100644 --- a/docs/src/spec/statements/break.md +++ b/docs/src/spec/statements/break.md @@ -11,43 +11,51 @@ If used within nested loops the `break` statement is associated with the innermo An example of a `break` statement used within a [`while`] loop. -```python -contract Foo: +```fe +contract Foo { - pub fn bar() -> u256: + pub fn bar() -> u256 { let sum: u256 - while sum < 10: + while sum < 10 { sum += 1 - if some_abort_condition(): + if some_abort_condition() { break - + } + } return sum + } - fn some_abort_condition() -> bool: + fn some_abort_condition() -> bool { # some complex logic return true + } +} ``` An example of a `break` statement used within a [`for`] loop. -```python -contract Foo: +```fe +contract Foo { - pub fn bar(values: Array) -> u256: + pub fn bar(values: Array) -> u256 { let sum: u256 - for i in values: + for i in values { sum = sum + i - if some_abort_condition(): + if some_abort_condition() { break - + } + } return sum + } - fn some_abort_condition() -> bool: + fn some_abort_condition() -> bool { # some complex logic return true + } +} ``` [`for`]: ./for.md -[`while`]: ./while.md \ No newline at end of file +[`while`]: ./while.md diff --git a/docs/src/spec/statements/const.md b/docs/src/spec/statements/const.md index 60c67e390c..aa38f23bac 100644 --- a/docs/src/spec/statements/const.md +++ b/docs/src/spec/statements/const.md @@ -8,19 +8,18 @@ A `const` statement introduces a named constant value. Constants are either directly inlined wherever they are used or loaded from the contract code depending on their type. -> Note: Constants do only support literals at this point - Example: -```python - +```fe const TEN: u256 = 10 +const HUNDO: u256 = TEN * TEN -contract Foo: - - pub fn bar() -> u256: - return TEN * 5 +contract Foo { + pub fn bar() -> u256 { + return HUNDO + } +} ``` diff --git a/docs/src/spec/statements/continue.md b/docs/src/spec/statements/continue.md index d229746946..08526c8676 100644 --- a/docs/src/spec/statements/continue.md +++ b/docs/src/spec/statements/continue.md @@ -11,43 +11,52 @@ If used within nested loops the `continue` statement is associated with the inne An example of a `continue` statement used within a [`while`] loop. -```python -contract Foo: +```fe +contract Foo { - pub fn bar() -> u256: + pub fn bar() -> u256 { let sum: u256 - while sum < 10: + while sum < 10 { sum += 1 - if some_skip_condition(): + if some_skip_condition() { continue + } + } return sum + } - fn some_skip_condition() -> bool: + fn some_skip_condition() -> bool { # some complex logic return true + } +} ``` An example of a `continue` statement used within a [`for`] loop. -```python -contract Foo: +```fe +contract Foo { - pub fn bar(values: Array) -> u256: + pub fn bar(values: Array) -> u256 { let sum: u256 - for i in values: + for i in values { sum = sum + i - if some_skip_condition(): + if some_skip_condition() { continue - + } + } return sum + } - fn some_skip_condition() -> bool: + fn some_skip_condition() -> bool { # some complex logic return true + } +} ``` [`for`]: ./for.md -[`while`]: ./while.md \ No newline at end of file +[`while`]: ./while.md diff --git a/docs/src/spec/statements/emit.md b/docs/src/spec/statements/emit.md index 22df3f44a2..2537e8c2eb 100644 --- a/docs/src/spec/statements/emit.md +++ b/docs/src/spec/statements/emit.md @@ -22,18 +22,20 @@ The `emit` statement is used to create [log entries] in the blockchain. The `emi Examples: -```python +```fe use std::context::Context -contract Foo: - event Mix: +contract Foo { + event Mix { num1: u256 idx addr: address num2: u256 my_bytes: Array - - pub fn emit_mix(ctx: Context, addr: address, my_bytes: Array): + } + pub fn emit_mix(ctx: Context, addr: address, my_bytes: Array) { emit Mix(ctx, num1: 26, addr, num2: 42, my_bytes) + } +} ``` [_Expression_]: ../expressions/index.md diff --git a/docs/src/spec/statements/for.md b/docs/src/spec/statements/for.md index b4b8b42393..af696c2c8c 100644 --- a/docs/src/spec/statements/for.md +++ b/docs/src/spec/statements/for.md @@ -3,10 +3,9 @@ > **Syntax**\ > _ForStatement_ :\ ->    `for` [IDENTIFIER] `in` [_Expression_] `:` [NEWLINE]\ ->    [INDENT]\ +>    `for` [IDENTIFIER] `in` [_Expression_] `{`\ >    ([_Statement_] | [_Expression_])+\ ->    [DEDENT]\ +>    `}` A `for` statement is a syntactic construct for looping over elements provided by an [array type]. @@ -14,20 +13,20 @@ An example of a `for` loop over the contents of an array: Example: -```python -contract Foo: +```fe +contract Foo { - pub fn bar(values: Array) -> u256: + pub fn bar(values: Array) -> u256 { let sum: u256 - for i in values: + for i in values { sum = sum + i - + } return sum + } +} ``` [NEWLINE]: ../lexical_structure/tokens.md#newline -[INDENT]: ../lexical_structure/tokens.md#indent -[DEDENT]: ../lexical_structure/tokens.md#dedent [IDENTIFIER]: ../lexical_structure/identifiers.md [_Expression_]: ../expressions/index.md [array type]: ../type_system/types/array.md diff --git a/docs/src/spec/statements/if.md b/docs/src/spec/statements/if.md index 63b4bd3c1f..ead428f4e7 100644 --- a/docs/src/spec/statements/if.md +++ b/docs/src/spec/statements/if.md @@ -3,35 +3,34 @@ > **Syntax**\ > _IfStatement_ :\ ->    `if` [_Expression_]`:` [NEWLINE]\ ->    [INDENT]\ +>    `if` [_Expression_]`{` >    ([_Statement_] | [_Expression_])+\ ->    [DEDENT]\ ->    (`else` `:` [NEWLINE]\ ->    [INDENT]\ +>    `}`\ +>    (`else` `{`\ >    ([_Statement_] | [_Expression_])+\ ->    [DEDENT])?\ +>    `}`)?\ Example: -```python -contract Foo: +```fe +contract Foo { - pub fn bar(val: u256) -> u256: - if val > 5: + pub fn bar(val: u256) -> u256 { + if val > 5 { return 1 - else: + } else { return 2 + } + } +} ``` The `if` statement is used for conditional execution. [NEWLINE]: ../lexical_structure/tokens.md#newline -[INDENT]: ../lexical_structure/tokens.md#indent -[DEDENT]: ../lexical_structure/tokens.md#dedent [_Expression_]: ../expressions/index.md [_Statement_]: ./index.md [struct]: ../items/structs.md -[EIP-838]: https://github.com/ethereum/EIPs/issues/838 \ No newline at end of file +[EIP-838]: https://github.com/ethereum/EIPs/issues/838 diff --git a/docs/src/spec/statements/index.md b/docs/src/spec/statements/index.md index 87cf0355e9..75e0a941c9 100644 --- a/docs/src/spec/statements/index.md +++ b/docs/src/spec/statements/index.md @@ -14,4 +14,3 @@ * [break Statement](./break.md) * [continue Statement](./continue.md) * [assert Statement](./assert.md) -* [pass Statement](./pass.md) \ No newline at end of file diff --git a/docs/src/spec/statements/let.md b/docs/src/spec/statements/let.md index 7db173099e..6bee0908d8 100644 --- a/docs/src/spec/statements/let.md +++ b/docs/src/spec/statements/let.md @@ -18,14 +18,16 @@ A `let` statement introduces a new set of variables. Any variables introduced by Example: -```python -contract Foo: +```fe +contract Foo { - pub fn bar(): + pub fn bar() { let val1: u256 = 1 let (val2):(u256) = (1,) let (val3, val4):(u256, bool) = (1, false) let (val5, val6, (val7, val8)):(u256, bool, (u256, u256)) = (1, false, (2, 4)) + } +} ``` diff --git a/docs/src/spec/statements/pass.md b/docs/src/spec/statements/pass.md deleted file mode 100644 index 0c1edd9fd5..0000000000 --- a/docs/src/spec/statements/pass.md +++ /dev/null @@ -1,34 +0,0 @@ -# `pass` statement - - -> **Syntax**\ -> _PassStatement_ :\ ->    `pass` - -The `pass` statement is a *null* operation, it has no effect on code execution. It is useful as a placeholder when a statement is required syntactically, but no code needs to be executed. - -Example of `pass` being used to define an empty contract body. - -```python -contract Foo: - pass -``` - -Example of `pass` being used to define an empty function body. - -```python -contract Foo: - - pub fn bar(): - pass -``` - -Example of `pass` being used to define an code block after an `if` statement. - -```python -contract Foo: - - pub fn bar(condition: bool): - if condition: - pass -``` diff --git a/docs/src/spec/statements/pragma.md b/docs/src/spec/statements/pragma.md index aec3fad97d..1157566fd5 100644 --- a/docs/src/spec/statements/pragma.md +++ b/docs/src/spec/statements/pragma.md @@ -13,11 +13,11 @@ statement will cause the compiler to reject compilation if the version of the co An example of a `pragma` statement: -``` +```fe,ignore pragma ^0.1.0 ``` The version requirement syntax is identical to the one that is used by cargo ([more info]). [more info]:https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html -[cargo]:https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html \ No newline at end of file +[cargo]:https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html diff --git a/docs/src/spec/statements/return.md b/docs/src/spec/statements/return.md index 0f1d31d776..6e907b63dd 100644 --- a/docs/src/spec/statements/return.md +++ b/docs/src/spec/statements/return.md @@ -10,30 +10,38 @@ The return statement is denoted with the keyword `return`. A `return` statement An example of a `return` statement without explicit use of an expression: -```python -contract Foo: - fn transfer(self, to: address, value: u256): - if not self.in_whitelist(to): +```fe +contract Foo { + fn transfer(self, to: address, value: u256) { + if not self.in_whitelist(to) { return + } + } - fn in_whitelist(self, to: address) -> bool: + fn in_whitelist(self, to: address) -> bool { # revert used as placeholder for actual logic revert + } +} ``` The above can also be written in a slightly more verbose form: -```python -contract Foo: - fn transfer(self, to: address, value: u256) -> (): - if not self.in_whitelist(to): +```fe +contract Foo { + fn transfer(self, to: address, value: u256) -> () { + if not self.in_whitelist(to) { return () + } + } - fn in_whitelist(self, to: address) -> bool: + fn in_whitelist(self, to: address) -> bool { # revert used as placeholder for actual logic revert + } +} ``` [_Expression_]: ../expressions/index.md [struct]: ../items/structs.md -[EIP-838]: https://github.com/ethereum/EIPs/issues/838 \ No newline at end of file +[EIP-838]: https://github.com/ethereum/EIPs/issues/838 diff --git a/docs/src/spec/statements/revert.md b/docs/src/spec/statements/revert.md index f18afd1c45..8bdbe4e2c7 100644 --- a/docs/src/spec/statements/revert.md +++ b/docs/src/spec/statements/revert.md @@ -10,24 +10,42 @@ statement will cause to revert all state changes made by the call and return wit An example of a `revert` statement without revert data: -``` -contract Foo: - fn transfer(self, to : address, value : u256): - if not self.in_whitelist(to): +```fe +contract Foo { + fn transfer(self, to: address, value: u256) { + if not self.in_whitelist(addr: to) { revert + } # more logic here + } + + fn in_whitelist(self, addr: address) -> bool { + return false + } +} ``` An example of a `revert` statement with revert data: -``` -contract Foo: - fn transfer(self, to : address, value : u256): - if not self.in_whitelist(to): - revert ApplicationError(code=5) +```fe +struct ApplicationError { + pub code: u8 +} + +contract Foo { + pub fn transfer(self, to: address, value: u256) { + if not self.in_whitelist(addr: to) { + revert ApplicationError(code: 5) + } # more logic here + } + + fn in_whitelist(self, addr: address) -> bool { + return false + } +} ``` [_Expression_]: ../expressions/index.md [struct]: ../items/structs.md -[EIP-838]: https://github.com/ethereum/EIPs/issues/838 \ No newline at end of file +[EIP-838]: https://github.com/ethereum/EIPs/issues/838 diff --git a/docs/src/spec/statements/while.md b/docs/src/spec/statements/while.md index 5cef81980f..c34e99d62e 100644 --- a/docs/src/spec/statements/while.md +++ b/docs/src/spec/statements/while.md @@ -3,29 +3,28 @@ > **Syntax**\ > _WhileStatement_ :\ ->    `while` [_Expression_] `:` [NEWLINE]\ ->    [INDENT]\ +>    `while` [_Expression_] `{`\ >    ([_Statement_] | [_Expression_])+\ ->    [DEDENT]\ +>    `}`\ A `while` loop begins by evaluation the [boolean] loop conditional expression. If the loop conditional expression evaluates to `true`, the loop body block executes, then control returns to the loop conditional expression. If the loop conditional expression evaluates to `false`, the `while` expression completes. Example: -```python -contract Foo: +```fe +contract Foo { - pub fn bar() -> u256: + pub fn bar() -> u256 { let sum: u256 - while sum < 10: + while sum < 10 { sum += 1 - + } return sum + } +} ``` [NEWLINE]: ../lexical_structure/tokens.md#newline -[INDENT]: ../lexical_structure/tokens.md#indent -[DEDENT]: ../lexical_structure/tokens.md#dedent [_Expression_]: ../expressions/index.md [_Statement_]: ./index.md [boolean]: ../type_system/types/boolean.md diff --git a/docs/src/spec/type_system/types/address.md b/docs/src/spec/type_system/types/address.md index 021bcc8a8f..39203320b6 100644 --- a/docs/src/spec/type_system/types/address.md +++ b/docs/src/spec/type_system/types/address.md @@ -4,12 +4,14 @@ The `address` type represents a 20 byte Ethereum address. Example: -```Python -contract Example: +```fe +contract Example { # An address in storage someone: address - fn do_something(): + fn do_something() { # A plain address (not part of a tuple, struct etc) remains on the stack - dai_contract: address = address(0x6b175474e89094c44da98b954eedeac495271d0f) -``` \ No newline at end of file + let dai_contract: address = address(0x6b175474e89094c44da98b954eedeac495271d0f) + } +} +``` diff --git a/docs/src/spec/type_system/types/array.md b/docs/src/spec/type_system/types/array.md index 8488592207..a44c2610c6 100644 --- a/docs/src/spec/type_system/types/array.md +++ b/docs/src/spec/type_system/types/array.md @@ -11,14 +11,16 @@ Arrays are either stored in storage or memory but are never stored directly on t Examples: -```Python -contract Foo: +```fe +contract Foo { # An array in storage bar: Array - fn do_something(): + fn do_something() { # An array in memory - values: Array = [10, 100, 100] + let values: Array = [10, 100, 100] + } +} ``` All elements of arrays are always initialized, and access to an array is diff --git a/docs/src/spec/type_system/types/boolean.md b/docs/src/spec/type_system/types/boolean.md index 1137234396..8925a12621 100644 --- a/docs/src/spec/type_system/types/boolean.md +++ b/docs/src/spec/type_system/types/boolean.md @@ -4,6 +4,6 @@ The `bool` type is a data type which can be either `true` or `false`. Example: -```Python -x = true -``` \ No newline at end of file +``` +let x: bool = true +``` diff --git a/docs/src/spec/type_system/types/contract.md b/docs/src/spec/type_system/types/contract.md index 584375cc85..087bb8aebe 100644 --- a/docs/src/spec/type_system/types/contract.md +++ b/docs/src/spec/type_system/types/contract.md @@ -2,25 +2,29 @@ An *contract type* is the type denoted by the name of an [`contract` item]. -A value of a given contract type carries the contract's public interface as +A value of a given contract type carries the contract's public interface as attribute functions. A new contract value can be created by either casting -an address to a contract type or by creating a new contract using the type +an address to a contract type or by creating a new contract using the type attribute functions `create` or `create2`. Example: -```python +```fe use std::context::Context -contract Foo: - pub fn get_my_num() -> u256: +contract Foo { + pub fn get_my_num() -> u256 { return 42 + } +} -contract FooFactory: - pub fn create2_foo(ctx: Context) -> address: +contract FooFactory { + pub fn create2_foo(ctx: Context) -> address { # `0` is the value being sent and `52` is the address salt let foo: Foo = Foo.create2(ctx, 0, 52) return address(foo) + } +} ``` -[`contract` item]: ../../items/contracts.md \ No newline at end of file +[`contract` item]: ../../items/contracts.md diff --git a/docs/src/spec/type_system/types/map.md b/docs/src/spec/type_system/types/map.md index 8cfa6fa22c..22a6ec5dfb 100644 --- a/docs/src/spec/type_system/types/map.md +++ b/docs/src/spec/type_system/types/map.md @@ -13,22 +13,27 @@ The values can be of any type including other maps, [structs], [tuples] or [arra Example: -```python -contract Foo: +```fe +contract Foo { bar: Map> baz: Map> - pub fn read_bar(self, a: address, b: address) -> u256: + pub fn read_bar(self, a: address, b: address) -> u256 { return self.bar[a][b] + } - pub fn write_bar(self, a: address, b: address, value: u256): + pub fn write_bar(self, a: address, b: address, value: u256) { self.bar[a][b] = value + } - pub fn read_baz(self, a: address, b: u256) -> bool: + pub fn read_baz(self, a: address, b: u256) -> bool { return self.baz[a][b] + } - pub fn write_baz(self, a: address, b: u256, value: bool): + pub fn write_baz(self, a: address, b: u256, value: bool) { self.baz[a][b] = value + } +} ``` [unit type]: unit.md @@ -37,4 +42,4 @@ contract Foo: [numeric types]: numeric.md [structs]: struct.md [tuples]: tuple.md -[arrays]: array.md \ No newline at end of file +[arrays]: array.md diff --git a/docs/src/spec/type_system/types/string.md b/docs/src/spec/type_system/types/string.md index 97631002e7..e2cac15435 100644 --- a/docs/src/spec/type_system/types/string.md +++ b/docs/src/spec/type_system/types/string.md @@ -8,11 +8,12 @@ Note that the value of `N` does not restrict the type to hold exactly that numbe Example: -```python -contract Foo: +```fe +contract Foo { - fn bar(): + fn bar() { let single_byte_string: String<1> = "a" - # Casting is needed because the type inferred from "foo" is String<3> - let longer_string: String<100> = String<100>("foo") -``` \ No newline at end of file + let longer_string: String<100> = "foo" + } +} +``` diff --git a/docs/src/spec/type_system/types/struct.md b/docs/src/spec/type_system/types/struct.md index 8c19aedcac..abf44d975e 100644 --- a/docs/src/spec/type_system/types/struct.md +++ b/docs/src/spec/type_system/types/struct.md @@ -10,19 +10,22 @@ Struct types are either stored in storage or memory but are never stored directl Examples: -```Python -struct Rectangle: - width: u256 - length: u256 +```fe +struct Rectangle { + pub width: u256 + pub length: u256 +} -contract Example: +contract Example { # A Rectangle in storage area: Rectangle - fn do_something(): + fn do_something() { let length: u256 = 20 # A rectangle in memory let square: Rectangle = Rectangle(width: 10, length) + } +} ``` All fields of struct types are always initialized. diff --git a/docs/theme/custom-highlight.js b/docs/theme/custom-highlight.js new file mode 100644 index 0000000000..c5dd9aa21a --- /dev/null +++ b/docs/theme/custom-highlight.js @@ -0,0 +1,87 @@ +function highlight_fe(hljs) { + const KEYWORDS = [ + "and", + "break", + "const", + "continue", + "contract", + "ingot", + "else", + "emit", + "enum", + "event", + "false", + "fn", + "for", + "idx", + "if", + "impl", + "in", + "let", + "loop", + "match", + "mut", + "or", + "not", + "pragma", + "pub", + "return", + "revert", + "self", + "Self", + "struct", + "trait", + "true", + "type", + "unsafe", + "use", + "where", + "while" + ]; + + const TYPES = [ + "address", + "i8", + "i16", + "i32", + "i64", + "i128", + "i256", + "u8", + "u16", + "u32", + "u64", + "u128", + "u256", + "bool", + "Context", + "Option", + "Result", + "String", + "Array", + "Map" + ]; + + return { + name: "Fe", + keywords: { + keyword: KEYWORDS.join(' '), + built_in: TYPES.join(' '), + literal: "false true", + }, + contains: [ + hljs.QUOTE_STRING_MODE, + hljs.C_NUMBER_MODE, + { + scope: "string", + begin: '"', + end: '"', + contains: [{ begin: "\\\\." }], + }, + hljs.COMMENT("#", "\n"), + ], + } +} + +hljs.registerLanguage("fe", highlight_fe); +hljs.initHighlightingOnLoad(); diff --git a/docs/validate_doc_examples.py b/docs/validate_doc_examples.py index c872327053..b4dfbaebc9 100755 --- a/docs/validate_doc_examples.py +++ b/docs/validate_doc_examples.py @@ -9,34 +9,10 @@ BOOK_SRC_DIR = THIS_DIR / 'src' TMP_SNIPPET_DIR = THIS_DIR / 'tmp_snippets' -# This will need to change in the future when code snippets are annotated with ```fe -CODE_SNIPPET_START_MARKER = '```python' +# use ```fe,ignore on snippets that shouldn't be tested +CODE_SNIPPET_START_MARKER = '```fe' CODE_SNIPPET_END_MARKER = '```' -# List of known snippets that should be skipped. This is usually the case -# when a snippets don't form a fully working contract. In the future if -# mdBook adds a way to hide code lines for non rust languages, these cases -# could be further minimized: https://github.com/rust-lang/mdBook/issues/1475 -# TRY TO KEEP THIS LIST SHORT -SKIP_LIST = [ - 'release_notes.md_0.fe', - 'release_notes.md_6.fe', - 'release_notes.md_7.fe', - 'sequence_types_in_memory.md_0.fe', - 'to_mem_function.md_0.fe', - 'visibility_and_privacy.md_0.fe', - 'clone_function.md_0.fe', - 'tokens.md_0.fe', - 'constant_size_values_in_storage.md_0.fe', - 'stack.md_0.fe', - 'functions.md_0.fe', - 'first_contract.md_0.fe', - 'first_contract.md_2.fe', - 'visibility_and_privacy.md_1.fe', - 'visibility_and_privacy.md_2.fe', - 'visibility_and_privacy.md_3.fe' -] - class CodeSnippet(NamedTuple): path: pathlib.Path index: int @@ -61,7 +37,7 @@ def get_all_snippets_in_file(path: pathlib.Path) -> Iterable[CodeSnippet]: snippet = None snippet_index = 0 for line in lines: - if line.strip().startswith(CODE_SNIPPET_START_MARKER): + if 'ignore' not in line and line.strip().startswith(CODE_SNIPPET_START_MARKER): snippet = CodeSnippet(path=path, index=snippet_index, content='') snippet_index += 1 elif line.strip().startswith(CODE_SNIPPET_END_MARKER): @@ -78,16 +54,19 @@ def create_fe_file(snippet: CodeSnippet) -> pathlib.Path: return fe_snippet_path def run_snippet(path: pathlib.Path) -> 'subprocess.CompletedProcess[bytes]': - return subprocess.run(["cargo", "run", str(path), '--overwrite']) + return subprocess.run(["./target/debug/fe", str(path), '--overwrite', '-e', 'abi']) def validate_code_examples() -> None: TMP_SNIPPET_DIR.mkdir(exist_ok=True) + build = subprocess.run(["cargo", "build"]) + if build.returncode == 1: + exit(1) + for path in get_all_doc_files(): for snippet in get_all_snippets_in_file(path): - if not snippet.unique_name() in SKIP_LIST: - fe_snippet = create_fe_file(snippet) - compile_result = run_snippet(fe_snippet) - if compile_result.returncode == 1: - exit(1) + fe_snippet = create_fe_file(snippet) + compile_result = run_snippet(fe_snippet) + if compile_result.returncode == 1: + exit(1) validate_code_examples() diff --git a/newsfragments/707.feature.md b/newsfragments/707.feature.md new file mode 100644 index 0000000000..379441dfb3 --- /dev/null +++ b/newsfragments/707.feature.md @@ -0,0 +1,28 @@ +Braces! Fe has abandoned python-style significant whitespace in favor of the +trusty curly brace. + +In addition, `elif` is now spelled `else if`, and the `pass` +statement no longer exists. + +Example: +``` +pub struct SomeError {} + +contract Foo { + x: u8 + y: u16 + + pub fn f(a: u8) -> u8 { + if a > 10 { + let x: u8 = 5 + return a + x + } else if a == 0 { + revert SomeError() + } else { + return a * 10 + } + } + + pub fn noop() {} +} +```