From 411d4b8d40b12a40d068474076f035f1966b235d Mon Sep 17 00:00:00 2001 From: Sean Billig Date: Wed, 1 Jun 2022 13:43:08 -0700 Subject: [PATCH] wip --- .../analysis__abi_encoding_stress.snap | 117 +++-- .../analysis__address_bytes10_map.snap | 19 +- .../tests/snapshots/analysis__assert.snap | 28 +- .../snapshots/analysis__associated_fns.snap | 16 +- .../tests/snapshots/analysis__aug_assign.snap | 89 ++-- .../tests/snapshots/analysis__balances.snap | 17 +- .../tests/snapshots/analysis__base_tuple.snap | 4 +- .../snapshots/analysis__basic_ingot.snap | 14 +- .../analysis__call_statement_with_args.snap | 19 +- .../analysis__call_statement_with_args_2.snap | 19 +- ...analysis__call_statement_without_args.snap | 18 +- .../analysis__checked_arithmetic.snap | 288 ++++++++--- .../snapshots/analysis__constructor.snap | 7 +- .../snapshots/analysis__create2_contract.snap | 3 +- .../snapshots/analysis__create_contract.snap | 3 +- .../analysis__create_contract_from_init.snap | 7 +- .../analysis__data_copying_stress.snap | 113 +++-- .../snapshots/analysis__erc20_token.snap | 171 +++++-- .../tests/snapshots/analysis__events.snap | 33 +- .../analysis__external_contract.snap | 34 +- .../analysis__for_loop_with_break.snap | 16 +- .../analysis__for_loop_with_continue.snap | 16 +- .../analysis__for_loop_with_static_array.snap | 16 +- .../tests/snapshots/analysis__guest_book.snap | 19 +- .../snapshots/analysis__if_statement.snap | 3 +- .../snapshots/analysis__if_statement_2.snap | 3 +- .../tests/snapshots/analysis__keccak.snap | 9 +- .../tests/snapshots/analysis__math.snap | 43 +- .../analysis__module_level_events.snap | 7 +- .../snapshots/analysis__multi_param.snap | 13 +- .../tests/snapshots/analysis__nested_map.snap | 42 +- .../tests/snapshots/analysis__ownable.snap | 28 +- .../analysis__pure_fn_standalone.snap | 24 +- .../analysis__return_addition_i256.snap | 4 +- .../analysis__return_addition_u128.snap | 4 +- .../analysis__return_addition_u256.snap | 4 +- .../snapshots/analysis__return_array.snap | 11 +- .../analysis__return_bitwiseand_u128.snap | 4 +- .../analysis__return_bitwiseand_u256.snap | 4 +- .../analysis__return_bitwiseor_u256.snap | 4 +- .../analysis__return_bitwiseshl_u256.snap | 4 +- .../analysis__return_bitwiseshr_i256.snap | 4 +- .../analysis__return_bitwiseshr_u256.snap | 4 +- .../analysis__return_bitwisexor_u256.snap | 4 +- .../analysis__return_bool_inverted.snap | 3 +- .../analysis__return_bool_op_and.snap | 4 +- .../analysis__return_bool_op_or.snap | 4 +- .../analysis__return_builtin_attributes.snap | 30 +- .../analysis__return_division_i256.snap | 4 +- .../analysis__return_division_u256.snap | 4 +- .../snapshots/analysis__return_eq_u256.snap | 4 +- .../snapshots/analysis__return_gt_i256.snap | 4 +- .../snapshots/analysis__return_gt_u256.snap | 4 +- .../snapshots/analysis__return_gte_i256.snap | 4 +- .../snapshots/analysis__return_gte_u256.snap | 4 +- .../analysis__return_identity_u128.snap | 3 +- .../analysis__return_identity_u16.snap | 3 +- .../analysis__return_identity_u256.snap | 3 +- .../analysis__return_identity_u32.snap | 3 +- .../analysis__return_identity_u64.snap | 3 +- .../analysis__return_identity_u8.snap | 3 +- .../snapshots/analysis__return_lt_i256.snap | 4 +- .../snapshots/analysis__return_lt_u128.snap | 4 +- .../snapshots/analysis__return_lt_u256.snap | 4 +- .../snapshots/analysis__return_lte_i256.snap | 4 +- .../snapshots/analysis__return_lte_u256.snap | 4 +- .../snapshots/analysis__return_mod_i256.snap | 4 +- .../snapshots/analysis__return_mod_u256.snap | 4 +- .../snapshots/analysis__return_msg_sig.snap | 3 +- .../analysis__return_multiplication_i256.snap | 4 +- .../analysis__return_multiplication_u256.snap | 4 +- .../analysis__return_noteq_u256.snap | 4 +- .../snapshots/analysis__return_pow_i256.snap | 4 +- .../snapshots/analysis__return_pow_u256.snap | 4 +- .../analysis__return_subtraction_i256.snap | 4 +- .../analysis__return_subtraction_u256.snap | 4 +- .../analysis__return_u256_from_called_fn.snap | 7 +- ..._return_u256_from_called_fn_with_args.snap | 16 +- .../tests/snapshots/analysis__revert.snap | 12 +- .../snapshots/analysis__self_address.snap | 3 +- .../tests/snapshots/analysis__send_value.snap | 5 +- .../analysis__simple_open_auction.snap | 30 +- .../analysis__sized_vals_in_sto.snap | 61 ++- .../tests/snapshots/analysis__strings.snap | 4 +- .../tests/snapshots/analysis__struct_fns.snap | 65 ++- .../tests/snapshots/analysis__structs.snap | 175 ++++--- .../analysis__ternary_expression.snap | 3 +- .../snapshots/analysis__tuple_stress.snap | 54 ++- .../snapshots/analysis__two_contracts.snap | 31 +- .../snapshots/analysis__type_aliases.snap | 193 ++++---- .../snapshots/analysis__u128_u128_map.snap | 19 +- .../snapshots/analysis__u16_u16_map.snap | 19 +- .../snapshots/analysis__u256_u256_map.snap | 19 +- .../snapshots/analysis__u32_u32_map.snap | 19 +- .../snapshots/analysis__u64_u64_map.snap | 19 +- .../tests/snapshots/analysis__u8_u8_map.snap | 19 +- .../tests/snapshots/analysis__uniswap.snap | 448 ++++++++++++------ .../tests/snapshots/analysis__while_loop.snap | 14 +- .../analysis__while_loop_with_break.snap | 14 +- .../analysis__while_loop_with_break_2.snap | 14 +- .../analysis__while_loop_with_continue.snap | 24 +- ..._call_non_pub_fn_on_external_contract.snap | 2 +- ...rs__ctx_builtins_param_incorrect_type.snap | 8 - .../snapshots/errors__ctx_missing_event.snap | 8 - .../errors__ctx_missing_internal_call.snap | 6 +- .../errors__duplicate_var_in_child_scope.snap | 10 +- .../snapshots/errors__emit_bad_args.snap | 8 +- .../snapshots/errors__missing_return.snap | 2 +- .../tests/snapshots/errors__self_misuse.snap | 14 +- .../snapshots/errors__self_mut_mismatch.snap | 10 +- .../snapshots/errors__sneaky_mutation.snap | 4 +- crates/library/std/src/context.fe | 2 +- .../cases__parse_ast__fn_def_generic.snap | 15 +- .../cases__parse_ast__fn_def_mut_args.snap | 27 +- .../cases__parse_ast__struct_def.snap | 4 +- .../snapshots/cases__print_ast__erc20.snap | 22 +- .../cases__print_ast__guest_book.snap | 2 +- .../call_event_with_wrong_types.fe | 2 +- .../call_non_pub_fn_on_external_contract.fe | 2 +- .../duplicate_var_in_child_scope.fe | 4 +- .../duplicate_var_in_for_loop.fe | 2 +- .../fixtures/compile_errors/needs_mem_copy.fe | 2 +- .../fixtures/compile_errors/not_in_scope_2.fe | 2 +- .../compile_errors/self_mut_mismatch.fe | 34 +- .../compile_errors/sneaky_mutation.fe | 17 +- .../test-files/fixtures/demos/erc20_token.fe | 22 +- .../test-files/fixtures/demos/guest_book.fe | 2 +- .../fixtures/demos/simple_open_auction.fe | 8 +- crates/test-files/fixtures/demos/uniswap.fe | 58 +-- .../fixtures/features/address_bytes10_map.fe | 2 +- crates/test-files/fixtures/features/assert.fe | 4 +- .../fixtures/features/associated_fns.fe | 2 +- .../fixtures/features/aug_assign.fe | 26 +- .../features/call_statement_with_args.fe | 4 +- .../features/call_statement_with_args_2.fe | 4 +- .../features/call_statement_without_args.fe | 4 +- .../fixtures/features/constructor.fe | 2 +- .../features/create_contract_from_init.fe | 2 +- .../features/ctx_param_external_func_call.fe | 2 +- .../features/ctx_param_internal_func_call.fe | 2 +- crates/test-files/fixtures/features/events.fe | 10 +- .../fixtures/features/external_contract.fe | 6 +- .../fixtures/features/for_loop_with_break.fe | 4 +- .../features/for_loop_with_continue.fe | 4 +- .../features/for_loop_with_static_array.fe | 4 +- .../for_loop_with_static_array_from_sto.fe | 4 +- .../features/if_statement_test_from_sto.fe | 2 +- .../fixtures/features/int_literal_coercion.fe | 2 +- .../test-files/fixtures/features/map_tuple.fe | 2 +- crates/test-files/fixtures/features/math.fe | 4 +- .../fixtures/features/module_level_events.fe | 2 +- .../fixtures/features/multi_param.fe | 2 +- .../fixtures/features/nested_map.fe | 4 +- .../test-files/fixtures/features/ownable.fe | 6 +- .../fixtures/features/pure_fn_standalone.fe | 4 +- .../fixtures/features/return_array.fe | 2 +- .../features/return_from_storage_array_i8.fe | 2 +- .../features/return_from_storage_i8.fe | 2 +- .../features/return_sum_list_expression_1.fe | 4 +- .../features/return_sum_list_expression_2.fe | 2 +- .../return_u256_from_called_fn_with_args.fe | 2 +- crates/test-files/fixtures/features/revert.fe | 2 +- .../fixtures/features/sized_vals_in_sto.fe | 8 +- .../test-files/fixtures/features/strings.fe | 2 +- .../fixtures/features/struct_fns.fe | 10 +- .../test-files/fixtures/features/structs.fe | 14 +- .../fixtures/features/two_contracts.fe | 6 +- .../fixtures/features/type_aliases.fe | 10 +- .../fixtures/features/u128_u128_map.fe | 2 +- .../fixtures/features/u16_u16_map.fe | 2 +- .../fixtures/features/u256_u256_map.fe | 2 +- .../fixtures/features/u32_u32_map.fe | 2 +- .../fixtures/features/u64_u64_map.fe | 2 +- .../test-files/fixtures/features/u8_u8_map.fe | 2 +- .../fixtures/features/while_loop.fe | 2 +- .../features/while_loop_test_from_sto.fe | 2 +- .../features/while_loop_with_break.fe | 2 +- .../features/while_loop_with_break_2.fe | 2 +- .../features/while_loop_with_continue.fe | 4 +- .../fixtures/stress/abi_encoding_stress.fe | 16 +- .../fixtures/stress/data_copying_stress.fe | 22 +- .../fixtures/stress/external_calls.fe | 8 +- .../fixtures/stress/tuple_stress.fe | 6 +- ...ests__demo_uniswap__uniswap_contracts.snap | 2 +- 184 files changed, 2116 insertions(+), 1183 deletions(-) diff --git a/crates/analyzer/tests/snapshots/analysis__abi_encoding_stress.snap b/crates/analyzer/tests/snapshots/analysis__abi_encoding_stress.snap index 3d4840c3a0..d219c33c22 100644 --- a/crates/analyzer/tests/snapshots/analysis__abi_encoding_stress.snap +++ b/crates/analyzer/tests/snapshots/analysis__abi_encoding_stress.snap @@ -50,18 +50,22 @@ note: note: ┌─ abi_encoding_stress.fe:27:5 │ -27 │ ╭ pub fn set_my_addrs(self, my_addrs: Array) { +27 │ ╭ pub fn set_my_addrs(mut self, my_addrs: Array) { 28 │ │ self.my_addrs = my_addrs 29 │ │ } - │ ╰─────^ attributes hash: 8893819222299525150 + │ ╰─────^ attributes hash: 2261211863999912498 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 535..539, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_addrs", typ: Ok( @@ -101,11 +105,14 @@ note: 31 │ ╭ pub fn get_my_addrs(self) -> Array { 32 │ │ return self.my_addrs.to_mem() 33 │ │ } - │ ╰─────^ attributes hash: 1736881624347502724 + │ ╰─────^ attributes hash: 1242159413180920033 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 636..640, + }, ), ctx_decl: None, params: [], @@ -140,18 +147,22 @@ note: note: ┌─ abi_encoding_stress.fe:35:5 │ -35 │ ╭ pub fn set_my_u128(self, my_u128: u128) { +35 │ ╭ pub fn set_my_u128(mut self, my_u128: u128) { 36 │ │ self.my_u128 = my_u128 37 │ │ } - │ ╰─────^ attributes hash: 15199964699853061770 + │ ╰─────^ attributes hash: 10686864831516926105 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 737..741, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_u128", typ: Ok( @@ -190,11 +201,14 @@ note: 39 │ ╭ pub fn get_my_u128(self) -> u128 { 40 │ │ return self.my_u128 41 │ │ } - │ ╰─────^ attributes hash: 15343208064821852867 + │ ╰─────^ attributes hash: 13239177426284803553 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 821..825, + }, ), ctx_decl: None, params: [], @@ -222,18 +236,22 @@ note: note: ┌─ abi_encoding_stress.fe:43:5 │ -43 │ ╭ pub fn set_my_string(self, my_string: String<10>) { +43 │ ╭ pub fn set_my_string(mut self, my_string: String<10>) { 44 │ │ self.my_string = my_string 45 │ │ } - │ ╰─────^ attributes hash: 241116312146617781 + │ ╰─────^ attributes hash: 7050396491214636923 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 901..905, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_string", typ: Ok( @@ -272,11 +290,14 @@ note: 47 │ ╭ pub fn get_my_string(self) -> String<10> { 48 │ │ return self.my_string.to_mem() 49 │ │ } - │ ╰─────^ attributes hash: 1556448784000816371 + │ ╰─────^ attributes hash: 6543955680763677008 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 999..1003, + }, ), ctx_decl: None, params: [], @@ -310,18 +331,22 @@ note: note: ┌─ abi_encoding_stress.fe:51:5 │ -51 │ ╭ pub fn set_my_u16s(self, my_u16s: Array) { +51 │ ╭ pub fn set_my_u16s(mut self, my_u16s: Array) { 52 │ │ self.my_u16s = my_u16s 53 │ │ } - │ ╰─────^ attributes hash: 15015381430419725173 + │ ╰─────^ attributes hash: 4346788423205731808 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 1094..1098, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_u16s", typ: Ok( @@ -363,11 +388,14 @@ note: 55 │ ╭ pub fn get_my_u16s(self) -> Array { 56 │ │ return self.my_u16s.to_mem() 57 │ │ } - │ ╰─────^ attributes hash: 14119474618304681318 + │ ╰─────^ attributes hash: 11956605043509286213 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 1189..1193, + }, ), ctx_decl: None, params: [], @@ -404,18 +432,22 @@ note: note: ┌─ abi_encoding_stress.fe:59:5 │ -59 │ ╭ pub fn set_my_bool(self, my_bool: bool) { +59 │ ╭ pub fn set_my_bool(mut self, my_bool: bool) { 60 │ │ self.my_bool = my_bool 61 │ │ } - │ ╰─────^ attributes hash: 3845928701529339179 + │ ╰─────^ attributes hash: 1055917414416595358 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 1287..1291, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_bool", typ: Ok( @@ -452,11 +484,14 @@ note: 63 │ ╭ pub fn get_my_bool(self) -> bool { 64 │ │ return self.my_bool 65 │ │ } - │ ╰─────^ attributes hash: 2163156009319630199 + │ ╰─────^ attributes hash: 9113221655060069026 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 1371..1375, + }, ), ctx_decl: None, params: [], @@ -482,18 +517,22 @@ note: note: ┌─ abi_encoding_stress.fe:67:5 │ -67 │ ╭ pub fn set_my_bytes(self, my_bytes: Array) { +67 │ ╭ pub fn set_my_bytes(mut self, my_bytes: Array) { 68 │ │ self.my_bytes = my_bytes 69 │ │ } - │ ╰─────^ attributes hash: 11573101353594183790 + │ ╰─────^ attributes hash: 14575135303485954620 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 1450..1454, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_bytes", typ: Ok( @@ -535,11 +574,14 @@ note: 71 │ ╭ pub fn get_my_bytes(self) -> Array { 72 │ │ return self.my_bytes.to_mem() 73 │ │ } - │ ╰─────^ attributes hash: 157798734366762321 + │ ╰─────^ attributes hash: 2825026861954100839 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 1548..1552, + }, ), ctx_decl: None, params: [], @@ -627,20 +669,21 @@ note: note: ┌─ abi_encoding_stress.fe:79:5 │ -79 │ ╭ pub fn mod_my_struct(my_struct: MyStruct) -> MyStruct { +79 │ ╭ pub fn mod_my_struct(mut 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 + │ ╰─────^ attributes hash: 13200187284784553811 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: true, label: None, name: "my_struct", typ: Ok( @@ -724,20 +767,24 @@ note: note: ┌─ abi_encoding_stress.fe:87:5 │ -87 │ ╭ pub fn emit_my_event(self, ctx: Context) { +87 │ ╭ pub fn emit_my_event(self, mut 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 + │ ╰─────^ attributes hash: 7205084328787069281 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 2029..2033, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__address_bytes10_map.snap b/crates/analyzer/tests/snapshots/analysis__address_bytes10_map.snap index 5cd353e9fb..2d3d25b622 100644 --- a/crates/analyzer/tests/snapshots/analysis__address_bytes10_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__address_bytes10_map.snap @@ -15,15 +15,19 @@ note: 4 │ ╭ pub fn read_bar(self, key: address) -> Array { 5 │ │ return self.bar[key].to_mem() 6 │ │ } - │ ╰─────^ attributes hash: 7365261960972751402 + │ ╰─────^ attributes hash: 10562697749306342509 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 73..77, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "key", typ: Ok( @@ -74,18 +78,22 @@ note: note: ┌─ address_bytes10_map.fe:8:5 │ - 8 │ ╭ pub fn write_bar(self, key: address, value: Array) { + 8 │ ╭ pub fn write_bar(mut self, key: address, value: Array) { 9 │ │ self.bar[key] = value 10 │ │ } - │ ╰─────^ attributes hash: 10331226497424577374 + │ ╰─────^ attributes hash: 13716785056256225687 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 182..186, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "key", typ: Ok( @@ -95,6 +103,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__assert.snap b/crates/analyzer/tests/snapshots/analysis__assert.snap index 8caccc07a7..0552dbd315 100644 --- a/crates/analyzer/tests/snapshots/analysis__assert.snap +++ b/crates/analyzer/tests/snapshots/analysis__assert.snap @@ -17,13 +17,14 @@ note: 5 │ ╭ pub fn bar(baz: u256) { 6 │ │ assert baz > 5 7 │ │ } - │ ╰─────^ attributes hash: 2614610269237134179 + │ ╰─────^ attributes hash: 11180987370333190690 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "baz", typ: Ok( @@ -62,13 +63,14 @@ note: 9 │ ╭ pub fn revert_with_static_string(baz: u256) { 10 │ │ assert baz > 5, "Must be greater than five" 11 │ │ } - │ ╰─────^ attributes hash: 2614610269237134179 + │ ╰─────^ attributes hash: 11180987370333190690 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "baz", typ: Ok( @@ -109,13 +111,14 @@ note: 13 │ ╭ pub fn revert_with(baz: u256, reason: String<1000>) { 14 │ │ assert baz > 5, reason 15 │ │ } - │ ╰─────^ attributes hash: 10044481770469626577 + │ ╰─────^ attributes hash: 5856527761647113718 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "baz", typ: Ok( @@ -127,6 +130,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "reason", typ: Ok( @@ -164,15 +168,18 @@ note: note: ┌─ assert.fe:17:5 │ -17 │ ╭ pub fn assert_sto_bool(self) { +17 │ ╭ pub fn assert_sto_bool(mut self) { 18 │ │ self.my_bool = false 19 │ │ assert self.my_bool 20 │ │ } - │ ╰─────^ attributes hash: 18235041182630809162 + │ ╰─────^ attributes hash: 6172828757363943507 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 353..357, + }, ), ctx_decl: None, params: [], @@ -208,15 +215,18 @@ note: note: ┌─ assert.fe:22:5 │ -22 │ ╭ pub fn assert_sto_string_msg(self) { +22 │ ╭ pub fn assert_sto_string_msg(mut self) { 23 │ │ self.my_string = "hello" 24 │ │ assert false, self.my_string.to_mem() 25 │ │ } - │ ╰─────^ attributes hash: 18235041182630809162 + │ ╰─────^ attributes hash: 14412201928266294920 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 462..466, + }, ), ctx_decl: None, params: [], diff --git a/crates/analyzer/tests/snapshots/analysis__associated_fns.snap b/crates/analyzer/tests/snapshots/analysis__associated_fns.snap index 6dd61318bb..8232a03a26 100644 --- a/crates/analyzer/tests/snapshots/analysis__associated_fns.snap +++ b/crates/analyzer/tests/snapshots/analysis__associated_fns.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn square(x: u256) -> u256 { 3 │ │ return x * x 4 │ │ } - │ ╰─────^ attributes hash: 6622018637299644818 + │ ╰─────^ attributes hash: 5693685615577339895 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -62,13 +63,14 @@ note: 10 │ ╭ pub fn new(x: u256) -> MyStruct { 11 │ │ return MyStruct(x) 12 │ │ } - │ ╰─────^ attributes hash: 2145703897684373991 + │ ╰─────^ attributes hash: 9726859283430527185 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -111,19 +113,23 @@ note: note: ┌─ associated_fns.fe:18:5 │ -18 │ ╭ pub fn bar(self, val: u256) -> u256 { +18 │ ╭ pub fn bar(mut 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 + │ ╰─────^ attributes hash: 434215784894194389 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 248..252, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "val", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__aug_assign.snap b/crates/analyzer/tests/snapshots/analysis__aug_assign.snap index 6ddbca517d..aa04da9f49 100644 --- a/crates/analyzer/tests/snapshots/analysis__aug_assign.snap +++ b/crates/analyzer/tests/snapshots/analysis__aug_assign.snap @@ -12,17 +12,18 @@ note: note: ┌─ aug_assign.fe:4:5 │ -4 │ ╭ pub fn add(a: u256, b: u256) -> u256 { +4 │ ╭ pub fn add(mut a: u256, b: u256) -> u256 { 5 │ │ a += b 6 │ │ return a 7 │ │ } - │ ╰─────^ attributes hash: 14373109651426912995 + │ ╰─────^ attributes hash: 8922743872866964061 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: true, label: None, name: "a", typ: Ok( @@ -34,6 +35,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -67,17 +69,18 @@ note: note: ┌─ aug_assign.fe:9:5 │ - 9 │ ╭ pub fn sub(a: u256, b: u256) -> u256 { + 9 │ ╭ pub fn sub(mut a: u256, b: u256) -> u256 { 10 │ │ a -= b 11 │ │ return a 12 │ │ } - │ ╰─────^ attributes hash: 14373109651426912995 + │ ╰─────^ attributes hash: 8922743872866964061 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: true, label: None, name: "a", typ: Ok( @@ -89,6 +92,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -122,17 +126,18 @@ note: note: ┌─ aug_assign.fe:14:5 │ -14 │ ╭ pub fn mul(a: u256, b: u256) -> u256 { +14 │ ╭ pub fn mul(mut a: u256, b: u256) -> u256 { 15 │ │ a *= b 16 │ │ return a 17 │ │ } - │ ╰─────^ attributes hash: 14373109651426912995 + │ ╰─────^ attributes hash: 8922743872866964061 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: true, label: None, name: "a", typ: Ok( @@ -144,6 +149,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -177,17 +183,18 @@ note: note: ┌─ aug_assign.fe:19:5 │ -19 │ ╭ pub fn div(a: u256, b: u256) -> u256 { +19 │ ╭ pub fn div(mut a: u256, b: u256) -> u256 { 20 │ │ a /= b 21 │ │ return a 22 │ │ } - │ ╰─────^ attributes hash: 14373109651426912995 + │ ╰─────^ attributes hash: 8922743872866964061 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: true, label: None, name: "a", typ: Ok( @@ -199,6 +206,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -232,17 +240,18 @@ note: note: ┌─ aug_assign.fe:24:5 │ -24 │ ╭ pub fn mod(a: u256, b: u256) -> u256 { +24 │ ╭ pub fn mod(mut a: u256, b: u256) -> u256 { 25 │ │ a %= b 26 │ │ return a 27 │ │ } - │ ╰─────^ attributes hash: 14373109651426912995 + │ ╰─────^ attributes hash: 8922743872866964061 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: true, label: None, name: "a", typ: Ok( @@ -254,6 +263,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -287,17 +297,18 @@ note: note: ┌─ aug_assign.fe:29:5 │ -29 │ ╭ pub fn pow(a: u256, b: u256) -> u256 { +29 │ ╭ pub fn pow(mut a: u256, b: u256) -> u256 { 30 │ │ a **= b 31 │ │ return a 32 │ │ } - │ ╰─────^ attributes hash: 14373109651426912995 + │ ╰─────^ attributes hash: 8922743872866964061 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: true, label: None, name: "a", typ: Ok( @@ -309,6 +320,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -342,17 +354,18 @@ note: note: ┌─ aug_assign.fe:34:5 │ -34 │ ╭ pub fn lshift(a: u8, b: u8) -> u8 { +34 │ ╭ pub fn lshift(mut a: u8, b: u8) -> u8 { 35 │ │ a <<= b 36 │ │ return a 37 │ │ } - │ ╰─────^ attributes hash: 3365128954177167387 + │ ╰─────^ attributes hash: 10280954931728497193 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: true, label: None, name: "a", typ: Ok( @@ -364,6 +377,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -397,17 +411,18 @@ note: note: ┌─ aug_assign.fe:39:5 │ -39 │ ╭ pub fn rshift(a: u8, b: u8) -> u8 { +39 │ ╭ pub fn rshift(mut a: u8, b: u8) -> u8 { 40 │ │ a >>= b 41 │ │ return a 42 │ │ } - │ ╰─────^ attributes hash: 3365128954177167387 + │ ╰─────^ attributes hash: 10280954931728497193 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: true, label: None, name: "a", typ: Ok( @@ -419,6 +434,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -452,17 +468,18 @@ note: note: ┌─ aug_assign.fe:44:5 │ -44 │ ╭ pub fn bit_or(a: u8, b: u8) -> u8 { +44 │ ╭ pub fn bit_or(mut a: u8, b: u8) -> u8 { 45 │ │ a |= b 46 │ │ return a 47 │ │ } - │ ╰─────^ attributes hash: 3365128954177167387 + │ ╰─────^ attributes hash: 10280954931728497193 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: true, label: None, name: "a", typ: Ok( @@ -474,6 +491,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -507,17 +525,18 @@ note: note: ┌─ aug_assign.fe:49:5 │ -49 │ ╭ pub fn bit_xor(a: u8, b: u8) -> u8 { +49 │ ╭ pub fn bit_xor(mut a: u8, b: u8) -> u8 { 50 │ │ a ^= b 51 │ │ return a 52 │ │ } - │ ╰─────^ attributes hash: 3365128954177167387 + │ ╰─────^ attributes hash: 10280954931728497193 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: true, label: None, name: "a", typ: Ok( @@ -529,6 +548,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -562,17 +582,18 @@ note: note: ┌─ aug_assign.fe:54:5 │ -54 │ ╭ pub fn bit_and(a: u8, b: u8) -> u8 { +54 │ ╭ pub fn bit_and(mut a: u8, b: u8) -> u8 { 55 │ │ a &= b 56 │ │ return a 57 │ │ } - │ ╰─────^ attributes hash: 3365128954177167387 + │ ╰─────^ attributes hash: 10280954931728497193 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: true, label: None, name: "a", typ: Ok( @@ -584,6 +605,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -617,20 +639,24 @@ note: note: ┌─ aug_assign.fe:59:5 │ -59 │ ╭ pub fn add_from_sto(self, a: u256, b: u256) -> u256 { +59 │ ╭ pub fn add_from_sto(mut 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 + │ ╰─────^ attributes hash: 8892968766579608687 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 997..1001, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "a", typ: Ok( @@ -642,6 +668,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -698,18 +725,19 @@ note: ┌─ aug_assign.fe:65:5 │ 65 │ ╭ pub fn add_from_mem(a: u256, b: u256) -> u256 { -66 │ │ let my_array: Array +66 │ │ let mut my_array: Array 67 │ │ my_array[7] = a 68 │ │ my_array[7] += b 69 │ │ return my_array[7] 70 │ │ } - │ ╰─────^ attributes hash: 14373109651426912995 + │ ╰─────^ attributes hash: 11503746384184385380 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "a", typ: Ok( @@ -721,6 +749,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -742,10 +771,10 @@ note: } note: - ┌─ aug_assign.fe:66:13 + ┌─ aug_assign.fe:66:17 │ -66 │ let my_array: Array - │ ^^^^^^^^ Array +66 │ let mut my_array: Array + │ ^^^^^^^^ Array note: ┌─ aug_assign.fe:67:9 diff --git a/crates/analyzer/tests/snapshots/analysis__balances.snap b/crates/analyzer/tests/snapshots/analysis__balances.snap index 80543a6138..977ceb97da 100644 --- a/crates/analyzer/tests/snapshots/analysis__balances.snap +++ b/crates/analyzer/tests/snapshots/analysis__balances.snap @@ -9,17 +9,21 @@ note: 5 │ ╭ pub fn my_balance(self, ctx: Context) -> u256 { 6 │ │ return ctx.self_balance() 7 │ │ } - │ ╰─────^ attributes hash: 3247318976601732237 + │ ╰─────^ attributes hash: 10001391050321116560 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 100..104, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -59,17 +63,21 @@ note: 9 │ ╭ pub fn other_balance(self, ctx: Context, someone: address) -> u256 { 10 │ │ return ctx.balance_of(someone) 11 │ │ } - │ ╰─────^ attributes hash: 7590750053308816492 + │ ╰─────^ attributes hash: 16932746229417359405 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 196..200, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -82,6 +90,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "someone", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__base_tuple.snap b/crates/analyzer/tests/snapshots/analysis__base_tuple.snap index d81acf2de8..656d31adb8 100644 --- a/crates/analyzer/tests/snapshots/analysis__base_tuple.snap +++ b/crates/analyzer/tests/snapshots/analysis__base_tuple.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(my_num: u256, my_bool: bool) -> (u256, bool) { 3 │ │ return (my_num, my_bool) 4 │ │ } - │ ╰─────^ attributes hash: 10319049298189511667 + │ ╰─────^ attributes hash: 6927751260067114807 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_num", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "my_bool", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__basic_ingot.snap b/crates/analyzer/tests/snapshots/analysis__basic_ingot.snap index dcf603af5d..114fafc352 100644 --- a/crates/analyzer/tests/snapshots/analysis__basic_ingot.snap +++ b/crates/analyzer/tests/snapshots/analysis__basic_ingot.snap @@ -250,7 +250,7 @@ note: 37 │ │ let bing_contract: BingContract = BingContract.create(ctx, 0) 38 │ │ return bing_contract.add(40, 50) 39 │ │ } - │ ╰─────^ attributes hash: 10526263819290319263 + │ ╰─────^ attributes hash: 5670239331635616289 │ = FunctionSignature { self_decl: None, @@ -259,6 +259,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -385,13 +386,14 @@ note: 12 │ ╭ pub fn add(_ x: u256, _ y: u256) -> u256 { 13 │ │ return x + y 14 │ │ } - │ ╰─────^ attributes hash: 4448606202021980030 + │ ╰─────^ attributes hash: 15612950807422836908 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -405,6 +407,7 @@ note: ), }, FunctionParam { + is_mut: false, label: Some( "_", ), @@ -485,11 +488,14 @@ note: 6 │ ╭ pub fn rums(self) -> u256 { 7 │ │ return 1 8 │ │ } - │ ╰─────^ attributes hash: 11773348765973600208 + │ ╰─────^ attributes hash: 13982485923064363433 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 86..90, + }, ), ctx_decl: None, params: [], 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 6315e99df2..14a2b15f6b 100644 --- a/crates/analyzer/tests/snapshots/analysis__call_statement_with_args.snap +++ b/crates/analyzer/tests/snapshots/analysis__call_statement_with_args.snap @@ -12,18 +12,22 @@ note: note: ┌─ call_statement_with_args.fe:4:5 │ -4 │ ╭ fn assign(self, _ val: u256) { +4 │ ╭ fn assign(mut self, _ val: u256) { 5 │ │ self.baz[0] = val 6 │ │ } - │ ╰─────^ attributes hash: 15254234582808678866 + │ ╰─────^ attributes hash: 7343693722356781615 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 59..63, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -69,15 +73,18 @@ note: note: ┌─ call_statement_with_args.fe:8:5 │ - 8 │ ╭ pub fn bar(self) -> u256 { + 8 │ ╭ pub fn bar(mut self) -> u256 { 9 │ │ self.assign(100) 10 │ │ return self.baz[0] 11 │ │ } - │ ╰─────^ attributes hash: 11773348765973600208 + │ ╰─────^ attributes hash: 2372547157715064603 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 132..136, + }, ), ctx_decl: None, params: [], 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 5735079ec7..4b80e8062f 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,19 +12,23 @@ note: note: ┌─ call_statement_with_args_2.fe:4:5 │ -4 │ ╭ fn assign(self, _ val: u256) -> u256 { +4 │ ╭ fn assign(mut self, _ val: u256) -> u256 { 5 │ │ self.baz[0] = val 6 │ │ return val 7 │ │ } - │ ╰─────^ attributes hash: 11102768331449211201 + │ ╰─────^ attributes hash: 1927733032085047692 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 59..63, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -74,15 +78,18 @@ note: note: ┌─ call_statement_with_args_2.fe:9:5 │ - 9 │ ╭ pub fn bar(self) -> u256 { + 9 │ ╭ pub fn bar(mut self) -> u256 { 10 │ │ self.assign(100) 11 │ │ return self.baz[0] 12 │ │ } - │ ╰─────^ attributes hash: 11773348765973600208 + │ ╰─────^ attributes hash: 742472364664266195 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 159..163, + }, ), ctx_decl: None, params: [], 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 ac178ec864..9478be6bcd 100644 --- a/crates/analyzer/tests/snapshots/analysis__call_statement_without_args.snap +++ b/crates/analyzer/tests/snapshots/analysis__call_statement_without_args.snap @@ -12,14 +12,17 @@ note: note: ┌─ call_statement_without_args.fe:4:5 │ -4 │ ╭ fn assign(self) { +4 │ ╭ fn assign(mut self) { 5 │ │ self.baz[0] = 100 6 │ │ } - │ ╰─────^ attributes hash: 18235041182630809162 + │ ╰─────^ attributes hash: 13111555417914425493 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 59..63, + }, ), ctx_decl: None, params: [], @@ -55,15 +58,18 @@ note: note: ┌─ call_statement_without_args.fe:8:5 │ - 8 │ ╭ pub fn bar(self) -> u256 { + 8 │ ╭ pub fn bar(mut self) -> u256 { 9 │ │ self.assign() 10 │ │ return self.baz[0] 11 │ │ } - │ ╰─────^ attributes hash: 11773348765973600208 + │ ╰─────^ attributes hash: 18416348318428808249 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 119..123, + }, ), ctx_decl: None, params: [], diff --git a/crates/analyzer/tests/snapshots/analysis__checked_arithmetic.snap b/crates/analyzer/tests/snapshots/analysis__checked_arithmetic.snap index 6ddf7ea3ad..ce703056f1 100644 --- a/crates/analyzer/tests/snapshots/analysis__checked_arithmetic.snap +++ b/crates/analyzer/tests/snapshots/analysis__checked_arithmetic.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn add_u256(left: u256, right: u256) -> u256 { 3 │ │ return left + right 4 │ │ } - │ ╰─────^ attributes hash: 8877497213208027149 + │ ╰─────^ attributes hash: 13561636266158776239 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -67,13 +69,14 @@ note: 6 │ ╭ pub fn add_u128(left: u128, right: u128) -> u128 { 7 │ │ return left + right 8 │ │ } - │ ╰─────^ attributes hash: 11187416061572591496 + │ ╰─────^ attributes hash: 1088222815573489033 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -85,6 +88,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -125,13 +129,14 @@ note: 10 │ ╭ pub fn add_u64(left: u64, right: u64) -> u64 { 11 │ │ return left + right 12 │ │ } - │ ╰─────^ attributes hash: 9316585824156398552 + │ ╰─────^ attributes hash: 6141666480694685068 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -143,6 +148,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -183,13 +189,14 @@ note: 14 │ ╭ pub fn add_u32(left: u32, right: u32) -> u32 { 15 │ │ return left + right 16 │ │ } - │ ╰─────^ attributes hash: 6948562809403003686 + │ ╰─────^ attributes hash: 723357691122549179 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -201,6 +208,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -241,13 +249,14 @@ note: 18 │ ╭ pub fn add_u16(left: u16, right: u16) -> u16 { 19 │ │ return left + right 20 │ │ } - │ ╰─────^ attributes hash: 4214429573900255413 + │ ╰─────^ attributes hash: 7763210927439240954 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -259,6 +268,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -299,13 +309,14 @@ note: 22 │ ╭ pub fn add_u8(left: u8, right: u8) -> u8 { 23 │ │ return left + right 24 │ │ } - │ ╰─────^ attributes hash: 3749617961046563034 + │ ╰─────^ attributes hash: 3232226110909033605 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -317,6 +328,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -357,13 +369,14 @@ note: 26 │ ╭ pub fn add_i256(left: i256, right: i256) -> i256 { 27 │ │ return left + right 28 │ │ } - │ ╰─────^ attributes hash: 17908204859155721295 + │ ╰─────^ attributes hash: 11030759398418474841 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -375,6 +388,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -415,13 +429,14 @@ note: 30 │ ╭ pub fn add_i128(left: i128, right: i128) -> i128 { 31 │ │ return left + right 32 │ │ } - │ ╰─────^ attributes hash: 1332431709112937827 + │ ╰─────^ attributes hash: 16292489631154262345 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -433,6 +448,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -473,13 +489,14 @@ note: 34 │ ╭ pub fn add_i64(left: i64, right: i64) -> i64 { 35 │ │ return left + right 36 │ │ } - │ ╰─────^ attributes hash: 3549113083347694903 + │ ╰─────^ attributes hash: 13650336494692511285 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -491,6 +508,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -531,13 +549,14 @@ note: 38 │ ╭ pub fn add_i32(left: i32, right: i32) -> i32 { 39 │ │ return left + right 40 │ │ } - │ ╰─────^ attributes hash: 15117649447142800500 + │ ╰─────^ attributes hash: 657069125483322509 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -549,6 +568,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -589,13 +609,14 @@ note: 42 │ ╭ pub fn add_i16(left: i16, right: i16) -> i16 { 43 │ │ return left + right 44 │ │ } - │ ╰─────^ attributes hash: 16520261699954225452 + │ ╰─────^ attributes hash: 9139017035189860035 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -607,6 +628,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -647,13 +669,14 @@ note: 46 │ ╭ pub fn add_i8(left: i8, right: i8) -> i8 { 47 │ │ return left + right 48 │ │ } - │ ╰─────^ attributes hash: 2984879578165475690 + │ ╰─────^ attributes hash: 17056309325931010525 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -665,6 +688,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -705,13 +729,14 @@ note: 50 │ ╭ pub fn sub_u256(left: u256, right: u256) -> u256 { 51 │ │ return left - right 52 │ │ } - │ ╰─────^ attributes hash: 8877497213208027149 + │ ╰─────^ attributes hash: 13561636266158776239 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -723,6 +748,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -763,13 +789,14 @@ note: 54 │ ╭ pub fn sub_u128(left: u128, right: u128) -> u128 { 55 │ │ return left - right 56 │ │ } - │ ╰─────^ attributes hash: 11187416061572591496 + │ ╰─────^ attributes hash: 1088222815573489033 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -781,6 +808,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -821,13 +849,14 @@ note: 58 │ ╭ pub fn sub_u64(left: u64, right: u64) -> u64 { 59 │ │ return left - right 60 │ │ } - │ ╰─────^ attributes hash: 9316585824156398552 + │ ╰─────^ attributes hash: 6141666480694685068 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -839,6 +868,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -879,13 +909,14 @@ note: 62 │ ╭ pub fn sub_u32(left: u32, right: u32) -> u32 { 63 │ │ return left - right 64 │ │ } - │ ╰─────^ attributes hash: 6948562809403003686 + │ ╰─────^ attributes hash: 723357691122549179 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -897,6 +928,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -937,13 +969,14 @@ note: 66 │ ╭ pub fn sub_u16(left: u16, right: u16) -> u16 { 67 │ │ return left - right 68 │ │ } - │ ╰─────^ attributes hash: 4214429573900255413 + │ ╰─────^ attributes hash: 7763210927439240954 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -955,6 +988,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -995,13 +1029,14 @@ note: 70 │ ╭ pub fn sub_u8(left: u8, right: u8) -> u8 { 71 │ │ return left - right 72 │ │ } - │ ╰─────^ attributes hash: 3749617961046563034 + │ ╰─────^ attributes hash: 3232226110909033605 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1013,6 +1048,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1053,13 +1089,14 @@ note: 74 │ ╭ pub fn sub_i256(left: i256, right: i256) -> i256 { 75 │ │ return left - right 76 │ │ } - │ ╰─────^ attributes hash: 17908204859155721295 + │ ╰─────^ attributes hash: 11030759398418474841 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1071,6 +1108,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1111,13 +1149,14 @@ note: 78 │ ╭ pub fn sub_i128(left: i128, right: i128) -> i128 { 79 │ │ return left - right 80 │ │ } - │ ╰─────^ attributes hash: 1332431709112937827 + │ ╰─────^ attributes hash: 16292489631154262345 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1129,6 +1168,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1169,13 +1209,14 @@ note: 82 │ ╭ pub fn sub_i64(left: i64, right: i64) -> i64 { 83 │ │ return left - right 84 │ │ } - │ ╰─────^ attributes hash: 3549113083347694903 + │ ╰─────^ attributes hash: 13650336494692511285 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1187,6 +1228,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1227,13 +1269,14 @@ note: 86 │ ╭ pub fn sub_i32(left: i32, right: i32) -> i32 { 87 │ │ return left - right 88 │ │ } - │ ╰─────^ attributes hash: 15117649447142800500 + │ ╰─────^ attributes hash: 657069125483322509 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1245,6 +1288,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1285,13 +1329,14 @@ note: 90 │ ╭ pub fn sub_i16(left: i16, right: i16) -> i16 { 91 │ │ return left - right 92 │ │ } - │ ╰─────^ attributes hash: 16520261699954225452 + │ ╰─────^ attributes hash: 9139017035189860035 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1303,6 +1348,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1343,13 +1389,14 @@ note: 94 │ ╭ pub fn sub_i8(left: i8, right: i8) -> i8 { 95 │ │ return left - right 96 │ │ } - │ ╰─────^ attributes hash: 2984879578165475690 + │ ╰─────^ attributes hash: 17056309325931010525 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1361,6 +1408,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1401,13 +1449,14 @@ note: 98 │ ╭ pub fn div_u256(left: u256, right: u256) -> u256 { 99 │ │ return left / right 100 │ │ } - │ ╰─────^ attributes hash: 8877497213208027149 + │ ╰─────^ attributes hash: 13561636266158776239 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1419,6 +1468,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1459,13 +1509,14 @@ note: 102 │ ╭ pub fn div_u128(left: u128, right: u128) -> u128 { 103 │ │ return left / right 104 │ │ } - │ ╰─────^ attributes hash: 11187416061572591496 + │ ╰─────^ attributes hash: 1088222815573489033 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1477,6 +1528,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1517,13 +1569,14 @@ note: 106 │ ╭ pub fn div_u64(left: u64, right: u64) -> u64 { 107 │ │ return left / right 108 │ │ } - │ ╰─────^ attributes hash: 9316585824156398552 + │ ╰─────^ attributes hash: 6141666480694685068 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1535,6 +1588,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1575,13 +1629,14 @@ note: 110 │ ╭ pub fn div_u32(left: u32, right: u32) -> u32 { 111 │ │ return left / right 112 │ │ } - │ ╰─────^ attributes hash: 6948562809403003686 + │ ╰─────^ attributes hash: 723357691122549179 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1593,6 +1648,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1633,13 +1689,14 @@ note: 114 │ ╭ pub fn div_u16(left: u16, right: u16) -> u16 { 115 │ │ return left / right 116 │ │ } - │ ╰─────^ attributes hash: 4214429573900255413 + │ ╰─────^ attributes hash: 7763210927439240954 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1651,6 +1708,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1691,13 +1749,14 @@ note: 118 │ ╭ pub fn div_u8(left: u8, right: u8) -> u8 { 119 │ │ return left / right 120 │ │ } - │ ╰─────^ attributes hash: 3749617961046563034 + │ ╰─────^ attributes hash: 3232226110909033605 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1709,6 +1768,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1749,13 +1809,14 @@ note: 122 │ ╭ pub fn div_i256(left: i256, right: i256) -> i256 { 123 │ │ return left / right 124 │ │ } - │ ╰─────^ attributes hash: 17908204859155721295 + │ ╰─────^ attributes hash: 11030759398418474841 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1767,6 +1828,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1807,13 +1869,14 @@ note: 126 │ ╭ pub fn div_i128(left: i128, right: i128) -> i128 { 127 │ │ return left / right 128 │ │ } - │ ╰─────^ attributes hash: 1332431709112937827 + │ ╰─────^ attributes hash: 16292489631154262345 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1825,6 +1888,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1865,13 +1929,14 @@ note: 130 │ ╭ pub fn div_i64(left: i64, right: i64) -> i64 { 131 │ │ return left / right 132 │ │ } - │ ╰─────^ attributes hash: 3549113083347694903 + │ ╰─────^ attributes hash: 13650336494692511285 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1883,6 +1948,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1923,13 +1989,14 @@ note: 134 │ ╭ pub fn div_i32(left: i32, right: i32) -> i32 { 135 │ │ return left / right 136 │ │ } - │ ╰─────^ attributes hash: 15117649447142800500 + │ ╰─────^ attributes hash: 657069125483322509 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1941,6 +2008,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -1981,13 +2049,14 @@ note: 138 │ ╭ pub fn div_i16(left: i16, right: i16) -> i16 { 139 │ │ return left / right 140 │ │ } - │ ╰─────^ attributes hash: 16520261699954225452 + │ ╰─────^ attributes hash: 9139017035189860035 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -1999,6 +2068,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2039,13 +2109,14 @@ note: 142 │ ╭ pub fn div_i8(left: i8, right: i8) -> i8 { 143 │ │ return left / right 144 │ │ } - │ ╰─────^ attributes hash: 2984879578165475690 + │ ╰─────^ attributes hash: 17056309325931010525 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2057,6 +2128,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2097,13 +2169,14 @@ note: 146 │ ╭ pub fn mul_u256(left: u256, right: u256) -> u256 { 147 │ │ return left * right 148 │ │ } - │ ╰─────^ attributes hash: 8877497213208027149 + │ ╰─────^ attributes hash: 13561636266158776239 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2115,6 +2188,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2155,13 +2229,14 @@ note: 150 │ ╭ pub fn mul_u128(left: u128, right: u128) -> u128 { 151 │ │ return left * right 152 │ │ } - │ ╰─────^ attributes hash: 11187416061572591496 + │ ╰─────^ attributes hash: 1088222815573489033 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2173,6 +2248,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2213,13 +2289,14 @@ note: 154 │ ╭ pub fn mul_u64(left: u64, right: u64) -> u64 { 155 │ │ return left * right 156 │ │ } - │ ╰─────^ attributes hash: 9316585824156398552 + │ ╰─────^ attributes hash: 6141666480694685068 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2231,6 +2308,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2271,13 +2349,14 @@ note: 158 │ ╭ pub fn mul_u32(left: u32, right: u32) -> u32 { 159 │ │ return left * right 160 │ │ } - │ ╰─────^ attributes hash: 6948562809403003686 + │ ╰─────^ attributes hash: 723357691122549179 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2289,6 +2368,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2329,13 +2409,14 @@ note: 162 │ ╭ pub fn mul_u16(left: u16, right: u16) -> u16 { 163 │ │ return left * right 164 │ │ } - │ ╰─────^ attributes hash: 4214429573900255413 + │ ╰─────^ attributes hash: 7763210927439240954 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2347,6 +2428,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2387,13 +2469,14 @@ note: 166 │ ╭ pub fn mul_u8(left: u8, right: u8) -> u8 { 167 │ │ return left * right 168 │ │ } - │ ╰─────^ attributes hash: 3749617961046563034 + │ ╰─────^ attributes hash: 3232226110909033605 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2405,6 +2488,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2445,13 +2529,14 @@ note: 170 │ ╭ pub fn mul_i256(left: i256, right: i256) -> i256 { 171 │ │ return left * right 172 │ │ } - │ ╰─────^ attributes hash: 17908204859155721295 + │ ╰─────^ attributes hash: 11030759398418474841 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2463,6 +2548,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2503,13 +2589,14 @@ note: 174 │ ╭ pub fn mul_i128(left: i128, right: i128) -> i128 { 175 │ │ return left * right 176 │ │ } - │ ╰─────^ attributes hash: 1332431709112937827 + │ ╰─────^ attributes hash: 16292489631154262345 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2521,6 +2608,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2561,13 +2649,14 @@ note: 178 │ ╭ pub fn mul_i64(left: i64, right: i64) -> i64 { 179 │ │ return left * right 180 │ │ } - │ ╰─────^ attributes hash: 3549113083347694903 + │ ╰─────^ attributes hash: 13650336494692511285 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2579,6 +2668,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2619,13 +2709,14 @@ note: 182 │ ╭ pub fn mul_i32(left: i32, right: i32) -> i32 { 183 │ │ return left * right 184 │ │ } - │ ╰─────^ attributes hash: 15117649447142800500 + │ ╰─────^ attributes hash: 657069125483322509 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2637,6 +2728,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2677,13 +2769,14 @@ note: 186 │ ╭ pub fn mul_i16(left: i16, right: i16) -> i16 { 187 │ │ return left * right 188 │ │ } - │ ╰─────^ attributes hash: 16520261699954225452 + │ ╰─────^ attributes hash: 9139017035189860035 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2695,6 +2788,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2735,13 +2829,14 @@ note: 190 │ ╭ pub fn mul_i8(left: i8, right: i8) -> i8 { 191 │ │ return left * right 192 │ │ } - │ ╰─────^ attributes hash: 2984879578165475690 + │ ╰─────^ attributes hash: 17056309325931010525 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2753,6 +2848,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2793,13 +2889,14 @@ note: 194 │ ╭ pub fn mod_u256(left: u256, right: u256) -> u256 { 195 │ │ return left % right 196 │ │ } - │ ╰─────^ attributes hash: 8877497213208027149 + │ ╰─────^ attributes hash: 13561636266158776239 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2811,6 +2908,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2851,13 +2949,14 @@ note: 198 │ ╭ pub fn mod_u128(left: u128, right: u128) -> u128 { 199 │ │ return left % right 200 │ │ } - │ ╰─────^ attributes hash: 11187416061572591496 + │ ╰─────^ attributes hash: 1088222815573489033 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2869,6 +2968,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2909,13 +3009,14 @@ note: 202 │ ╭ pub fn mod_u64(left: u64, right: u64) -> u64 { 203 │ │ return left % right 204 │ │ } - │ ╰─────^ attributes hash: 9316585824156398552 + │ ╰─────^ attributes hash: 6141666480694685068 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2927,6 +3028,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -2967,13 +3069,14 @@ note: 206 │ ╭ pub fn mod_u32(left: u32, right: u32) -> u32 { 207 │ │ return left % right 208 │ │ } - │ ╰─────^ attributes hash: 6948562809403003686 + │ ╰─────^ attributes hash: 723357691122549179 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -2985,6 +3088,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3025,13 +3129,14 @@ note: 210 │ ╭ pub fn mod_u16(left: u16, right: u16) -> u16 { 211 │ │ return left % right 212 │ │ } - │ ╰─────^ attributes hash: 4214429573900255413 + │ ╰─────^ attributes hash: 7763210927439240954 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3043,6 +3148,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3083,13 +3189,14 @@ note: 214 │ ╭ pub fn mod_u8(left: u8, right: u8) -> u8 { 215 │ │ return left % right 216 │ │ } - │ ╰─────^ attributes hash: 3749617961046563034 + │ ╰─────^ attributes hash: 3232226110909033605 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3101,6 +3208,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3141,13 +3249,14 @@ note: 218 │ ╭ pub fn mod_i256(left: i256, right: i256) -> i256 { 219 │ │ return left % right 220 │ │ } - │ ╰─────^ attributes hash: 17908204859155721295 + │ ╰─────^ attributes hash: 11030759398418474841 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3159,6 +3268,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3199,13 +3309,14 @@ note: 222 │ ╭ pub fn mod_i128(left: i128, right: i128) -> i128 { 223 │ │ return left % right 224 │ │ } - │ ╰─────^ attributes hash: 1332431709112937827 + │ ╰─────^ attributes hash: 16292489631154262345 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3217,6 +3328,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3257,13 +3369,14 @@ note: 226 │ ╭ pub fn mod_i64(left: i64, right: i64) -> i64 { 227 │ │ return left % right 228 │ │ } - │ ╰─────^ attributes hash: 3549113083347694903 + │ ╰─────^ attributes hash: 13650336494692511285 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3275,6 +3388,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3315,13 +3429,14 @@ note: 230 │ ╭ pub fn mod_i32(left: i32, right: i32) -> i32 { 231 │ │ return left % right 232 │ │ } - │ ╰─────^ attributes hash: 15117649447142800500 + │ ╰─────^ attributes hash: 657069125483322509 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3333,6 +3448,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3373,13 +3489,14 @@ note: 234 │ ╭ pub fn mod_i16(left: i16, right: i16) -> i16 { 235 │ │ return left % right 236 │ │ } - │ ╰─────^ attributes hash: 16520261699954225452 + │ ╰─────^ attributes hash: 9139017035189860035 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3391,6 +3508,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3431,13 +3549,14 @@ note: 238 │ ╭ pub fn mod_i8(left: i8, right: i8) -> i8 { 239 │ │ return left % right 240 │ │ } - │ ╰─────^ attributes hash: 2984879578165475690 + │ ╰─────^ attributes hash: 17056309325931010525 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3449,6 +3568,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3489,13 +3609,14 @@ note: 242 │ ╭ pub fn pow_u256(left: u256, right: u256) -> u256 { 243 │ │ return left ** right 244 │ │ } - │ ╰─────^ attributes hash: 8877497213208027149 + │ ╰─────^ attributes hash: 13561636266158776239 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3507,6 +3628,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3547,13 +3669,14 @@ note: 246 │ ╭ pub fn pow_u128(left: u128, right: u128) -> u128 { 247 │ │ return left ** right 248 │ │ } - │ ╰─────^ attributes hash: 11187416061572591496 + │ ╰─────^ attributes hash: 1088222815573489033 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3565,6 +3688,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3605,13 +3729,14 @@ note: 250 │ ╭ pub fn pow_u64(left: u64, right: u64) -> u64 { 251 │ │ return left ** right 252 │ │ } - │ ╰─────^ attributes hash: 9316585824156398552 + │ ╰─────^ attributes hash: 6141666480694685068 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3623,6 +3748,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3663,13 +3789,14 @@ note: 254 │ ╭ pub fn pow_u32(left: u32, right: u32) -> u32 { 255 │ │ return left ** right 256 │ │ } - │ ╰─────^ attributes hash: 6948562809403003686 + │ ╰─────^ attributes hash: 723357691122549179 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3681,6 +3808,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3721,13 +3849,14 @@ note: 258 │ ╭ pub fn pow_u16(left: u16, right: u16) -> u16 { 259 │ │ return left ** right 260 │ │ } - │ ╰─────^ attributes hash: 4214429573900255413 + │ ╰─────^ attributes hash: 7763210927439240954 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3739,6 +3868,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3779,13 +3909,14 @@ note: 262 │ ╭ pub fn pow_u8(left: u8, right: u8) -> u8 { 263 │ │ return left ** right 264 │ │ } - │ ╰─────^ attributes hash: 3749617961046563034 + │ ╰─────^ attributes hash: 3232226110909033605 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3797,6 +3928,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3837,13 +3969,14 @@ note: 266 │ ╭ pub fn pow_i256(left: i256, right: u256) -> i256 { 267 │ │ return left ** right 268 │ │ } - │ ╰─────^ attributes hash: 10218838230504849711 + │ ╰─────^ attributes hash: 12037862889919666495 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3855,6 +3988,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3895,13 +4029,14 @@ note: 270 │ ╭ pub fn pow_i128(left: i128, right: u128) -> i128 { 271 │ │ return left ** right 272 │ │ } - │ ╰─────^ attributes hash: 8492300797170107874 + │ ╰─────^ attributes hash: 15337219696106069050 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3913,6 +4048,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -3953,13 +4089,14 @@ note: 274 │ ╭ pub fn pow_i64(left: i64, right: u64) -> i64 { 275 │ │ return left ** right 276 │ │ } - │ ╰─────^ attributes hash: 8175269888119534907 + │ ╰─────^ attributes hash: 834834180095113269 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -3971,6 +4108,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -4011,13 +4149,14 @@ note: 278 │ ╭ pub fn pow_i32(left: i32, right: u32) -> i32 { 279 │ │ return left ** right 280 │ │ } - │ ╰─────^ attributes hash: 9388330002377862662 + │ ╰─────^ attributes hash: 6483300504560320856 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -4029,6 +4168,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -4069,13 +4209,14 @@ note: 282 │ ╭ pub fn pow_i16(left: i16, right: u16) -> i16 { 283 │ │ return left ** right 284 │ │ } - │ ╰─────^ attributes hash: 8172583117888506116 + │ ╰─────^ attributes hash: 1847870501192865933 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -4087,6 +4228,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( @@ -4127,13 +4269,14 @@ note: 286 │ ╭ pub fn pow_i8(left: i8, right: u8) -> i8 { 287 │ │ return left ** right 288 │ │ } - │ ╰─────^ attributes hash: 783967907920544100 + │ ╰─────^ attributes hash: 9882565483542278581 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "left", typ: Ok( @@ -4145,6 +4288,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "right", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__constructor.snap b/crates/analyzer/tests/snapshots/analysis__constructor.snap index e43d7fc5fb..a99eef1692 100644 --- a/crates/analyzer/tests/snapshots/analysis__constructor.snap +++ b/crates/analyzer/tests/snapshots/analysis__constructor.snap @@ -15,11 +15,14 @@ note: 8 │ ╭ pub fn read_bar(self) -> u256 { 9 │ │ return self.bar[42] 10 │ │ } - │ ╰─────^ attributes hash: 11773348765973600208 + │ ╰─────^ attributes hash: 1671297230374666981 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 157..161, + }, ), ctx_decl: None, params: [], diff --git a/crates/analyzer/tests/snapshots/analysis__create2_contract.snap b/crates/analyzer/tests/snapshots/analysis__create2_contract.snap index 4f6af3b543..8f3c3ee5ec 100644 --- a/crates/analyzer/tests/snapshots/analysis__create2_contract.snap +++ b/crates/analyzer/tests/snapshots/analysis__create2_contract.snap @@ -37,7 +37,7 @@ note: 11 │ │ let foo: Foo = Foo.create2(ctx, 0, 52) 12 │ │ return address(foo) 13 │ │ } - │ ╰─────^ attributes hash: 9364783648076633772 + │ ╰─────^ attributes hash: 724290952338722356 │ = FunctionSignature { self_decl: None, @@ -46,6 +46,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__create_contract.snap b/crates/analyzer/tests/snapshots/analysis__create_contract.snap index 993a0a5fbb..6152b91410 100644 --- a/crates/analyzer/tests/snapshots/analysis__create_contract.snap +++ b/crates/analyzer/tests/snapshots/analysis__create_contract.snap @@ -37,7 +37,7 @@ note: 11 │ │ let foo: Foo = Foo.create(ctx, 0) 12 │ │ return address(foo) 13 │ │ } - │ ╰─────^ attributes hash: 9364783648076633772 + │ ╰─────^ attributes hash: 724290952338722356 │ = FunctionSignature { self_decl: None, @@ -46,6 +46,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( 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 e06d4c7e3e..1575855541 100644 --- a/crates/analyzer/tests/snapshots/analysis__create_contract_from_init.snap +++ b/crates/analyzer/tests/snapshots/analysis__create_contract_from_init.snap @@ -42,11 +42,14 @@ note: 16 │ ╭ pub fn get_foo_addr(self) -> address { 17 │ │ return self.foo_addr 18 │ │ } - │ ╰─────^ attributes hash: 227275695522088782 + │ ╰─────^ attributes hash: 11261936337788107530 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 281..285, + }, ), ctx_decl: None, params: [], diff --git a/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap b/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap index a697430005..fc0e23c3c8 100644 --- a/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap +++ b/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap @@ -30,21 +30,25 @@ note: note: ┌─ data_copying_stress.fe:16:5 │ -16 │ ╭ pub fn set_my_vals(self, my_string: String<42>, my_other_string: String<42>, my_u256: u256, my_other_u256: u256) { +16 │ ╭ pub fn set_my_vals(mut 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 + │ ╰─────^ attributes hash: 13119163414397333007 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 309..313, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_string", typ: Ok( @@ -56,6 +60,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "my_other_string", typ: Ok( @@ -67,6 +72,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "my_u256", typ: Ok( @@ -78,6 +84,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "my_other_u256", typ: Ok( @@ -143,15 +150,18 @@ note: note: ┌─ data_copying_stress.fe:23:5 │ -23 │ ╭ pub fn set_to_my_other_vals(self) { +23 │ ╭ pub fn set_to_my_other_vals(mut self) { 24 │ │ self.my_string = self.my_other_string 25 │ │ self.my_u256 = self.my_other_u256 26 │ │ } - │ ╰─────^ attributes hash: 18235041182630809162 + │ ╰─────^ attributes hash: 13976532559470675856 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 604..608, + }, ), ctx_decl: None, params: [], @@ -201,20 +211,21 @@ note: note: ┌─ data_copying_stress.fe:28:5 │ -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 +28 │ ╭ pub fn multiple_references_shared_memory(mut my_array: Array) { +29 │ │ let mut my_2nd_array: Array = my_array +30 │ │ let mut my_3rd_array: Array = my_2nd_array 31 │ │ assert my_array[3] != 5 · │ 39 │ │ assert my_3rd_array[3] == 50 40 │ │ } - │ ╰─────^ attributes hash: 16237067187800993503 + │ ╰─────^ attributes hash: 5546257418157211225 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: true, label: None, name: "my_array", typ: Ok( @@ -237,20 +248,20 @@ note: } note: - ┌─ data_copying_stress.fe:29:13 + ┌─ data_copying_stress.fe:29:17 │ -29 │ let my_2nd_array: Array = my_array - │ ^^^^^^^^^^^^ Array -30 │ let my_3rd_array: Array = my_2nd_array - │ ^^^^^^^^^^^^ Array +29 │ let mut my_2nd_array: Array = my_array + │ ^^^^^^^^^^^^ Array +30 │ let mut my_3rd_array: Array = my_2nd_array + │ ^^^^^^^^^^^^ Array note: - ┌─ data_copying_stress.fe:29:45 + ┌─ data_copying_stress.fe:29:49 │ -29 │ let my_2nd_array: Array = my_array - │ ^^^^^^^^ Array: Memory -30 │ let my_3rd_array: Array = my_2nd_array - │ ^^^^^^^^^^^^ Array: Memory +29 │ let mut my_2nd_array: Array = my_array + │ ^^^^^^^^ Array: Memory +30 │ let mut my_3rd_array: Array = my_2nd_array + │ ^^^^^^^^^^^^ Array: Memory 31 │ assert my_array[3] != 5 │ ^^^^^^^^ ^ u256: Value │ │ @@ -405,17 +416,18 @@ note: note: ┌─ data_copying_stress.fe:42:5 │ -42 │ ╭ pub fn mutate_and_return(my_array: Array) -> Array { +42 │ ╭ pub fn mutate_and_return(mut my_array: Array) -> Array { 43 │ │ my_array[3] = 5 44 │ │ return my_array 45 │ │ } - │ ╰─────^ attributes hash: 15461468619504661037 + │ ╰─────^ attributes hash: 1975721721401490781 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: true, label: None, name: "my_array", typ: Ok( @@ -466,13 +478,14 @@ note: 47 │ ╭ pub fn clone_and_return(my_array: Array) -> Array { 48 │ │ return my_array.clone() 49 │ │ } - │ ╰─────^ attributes hash: 15461468619504661037 + │ ╰─────^ attributes hash: 10787877182059102707 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_array", typ: Ok( @@ -518,13 +531,14 @@ note: 52 │ │ my_array.clone()[3] = 5 53 │ │ return my_array 54 │ │ } - │ ╰─────^ attributes hash: 15461468619504661037 + │ ╰─────^ attributes hash: 10787877182059102707 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_array", typ: Ok( @@ -578,18 +592,21 @@ note: note: ┌─ data_copying_stress.fe:56:5 │ -56 │ ╭ pub fn assign_my_nums_and_return(self) -> Array { -57 │ │ let my_nums_mem: Array +56 │ ╭ pub fn assign_my_nums_and_return(mut self) -> Array { +57 │ │ let mut my_nums_mem: Array 58 │ │ self.my_nums[0] = 42 59 │ │ self.my_nums[1] = 26 · │ 64 │ │ return my_nums_mem 65 │ │ } - │ ╰─────^ attributes hash: 13146367689365512086 + │ ╰─────^ attributes hash: 18105779197536655976 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 1644..1648, + }, ), ctx_decl: None, params: [], @@ -606,10 +623,10 @@ note: } note: - ┌─ data_copying_stress.fe:57:13 + ┌─ data_copying_stress.fe:57:17 │ -57 │ let my_nums_mem: Array - │ ^^^^^^^^^^^ Array +57 │ let mut my_nums_mem: Array + │ ^^^^^^^^^^^ Array note: ┌─ data_copying_stress.fe:58:9 @@ -726,20 +743,24 @@ note: note: ┌─ data_copying_stress.fe:67:5 │ -67 │ ╭ pub fn emit_my_event(self, ctx: Context) { +67 │ ╭ pub fn emit_my_event(self, mut ctx: Context) { 68 │ │ emit_my_event_internal(ctx, self.my_string.to_mem(), self.my_u256) 69 │ │ } - │ ╰─────^ attributes hash: 1731341862738941170 + │ ╰─────^ attributes hash: 7116838396799053469 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 1961..1965, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -796,10 +817,10 @@ note: note: ┌─ data_copying_stress.fe:71:5 │ -71 │ ╭ fn emit_my_event_internal(ctx: Context, _ my_string: String<42>, _ my_u256: u256) { +71 │ ╭ fn emit_my_event_internal(mut ctx: Context, _ my_string: String<42>, _ my_u256: u256) { 72 │ │ emit MyEvent(ctx, my_string, my_u256) 73 │ │ } - │ ╰─────^ attributes hash: 15658342901286022244 + │ ╰─────^ attributes hash: 7009973305464434950 │ = FunctionSignature { self_decl: None, @@ -808,6 +829,7 @@ note: ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -820,6 +842,7 @@ note: ), }, FunctionParam { + is_mut: false, label: Some( "_", ), @@ -833,6 +856,7 @@ note: ), }, FunctionParam { + is_mut: false, label: Some( "_", ), @@ -899,18 +923,22 @@ note: note: ┌─ data_copying_stress.fe:75:5 │ -75 │ ╭ pub fn set_my_addrs(self, my_addrs: Array) { +75 │ ╭ pub fn set_my_addrs(mut self, my_addrs: Array) { 76 │ │ self.my_addrs = my_addrs 77 │ │ } - │ ╰─────^ attributes hash: 1347763946351267085 + │ ╰─────^ attributes hash: 16854291332565717892 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 2242..2246, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_addrs", typ: Ok( @@ -950,11 +978,14 @@ note: 79 │ ╭ pub fn get_my_second_addr(self) -> address { 80 │ │ return self.my_addrs[1] 81 │ │ } - │ ╰─────^ attributes hash: 227275695522088782 + │ ╰─────^ attributes hash: 5054122372842589159 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 2349..2353, + }, ), ctx_decl: None, params: [], diff --git a/crates/analyzer/tests/snapshots/analysis__erc20_token.snap b/crates/analyzer/tests/snapshots/analysis__erc20_token.snap index e0f2aa6e45..8b3a861a05 100644 --- a/crates/analyzer/tests/snapshots/analysis__erc20_token.snap +++ b/crates/analyzer/tests/snapshots/analysis__erc20_token.snap @@ -45,11 +45,14 @@ note: 30 │ ╭ pub fn name(self) -> String<100> { 31 │ │ return self._name.to_mem() 32 │ │ } - │ ╰─────^ attributes hash: 2936475649167061923 + │ ╰─────^ attributes hash: 17500122020264694613 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 714..718, + }, ), ctx_decl: None, params: [], @@ -86,11 +89,14 @@ note: 34 │ ╭ pub fn symbol(self) -> String<100> { 35 │ │ return self._symbol.to_mem() 36 │ │ } - │ ╰─────^ attributes hash: 2936475649167061923 + │ ╰─────^ attributes hash: 17062809633595197186 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 797..801, + }, ), ctx_decl: None, params: [], @@ -127,11 +133,14 @@ note: 38 │ ╭ pub fn decimals(self) -> u8 { 39 │ │ return self._decimals 40 │ │ } - │ ╰─────^ attributes hash: 11864308689780915279 + │ ╰─────^ attributes hash: 8864080977058785482 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 884..888, + }, ), ctx_decl: None, params: [], @@ -162,11 +171,14 @@ note: 42 │ ╭ pub fn totalSupply(self) -> u256 { 43 │ │ return self._total_supply 44 │ │ } - │ ╰─────^ attributes hash: 11773348765973600208 + │ ╰─────^ attributes hash: 3680341463490813372 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 958..962, + }, ), ctx_decl: None, params: [], @@ -197,15 +209,19 @@ note: 46 │ ╭ pub fn balanceOf(self, _ account: address) -> u256 { 47 │ │ return self._balances[account] 48 │ │ } - │ ╰─────^ attributes hash: 5993653573135321647 + │ ╰─────^ attributes hash: 2521245700396309432 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 1036..1040, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -249,21 +265,25 @@ note: note: ┌─ erc20_token.fe:50:5 │ -50 │ ╭ pub fn transfer(self, ctx: Context, recipient: address, value: u256) -> bool { +50 │ ╭ pub fn transfer(mut self, mut ctx: Context, recipient: address, value: u256) -> bool { 51 │ │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) 52 │ │ return true 53 │ │ } - │ ╰─────^ attributes hash: 9700541873563816287 + │ ╰─────^ attributes hash: 4130482563254383978 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 1142..1146, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -276,6 +296,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "recipient", typ: Ok( @@ -285,6 +306,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( @@ -335,15 +357,19 @@ note: 55 │ ╭ pub fn allowance(self, owner: address, spender: address) -> u256 { 56 │ │ return self._allowances[owner][spender] 57 │ │ } - │ ╰─────^ attributes hash: 3316599995530573429 + │ ╰─────^ attributes hash: 16719273380469184282 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 1329..1333, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "owner", typ: Ok( @@ -353,6 +379,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "spender", typ: Ok( @@ -402,21 +429,25 @@ note: note: ┌─ erc20_token.fe:59:5 │ -59 │ ╭ pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool { +59 │ ╭ pub fn approve(mut self, mut ctx: Context, spender: address, value: u256) -> bool { 60 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) 61 │ │ return true 62 │ │ } - │ ╰─────^ attributes hash: 8309406699454253603 + │ ╰─────^ attributes hash: 13165959594328713588 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 1457..1461, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -429,6 +460,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "spender", typ: Ok( @@ -438,6 +470,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( @@ -485,23 +518,27 @@ note: note: ┌─ erc20_token.fe:64:5 │ -64 │ ╭ pub fn transferFrom(self, ctx: Context, sender: address, recipient: address, value: u256) -> bool { +64 │ ╭ pub fn transferFrom(mut self, mut 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 + │ ╰─────^ attributes hash: 12957386633699042234 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 1645..1649, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -514,6 +551,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "sender", typ: Ok( @@ -523,6 +561,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "recipient", typ: Ok( @@ -532,6 +571,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( @@ -666,21 +706,25 @@ note: note: ┌─ erc20_token.fe:71:5 │ -71 │ ╭ pub fn increaseAllowance(self, ctx: Context, spender: address, addedValue: u256) -> bool { +71 │ ╭ pub fn increaseAllowance(mut self, mut 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 + │ ╰─────^ attributes hash: 4136668192462742125 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 2038..2042, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -693,6 +737,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "spender", typ: Ok( @@ -702,6 +747,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "addedValue", typ: Ok( @@ -785,21 +831,25 @@ note: note: ┌─ erc20_token.fe:76:5 │ -76 │ ╭ pub fn decreaseAllowance(self, ctx: Context, spender: address, subtractedValue: u256) -> bool { +76 │ ╭ pub fn decreaseAllowance(mut self, mut 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 + │ ╰─────^ attributes hash: 12521889084514602239 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 2294..2298, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -812,6 +862,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "spender", typ: Ok( @@ -821,6 +872,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "subtractedValue", typ: Ok( @@ -904,24 +956,28 @@ note: note: ┌─ erc20_token.fe:81:5 │ -81 │ ╭ fn _transfer(self, ctx: Context, sender: address, recipient: address, value: u256) { +81 │ ╭ fn _transfer(mut self, mut 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 + │ ╰─────^ attributes hash: 3540440218259749739 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 2548..2552, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -934,6 +990,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "sender", typ: Ok( @@ -943,6 +1000,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "recipient", typ: Ok( @@ -952,6 +1010,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( @@ -1147,24 +1206,28 @@ note: note: ┌─ erc20_token.fe:90:5 │ -90 │ ╭ fn _mint(self, ctx: Context, account: address, value: u256) { +90 │ ╭ fn _mint(mut self, mut 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 + │ ╰─────^ attributes hash: 11341648139676614111 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 2987..2991, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -1177,6 +1240,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "account", typ: Ok( @@ -1186,6 +1250,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( @@ -1362,24 +1427,28 @@ note: note: ┌─ erc20_token.fe:98:5 │ - 98 │ ╭ fn _burn(self, ctx: Context, account: address, value: u256) { + 98 │ ╭ fn _burn(mut self, mut 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 + │ ╰─────^ attributes hash: 15264309683163609993 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 3361..3365, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -1392,6 +1461,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "account", typ: Ok( @@ -1401,6 +1471,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( @@ -1578,23 +1649,27 @@ note: note: ┌─ erc20_token.fe:106:5 │ -106 │ ╭ fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { +106 │ ╭ fn _approve(mut self, mut 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 + │ ╰─────^ attributes hash: 4292231801540365031 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 3738..3742, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -1607,6 +1682,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "owner", typ: Ok( @@ -1616,6 +1692,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "spender", typ: Ok( @@ -1625,6 +1702,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( @@ -1755,18 +1833,22 @@ note: note: ┌─ erc20_token.fe:113:5 │ -113 │ ╭ fn _setup_decimals(self, _ decimals_: u8) { +113 │ ╭ fn _setup_decimals(mut self, _ decimals_: u8) { 114 │ │ self._decimals = decimals_ 115 │ │ } - │ ╰─────^ attributes hash: 2241116105643912660 + │ ╰─────^ attributes hash: 8007357574172001595 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 4016..4020, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -1805,13 +1887,14 @@ note: ┌─ erc20_token.fe:117:5 │ 117 │ fn _before_token_transfer(from: address, to: address, _ value: u256) {} - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 10552855728897650120 + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attributes hash: 3567400584182650750 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "from", typ: Ok( @@ -1821,6 +1904,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "to", typ: Ok( @@ -1830,6 +1914,7 @@ note: ), }, FunctionParam { + is_mut: false, label: Some( "_", ), diff --git a/crates/analyzer/tests/snapshots/analysis__events.snap b/crates/analyzer/tests/snapshots/analysis__events.snap index 6dad34fe82..4f07656d5b 100644 --- a/crates/analyzer/tests/snapshots/analysis__events.snap +++ b/crates/analyzer/tests/snapshots/analysis__events.snap @@ -40,10 +40,10 @@ note: note: ┌─ events.fe:25:5 │ -25 │ ╭ pub fn emit_nums(ctx: Context) { +25 │ ╭ pub fn emit_nums(mut ctx: Context) { 26 │ │ emit Nums(ctx, num1: 26, num2: 42) 27 │ │ } - │ ╰─────^ attributes hash: 5519676733853656531 + │ ╰─────^ attributes hash: 3107376239596606736 │ = FunctionSignature { self_decl: None, @@ -52,6 +52,7 @@ note: ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -117,10 +118,10 @@ note: note: ┌─ events.fe:29:5 │ -29 │ ╭ pub fn emit_bases(ctx: Context, addr: address) { +29 │ ╭ pub fn emit_bases(mut ctx: Context, addr: address) { 30 │ │ emit Bases(ctx, num: 26, addr) 31 │ │ } - │ ╰─────^ attributes hash: 15383426943610850221 + │ ╰─────^ attributes hash: 10645192025445674186 │ = FunctionSignature { self_decl: None, @@ -129,6 +130,7 @@ note: ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -141,6 +143,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "addr", typ: Ok( @@ -201,10 +204,10 @@ note: note: ┌─ events.fe:33:5 │ -33 │ ╭ pub fn emit_mix(ctx: Context, addr: address, my_bytes: Array) { +33 │ ╭ pub fn emit_mix(mut ctx: Context, addr: address, my_bytes: Array) { 34 │ │ emit Mix(ctx, num1: 26, addr, num2: 42, my_bytes) 35 │ │ } - │ ╰─────^ attributes hash: 9652612436637375041 + │ ╰─────^ attributes hash: 14298327822992287135 │ = FunctionSignature { self_decl: None, @@ -213,6 +216,7 @@ note: ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -225,6 +229,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "addr", typ: Ok( @@ -234,6 +239,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "my_bytes", typ: Ok( @@ -326,13 +332,13 @@ note: note: ┌─ events.fe:37:5 │ -37 │ ╭ pub fn emit_addresses(ctx: Context, addr1: address, addr2: address) { -38 │ │ let addrs: Array +37 │ ╭ pub fn emit_addresses(mut ctx: Context, addr1: address, addr2: address) { +38 │ │ let mut addrs: Array 39 │ │ addrs[0] = addr1 40 │ │ addrs[1] = addr2 41 │ │ emit Addresses(ctx, addrs) 42 │ │ } - │ ╰─────^ attributes hash: 18438233211486921531 + │ ╰─────^ attributes hash: 12718344820069656177 │ = FunctionSignature { self_decl: None, @@ -341,6 +347,7 @@ note: ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -353,6 +360,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "addr1", typ: Ok( @@ -362,6 +370,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "addr2", typ: Ok( @@ -379,10 +388,10 @@ note: } note: - ┌─ events.fe:38:13 + ┌─ events.fe:38:17 │ -38 │ let addrs: Array - │ ^^^^^ Array +38 │ let mut addrs: Array + │ ^^^^^ Array note: ┌─ events.fe:39:9 diff --git a/crates/analyzer/tests/snapshots/analysis__external_contract.snap b/crates/analyzer/tests/snapshots/analysis__external_contract.snap index 885106fdd3..6b35343ae1 100644 --- a/crates/analyzer/tests/snapshots/analysis__external_contract.snap +++ b/crates/analyzer/tests/snapshots/analysis__external_contract.snap @@ -16,10 +16,10 @@ note: note: ┌─ external_contract.fe:10:5 │ -10 │ ╭ pub fn emit_event(ctx: Context, my_num: u256, my_addrs: Array, my_string: String<11>) { +10 │ ╭ pub fn emit_event(mut 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 + │ ╰─────^ attributes hash: 16228661198190992587 │ = FunctionSignature { self_decl: None, @@ -28,6 +28,7 @@ note: ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -40,6 +41,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "my_num", typ: Ok( @@ -51,6 +53,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "my_addrs", typ: Ok( @@ -63,6 +66,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "my_string", typ: Ok( @@ -141,19 +145,20 @@ note: ┌─ external_contract.fe:14:5 │ 14 │ ╭ pub fn build_array(a: u256, b: u256) -> Array { -15 │ │ let my_array: Array +15 │ │ let mut 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 + │ ╰─────^ attributes hash: 10662183460702627724 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "a", typ: Ok( @@ -165,6 +170,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -189,10 +195,10 @@ note: } note: - ┌─ external_contract.fe:15:13 + ┌─ external_contract.fe:15:17 │ -15 │ let my_array: Array - │ ^^^^^^^^ Array +15 │ let mut my_array: Array + │ ^^^^^^^^ Array note: ┌─ external_contract.fe:16:9 @@ -246,11 +252,11 @@ note: note: ┌─ external_contract.fe:24:5 │ -24 │ ╭ pub fn call_emit_event(ctx: Context, foo_address: address, my_num: u256, my_addrs: Array, my_string: String<11>) { +24 │ ╭ pub fn call_emit_event(mut ctx: Context, foo_address: address, my_num: u256, my_addrs: Array, my_string: String<11>) { 25 │ │ let foo: Foo = Foo(foo_address) 26 │ │ foo.emit_event(ctx, my_num, my_addrs, my_string) 27 │ │ } - │ ╰─────^ attributes hash: 11744736773867210426 + │ ╰─────^ attributes hash: 4061500227430759613 │ = FunctionSignature { self_decl: None, @@ -259,6 +265,7 @@ note: ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -271,6 +278,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "foo_address", typ: Ok( @@ -280,6 +288,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "my_num", typ: Ok( @@ -291,6 +300,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "my_addrs", typ: Ok( @@ -303,6 +313,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "my_string", typ: Ok( @@ -359,13 +370,14 @@ note: 30 │ │ let foo: Foo = Foo(foo_address) 31 │ │ return foo.build_array(a, b) 32 │ │ } - │ ╰─────^ attributes hash: 4627171240003453976 + │ ╰─────^ attributes hash: 10337064335796372437 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "foo_address", typ: Ok( @@ -375,6 +387,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "a", typ: Ok( @@ -386,6 +399,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( 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 9591dcffbf..636085819b 100644 --- a/crates/analyzer/tests/snapshots/analysis__for_loop_with_break.snap +++ b/crates/analyzer/tests/snapshots/analysis__for_loop_with_break.snap @@ -7,7 +7,7 @@ note: ┌─ for_loop_with_break.fe:2:5 │ 2 │ ╭ pub fn bar() -> u256 { - 3 │ │ let my_array: Array + 3 │ │ let mut my_array: Array 4 │ │ my_array[0] = 5 5 │ │ my_array[1] = 10 · │ @@ -29,13 +29,13 @@ note: } note: - ┌─ for_loop_with_break.fe:3:13 + ┌─ for_loop_with_break.fe:3:17 │ -3 │ let my_array: Array - │ ^^^^^^^^ Array +3 │ let mut my_array: Array + │ ^^^^^^^^ Array · -7 │ let sum: u256 = 0 - │ ^^^ u256 +7 │ let mut sum: u256 = 0 + │ ^^^ u256 8 │ for i in my_array { │ ^ u256 @@ -78,8 +78,8 @@ note: │ ^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Memory -7 │ let sum: u256 = 0 - │ ^ u256: Value +7 │ let mut sum: u256 = 0 + │ ^ u256: Value 8 │ for i in my_array { │ ^^^^^^^^ Array: Memory 9 │ sum = sum + i 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 c33ca380d0..04f2100d7b 100644 --- a/crates/analyzer/tests/snapshots/analysis__for_loop_with_continue.snap +++ b/crates/analyzer/tests/snapshots/analysis__for_loop_with_continue.snap @@ -7,7 +7,7 @@ note: ┌─ for_loop_with_continue.fe:2:5 │ 2 │ ╭ pub fn bar() -> u256 { - 3 │ │ let my_array: Array + 3 │ │ let mut my_array: Array 4 │ │ my_array[0] = 2 5 │ │ my_array[1] = 3 · │ @@ -29,13 +29,13 @@ note: } note: - ┌─ for_loop_with_continue.fe:3:13 + ┌─ for_loop_with_continue.fe:3:17 │ - 3 │ let my_array: Array - │ ^^^^^^^^ Array + 3 │ let mut my_array: Array + │ ^^^^^^^^ Array · - 9 │ let sum: u256 = 0 - │ ^^^ u256 + 9 │ let mut sum: u256 = 0 + │ ^^^ u256 10 │ for i in my_array { │ ^ u256 @@ -102,8 +102,8 @@ note: │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory - 9 │ let sum: u256 = 0 - │ ^ u256: Value + 9 │ let mut sum: u256 = 0 + │ ^ u256: Value 10 │ for i in my_array { │ ^^^^^^^^ Array: Memory 11 │ if i % 2 == 0 { 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 db1bd5e526..0b8759c7f7 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 @@ -7,7 +7,7 @@ note: ┌─ for_loop_with_static_array.fe:2:5 │ 2 │ ╭ pub fn bar() -> u256 { - 3 │ │ let my_array: Array + 3 │ │ let mut my_array: Array 4 │ │ my_array[0] = 5 5 │ │ my_array[1] = 10 · │ @@ -29,13 +29,13 @@ note: } note: - ┌─ for_loop_with_static_array.fe:3:13 + ┌─ for_loop_with_static_array.fe:3:17 │ -3 │ let my_array: Array - │ ^^^^^^^^ Array +3 │ let mut my_array: Array + │ ^^^^^^^^ Array · -7 │ let sum: u256 = 0 - │ ^^^ u256 +7 │ let mut sum: u256 = 0 + │ ^^^ u256 8 │ for i in my_array { │ ^ u256 @@ -78,8 +78,8 @@ note: │ ^^^^^^^^^^^ ^^ u256: Value │ │ │ u256: Memory -7 │ let sum: u256 = 0 - │ ^ u256: Value +7 │ let mut sum: u256 = 0 + │ ^ u256: Value 8 │ for i in my_array { │ ^^^^^^^^ Array: Memory 9 │ sum = sum + i diff --git a/crates/analyzer/tests/snapshots/analysis__guest_book.snap b/crates/analyzer/tests/snapshots/analysis__guest_book.snap index 11bf5cb11f..efa7edf0ff 100644 --- a/crates/analyzer/tests/snapshots/analysis__guest_book.snap +++ b/crates/analyzer/tests/snapshots/analysis__guest_book.snap @@ -18,24 +18,28 @@ note: note: ┌─ guest_book.fe:14:5 │ -14 │ ╭ pub fn sign(self, ctx: Context, book_msg: String<100>) { +14 │ ╭ pub fn sign(mut self, mut 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 + │ ╰─────^ attributes hash: 14944303004151825907 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 361..365, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -48,6 +52,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "book_msg", typ: Ok( @@ -130,15 +135,19 @@ note: 24 │ │ # has to be done explicitly via `to_mem()` 25 │ │ return self.messages[addr].to_mem() 26 │ │ } - │ ╰─────^ attributes hash: 3325224293767249368 + │ ╰─────^ attributes hash: 5564385222313555802 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 622..626, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "addr", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__if_statement.snap b/crates/analyzer/tests/snapshots/analysis__if_statement.snap index 47bb9f2829..c1307d69c7 100644 --- a/crates/analyzer/tests/snapshots/analysis__if_statement.snap +++ b/crates/analyzer/tests/snapshots/analysis__if_statement.snap @@ -13,13 +13,14 @@ note: 6 │ │ return 0 7 │ │ } 8 │ │ } - │ ╰─────^ attributes hash: 10660199954095577886 + │ ╰─────^ attributes hash: 8959570820935905956 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "input", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__if_statement_2.snap b/crates/analyzer/tests/snapshots/analysis__if_statement_2.snap index 5528c27edb..3f2a10b1fa 100644 --- a/crates/analyzer/tests/snapshots/analysis__if_statement_2.snap +++ b/crates/analyzer/tests/snapshots/analysis__if_statement_2.snap @@ -13,13 +13,14 @@ note: · │ 8 │ │ return 0 9 │ │ } - │ ╰─────^ attributes hash: 12367727332255217641 + │ ╰─────^ attributes hash: 9591732929458065615 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "val", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__keccak.snap b/crates/analyzer/tests/snapshots/analysis__keccak.snap index 0710b6ac1d..5741872c5e 100644 --- a/crates/analyzer/tests/snapshots/analysis__keccak.snap +++ b/crates/analyzer/tests/snapshots/analysis__keccak.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn return_hash_from_u8(val: Array) -> u256 { 3 │ │ return keccak256(val) 4 │ │ } - │ ╰─────^ attributes hash: 6936681782057010951 + │ ╰─────^ attributes hash: 11098857156456257253 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "val", typ: Ok( @@ -57,13 +58,14 @@ note: 6 │ ╭ pub fn return_hash_from_foo(val: Array) -> u256 { 7 │ │ return keccak256(val) 8 │ │ } - │ ╰─────^ attributes hash: 10874278598381710302 + │ ╰─────^ attributes hash: 9517504692837087494 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "val", typ: Ok( @@ -105,13 +107,14 @@ note: 10 │ ╭ pub fn return_hash_from_u256(val: Array) -> u256 { 11 │ │ return keccak256(val) 12 │ │ } - │ ╰─────^ attributes hash: 1385099984461119772 + │ ╰─────^ attributes hash: 10130155590853325457 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "val", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__math.snap b/crates/analyzer/tests/snapshots/analysis__math.snap index e8bd4e9d95..e2441da992 100644 --- a/crates/analyzer/tests/snapshots/analysis__math.snap +++ b/crates/analyzer/tests/snapshots/analysis__math.snap @@ -7,19 +7,20 @@ note: ┌─ math.fe:2:5 │ 2 │ ╭ pub fn sqrt(val: u256) -> u256 { - 3 │ │ let z: u256 + 3 │ │ let mut z: u256 4 │ │ if val > 3 { 5 │ │ z = val · │ 14 │ │ return z 15 │ │ } - │ ╰─────^ attributes hash: 12367727332255217641 + │ ╰─────^ attributes hash: 9591732929458065615 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "val", typ: Ok( @@ -41,13 +42,13 @@ note: } note: - ┌─ math.fe:3:13 + ┌─ math.fe:3:17 │ -3 │ let z: u256 - │ ^ u256 - · -6 │ let x: u256 = val / 2 + 1 +3 │ let mut z: u256 │ ^ u256 + · +6 │ let mut x: u256 = val / 2 + 1 + │ ^ u256 note: ┌─ math.fe:4:12 @@ -66,24 +67,24 @@ note: │ ^ ^^^ u256: Value │ │ │ u256: Value -6 │ let x: u256 = val / 2 + 1 - │ ^^^ ^ u256: Value - │ │ - │ u256: Value +6 │ let mut x: u256 = val / 2 + 1 + │ ^^^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ math.fe:6:27 + ┌─ math.fe:6:31 │ -6 │ let x: u256 = val / 2 + 1 - │ ^^^^^^^ ^ u256: Value - │ │ - │ u256: Value +6 │ let mut x: u256 = val / 2 + 1 + │ ^^^^^^^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ math.fe:6:27 + ┌─ math.fe:6:31 │ -6 │ let x: u256 = val / 2 + 1 - │ ^^^^^^^^^^^ u256: Value +6 │ let mut x: u256 = val / 2 + 1 + │ ^^^^^^^^^^^ u256: Value 7 │ while x < z { │ ^ ^ u256: Value │ │ @@ -150,13 +151,14 @@ note: 17 │ ╭ pub fn min(x: u256, y: u256) -> u256 { 18 │ │ return x if x < y else y 19 │ │ } - │ ╰─────^ attributes hash: 6847926207878778580 + │ ╰─────^ attributes hash: 17735345042517179818 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -168,6 +170,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__module_level_events.snap b/crates/analyzer/tests/snapshots/analysis__module_level_events.snap index e18a99628b..d15eb8a253 100644 --- a/crates/analyzer/tests/snapshots/analysis__module_level_events.snap +++ b/crates/analyzer/tests/snapshots/analysis__module_level_events.snap @@ -16,10 +16,10 @@ note: note: ┌─ module_level_events.fe:10:5 │ -10 │ ╭ fn transfer(ctx: Context, to: address, value: u256) { +10 │ ╭ fn transfer(mut ctx: Context, to: address, value: u256) { 11 │ │ emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) 12 │ │ } - │ ╰─────^ attributes hash: 10847004199357482546 + │ ╰─────^ attributes hash: 4681643600085308816 │ = FunctionSignature { self_decl: None, @@ -28,6 +28,7 @@ note: ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -40,6 +41,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "to", typ: Ok( @@ -49,6 +51,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__multi_param.snap b/crates/analyzer/tests/snapshots/analysis__multi_param.snap index 286088adfd..0ff28d4af5 100644 --- a/crates/analyzer/tests/snapshots/analysis__multi_param.snap +++ b/crates/analyzer/tests/snapshots/analysis__multi_param.snap @@ -7,19 +7,20 @@ note: ┌─ multi_param.fe:2:5 │ 2 │ ╭ pub fn bar(x: u256, y: u256, z: u256) -> Array { -3 │ │ let my_array: Array +3 │ │ let mut my_array: Array 4 │ │ my_array[0] = x 5 │ │ my_array[1] = y 6 │ │ my_array[2] = z 7 │ │ return my_array 8 │ │ } - │ ╰─────^ attributes hash: 10778435134172267300 + │ ╰─────^ attributes hash: 14718470244400754233 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -31,6 +32,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( @@ -42,6 +44,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "z", typ: Ok( @@ -66,10 +69,10 @@ note: } note: - ┌─ multi_param.fe:3:13 + ┌─ multi_param.fe:3:17 │ -3 │ let my_array: Array - │ ^^^^^^^^ Array +3 │ let mut my_array: Array + │ ^^^^^^^^ Array note: ┌─ multi_param.fe:4:9 diff --git a/crates/analyzer/tests/snapshots/analysis__nested_map.snap b/crates/analyzer/tests/snapshots/analysis__nested_map.snap index 7dc9adc672..29e38c79f4 100644 --- a/crates/analyzer/tests/snapshots/analysis__nested_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__nested_map.snap @@ -17,15 +17,19 @@ note: 5 │ ╭ pub fn read_bar(self, a: address, b: address) -> u256 { 6 │ │ return self.bar[a][b] 7 │ │ } - │ ╰─────^ attributes hash: 17216960098647945084 + │ ╰─────^ attributes hash: 1724072650484837323 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 117..121, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "a", typ: Ok( @@ -35,6 +39,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -84,18 +89,22 @@ note: note: ┌─ nested_map.fe:9:5 │ - 9 │ ╭ pub fn write_bar(self, a: address, b: address, value: u256) { + 9 │ ╭ pub fn write_bar(mut self, a: address, b: address, value: u256) { 10 │ │ self.bar[a][b] = value 11 │ │ } - │ ╰─────^ attributes hash: 1717293224155577849 + │ ╰─────^ attributes hash: 3790722063629028648 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 219..223, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "a", typ: Ok( @@ -105,6 +114,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -114,6 +124,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( @@ -168,15 +179,19 @@ note: 13 │ ╭ pub fn read_baz(self, a: address, b: u256) -> bool { 14 │ │ return self.baz[a][b] 15 │ │ } - │ ╰─────^ attributes hash: 13548986453815092160 + │ ╰─────^ attributes hash: 17390224544797351577 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 322..326, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "a", typ: Ok( @@ -186,6 +201,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -235,18 +251,22 @@ note: note: ┌─ nested_map.fe:17:5 │ -17 │ ╭ pub fn write_baz(self, a: address, b: u256, value: bool) { +17 │ ╭ pub fn write_baz(mut self, a: address, b: u256, value: bool) { 18 │ │ self.baz[a][b] = value 19 │ │ } - │ ╰─────^ attributes hash: 6442389777288668179 + │ ╰─────^ attributes hash: 10332709125276705536 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 421..425, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "a", typ: Ok( @@ -256,6 +276,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "b", typ: Ok( @@ -267,6 +288,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__ownable.snap b/crates/analyzer/tests/snapshots/analysis__ownable.snap index 196108b701..1b94ce348e 100644 --- a/crates/analyzer/tests/snapshots/analysis__ownable.snap +++ b/crates/analyzer/tests/snapshots/analysis__ownable.snap @@ -23,11 +23,14 @@ note: 15 │ ╭ pub fn owner(self) -> address { 16 │ │ return self._owner 17 │ │ } - │ ╰─────^ attributes hash: 227275695522088782 + │ ╰─────^ attributes hash: 11261936337788107530 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 281..285, + }, ), ctx_decl: None, params: [], @@ -53,22 +56,26 @@ note: note: ┌─ ownable.fe:19:5 │ -19 │ ╭ pub fn renounceOwnership(self, ctx: Context) { +19 │ ╭ pub fn renounceOwnership(mut self, mut 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 + │ ╰─────^ attributes hash: 5772252786598169948 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 367..371, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -181,23 +188,27 @@ note: note: ┌─ ownable.fe:25:5 │ -25 │ ╭ pub fn transferOwnership(self, ctx: Context, newOwner: address) { +25 │ ╭ pub fn transferOwnership(mut self, mut 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 + │ ╰─────^ attributes hash: 2485595419646747986 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 607..611, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -210,6 +221,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "newOwner", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__pure_fn_standalone.snap b/crates/analyzer/tests/snapshots/analysis__pure_fn_standalone.snap index e5b56bae9d..a0612e3592 100644 --- a/crates/analyzer/tests/snapshots/analysis__pure_fn_standalone.snap +++ b/crates/analyzer/tests/snapshots/analysis__pure_fn_standalone.snap @@ -9,13 +9,14 @@ note: 1 │ ╭ fn add_bonus(_ x: u256) -> u256 { 2 │ │ return x + 10 3 │ │ } - │ ╰─^ attributes hash: 4402553917254279762 + │ ╰─^ attributes hash: 12704631085410906379 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -63,22 +64,26 @@ note: note: ┌─ pure_fn_standalone.fe:9:5 │ - 9 │ ╭ fn add_points(self, _ user: address, _ val: u256) { + 9 │ ╭ fn add_points(mut self, _ user: address, _ val: u256) { 10 │ │ if self.cool_users[user] { 11 │ │ self.points[user] += add_bonus(val) 12 │ │ } else { 13 │ │ self.points[user] += val 14 │ │ } 15 │ │ } - │ ╰─────^ attributes hash: 11016307003570025576 + │ ╰─────^ attributes hash: 2170998116934609119 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 159..163, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -90,6 +95,7 @@ note: ), }, FunctionParam { + is_mut: false, label: Some( "_", ), @@ -176,22 +182,26 @@ note: note: ┌─ pure_fn_standalone.fe:17:5 │ -17 │ ╭ pub fn bar(self, _ x: u256) -> u256 { +17 │ ╭ pub fn bar(mut self, _ x: u256) -> u256 { 18 │ │ let a: address = address(x) 19 │ │ self.add_points(a, 100) 20 │ │ self.cool_users[a] = true 21 │ │ self.add_points(a, 100) 22 │ │ return self.points[a] 23 │ │ } - │ ╰─────^ attributes hash: 15237606768598971644 + │ ╰─────^ attributes hash: 14207160563868819266 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 370..374, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), diff --git a/crates/analyzer/tests/snapshots/analysis__return_addition_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_addition_i256.snap index 8d310d4a9a..b8723e0d34 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_addition_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_addition_i256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: i256, y: i256) -> i256 { 3 │ │ return x + y 4 │ │ } - │ ╰─────^ attributes hash: 6924216180113238234 + │ ╰─────^ attributes hash: 7699535412319480105 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_addition_u128.snap b/crates/analyzer/tests/snapshots/analysis__return_addition_u128.snap index 8c9e62ff12..1a40856b5c 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_addition_u128.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_addition_u128.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u128, y: u128) -> u128 { 3 │ │ return x + y 4 │ │ } - │ ╰─────^ attributes hash: 233274078014721184 + │ ╰─────^ attributes hash: 8645705797135262415 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_addition_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_addition_u256.snap index 7d75cce26d..fd261dece7 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_addition_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_addition_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x + y 4 │ │ } - │ ╰─────^ attributes hash: 6847926207878778580 + │ ╰─────^ attributes hash: 17735345042517179818 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_array.snap b/crates/analyzer/tests/snapshots/analysis__return_array.snap index e5bb07533e..60452550e2 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_array.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_array.snap @@ -7,17 +7,18 @@ note: ┌─ return_array.fe:2:5 │ 2 │ ╭ pub fn bar(x: u256) -> Array { -3 │ │ let my_array: Array +3 │ │ let mut my_array: Array 4 │ │ my_array[3] = x 5 │ │ return my_array 6 │ │ } - │ ╰─────^ attributes hash: 5752237891839439208 + │ ╰─────^ attributes hash: 10359449677193810264 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -42,10 +43,10 @@ note: } note: - ┌─ return_array.fe:3:13 + ┌─ return_array.fe:3:17 │ -3 │ let my_array: Array - │ ^^^^^^^^ Array +3 │ let mut 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 b17725ad29..0b30708422 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bitwiseand_u128.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bitwiseand_u128.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u128, y: u128) -> u128 { 3 │ │ return x & y 4 │ │ } - │ ╰─────^ attributes hash: 233274078014721184 + │ ╰─────^ attributes hash: 8645705797135262415 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_bitwiseand_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_bitwiseand_u256.snap index d381fd8335..13ee30311c 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bitwiseand_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bitwiseand_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x & y 4 │ │ } - │ ╰─────^ attributes hash: 6847926207878778580 + │ ╰─────^ attributes hash: 17735345042517179818 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_bitwiseor_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_bitwiseor_u256.snap index e12bd3c574..f411ea7076 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bitwiseor_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bitwiseor_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x | y 4 │ │ } - │ ╰─────^ attributes hash: 6847926207878778580 + │ ╰─────^ attributes hash: 17735345042517179818 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_bitwiseshl_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_bitwiseshl_u256.snap index 48f2db15f3..e063c773e8 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bitwiseshl_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bitwiseshl_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x << y 4 │ │ } - │ ╰─────^ attributes hash: 6847926207878778580 + │ ╰─────^ attributes hash: 17735345042517179818 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_i256.snap index 0629d6d210..11a0589d3f 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_i256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: i256, y: u256) -> i256 { 3 │ │ return x >> y 4 │ │ } - │ ╰─────^ attributes hash: 12518870770702615859 + │ ╰─────^ attributes hash: 17489076620501404074 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_u256.snap index ece7a0fffa..e066760a67 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bitwiseshr_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x >> y 4 │ │ } - │ ╰─────^ attributes hash: 6847926207878778580 + │ ╰─────^ attributes hash: 17735345042517179818 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_bitwisexor_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_bitwisexor_u256.snap index c7ddf9c5d1..9708c40cb0 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bitwisexor_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bitwisexor_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x ^ y 4 │ │ } - │ ╰─────^ attributes hash: 6847926207878778580 + │ ╰─────^ attributes hash: 17735345042517179818 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_bool_inverted.snap b/crates/analyzer/tests/snapshots/analysis__return_bool_inverted.snap index 7078c985be..e401f0e43b 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bool_inverted.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bool_inverted.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(some_condition: bool) -> bool { 3 │ │ return not some_condition 4 │ │ } - │ ╰─────^ attributes hash: 9793001524182520011 + │ ╰─────^ attributes hash: 5708646468144011243 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "some_condition", typ: Ok( 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 509378f776..11a48abebc 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bool_op_and.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bool_op_and.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: bool, y: bool) -> bool { 3 │ │ return x and y 4 │ │ } - │ ╰─────^ attributes hash: 3532809531490166398 + │ ╰─────^ attributes hash: 17779774754330062278 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -25,6 +26,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( 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 4aa2835080..e524de9e70 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_bool_op_or.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_bool_op_or.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: bool, y: bool) -> bool { 3 │ │ return x or y 4 │ │ } - │ ╰─────^ attributes hash: 3532809531490166398 + │ ╰─────^ attributes hash: 17779774754330062278 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -25,6 +26,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_builtin_attributes.snap b/crates/analyzer/tests/snapshots/analysis__return_builtin_attributes.snap index c23f50a552..baaf0bbb28 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_builtin_attributes.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_builtin_attributes.snap @@ -9,7 +9,7 @@ note: 4 │ ╭ pub fn base_fee(ctx: Context) -> u256 { 5 │ │ return ctx.base_fee() 6 │ │ } - │ ╰─────^ attributes hash: 10526263819290319263 + │ ╰─────^ attributes hash: 5670239331635616289 │ = FunctionSignature { self_decl: None, @@ -18,6 +18,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -57,7 +58,7 @@ note: 8 │ ╭ pub fn coinbase(ctx: Context) -> address { 9 │ │ return ctx.block_coinbase() 10 │ │ } - │ ╰─────^ attributes hash: 9364783648076633772 + │ ╰─────^ attributes hash: 724290952338722356 │ = FunctionSignature { self_decl: None, @@ -66,6 +67,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -103,7 +105,7 @@ note: 12 │ ╭ pub fn difficulty(ctx: Context) -> u256 { 13 │ │ return ctx.block_difficulty() 14 │ │ } - │ ╰─────^ attributes hash: 10526263819290319263 + │ ╰─────^ attributes hash: 5670239331635616289 │ = FunctionSignature { self_decl: None, @@ -112,6 +114,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -151,7 +154,7 @@ note: 16 │ ╭ pub fn number(ctx: Context) -> u256 { 17 │ │ return ctx.block_number() 18 │ │ } - │ ╰─────^ attributes hash: 10526263819290319263 + │ ╰─────^ attributes hash: 5670239331635616289 │ = FunctionSignature { self_decl: None, @@ -160,6 +163,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -199,7 +203,7 @@ note: 20 │ ╭ pub fn timestamp(ctx: Context) -> u256 { 21 │ │ return ctx.block_timestamp() 22 │ │ } - │ ╰─────^ attributes hash: 10526263819290319263 + │ ╰─────^ attributes hash: 5670239331635616289 │ = FunctionSignature { self_decl: None, @@ -208,6 +212,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -247,7 +252,7 @@ note: 24 │ ╭ pub fn chainid(ctx: Context) -> u256 { 25 │ │ return ctx.chain_id() 26 │ │ } - │ ╰─────^ attributes hash: 10526263819290319263 + │ ╰─────^ attributes hash: 5670239331635616289 │ = FunctionSignature { self_decl: None, @@ -256,6 +261,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -295,7 +301,7 @@ note: 28 │ ╭ pub fn sender(ctx: Context) -> address { 29 │ │ return ctx.msg_sender() 30 │ │ } - │ ╰─────^ attributes hash: 9364783648076633772 + │ ╰─────^ attributes hash: 724290952338722356 │ = FunctionSignature { self_decl: None, @@ -304,6 +310,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -341,7 +348,7 @@ note: 32 │ ╭ pub fn value(ctx: Context) -> u256 { 33 │ │ return ctx.msg_value() 34 │ │ } - │ ╰─────^ attributes hash: 10526263819290319263 + │ ╰─────^ attributes hash: 5670239331635616289 │ = FunctionSignature { self_decl: None, @@ -350,6 +357,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -389,7 +397,7 @@ note: 36 │ ╭ pub fn origin(ctx: Context) -> address { 37 │ │ return ctx.tx_origin() 38 │ │ } - │ ╰─────^ attributes hash: 9364783648076633772 + │ ╰─────^ attributes hash: 724290952338722356 │ = FunctionSignature { self_decl: None, @@ -398,6 +406,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -435,7 +444,7 @@ note: 40 │ ╭ pub fn gas_price(ctx: Context) -> u256 { 41 │ │ return ctx.tx_gas_price() 42 │ │ } - │ ╰─────^ attributes hash: 10526263819290319263 + │ ╰─────^ attributes hash: 5670239331635616289 │ = FunctionSignature { self_decl: None, @@ -444,6 +453,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_division_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_division_i256.snap index af84a0f319..a1409ffc2a 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_division_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_division_i256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: i256, y: i256) -> i256 { 3 │ │ return x / y 4 │ │ } - │ ╰─────^ attributes hash: 6924216180113238234 + │ ╰─────^ attributes hash: 7699535412319480105 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_division_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_division_u256.snap index 36546f2c8e..a73cd8a204 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_division_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_division_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x / y 4 │ │ } - │ ╰─────^ attributes hash: 6847926207878778580 + │ ╰─────^ attributes hash: 17735345042517179818 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_eq_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_eq_u256.snap index a7290cd713..6f940bd938 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_eq_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_eq_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> bool { 3 │ │ return x == y 4 │ │ } - │ ╰─────^ attributes hash: 3021624743158907825 + │ ╰─────^ attributes hash: 839395022767608879 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_gt_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_gt_i256.snap index a2f896ae14..ad137aa702 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_gt_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_gt_i256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: i256, y: i256) -> bool { 3 │ │ return x > y 4 │ │ } - │ ╰─────^ attributes hash: 7978284628773169348 + │ ╰─────^ attributes hash: 2782521185219635903 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_gt_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_gt_u256.snap index 1a8a9d3f82..c7de4469c1 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_gt_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_gt_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> bool { 3 │ │ return x > y 4 │ │ } - │ ╰─────^ attributes hash: 3021624743158907825 + │ ╰─────^ attributes hash: 839395022767608879 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_gte_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_gte_i256.snap index cd51e66fc1..73da1d1b64 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_gte_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_gte_i256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: i256, y: i256) -> bool { 3 │ │ return x >= y 4 │ │ } - │ ╰─────^ attributes hash: 7978284628773169348 + │ ╰─────^ attributes hash: 2782521185219635903 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_gte_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_gte_u256.snap index 7d1b501f57..ff339c7a1f 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_gte_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_gte_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> bool { 3 │ │ return x >= y 4 │ │ } - │ ╰─────^ attributes hash: 3021624743158907825 + │ ╰─────^ attributes hash: 839395022767608879 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_identity_u128.snap b/crates/analyzer/tests/snapshots/analysis__return_identity_u128.snap index 9c397d3bb1..6da7e2caf9 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_identity_u128.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_identity_u128.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u128) -> u128 { 3 │ │ return x 4 │ │ } - │ ╰─────^ attributes hash: 8882570074302111953 + │ ╰─────^ attributes hash: 9479837514185375791 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_identity_u16.snap b/crates/analyzer/tests/snapshots/analysis__return_identity_u16.snap index a229da26c4..0eaa6b8add 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_identity_u16.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_identity_u16.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u16) -> u16 { 3 │ │ return x 4 │ │ } - │ ╰─────^ attributes hash: 12880247899747575992 + │ ╰─────^ attributes hash: 17761542541433498452 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_identity_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_identity_u256.snap index 12f99ca768..9cf2ab0edf 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_identity_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_identity_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256) -> u256 { 3 │ │ return x 4 │ │ } - │ ╰─────^ attributes hash: 6622018637299644818 + │ ╰─────^ attributes hash: 5693685615577339895 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_identity_u32.snap b/crates/analyzer/tests/snapshots/analysis__return_identity_u32.snap index 8a31db838f..93f2757d42 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_identity_u32.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_identity_u32.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u32) -> u32 { 3 │ │ return x 4 │ │ } - │ ╰─────^ attributes hash: 3053189841811312763 + │ ╰─────^ attributes hash: 10842840051086892657 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_identity_u64.snap b/crates/analyzer/tests/snapshots/analysis__return_identity_u64.snap index 8693495b09..adb25f7b83 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_identity_u64.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_identity_u64.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u64) -> u64 { 3 │ │ return x 4 │ │ } - │ ╰─────^ attributes hash: 14360693544116809530 + │ ╰─────^ attributes hash: 4793091770409590459 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_identity_u8.snap b/crates/analyzer/tests/snapshots/analysis__return_identity_u8.snap index 3b62b044ae..03a0b7b67b 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_identity_u8.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_identity_u8.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u8) -> u8 { 3 │ │ return x 4 │ │ } - │ ╰─────^ attributes hash: 4472501580732693210 + │ ╰─────^ attributes hash: 3325622592314505201 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_lt_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_lt_i256.snap index 308e699576..858b723df4 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_lt_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_lt_i256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: i256, y: i256) -> bool { 3 │ │ return x < y 4 │ │ } - │ ╰─────^ attributes hash: 7978284628773169348 + │ ╰─────^ attributes hash: 2782521185219635903 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_lt_u128.snap b/crates/analyzer/tests/snapshots/analysis__return_lt_u128.snap index 32867706f8..83767a8d79 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_lt_u128.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_lt_u128.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u128, y: u128) -> bool { 3 │ │ return x < y 4 │ │ } - │ ╰─────^ attributes hash: 4640755342958234471 + │ ╰─────^ attributes hash: 3077342670270838484 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_lt_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_lt_u256.snap index 1d05310d69..76f00d50e5 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_lt_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_lt_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> bool { 3 │ │ return x < y 4 │ │ } - │ ╰─────^ attributes hash: 3021624743158907825 + │ ╰─────^ attributes hash: 839395022767608879 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_lte_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_lte_i256.snap index d89d6916ab..205302dc35 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_lte_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_lte_i256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: i256, y: i256) -> bool { 3 │ │ return x <= y 4 │ │ } - │ ╰─────^ attributes hash: 7978284628773169348 + │ ╰─────^ attributes hash: 2782521185219635903 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_lte_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_lte_u256.snap index 6a9b88f4a9..4728f23af7 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_lte_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_lte_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> bool { 3 │ │ return x <= y 4 │ │ } - │ ╰─────^ attributes hash: 3021624743158907825 + │ ╰─────^ attributes hash: 839395022767608879 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_mod_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_mod_i256.snap index b13326c05b..acb026aff5 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_mod_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_mod_i256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: i256, y: i256) -> i256 { 3 │ │ return x % y 4 │ │ } - │ ╰─────^ attributes hash: 6924216180113238234 + │ ╰─────^ attributes hash: 7699535412319480105 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_mod_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_mod_u256.snap index cef3907a2b..23b5eb59c3 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_mod_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_mod_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x % y 4 │ │ } - │ ╰─────^ attributes hash: 6847926207878778580 + │ ╰─────^ attributes hash: 17735345042517179818 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_msg_sig.snap b/crates/analyzer/tests/snapshots/analysis__return_msg_sig.snap index f1c7b27d82..76feba30af 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_msg_sig.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_msg_sig.snap @@ -9,7 +9,7 @@ note: 4 │ ╭ pub fn bar(ctx: Context) -> u256 { 5 │ │ return ctx.msg_sig() 6 │ │ } - │ ╰─────^ attributes hash: 10526263819290319263 + │ ╰─────^ attributes hash: 5670239331635616289 │ = FunctionSignature { self_decl: None, @@ -18,6 +18,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_multiplication_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_multiplication_i256.snap index dccf128f50..828f39e773 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_multiplication_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_multiplication_i256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: i256, y: i256) -> i256 { 3 │ │ return x * y 4 │ │ } - │ ╰─────^ attributes hash: 6924216180113238234 + │ ╰─────^ attributes hash: 7699535412319480105 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_multiplication_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_multiplication_u256.snap index e7f35f9fef..e2314f957f 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_multiplication_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_multiplication_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x * y 4 │ │ } - │ ╰─────^ attributes hash: 6847926207878778580 + │ ╰─────^ attributes hash: 17735345042517179818 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_noteq_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_noteq_u256.snap index 90cf30a944..42f1d7bd0e 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_noteq_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_noteq_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> bool { 3 │ │ return x != y 4 │ │ } - │ ╰─────^ attributes hash: 3021624743158907825 + │ ╰─────^ attributes hash: 839395022767608879 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_pow_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_pow_i256.snap index 59ce547820..1e8b8a93ce 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_pow_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_pow_i256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: i8, y: u8) -> i8 { 3 │ │ return x ** y 4 │ │ } - │ ╰─────^ attributes hash: 14588309679488297104 + │ ╰─────^ attributes hash: 9330825969551390490 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_pow_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_pow_u256.snap index 0a790cf373..4fcc127431 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_pow_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_pow_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x ** y 4 │ │ } - │ ╰─────^ attributes hash: 6847926207878778580 + │ ╰─────^ attributes hash: 17735345042517179818 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_subtraction_i256.snap b/crates/analyzer/tests/snapshots/analysis__return_subtraction_i256.snap index 9cdf0116b9..53b2e0b100 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_subtraction_i256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_subtraction_i256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: i256, y: i256) -> i256 { 3 │ │ return x - y 4 │ │ } - │ ╰─────^ attributes hash: 6924216180113238234 + │ ╰─────^ attributes hash: 7699535412319480105 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__return_subtraction_u256.snap b/crates/analyzer/tests/snapshots/analysis__return_subtraction_u256.snap index 1562abed2b..a7fcb4e6c0 100644 --- a/crates/analyzer/tests/snapshots/analysis__return_subtraction_u256.snap +++ b/crates/analyzer/tests/snapshots/analysis__return_subtraction_u256.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(x: u256, y: u256) -> u256 { 3 │ │ return x - y 4 │ │ } - │ ╰─────^ attributes hash: 6847926207878778580 + │ ╰─────^ attributes hash: 17735345042517179818 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -27,6 +28,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( 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 606e6bcbe3..469245dc16 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 @@ -9,11 +9,14 @@ note: 2 │ ╭ pub fn bar(self) -> u256 { 3 │ │ return foo() 4 │ │ } - │ ╰─────^ attributes hash: 11773348765973600208 + │ ╰─────^ attributes hash: 4631522600413788694 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 30..34, + }, ), ctx_decl: None, params: [], 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 b463097ea4..40dd72cbe8 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 @@ -15,13 +15,14 @@ note: 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 + │ ╰─────^ attributes hash: 9997518414697594592 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -35,6 +36,7 @@ note: ), }, FunctionParam { + is_mut: false, label: Some( "_", ), @@ -48,6 +50,7 @@ note: ), }, FunctionParam { + is_mut: false, label: Some( "_", ), @@ -61,6 +64,7 @@ note: ), }, FunctionParam { + is_mut: false, label: Some( "_", ), @@ -74,6 +78,7 @@ note: ), }, FunctionParam { + is_mut: false, label: Some( "_", ), @@ -164,15 +169,18 @@ note: note: ┌─ return_u256_from_called_fn_with_args.fe:12:5 │ -12 │ ╭ pub fn bar(self) -> u256 { +12 │ ╭ pub fn bar(mut self) -> u256 { 13 │ │ self.baz[0] = 43 14 │ │ return foo(5, 2, cem(), 25 + 25, self.baz[0]) 15 │ │ } - │ ╰─────^ attributes hash: 11773348765973600208 + │ ╰─────^ attributes hash: 17805881872798975162 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 243..247, + }, ), ctx_decl: None, params: [], diff --git a/crates/analyzer/tests/snapshots/analysis__revert.snap b/crates/analyzer/tests/snapshots/analysis__revert.snap index 5217aabc83..33e2a1211d 100644 --- a/crates/analyzer/tests/snapshots/analysis__revert.snap +++ b/crates/analyzer/tests/snapshots/analysis__revert.snap @@ -44,7 +44,7 @@ note: 15 │ ╭ pub fn revert_custom_error(ctx: Context) { 16 │ │ ctx.send_value(to: address(0), wei: 100) 17 │ │ } - │ ╰─────^ attributes hash: 5519676733853656531 + │ ╰─────^ attributes hash: 1359797249093753473 │ = FunctionSignature { self_decl: None, @@ -53,6 +53,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -130,15 +131,18 @@ note: note: ┌─ revert.fe:23:5 │ -23 │ ╭ pub fn revert_other_error_from_sto(self) { +23 │ ╭ pub fn revert_other_error_from_sto(mut self) { 24 │ │ self.my_other_error = OtherError(msg: 1, val: true) 25 │ │ revert self.my_other_error.to_mem() 26 │ │ } - │ ╰─────^ attributes hash: 18235041182630809162 + │ ╰─────^ attributes hash: 13411050122270746593 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 414..418, + }, ), ctx_decl: None, params: [], diff --git a/crates/analyzer/tests/snapshots/analysis__self_address.snap b/crates/analyzer/tests/snapshots/analysis__self_address.snap index f2ea18b791..18b9c1ec53 100644 --- a/crates/analyzer/tests/snapshots/analysis__self_address.snap +++ b/crates/analyzer/tests/snapshots/analysis__self_address.snap @@ -9,7 +9,7 @@ note: 4 │ ╭ pub fn my_address(ctx: Context) -> address { 5 │ │ return ctx.self_address() 6 │ │ } - │ ╰─────^ attributes hash: 9364783648076633772 + │ ╰─────^ attributes hash: 724290952338722356 │ = FunctionSignature { self_decl: None, @@ -18,6 +18,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__send_value.snap b/crates/analyzer/tests/snapshots/analysis__send_value.snap index cd2a48be20..95ea41990f 100644 --- a/crates/analyzer/tests/snapshots/analysis__send_value.snap +++ b/crates/analyzer/tests/snapshots/analysis__send_value.snap @@ -9,7 +9,7 @@ note: 4 │ ╭ pub fn send_them_wei(ctx: Context, to: address, wei: u256) { 5 │ │ ctx.send_value(to, wei) 6 │ │ } - │ ╰─────^ attributes hash: 14069636423119281176 + │ ╰─────^ attributes hash: 17669353741841696983 │ = FunctionSignature { self_decl: None, @@ -18,6 +18,7 @@ note: ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -30,6 +31,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "to", typ: Ok( @@ -39,6 +41,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "wei", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap b/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap index 30907fe501..cba1a6d9f4 100644 --- a/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap +++ b/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap @@ -47,24 +47,28 @@ note: note: ┌─ simple_open_auction.fe:42:5 │ -42 │ ╭ pub fn bid(self, ctx: Context) { +42 │ ╭ pub fn bid(mut self, mut ctx: Context) { 43 │ │ if ctx.block_timestamp() > self.auction_end_time { 44 │ │ revert AuctionAlreadyEnded() 45 │ │ } · │ 55 │ │ emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) 56 │ │ } - │ ╰─────^ attributes hash: 1731341862738941170 + │ ╰─────^ attributes hash: 1595133489687356319 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 833..837, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -283,24 +287,28 @@ note: note: ┌─ simple_open_auction.fe:58:5 │ -58 │ ╭ pub fn withdraw(self, ctx: Context) -> bool { +58 │ ╭ pub fn withdraw(mut self, ctx: Context) -> bool { 59 │ │ let amount: u256 = self.pending_returns[ctx.msg_sender()] 60 │ │ 61 │ │ if amount > 0 { · │ 65 │ │ return true 66 │ │ } - │ ╰─────^ attributes hash: 2616212654540170552 + │ ╰─────^ attributes hash: 11935853243259623885 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 1425..1429, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -411,24 +419,28 @@ note: note: ┌─ simple_open_auction.fe:68:5 │ -68 │ ╭ pub fn action_end(self, ctx: Context) { +68 │ ╭ pub fn action_end(mut self, mut ctx: Context) { 69 │ │ if ctx.block_timestamp() <= self.auction_end_time { 70 │ │ revert AuctionNotYetEnded() 71 │ │ } · │ 78 │ │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) 79 │ │ } - │ ╰─────^ attributes hash: 1731341862738941170 + │ ╰─────^ attributes hash: 10290761832650275773 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 1726..1730, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( 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 dd6564ec72..f4698b2db8 100644 --- a/crates/analyzer/tests/snapshots/analysis__sized_vals_in_sto.snap +++ b/crates/analyzer/tests/snapshots/analysis__sized_vals_in_sto.snap @@ -26,18 +26,22 @@ note: note: ┌─ sized_vals_in_sto.fe:14:5 │ -14 │ ╭ pub fn write_num(self, x: u256) { +14 │ ╭ pub fn write_num(mut self, x: u256) { 15 │ │ self.num = x 16 │ │ } - │ ╰─────^ attributes hash: 4582507849783874218 + │ ╰─────^ attributes hash: 15247572977843500486 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 227..231, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -76,11 +80,14 @@ note: 18 │ ╭ pub fn read_num(self) -> u256 { 19 │ │ return self.num 20 │ │ } - │ ╰─────^ attributes hash: 11773348765973600208 + │ ╰─────^ attributes hash: 4028969848440039662 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 292..296, + }, ), ctx_decl: None, params: [], @@ -108,18 +115,22 @@ note: note: ┌─ sized_vals_in_sto.fe:22:5 │ -22 │ ╭ pub fn write_nums(self, x: Array) { +22 │ ╭ pub fn write_nums(mut self, x: Array) { 23 │ │ self.nums = x 24 │ │ } - │ ╰─────^ attributes hash: 15243923981938152137 + │ ╰─────^ attributes hash: 6335063743722828114 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 365..369, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -161,11 +172,14 @@ note: 26 │ ╭ pub fn read_nums(self) -> Array { 27 │ │ return self.nums.to_mem() 28 │ │ } - │ ╰─────^ attributes hash: 7235961322057554817 + │ ╰─────^ attributes hash: 16300294072839282769 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 443..447, + }, ), ctx_decl: None, params: [], @@ -202,18 +216,22 @@ note: note: ┌─ sized_vals_in_sto.fe:30:5 │ -30 │ ╭ pub fn write_str(self, x: String<26>) { +30 │ ╭ pub fn write_str(mut self, x: String<26>) { 31 │ │ self.str = x 32 │ │ } - │ ╰─────^ attributes hash: 3874088449945578306 + │ ╰─────^ attributes hash: 14153874093445404161 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 536..540, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -252,11 +270,14 @@ note: 34 │ ╭ pub fn read_str(self) -> String<26> { 35 │ │ return self.str.to_mem() 36 │ │ } - │ ╰─────^ attributes hash: 3487383639176435631 + │ ╰─────^ attributes hash: 4927645279819337519 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 607..611, + }, ), ctx_decl: None, params: [], @@ -290,20 +311,24 @@ note: note: ┌─ sized_vals_in_sto.fe:38:5 │ -38 │ ╭ pub fn emit_event(self, ctx: Context) { +38 │ ╭ pub fn emit_event(self, mut ctx: Context) { 39 │ │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) 40 │ │ } - │ ╰─────^ attributes hash: 1731341862738941170 + │ ╰─────^ attributes hash: 3139632444988492662 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 691..695, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__strings.snap b/crates/analyzer/tests/snapshots/analysis__strings.snap index efed32f415..61cffc13a7 100644 --- a/crates/analyzer/tests/snapshots/analysis__strings.snap +++ b/crates/analyzer/tests/snapshots/analysis__strings.snap @@ -27,13 +27,14 @@ note: 18 │ ╭ pub fn bar(s1: String<100>, s2: String<100>) -> String<100> { 19 │ │ return s2 20 │ │ } - │ ╰─────^ attributes hash: 4992726103398710247 + │ ╰─────^ attributes hash: 3978581450914459437 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "s1", typ: Ok( @@ -45,6 +46,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "s2", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__struct_fns.snap b/crates/analyzer/tests/snapshots/analysis__struct_fns.snap index 955e45482c..e8f1bed876 100644 --- a/crates/analyzer/tests/snapshots/analysis__struct_fns.snap +++ b/crates/analyzer/tests/snapshots/analysis__struct_fns.snap @@ -17,13 +17,14 @@ note: 5 │ ╭ pub fn new(x: u64, y: u64) -> Point { 6 │ │ return Point(x, y) 7 │ │ } - │ ╰─────^ attributes hash: 16588628800633378656 + │ ╰─────^ attributes hash: 12912049707195925750 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -35,6 +36,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( @@ -112,11 +114,14 @@ note: 13 │ ╭ pub fn x(self) -> u64 { 14 │ │ return self.x 15 │ │ } - │ ╰─────^ attributes hash: 10117872852848404071 + │ ╰─────^ attributes hash: 2132949142240906430 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 206..210, + }, ), ctx_decl: None, params: [], @@ -144,20 +149,24 @@ note: note: ┌─ struct_fns.fe:17:5 │ -17 │ ╭ pub fn set_x(self, _ x: u64) -> u64 { +17 │ ╭ pub fn set_x(mut self, _ x: u64) -> u64 { 18 │ │ let old: u64 = self.x 19 │ │ self.x = x 20 │ │ return old 21 │ │ } - │ ╰─────^ attributes hash: 9776752757917359734 + │ ╰─────^ attributes hash: 13563361800320893228 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 271..275, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -213,17 +222,20 @@ note: note: ┌─ struct_fns.fe:23:5 │ -23 │ ╭ pub fn reflect(self) { +23 │ ╭ pub fn reflect(mut 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 + │ ╰─────^ attributes hash: 10714264657207187376 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 394..398, + }, ), ctx_decl: None, params: [], @@ -285,19 +297,23 @@ note: note: ┌─ struct_fns.fe:30:5 │ -30 │ ╭ pub fn translate(self, x: u64, y: u64) { +30 │ ╭ pub fn translate(mut self, x: u64, y: u64) { 31 │ │ self.x += x 32 │ │ self.y += y 33 │ │ } - │ ╰─────^ attributes hash: 7723021135770029200 + │ ╰─────^ attributes hash: 14860535953510671722 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 528..532, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -309,6 +325,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( @@ -359,15 +376,19 @@ note: 37 │ │ let y: u64 = self.y + other.y 38 │ │ return Point(x, y) 39 │ │ } - │ ╰─────^ attributes hash: 13368777112318344367 + │ ╰─────^ attributes hash: 17767028382730754195 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 614..618, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -463,7 +484,7 @@ note: │ 42 │ ╭ pub fn do_pointy_things() { 43 │ │ let p1: Point = Point::origin() -44 │ │ p1.translate(x: 5, y: 10) +44 │ │ p1.translate(x: 5, y: 10) # XXX require mut p1 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 @@ -486,7 +507,7 @@ note: │ 43 │ let p1: Point = Point::origin() │ ^^ Point -44 │ p1.translate(x: 5, y: 10) +44 │ p1.translate(x: 5, y: 10) # XXX require mut p1 45 │ let p2: Point = Point(x: 1, y: 2) │ ^^ Point 46 │ let p3: Point = p1.add(p2) @@ -497,7 +518,7 @@ note: │ 43 │ let p1: Point = Point::origin() │ ^^^^^^^^^^^^^^^ Point: Memory -44 │ p1.translate(x: 5, y: 10) +44 │ p1.translate(x: 5, y: 10) # XXX require mut p1 │ ^^ ^ ^^ u64: Value │ │ │ │ │ u64: Value @@ -506,7 +527,7 @@ note: note: ┌─ struct_fns.fe:44:5 │ -44 │ p1.translate(x: 5, y: 10) +44 │ p1.translate(x: 5, y: 10) # XXX require mut p1 │ ^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value 45 │ let p2: Point = Point(x: 1, y: 2) │ ^ ^ u64: Value @@ -577,13 +598,14 @@ note: · │ 58 │ │ return p.y 59 │ │ } - │ ╰─────^ attributes hash: 14881144643149919691 + │ ╰─────^ attributes hash: 5923520168119638877 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "x", typ: Ok( @@ -595,6 +617,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "y", typ: Ok( @@ -674,7 +697,7 @@ note: │ 54 │ assert p.x == x and p.y == y │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value -55 │ p.set_x(100) +55 │ p.set_x(100) # XXX require mut │ ^ ^^^ u64: Value │ │ │ Point: Memory @@ -682,7 +705,7 @@ note: note: ┌─ struct_fns.fe:55:9 │ -55 │ p.set_x(100) +55 │ p.set_x(100) # XXX require mut │ ^^^^^^^^^^^^ u64: Value 56 │ p.reflect() │ ^ Point: Memory diff --git a/crates/analyzer/tests/snapshots/analysis__structs.snap b/crates/analyzer/tests/snapshots/analysis__structs.snap index 55aeae8964..2baf83479a 100644 --- a/crates/analyzer/tests/snapshots/analysis__structs.snap +++ b/crates/analyzer/tests/snapshots/analysis__structs.snap @@ -37,13 +37,14 @@ note: 17 │ ╭ pub fn new(val: u256) -> Mixed { 18 │ │ return Mixed(foo: val, bar: false) 19 │ │ } - │ ╰─────^ attributes hash: 2524938698704972422 + │ ╰─────^ attributes hash: 18265650288744660032 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "val", typ: Ok( @@ -97,11 +98,14 @@ note: 28 │ ╭ pub fn encode(self) -> Array { 29 │ │ return self.abi_encode() 30 │ │ } - │ ╰─────^ attributes hash: 2052929893622941907 + │ ╰─────^ attributes hash: 3277581803880114358 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 424..428, + }, ), ctx_decl: None, params: [], @@ -135,11 +139,14 @@ note: 32 │ ╭ pub fn hash(self) -> u256 { 33 │ │ return keccak256(self.encode()) 34 │ │ } - │ ╰─────^ attributes hash: 11773348765973600208 + │ ╰─────^ attributes hash: 3800231203158928125 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 506..510, + }, ), ctx_decl: None, params: [], @@ -176,11 +183,14 @@ note: 36 │ ╭ pub fn price_per_sqft(self) -> u256 { 37 │ │ return self.price / self.size 38 │ │ } - │ ╰─────^ attributes hash: 11773348765973600208 + │ ╰─────^ attributes hash: 7121155759541830230 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 595..599, + }, ), ctx_decl: None, params: [], @@ -222,15 +232,18 @@ note: note: ┌─ structs.fe:40:5 │ -40 │ ╭ pub fn expand(self) { +40 │ ╭ pub fn expand(mut self) { 41 │ │ self.rooms += 1 42 │ │ self.size += 100 43 │ │ } - │ ╰─────^ attributes hash: 18235041182630809162 + │ ╰─────^ attributes hash: 6056324316352758490 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 678..682, + }, ), ctx_decl: None, params: [], @@ -276,18 +289,21 @@ note: note: ┌─ structs.fe:50:5 │ -50 │ ╭ pub fn complex_struct_in_storage(self) -> String<3> { +50 │ ╭ pub fn complex_struct_in_storage(mut 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 · │ 79 │ │ return self.my_bar.name.to_mem() 80 │ │ } - │ ╰─────^ attributes hash: 7100809906483982919 + │ ╰─────^ attributes hash: 10302942579009622678 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 837..841, + }, ), ctx_decl: None, params: [], @@ -1072,19 +1088,17 @@ note: note: ┌─ structs.fe:82:5 │ - 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)) + 82 │ ╭ pub fn complex_struct_in_memory() -> String<3> { + 83 │ │ let mut 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 · │ 111 │ │ return val.name 112 │ │ } - │ ╰─────^ attributes hash: 7100809906483982919 + │ ╰─────^ attributes hash: 12941863115788397621 │ = FunctionSignature { - self_decl: Some( - Mutable, - ), + self_decl: None, ctx_decl: None, params: [], return_type: Ok( @@ -1097,49 +1111,49 @@ note: } note: - ┌─ structs.fe:83:13 + ┌─ structs.fe:83:17 │ -83 │ let val: Bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) - │ ^^^ Bar +83 │ let mut val: Bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) + │ ^^^ Bar note: - ┌─ structs.fe:83:34 + ┌─ structs.fe:83:38 │ -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 +83 │ let mut 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:83:50 + ┌─ structs.fe:83:54 │ -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 +83 │ let mut 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:83:65 + ┌─ structs.fe:83:69 │ -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 +83 │ let mut 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:83:99 + ┌─ structs.fe:83:103 │ -83 │ let val: Bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) - │ ^^^^^^^^^ (u256, bool): Memory +83 │ let mut val: Bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) + │ ^^^^^^^^^ (u256, bool): Memory note: - ┌─ structs.fe:83:24 + ┌─ structs.fe:83:28 │ -83 │ let val: Bar = Bar(name: "foo", numbers: [1, 2], point: Point(x: 100, y: 200), something: (1, true)) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Bar: Memory +83 │ let mut 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 @@ -1697,11 +1711,14 @@ note: 115 │ │ let mixed: Mixed = Mixed::new(val: 1) 116 │ │ return mixed.foo 117 │ │ } - │ ╰─────^ attributes hash: 11773348765973600208 + │ ╰─────^ attributes hash: 1469673370516439530 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 3315..3319, + }, ), ctx_decl: None, params: [], @@ -1743,18 +1760,22 @@ note: note: ┌─ structs.fe:119:5 │ -119 │ ╭ pub fn set_house(self, data: House) { +119 │ ╭ pub fn set_house(mut self, data: House) { 120 │ │ self.my_house = data 121 │ │ } - │ ╰─────^ attributes hash: 571714015924720006 + │ ╰─────^ attributes hash: 537227353021317844 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 3434..3438, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "data", typ: Ok( @@ -1794,11 +1815,14 @@ note: 123 │ ╭ pub fn get_house(self) -> House { 124 │ │ return self.my_house.to_mem() 125 │ │ } - │ ╰─────^ attributes hash: 18226871377775469920 + │ ╰─────^ attributes hash: 1919473522518021755 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 3512..3516, + }, ), ctx_decl: None, params: [], @@ -1833,18 +1857,21 @@ note: note: ┌─ structs.fe:127:5 │ -127 │ ╭ pub fn create_house(self) { +127 │ ╭ pub fn create_house(mut 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 · │ 152 │ │ assert self.my_house.vacant 153 │ │ } - │ ╰─────^ attributes hash: 18235041182630809162 + │ ╰─────^ attributes hash: 8667441894878710947 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 3602..3606, + }, ), ctx_decl: None, params: [], @@ -2413,7 +2440,7 @@ note: ┌─ structs.fe:155:5 │ 155 │ ╭ pub fn bar() -> u256 { -156 │ │ let building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) +156 │ │ let mut building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) 157 │ │ assert building.size == 500 158 │ │ assert building.price == 300 · │ @@ -2435,33 +2462,33 @@ note: } note: - ┌─ structs.fe:156:13 + ┌─ structs.fe:156:17 │ -156 │ let building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) - │ ^^^^^^^^ House +156 │ let mut building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) + │ ^^^^^^^^ House note: - ┌─ structs.fe:156:44 + ┌─ structs.fe:156:48 │ -156 │ let building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) - │ ^^^ ^^^ ^^ u8: Value - │ │ │ - │ │ u256: Value - │ u256: Value +156 │ let mut building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) + │ ^^^ ^^^ ^^ u8: Value + │ │ │ + │ │ u256: Value + │ u256: Value note: - ┌─ structs.fe:156:67 + ┌─ structs.fe:156:71 │ -156 │ let building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) - │ ^^^^^^ ^^^^ bool: Value - │ │ - │ u8: Value +156 │ let mut building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) + │ ^^^^^^ ^^^^ bool: Value + │ │ + │ u8: Value note: - ┌─ structs.fe:156:31 + ┌─ structs.fe:156:35 │ -156 │ let building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ House: Memory +156 │ let mut building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ House: Memory 157 │ assert building.size == 500 │ ^^^^^^^^ House: Memory diff --git a/crates/analyzer/tests/snapshots/analysis__ternary_expression.snap b/crates/analyzer/tests/snapshots/analysis__ternary_expression.snap index 4b44929786..91f8839b17 100644 --- a/crates/analyzer/tests/snapshots/analysis__ternary_expression.snap +++ b/crates/analyzer/tests/snapshots/analysis__ternary_expression.snap @@ -9,13 +9,14 @@ note: 2 │ ╭ pub fn bar(input: u256) -> u256 { 3 │ │ return 1 if input > 5 else 0 4 │ │ } - │ ╰─────^ attributes hash: 10660199954095577886 + │ ╰─────^ attributes hash: 8959570820935905956 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "input", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap b/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap index 823eb85780..9a994f8804 100644 --- a/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap +++ b/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap @@ -21,13 +21,14 @@ note: 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 + │ ╰─────^ attributes hash: 360724337181506789 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_num", typ: Ok( @@ -39,6 +40,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "my_bool", typ: Ok( @@ -48,6 +50,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "my_address", typ: Ok( @@ -99,13 +102,14 @@ note: 14 │ ╭ pub fn read_my_tuple_item0(my_tuple: (u256, bool, address)) -> u256 { 15 │ │ return my_tuple.item0 16 │ │ } - │ ╰─────^ attributes hash: 1005385906871296536 + │ ╰─────^ attributes hash: 15352344024579628422 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_tuple", typ: Ok( @@ -156,13 +160,14 @@ note: 18 │ ╭ pub fn read_my_tuple_item1(my_tuple: (u256, bool, address)) -> bool { 19 │ │ return my_tuple.item1 20 │ │ } - │ ╰─────^ attributes hash: 5615774585289781220 + │ ╰─────^ attributes hash: 8583403567405507409 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_tuple", typ: Ok( @@ -211,13 +216,14 @@ note: 22 │ ╭ pub fn read_my_tuple_item2(my_tuple: (u256, bool, address)) -> address { 23 │ │ return my_tuple.item2 24 │ │ } - │ ╰─────^ attributes hash: 13024428391414866682 + │ ╰─────^ attributes hash: 12664160725472535777 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_tuple", typ: Ok( @@ -266,13 +272,14 @@ note: 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 + │ ╰─────^ attributes hash: 3066397049255145296 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_tuple", typ: Ok( @@ -360,10 +367,10 @@ note: note: ┌─ tuple_stress.fe:30:5 │ -30 │ ╭ pub fn emit_my_event(ctx: Context, my_tuple: (u256, bool, address)) { +30 │ ╭ pub fn emit_my_event(mut ctx: Context, my_tuple: (u256, bool, address)) { 31 │ │ emit MyEvent(ctx, my_tuple) 32 │ │ } - │ ╰─────^ attributes hash: 10535390144430265813 + │ ╰─────^ attributes hash: 11025609152955346579 │ = FunctionSignature { self_decl: None, @@ -372,6 +379,7 @@ note: ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -384,6 +392,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "my_tuple", typ: Ok( @@ -460,19 +469,23 @@ note: note: ┌─ tuple_stress.fe:34:5 │ -34 │ ╭ pub fn set_my_sto_tuple(self, my_u256: u256, my_i32: i32) { +34 │ ╭ pub fn set_my_sto_tuple(mut 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 + │ ╰─────^ attributes hash: 18341452813968392070 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 948..952, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_u256", typ: Ok( @@ -484,6 +497,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "my_i32", typ: Ok( @@ -591,11 +605,14 @@ note: 39 │ ╭ pub fn get_my_sto_tuple(self) -> (u256, i32) { 40 │ │ return self.my_sto_tuple.to_mem() 41 │ │ } - │ ╰─────^ attributes hash: 6833980121040096883 + │ ╰─────^ attributes hash: 15633340648095965563 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 1153..1157, + }, ), ctx_decl: None, params: [], @@ -640,22 +657,26 @@ note: note: ┌─ tuple_stress.fe:43:5 │ -43 │ ╭ pub fn build_tuple_and_emit(self, ctx: Context) { +43 │ ╭ pub fn build_tuple_and_emit(self, mut 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 + │ ╰─────^ attributes hash: 14064258130730596935 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 1257..1261, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -754,13 +775,14 @@ note: 49 │ ╭ pub fn encode_my_tuple(my_tuple: (u256, bool, address)) -> Array { 50 │ │ return my_tuple.abi_encode() 51 │ │ } - │ ╰─────^ attributes hash: 3539305055628398466 + │ ╰─────^ attributes hash: 8393962525368106551 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "my_tuple", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__two_contracts.snap b/crates/analyzer/tests/snapshots/analysis__two_contracts.snap index b0a320d34e..5445b96e4f 100644 --- a/crates/analyzer/tests/snapshots/analysis__two_contracts.snap +++ b/crates/analyzer/tests/snapshots/analysis__two_contracts.snap @@ -12,21 +12,25 @@ note: note: ┌─ two_contracts.fe:10:5 │ -10 │ ╭ pub fn foo(self, ctx: Context) -> u256 { +10 │ ╭ pub fn foo(mut self, ctx: Context) -> u256 { 11 │ │ self.other.set_foo_addr(ctx.self_address()) 12 │ │ return self.other.answer() 13 │ │ } - │ ╰─────^ attributes hash: 3247318976601732237 + │ ╰─────^ attributes hash: 17308523880210986290 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 170..174, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -94,13 +98,14 @@ note: 15 │ ╭ pub fn add(_ x: u256, _ y: u256) -> u256 { 16 │ │ return x + y 17 │ │ } - │ ╰─────^ attributes hash: 4448606202021980030 + │ ╰─────^ attributes hash: 15612950807422836908 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -114,6 +119,7 @@ note: ), }, FunctionParam { + is_mut: false, label: Some( "_", ), @@ -159,18 +165,22 @@ note: note: ┌─ two_contracts.fe:23:5 │ -23 │ ╭ pub fn set_foo_addr(self, _ addr: address) { +23 │ ╭ pub fn set_foo_addr(mut self, _ addr: address) { 24 │ │ self.other = Foo(addr) 25 │ │ } - │ ╰─────^ attributes hash: 3263176293298741376 + │ ╰─────^ attributes hash: 16843431437153664683 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 430..434, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -215,11 +225,14 @@ note: 27 │ ╭ pub fn answer(self) -> u256 { 28 │ │ return self.other.add(20, 22) 29 │ │ } - │ ╰─────^ attributes hash: 11773348765973600208 + │ ╰─────^ attributes hash: 12456261780698058596 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 511..515, + }, ), ctx_decl: None, params: [], diff --git a/crates/analyzer/tests/snapshots/analysis__type_aliases.snap b/crates/analyzer/tests/snapshots/analysis__type_aliases.snap index 2fc81178f8..e9f23e2ba6 100644 --- a/crates/analyzer/tests/snapshots/analysis__type_aliases.snap +++ b/crates/analyzer/tests/snapshots/analysis__type_aliases.snap @@ -10,71 +10,75 @@ note: │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map> note: - ┌─ type_aliases.fe:5:1 + ┌─ type_aliases.fe:4:1 │ -5 │ type Scoreboard = Map +4 │ type Scoreboard = Map │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map note: - ┌─ type_aliases.fe:7:1 + ┌─ type_aliases.fe:5:1 │ -7 │ type AuthorPosts = Map +5 │ type AuthorPosts = Map │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map note: - ┌─ type_aliases.fe:9:1 + ┌─ type_aliases.fe:6:1 │ -9 │ type Author = address +6 │ type Author = address │ ^^^^^^^^^^^^^^^^^^^^^ address note: - ┌─ type_aliases.fe:11:1 - │ -11 │ type Score = u64 - │ ^^^^^^^^^^^^^^^^ u64 + ┌─ type_aliases.fe:7:1 + │ +7 │ type Score = u64 + │ ^^^^^^^^^^^^^^^^ u64 note: - ┌─ type_aliases.fe:13:1 - │ -13 │ type PostId = u256 - │ ^^^^^^^^^^^^^^^^^^ u256 + ┌─ type_aliases.fe:8:1 + │ +8 │ type PostId = u256 + │ ^^^^^^^^^^^^^^^^^^ u256 note: - ┌─ type_aliases.fe:15:1 - │ -15 │ type PostBody = String<32> - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ String<32> + ┌─ type_aliases.fe:9:1 + │ +9 │ type PostBody = String<32> + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ String<32> note: - ┌─ type_aliases.fe:18:5 + ┌─ type_aliases.fe:12:5 │ -18 │ posts: Posts +12 │ posts: Posts │ ^^^^^^^^^^^^ Map> -19 │ authors: AuthorPosts +13 │ authors: AuthorPosts │ ^^^^^^^^^^^^^^^^^^^^ Map -20 │ scoreboard: Scoreboard +14 │ scoreboard: Scoreboard │ ^^^^^^^^^^^^^^^^^^^^^^ Map note: - ┌─ type_aliases.fe:22:5 + ┌─ type_aliases.fe:16:5 │ -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 +16 │ ╭ pub fn post(mut self, ctx: Context, body: PostBody) { +17 │ │ let id: PostId = 0 +18 │ │ self.posts[id] = body +19 │ │ self.authors[ctx.msg_sender()] +20 │ │ self.scoreboard[id] = 0 +21 │ │ } + │ ╰─────^ attributes hash: 6463244129054231356 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 331..335, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -87,6 +91,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "body", typ: Ok( @@ -106,92 +111,96 @@ note: } note: - ┌─ type_aliases.fe:23:13 + ┌─ type_aliases.fe:17:13 │ -23 │ let id: PostId = 0 +17 │ let id: PostId = 0 │ ^^ u256 note: - ┌─ type_aliases.fe:23:26 + ┌─ type_aliases.fe:17:26 │ -23 │ let id: PostId = 0 +17 │ let id: PostId = 0 │ ^ u256: Value -24 │ self.posts[id] = body +18 │ self.posts[id] = body │ ^^^^ Forum: Value note: - ┌─ type_aliases.fe:24:9 + ┌─ type_aliases.fe:18:9 │ -24 │ self.posts[id] = body +18 │ self.posts[id] = body │ ^^^^^^^^^^ ^^ u256: Value │ │ │ Map>: Storage { nonce: Some(0) } note: - ┌─ type_aliases.fe:24:9 + ┌─ type_aliases.fe:18:9 │ -24 │ self.posts[id] = body +18 │ self.posts[id] = body │ ^^^^^^^^^^^^^^ ^^^^ String<32>: Memory │ │ │ String<32>: Storage { nonce: None } -25 │ self.authors[ctx.msg_sender()] +19 │ self.authors[ctx.msg_sender()] │ ^^^^ Forum: Value note: - ┌─ type_aliases.fe:25:9 + ┌─ type_aliases.fe:19:9 │ -25 │ self.authors[ctx.msg_sender()] +19 │ self.authors[ctx.msg_sender()] │ ^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: Some(1) } note: - ┌─ type_aliases.fe:25:22 + ┌─ type_aliases.fe:19:22 │ -25 │ self.authors[ctx.msg_sender()] +19 │ self.authors[ctx.msg_sender()] │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ type_aliases.fe:25:9 + ┌─ type_aliases.fe:19:9 │ -25 │ self.authors[ctx.msg_sender()] +19 │ self.authors[ctx.msg_sender()] │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: None } -26 │ self.scoreboard[id] = 0 +20 │ self.scoreboard[id] = 0 │ ^^^^ Forum: Value note: - ┌─ type_aliases.fe:26:9 + ┌─ type_aliases.fe:20:9 │ -26 │ self.scoreboard[id] = 0 +20 │ self.scoreboard[id] = 0 │ ^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ Map: Storage { nonce: Some(2) } note: - ┌─ type_aliases.fe:26:9 + ┌─ type_aliases.fe:20:9 │ -26 │ self.scoreboard[id] = 0 +20 │ self.scoreboard[id] = 0 │ ^^^^^^^^^^^^^^^^^^^ ^ u64: Value │ │ │ u64: Storage { nonce: None } note: - ┌─ type_aliases.fe:29:5 + ┌─ type_aliases.fe:23:5 │ -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 +23 │ ╭ pub fn upvote(mut self, id: PostId) -> Score { +24 │ │ let score: Score = self.scoreboard[id] + 1 +25 │ │ self.scoreboard[id] = score +26 │ │ return score +27 │ │ } + │ ╰─────^ attributes hash: 9758032486406104337 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 526..530, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "id", typ: Ok( @@ -213,74 +222,78 @@ note: } note: - ┌─ type_aliases.fe:30:13 + ┌─ type_aliases.fe:24:13 │ -30 │ let score: Score = self.scoreboard[id] + 1 +24 │ let score: Score = self.scoreboard[id] + 1 │ ^^^^^ u64 note: - ┌─ type_aliases.fe:30:28 + ┌─ type_aliases.fe:24:28 │ -30 │ let score: Score = self.scoreboard[id] + 1 +24 │ let score: Score = self.scoreboard[id] + 1 │ ^^^^ Forum: Value note: - ┌─ type_aliases.fe:30:28 + ┌─ type_aliases.fe:24:28 │ -30 │ let score: Score = self.scoreboard[id] + 1 +24 │ let score: Score = self.scoreboard[id] + 1 │ ^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ Map: Storage { nonce: Some(2) } note: - ┌─ type_aliases.fe:30:28 + ┌─ type_aliases.fe:24:28 │ -30 │ let score: Score = self.scoreboard[id] + 1 +24 │ let score: Score = self.scoreboard[id] + 1 │ ^^^^^^^^^^^^^^^^^^^ ^ u64: Value │ │ │ u64: Storage { nonce: None } => Value note: - ┌─ type_aliases.fe:30:28 + ┌─ type_aliases.fe:24:28 │ -30 │ let score: Score = self.scoreboard[id] + 1 +24 │ let score: Score = self.scoreboard[id] + 1 │ ^^^^^^^^^^^^^^^^^^^^^^^ u64: Value -31 │ self.scoreboard[id] = score +25 │ self.scoreboard[id] = score │ ^^^^ Forum: Value note: - ┌─ type_aliases.fe:31:9 + ┌─ type_aliases.fe:25:9 │ -31 │ self.scoreboard[id] = score +25 │ self.scoreboard[id] = score │ ^^^^^^^^^^^^^^^ ^^ u256: Value │ │ │ Map: Storage { nonce: Some(2) } note: - ┌─ type_aliases.fe:31:9 + ┌─ type_aliases.fe:25:9 │ -31 │ self.scoreboard[id] = score +25 │ self.scoreboard[id] = score │ ^^^^^^^^^^^^^^^^^^^ ^^^^^ u64: Value │ │ │ u64: Storage { nonce: None } -32 │ return score +26 │ return score │ ^^^^^ u64: Value note: - ┌─ type_aliases.fe:35:5 + ┌─ type_aliases.fe:29:5 │ -35 │ ╭ pub fn get_post(self, id: PostId) -> PostBody { -36 │ │ return self.posts[id].to_mem() -37 │ │ } - │ ╰─────^ attributes hash: 6772945894090223199 +29 │ ╭ pub fn get_post(self, id: PostId) -> PostBody { +30 │ │ return self.posts[id].to_mem() +31 │ │ } + │ ╰─────^ attributes hash: 10324852255901303209 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 690..694, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "id", typ: Ok( @@ -302,29 +315,29 @@ note: } note: - ┌─ type_aliases.fe:36:16 + ┌─ type_aliases.fe:30:16 │ -36 │ return self.posts[id].to_mem() +30 │ return self.posts[id].to_mem() │ ^^^^ Forum: Value note: - ┌─ type_aliases.fe:36:16 + ┌─ type_aliases.fe:30:16 │ -36 │ return self.posts[id].to_mem() +30 │ return self.posts[id].to_mem() │ ^^^^^^^^^^ ^^ u256: Value │ │ │ Map>: Storage { nonce: Some(0) } note: - ┌─ type_aliases.fe:36:16 + ┌─ type_aliases.fe:30:16 │ -36 │ return self.posts[id].to_mem() +30 │ return self.posts[id].to_mem() │ ^^^^^^^^^^^^^^ String<32>: Storage { nonce: None } note: - ┌─ type_aliases.fe:36:16 + ┌─ type_aliases.fe:30:16 │ -36 │ return self.posts[id].to_mem() +30 │ 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 f35fe0a28b..aaa9d8df58 100644 --- a/crates/analyzer/tests/snapshots/analysis__u128_u128_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__u128_u128_map.snap @@ -15,15 +15,19 @@ note: 4 │ ╭ pub fn read_bar(self, key: u128) -> u128 { 5 │ │ return self.bar[key] 6 │ │ } - │ ╰─────^ attributes hash: 1939765458140608268 + │ ╰─────^ attributes hash: 5196838515307723367 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 61..65, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "key", typ: Ok( @@ -67,18 +71,22 @@ note: note: ┌─ u128_u128_map.fe:8:5 │ - 8 │ ╭ pub fn write_bar(self, key: u128, value: u128) { + 8 │ ╭ pub fn write_bar(mut self, key: u128, value: u128) { 9 │ │ self.bar[key] = value 10 │ │ } - │ ╰─────^ attributes hash: 9126735252114279653 + │ ╰─────^ attributes hash: 453647258723181658 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 149..153, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "key", typ: Ok( @@ -90,6 +98,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__u16_u16_map.snap b/crates/analyzer/tests/snapshots/analysis__u16_u16_map.snap index 2fabdb8920..bedbb6cdb0 100644 --- a/crates/analyzer/tests/snapshots/analysis__u16_u16_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__u16_u16_map.snap @@ -15,15 +15,19 @@ note: 4 │ ╭ pub fn read_bar(self, key: u16) -> u16 { 5 │ │ return self.bar[key] 6 │ │ } - │ ╰─────^ attributes hash: 18312053447303862075 + │ ╰─────^ attributes hash: 17695033416019141840 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 59..63, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "key", typ: Ok( @@ -67,18 +71,22 @@ note: note: ┌─ u16_u16_map.fe:8:5 │ - 8 │ ╭ pub fn write_bar(self, key: u16, value: u16) { + 8 │ ╭ pub fn write_bar(mut self, key: u16, value: u16) { 9 │ │ self.bar[key] = value 10 │ │ } - │ ╰─────^ attributes hash: 8088868709641766820 + │ ╰─────^ attributes hash: 4727872131148104636 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 145..149, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "key", typ: Ok( @@ -90,6 +98,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__u256_u256_map.snap b/crates/analyzer/tests/snapshots/analysis__u256_u256_map.snap index c7faa32d20..0aa293ec54 100644 --- a/crates/analyzer/tests/snapshots/analysis__u256_u256_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__u256_u256_map.snap @@ -15,15 +15,19 @@ note: 4 │ ╭ pub fn read_bar(self, key: u256) -> u256 { 5 │ │ return self.bar[key] 6 │ │ } - │ ╰─────^ attributes hash: 14897000516975740248 + │ ╰─────^ attributes hash: 7459864901144071237 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 61..65, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "key", typ: Ok( @@ -67,18 +71,22 @@ note: note: ┌─ u256_u256_map.fe:8:5 │ - 8 │ ╭ pub fn write_bar(self, key: u256, value: u256) { + 8 │ ╭ pub fn write_bar(mut self, key: u256, value: u256) { 9 │ │ self.bar[key] = value 10 │ │ } - │ ╰─────^ attributes hash: 17030413653610901743 + │ ╰─────^ attributes hash: 10597535678839299029 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 149..153, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "key", typ: Ok( @@ -90,6 +98,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__u32_u32_map.snap b/crates/analyzer/tests/snapshots/analysis__u32_u32_map.snap index f8973f21e7..a9b9084b29 100644 --- a/crates/analyzer/tests/snapshots/analysis__u32_u32_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__u32_u32_map.snap @@ -15,15 +15,19 @@ note: 4 │ ╭ pub fn read_bar(self, key: u32) -> u32 { 5 │ │ return self.bar[key] 6 │ │ } - │ ╰─────^ attributes hash: 17684751964541454304 + │ ╰─────^ attributes hash: 4583036915203748875 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 59..63, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "key", typ: Ok( @@ -67,18 +71,22 @@ note: note: ┌─ u32_u32_map.fe:8:5 │ - 8 │ ╭ pub fn write_bar(self, key: u32, value: u32) { + 8 │ ╭ pub fn write_bar(mut self, key: u32, value: u32) { 9 │ │ self.bar[key] = value 10 │ │ } - │ ╰─────^ attributes hash: 9068646997358780798 + │ ╰─────^ attributes hash: 15280695020486233808 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 145..149, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "key", typ: Ok( @@ -90,6 +98,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__u64_u64_map.snap b/crates/analyzer/tests/snapshots/analysis__u64_u64_map.snap index 5bebd390a5..ecbd6a4a5e 100644 --- a/crates/analyzer/tests/snapshots/analysis__u64_u64_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__u64_u64_map.snap @@ -15,15 +15,19 @@ note: 4 │ ╭ pub fn read_bar(self, key: u64) -> u64 { 5 │ │ return self.bar[key] 6 │ │ } - │ ╰─────^ attributes hash: 5490397784598880129 + │ ╰─────^ attributes hash: 5286801638065394545 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 59..63, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "key", typ: Ok( @@ -67,18 +71,22 @@ note: note: ┌─ u64_u64_map.fe:8:5 │ - 8 │ ╭ pub fn write_bar(self, key: u64, value: u64) { + 8 │ ╭ pub fn write_bar(mut self, key: u64, value: u64) { 9 │ │ self.bar[key] = value 10 │ │ } - │ ╰─────^ attributes hash: 2182326649216136625 + │ ╰─────^ attributes hash: 78563977039591761 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 145..149, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "key", typ: Ok( @@ -90,6 +98,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__u8_u8_map.snap b/crates/analyzer/tests/snapshots/analysis__u8_u8_map.snap index 9d0442f2ba..b50b11d517 100644 --- a/crates/analyzer/tests/snapshots/analysis__u8_u8_map.snap +++ b/crates/analyzer/tests/snapshots/analysis__u8_u8_map.snap @@ -15,15 +15,19 @@ note: 4 │ ╭ pub fn read_bar(self, key: u8) -> u8 { 5 │ │ return self.bar[key] 6 │ │ } - │ ╰─────^ attributes hash: 3828358868158950430 + │ ╰─────^ attributes hash: 9684298647957052783 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 57..61, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "key", typ: Ok( @@ -67,18 +71,22 @@ note: note: ┌─ u8_u8_map.fe:8:5 │ - 8 │ ╭ pub fn write_bar(self, key: u8, value: u8) { + 8 │ ╭ pub fn write_bar(mut self, key: u8, value: u8) { 9 │ │ self.bar[key] = value 10 │ │ } - │ ╰─────^ attributes hash: 1989504953336313430 + │ ╰─────^ attributes hash: 9600064637989278359 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 141..145, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "key", typ: Ok( @@ -90,6 +98,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( diff --git a/crates/analyzer/tests/snapshots/analysis__uniswap.snap b/crates/analyzer/tests/snapshots/analysis__uniswap.snap index fbaad2dc9a..e8bb2a0bc4 100644 --- a/crates/analyzer/tests/snapshots/analysis__uniswap.snap +++ b/crates/analyzer/tests/snapshots/analysis__uniswap.snap @@ -9,13 +9,14 @@ note: 4 │ ╭ pub fn balanceOf(_ account: address) -> u256 { 5 │ │ return 0 6 │ │ } - │ ╰─────^ attributes hash: 4709511530683498418 + │ ╰─────^ attributes hash: 15536516206350149884 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -48,13 +49,14 @@ note: 8 │ ╭ pub fn transfer(to: address, _ amount: u256) -> bool { 9 │ │ return false 10 │ │ } - │ ╰─────^ attributes hash: 12261720285838819896 + │ ╰─────^ attributes hash: 12085341657079846741 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: None, name: "to", typ: Ok( @@ -64,6 +66,7 @@ note: ), }, FunctionParam { + is_mut: false, label: Some( "_", ), @@ -103,8 +106,8 @@ note: 21 │ nonces: Map │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Map 22 │ -23 │ factory: address - │ ^^^^^^^^^^^^^^^^ address +23 │ factory: UniswapV2Factory + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ UniswapV2Factory 24 │ token0: ERC20 │ ^^^^^^^^^^^^^ ERC20 25 │ token1: ERC20 @@ -194,13 +197,16 @@ note: ┌─ uniswap.fe:78:5 │ 78 │ ╭ pub fn factory(self) -> address { -79 │ │ return self.factory +79 │ │ return address(self.factory) 80 │ │ } - │ ╰─────^ attributes hash: 227275695522088782 + │ ╰─────^ attributes hash: 15278132372417349493 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 1502..1506, + }, ), ctx_decl: None, params: [], @@ -212,16 +218,22 @@ note: } note: - ┌─ uniswap.fe:79:16 + ┌─ uniswap.fe:79:24 │ -79 │ return self.factory - │ ^^^^ UniswapV2Pair: Value +79 │ return address(self.factory) + │ ^^^^ UniswapV2Pair: Value + +note: + ┌─ uniswap.fe:79:24 + │ +79 │ return address(self.factory) + │ ^^^^^^^^^^^^ UniswapV2Factory: Storage { nonce: Some(4) } => Value note: ┌─ uniswap.fe:79:16 │ -79 │ return self.factory - │ ^^^^^^^^^^^^ address: Storage { nonce: Some(4) } => Value +79 │ return address(self.factory) + │ ^^^^^^^^^^^^^^^^^^^^^ address: Value note: ┌─ uniswap.fe:82:5 @@ -229,11 +241,14 @@ note: 82 │ ╭ pub fn token0(self) -> address { 83 │ │ return address(self.token0) 84 │ │ } - │ ╰─────^ attributes hash: 227275695522088782 + │ ╰─────^ attributes hash: 14564309738631945387 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 1583..1587, + }, ), ctx_decl: None, params: [], @@ -268,11 +283,14 @@ note: 86 │ ╭ pub fn token1(self) -> address { 87 │ │ return address(self.token1) 88 │ │ } - │ ╰─────^ attributes hash: 227275695522088782 + │ ╰─────^ attributes hash: 14594191188684846156 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 1663..1667, + }, ), ctx_decl: None, params: [], @@ -304,22 +322,26 @@ note: note: ┌─ uniswap.fe:90:5 │ -90 │ ╭ fn _mint(self, ctx: Context, to: address, value: u256) { +90 │ ╭ fn _mint(mut self, mut 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 + │ ╰─────^ attributes hash: 13471972465529729631 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 1742..1746, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -332,6 +354,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "to", typ: Ok( @@ -341,6 +364,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( @@ -484,22 +508,26 @@ note: note: ┌─ uniswap.fe:96:5 │ - 96 │ ╭ fn _burn(self, ctx: Context, from: address, value: u256) { + 96 │ ╭ fn _burn(mut self, mut 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 + │ ╰─────^ attributes hash: 17370357368197929956 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 1982..1986, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -512,6 +540,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "from", typ: Ok( @@ -521,6 +550,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( @@ -664,21 +694,25 @@ note: note: ┌─ uniswap.fe:102:5 │ -102 │ ╭ fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { +102 │ ╭ fn _approve(mut self, mut 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 + │ ╰─────^ attributes hash: 12629605514702101930 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 2231..2235, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -691,6 +725,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "owner", typ: Ok( @@ -700,6 +735,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "spender", typ: Ok( @@ -709,6 +745,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( @@ -807,22 +844,26 @@ note: note: ┌─ uniswap.fe:107:5 │ -107 │ ╭ fn _transfer(self, ctx: Context, from: address, to: address, value: u256) { +107 │ ╭ fn _transfer(mut self, mut 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 + │ ╰─────^ attributes hash: 4593216175197439456 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 2430..2434, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -835,6 +876,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "from", typ: Ok( @@ -844,6 +886,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "to", typ: Ok( @@ -853,6 +896,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( @@ -1005,21 +1049,25 @@ note: note: ┌─ uniswap.fe:113:5 │ -113 │ ╭ pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool { +113 │ ╭ pub fn approve(mut self, mut ctx: Context, spender: address, value: u256) -> bool { 114 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) 115 │ │ return true 116 │ │ } - │ ╰─────^ attributes hash: 8309406699454253603 + │ ╰─────^ attributes hash: 6286628319890692535 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 2683..2687, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -1032,6 +1080,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "spender", typ: Ok( @@ -1041,6 +1090,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( @@ -1088,21 +1138,25 @@ note: note: ┌─ uniswap.fe:118:5 │ -118 │ ╭ pub fn transfer(self, ctx: Context, to: address, value: u256) -> bool { +118 │ ╭ pub fn transfer(mut self, mut ctx: Context, to: address, value: u256) -> bool { 119 │ │ self._transfer(ctx, from: ctx.msg_sender(), to, value) 120 │ │ return true 121 │ │ } - │ ╰─────^ attributes hash: 14718526948940966913 + │ ╰─────^ attributes hash: 13421772796169857129 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 2867..2871, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -1115,6 +1169,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "to", typ: Ok( @@ -1124,6 +1179,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( @@ -1171,23 +1227,27 @@ note: note: ┌─ uniswap.fe:123:5 │ -123 │ ╭ pub fn transferFrom(self, ctx: Context, from: address, to: address, value: u256) -> bool { +123 │ ╭ pub fn transferFrom(mut self, mut 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 + │ ╰─────^ attributes hash: 1351974348243425310 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 3045..3049, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -1200,6 +1260,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "from", typ: Ok( @@ -1209,6 +1270,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "to", typ: Ok( @@ -1218,6 +1280,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "value", typ: Ok( @@ -1367,15 +1430,19 @@ note: 130 │ ╭ pub fn balanceOf(self, _ account: address) -> u256 { 131 │ │ return self.balances[account] 132 │ │ } - │ ╰─────^ attributes hash: 5993653573135321647 + │ ╰─────^ attributes hash: 15194449064687040684 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 3375..3379, + }, ), ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -1422,11 +1489,14 @@ note: 134 │ ╭ pub fn get_reserves(self) -> (u256, u256, u256) { 135 │ │ return (self.reserve0, self.reserve1, self.block_timestamp_last) 136 │ │ } - │ ╰─────^ attributes hash: 3743538709625240197 + │ ╰─────^ attributes hash: 3926516177822859043 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 3480..3484, + }, ), ctx_decl: None, params: [], @@ -1492,22 +1562,26 @@ note: note: ┌─ uniswap.fe:139:5 │ -139 │ ╭ pub fn initialize(self, ctx: Context, token0: ERC20, token1: ERC20) { -140 │ │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" +139 │ ╭ pub fn initialize(mut self, ctx: Context, token0: ERC20, token1: ERC20) { +140 │ │ assert ctx.msg_sender() == address(self.factory), "UniswapV2: FORBIDDEN" 141 │ │ self.token0 = token0 142 │ │ self.token1 = token1 143 │ │ } - │ ╰─────^ attributes hash: 18170027042989505865 + │ ╰─────^ attributes hash: 15974397572347181954 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 3671..3675, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -1520,6 +1594,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "token0", typ: Ok( @@ -1531,6 +1606,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "token1", typ: Ok( @@ -1552,29 +1628,35 @@ note: note: ┌─ uniswap.fe:140:16 │ -140 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" +140 │ assert ctx.msg_sender() == address(self.factory), "UniswapV2: FORBIDDEN" │ ^^^ Context: Memory note: ┌─ uniswap.fe:140:16 │ -140 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" - │ ^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value - │ │ +140 │ assert ctx.msg_sender() == address(self.factory), "UniswapV2: FORBIDDEN" + │ ^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value + │ │ │ address: Value +note: + ┌─ uniswap.fe:140:44 + │ +140 │ assert ctx.msg_sender() == address(self.factory), "UniswapV2: FORBIDDEN" + │ ^^^^^^^^^^^^ UniswapV2Factory: Storage { nonce: Some(4) } => Value + note: ┌─ uniswap.fe:140:36 │ -140 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" - │ ^^^^^^^^^^^^ address: Storage { nonce: Some(4) } => Value +140 │ assert ctx.msg_sender() == address(self.factory), "UniswapV2: FORBIDDEN" + │ ^^^^^^^^^^^^^^^^^^^^^ address: Value note: ┌─ uniswap.fe:140:16 │ -140 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ String<20>: Memory - │ │ +140 │ assert ctx.msg_sender() == address(self.factory), "UniswapV2: FORBIDDEN" + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ String<20>: Memory + │ │ │ bool: Value 141 │ self.token0 = token0 │ ^^^^ UniswapV2Pair: Value @@ -1600,24 +1682,28 @@ note: note: ┌─ uniswap.fe:146:5 │ -146 │ ╭ fn _update(self, ctx: Context, balance0: u256, balance1: u256, reserve0: u256, reserve1: u256) { +146 │ ╭ fn _update(mut self, mut 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 · │ 158 │ │ emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) 159 │ │ } - │ ╰─────^ attributes hash: 14441581101409065213 + │ ╰─────^ attributes hash: 8120571795129401038 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 3963..3967, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -1630,6 +1716,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "balance0", typ: Ok( @@ -1641,6 +1728,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "balance1", typ: Ok( @@ -1652,6 +1740,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "reserve0", typ: Ok( @@ -1663,6 +1752,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "reserve1", typ: Ok( @@ -1936,24 +2026,28 @@ note: note: ┌─ uniswap.fe:161:5 │ -161 │ ╭ fn _mint_fee(self, ctx: Context, reserve0: u256, reserve1: u256) -> bool { -162 │ │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() +161 │ ╭ fn _mint_fee(mut self, mut ctx: Context, reserve0: u256, reserve1: u256) -> bool { +162 │ │ let fee_to: address = self.factory.fee_to() 163 │ │ let fee_on: bool = fee_to != address(0) 164 │ │ let k_last: u256 = self.k_last · │ 181 │ │ return fee_on 182 │ │ } - │ ╰─────^ attributes hash: 12335666382859496931 + │ ╰─────^ attributes hash: 16362661907044867957 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 4822..4826, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -1966,6 +2060,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "reserve0", typ: Ok( @@ -1977,6 +2072,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "reserve1", typ: Ok( @@ -1998,7 +2094,7 @@ note: note: ┌─ uniswap.fe:162:13 │ -162 │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() +162 │ let fee_to: address = self.factory.fee_to() │ ^^^^^^ address 163 │ let fee_on: bool = fee_to != address(0) │ ^^^^^^ bool @@ -2018,28 +2114,22 @@ note: │ ^^^^^^^^^ u256 note: - ┌─ uniswap.fe:162:48 - │ -162 │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() - │ ^^^^ UniswapV2Pair: Value - -note: - ┌─ uniswap.fe:162:48 + ┌─ uniswap.fe:162:31 │ -162 │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() - │ ^^^^^^^^^^^^ address: Storage { nonce: Some(4) } => Value +162 │ let fee_to: address = self.factory.fee_to() + │ ^^^^ UniswapV2Pair: Value note: ┌─ uniswap.fe:162:31 │ -162 │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UniswapV2Factory: Value +162 │ let fee_to: address = self.factory.fee_to() + │ ^^^^^^^^^^^^ UniswapV2Factory: Storage { nonce: Some(4) } => Value note: ┌─ uniswap.fe:162:31 │ -162 │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ address: Value +162 │ let fee_to: address = self.factory.fee_to() + │ ^^^^^^^^^^^^^^^^^^^^^ address: Value 163 │ let fee_on: bool = fee_to != address(0) │ ^^^^^^ ^ u256: Value │ │ @@ -2212,24 +2302,28 @@ note: note: ┌─ uniswap.fe:185:5 │ -185 │ ╭ pub fn mint(self, ctx: Context, to: address) -> u256 { +185 │ ╭ pub fn mint(mut self, mut ctx: Context, to: address) -> u256 { 186 │ │ let MINIMUM_LIQUIDITY: u256 = 1000 187 │ │ let reserve0: u256 = self.reserve0 188 │ │ let reserve1: u256 = self.reserve1 · │ 209 │ │ return liquidity 210 │ │ } - │ ╰─────^ attributes hash: 11513995717553818344 + │ ╰─────^ attributes hash: 1442720676710541957 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 5834..5838, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -2242,6 +2336,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "to", typ: Ok( @@ -2281,8 +2376,8 @@ note: │ ^^^^^^ bool 194 │ let total_supply: u256 = self.total_supply # gas savings, must be defined here since totalSupply can update in _mintFee │ ^^^^^^^^^^^^ u256 -195 │ let liquidity: u256 = 0 - │ ^^^^^^^^^ u256 +195 │ let mut liquidity: u256 = 0 + │ ^^^^^^^^^ u256 note: ┌─ uniswap.fe:186:39 @@ -2401,8 +2496,8 @@ note: │ 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 -195 │ let liquidity: u256 = 0 - │ ^ u256: Value +195 │ let mut liquidity: u256 = 0 + │ ^ u256: Value 196 │ if total_supply == 0 { │ ^^^^^^^^^^^^ ^ u256: Value │ │ @@ -2621,24 +2716,28 @@ note: note: ┌─ uniswap.fe:213:5 │ -213 │ ╭ pub fn burn(self, ctx: Context, to: address) -> (u256, u256) { +213 │ ╭ pub fn burn(mut self, mut ctx: Context, to: address) -> (u256, u256) { 214 │ │ let reserve0: u256 = self.reserve0 215 │ │ let reserve1: u256 = self.reserve1 216 │ │ let token0: ERC20 = self.token0 · │ 237 │ │ return (amount0, amount1) 238 │ │ } - │ ╰─────^ attributes hash: 4652297158603848356 + │ ╰─────^ attributes hash: 13634551864155722811 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 7358..7362, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -2651,6 +2750,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "to", typ: Ok( @@ -2691,10 +2791,10 @@ note: │ ^^^^^^ ERC20 217 │ let token1: ERC20 = self.token1 │ ^^^^^^ ERC20 -218 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) - │ ^^^^^^^^ u256 -219 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) - │ ^^^^^^^^ u256 +218 │ let mut balance0: u256 = token0.balanceOf(ctx.self_address()) + │ ^^^^^^^^ u256 +219 │ let mut balance1: u256 = token1.balanceOf(ctx.self_address()) + │ ^^^^^^^^ u256 220 │ let liquidity: u256 = self.balances[ctx.self_address()] │ ^^^^^^^^^ u256 221 │ @@ -2742,38 +2842,38 @@ note: │ 217 │ let token1: ERC20 = self.token1 │ ^^^^^^^^^^^ ERC20: Storage { nonce: Some(6) } => Value -218 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) - │ ^^^^^^ ^^^ Context: Memory - │ │ - │ ERC20: Value +218 │ let mut balance0: u256 = token0.balanceOf(ctx.self_address()) + │ ^^^^^^ ^^^ Context: Memory + │ │ + │ ERC20: Value note: - ┌─ uniswap.fe:218:47 + ┌─ uniswap.fe:218:51 │ -218 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) - │ ^^^^^^^^^^^^^^^^^^ address: Value +218 │ let mut balance0: u256 = token0.balanceOf(ctx.self_address()) + │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:218:30 + ┌─ uniswap.fe:218:34 │ -218 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -219 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) - │ ^^^^^^ ^^^ Context: Memory - │ │ - │ ERC20: Value +218 │ let mut balance0: u256 = token0.balanceOf(ctx.self_address()) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +219 │ let mut balance1: u256 = token1.balanceOf(ctx.self_address()) + │ ^^^^^^ ^^^ Context: Memory + │ │ + │ ERC20: Value note: - ┌─ uniswap.fe:219:47 + ┌─ uniswap.fe:219:51 │ -219 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) - │ ^^^^^^^^^^^^^^^^^^ address: Value +219 │ let mut balance1: u256 = token1.balanceOf(ctx.self_address()) + │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:219:30 + ┌─ uniswap.fe:219:34 │ -219 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +219 │ let mut balance1: u256 = token1.balanceOf(ctx.self_address()) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value 220 │ let liquidity: u256 = self.balances[ctx.self_address()] │ ^^^^ UniswapV2Pair: Value @@ -3069,24 +3169,28 @@ note: note: ┌─ uniswap.fe:243:5 │ -243 │ ╭ pub fn swap(self, ctx: Context, amount0_out: u256, amount1_out: u256, to: address) { +243 │ ╭ pub fn swap(mut self, mut 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 · │ 279 │ │ emit Swap(ctx, sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to) 280 │ │ } - │ ╰─────^ attributes hash: 18411078236281700131 + │ ╰─────^ attributes hash: 9215307444703324201 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 9093..9097, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -3099,6 +3203,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "amount0_out", typ: Ok( @@ -3110,6 +3215,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "amount1_out", typ: Ok( @@ -3121,6 +3227,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "to", typ: Ok( @@ -3697,17 +3804,21 @@ note: 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 + │ ╰─────^ attributes hash: 17008204640190366872 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 11026..11030, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -3720,6 +3831,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "to", typ: Ok( @@ -3843,24 +3955,28 @@ note: note: ┌─ uniswap.fe:291:5 │ -291 │ ╭ pub fn sync(self, ctx: Context) { +291 │ ╭ pub fn sync(mut self, mut ctx: Context) { 292 │ │ let token0: ERC20 = self.token0 293 │ │ let token1: ERC20 = self.token1 294 │ │ self._update(ctx, · │ 298 │ │ reserve1: self.reserve1) 299 │ │ } - │ ╰─────^ attributes hash: 1731341862738941170 + │ ╰─────^ attributes hash: 2541577077761793004 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 11399..11403, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -4004,11 +4120,14 @@ note: 322 │ ╭ pub fn fee_to(self) -> address { 323 │ │ return self.fee_to 324 │ │ } - │ ╰─────^ attributes hash: 227275695522088782 + │ ╰─────^ attributes hash: 8970242853773362099 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 12208..12212, + }, ), ctx_decl: None, params: [], @@ -4037,11 +4156,14 @@ note: 326 │ ╭ pub fn fee_to_setter(self) -> address { 327 │ │ return self.fee_to_setter 328 │ │ } - │ ╰─────^ attributes hash: 227275695522088782 + │ ╰─────^ attributes hash: 7413951841784457257 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 12286..12290, + }, ), ctx_decl: None, params: [], @@ -4070,11 +4192,14 @@ note: 330 │ ╭ pub fn all_pairs_length(self) -> u256 { 331 │ │ return self.pair_counter 332 │ │ } - │ ╰─────^ attributes hash: 11773348765973600208 + │ ╰─────^ attributes hash: 10067575508843998132 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: Ref, + span: 12374..12378, + }, ), ctx_decl: None, params: [], @@ -4102,24 +4227,28 @@ note: note: ┌─ uniswap.fe:334:5 │ -334 │ ╭ pub fn create_pair(self, ctx: Context, _ token_a: address, _ token_b: address) -> address { +334 │ ╭ pub fn create_pair(mut self, mut 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 · │ 352 │ │ return address(pair) 353 │ │ } - │ ╰─────^ attributes hash: 8455575078477255668 + │ ╰─────^ attributes hash: 15917361863766220684 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 12457..12461, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: true, label: None, name: "ctx", typ: Ok( @@ -4132,6 +4261,7 @@ note: ), }, FunctionParam { + is_mut: false, label: Some( "_", ), @@ -4143,6 +4273,7 @@ note: ), }, FunctionParam { + is_mut: false, label: Some( "_", ), @@ -4547,21 +4678,25 @@ note: note: ┌─ uniswap.fe:355:5 │ -355 │ ╭ pub fn set_fee_to(self, ctx: Context, fee_to: address) { +355 │ ╭ pub fn set_fee_to(mut 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 + │ ╰─────^ attributes hash: 10946147790633155374 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 13471..13475, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -4574,6 +4709,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "fee_to", typ: Ok( @@ -4631,21 +4767,25 @@ note: note: ┌─ uniswap.fe:360:5 │ -360 │ ╭ pub fn set_fee_to_setter(self, ctx: Context, fee_to_setter: address) { +360 │ ╭ pub fn set_fee_to_setter(mut 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 + │ ╰─────^ attributes hash: 17437035610403751314 │ = FunctionSignature { self_decl: Some( - Mutable, + SelfDecl { + kind: MutRef, + span: 13657..13661, + }, ), ctx_decl: Some( Mutable, ), params: [ FunctionParam { + is_mut: false, label: None, name: "ctx", typ: Ok( @@ -4658,6 +4798,7 @@ note: ), }, FunctionParam { + is_mut: false, label: None, name: "fee_to_setter", typ: Ok( @@ -4710,19 +4851,20 @@ note: ┌─ uniswap.fe:366:1 │ 366 │ ╭ fn sqrt(_ val: u256) -> u256 { -367 │ │ let z: u256 +367 │ │ let mut z: u256 368 │ │ if val > 3 { 369 │ │ z = val · │ 378 │ │ return z 379 │ │ } - │ ╰─^ attributes hash: 4892692935064256824 + │ ╰─^ attributes hash: 15366629843235519421 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -4746,13 +4888,13 @@ note: } note: - ┌─ uniswap.fe:367:9 + ┌─ uniswap.fe:367:13 │ -367 │ let z: u256 - │ ^ u256 - · -370 │ let x: u256 = val / 2 + 1 +367 │ let mut z: u256 │ ^ u256 + · +370 │ let mut x: u256 = val / 2 + 1 + │ ^ u256 note: ┌─ uniswap.fe:368:8 @@ -4771,24 +4913,24 @@ note: │ ^ ^^^ u256: Value │ │ │ u256: Value -370 │ let x: u256 = val / 2 + 1 - │ ^^^ ^ u256: Value - │ │ - │ u256: Value +370 │ let mut x: u256 = val / 2 + 1 + │ ^^^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ uniswap.fe:370:23 + ┌─ uniswap.fe:370:27 │ -370 │ let x: u256 = val / 2 + 1 - │ ^^^^^^^ ^ u256: Value - │ │ - │ u256: Value +370 │ let mut x: u256 = val / 2 + 1 + │ ^^^^^^^ ^ u256: Value + │ │ + │ u256: Value note: - ┌─ uniswap.fe:370:23 + ┌─ uniswap.fe:370:27 │ -370 │ let x: u256 = val / 2 + 1 - │ ^^^^^^^^^^^ u256: Value +370 │ let mut x: u256 = val / 2 + 1 + │ ^^^^^^^^^^^ u256: Value 371 │ while x < z { │ ^ ^ u256: Value │ │ @@ -4855,13 +4997,14 @@ note: 381 │ ╭ fn min(_ x: u256, _ y: u256) -> u256 { 382 │ │ return x if x < y else y 383 │ │ } - │ ╰─^ attributes hash: 4448606202021980030 + │ ╰─^ attributes hash: 15612950807422836908 │ = FunctionSignature { self_decl: None, ctx_decl: None, params: [ FunctionParam { + is_mut: false, label: Some( "_", ), @@ -4875,6 +5018,7 @@ note: ), }, FunctionParam { + is_mut: false, label: Some( "_", ), diff --git a/crates/analyzer/tests/snapshots/analysis__while_loop.snap b/crates/analyzer/tests/snapshots/analysis__while_loop.snap index 5cd038deda..accd5a2d0b 100644 --- a/crates/analyzer/tests/snapshots/analysis__while_loop.snap +++ b/crates/analyzer/tests/snapshots/analysis__while_loop.snap @@ -7,7 +7,7 @@ note: ┌─ while_loop.fe:2:5 │ 2 │ ╭ pub fn bar() -> u256 { - 3 │ │ let val: u256 = 0 + 3 │ │ let mut val: u256 = 0 4 │ │ while val < 2 { 5 │ │ val = val + 1 · │ @@ -29,16 +29,16 @@ note: } note: - ┌─ while_loop.fe:3:13 + ┌─ while_loop.fe:3:17 │ -3 │ let val: u256 = 0 - │ ^^^ u256 +3 │ let mut val: u256 = 0 + │ ^^^ u256 note: - ┌─ while_loop.fe:3:25 + ┌─ while_loop.fe:3:29 │ -3 │ let val: u256 = 0 - │ ^ u256: Value +3 │ let mut val: u256 = 0 + │ ^ u256: Value 4 │ while val < 2 { │ ^^^ ^ 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 c4c536fc90..b22cc5cab6 100644 --- a/crates/analyzer/tests/snapshots/analysis__while_loop_with_break.snap +++ b/crates/analyzer/tests/snapshots/analysis__while_loop_with_break.snap @@ -7,7 +7,7 @@ note: ┌─ while_loop_with_break.fe:2:5 │ 2 │ ╭ pub fn bar() -> u256 { -3 │ │ let val: u256 = 0 +3 │ │ let mut val: u256 = 0 4 │ │ while val < 2 { 5 │ │ val = val + 1 · │ @@ -29,16 +29,16 @@ note: } note: - ┌─ while_loop_with_break.fe:3:13 + ┌─ while_loop_with_break.fe:3:17 │ -3 │ let val: u256 = 0 - │ ^^^ u256 +3 │ let mut val: u256 = 0 + │ ^^^ u256 note: - ┌─ while_loop_with_break.fe:3:25 + ┌─ while_loop_with_break.fe:3:29 │ -3 │ let val: u256 = 0 - │ ^ u256: Value +3 │ let mut val: u256 = 0 + │ ^ u256: Value 4 │ while val < 2 { │ ^^^ ^ 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 1ace43a336..4753de59fe 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 @@ -7,7 +7,7 @@ note: ┌─ while_loop_with_break_2.fe:2:5 │ 2 │ ╭ pub fn bar() -> u256 { - 3 │ │ let val: u256 = 0 + 3 │ │ let mut val: u256 = 0 4 │ │ while val < 2 { 5 │ │ val = val + 1 · │ @@ -29,16 +29,16 @@ note: } note: - ┌─ while_loop_with_break_2.fe:3:13 + ┌─ while_loop_with_break_2.fe:3:17 │ -3 │ let val: u256 = 0 - │ ^^^ u256 +3 │ let mut val: u256 = 0 + │ ^^^ u256 note: - ┌─ while_loop_with_break_2.fe:3:25 + ┌─ while_loop_with_break_2.fe:3:29 │ -3 │ let val: u256 = 0 - │ ^ u256: Value +3 │ let mut val: u256 = 0 + │ ^ u256: Value 4 │ while val < 2 { │ ^^^ ^ 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 46727e3ef9..b57e963cd9 100644 --- a/crates/analyzer/tests/snapshots/analysis__while_loop_with_continue.snap +++ b/crates/analyzer/tests/snapshots/analysis__while_loop_with_continue.snap @@ -7,8 +7,8 @@ note: ┌─ while_loop_with_continue.fe:2:5 │ 2 │ ╭ pub fn bar() -> u256 { - 3 │ │ let i: u256 = 0 - 4 │ │ let counter: u256 = 0 + 3 │ │ let mut i: u256 = 0 + 4 │ │ let mut counter: u256 = 0 5 │ │ while i < 2 { · │ 12 │ │ return counter @@ -29,20 +29,20 @@ note: } note: - ┌─ while_loop_with_continue.fe:3:13 + ┌─ while_loop_with_continue.fe:3:17 │ -3 │ let i: u256 = 0 - │ ^ u256 -4 │ let counter: u256 = 0 - │ ^^^^^^^ u256 +3 │ let mut i: u256 = 0 + │ ^ u256 +4 │ let mut counter: u256 = 0 + │ ^^^^^^^ u256 note: - ┌─ while_loop_with_continue.fe:3:23 + ┌─ while_loop_with_continue.fe:3:27 │ -3 │ let i: u256 = 0 - │ ^ u256: Value -4 │ let counter: u256 = 0 - │ ^ u256: Value +3 │ let mut i: u256 = 0 + │ ^ u256: Value +4 │ let mut counter: u256 = 0 + │ ^ u256: Value 5 │ while i < 2 { │ ^ ^ u256: Value │ │ 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 e5f8c8da80..334a5cf8a5 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 @@ -6,7 +6,7 @@ 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:13:25 │ - 6 │ ╭ fn do_private_thingz(self) { + 6 │ ╭ fn do_private_thingz(mut self) { 7 │ │ self.val = 100 8 │ │ } │ ╰─────' `do_private_thingz` is defined here 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 0de7c91454..69e234b269 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 @@ -23,14 +23,6 @@ error: incorrect type for argument to `Barn.create` 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:15:27 - │ -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:15:27 │ diff --git a/crates/analyzer/tests/snapshots/errors__ctx_missing_event.snap b/crates/analyzer/tests/snapshots/errors__ctx_missing_event.snap index 0004a26eb3..212377c0a2 100644 --- a/crates/analyzer/tests/snapshots/errors__ctx_missing_event.snap +++ b/crates/analyzer/tests/snapshots/errors__ctx_missing_event.snap @@ -11,14 +11,6 @@ error: `HelloWorld` expects 2 arguments, but 1 was provided │ │ │ expects 2 arguments -error: argument label mismatch - ┌─ compile_errors/ctx_missing_event.fe:9:25 - │ -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:9:34 │ 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 a25994acc6..6308cc89c3 100644 --- a/crates/analyzer/tests/snapshots/errors__ctx_missing_internal_call.snap +++ b/crates/analyzer/tests/snapshots/errors__ctx_missing_internal_call.snap @@ -13,11 +13,11 @@ error: `bar` expects 1 argument, but 0 were provided │ -- supplied 0 arguments error: cannot modify `self`, as it is not mutable - ┌─ compile_errors/ctx_missing_internal_call.fe:10:9 + ┌─ compile_errors/ctx_missing_internal_call.fe:11:9 │ - 9 │ pub fn baz(self, ctx: Context): +10 │ pub fn baz(self, ctx: Context) { │ ---- consider changing this to be mutable: `mut self` -10 │ self.favorite_number = bar() +11 │ self.favorite_number = bar() │ ^^^^ not mutable 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 ec25eb8e9b..457c5afa14 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 @@ -4,13 +4,13 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: duplicate definition of variable `sum` - ┌─ compile_errors/duplicate_var_in_child_scope.fe:4:13 + ┌─ compile_errors/duplicate_var_in_child_scope.fe:4:17 │ -4 │ let sum: u256 = 0 - │ ^^^ `sum` first defined here +4 │ let mut sum: u256 = 0 + │ ^^^ `sum` first defined here 5 │ for i in my_array { -6 │ let sum: u64 = 0 - │ --- `sum` redefined here +6 │ let mut sum: u64 = 0 + │ --- `sum` redefined here error: `+` operand types must be equal ┌─ compile_errors/duplicate_var_in_child_scope.fe:7:13 diff --git a/crates/analyzer/tests/snapshots/errors__emit_bad_args.snap b/crates/analyzer/tests/snapshots/errors__emit_bad_args.snap index da64b2371c..74598c1a6a 100644 --- a/crates/analyzer/tests/snapshots/errors__emit_bad_args.snap +++ b/crates/analyzer/tests/snapshots/errors__emit_bad_args.snap @@ -11,13 +11,11 @@ error: `Foo` expects 4 arguments, but 5 were provided │ │ │ expects 4 arguments -error: missing argument label - ┌─ compile_errors/emit_bad_args.fe:11:23 +error: expected mut arg + ┌─ compile_errors/emit_bad_args.fe:11:18 │ 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`. + │ ^^^ this is not mutable error: incorrect type for `Foo` argument `x` ┌─ compile_errors/emit_bad_args.fe:11:23 diff --git a/crates/analyzer/tests/snapshots/errors__missing_return.snap b/crates/analyzer/tests/snapshots/errors__missing_return.snap index 0b734c1788..8d1f22c0fd 100644 --- a/crates/analyzer/tests/snapshots/errors__missing_return.snap +++ b/crates/analyzer/tests/snapshots/errors__missing_return.snap @@ -14,7 +14,7 @@ error: function body is missing a return or revert statement error: cannot modify `self.baz`, as it is not mutable ┌─ compile_errors/missing_return.fe:5:9 │ -4 │ pub fn bar(self) -> u256: +4 │ pub fn bar(self) -> u256 { │ ---- consider changing this to be mutable: `mut self` 5 │ self.baz[0] = 1 │ ^^^^^^^^ not mutable diff --git a/crates/analyzer/tests/snapshots/errors__self_misuse.snap b/crates/analyzer/tests/snapshots/errors__self_misuse.snap index 2fa7623dbf..a1b9aea8c6 100644 --- a/crates/analyzer/tests/snapshots/errors__self_misuse.snap +++ b/crates/analyzer/tests/snapshots/errors__self_misuse.snap @@ -16,12 +16,12 @@ error: `self` can only be used in contract or struct functions │ ^^^^ not allowed in functions defined outside of a contract or struct error: cannot modify `s`, as it is not mutable - ┌─ compile_errors/self_misuse.fe:6:3 + ┌─ compile_errors/self_misuse.fe:7:5 │ -5 │ fn change_x(_ s: S): +6 │ fn change_x(_ s: S) { │ - consider changing this to be mutable: `mut s` -6 │ s.x = 100 - │ ^ not mutable +7 │ s.x = 100 + │ ^ not mutable error: `self` is not callable ┌─ compile_errors/self_misuse.fe:16:9 @@ -30,10 +30,10 @@ error: `self` is not callable │ ^^^^ can't be used as a function error: invalid assignment target - ┌─ compile_errors/self_misuse.fe:18:5 + ┌─ compile_errors/self_misuse.fe:20:9 │ -18 │ self = S(x: 10) - │ ^^^^ +20 │ self = S(x: 10) + │ ^^^^ │ = The left side of an assignment can be a variable name, attribute, subscript, or tuple. diff --git a/crates/analyzer/tests/snapshots/errors__self_mut_mismatch.snap b/crates/analyzer/tests/snapshots/errors__self_mut_mismatch.snap index 3ee74661c3..02fe5f6190 100644 --- a/crates/analyzer/tests/snapshots/errors__self_mut_mismatch.snap +++ b/crates/analyzer/tests/snapshots/errors__self_mut_mismatch.snap @@ -6,7 +6,7 @@ expression: "error_string(&path, test_files::fixture(path))" error: function `set_things` requires `mut self` ┌─ compile_errors/self_mut_mismatch.fe:5:14 │ -4 │ fn foo(self): +4 │ fn foo(self) { │ ---- consider changing this to be mutable: `mut self` 5 │ self.set_things(x: 10) │ ---- ^^^^^^^^^^ requires `mut self` @@ -16,18 +16,18 @@ error: function `set_things` requires `mut self` error: cannot modify `self`, as it is not mutable ┌─ compile_errors/self_mut_mismatch.fe:6:9 │ -4 │ fn foo(self): +4 │ fn foo(self) { │ ---- consider changing this to be mutable: `mut self` 5 │ self.set_things(x: 10) 6 │ self.x = 100 │ ^^^^ not mutable error: cannot modify `self`, as it is not mutable - ┌─ compile_errors/self_mut_mismatch.fe:28:9 + ┌─ compile_errors/self_mut_mismatch.fe:32:9 │ -27 │ pub fn get_name(self) -> String<100>: +31 │ pub fn get_name(self) -> String<100> { │ ---- consider changing this to be mutable: `mut self` -28 │ self.name = "shouldnt work" +32 │ self.name = "shouldnt work" │ ^^^^ not mutable diff --git a/crates/analyzer/tests/snapshots/errors__sneaky_mutation.snap b/crates/analyzer/tests/snapshots/errors__sneaky_mutation.snap index 234178d753..7855945627 100644 --- a/crates/analyzer/tests/snapshots/errors__sneaky_mutation.snap +++ b/crates/analyzer/tests/snapshots/errors__sneaky_mutation.snap @@ -34,9 +34,9 @@ error: expected mut arg │ ^^^ this is not mutable error: sneaky mutation - ┌─ compile_errors/sneaky_mutation.fe:42:9 + ┌─ compile_errors/sneaky_mutation.fe:43:9 │ -42 │ self.array = array +43 │ self.array = array │ ^^^^^^^^^^ ----- this is immutable │ │ │ this is mutable diff --git a/crates/library/std/src/context.fe b/crates/library/std/src/context.fe index 222cdf7353..571b8fd83b 100644 --- a/crates/library/std/src/context.fe +++ b/crates/library/std/src/context.fe @@ -62,7 +62,7 @@ pub struct Context { unsafe { return address(__address()) } } - pub fn send_value(self, to: address, wei: u256) { + pub fn send_value(mut self, to: address, wei: u256) { unsafe { if evm::balance() < wei { revert Error(code: ERROR_INSUFFICIENT_FUNDS_TO_SEND_VALUE) 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 ae957dd09f..ff37fb97a9 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 @@ -50,7 +50,8 @@ Node( ), args: [ Node( - kind: Regular(RegularFunctionArg( + kind: Regular( + mut_: None, label: None, name: Node( kind: "this", @@ -68,14 +69,15 @@ Node( end: 27, ), ), - )), + ), span: Span( start: 20, end: 27, ), ), Node( - kind: Regular(RegularFunctionArg( + kind: Regular( + mut_: None, label: None, name: Node( kind: "that", @@ -93,14 +95,15 @@ Node( end: 36, ), ), - )), + ), span: Span( start: 29, end: 36, ), ), Node( - kind: Regular(RegularFunctionArg( + kind: Regular( + mut_: None, label: Some(Node( kind: "_", span: Span( @@ -124,7 +127,7 @@ Node( end: 48, ), ), - )), + ), span: Span( start: 40, end: 48, diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_mut_args.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_mut_args.snap index 94c2ceada5..47b63d6bd9 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_mut_args.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__fn_def_mut_args.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(fn_def_mut_args), try_parse_module,\n \"fn transfer(mut from sender: address, to recip: address, mut val: u64) -> bool:\\n false\")" +expression: "ast_string(stringify!(fn_def_mut_args), try_parse_module,\n \"fn transfer(mut from sender: address, to recip: address, mut val: u64) -> bool { \\n return false \\n}\")" --- Node( @@ -17,6 +17,13 @@ Node( end: 11, ), ), + generic_params: Node( + kind: [], + span: Span( + start: 3, + end: 11, + ), + ), args: [ Node( kind: Regular( @@ -126,31 +133,31 @@ Node( )), body: [ Node( - kind: Expr( - value: Node( + kind: Return( + value: Some(Node( kind: Bool(false), span: Span( - start: 81, - end: 86, + start: 90, + end: 95, ), - ), + )), ), span: Span( - start: 81, - end: 86, + start: 83, + end: 95, ), ), ], ), span: Span( start: 0, - end: 86, + end: 98, ), )), ], ), span: Span( start: 0, - end: 86, + end: 98, ), ) 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 c19c7f19ee..7dec4893ba 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 @@ -181,7 +181,9 @@ Node( ), args: [ Node( - kind: Self_, + kind: Self_( + mut_: None, + ), span: Span( start: 80, end: 84, diff --git a/crates/parser/tests/cases/snapshots/cases__print_ast__erc20.snap b/crates/parser/tests/cases/snapshots/cases__print_ast__erc20.snap index c74fd97eac..861148aa1a 100644 --- a/crates/parser/tests/cases/snapshots/cases__print_ast__erc20.snap +++ b/crates/parser/tests/cases/snapshots/cases__print_ast__erc20.snap @@ -25,7 +25,7 @@ contract ERC20 { value: u256 } - pub fn __init__(self, ctx: Context, name: String<100>, symbol: String<100>) { + pub fn __init__(mut self, mut ctx: Context, name: String<100>, symbol: String<100>) { self._name = name self._symbol = symbol self._decimals = u8(18) @@ -52,7 +52,7 @@ contract ERC20 { return self._balances[account] } - pub fn transfer(self, ctx: Context, recipient: address, value: u256) -> bool { + pub fn transfer(mut self, mut ctx: Context, recipient: address, value: u256) -> bool { self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) return true } @@ -61,29 +61,29 @@ contract ERC20 { return self._allowances[owner][spender] } - pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool { + pub fn approve(mut self, mut 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(mut self, mut 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(mut self, mut 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(mut self, mut 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(mut self, mut ctx: Context, sender: address, recipient: address, value: u256) { assert sender != address(0) assert recipient != address(0) _before_token_transfer(from: sender, to: recipient, value) @@ -92,7 +92,7 @@ contract ERC20 { emit Transfer(ctx, from: sender, to: recipient, value) } - fn _mint(self, ctx: Context, account: address, value: u256) { + fn _mint(mut self, mut 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 @@ -100,7 +100,7 @@ contract ERC20 { emit Transfer(ctx, from: address(0), to: account, value) } - fn _burn(self, ctx: Context, account: address, value: u256) { + fn _burn(mut self, mut 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 @@ -108,14 +108,14 @@ contract ERC20 { emit Transfer(ctx, from: account, to: address(0), value) } - fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { + fn _approve(mut self, mut 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(mut self, _ decimals_: u8) { self._decimals = decimals_ } 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 index d4a34739bc..0e295a049c 100644 --- a/crates/parser/tests/cases/snapshots/cases__print_ast__guest_book.snap +++ b/crates/parser/tests/cases/snapshots/cases__print_ast__guest_book.snap @@ -12,7 +12,7 @@ contract GuestBook { book_msg: String<100> } - pub fn sign(self, ctx: Context, book_msg: String<100>) { + pub fn sign(mut self, mut ctx: Context, book_msg: String<100>) { self.messages[ctx.msg_sender()] = book_msg emit Signed(ctx, book_msg) } 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 95a7137dec..551e0393fa 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 @@ -6,7 +6,7 @@ contract Foo { idx val_2: u8 } - pub fn foo(ctx: Context) { + pub fn foo(mut 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 897120d42a..92c4b83816 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 @@ -3,7 +3,7 @@ use std::context::Context contract Foo { val: u8 - fn do_private_thingz(self) { + fn do_private_thingz(mut self) { self.val = 100 } } 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 58856c3e55..c4d231b049 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,9 +1,9 @@ contract Foo { pub fn bar() { let my_array: Array - let sum: u256 = 0 + let mut sum: u256 = 0 for i in my_array { - let sum: u64 = 0 + let mut sum: u64 = 0 sum += i } } 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 773f2b8c09..156cac6f67 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 @@ -2,7 +2,7 @@ contract C { fn f() { let x: u256 = 10 let xs: Array = [1, 2, 3, 4] - let sum: u8 = 0 + let mut sum: u8 = 0 for x in xs { sum += x } 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 264f390b25..da134c3ee2 100644 --- a/crates/test-files/fixtures/compile_errors/needs_mem_copy.fe +++ b/crates/test-files/fixtures/compile_errors/needs_mem_copy.fe @@ -1,7 +1,7 @@ contract Foo { my_sto_array: Array - pub fn bar(self, my_array: Array) { + pub fn bar(self, mut my_array: Array) { my_array = self.my_sto_array } 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 db4d77afa4..dd53c85230 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,6 +1,6 @@ contract Foo { pub fn bar() -> u256 { - let i: u256 = 0 + let mut i: u256 = 0 while i < 1 { i = 1 let y: u256 = 1 diff --git a/crates/test-files/fixtures/compile_errors/self_mut_mismatch.fe b/crates/test-files/fixtures/compile_errors/self_mut_mismatch.fe index a4cfad179e..e7613168ab 100644 --- a/crates/test-files/fixtures/compile_errors/self_mut_mismatch.fe +++ b/crates/test-files/fixtures/compile_errors/self_mut_mismatch.fe @@ -1,32 +1,38 @@ -contract Foo: +contract Foo { x: u8 - fn foo(self): + fn foo(self) { self.set_things(x: 10) self.x = 100 - - fn set_things(mut self, x: u8): + } + fn set_things(mut self, x: u8) { self.x = x - - fn test_struct(): + } + fn test_struct() { let m: Person = Person(name: "Martha") m.set_name("May") - - fn test_contract(): + } + fn test_contract() { let b: Beef = Beef(address(0xbeef)) + } +} -contract Beef: +contract Beef { y: u8 - pub fn set_y(mut self, y: u8): + pub fn set_y(mut self, y: u8) { self.y = y + } +} -struct Person: +struct Person { pub name: String<100> - pub fn get_name(self) -> String<100>: + pub fn get_name(self) -> String<100> { self.name = "shouldnt work" return self.name - - pub fn set_name(mut self, mut _ name: String<100>): + } + pub fn set_name(mut self, mut _ name: String<100>) { self.name = name + } +} \ No newline at end of file diff --git a/crates/test-files/fixtures/compile_errors/sneaky_mutation.fe b/crates/test-files/fixtures/compile_errors/sneaky_mutation.fe index 0408b794e7..f2ee7e3b63 100644 --- a/crates/test-files/fixtures/compile_errors/sneaky_mutation.fe +++ b/crates/test-files/fixtures/compile_errors/sneaky_mutation.fe @@ -1,5 +1,5 @@ -fn f(): +fn f() { # Mutate an immutable via aliasing... # ...at constuction time @@ -11,9 +11,9 @@ fn f(): let mut y1: Array y1 = x y1[0] = 20 +} - -fn g(): +fn g() { # Put an immutable array into a mutable struct... # ...at construction time @@ -34,14 +34,17 @@ fn g(): # This should work. w2.set_array2([10, 10, 10]) +} -struct ArrayWrapper: +struct ArrayWrapper { pub array: Array - pub fn set_array(mut self, _ array: Array): + pub fn set_array(mut self, _ array: Array) { self.array = array self.array[2] = 100 - - pub fn set_array2(mut self, mut _ array: Array): + } + pub fn set_array2(mut self, mut _ array: Array) { self.array = array self.array[2] = 100 + } +} diff --git a/crates/test-files/fixtures/demos/erc20_token.fe b/crates/test-files/fixtures/demos/erc20_token.fe index e2f6364b95..5a481a8274 100644 --- a/crates/test-files/fixtures/demos/erc20_token.fe +++ b/crates/test-files/fixtures/demos/erc20_token.fe @@ -20,7 +20,7 @@ contract ERC20 { value: u256 } - pub fn __init__(self, ctx: Context, name: String<100>, symbol: String<100>) { + pub fn __init__(mut self, mut ctx: Context, name: String<100>, symbol: String<100>) { self._name = name self._symbol = symbol self._decimals = u8(18) @@ -47,7 +47,7 @@ contract ERC20 { return self._balances[account] } - pub fn transfer(self, ctx: Context, recipient: address, value: u256) -> bool { + pub fn transfer(mut self, mut ctx: Context, recipient: address, value: u256) -> bool { self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) return true } @@ -56,29 +56,29 @@ contract ERC20 { return self._allowances[owner][spender] } - pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool { + pub fn approve(mut self, mut 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(mut self, mut 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(mut self, mut 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(mut self, mut 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(mut self, mut ctx: Context, sender: address, recipient: address, value: u256) { assert sender != address(0) assert recipient != address(0) _before_token_transfer(from: sender, to: recipient, value) @@ -87,7 +87,7 @@ contract ERC20 { emit Transfer(ctx, from: sender, to: recipient, value) } - fn _mint(self, ctx: Context, account: address, value: u256) { + fn _mint(mut self, mut 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 @@ -95,7 +95,7 @@ contract ERC20 { emit Transfer(ctx, from: address(0), to: account, value) } - fn _burn(self, ctx: Context, account: address, value: u256) { + fn _burn(mut self, mut 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 @@ -103,14 +103,14 @@ contract ERC20 { emit Transfer(ctx, from: account, to: address(0), value) } - fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { + fn _approve(mut self, mut 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(mut self, _ decimals_: u8) { self._decimals = decimals_ } diff --git a/crates/test-files/fixtures/demos/guest_book.fe b/crates/test-files/fixtures/demos/guest_book.fe index 1b20c6991f..785a5d4c39 100644 --- a/crates/test-files/fixtures/demos/guest_book.fe +++ b/crates/test-files/fixtures/demos/guest_book.fe @@ -11,7 +11,7 @@ contract GuestBook { book_msg: String<100> } - pub fn sign(self, ctx: Context, book_msg: String<100>) { + pub fn sign(mut self, mut ctx: Context, book_msg: String<100>) { # All storage access is explicit using `self.` self.messages[ctx.msg_sender()] = book_msg diff --git a/crates/test-files/fixtures/demos/simple_open_auction.fe b/crates/test-files/fixtures/demos/simple_open_auction.fe index 6c2a13c358..99885aec95 100644 --- a/crates/test-files/fixtures/demos/simple_open_auction.fe +++ b/crates/test-files/fixtures/demos/simple_open_auction.fe @@ -33,13 +33,13 @@ contract SimpleOpenAuction { } # constructor - pub fn __init__(self, ctx: Context, bidding_time: u256, beneficiary_addr: address) { + pub fn __init__(mut 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) { + pub fn bid(mut self, mut ctx: Context) { if ctx.block_timestamp() > self.auction_end_time { revert AuctionAlreadyEnded() } @@ -55,7 +55,7 @@ contract SimpleOpenAuction { emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) } - pub fn withdraw(self, ctx: Context) -> bool { + pub fn withdraw(mut self, ctx: Context) -> bool { let amount: u256 = self.pending_returns[ctx.msg_sender()] if amount > 0 { @@ -65,7 +65,7 @@ contract SimpleOpenAuction { return true } - pub fn action_end(self, ctx: Context) { + pub fn action_end(mut self, mut ctx: Context) { if ctx.block_timestamp() <= self.auction_end_time { revert AuctionNotYetEnded() } diff --git a/crates/test-files/fixtures/demos/uniswap.fe b/crates/test-files/fixtures/demos/uniswap.fe index 0051203085..08a56fd57d 100644 --- a/crates/test-files/fixtures/demos/uniswap.fe +++ b/crates/test-files/fixtures/demos/uniswap.fe @@ -20,7 +20,7 @@ contract UniswapV2Pair { nonces: Map - factory: address + factory: UniswapV2Factory token0: ERC20 token1: ERC20 @@ -71,12 +71,12 @@ contract UniswapV2Pair { reserve1: u256 } - pub fn __init__(self, ctx: Context) { - self.factory = ctx.msg_sender() + pub fn __init__(mut self, ctx: Context) { + self.factory = UniswapV2Factory(ctx.msg_sender()) } pub fn factory(self) -> address { - return self.factory + return address(self.factory) } pub fn token0(self) -> address { @@ -87,40 +87,40 @@ contract UniswapV2Pair { return address(self.token1) } - fn _mint(self, ctx: Context, to: address, value: u256) { + fn _mint(mut self, mut 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(mut self, mut 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(mut self, mut 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(mut self, mut 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(mut self, mut 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(mut self, mut 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(mut self, mut 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) @@ -136,14 +136,14 @@ contract UniswapV2Pair { } # called once by the factory at time of deployment - pub fn initialize(self, ctx: Context, token0: ERC20, token1: ERC20) { - assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" + pub fn initialize(mut self, ctx: Context, token0: ERC20, token1: ERC20) { + assert ctx.msg_sender() == address(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(mut self, mut ctx: Context, balance0: u256, balance1: u256, reserve0: u256, reserve1: u256) { # changed from u32s # TODO: reproduce desired overflow (https://github.com/ethereum/fe/issues/286) let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 @@ -158,8 +158,8 @@ contract UniswapV2Pair { emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) } - fn _mint_fee(self, ctx: Context, reserve0: u256, reserve1: u256) -> bool { - let fee_to: address = UniswapV2Factory(self.factory).fee_to() + fn _mint_fee(mut self, mut ctx: Context, reserve0: u256, reserve1: u256) -> bool { + let fee_to: address = self.factory.fee_to() let fee_on: bool = fee_to != address(0) let k_last: u256 = self.k_last if fee_on { @@ -182,7 +182,7 @@ contract UniswapV2Pair { } # 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(mut self, mut ctx: Context, to: address) -> u256 { let MINIMUM_LIQUIDITY: u256 = 1000 let reserve0: u256 = self.reserve0 let reserve1: u256 = self.reserve1 @@ -192,7 +192,7 @@ contract UniswapV2Pair { 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 + let mut liquidity: u256 = 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 @@ -210,13 +210,13 @@ contract UniswapV2Pair { } # 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(mut self, mut ctx: Context, to: address) -> (u256, u256) { let reserve0: u256 = self.reserve0 let reserve1: u256 = self.reserve1 let token0: ERC20 = self.token0 let token1: ERC20 = self.token1 - let balance0: u256 = token0.balanceOf(ctx.self_address()) - let balance1: u256 = token1.balanceOf(ctx.self_address()) + let mut balance0: u256 = token0.balanceOf(ctx.self_address()) + let mut balance1: u256 = token1.balanceOf(ctx.self_address()) let liquidity: u256 = self.balances[ctx.self_address()] let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) @@ -240,7 +240,7 @@ contract UniswapV2Pair { # 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(mut self, mut 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 @@ -288,7 +288,7 @@ contract UniswapV2Pair { } # force reserves to match balances - pub fn sync(self, ctx: Context) { + pub fn sync(mut self, mut ctx: Context) { let token0: ERC20 = self.token0 let token1: ERC20 = self.token1 self._update(ctx, @@ -315,7 +315,7 @@ contract UniswapV2Factory { index: u256 } - pub fn __init__(self, _ fee_to_setter: address) { + pub fn __init__(mut self, _ fee_to_setter: address) { self.fee_to_setter = fee_to_setter } @@ -331,7 +331,7 @@ contract UniswapV2Factory { return self.pair_counter } - pub fn create_pair(self, ctx: Context, _ token_a: address, _ token_b: address) -> address { + pub fn create_pair(mut self, mut 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 @@ -352,22 +352,22 @@ contract UniswapV2Factory { return address(pair) } - pub fn set_fee_to(self, ctx: Context, fee_to: address) { + pub fn set_fee_to(mut 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(mut 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 { - let z: u256 + let mut z: u256 if val > 3 { z = val - let x: u256 = val / 2 + 1 + let mut x: u256 = val / 2 + 1 while x < z { z = x x = (val / x + x) / 2 diff --git a/crates/test-files/fixtures/features/address_bytes10_map.fe b/crates/test-files/fixtures/features/address_bytes10_map.fe index 6f85dd3f1a..b008731a5c 100644 --- a/crates/test-files/fixtures/features/address_bytes10_map.fe +++ b/crates/test-files/fixtures/features/address_bytes10_map.fe @@ -5,7 +5,7 @@ contract Foo { return self.bar[key].to_mem() } - pub fn write_bar(self, key: address, value: Array) { + pub fn write_bar(mut self, key: address, value: Array) { self.bar[key] = value } } diff --git a/crates/test-files/fixtures/features/assert.fe b/crates/test-files/fixtures/features/assert.fe index 96d2413f44..ff83d1a223 100644 --- a/crates/test-files/fixtures/features/assert.fe +++ b/crates/test-files/fixtures/features/assert.fe @@ -14,12 +14,12 @@ contract Foo { assert baz > 5, reason } - pub fn assert_sto_bool(self) { + pub fn assert_sto_bool(mut self) { self.my_bool = false assert self.my_bool } - pub fn assert_sto_string_msg(self) { + pub fn assert_sto_string_msg(mut 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 d708b684ff..6218813343 100644 --- a/crates/test-files/fixtures/features/associated_fns.fe +++ b/crates/test-files/fixtures/features/associated_fns.fe @@ -15,7 +15,7 @@ struct MyStruct { contract Foo { my_struct: MyStruct - pub fn bar(self, val: u256) -> u256 { + pub fn bar(mut 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 da6bbd2e38..3fb428e3c0 100644 --- a/crates/test-files/fixtures/features/aug_assign.fe +++ b/crates/test-files/fixtures/features/aug_assign.fe @@ -1,69 +1,69 @@ contract Foo { my_num: u256 - pub fn add(a: u256, b: u256) -> u256 { + pub fn add(mut a: u256, b: u256) -> u256 { a += b return a } - pub fn sub(a: u256, b: u256) -> u256 { + pub fn sub(mut a: u256, b: u256) -> u256 { a -= b return a } - pub fn mul(a: u256, b: u256) -> u256 { + pub fn mul(mut a: u256, b: u256) -> u256 { a *= b return a } - pub fn div(a: u256, b: u256) -> u256 { + pub fn div(mut a: u256, b: u256) -> u256 { a /= b return a } - pub fn mod(a: u256, b: u256) -> u256 { + pub fn mod(mut a: u256, b: u256) -> u256 { a %= b return a } - pub fn pow(a: u256, b: u256) -> u256 { + pub fn pow(mut a: u256, b: u256) -> u256 { a **= b return a } - pub fn lshift(a: u8, b: u8) -> u8 { + pub fn lshift(mut a: u8, b: u8) -> u8 { a <<= b return a } - pub fn rshift(a: u8, b: u8) -> u8 { + pub fn rshift(mut a: u8, b: u8) -> u8 { a >>= b return a } - pub fn bit_or(a: u8, b: u8) -> u8 { + pub fn bit_or(mut a: u8, b: u8) -> u8 { a |= b return a } - pub fn bit_xor(a: u8, b: u8) -> u8 { + pub fn bit_xor(mut a: u8, b: u8) -> u8 { a ^= b return a } - pub fn bit_and(a: u8, b: u8) -> u8 { + pub fn bit_and(mut 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(mut 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 { - let my_array: Array + let mut my_array: Array my_array[7] = a my_array[7] += b return my_array[7] 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 5312046273..42f490e2b2 100644 --- a/crates/test-files/fixtures/features/call_statement_with_args.fe +++ b/crates/test-files/fixtures/features/call_statement_with_args.fe @@ -1,11 +1,11 @@ contract Foo { baz: Map - fn assign(self, _ val: u256) { + fn assign(mut self, _ val: u256) { self.baz[0] = val } - pub fn bar(self) -> u256 { + pub fn bar(mut 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 fb7facc533..b56ab73b68 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,12 +1,12 @@ contract Foo { baz: Map - fn assign(self, _ val: u256) -> u256 { + fn assign(mut self, _ val: u256) -> u256 { self.baz[0] = val return val } - pub fn bar(self) -> u256 { + pub fn bar(mut 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 eade30b6e8..9e4a6b1e27 100644 --- a/crates/test-files/fixtures/features/call_statement_without_args.fe +++ b/crates/test-files/fixtures/features/call_statement_without_args.fe @@ -1,11 +1,11 @@ contract Foo { baz: Map - fn assign(self) { + fn assign(mut self) { self.baz[0] = 100 } - pub fn bar(self) -> u256 { + pub fn bar(mut self) -> u256 { self.assign() return self.baz[0] } diff --git a/crates/test-files/fixtures/features/constructor.fe b/crates/test-files/fixtures/features/constructor.fe index 03a7af61d5..9986f2ef4a 100644 --- a/crates/test-files/fixtures/features/constructor.fe +++ b/crates/test-files/fixtures/features/constructor.fe @@ -1,7 +1,7 @@ contract Foo { bar: Map - pub fn __init__(self, baz: u256, bing: u256) { + pub fn __init__(mut self, baz: u256, bing: u256) { self.bar[42] = baz + bing } 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 72d1a7daad..ba9661c4c5 100644 --- a/crates/test-files/fixtures/features/create_contract_from_init.fe +++ b/crates/test-files/fixtures/features/create_contract_from_init.fe @@ -9,7 +9,7 @@ contract Foo { contract FooFactory { foo_addr: address - pub fn __init__(self, ctx: Context) { + pub fn __init__(mut self, mut ctx: Context) { self.foo_addr = address(Foo.create(ctx, 0)) } 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 c959e2b315..9af4cdd1d2 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 @@ -7,7 +7,7 @@ contract Foo { return ctx.block_number() } - pub fn bing(self, _ new_num: u256) -> u256 { + pub fn bing(mut self, _ new_num: u256) -> u256 { self.my_num = new_num return self.my_num } 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 f2f7712088..bd3b337796 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 @@ -3,7 +3,7 @@ use std::context::Context contract Foo { is_true: bool - pub fn bar(self, ctx: Context) -> u256 { + pub fn bar(mut self, ctx: Context) -> u256 { self.is_true = false return baz(ctx) } diff --git a/crates/test-files/fixtures/features/events.fe b/crates/test-files/fixtures/features/events.fe index 453ac576a6..7d5619129a 100644 --- a/crates/test-files/fixtures/features/events.fe +++ b/crates/test-files/fixtures/features/events.fe @@ -22,20 +22,20 @@ contract Foo { addrs: Array } - pub fn emit_nums(ctx: Context) { + pub fn emit_nums(mut ctx: Context) { emit Nums(ctx, num1: 26, num2: 42) } - pub fn emit_bases(ctx: Context, addr: address) { + pub fn emit_bases(mut 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(mut 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) { - let addrs: Array + pub fn emit_addresses(mut ctx: Context, addr1: address, addr2: address) { + let mut addrs: Array addrs[0] = addr1 addrs[1] = addr2 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 54a0512960..bc4da6283e 100644 --- a/crates/test-files/fixtures/features/external_contract.fe +++ b/crates/test-files/fixtures/features/external_contract.fe @@ -7,12 +7,12 @@ contract Foo { my_string: String<11> } - pub fn emit_event(ctx: Context, my_num: u256, my_addrs: Array, my_string: String<11>) { + pub fn emit_event(mut 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 { - let my_array: Array + let mut my_array: Array my_array[0] = a my_array[1] = a * b my_array[2] = b @@ -21,7 +21,7 @@ contract Foo { } contract FooProxy { - pub fn call_emit_event(ctx: Context, foo_address: address, my_num: u256, my_addrs: Array, my_string: String<11>) { + pub fn call_emit_event(mut ctx: Context, foo_address: address, my_num: u256, my_addrs: Array, my_string: String<11>) { let foo: Foo = Foo(foo_address) foo.emit_event(ctx, my_num, my_addrs, my_string) } 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 25d20b5fb3..f6b6ea1edd 100644 --- a/crates/test-files/fixtures/features/for_loop_with_break.fe +++ b/crates/test-files/fixtures/features/for_loop_with_break.fe @@ -1,10 +1,10 @@ contract Foo { pub fn bar() -> u256 { - let my_array: Array + let mut my_array: Array my_array[0] = 5 my_array[1] = 10 my_array[2] = 15 - let sum: u256 = 0 + let mut sum: u256 = 0 for i in my_array { sum = sum + i if sum == 15 { 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 b946482371..da5ce96037 100644 --- a/crates/test-files/fixtures/features/for_loop_with_continue.fe +++ b/crates/test-files/fixtures/features/for_loop_with_continue.fe @@ -1,12 +1,12 @@ contract Foo { pub fn bar() -> u256 { - let my_array: Array + let mut my_array: Array my_array[0] = 2 my_array[1] = 3 my_array[2] = 5 my_array[3] = 6 my_array[4] = 9 - let sum: u256 = 0 + let mut sum: u256 = 0 for i in my_array { if i % 2 == 0 { continue 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 632df0dfa5..cbce388697 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,10 +1,10 @@ contract Foo { pub fn bar() -> u256 { - let my_array: Array + let mut my_array: Array my_array[0] = 5 my_array[1] = 10 my_array[2] = 15 - let sum: u256 = 0 + let mut sum: u256 = 0 for i in my_array { sum = sum + i } 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 901a5fd0bc..b9212bfffa 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,9 +1,9 @@ contract Foo { my_array: Array - pub fn bar(self) -> u256 { + pub fn bar(mut self) -> u256 { self.my_array = [1, 2, 3] - let sum: u256 = 0 + let mut sum: u256 = 0 for i in self.my_array.to_mem() { sum = sum + i } 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 6bda2ec697..a7738c86dc 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 @@ -3,7 +3,7 @@ contract Foo { my_bool2: bool my_bool3: bool - pub fn bar(self) -> u256 { + pub fn bar(mut self) -> u256 { self.my_bool1 = false self.my_bool2 = false self.my_bool3 = true diff --git a/crates/test-files/fixtures/features/int_literal_coercion.fe b/crates/test-files/fixtures/features/int_literal_coercion.fe index c837a08ae0..359d7aa55e 100644 --- a/crates/test-files/fixtures/features/int_literal_coercion.fe +++ b/crates/test-files/fixtures/features/int_literal_coercion.fe @@ -1,6 +1,6 @@ contract Foo { pub fn bar() -> u32 { - let c: u32 = 30 + let mut c: u32 = 30 c = 300 let d: (u128, u64, u32) = (100, 200, c) return d.item2 diff --git a/crates/test-files/fixtures/features/map_tuple.fe b/crates/test-files/fixtures/features/map_tuple.fe index 62341dd14c..bb1e0bca56 100644 --- a/crates/test-files/fixtures/features/map_tuple.fe +++ b/crates/test-files/fixtures/features/map_tuple.fe @@ -1,7 +1,7 @@ contract Foo { tuples: Map - pub fn bar(self, x: u256) -> u256 { + pub fn bar(mut 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 a6499b5238..58fed070fc 100644 --- a/crates/test-files/fixtures/features/math.fe +++ b/crates/test-files/fixtures/features/math.fe @@ -1,9 +1,9 @@ contract Math { pub fn sqrt(val: u256) -> u256 { - let z: u256 + let mut z: u256 if val > 3 { z = val - let x: u256 = val / 2 + 1 + let mut x: u256 = val / 2 + 1 while x < z { z = x x = (val / x + x) / 2 diff --git a/crates/test-files/fixtures/features/module_level_events.fe b/crates/test-files/fixtures/features/module_level_events.fe index 96b59c943e..9957296554 100644 --- a/crates/test-files/fixtures/features/module_level_events.fe +++ b/crates/test-files/fixtures/features/module_level_events.fe @@ -7,7 +7,7 @@ event Transfer { } contract Foo { - fn transfer(ctx: Context, to: address, value: u256) { + fn transfer(mut 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 df5cd903b5..76fbab41b7 100644 --- a/crates/test-files/fixtures/features/multi_param.fe +++ b/crates/test-files/fixtures/features/multi_param.fe @@ -1,6 +1,6 @@ contract Foo { pub fn bar(x: u256, y: u256, z: u256) -> Array { - let my_array: Array + let mut my_array: Array my_array[0] = x my_array[1] = y my_array[2] = z diff --git a/crates/test-files/fixtures/features/nested_map.fe b/crates/test-files/fixtures/features/nested_map.fe index 1271b748a2..e7db5f32cd 100644 --- a/crates/test-files/fixtures/features/nested_map.fe +++ b/crates/test-files/fixtures/features/nested_map.fe @@ -6,7 +6,7 @@ contract Foo { return self.bar[a][b] } - pub fn write_bar(self, a: address, b: address, value: u256) { + pub fn write_bar(mut self, a: address, b: address, value: u256) { self.bar[a][b] = value } @@ -14,7 +14,7 @@ contract Foo { return self.baz[a][b] } - pub fn write_baz(self, a: address, b: u256, value: bool) { + pub fn write_baz(mut self, a: address, b: u256, value: bool) { self.baz[a][b] = value } } diff --git a/crates/test-files/fixtures/features/ownable.fe b/crates/test-files/fixtures/features/ownable.fe index fdc059c340..106550fa52 100644 --- a/crates/test-files/fixtures/features/ownable.fe +++ b/crates/test-files/fixtures/features/ownable.fe @@ -8,7 +8,7 @@ contract Ownable { idx newOwner: address } - pub fn __init__(self, ctx: Context) { + pub fn __init__(mut self, ctx: Context) { self._owner = ctx.msg_sender() } @@ -16,13 +16,13 @@ contract Ownable { return self._owner } - pub fn renounceOwnership(self, ctx: Context) { + pub fn renounceOwnership(mut self, mut 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) { + pub fn transferOwnership(mut self, mut ctx: Context, newOwner: address) { assert ctx.msg_sender() == self._owner assert newOwner != address(0) self._owner = newOwner diff --git a/crates/test-files/fixtures/features/pure_fn_standalone.fe b/crates/test-files/fixtures/features/pure_fn_standalone.fe index 2b4f939a3f..9fd2a64f43 100644 --- a/crates/test-files/fixtures/features/pure_fn_standalone.fe +++ b/crates/test-files/fixtures/features/pure_fn_standalone.fe @@ -6,7 +6,7 @@ contract Foo { cool_users: Map points: Map - fn add_points(self, _ user: address, _ val: u256) { + fn add_points(mut self, _ user: address, _ val: u256) { if self.cool_users[user] { self.points[user] += add_bonus(val) } else { @@ -14,7 +14,7 @@ contract Foo { } } - pub fn bar(self, _ x: u256) -> u256 { + pub fn bar(mut self, _ x: u256) -> u256 { let a: address = address(x) self.add_points(a, 100) self.cool_users[a] = true diff --git a/crates/test-files/fixtures/features/return_array.fe b/crates/test-files/fixtures/features/return_array.fe index 03bbd33b54..108fa62144 100644 --- a/crates/test-files/fixtures/features/return_array.fe +++ b/crates/test-files/fixtures/features/return_array.fe @@ -1,6 +1,6 @@ contract Foo { pub fn bar(x: u256) -> Array { - let my_array: Array + let mut my_array: Array my_array[3] = x return my_array } 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 e78d92c114..f30eaf6433 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,7 +1,7 @@ contract Foo { some_thing: Array - pub fn bar(self, val: i8) -> Array { + pub fn bar(mut self, val: i8) -> Array { self.some_thing[0] = val 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 cda7de9670..882256d443 100644 --- a/crates/test-files/fixtures/features/return_from_storage_i8.fe +++ b/crates/test-files/fixtures/features/return_from_storage_i8.fe @@ -2,7 +2,7 @@ contract Foo { some_thing: i8 some_other: i8 - pub fn bar(self, val: i8) -> i8 { + pub fn bar(mut self, val: i8) -> i8 { self.some_thing = val self.some_other = val let x: i8 = self.some_thing + self.some_other 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 f13a272c50..23a0f44d81 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,10 @@ contract Foo { num_two: u256 - pub fn bar(self) -> u256 { + pub fn bar(mut 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 + let mut sum: u256 = 0 for i in my_array { sum = sum + i } 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 edddc6a955..618832ef13 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 @@ -4,7 +4,7 @@ contract Foo { } fn count(_ values: Array) -> u256 { - let sum: u256 = 0 + let mut sum: u256 = 0 for i in values { sum = sum + i } 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 fb945e4d12..68b3c105cd 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 @@ -9,7 +9,7 @@ contract Foo { return 100 } - pub fn bar(self) -> u256 { + pub fn bar(mut self) -> u256 { self.baz[0] = 43 return foo(5, 2, cem(), 25 + 25, self.baz[0]) } diff --git a/crates/test-files/fixtures/features/revert.fe b/crates/test-files/fixtures/features/revert.fe index 3b7a69031e..17e54332e3 100644 --- a/crates/test-files/fixtures/features/revert.fe +++ b/crates/test-files/fixtures/features/revert.fe @@ -20,7 +20,7 @@ contract Foo { revert OtherError(msg: 1, val: true) } - pub fn revert_other_error_from_sto(self) { + pub fn revert_other_error_from_sto(mut 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/sized_vals_in_sto.fe b/crates/test-files/fixtures/features/sized_vals_in_sto.fe index 3cba528604..c15ae242f4 100644 --- a/crates/test-files/fixtures/features/sized_vals_in_sto.fe +++ b/crates/test-files/fixtures/features/sized_vals_in_sto.fe @@ -11,7 +11,7 @@ contract Foo { str: String<26> } - pub fn write_num(self, x: u256) { + pub fn write_num(mut self, x: u256) { self.num = x } @@ -19,7 +19,7 @@ contract Foo { return self.num } - pub fn write_nums(self, x: Array) { + pub fn write_nums(mut self, x: Array) { self.nums = x } @@ -27,7 +27,7 @@ contract Foo { return self.nums.to_mem() } - pub fn write_str(self, x: String<26>) { + pub fn write_str(mut self, x: String<26>) { self.str = x } @@ -35,7 +35,7 @@ contract Foo { return self.str.to_mem() } - pub fn emit_event(self, ctx: Context) { + pub fn emit_event(self, mut 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 21ba67e7e8..8adc929c5e 100644 --- a/crates/test-files/fixtures/features/strings.fe +++ b/crates/test-files/fixtures/features/strings.fe @@ -11,7 +11,7 @@ contract Foo { s5: String<100> } - pub fn __init__(ctx: Context, s1: String<42>, a: address, s2: String<26>, u: u256, s3: String<100>) { + pub fn __init__(mut 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")) } diff --git a/crates/test-files/fixtures/features/struct_fns.fe b/crates/test-files/fixtures/features/struct_fns.fe index fbf3f5569a..d7b234ca70 100644 --- a/crates/test-files/fixtures/features/struct_fns.fe +++ b/crates/test-files/fixtures/features/struct_fns.fe @@ -14,20 +14,20 @@ struct Point { return self.x } - pub fn set_x(self, _ x: u64) -> u64 { + pub fn set_x(mut self, _ x: u64) -> u64 { let old: u64 = self.x self.x = x return old } - pub fn reflect(self) { + pub fn reflect(mut 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) { + pub fn translate(mut self, x: u64, y: u64) { self.x += x self.y += y } @@ -41,7 +41,7 @@ struct Point { pub fn do_pointy_things() { let p1: Point = Point::origin() - p1.translate(x: 5, y: 10) + p1.translate(x: 5, y: 10) # XXX require mut p1 let p2: Point = Point(x: 1, y: 2) let p3: Point = p1.add(p2) assert p3.x == 6 and p3.y == 12 @@ -52,7 +52,7 @@ contract Foo { do_pointy_things() let p: Point = Point::new(x, y) assert p.x == x and p.y == y - p.set_x(100) + p.set_x(100) # XXX require mut 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 20658f748c..6dabddba62 100644 --- a/crates/test-files/fixtures/features/structs.fe +++ b/crates/test-files/fixtures/features/structs.fe @@ -37,7 +37,7 @@ struct House { return self.price / self.size } - pub fn expand(self) { + pub fn expand(mut self) { self.rooms += 1 self.size += 100 } @@ -47,7 +47,7 @@ contract Foo { my_house: House my_bar: Bar - pub fn complex_struct_in_storage(self) -> String<3> { + pub fn complex_struct_in_storage(mut 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 @@ -79,8 +79,8 @@ contract Foo { 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)) + pub fn complex_struct_in_memory() -> String<3> { + let mut 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 @@ -116,7 +116,7 @@ contract Foo { return mixed.foo } - pub fn set_house(self, data: House) { + pub fn set_house(mut self, data: House) { self.my_house = data } @@ -124,7 +124,7 @@ contract Foo { return self.my_house.to_mem() } - pub fn create_house(self) { + pub fn create_house(mut 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 @@ -153,7 +153,7 @@ contract Foo { } pub fn bar() -> u256 { - let building: House = House(price: 300, size: 500, rooms: u8(20), vacant: true) + let mut 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) diff --git a/crates/test-files/fixtures/features/two_contracts.fe b/crates/test-files/fixtures/features/two_contracts.fe index 93d89c1f7f..d04225acc7 100644 --- a/crates/test-files/fixtures/features/two_contracts.fe +++ b/crates/test-files/fixtures/features/two_contracts.fe @@ -3,11 +3,11 @@ use std::context::Context contract Foo { other: Bar - pub fn __init__(self, ctx: Context) { + pub fn __init__(mut self, ctx: Context) { self.other = Bar.create(ctx, 0) } - pub fn foo(self, ctx: Context) -> u256 { + pub fn foo(mut self, ctx: Context) -> u256 { self.other.set_foo_addr(ctx.self_address()) return self.other.answer() } @@ -20,7 +20,7 @@ contract Foo { contract Bar { other: Foo - pub fn set_foo_addr(self, _ addr: address) { + pub fn set_foo_addr(mut self, _ addr: address) { self.other = Foo(addr) } diff --git a/crates/test-files/fixtures/features/type_aliases.fe b/crates/test-files/fixtures/features/type_aliases.fe index 8b6fe86ef7..2dd61c0c33 100644 --- a/crates/test-files/fixtures/features/type_aliases.fe +++ b/crates/test-files/fixtures/features/type_aliases.fe @@ -1,17 +1,11 @@ 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 { @@ -19,14 +13,14 @@ contract Forum { authors: AuthorPosts scoreboard: Scoreboard - pub fn post(self, ctx: Context, body: PostBody) { + pub fn post(mut 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(mut self, id: PostId) -> Score { let score: Score = self.scoreboard[id] + 1 self.scoreboard[id] = score return score diff --git a/crates/test-files/fixtures/features/u128_u128_map.fe b/crates/test-files/fixtures/features/u128_u128_map.fe index d6d70b67e3..3d2f6cb45e 100644 --- a/crates/test-files/fixtures/features/u128_u128_map.fe +++ b/crates/test-files/fixtures/features/u128_u128_map.fe @@ -5,7 +5,7 @@ contract Foo { return self.bar[key] } - pub fn write_bar(self, key: u128, value: u128) { + pub fn write_bar(mut 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 6d98a40cde..f14cf3c1bd 100644 --- a/crates/test-files/fixtures/features/u16_u16_map.fe +++ b/crates/test-files/fixtures/features/u16_u16_map.fe @@ -5,7 +5,7 @@ contract Foo { return self.bar[key] } - pub fn write_bar(self, key: u16, value: u16) { + pub fn write_bar(mut 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 ceedbf4e3a..aad55b3171 100644 --- a/crates/test-files/fixtures/features/u256_u256_map.fe +++ b/crates/test-files/fixtures/features/u256_u256_map.fe @@ -5,7 +5,7 @@ contract Foo { return self.bar[key] } - pub fn write_bar(self, key: u256, value: u256) { + pub fn write_bar(mut 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 37730309fc..f6e1860f40 100644 --- a/crates/test-files/fixtures/features/u32_u32_map.fe +++ b/crates/test-files/fixtures/features/u32_u32_map.fe @@ -5,7 +5,7 @@ contract Foo { return self.bar[key] } - pub fn write_bar(self, key: u32, value: u32) { + pub fn write_bar(mut 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 523b0201fc..a1918af839 100644 --- a/crates/test-files/fixtures/features/u64_u64_map.fe +++ b/crates/test-files/fixtures/features/u64_u64_map.fe @@ -5,7 +5,7 @@ contract Foo { return self.bar[key] } - pub fn write_bar(self, key: u64, value: u64) { + pub fn write_bar(mut 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 d9cdd74259..db0d54530f 100644 --- a/crates/test-files/fixtures/features/u8_u8_map.fe +++ b/crates/test-files/fixtures/features/u8_u8_map.fe @@ -5,7 +5,7 @@ contract Foo { return self.bar[key] } - pub fn write_bar(self, key: u8, value: u8) { + pub fn write_bar(mut 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 1eac9e0284..ec22e3a5fe 100644 --- a/crates/test-files/fixtures/features/while_loop.fe +++ b/crates/test-files/fixtures/features/while_loop.fe @@ -1,6 +1,6 @@ contract Foo { pub fn bar() -> u256 { - let val: u256 = 0 + let mut val: u256 = 0 while val < 2 { val = val + 1 if val == 2 { 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 865acdef86..b2f4f61672 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,7 +1,7 @@ contract Foo { my_bool: bool - pub fn bar(self) -> u256 { + pub fn bar(mut self) -> u256 { self.my_bool = false while self.my_bool { 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 38f9fd64be..9824808165 100644 --- a/crates/test-files/fixtures/features/while_loop_with_break.fe +++ b/crates/test-files/fixtures/features/while_loop_with_break.fe @@ -1,6 +1,6 @@ contract Foo { pub fn bar() -> u256 { - let val: u256 = 0 + let mut val: u256 = 0 while val < 2 { val = val + 1 break 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 e27f106540..ec6d1a54ef 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,6 +1,6 @@ contract Foo { pub fn bar() -> u256 { - let val: u256 = 0 + let mut val: u256 = 0 while val < 2 { val = val + 1 if val == 1 { 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 8823bbf924..a3c68fce48 100644 --- a/crates/test-files/fixtures/features/while_loop_with_continue.fe +++ b/crates/test-files/fixtures/features/while_loop_with_continue.fe @@ -1,7 +1,7 @@ contract Foo { pub fn bar() -> u256 { - let i: u256 = 0 - let counter: u256 = 0 + let mut i: u256 = 0 + let mut counter: u256 = 0 while i < 2 { i = i + 1 if i == 1 { diff --git a/crates/test-files/fixtures/stress/abi_encoding_stress.fe b/crates/test-files/fixtures/stress/abi_encoding_stress.fe index 0c1e913955..cf2e16e516 100644 --- a/crates/test-files/fixtures/stress/abi_encoding_stress.fe +++ b/crates/test-files/fixtures/stress/abi_encoding_stress.fe @@ -24,7 +24,7 @@ contract Foo { my_bytes: Array } - pub fn set_my_addrs(self, my_addrs: Array) { + pub fn set_my_addrs(mut self, my_addrs: Array) { self.my_addrs = my_addrs } @@ -32,7 +32,7 @@ contract Foo { return self.my_addrs.to_mem() } - pub fn set_my_u128(self, my_u128: u128) { + pub fn set_my_u128(mut self, my_u128: u128) { self.my_u128 = my_u128 } @@ -40,7 +40,7 @@ contract Foo { return self.my_u128 } - pub fn set_my_string(self, my_string: String<10>) { + pub fn set_my_string(mut self, my_string: String<10>) { self.my_string = my_string } @@ -48,7 +48,7 @@ contract Foo { return self.my_string.to_mem() } - pub fn set_my_u16s(self, my_u16s: Array) { + pub fn set_my_u16s(mut self, my_u16s: Array) { self.my_u16s = my_u16s } @@ -56,7 +56,7 @@ contract Foo { return self.my_u16s.to_mem() } - pub fn set_my_bool(self, my_bool: bool) { + pub fn set_my_bool(mut self, my_bool: bool) { self.my_bool = my_bool } @@ -64,7 +64,7 @@ contract Foo { return self.my_bool } - pub fn set_my_bytes(self, my_bytes: Array) { + pub fn set_my_bytes(mut self, my_bytes: Array) { self.my_bytes = my_bytes } @@ -76,7 +76,7 @@ contract Foo { 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(mut my_struct: MyStruct) -> MyStruct { my_struct.my_num = 12341234 my_struct.my_num2 = u8(42) my_struct.my_bool = false @@ -84,7 +84,7 @@ contract Foo { return my_struct } - pub fn emit_my_event(self, ctx: Context) { + pub fn emit_my_event(self, mut 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 0b814aeaec..41995961e1 100644 --- a/crates/test-files/fixtures/stress/data_copying_stress.fe +++ b/crates/test-files/fixtures/stress/data_copying_stress.fe @@ -13,21 +13,21 @@ contract Foo { 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(mut 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(mut self) { self.my_string = self.my_other_string self.my_u256 = self.my_other_u256 } - pub fn multiple_references_shared_memory(my_array: Array) { - let my_2nd_array: Array = my_array - let my_3rd_array: Array = my_2nd_array + pub fn multiple_references_shared_memory(mut my_array: Array) { + let mut my_2nd_array: Array = my_array + let mut my_3rd_array: Array = my_2nd_array assert my_array[3] != 5 my_array[3] = 5 assert my_array[3] == 5 @@ -39,7 +39,7 @@ contract Foo { assert my_3rd_array[3] == 50 } - pub fn mutate_and_return(my_array: Array) -> Array { + pub fn mutate_and_return(mut my_array: Array) -> Array { my_array[3] = 5 return my_array } @@ -53,8 +53,8 @@ contract Foo { return my_array } - pub fn assign_my_nums_and_return(self) -> Array { - let my_nums_mem: Array + pub fn assign_my_nums_and_return(mut self) -> Array { + let mut my_nums_mem: Array self.my_nums[0] = 42 self.my_nums[1] = 26 self.my_nums[2] = 0 @@ -64,15 +64,15 @@ contract Foo { return my_nums_mem } - pub fn emit_my_event(self, ctx: Context) { + pub fn emit_my_event(self, mut 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(mut 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(mut self, my_addrs: Array) { self.my_addrs = my_addrs } diff --git a/crates/test-files/fixtures/stress/external_calls.fe b/crates/test-files/fixtures/stress/external_calls.fe index 78b5281404..b5c23353d7 100644 --- a/crates/test-files/fixtures/stress/external_calls.fe +++ b/crates/test-files/fixtures/stress/external_calls.fe @@ -12,7 +12,7 @@ contract Foo { return self.my_string.to_mem() } - pub fn set_my_string(self, some_string: String<100>) { + pub fn set_my_string(mut self, some_string: String<100>) { self.my_string = some_string } @@ -20,11 +20,11 @@ contract Foo { return self.my_tuple.to_mem() } - pub fn set_my_tuple(self, some_tuple: (u256, address)) { + pub fn set_my_tuple(mut 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(mut self, some_string: String<100>, some_tuple: (u256, address)) { self.my_string = some_string self.my_tuple = some_tuple } @@ -61,7 +61,7 @@ contract Foo { contract FooProxy { foo: Foo - pub fn __init__(self, foo_addr: address) { + pub fn __init__(mut self, foo_addr: address) { self.foo = Foo(foo_addr) } diff --git a/crates/test-files/fixtures/stress/tuple_stress.fe b/crates/test-files/fixtures/stress/tuple_stress.fe index 3958f33343..9a43e20bbe 100644 --- a/crates/test-files/fixtures/stress/tuple_stress.fe +++ b/crates/test-files/fixtures/stress/tuple_stress.fe @@ -27,11 +27,11 @@ contract Foo { return my_tuple.item10 } - pub fn emit_my_event(ctx: Context, my_tuple: (u256, bool, address)) { + pub fn emit_my_event(mut 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(mut 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) } @@ -40,7 +40,7 @@ contract Foo { return self.my_sto_tuple.to_mem() } - pub fn build_tuple_and_emit(self, ctx: Context) { + pub fn build_tuple_and_emit(self, mut 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)) emit_my_event(ctx, my_tuple) diff --git a/crates/tests/src/snapshots/fe_compiler_tests__demo_uniswap__uniswap_contracts.snap b/crates/tests/src/snapshots/fe_compiler_tests__demo_uniswap__uniswap_contracts.snap index 797759f9dd..c6e463da03 100644 --- a/crates/tests/src/snapshots/fe_compiler_tests__demo_uniswap__uniswap_contracts.snap +++ b/crates/tests/src/snapshots/fe_compiler_tests__demo_uniswap__uniswap_contracts.snap @@ -12,7 +12,7 @@ balanceOf([Address(0x0000000000000000000000000000000000000000)]) used 628 gas get_reserves([]) used 801 gas swap([Uint(1993), Uint(0), Address(0x0000000000000000000000000000000000000042)]) used 36368 gas get_reserves([]) used 801 gas -transfer([Address(0xfe56bcfd2347f902e355bce7d8616526aa5c064c), Uint(141421356237309503880)]) used 5802 gas +transfer([Address(0xc5992755e189b833002ff4dae0977fad561e1ae3), Uint(141421356237309503880)]) used 5802 gas burn([Address(0x1000000000000000000000000000000000000001)]) used 3650 gas get_reserves([]) used 801 gas