From 2ffc8f5ada01dbbf62df98bab1b7efa277ce5a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Fri, 13 Dec 2024 19:17:21 -0500 Subject: [PATCH] Solidity binding fixes driven by Sanctuary (#1149) This PR contains fixes to bindings for issues that were found by trying to resolve all references in Sanctuary, as well as test cases to verify them. It also improves documentation of the rules and improvements (renames and rearrangements) for readability. The built-in types are also standardized with a PascalCase naming convention. Most notably, it introduces extension scopes to support resolving attached function set via `using` directives. These extension scopes need to be accessible at any point during the resolution of a symbol stack if the originating reference is located in a lexical scope which is affected by a `using` directive. This forced a refactor of the lexical scope node structure, introducing a new `.extended_scope` available in nodes where references may need to resolve to attached functions (ie. function bodies, constant initialization expressions, etc.) Also, for Solidity < 0.7.0 `using` directives are inherited, so we need to propagate the new extension scopes for all sub-contracts relative to where the directive is located. The extension scope mechanism is implemented using the _jump to scope_ and scope stack features of the stack graphs. The extended scope would optionally push the extension scope for the current contract and then continue resolution through the normal lexical scope. This effectively doubles the search space in the graph when performing a resolution, and this happens every time we inject a new extension scope to the scope stack. This has the potential to exponentially increase the running times and memory requirements. This is a known caveat which will be addressed in a future PR. --- crates/metaslang/bindings/src/resolver/mod.rs | 19 +- .../inputs/language/bindings/rules.msgb | 1418 +++++++++++++---- .../inputs/language/src/definition.rs | 147 +- .../bindings/generated/binding_rules.rs | 1418 +++++++++++++---- .../generated/bindings/generated/built_ins.rs | 8 +- .../bindings/generated/built_ins/0.4.11.sol | 62 +- .../bindings/generated/built_ins/0.4.17.sol | 64 +- .../bindings/generated/built_ins/0.4.22.sol | 72 +- .../bindings/generated/built_ins/0.5.0.sol | 74 +- .../bindings/generated/built_ins/0.5.3.sol | 74 +- .../bindings/generated/built_ins/0.6.0.sol | 76 +- .../bindings/generated/built_ins/0.6.2.sol | 78 +- .../bindings/generated/built_ins/0.6.7.sol | 78 +- .../bindings/generated/built_ins/0.6.8.sol | 78 +- .../bindings/generated/built_ins/0.7.0.sol | 72 +- .../bindings/generated/built_ins/0.8.0.sol | 72 +- .../bindings/generated/built_ins/0.8.11.sol | 83 +- .../bindings/generated/built_ins/0.8.18.sol | 83 +- .../bindings/generated/built_ins/0.8.2.sol | 74 +- .../bindings/generated/built_ins/0.8.24.sol | 83 +- .../bindings/generated/built_ins/0.8.26.sol | 83 +- .../bindings/generated/built_ins/0.8.4.sol | 111 ++ .../bindings/generated/built_ins/0.8.7.sol | 77 +- .../bindings/generated/built_ins/0.8.8.sol | 116 ++ .../src/bindings_assertions/generated/mod.rs | 1 + .../bindings_assertions/generated/using.rs | 10 + .../src/bindings_output/generated/arrays.rs | 5 + .../bindings_output/generated/built_ins.rs | 15 + .../bindings_output/generated/contracts.rs | 75 + .../src/bindings_output/generated/errors.rs | 5 + .../bindings_output/generated/expressions.rs | 25 + .../bindings_output/generated/interfaces.rs | 5 + .../bindings_output/generated/libraries.rs | 20 + .../src/bindings_output/generated/mod.rs | 1 + .../src/bindings_output/generated/structs.rs | 5 + .../bindings_output/generated/user_types.rs | 10 + .../src/bindings_output/generated/using.rs | 75 + .../bindings_output/generated/variables.rs | 5 + .../src/bindings_output/generated/yul.rs | 20 + .../testing/perf/src/tests/definitions.rs | 7 +- .../testing/perf/src/tests/init_bindings.rs | 7 +- .../testing/perf/src/tests/references.rs | 8 +- .../bindings_assertions/using/inherited.sol | 16 + .../length/generated/0.4.11-success.txt | 33 + .../bindings_output/arrays/length/input.sol | 9 + .../address/generated/0.4.11-failure.txt | 5 + .../address/generated/0.5.0-success.txt | 5 + .../built_ins/address/input.sol | 1 + .../arrays/generated/0.4.11-success.txt | 111 +- .../arrays/generated/0.6.0-success.txt | 111 +- .../built_ins/arrays/input.sol | 10 - .../bytes/generated/0.4.11-success.txt | 51 + .../bindings_output/built_ins/bytes/input.sol | 14 + .../generated/0.4.11-failure.txt | 8 +- .../generated/0.4.21-failure.txt | 8 +- .../function_type/generated/0.8.4-success.txt | 8 +- .../functions/generated/0.4.11-failure.txt | 16 +- .../functions/generated/0.4.21-failure.txt | 16 +- .../functions/generated/0.4.22-failure.txt | 16 +- .../functions/generated/0.5.0-failure.txt | 16 +- .../functions/generated/0.8.13-failure.txt | 16 +- .../functions/generated/0.8.24-success.txt | 16 +- .../functions/generated/0.8.27-success.txt | 16 +- .../functions/generated/0.8.4-failure.txt | 16 +- .../this/generated/0.4.11-success.txt | 15 + .../bindings_output/built_ins/this/input.sol | 5 + .../generated/0.4.11-success.txt | 16 + .../generated/0.5.0-failure.txt | 16 + .../built_ins/this_as_address/input.sol | 6 + .../generated/0.4.11-failure.txt | 27 + .../generated/0.4.22-success.txt | 18 + .../constructor_call_parent/input.sol | 6 + .../generated/0.4.11-success.txt | 36 + .../contracts/inherited_state_vars/input.sol | 12 + .../generated/0.4.11-failure.txt | 13 + .../generated/0.6.0-success.txt | 41 + .../contracts/internal_visibility/input.sol | 13 + .../generated/0.4.11-success.txt | 20 + .../generated/0.5.0-failure.txt | 20 + .../contracts/legacy_constructors/input.sol | 5 + .../generated/0.4.11-success.txt | 35 + .../generated/0.7.0-failure.txt | 35 + .../legacy_function_options/input.sol | 9 + .../generated/0.4.11-success.txt | 38 + .../contracts/multi_inheritance/input.sol | 16 + .../generated/0.4.11-success.txt | 30 + .../contracts/public_array_getters/input.sol | 8 + .../generated/0.4.11-success.txt | 30 + .../contracts/public_getter_members/input.sol | 8 + .../generated/0.4.11-success.txt | 4 +- .../generated/0.4.11-success.txt | 35 + .../public_inherited_getter/input.sol | 12 + .../generated/0.4.11-success.txt | 30 + .../public_mapping_getters/input.sol | 8 + .../generated/0.4.11-success.txt | 37 + .../contracts/public_struct_getter/input.sol | 9 + .../generated/0.4.11-success.txt | 26 + .../contracts/qualified_inherited/input.sol | 8 + .../generated/0.4.11-success.txt | 31 + .../contracts/qualified_parent_call/input.sol | 9 + .../super_deep/generated/0.4.11-success.txt | 29 + .../contracts/super_deep/input.sol | 9 + .../generated/0.4.11-success.txt | 12 +- .../super_scope/generated/0.4.16-failure.txt | 4 +- .../super_scope/generated/0.6.0-success.txt | 4 +- .../this_scope/generated/0.4.11-success.txt | 4 +- .../generated/0.4.11-success.txt | 13 + .../generated/0.4.22-success.txt | 13 + .../generated/0.6.0-failure.txt | 19 + .../generated/0.6.5-failure.txt | 19 + .../generated/0.8.27-failure.txt | 19 + .../contracts/unnamed_function/input.sol | 5 + .../generated/0.4.16-failure.txt | 4 +- .../generated/0.6.0-success.txt | 4 +- .../selector/generated/0.4.11-failure.txt | 31 + .../selector/generated/0.8.4-success.txt | 21 + .../bindings_output/errors/selector/input.sol | 7 + .../generated/0.4.11-success.txt | 100 ++ .../expressions/binary_operators/input.sol | 21 + .../generated/0.4.11-failure.txt | 40 + .../generated/0.4.21-failure.txt | 40 + .../generated/0.5.0-failure.txt | 40 + .../generated/0.5.3-failure.txt | 40 + .../generated/0.6.0-success.txt | 38 + .../expressions/elementary_casting/input.sol | 13 + .../generated/0.4.11-success.txt | 35 + .../generated/0.7.0-failure.txt | 35 + .../expressions/legacy_call_options/input.sol | 7 + .../generated/0.4.11-success.txt | 19 + .../expressions/literal_address/input.sol | 5 + .../generated/0.4.11-success.txt | 27 + .../expressions/literal_integers/input.sol | 9 + .../generated/0.4.11-success.txt | 23 + .../interfaces/own_types_access/input.sol | 6 + .../constants/generated/0.4.11-success.txt | 34 + .../libraries/constants/input.sol | 14 + .../modifiers/generated/0.4.11-success.txt | 21 + .../libraries/modifiers/input.sol | 6 + .../generated/0.4.11-failure.txt | 38 + .../generated/0.4.22-failure.txt | 38 + .../generated/0.8.4-success.txt | 19 + .../libraries/modifiers_scope/input.sol | 7 + .../generated/0.4.11-success.txt | 49 + .../propagate_dynamic_scope/input.sol | 13 + .../generated/0.4.11-success.txt | 31 + .../structs/function_call/input.sol | 9 + .../wrap_unwrap/generated/0.4.11-failure.txt | 13 + .../wrap_unwrap/generated/0.6.0-failure.txt | 13 + .../wrap_unwrap/generated/0.7.1-failure.txt | 13 + .../wrap_unwrap/generated/0.7.4-failure.txt | 13 + .../wrap_unwrap/generated/0.8.0-failure.txt | 13 + .../wrap_unwrap/generated/0.8.4-failure.txt | 13 + .../wrap_unwrap/generated/0.8.8-success.txt | 36 + .../user_types/wrap_unwrap/input.sol | 8 + .../address/generated/0.4.11-failure.txt | 35 + .../address/generated/0.4.21-failure.txt | 35 + .../using/address/generated/0.5.0-failure.txt | 35 + .../using/address/generated/0.5.3-failure.txt | 35 + .../using/address/generated/0.6.0-success.txt | 31 + .../bindings_output/using/address/input.sol | 9 + .../casting/generated/0.4.11-success.txt | 41 + .../bindings_output/using/casting/input.sol | 11 + .../generated/0.4.11-success.txt | 78 + .../using/chained_calls/input.sol | 17 + .../generated/0.4.11-success.txt | 44 + .../generated/0.7.0-failure.txt | 44 + .../using/inherit_extension/input.sol | 15 + .../generated/0.4.11-success.txt | 52 + .../using/inherited_types/input.sol | 15 + .../mappings/generated/0.4.11-success.txt | 32 + .../bindings_output/using/mappings/input.sol | 10 + .../generated/0.4.11-success.txt | 48 + .../generated/0.7.0-failure.txt | 48 + .../using/on_interfaces_inherited/input.sol | 14 + .../generated/0.4.11-success.txt | 38 + .../using/on_parameters/input.sol | 10 + .../generated/0.4.11-success.txt | 33 + .../on_state_var_initialization/input.sol | 8 + .../generated/0.4.11-success.txt | 38 + .../using/on_super_calls/input.sol | 12 + .../generated/0.4.11-success.txt | 49 + .../using/qualified_type/input.sol | 13 + .../using/star/generated/0.4.11-success.txt | 71 +- .../bindings_output/using/star/input.sol | 10 +- .../generated/0.4.11-success.txt | 33 + .../using/star_in_library/input.sol | 9 + .../generated/0.4.11-success.txt | 38 + .../generated/0.7.0-failure.txt | 38 + .../using/star_inherited/input.sol | 14 + .../uint_alias/generated/0.4.11-success.txt | 32 + .../using/uint_alias/input.sol | 10 + .../user_types/generated/0.4.11-failure.txt | 13 + .../user_types/generated/0.6.0-failure.txt | 13 + .../user_types/generated/0.7.1-failure.txt | 13 + .../user_types/generated/0.7.4-failure.txt | 13 + .../user_types/generated/0.8.0-failure.txt | 13 + .../user_types/generated/0.8.4-failure.txt | 13 + .../user_types/generated/0.8.8-success.txt | 67 + .../using/user_types/input.sol | 18 + .../generated/0.4.11-success.txt | 31 + .../generated/0.5.0-failure.txt | 31 + .../generated/0.5.3-failure.txt | 31 + .../generated/0.6.0-failure.txt | 31 + .../generated/0.7.0-failure.txt | 31 + .../generated/0.8.0-failure.txt | 31 + .../generated/0.8.4-failure.txt | 31 + .../variables/var_declaration/input.sol | 7 + .../generated/0.4.11-failure.txt | 67 + .../generated/0.6.0-failure.txt | 67 + .../generated/0.7.1-failure.txt | 67 + .../generated/0.7.4-success.txt | 63 + .../constant_access_from_functions/input.sol | 27 + .../generated/0.4.11-failure.txt | 26 + .../generated/0.4.12-failure.txt | 26 + .../generated/0.5.0-failure.txt | 26 + .../generated/0.5.8-success.txt | 21 + .../generated/0.7.0-failure.txt | 26 + .../generated/0.8.18-failure.txt | 26 + .../generated/0.8.24-failure.txt | 26 + .../generated/0.8.7-failure.txt | 26 + .../yul/identifiers_with_dots/input.sol | 8 + .../generated/0.4.11-success.txt | 30 + .../generated/0.5.8-failure.txt | 26 + .../generated/0.7.0-success.txt | 30 + .../yul/slot_offset_members/input.sol | 9 + .../slot_suffix/generated/0.4.11-success.txt | 26 + .../slot_suffix/generated/0.7.0-failure.txt | 26 + .../bindings_output/yul/slot_suffix/input.sol | 9 + 228 files changed, 7669 insertions(+), 1621 deletions(-) create mode 100644 crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.4.sol create mode 100644 crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.8.sol create mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/using.rs create mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_output/generated/user_types.rs create mode 100644 crates/solidity/testing/snapshots/bindings_assertions/using/inherited.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/arrays/length/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/built_ins/bytes/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/built_ins/bytes/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/built_ins/this/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/built_ins/this/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.5.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/generated/0.4.22-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/inherited_state_vars/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/inherited_state_vars/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/generated/0.6.0-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.5.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/generated/0.7.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/multi_inheritance/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/multi_inheritance/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/public_inherited_getter/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/public_inherited_getter/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.4.22-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.6.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.6.5-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.8.27-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/errors/selector/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/errors/selector/generated/0.8.4-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/errors/selector/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/binary_operators/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/binary_operators/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.21-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.3-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.6.0-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.7.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/literal_address/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/literal_address/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/interfaces/own_types_access/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/interfaces/own_types_access/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/libraries/constants/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/libraries/constants/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.4.22-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.8.4-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/libraries/propagate_dynamic_scope/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/libraries/propagate_dynamic_scope/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/structs/function_call/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/structs/function_call/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.6.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.7.1-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.7.4-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.4-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.8-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.4.21-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.5.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.5.3-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.6.0-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/address/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/casting/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/casting/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/chained_calls/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/chained_calls/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/generated/0.7.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/inherited_types/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/inherited_types/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/mappings/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/mappings/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.7.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/on_parameters/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/on_parameters/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/on_state_var_initialization/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/on_state_var_initialization/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/on_super_calls/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/on_super_calls/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/qualified_type/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/qualified_type/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/star_in_library/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/star_in_library/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/star_inherited/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/star_inherited/generated/0.7.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/star_inherited/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/uint_alias/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/uint_alias/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.6.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.7.1-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.7.4-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.4-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.8-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/user_types/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.5.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.5.3-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.6.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.7.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.8.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.8.4-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.6.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.7.1-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.7.4-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.4.12-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.5.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.5.8-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.7.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.18-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.24-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.7-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.5.8-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.7.0-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.7.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/input.sol diff --git a/crates/metaslang/bindings/src/resolver/mod.rs b/crates/metaslang/bindings/src/resolver/mod.rs index 46a92cdc0f..57c0caf305 100644 --- a/crates/metaslang/bindings/src/resolver/mod.rs +++ b/crates/metaslang/bindings/src/resolver/mod.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use std::iter::once; use metaslang_cst::kinds::KindTypes; @@ -76,19 +76,28 @@ impl<'a, KT: KindTypes + 'static> Resolver<'a, KT> { ) .expect("should never be cancelled"); + let mut added_nodes = HashSet::new(); for reference_path in &reference_paths { - if reference_paths - .iter() - .all(|other| !other.shadows(&mut self.partials, reference_path)) + let end_node = reference_path.end_node; + + // Because of how we're using the scope stack to propagate dynamic + // scopes, we may get multiple results with different scope stack + // postconditions but reaching the exact same definition. We only + // care about the definition, so we check for uniqueness. + if !added_nodes.contains(&end_node) + && reference_paths + .iter() + .all(|other| !other.shadows(&mut self.partials, reference_path)) { self.results.push(ResolvedPath { definition: self .owner - .to_definition(reference_path.end_node) + .to_definition(end_node) .expect("path to end in a definition node"), partial_path: reference_path.clone(), score: 0.0, }); + added_nodes.insert(end_node); } } } diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 0e341a683b..0a4b6e4913 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -21,6 +21,12 @@ inherit .enclosing_def inherit .parent_scope inherit .lexical_scope +inherit .extended_scope + +; Used to resolve extension methods for `using for *` directives +; This is used as a minor optimization to avoid introducing new possible paths +; when there are no `using for *` directives in the contract. +inherit .star_extension ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -62,14 +68,25 @@ inherit .lexical_scope ;; inherited) for contracts to resolve bases (both in inheritance lists and ;; override specifiers) let @source_unit.parent_scope = @source_unit.lexical_scope + ; FIXME: we probably need to make extended scope different than lexical scope + ; and push an extension scope on that path + let @source_unit.extended_scope = @source_unit.lexical_scope + + ; We may jump to scope here to resolve using the extensions scope provided by + ; contract/libraries that contain `using` directives + edge @source_unit.lexical_scope -> JUMP_TO_SCOPE_NODE + + ; Provide a default star extension sink node that gets inherited. This is + ; connected to from expressions, and those can potentially happen anywhere. + node @source_unit.star_extension } ;; Top-level definitions... @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @unit_member ( [ContractDefinition] - | [InterfaceDefinition] | [LibraryDefinition] + | [InterfaceDefinition] | [StructDefinition] | [EnumDefinition] | [FunctionDefinition] @@ -79,11 +96,25 @@ inherit .lexical_scope | [EventDefinition] )] ]] { - edge @unit_member.lexical_scope -> @source_unit.lexical_scope edge @source_unit.lexical_scope -> @unit_member.def edge @source_unit.defs -> @unit_member.def + + ; In the general case, the lexical scope of the definition connects directly + ; to the source unit's + edge @unit_member.lexical_scope -> @source_unit.lexical_scope +} + +;; Definitions that need to resolve expressions do it through an extended_scope +@source_unit [SourceUnit [SourceUnitMembers + [SourceUnitMember @unit_member ( + [FunctionDefinition] + | [ConstantDefinition] + )] +]] { + edge @unit_member.extended_scope -> @source_unit.extended_scope } + ;; Special case for built-ins: we want to export all symbols in the contract: ;; functions, types and state variables. All built-in symbols are defined in an ;; internal contract named '%BuiltIns%' (renamed from '$BuiltIns$') so we need @@ -94,13 +125,14 @@ inherit .lexical_scope [SourceUnitMember @contract [ContractDefinition name: ["%BuiltIns%"]]] ]] { if (is-system-file FILE_PATH) { - edge @source_unit.defs -> @contract.members - edge @source_unit.defs -> @contract.type_members - edge @source_unit.defs -> @contract.state_vars + edge @source_unit.defs -> @contract.instance } } @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @using [UsingDirective]]]] { + ; TODO: this is the hook for top-level extensions, but this should connect to + ; an extensions scope that gets pushed to the scope stack, as in the case of + ; contracts/libraries (defined further down below). edge @source_unit.lexical_scope -> @using.def } @@ -111,7 +143,7 @@ inherit .lexical_scope edge @source_unit.defs -> @using.def } -;; ... and imports +;; Import connections to the source unit @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember [ImportDirective [ImportClause @import ( @@ -250,28 +282,41 @@ inherit .lexical_scope ;; interface), aka the source unit edge @type_name.push_end -> heir.parent_scope - ;; Make base members accesible as our own members - node member - attr (member) push_symbol = "." - - node typeof - attr (typeof) push_symbol = "@typeof" - - edge heir.members -> member - edge member -> typeof - edge typeof -> @type_name.push_begin - - ;; Make base defs (eg. enums and structs) accessible as our own - node type_member - attr (type_member) push_symbol = "." - - edge heir.type_members -> type_member - edge type_member -> @type_name.push_begin - - ; Resolve the "super" keyword to the inherited type - edge heir.super -> @type_name.push_begin + ; Access instance members of the inherited contract/interface, from the + ; instance scope of the inheriting contract/interface + node instance + attr (instance) push_symbol = "@instance" + edge heir.instance -> instance + edge instance -> @type_name.push_begin + + ; Base members can also be accessed (from the instance scope) qualified with + ; the base name (eg. `Base.something`) + node member_pop + attr (member_pop) pop_symbol = "." + edge heir.instance -> @type_name.pop_begin + edge @type_name.pop_end -> member_pop + edge member_pop -> instance + + ; Base namespace-like members (ie. enums, structs, etc) are also accessible as + ; our own namespace members + node ns_member + attr (ns_member) push_symbol = "." + edge heir.ns -> ns_member + edge ns_member -> @type_name.push_begin + + if (version-matches "< 0.7.0") { + ; `using` directives are inherited in Solidity < 0.7.0, so connect them to + ; our own extensions scope + node extensions_push_guard + attr (extensions_push_guard) push_symbol = "@extensions" + edge heir.extensions -> extensions_push_guard + edge extensions_push_guard -> @type_name.push_begin + } } +;; The next couple of rules setup a `.parent_refs` attribute to use in the +;; resolution algorithm to perform linearisation of a contract hierarchy. + ;; NOTE: we use anchors here to prevent the query engine from returning all the ;; sublists of possible parents @specifier [InheritanceSpecifier [InheritanceTypes . @parents [_]+ .]] { @@ -294,38 +339,34 @@ inherit .lexical_scope ;;; Contracts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@contract [ContractDefinition] { +@contract [ContractDefinition @name name: [Identifier]] { node @contract.lexical_scope - node @contract.super_scope + node @contract.extended_scope + node @contract.extensions node @contract.def node @contract.members - node @contract.type_members + node @contract.ns node @contract.modifiers - node @contract.state_vars + node @contract.instance - edge @contract.lexical_scope -> @contract.members - edge @contract.lexical_scope -> @contract.type_members - edge @contract.lexical_scope -> @contract.state_vars + attr (@contract.def) node_definition = @name + attr (@contract.def) definiens_node = @contract - ;; Modifiers are available as a contract type members through a special '@modifier' symbol - node modifier - attr (modifier) pop_symbol = "@modifier" - edge @contract.type_members -> modifier - edge modifier -> @contract.modifiers + edge @contract.lexical_scope -> @contract.instance - let @contract.enclosing_def = @contract.def -} + ; Instance scope can also see members and our namespace definitions + edge @contract.instance -> @contract.members + edge @contract.instance -> @contract.ns -@contract [ContractDefinition @name name: [Identifier]] { - attr (@contract.def) node_definition = @name - attr (@contract.def) definiens_node = @contract + let @contract.enclosing_def = @contract.def - ;; "instance" like access path - ;; we have two distinct paths: @typeof -> . for accesses to variables of the contract's type - ;; and () -> . for accesses through a `new` invocation (or casting) + ;; External "instance" scope access: either member access through a variable + ;; of the contract's type, or through calling (which happens on `new` + ;; invocations or casting). These should access only externally accessible + ;; members, such as functions and public variables. node member attr (member) pop_symbol = "." - edge member -> @contract.members + edge member -> @contract.instance node type_def attr (type_def) pop_symbol = "@typeof" @@ -337,81 +378,154 @@ inherit .lexical_scope edge @contract.def -> call edge call -> member - ;; "namespace" like access path - node type_member - attr (type_member) pop_symbol = "." - edge @contract.def -> type_member - edge type_member -> @contract.type_members - - ;; Define "this" and connect it to the contract definition + ;; "namespace" scope access + node ns_member + attr (ns_member) pop_symbol = "." + edge @contract.def -> ns_member + edge ns_member -> @contract.ns + + ; Finally there's an @instance guarded path used by derived contracts to + ; access instance accessible members + node instance + attr (instance) pop_symbol = "@instance" + edge @contract.def -> instance + edge instance -> @contract.instance + + ; "this" keyword is available in our lexical scope and can access any + ; externally available member node this attr (this) pop_symbol = "this" - edge this -> member - - ;; ... and make it available in the contract's lexical scope edge @contract.lexical_scope -> this + edge this -> member - ; Resolve the "this" keyword to the contract itself - node name_push - attr (name_push) push_symbol = (source-text @name) - edge this -> name_push - edge name_push -> @contract.lexical_scope - - ;; Define "super" effectively as if it was a state variable of a type connected by our super_scope - ;; super_scope will later connect to the base contract defs directly - node @contract.super - attr (@contract.super) pop_symbol = "super" - - node super_typeof - attr (super_typeof) push_symbol = "@typeof" - - edge @contract.super -> super_typeof - edge super_typeof -> @contract.super_scope - - ;; Finally make "super" available in the contract's lexical scope for function bodies to use - edge @contract.lexical_scope -> @contract.super - - ; NOTE: The keyword "super" itself resolves to each of its parent contracts. - ; See the related rules in the InheritanceSpecifier section above. + ;; Modifiers are available as a contract type members through a special '@modifier' guard + node modifier + attr (modifier) pop_symbol = "@modifier" + edge @contract.ns -> modifier + edge modifier -> @contract.modifiers - ;; This defines the sink of edges added from base contracts when setting this - ;; contract as the compilation context - attr (@contract.def) export_node = @contract.members + ; There may be attached functions to our type. For the general case of + ; variables of our type, that's already handled via normal lexical scope + ; resolution. But for casting/`new` invocations that we resolve through the + ; `()` guard above, we need to explicitly jump to the extension scope from + ; here to attempt resolving the attached function. We cannot jump back to the + ; parent scope because that would create a cycle in the graph. + node push_typeof + attr (push_typeof) push_symbol = "@typeof" + node push_name + attr (push_name) push_symbol = (source-text @name) + edge call -> push_typeof + edge push_typeof -> push_name + edge push_name -> JUMP_TO_SCOPE_NODE - ;; This node will eventually connect to the contract's members being compiled - ;; and grants access to definitions in that contract and all its parents - ;; (recursively) - node super_import - attr (super_import) pop_symbol = "." - edge @contract.super -> super_import + if (version-matches "< 0.5.0") { + ; For Solidity < 0.5.0 `this` also acts like an `address` + node address_ref + attr (address_ref) push_symbol = "%address" + node address_typeof + attr (address_typeof) push_symbol = "@typeof" + edge this -> address_typeof + edge address_typeof -> address_ref + edge address_ref -> @contract.lexical_scope + } - ;; This defines the source side of edges added to base contracts when setting - ;; a contract as compilation context; this allows this contract (a base) to - ;; access virtual methods in any sub-contract defined in the hierarchy - attr (@contract.def) import_nodes = [@contract.lexical_scope, super_import] + ; This is the connection point to resolve attached functions by `using for *` + node @contract.star_extension + attr (@contract.star_extension) push_symbol = "@*" + + if (version-matches "< 0.7.0") { + ; Expose extensions through an `@extensions` guard on Solidity < 0.7.0 so + ; that they can be accessed from sub contract extension scopes + node extensions_guard + attr (extensions_guard) pop_symbol = "@extensions" + edge @contract.def -> extensions_guard + edge extensions_guard -> @contract.extensions + + ; Since using directives are inherited, we need to *always* connect the push + ; extensions to the extended scope, regardless of whether this contract + ; contains any `using` directive. + edge @contract.extended_scope -> @contract.push_extensions + + ; For Solidity < 0.7.0 using directives are inherited, so we need to connect + ; always For newer versions, this connection only happens when there is a + ; `using for *` directive in the contract (see rule below) + edge @contract.star_extension -> @contract.extended_scope + } ; Path to resolve the built-in type for type() expressions node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_contract_type - attr (type_contract_type) push_symbol = "%typeContractType" + attr (type_contract_type) push_symbol = "%ContractTypeType" edge @contract.def -> type edge type -> type_contract_type - edge type_contract_type -> @contract.lexical_scope + edge type_contract_type -> @contract.parent_scope + + ; The following defines the connection nodes the resolution algorithm uses + ; *only when setting a compilation context/target*. + + ; This attribute defines the sink of edges added from base contracts when + ; setting this contract as the compilation context, and should provide access + ; to anything that can be reached through `super`. The instance scope is a bit + ; too broad, but `.members` is too narrow as it doesn't allow navigation to + ; parent contracts (and from the base we need to be able to reach all + ; contracts in the hierarchy). + attr (@contract.def) export_node = @contract.instance + + ; This node will eventually connect to the contract's members being compiled + ; and grants access to definitions in that contract and all its parents + ; (recursively). It only makes sense if `super` is defined (ie. if we have + ; parents), but we define it here to be able to use it in the declaration of + ; import nodes. This is the dual of the export_node above. + node @contract.super_import + attr (@contract.super_import) pop_symbol = "." + + ; This defines the source side of edges added to base contracts when setting + ; a contract as compilation context; this allows this contract (a base) to + ; access virtual methods in any sub-contract defined in the hierarchy (both + ; with and without `super`, hence the two connection points). + attr (@contract.def) import_nodes = [@contract.lexical_scope, @contract.super_import] } @contract [ContractDefinition @specifier [InheritanceSpecifier]] { + ; The `.heir` scoped variable allows the rules for `InheritanceSpecifier` + ; above to connect the instance scope of this contract to the parents. let @specifier.heir = @contract attr (@contract.def) parents = @specifier.parent_refs + + ; The rest of these statements deal with defining and connecting the `super` + ; keyword path. + + ; `super_scope` is where we hook all references to our parent contracts + node @contract.super_scope + + ; Define "super" in the lexical scope + node @contract.super + attr (@contract.super) pop_symbol = "super" + edge @contract.lexical_scope -> @contract.super + + ; This connects `super` to exported scopes from all contracts in the hierarchy + ; when setting a contract compilation target (see more detailed description + ; above on the definition of the `super_import` node). + edge @contract.super -> @contract.super_import + + ; Then connect it through an `@instance` guard to the parent contracts through + ; `super_scope`. This allows "instance"-like access to members of parents + ; through `super`. + node super_instance + attr (super_instance) push_symbol = "@instance" + edge @contract.super_import -> super_instance + edge super_instance -> @contract.super_scope } @contract [ContractDefinition [InheritanceSpecifier [InheritanceTypes [InheritanceType @type_name [IdentifierPath]] ]]] { - ;; The base contract defs are directly accesible through our special super scope + ;; The base contract defs are directly accesible through our super scope edge @contract.super_scope -> @type_name.push_begin } +; Pure definitions that cannot contain expressions @contract [ContractDefinition [ContractMembers [ContractMember @member ( [EnumDefinition] @@ -419,21 +533,39 @@ inherit .lexical_scope | [EventDefinition] | [ErrorDefinition] | [UserDefinedValueTypeDefinition] - | [FunctionDefinition] + )] +]] { + edge @member.lexical_scope -> @contract.lexical_scope +} + +; Definitions that can contain expressions need two scopes: +; - normal lexical scope for resolving types +; - extended scope (extended by using directives) for resolving expressions +@contract [ContractDefinition [ContractMembers + [ContractMember @member ( + [FunctionDefinition] | [ConstructorDefinition] - | [StateVariableDefinition] | [ModifierDefinition] | [FallbackFunctionDefinition] | [ReceiveFunctionDefinition] + | [UnnamedFunctionDefinition] + | [StateVariableDefinition] )] ]] { edge @member.lexical_scope -> @contract.lexical_scope + edge @member.extended_scope -> @contract.extended_scope } @contract [ContractDefinition [ContractMembers [ContractMember @using [UsingDirective]] ]] { - edge @contract.lexical_scope -> @using.def + ; Hook the using definition in the extensions scope + edge @contract.extensions -> @using.def + + ; Connect the extensions push path (this can happen multiple times if there + ; are multiple `using` directives in the contract, but that's allowed by the + ; graph builder). + edge @contract.extended_scope -> @contract.push_extensions } @contract [ContractDefinition [ContractMembers @@ -445,13 +577,20 @@ inherit .lexical_scope | [UserDefinedValueTypeDefinition] )] ]] { - edge @contract.type_members -> @member.def + ; These definition go into the "namespace" scope and are accessible externally + ; via qualified naming (eg. `Contract.MyStruct`) + edge @contract.ns -> @member.def } @contract [ContractDefinition [ContractMembers [ContractMember @state_var [StateVariableDefinition]] ]] { - edge @contract.state_vars -> @state_var.def + ; State variables are available to derived contracts. + ; TODO: this also exposes private state variables to derived contracts, but we + ; can't easily filter them because we don't have negative assertions in our + ; query language (we would need to modify this query for anything *not* + ; containing a `PrivateKeyword` node) + edge @contract.instance -> @state_var.def } ;; Public state variables are also exposed as external member functions @@ -480,13 +619,15 @@ inherit .lexical_scope [FunctionAttributes [FunctionAttribute ([ExternalKeyword] | [PublicKeyword])]] ]] ]] { - ; public or external functions are also accessible through the contract type - edge @contract.type_members -> @function.def + ; Public or external functions are also accessible through the contract type + ; (to retrieve their `.selector` for example) + edge @contract.ns -> @function.def } @contract [ContractDefinition members: [ContractMembers [ContractMember @modifier [ModifierDefinition]] ]] { + ; Modifiers live in their own special scope edge @contract.modifiers -> @modifier.def ;; This may prioritize this definition (when there are multiple options) @@ -495,6 +636,15 @@ inherit .lexical_scope attr (@modifier.def) parents = [@contract.def] } +@contract [ContractDefinition [ContractMembers [ContractMember + [UsingDirective [UsingTarget [Asterisk]]] +]]] { + ; Connect the star extension node to the resolution extended scope if there is + ; a `using for *` directive in the contract + edge @contract.star_extension -> @contract.extended_scope +} + +; This applies to both state variables and function definitions @override [OverrideSpecifier [OverridePathsDeclaration [OverridePaths @base_ident [IdentifierPath] ]]] { @@ -507,26 +657,32 @@ inherit .lexical_scope ;;; Interfaces ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@interface [InterfaceDefinition] { +@interface [InterfaceDefinition @name name: [Identifier]] { node @interface.lexical_scope node @interface.def node @interface.members - node @interface.type_members - - edge @interface.lexical_scope -> @interface.members - edge @interface.lexical_scope -> @interface.type_members -} + node @interface.ns + node @interface.instance -@interface [InterfaceDefinition @name name: [Identifier]] { attr (@interface.def) node_definition = @name attr (@interface.def) definiens_node = @interface - ;; "instance" like access path - ;; we have two distinct paths: @typeof -> . for accesses to variables of the contract's type - ;; and () -> . for accesses through a `new` invocation (or casting) + edge @interface.lexical_scope -> @interface.instance + + ; Interfaces don't contain expressions (or `using` directives), so the + ; extended scope is the same as the lexical scope + let @interface.extended_scope = @interface.lexical_scope + ; The extensions node is required for the inheritance rules, but not used in interfaces + let @interface.extensions = (node) + + edge @interface.instance -> @interface.members + edge @interface.instance -> @interface.ns + + ;; External "instance" like access path, to access members of a variable of + ;; the interface's type or through a casting call. node member attr (member) pop_symbol = "." - edge member -> @interface.members + edge member -> @interface.instance node typeof attr (typeof) pop_symbol = "@typeof" @@ -538,28 +694,43 @@ inherit .lexical_scope edge @interface.def -> call edge call -> member + ; From a call we may need to resolve using the extensions scope, in case there's + ; a `using` directive on our type. This path ends up jumping to scope just to + ; handle that case. + node push_typeof + attr (push_typeof) push_symbol = "@typeof" + node push_name + attr (push_name) push_symbol = (source-text @name) + edge call -> push_typeof + edge push_typeof -> push_name + edge push_name -> JUMP_TO_SCOPE_NODE + ;; "namespace" like access path - node type_member - attr (type_member) pop_symbol = "." - edge @interface.def -> type_member - edge type_member -> @interface.type_members + node ns_member + attr (ns_member) pop_symbol = "." + edge @interface.def -> ns_member + edge ns_member -> @interface.ns + + ; Finally there's guarded `@instance` path used by derived contracts to access + ; instance accessible members + node instance + attr (instance) pop_symbol = "@instance" + edge @interface.def -> instance + edge instance -> @interface.instance ; Path to resolve the built-in type for type() expressions node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_interface_type - attr (type_interface_type) push_symbol = "%typeInterfaceType" + attr (type_interface_type) push_symbol = "%InterfaceTypeType" edge @interface.def -> type edge type -> type_interface_type - edge type_interface_type -> @interface.lexical_scope + edge type_interface_type -> @interface.parent_scope } @interface [InterfaceDefinition @specifier [InheritanceSpecifier]] { let @specifier.heir = @interface attr (@interface.def) parents = @specifier.parent_refs - - ; Define a dummy "super" node required by the rules for InheritanceSpecifier - node @interface.super } @interface [InterfaceDefinition [InterfaceMembers @@ -573,7 +744,7 @@ inherit .lexical_scope )] ]] { edge @member.lexical_scope -> @interface.lexical_scope - edge @interface.type_members -> @member.def + edge @interface.ns -> @member.def } ;; Allow references (eg. variables of the interface type) to the interface to @@ -581,14 +752,14 @@ inherit .lexical_scope @interface [InterfaceDefinition members: [InterfaceMembers item: [ContractMember @function variant: [FunctionDefinition]] ]] { - edge @function.lexical_scope -> @interface.lexical_scope edge @interface.members -> @function.def + edge @function.extended_scope -> @interface.extended_scope } [InterfaceDefinition [InterfaceMembers [ContractMember @using [UsingDirective]]]] { ; using directives are not allowed in interfaces, but the grammar allows them ; so we need to create an artificial node here to connect to created edges from - ; the internal nodes + ; the instance nodes let @using.lexical_scope = (node) } @@ -597,38 +768,47 @@ inherit .lexical_scope ;;; Libraries ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@library [LibraryDefinition] { +@library [LibraryDefinition @name name: [Identifier]] { node @library.lexical_scope + node @library.extended_scope + node @library.extensions node @library.def - node @library.members + node @library.ns + node @library.modifiers - edge @library.lexical_scope -> @library.members -} - -@library [LibraryDefinition @name name: [Identifier]] { attr (@library.def) node_definition = @name attr (@library.def) definiens_node = @library + edge @library.lexical_scope -> @library.ns + node member attr (member) pop_symbol = "." edge @library.def -> member + edge member -> @library.ns - edge member -> @library.members + ; Access to modifiers is guarded by a @modifier symbol + node modifier + attr (modifier) pop_symbol = "@modifier" + edge @library.ns -> modifier + edge modifier -> @library.modifiers ; Path to resolve the built-in type for type() expressions (same as contracts) node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_library_type - attr (type_library_type) push_symbol = "%typeContractType" + attr (type_library_type) push_symbol = "%ContractTypeType" edge @library.def -> type edge type -> type_library_type edge type_library_type -> @library.lexical_scope + + ; This is the connection point to resolve attached functions by `using for *` + node @library.star_extension + attr (@library.star_extension) push_symbol = "@*" } @library [LibraryDefinition [LibraryMembers [ContractMember @member ( - [FunctionDefinition] - | [EnumDefinition] + [EnumDefinition] | [StructDefinition] | [EventDefinition] | [ErrorDefinition] @@ -636,13 +816,82 @@ inherit .lexical_scope )] ]] { edge @member.lexical_scope -> @library.lexical_scope - edge @library.members -> @member.def + edge @library.ns -> @member.def +} + +@library [LibraryDefinition [LibraryMembers + [ContractMember @member ( + [FunctionDefinition] + | [StateVariableDefinition [StateVariableAttributes [StateVariableAttribute [ConstantKeyword]]]] + )] +]] { + edge @member.lexical_scope -> @library.lexical_scope + edge @member.extended_scope -> @library.extended_scope + edge @library.ns -> @member.def +} + +@library [LibraryDefinition [LibraryMembers + [ContractMember @modifier [ModifierDefinition]] +]] { + edge @library.modifiers -> @modifier.def + edge @modifier.lexical_scope -> @library.lexical_scope + edge @modifier.extended_scope -> @library.extended_scope } @library [LibraryDefinition [LibraryMembers [ContractMember @using [UsingDirective]] ]] { - edge @library.lexical_scope -> @using.def + ; Expose the using directive from the extensions scope + edge @library.extensions -> @using.def + + ; Connect the extensions push path + edge @library.extended_scope -> @library.push_extensions +} + +@library [LibraryDefinition [LibraryMembers [ContractMember + [UsingDirective [UsingTarget [Asterisk]]] +]]] { + ; Connect the star extension node to the resolution extended scope if there is + ; a `using for *` directive in the library + edge @library.star_extension -> @library.extended_scope +} + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Extensions scope rules +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; For contracts (and libraries) navigating to the source unit lexical scope +;; *also* needs to (optionally) propagate an extensions scope to be able to +;; correctly bind `using` attached functions. +@contract_or_library ([ContractDefinition] | [LibraryDefinition]) { + ; The `.extended_scope` resolution scope used by function bodies and other + ; expressions. From there we need to (optionally) push the extensions scope + ; (ie. `using` directives definitions) to the scope stack. + ; We will connect the path to push the extensions *if* the contract/library + ; has a `using` directive. Also, the extended scope links to the lexical scope + ; of the contract/library directly, regardless of whether there is a `using` + ; directive or not. + ; TODO: if we had a query negation operator to detect when there is no `using` + ; directive, could we avoid connecting directly when there are extensions? + edge @contract_or_library.extended_scope -> @contract_or_library.lexical_scope + + ; The .extensions node is where `using` directives will hook the definitions + attr (@contract_or_library.extensions) is_exported + + ; Now we define the path to push the .extensions scope into the scope stack. + ; We connect this to the extended scope only when there are extensions in the + ; contract/library. + node @contract_or_library.push_extensions + attr (@contract_or_library.push_extensions) push_scoped_symbol = "@extend" + attr (@contract_or_library.push_extensions) scope = @contract_or_library.extensions + node drop_scopes + attr (drop_scopes) type = "drop_scopes" + node pop_extensions + attr (pop_extensions) pop_scoped_symbol = "@extend" + + edge @contract_or_library.push_extensions -> drop_scopes + edge drop_scopes -> pop_extensions + edge pop_extensions -> @contract_or_library.lexical_scope } @@ -650,8 +899,11 @@ inherit .lexical_scope ;;; Using directives ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; The UsingDirective node requires the enclosing context to setup a -;; .lexical_scope scoped variable for it to resolve both targets and subjects. +;; The UsingDirective node requires the enclosing context to setup an +;; .extended_scope scoped variable for it to resolve both targets and subjects. +;; The resolution connects to the extended scope in order to (potentially) push +;; the same extension scope again, to resolve chained calls that all make use of +;; attached functions. @using [UsingDirective] { ; This node acts as a definition in the sense that provides an entry point @@ -659,14 +911,15 @@ inherit .lexical_scope ; target type node @using.def - ; This internal node connects the other end of the popping path starting at - ; .def and resolves for the library/functions in the directive + ; This internal node connects the definition side of the clause to the target + ; for resolution, and allows handling the multiple cases of `using` syntax + ; easily node @using.clause } @using [UsingDirective [UsingClause @id_path [IdentifierPath]]] { ; resolve the library to be used in the directive - edge @id_path.push_end -> @using.lexical_scope + edge @id_path.push_end -> @using.extended_scope ; because we're using the whole library, we don't need to "consume" the ; attached function (as when using the deconstruction syntax), but we still @@ -688,7 +941,7 @@ inherit .lexical_scope ]] ]]] { ; resolve the function to be used in the directive - edge @id_path.push_end -> @using.lexical_scope + edge @id_path.push_end -> @using.extended_scope node dot attr (dot) pop_symbol = "." @@ -704,13 +957,20 @@ inherit .lexical_scope ; pop the type symbols to connect to the attached function (via @using.clause) node typeof attr (typeof) pop_symbol = "@typeof" + node cast + attr (cast) pop_symbol = "()" - edge @using.def -> @type_name.pop_begin + ; We connect to all_pop_begin to be able to resolve both qualified and + ; unqualified instances of the target type + edge @using.def -> @type_name.all_pop_begin edge @type_name.pop_end -> typeof edge typeof -> @using.clause + edge @type_name.pop_end -> cast + edge cast -> @using.clause - ; resolve the target type of the directive - edge @type_name.type_ref -> @using.lexical_scope + ; resolve the target type of the directive on the extended scope so the + ; extension scope gets re-pushed + edge @type_name.type_ref -> @using.extended_scope } [ContractMember @using [UsingDirective [UsingTarget [Asterisk]]]] { @@ -726,7 +986,7 @@ inherit .lexical_scope ;;; Type names ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; TypeName nodes should define two scoped variables: +;; TypeName nodes should define these scoped variables: ;; ;; - @type_name.type_ref represents the node in the graph where we're ready to ;; resolve the type, and thus should generally be connected to a (lexical) @@ -735,12 +995,19 @@ inherit .lexical_scope ;; - @type_name.output represents the other end of the type and corresponds to a ;; state where the type has already been resolved so we can, for example ;; resolve its members (sink node, outside edges connect *to* here). +;; +;; - @type_name.pop_begin, @type_name.pop_end are used in a definition context, +;; ie. when we need to pop the type name symbol(s) from the symbol stack. +;; Additionally, @type_name.all_pop_begin links to each symbol in a typename +;; (ie. in an identifier path typename), which allows referring to a type both +;; qualified and unqualified. @type_name [TypeName @elementary [ElementaryType]] { let @type_name.type_ref = @elementary.ref let @type_name.output = @elementary.ref let @type_name.pop_begin = @elementary.pop let @type_name.pop_end = @elementary.pop + let @type_name.all_pop_begin = @elementary.pop } @type_name [TypeName @id_path [IdentifierPath]] { @@ -755,6 +1022,7 @@ inherit .lexical_scope let @type_name.pop_begin = @id_path.pop_begin let @type_name.pop_end = @id_path.pop_end + let @type_name.all_pop_begin = @id_path.all_pop_begin } @type_name [TypeName @type_variant ([ArrayTypeName] | [FunctionType])] { @@ -762,6 +1030,7 @@ inherit .lexical_scope let @type_name.output = @type_variant.output let @type_name.pop_begin = @type_variant.pop_begin let @type_name.pop_end = @type_variant.pop_end + let @type_name.all_pop_begin = @type_variant.pop_begin } @type_name [TypeName @mapping [MappingType]] { @@ -769,6 +1038,7 @@ inherit .lexical_scope let @type_name.output = @mapping.output let @type_name.pop_begin = @mapping.pop_begin let @type_name.pop_end = @mapping.pop_end + let @type_name.all_pop_begin = @mapping.pop_begin } @@ -783,76 +1053,130 @@ inherit .lexical_scope node @elementary.pop attr (@elementary.pop) pop_symbol = @elementary.symbol + + ; These variables are a bit redundant, but necessary to easily use elementary + ; types as mapping keys + let @elementary.pop_begin = @elementary.pop + let @elementary.pop_end = @elementary.pop + let @elementary.all_pop_begin = @elementary.pop + + let @elementary.push_begin = @elementary.ref + let @elementary.push_end = @elementary.ref } -@elementary [ElementaryType variant: [AddressType @address [AddressKeyword]]] { - let @elementary.symbol = (format "%{}" (source-text @address)) +@elementary [ElementaryType [AddressType]] { + let @elementary.symbol = "%address" } -@elementary [ElementaryType @keyword ( - [BoolKeyword] - | [ByteKeyword] - | [BytesKeyword] - | [StringKeyword] - | [IntKeyword] - | [UintKeyword] - | [FixedKeyword] - | [UfixedKeyword] -)] { +@elementary [ElementaryType [BoolKeyword]] { + let @elementary.symbol = "%bool" +} + +@elementary [ElementaryType [ByteKeyword]] { + let @elementary.symbol = "%byte" +} + +@elementary [ElementaryType @keyword [BytesKeyword]] { let @elementary.symbol = (format "%{}" (source-text @keyword)) } +@elementary [ElementaryType [StringKeyword]] { + let @elementary.symbol = "%string" +} + +@elementary [ElementaryType @keyword [IntKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "int") { + let @elementary.symbol = "%int256" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + +@elementary [ElementaryType @keyword [UintKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "uint") { + let @elementary.symbol = "%uint256" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + +@elementary [ElementaryType @keyword [FixedKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "fixed") { + let @elementary.symbol = "%fixed128x18" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + +@elementary [ElementaryType @keyword [UfixedKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "ufixed") { + let @elementary.symbol = "%ufixed128x18" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Mappings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@mapping [MappingType] { +@mapping [MappingType + [MappingKey [MappingKeyType @key_type ([IdentifierPath] | [ElementaryType])]] + [MappingValue @value_type [TypeName]] +] { node @mapping.lexical_scope node @mapping.output -} -@mapping [MappingType [MappingKey [MappingKeyType @key_ident [IdentifierPath]]]] { - ; resolve key type - edge @key_ident.push_end -> @mapping.lexical_scope -} - -@mapping [MappingType [MappingValue @value_type [TypeName]]] { - ; for mapping types we don't need to push the type itself, because we don't need it (yet) - ; ditto for the pop path, because a mapping type cannot be the target of a using directive + ; Define the pushing path of the mapping type + ; ValueType <- top of the symbol stack + ; KeyType + ; %mapping <- bottom of the symbol stack + node mapping + attr (mapping) push_symbol = "%Mapping" + edge @mapping.output -> mapping + edge mapping -> @key_type.push_begin + edge @key_type.push_end -> @value_type.output + + ; Both key and value types need to be resolved + edge @value_type.type_ref -> @mapping.lexical_scope + edge @key_type.push_end -> @mapping.lexical_scope - ; The mapping's type exposes the `%index` (ie. `[]`) operator that returns the value type - ; This is similar to arrays, only in that case we have a built-in type where - ; we can define an index function. For mappings we hard-code in the rules directly. + ; The mapping's type exposes the `[]` operator that returns the value type. node typeof_input attr (typeof_input) pop_symbol = "@typeof" - - node index_member - attr (index_member) pop_symbol = "." - node index - attr (index) pop_symbol = "%index" - node index_call - attr (index_call) pop_symbol = "()" + edge @mapping.output -> typeof_input node typeof_output attr (typeof_output) push_symbol = "@typeof" - - edge @mapping.output -> typeof_input - edge typeof_input -> index_member - edge index_member -> index - edge index -> index_call - edge index_call -> typeof_output edge typeof_output -> @value_type.output - ; resolve the value type through our scope - edge @value_type.type_ref -> @mapping.lexical_scope + node index + attr (index) pop_symbol = "[]" + edge typeof_input -> index + edge index -> typeof_output + + ; Special case for mapping public state variables: they can be called + ; like a function with a key, and it's effectively the same as indexing it. + node getter_call + attr (getter_call) pop_symbol = "@as_getter" + edge typeof_input -> getter_call + edge getter_call -> typeof_output + + ; Now we define the "definition" route (aka. the pop route), to use in `using` directives only + ; This is the reverse of the pushing path above (to the `.output` node) + node pop_mapping + attr (pop_mapping) pop_symbol = "%Mapping" - ; We use the value_type's definition path as our own because it's needed when - ; a mapping is the target of a `using` directive. It's not correct, but we - ; don't have the analog referencing path either. let @mapping.pop_begin = @value_type.pop_begin - let @mapping.pop_end = @value_type.pop_end + edge @value_type.pop_end -> @key_type.pop_begin + edge @key_type.pop_end -> pop_mapping + let @mapping.pop_end = pop_mapping } @@ -866,47 +1190,69 @@ inherit .lexical_scope } @array [ArrayTypeName [TypeName] index: [Expression]] { - let @array.type = "%arrayFixed" + let @array.type_symbol = "%FixedArray" } @array [ArrayTypeName [OpenBracket] . [CloseBracket]] { - let @array.type = "%array" + let @array.type_symbol = "%Array" } @array [ArrayTypeName @type_name [TypeName]] { - ; First define the normal, reference route: - - ; We first push the array type `%array`, which should connect to two distinct paths: - ; 1. the typed path, which will use a jump scope entry to resolve the element type - ; 2. the hard-coded path to connect to any `using` directive + ; Define the pushing path of the array type + ; ValueType <- top of the symbol stack + ; %array / %arrayFixed <- bottom of the symbol stack node array - attr (array) push_symbol = @array.type + attr (array) push_symbol = @array.type_symbol edge @array.output -> array + edge array -> @type_name.output - ; For the first path, we need to define a scope jump entry for resolving the element type of the array - node entry - attr (entry) is_exported - node element - attr (element) pop_symbol = "%element" - edge entry -> element - edge element -> @type_name.output + ; Resolve the value type itself + edge @type_name.type_ref -> @array.lexical_scope + ; And also the "type erased" array type so we can resolve built-in members + edge array -> @array.lexical_scope - ; And then the path itself - node params - attr (params) push_scoped_symbol = "<>", scope = entry - edge array -> params + ; Define the path to resolve index access (aka the `[]` operator) - ; Second path, for `using` directives - edge array -> @type_name.output + node typeof_input + attr (typeof_input) pop_symbol = "@typeof" + edge @array.output -> typeof_input - ; Finally, both ends connect to our lexical scope - edge params -> @array.lexical_scope - edge @type_name.type_ref -> @array.lexical_scope + node typeof_output + attr (typeof_output) push_symbol = "@typeof" + edge typeof_output -> @type_name.output + + node index + attr (index) pop_symbol = "[]" + edge typeof_input -> index + edge index -> typeof_output + + ; Special case for public state variables of type array: they can be called + ; like a function with an index, and it's effectively the same as indexing the + ; array. + node getter_call + attr (getter_call) pop_symbol = "@as_getter" + edge typeof_input -> getter_call + edge getter_call -> typeof_output + + ; Define the special `.push()` built-in that returns the element type (for Solidity >= 0.6.0) + if (version-matches ">= 0.6.0") { + node built_in_member + attr (built_in_member) pop_symbol = "." + node push_built_in + attr (push_built_in) pop_symbol = "push" + node built_in_call + attr (built_in_call) pop_symbol = "()" + + edge typeof_input -> built_in_member + edge built_in_member -> push_built_in + edge push_built_in -> built_in_call + edge built_in_call -> typeof_output + } ; Now we define the "definition" route (aka. the pop route), to use in `using` directives only ; This is essentially the reverse of the second path above node pop_array - attr (pop_array) pop_symbol = @array.type + attr (pop_array) pop_symbol = @array.type_symbol let @array.pop_begin = @type_name.pop_begin edge @type_name.pop_end -> pop_array @@ -921,10 +1267,10 @@ inherit .lexical_scope @ftype [FunctionType @attrs [FunctionTypeAttributes]] { ; Compute the built-in type of the function ; %functionExternal provides access to .selector and .address - var type = "%function" + var type_symbol = "%Function" scan (source-text @attrs) { "external" { - set type = "%functionExternal" + set type_symbol = "%ExternalFunction" } } @@ -934,14 +1280,14 @@ inherit .lexical_scope ; This path pushes the function type to the symbol stack ; TODO: add parameter and return types to distinguish between different function types node function_type - attr (function_type) push_symbol = type + attr (function_type) push_symbol = type_symbol edge @ftype.output -> function_type edge function_type -> @ftype.lexical_scope ; the pop path for the using directive node pop_function_type - attr (pop_function_type) pop_symbol = type + attr (pop_function_type) pop_symbol = type_symbol let @ftype.pop_begin = pop_function_type let @ftype.pop_end = pop_function_type @@ -958,8 +1304,9 @@ inherit .lexical_scope @ftype [FunctionType [ReturnsDeclaration [ParametersDeclaration [Parameters . @param [Parameter] .]] ]] { - ; variables of a function type type can be "called" and resolve to the type of - ; the return parameter + ; Variables of a function type type can be "called" and resolve to the type of + ; the return parameter. This is only valid if the function returns a single + ; value. node typeof attr (typeof) pop_symbol = "@typeof" @@ -986,14 +1333,22 @@ inherit .lexical_scope ;; @id_path.pop_end. ;; ;; NOTE: most of the time, and unless this identifier path is the target of a -;; using directive this path will not be used and will form a disconnected -;; graph component. We currently have no way of determining when this path is -;; necessary, so we always construct it. +;; using directive this second path will not be used and will form a +;; disconnected graph component. We currently have no way of determining when +;; this path is necessary, so we always construct it. ;; ;; Additionally the IdentifierPath defines another scoped variable ;; @id_path.rightmost_identifier which corresponds to the identifier in the last -;; position in the path, from left to right. Useful for the using directive to -;; be able to pop the name of the attached function. +;; position in the path, from left to right. This is used in the using directive +;; rules to be able to pop the name of the attached function. + +@id_path [IdentifierPath] { + ; This node connects to all parts of the path, for popping. This allows to + ; connect at any point of the path. Useful for `using` directives when the + ; target type is fully qualified but we want to resolve for the unqualified + ; name. + node @id_path.all_pop_begin +} @id_path [IdentifierPath @name [Identifier]] { node @name.ref @@ -1002,6 +1357,8 @@ inherit .lexical_scope node @name.pop attr (@name.pop) pop_symbol = (source-text @name) + + edge @id_path.all_pop_begin -> @name.pop } @id_path [IdentifierPath @name [Identifier] .] { @@ -1069,14 +1426,15 @@ inherit .lexical_scope } @function [FunctionDefinition @attrs [FunctionAttributes]] { - var function_type = "%function" + var type_symbol = "%Function" scan (source-text @attrs) { "\\b(public|external)\\b" { - set function_type = "%functionExternal" + set type_symbol = "%ExternalFunction" } } node @function.lexical_scope + node @function.extended_scope node @function.def ; this path from the function definition to the scope allows attaching @@ -1084,7 +1442,7 @@ inherit .lexical_scope node typeof attr (typeof) push_symbol = "@typeof" node type_function - attr (type_function) push_symbol = function_type + attr (type_function) push_symbol = type_symbol edge @function.def -> typeof edge typeof -> type_function edge type_function -> @function.lexical_scope @@ -1096,12 +1454,12 @@ inherit .lexical_scope } @function [FunctionDefinition @params parameters: [ParametersDeclaration]] { - edge @params.lexical_scope -> @function.lexical_scope + edge @params.lexical_scope -> @function.extended_scope ;; Input parameters are available in the function scope - edge @function.lexical_scope -> @params.defs + edge @function.extended_scope -> @params.defs ;; ... and shadow other declarations - attr (@function.lexical_scope -> @params.defs) precedence = 1 + attr (@function.extended_scope -> @params.defs) precedence = 1 ;; Connect to paramaters for named argument resolution edge @function.def -> @params.names @@ -1110,12 +1468,12 @@ inherit .lexical_scope @function [FunctionDefinition returns: [ReturnsDeclaration @return_params [ParametersDeclaration] ]] { - edge @return_params.lexical_scope -> @function.lexical_scope + edge @return_params.lexical_scope -> @function.extended_scope ;; Return parameters are available in the function scope - edge @function.lexical_scope -> @return_params.defs + edge @function.extended_scope -> @return_params.defs ;; ... and shadow other declarations - attr (@function.lexical_scope -> @return_params.defs) precedence = 1 + attr (@function.extended_scope -> @return_params.defs) precedence = 1 } ;; Only functions that return a single value have an actual return type @@ -1132,13 +1490,13 @@ inherit .lexical_scope ;; Connect the function body's block lexical scope to the function @function [FunctionDefinition [FunctionBody @block [Block]]] { - edge @block.lexical_scope -> @function.lexical_scope + edge @block.lexical_scope -> @function.extended_scope } @function [FunctionDefinition [FunctionAttributes item: [FunctionAttribute @modifier [ModifierInvocation] ]]] { - edge @modifier.lexical_scope -> @function.lexical_scope + edge @modifier.lexical_scope -> @function.extended_scope } @modifier [ModifierInvocation @name [IdentifierPath]] { @@ -1149,12 +1507,40 @@ inherit .lexical_scope edge @name.push_end -> modifier edge modifier -> @modifier.lexical_scope + + ; This allows resolving @name in the more general scope in constructors (since + ; calling a parent constructor is parsed as a modifier invocation) + let @modifier.identifier = @name.push_end } @modifier [ModifierInvocation @args [ArgumentsDeclaration]] { edge @args.lexical_scope -> @modifier.lexical_scope } +;;; Unnamed functions (deprecated) +@unnamed_function [UnnamedFunctionDefinition] { + node @unnamed_function.lexical_scope + node @unnamed_function.extended_scope +} + +@unnamed_function [UnnamedFunctionDefinition @params parameters: [ParametersDeclaration]] { + edge @params.lexical_scope -> @unnamed_function.extended_scope + + edge @unnamed_function.extended_scope -> @params.defs + attr (@unnamed_function.extended_scope -> @params.defs) precedence = 1 +} + +@unnamed_function [UnnamedFunctionDefinition [FunctionBody @block [Block]]] { + edge @block.lexical_scope -> @unnamed_function.extended_scope +} + +@unnamed_function [UnnamedFunctionDefinition + [UnnamedFunctionAttributes [UnnamedFunctionAttribute @modifier [ModifierInvocation]]] +] { + edge @modifier.lexical_scope -> @unnamed_function.lexical_scope +} + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Constructors @@ -1162,16 +1548,17 @@ inherit .lexical_scope @constructor [ConstructorDefinition] { node @constructor.lexical_scope + node @constructor.extended_scope node @constructor.def } @constructor [ConstructorDefinition @params parameters: [ParametersDeclaration]] { - edge @params.lexical_scope -> @constructor.lexical_scope + edge @params.lexical_scope -> @constructor.extended_scope ;; Input parameters are available in the constructor scope - edge @constructor.lexical_scope -> @params.defs + edge @constructor.extended_scope -> @params.defs ;; ... and shadow other declarations - attr (@constructor.lexical_scope -> @params.defs) precedence = 1 + attr (@constructor.extended_scope -> @params.defs) precedence = 1 ;; Connect to paramaters for named argument resolution edge @constructor.def -> @params.names @@ -1179,13 +1566,14 @@ inherit .lexical_scope ;; Connect the constructor body's block lexical scope to the constructor @constructor [ConstructorDefinition @block [Block]] { - edge @block.lexical_scope -> @constructor.lexical_scope + edge @block.lexical_scope -> @constructor.extended_scope } @constructor [ConstructorDefinition [ConstructorAttributes item: [ConstructorAttribute @modifier [ModifierInvocation] ]]] { - edge @modifier.lexical_scope -> @constructor.lexical_scope + edge @modifier.lexical_scope -> @constructor.extended_scope + edge @modifier.identifier -> @constructor.lexical_scope } @contract [ContractDefinition [ContractMembers [ContractMember @@ -1195,7 +1583,9 @@ inherit .lexical_scope edge @contract.def -> @constructor.def } -;; Solidity < 0.5.0 constructors were declared as functions of the contract's name +;; Solidity < 0.5.0 constructors +;; They were declared as functions of the contract's name + @contract [ContractDefinition @contract_name [Identifier] [ContractMembers [ContractMember [FunctionDefinition @@ -1211,6 +1601,21 @@ inherit .lexical_scope } } +[ContractDefinition + @contract_name [Identifier] + [ContractMembers [ContractMember @function [FunctionDefinition + [FunctionName @function_name [Identifier]] + [FunctionAttributes [FunctionAttribute @modifier [ModifierInvocation]]] + ]]] +] { + if (version-matches "< 0.5.0") { + if (eq (source-text @contract_name) (source-text @function_name)) { + ; Parent constructor calls are parsed as modifier invocations + edge @modifier.identifier -> @function.lexical_scope + } + } +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Fallback and receive functions @@ -1218,14 +1623,15 @@ inherit .lexical_scope @fallback [FallbackFunctionDefinition] { node @fallback.lexical_scope + node @fallback.extended_scope } @fallback [FallbackFunctionDefinition @params parameters: [ParametersDeclaration]] { - edge @params.lexical_scope -> @fallback.lexical_scope + edge @params.lexical_scope -> @fallback.extended_scope ;; Input parameters are available in the fallback function scope - edge @fallback.lexical_scope -> @params.defs - attr (@fallback.lexical_scope -> @params.defs) precedence = 1 + edge @fallback.extended_scope -> @params.defs + attr (@fallback.extended_scope -> @params.defs) precedence = 1 } @fallback [FallbackFunctionDefinition returns: [ReturnsDeclaration @@ -1234,12 +1640,12 @@ inherit .lexical_scope edge @return_params.lexical_scope -> @fallback.lexical_scope ;; Return parameters are available in the fallback function scope - edge @fallback.lexical_scope -> @return_params.defs - attr (@fallback.lexical_scope -> @return_params.defs) precedence = 1 + edge @fallback.extended_scope -> @return_params.defs + attr (@fallback.extended_scope -> @return_params.defs) precedence = 1 } @fallback [FallbackFunctionDefinition [FunctionBody @block [Block]]] { - edge @block.lexical_scope -> @fallback.lexical_scope + edge @block.lexical_scope -> @fallback.extended_scope } @fallback [FallbackFunctionDefinition [FallbackFunctionAttributes @@ -1250,10 +1656,11 @@ inherit .lexical_scope @receive [ReceiveFunctionDefinition] { node @receive.lexical_scope + node @receive.extended_scope } @receive [ReceiveFunctionDefinition [FunctionBody @block [Block]]] { - edge @block.lexical_scope -> @receive.lexical_scope + edge @block.lexical_scope -> @receive.extended_scope } @receive [ReceiveFunctionDefinition [ReceiveFunctionAttributes @@ -1270,6 +1677,7 @@ inherit .lexical_scope @modifier [ModifierDefinition] { node @modifier.def node @modifier.lexical_scope + node @modifier.extended_scope } @modifier [ModifierDefinition @@ -1279,7 +1687,7 @@ inherit .lexical_scope attr (@modifier.def) node_definition = @name attr (@modifier.def) definiens_node = @modifier - edge @body.lexical_scope -> @modifier.lexical_scope + edge @body.lexical_scope -> @modifier.extended_scope ; Special case: bind the place holder statement `_` to the built-in ; `%placeholder`. This only happens in the body of a modifier. @@ -1294,11 +1702,11 @@ inherit .lexical_scope } @modifier [ModifierDefinition @params [ParametersDeclaration]] { - edge @params.lexical_scope -> @modifier.lexical_scope + edge @params.lexical_scope -> @modifier.extended_scope ;; Input parameters are available in the modifier scope - edge @modifier.lexical_scope -> @params.defs - attr (@modifier.lexical_scope -> @params.defs) precedence = 1 + edge @modifier.extended_scope -> @params.defs + attr (@modifier.extended_scope -> @params.defs) precedence = 1 } @@ -1386,7 +1794,6 @@ inherit .lexical_scope @expr_stmt [ExpressionStatement] { node @expr_stmt.lexical_scope - node @expr_stmt.defs } @@ -1394,32 +1801,46 @@ inherit .lexical_scope @stmt [Statement @var_decl [VariableDeclarationStatement]] { edge @var_decl.lexical_scope -> @stmt.lexical_scope - edge @stmt.defs -> @var_decl.defs + edge @stmt.defs -> @var_decl.def } @var_decl [VariableDeclarationStatement] { node @var_decl.lexical_scope - node @var_decl.defs + node @var_decl.def } @var_decl [VariableDeclarationStatement [VariableDeclarationType @var_type [TypeName]] @name name: [Identifier] ] { - node def - attr (def) node_definition = @name - attr (def) definiens_node = @var_decl + attr (@var_decl.def) node_definition = @name + attr (@var_decl.def) definiens_node = @var_decl - edge @var_decl.defs -> def edge @var_type.type_ref -> @var_decl.lexical_scope node typeof attr (typeof) push_symbol = "@typeof" - edge def -> typeof + edge @var_decl.def -> typeof edge typeof -> @var_type.output } +@var_decl [VariableDeclarationStatement + [VariableDeclarationType [VarKeyword]] + @name name: [Identifier] +] { + attr (@var_decl.def) node_definition = @name + attr (@var_decl.def) definiens_node = @var_decl +} + +@var_decl [VariableDeclarationStatement + [VariableDeclarationType [VarKeyword]] + [VariableDeclarationValue @value [Expression]] +] { + edge @var_decl.def -> @value.output +} + + ;;; Tuple deconstruction statements @@ -1493,11 +1914,20 @@ inherit .lexical_scope ;; For loops @stmt [Statement [ForStatement - initialization: [ForStatementInitialization - @init_stmt ([ExpressionStatement] - | [VariableDeclarationStatement] - | [TupleDeconstructionStatement]) - ] + initialization: [ForStatementInitialization @init_stmt [ExpressionStatement]] +]] { + edge @init_stmt.lexical_scope -> @stmt.lexical_scope +} + +@stmt [Statement [ForStatement + initialization: [ForStatementInitialization @init_stmt [VariableDeclarationStatement]] +]] { + edge @init_stmt.lexical_scope -> @stmt.lexical_scope + edge @stmt.init_defs -> @init_stmt.def +} + +@stmt [Statement [ForStatement + initialization: [ForStatementInitialization @init_stmt [TupleDeconstructionStatement]] ]] { edge @init_stmt.lexical_scope -> @stmt.lexical_scope edge @stmt.init_defs -> @init_stmt.defs @@ -1635,6 +2065,7 @@ inherit .lexical_scope @state_var [StateVariableDefinition] { node @state_var.lexical_scope + node @state_var.extended_scope node @state_var.def } @@ -1647,11 +2078,36 @@ inherit .lexical_scope edge @type_name.type_ref -> @state_var.lexical_scope - node typeof - attr (typeof) push_symbol = "@typeof" + node @state_var.typeof + attr (@state_var.typeof) push_symbol = "@typeof" - edge @state_var.def -> typeof - edge typeof -> @type_name.output + edge @state_var.def -> @state_var.typeof + edge @state_var.typeof -> @type_name.output +} + +@state_var [StateVariableDefinition + [StateVariableAttributes [StateVariableAttribute [PublicKeyword]]] +] { + ; Public state variables are used as functions when invoked from an external contract + node call + attr (call) pop_symbol = "()" + + ; In the general case using the getter can bind to the state variable's type + edge @state_var.def -> call + edge call -> @state_var.typeof + + ; Some complex types generate special getters (ie. arrays and mappings index + ; their contents, structs flatten most of their fields and return a tuple) + node getter + attr (getter) push_symbol = "@as_getter" + edge call -> getter + edge getter -> @state_var.typeof +} + +@state_var [StateVariableDefinition + [StateVariableDefinitionValue @value [Expression]] +] { + let @value.lexical_scope = @state_var.extended_scope } @@ -1659,13 +2115,11 @@ inherit .lexical_scope ;;; Enum definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@enum [EnumDefinition] { +@enum [EnumDefinition @name name: [Identifier]] { node @enum.lexical_scope node @enum.def node @enum.members -} -@enum [EnumDefinition @name name: [Identifier]] { attr (@enum.def) node_definition = @name attr (@enum.def) definiens_node = @enum @@ -1677,9 +2131,9 @@ inherit .lexical_scope ; Path to resolve the built-in type for enums (which is the same as for integer types) node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_enum_type - attr (type_enum_type) push_symbol = "%typeIntType" + attr (type_enum_type) push_symbol = "%IntTypeType" edge @enum.def -> type edge type -> type_enum_type edge type_enum_type -> @enum.lexical_scope @@ -1700,73 +2154,61 @@ inherit .lexical_scope ;;; Structure definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@struct [StructDefinition] { +@struct [StructDefinition @name name: [Identifier]] { node @struct.lexical_scope node @struct.def node @struct.members -} -@struct [StructDefinition @name name: [Identifier]] { - ; Since we use structs to define built-in types and some of them (ie. array) - ; have have a parametric type, we define two distinct paths to define a - ; struct: - ; 1. the normal, non parametric path, should drop scopes in the scope stack first of all - ; 2. the parametric path, that pops a scope to resolve the parametric type - ; Both of these connect to the node that pops the struct identifier symbol - - ; First the normal path - node struct_drop - attr (struct_drop) type = "drop_scopes" - edge @struct.def -> struct_drop - - ; Second path, pops the scope - node typed_params - attr (typed_params) pop_scoped_symbol = "<>" - edge @struct.def -> typed_params - - ; Connect both to the struct identifier - node def - attr (def) node_definition = @name - attr (def) definiens_node = @struct - edge struct_drop -> def - edge typed_params -> def - - ; On the other end, to properly close the second path we need to jump to the popped scope - ; (this is why on the other path we drop scopes) - edge @struct.lexical_scope -> JUMP_TO_SCOPE_NODE + attr (@struct.def) node_definition = @name + attr (@struct.def) definiens_node = @struct ; Now connect normally to the struct members - node type_def - attr (type_def) pop_symbol = "@typeof" + node @struct.typeof + attr (@struct.typeof) pop_symbol = "@typeof" node member attr (member) pop_symbol = "." - edge def -> type_def - edge type_def -> member + edge @struct.def -> @struct.typeof + edge @struct.typeof -> member edge member -> @struct.members ; Bind member names when using construction with named arguments node param_names attr (param_names) pop_symbol = "@param_names" - edge def -> param_names + edge @struct.def -> param_names edge param_names -> @struct.members + + ; Used as a function call (ie. casting), should bind to itself + node call + attr (call) pop_symbol = "()" + edge @struct.def -> call + edge call -> member } @struct [StructDefinition [StructMembers @member item: [StructMember @type_name [TypeName] @name name: [Identifier]] ]] { - node def - attr (def) node_definition = @name - attr (def) definiens_node = @member + node @member.def + attr (@member.def) node_definition = @name + attr (@member.def) definiens_node = @member - edge @struct.members -> def + edge @struct.members -> @member.def edge @type_name.type_ref -> @struct.lexical_scope - node typeof - attr (typeof) push_symbol = "@typeof" + node @member.typeof + attr (@member.typeof) push_symbol = "@typeof" - edge def -> typeof - edge typeof -> @type_name.output + edge @member.def -> @member.typeof + edge @member.typeof -> @type_name.output +} + +@struct [StructDefinition [StructMembers . @first_member [StructMember]]] { + ; As a public getter result, the value returned is a tuple with all our fields flattened + ; We only care about the first member for name binding, since tuples are not real types + node getter_call + attr (getter_call) pop_symbol = "@as_getter" + edge @struct.typeof -> getter_call + edge getter_call -> @first_member.typeof } @@ -1819,6 +2261,15 @@ inherit .lexical_scope node @error.params attr (@error.params) pop_symbol = "@param_names" edge @error.def -> @error.params + + ; Bind to built-in errorType for accessing built-in member `.selector` + node typeof + attr (typeof) push_symbol = "@typeof" + node error_type + attr (error_type) push_symbol = "%ErrorType" + edge @error.def -> typeof + edge typeof -> error_type + edge error_type -> @error.lexical_scope } @error [ErrorDefinition [ErrorParametersDeclaration [ErrorParameters @@ -1862,17 +2313,59 @@ inherit .lexical_scope edge @type_name.type_ref -> @constant.lexical_scope } -@user_type [UserDefinedValueTypeDefinition] { +@user_type [UserDefinedValueTypeDefinition @name [Identifier] @value_type [ElementaryType]] { node @user_type.lexical_scope node @user_type.def -} -@user_type [UserDefinedValueTypeDefinition @name [Identifier]] { - node def - attr (def) node_definition = @name - attr (def) definiens_node = @user_type + attr (@user_type.def) node_definition = @name + attr (@user_type.def) definiens_node = @user_type + + ; Provide member resolution through the built-in `%userTypeType` + ; Because the built-in is defined as a struct, we need to push an extra `@typeof` + node member_guard + attr (member_guard) pop_symbol = "." + node member + attr (member) push_symbol = "." + node typeof + attr (typeof) push_symbol = "@typeof" + node user_type_type + attr (user_type_type) push_symbol = "%UserDefinedValueType" - edge @user_type.def -> def + edge @user_type.def -> member_guard + edge member_guard -> member + edge member -> typeof + edge typeof -> user_type_type + edge user_type_type -> @user_type.lexical_scope + + ; Hard-code built-in functions `wrap` and `unwrap` in order to be able to + ; resolve their return types + node wrap + attr (wrap) pop_symbol = "wrap" + node wrap_call + attr (wrap_call) pop_symbol = "()" + node wrap_typeof + attr (wrap_typeof) push_symbol = "@typeof" + + edge member_guard -> wrap + edge wrap -> wrap_call + edge wrap_call -> wrap_typeof + edge wrap_typeof -> @value_type.ref + edge @value_type.ref -> @user_type.lexical_scope + + node unwrap + attr (unwrap) pop_symbol = "unwrap" + node unwrap_call + attr (unwrap_call) pop_symbol = "()" + node unwrap_typeof + attr (unwrap_typeof) push_symbol = "@typeof" + node type_ref + attr (type_ref) push_symbol = (source-text @name) + + edge member_guard -> unwrap + edge unwrap -> unwrap_call + edge unwrap_call -> unwrap_typeof + edge unwrap_typeof -> type_ref + edge type_ref -> @user_type.lexical_scope } @@ -1892,9 +2385,7 @@ inherit .lexical_scope } ;; Identifier expressions -@expr [Expression @name ( - variant: [Identifier] | variant: [SuperKeyword] | variant: [ThisKeyword] -)] { +@expr [Expression @name [Identifier]] { node ref attr (ref) node_reference = @name attr (ref) parents = [@expr.enclosing_def] @@ -1903,6 +2394,14 @@ inherit .lexical_scope edge @expr.output -> ref } +@expr [Expression @keyword ([ThisKeyword] | [SuperKeyword])] { + ; This is almost equivalent to the above rule, except it doesn't generate a reference + node keyword + attr (keyword) push_symbol = (source-text @keyword) + edge keyword -> @expr.lexical_scope + edge @expr.output -> keyword +} + ;; Member access expressions @expr [Expression [MemberAccessExpression @operand operand: [Expression] @@ -1921,10 +2420,7 @@ inherit .lexical_scope edge @expr.output -> @name.ref ; Shortcut path for expressions inside contracts with using X for * directives - node star - attr (star) push_symbol = "@*" - edge member -> star - edge star -> @expr.lexical_scope + edge member -> @expr.star_extension } ;; Special case: member accesses to `super` are tagged with "super" to rank @@ -1936,21 +2432,31 @@ inherit .lexical_scope attr (@name.ref) tag = "super" } +;; Elementary types used as expressions (eg. for type casting, or for built-ins like `string.concat`) +@expr [Expression @type [ElementaryType]] { + edge @expr.output -> @type.ref + edge @type.ref -> @expr.lexical_scope + + ; Elementary types can also be used for casting; instead of defining built-in + ; struct for each available elementary type, we define a special path here + node call + attr (call) pop_symbol = "()" + node typeof + attr (typeof) push_symbol = "@typeof" + edge @expr.output -> call + edge call -> typeof + edge typeof -> @type.ref +} + ;; Index access expressions @expr [Expression [IndexAccessExpression @operand operand: [Expression] ]] { - node index_call - attr (index_call) push_symbol = "()" node index - attr (index) push_symbol = "%index" - node index_member - attr (index_member) push_symbol = "." + attr (index) push_symbol = "[]" - edge @expr.output -> index_call - edge index_call -> index - edge index -> index_member - edge index_member -> @operand.output + edge @expr.output -> index + edge index -> @operand.output } ;; Type expressions @@ -1963,7 +2469,7 @@ inherit .lexical_scope node typeof attr (typeof) push_symbol = "@typeof" node type - attr (type) push_symbol = "%typeIntType" + attr (type) push_symbol = "%IntTypeType" edge @type_expr.output -> typeof edge typeof -> type @@ -1975,7 +2481,7 @@ inherit .lexical_scope node typeof attr (typeof) push_symbol = "@typeof" node type - attr (type) push_symbol = "%type" + attr (type) push_symbol = "@type" edge @type_expr.output -> typeof edge typeof -> type @@ -2039,7 +2545,7 @@ inherit .lexical_scope attr (@options.refs) push_symbol = "@param_names" node call_options - attr (call_options) push_symbol = "%callOptions" + attr (call_options) push_symbol = "%CallOptions" edge @options.refs -> call_options edge call_options -> @expr.lexical_scope @@ -2053,6 +2559,137 @@ inherit .lexical_scope } +;;; Payable +; These work like `address`, should they should bind to `%address` +@expr [Expression [PayableKeyword]] { + node ref + attr (ref) push_symbol = "%address" + + edge ref -> @expr.lexical_scope + edge @expr.output -> ref +} + + +;;; Tuple expressions + +; Parenthesized expressions are parsed as tuples of a single value +@expr [Expression [TupleExpression [TupleValues . [TupleValue @operand [Expression]] .]]] { + edge @expr.output -> @operand.output +} + +;;; Arithmetic, bitwise & logical operators, etc + +; Bind to the left operand only: assignment expressions +@expr [Expression [_ + @left_operand left_operand: [Expression] + ( + [Equal] + | [BarEqual] + | [PlusEqual] + | [MinusEqual] + | [CaretEqual] + | [SlashEqual] + | [PercentEqual] + | [AsteriskEqual] + | [AmpersandEqual] + | [LessThanLessThanEqual] + | [GreaterThanGreaterThanEqual] + | [GreaterThanGreaterThanGreaterThanEqual] + ) +]] { + edge @expr.output -> @left_operand.output +} + +; Unary operators postfix +@expr [Expression [_ + @operand operand: [Expression] + ([PlusPlus] | [MinusMinus]) +]] { + edge @expr.output -> @operand.output +} + +; Unary operators prefix +@expr [Expression [_ + ([PlusPlus] | [MinusMinus] | [Tilde] | [Bang] | [Minus] | [Plus]) + @operand operand: [Expression] +]] { + edge @expr.output -> @operand.output +} + +; Bind to both operands: logical and/or, arithmetic, bit-wise expressions +@expr [Expression [_ + @left_operand left_operand: [Expression] + ( + [BarBar] + | [AmpersandAmpersand] + + | [Plus] + | [Minus] + | [Asterisk] + | [Slash] + | [Percent] + | [AsteriskAsterisk] + + | [Bar] + | [Caret] + | [Ampersand] + + | [LessThanLessThan] + | [GreaterThanGreaterThan] + | [GreaterThanGreaterThanGreaterThan] + ) + @right_operand right_operand: [Expression] +]] { + edge @expr.output -> @left_operand.output + edge @expr.output -> @right_operand.output +} + +; Comparison operators bind to bool type +@expr [Expression [_ + ( + [EqualEqual] + | [BangEqual] + | [LessThan] + | [GreaterThan] + | [LessThanEqual] + | [GreaterThanEqual] + ) +]] { + node typeof + attr (typeof) push_symbol = "@typeof" + node bool + attr (bool) push_symbol = "%bool" + edge @expr.output -> typeof + edge typeof -> bool + edge bool -> @expr.lexical_scope +} + +; Ternary conditional expression binds to both branches +@expr [Expression [ConditionalExpression + @true_expression true_expression: [Expression] + @false_expression false_expression: [Expression] +]] { + edge @expr.output -> @true_expression.output + edge @expr.output -> @false_expression.output +} + + +;;; Literal Address Expressions +@expr [Expression [HexNumberExpression @hex_literal [HexLiteral]]] { + scan (source-text @hex_literal) { + "0x[0-9a-fA-F]{40}" { + ; Treat it as a valid address + node typeof + attr (typeof) push_symbol = "@typeof" + node address + attr (address) push_symbol = "%address" + edge @expr.output -> typeof + edge typeof -> address + edge address -> @expr.lexical_scope + } + } +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Yul @@ -2162,6 +2799,38 @@ inherit .lexical_scope ;; parameters) are functions (ie. the body of the function doesn't have access ;; to any outside variables) edge @fundef.lexical_scope -> @block.function_defs + ; Exception: but outside constants *are* available, so we provide a guarded + ; access to the parent lexical scope. This guard will be popped to link to + ; available constants. + node yul_function_guard + attr (yul_function_guard) push_symbol = "@in_yul_function" + edge @fundef.lexical_scope -> yul_function_guard + edge yul_function_guard -> @block.lexical_scope +} + +;; Constants need to be available inside Yul functions. This is an exception +;; since no other external identifiers are, so the path is guarded. We create a +;; scope in the source unit, contracts and libraries, and guard it from the +;; lexical scope, so we can link constant definitions here. See the dual path in +;; the rule above. +@constant_container ([SourceUnit] | [ContractDefinition] | [LibraryDefinition]) { + node @constant_container.yul_functions_guarded_scope + attr (@constant_container.yul_functions_guarded_scope) pop_symbol = "@in_yul_function" + edge @constant_container.lexical_scope -> @constant_container.yul_functions_guarded_scope +} + +;; Make top-level constants available inside Yul functions +@source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @constant [ConstantDefinition]]]] { + edge @source_unit.yul_functions_guarded_scope -> @constant.def +} + +;; Ditto for contracts, interfaces and libraries +@contract [_ members: [_ [ContractMember + @constant [StateVariableDefinition + [StateVariableAttributes [StateVariableAttribute [ConstantKeyword]]] + ] +]]] { + edge @contract.yul_functions_guarded_scope -> @constant.def } @fundef [YulFunctionDefinition @@ -2277,11 +2946,60 @@ inherit .lexical_scope node @path.lexical_scope } -@path [YulPath @name [YulIdentifier]] { +@path [YulPath . @name [YulIdentifier]] { node ref attr (ref) node_reference = @name edge ref -> @path.lexical_scope + + if (version-matches "< 0.7.0") { + ; Before Solidity 0.7.0 storage variables' `.offset` and `.slot` were + ; accessed by suffixing the name with `_offset` and `_slot` + scan (source-text @name) { + "^(.*)_(slot|offset|length)$" { + let symbol = $0 + let without_suffix = $1 + let suffix = $2 + + ; We bind the whole symbol to the built-in field for the known cases + node pop_ref + attr (pop_ref) pop_symbol = symbol + node push_suffixless + attr (push_suffixless) push_symbol = suffix + node member_of + attr (member_of) push_symbol = "." + node typeof + attr (typeof) push_symbol = "@typeof" + node yul_external + attr (yul_external) push_symbol = "%YulExternal" + + edge ref -> pop_ref + edge pop_ref -> push_suffixless + edge push_suffixless -> member_of + edge member_of -> typeof + edge typeof -> yul_external + edge yul_external -> @path.lexical_scope + } + } + } +} + +@path [YulPath [Period] @member [YulIdentifier] .] { + ; Yul variable members only apply to external variables and hence are + ; automatically bound to a special %YulExternal built-in + node ref + attr (ref) node_reference = @member + node member_of + attr (member_of) push_symbol = "." + node typeof + attr (typeof) push_symbol = "@typeof" + node yul_external + attr (yul_external) push_symbol = "%YulExternal" + + edge ref -> member_of + edge member_of -> typeof + edge typeof -> yul_external + edge yul_external -> @path.lexical_scope } @expr [YulExpression @funcall [YulFunctionCallExpression]] { diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 9fe81048ce..7ff142dfd5 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -6751,42 +6751,45 @@ codegen_language_macros::compile!(Language( enabled = Till("0.5.0") ), BuiltInType( - name = "$abiType", + name = "$AbiType", fields = [], functions = [ BuiltInFunction( name = "decode", - parameters = ["bytes memory", "$args"], - return_type = "$args", + parameters = ["bytes memory encodedData", "$Type[] encodedTypesTuple"], + return_type = "$Any[]", enabled = From("0.5.0") ), BuiltInFunction( name = "encode", - parameters = ["$args"], + parameters = ["$Any[] valuesToEncode"], return_type = "bytes memory", enabled = From("0.4.22") ), BuiltInFunction( name = "encodeCall", - parameters = ["function()", "$args"], + parameters = [ + "function() functionPointer", + "$Any[] functionArgumentsTuple" + ], return_type = "bytes memory", enabled = From("0.8.11") ), BuiltInFunction( name = "encodePacked", - parameters = ["$args"], + parameters = ["$Any[] valuesToEncode"], return_type = "bytes memory", enabled = From("0.4.22") ), BuiltInFunction( name = "encodeWithSelector", - parameters = ["bytes4 selector", "$args"], + parameters = ["bytes4 selector", "$Any[] functionArgumentsTuple"], return_type = "bytes memory", enabled = From("0.4.22") ), BuiltInFunction( name = "encodeWithSignature", - parameters = ["string memory", "$args"], + parameters = ["string memory signature", "$Any[] valuesToEncode"], return_type = "bytes memory", enabled = From("0.4.22") ) @@ -6832,7 +6835,7 @@ codegen_language_macros::compile!(Language( ), BuiltInFunction( name = "send", - parameters = ["uint256"], + parameters = ["uint256 amount"], return_type = "bool" ), BuiltInFunction( @@ -6841,49 +6844,40 @@ codegen_language_macros::compile!(Language( return_type = "bool, bytes memory", enabled = From("0.5.0") ), - BuiltInFunction(name = "transfer", parameters = ["uint256"]) + BuiltInFunction(name = "transfer", parameters = ["uint256 amount"]) ] ), BuiltInType( - name = "$array", + name = "$Array", fields = [BuiltInField(definition = "uint length")], functions = [ - BuiltInFunction( - name = "$index", - parameters = ["uint"], - return_type = "$element" - ), BuiltInFunction( name = "push", parameters = [], - return_type = "$element", + return_type = "$ValueType", enabled = From("0.6.0") ), BuiltInFunction( name = "push", - parameters = ["$element"], + parameters = ["$ValueType element"], return_type = "uint", enabled = Till("0.6.0") ), BuiltInFunction( name = "push", - parameters = ["$element"], + parameters = ["$ValueType element"], enabled = From("0.6.0") ), BuiltInFunction(name = "pop", parameters = []) ] ), BuiltInType( - name = "$arrayFixed", + name = "$FixedArray", fields = [BuiltInField(definition = "uint length")], - functions = [BuiltInFunction( - name = "$index", - parameters = ["uint"], - return_type = "$element" - )] + functions = [] ), BuiltInType( - name = "$blockType", + name = "$BlockType", fields = [ BuiltInField(definition = "uint basefee", enabled = From("0.8.7")), BuiltInField(definition = "uint blobbasefee", enabled = From("0.8.24")), @@ -6904,15 +6898,20 @@ codegen_language_macros::compile!(Language( ), BuiltInType( name = "$bytes", + fields = [BuiltInField(definition = "uint length")], + functions = [] + ), + BuiltInType( + name = "$BytesType", fields = [], functions = [BuiltInFunction( name = "concat", - parameters = ["$args"], + parameters = ["bytes[] bytesToConcatenate"], return_type = "bytes memory" )] ), BuiltInType( - name = "$callOptions", + name = "$CallOptions", fields = [ BuiltInField(definition = "uint gas"), BuiltInField(definition = "uint salt"), @@ -6922,28 +6921,52 @@ codegen_language_macros::compile!(Language( enabled = From("0.6.2") ), BuiltInType( - name = "$functionExternal", + name = "$ErrorType", + fields = [BuiltInField(definition = "bytes4 selector")], + functions = [], + enabled = From("0.8.4") + ), + BuiltInType( + name = "$Function", + fields = [], + functions = [ + BuiltInFunction( + name = "gas", + parameters = ["uint amount"], + return_type = "function()", + enabled = Till("0.7.0") + ), + BuiltInFunction( + name = "value", + parameters = ["uint amount"], + return_type = "function()", + enabled = Till("0.7.0") + ) + ] + ), + BuiltInType( + name = "$ExternalFunction", fields = [ - BuiltInField(definition = "$address address", enabled = From("0.8.2")), - BuiltInField(definition = "$selector selector", enabled = From("0.4.17")) + BuiltInField(definition = "address address", enabled = From("0.8.2")), + BuiltInField(definition = "bytes4 selector", enabled = From("0.4.17")) ], functions = [ BuiltInFunction( name = "gas", - parameters = ["uint"], - return_type = "$function", + parameters = ["uint amount"], + return_type = "function()", enabled = Till("0.7.0") ), BuiltInFunction( name = "value", - parameters = ["uint"], - return_type = "$function", + parameters = ["uint amount"], + return_type = "function()", enabled = Till("0.7.0") ) ] ), BuiltInType( - name = "$msgType", + name = "$MessageType", fields = [ BuiltInField(definition = "bytes data"), BuiltInField(definition = "uint256 gas", enabled = Till("0.5.0")), @@ -6958,16 +6981,16 @@ codegen_language_macros::compile!(Language( functions = [] ), BuiltInType( - name = "$string", + name = "$StringType", fields = [], functions = [BuiltInFunction( name = "concat", - parameters = ["$args"], + parameters = ["string[] stringsToConcatenate"], return_type = "string memory" )] ), BuiltInType( - name = "$txType", + name = "$TransactionType", fields = [ BuiltInField(definition = "uint gasprice"), BuiltInField( @@ -6979,7 +7002,7 @@ codegen_language_macros::compile!(Language( functions = [] ), BuiltInType( - name = "$typeContractType", + name = "$ContractTypeType", fields = [ BuiltInField(definition = "string name"), BuiltInField(definition = "bytes creationCode", enabled = From("0.5.3")), @@ -6989,7 +7012,7 @@ codegen_language_macros::compile!(Language( functions = [] ), BuiltInType( - name = "$typeInterfaceType", + name = "$InterfaceTypeType", fields = [ BuiltInField(definition = "string name"), BuiltInField(definition = "bytes4 interfaceId", enabled = From("0.6.7")) @@ -6997,18 +7020,48 @@ codegen_language_macros::compile!(Language( functions = [] ), BuiltInType( - name = "$typeIntType", + name = "$IntTypeType", fields = [ BuiltInField(definition = "int min", enabled = From("0.6.8")), BuiltInField(definition = "int max", enabled = From("0.6.8")) ], functions = [] ), - BuiltInVariable(definition = "$function $placeholder"), - BuiltInVariable(definition = "$abiType abi"), - BuiltInVariable(definition = "$blockType block"), - BuiltInVariable(definition = "$msgType msg"), + BuiltInType( + name = "$UserDefinedValueType", + fields = [], + functions = [ + BuiltInFunction( + name = "wrap", + parameters = ["$WrappedType elementaryType"], + return_type = "$UserType" + ), + BuiltInFunction( + name = "unwrap", + parameters = ["$UserType userType"], + return_type = "$WrappedType" + ) + ], + enabled = From("0.8.8") + ), + BuiltInType( + name = "$YulExternal", + fields = [ + // These apply to state and storage variables + BuiltInField(definition = "uint slot"), + BuiltInField(definition = "uint offset"), + // Dynamic calldata arrays also have a length + BuiltInField(definition = "uint length") + ], + functions = [] + ), + BuiltInVariable(definition = "$Function $placeholder"), + BuiltInVariable(definition = "$AbiType abi"), + BuiltInVariable(definition = "$BlockType block"), + BuiltInVariable(definition = "$BytesType $bytes"), + BuiltInVariable(definition = "$MessageType msg"), BuiltInVariable(definition = "uint now", enabled = Till("0.7.0")), - BuiltInVariable(definition = "$txType tx") + BuiltInVariable(definition = "$StringType $string"), + BuiltInVariable(definition = "$TransactionType tx") ] )); diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/binding_rules.rs b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/binding_rules.rs index 63e0862896..c47f067e24 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/binding_rules.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/binding_rules.rs @@ -26,6 +26,12 @@ inherit .enclosing_def inherit .parent_scope inherit .lexical_scope +inherit .extended_scope + +; Used to resolve extension methods for `using for *` directives +; This is used as a minor optimization to avoid introducing new possible paths +; when there are no `using for *` directives in the contract. +inherit .star_extension ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -67,14 +73,25 @@ inherit .lexical_scope ;; inherited) for contracts to resolve bases (both in inheritance lists and ;; override specifiers) let @source_unit.parent_scope = @source_unit.lexical_scope + ; FIXME: we probably need to make extended scope different than lexical scope + ; and push an extension scope on that path + let @source_unit.extended_scope = @source_unit.lexical_scope + + ; We may jump to scope here to resolve using the extensions scope provided by + ; contract/libraries that contain `using` directives + edge @source_unit.lexical_scope -> JUMP_TO_SCOPE_NODE + + ; Provide a default star extension sink node that gets inherited. This is + ; connected to from expressions, and those can potentially happen anywhere. + node @source_unit.star_extension } ;; Top-level definitions... @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @unit_member ( [ContractDefinition] - | [InterfaceDefinition] | [LibraryDefinition] + | [InterfaceDefinition] | [StructDefinition] | [EnumDefinition] | [FunctionDefinition] @@ -84,11 +101,25 @@ inherit .lexical_scope | [EventDefinition] )] ]] { - edge @unit_member.lexical_scope -> @source_unit.lexical_scope edge @source_unit.lexical_scope -> @unit_member.def edge @source_unit.defs -> @unit_member.def + + ; In the general case, the lexical scope of the definition connects directly + ; to the source unit's + edge @unit_member.lexical_scope -> @source_unit.lexical_scope +} + +;; Definitions that need to resolve expressions do it through an extended_scope +@source_unit [SourceUnit [SourceUnitMembers + [SourceUnitMember @unit_member ( + [FunctionDefinition] + | [ConstantDefinition] + )] +]] { + edge @unit_member.extended_scope -> @source_unit.extended_scope } + ;; Special case for built-ins: we want to export all symbols in the contract: ;; functions, types and state variables. All built-in symbols are defined in an ;; internal contract named '%BuiltIns%' (renamed from '$BuiltIns$') so we need @@ -99,13 +130,14 @@ inherit .lexical_scope [SourceUnitMember @contract [ContractDefinition name: ["%BuiltIns%"]]] ]] { if (is-system-file FILE_PATH) { - edge @source_unit.defs -> @contract.members - edge @source_unit.defs -> @contract.type_members - edge @source_unit.defs -> @contract.state_vars + edge @source_unit.defs -> @contract.instance } } @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @using [UsingDirective]]]] { + ; TODO: this is the hook for top-level extensions, but this should connect to + ; an extensions scope that gets pushed to the scope stack, as in the case of + ; contracts/libraries (defined further down below). edge @source_unit.lexical_scope -> @using.def } @@ -116,7 +148,7 @@ inherit .lexical_scope edge @source_unit.defs -> @using.def } -;; ... and imports +;; Import connections to the source unit @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember [ImportDirective [ImportClause @import ( @@ -255,28 +287,41 @@ inherit .lexical_scope ;; interface), aka the source unit edge @type_name.push_end -> heir.parent_scope - ;; Make base members accesible as our own members - node member - attr (member) push_symbol = "." - - node typeof - attr (typeof) push_symbol = "@typeof" - - edge heir.members -> member - edge member -> typeof - edge typeof -> @type_name.push_begin - - ;; Make base defs (eg. enums and structs) accessible as our own - node type_member - attr (type_member) push_symbol = "." - - edge heir.type_members -> type_member - edge type_member -> @type_name.push_begin - - ; Resolve the "super" keyword to the inherited type - edge heir.super -> @type_name.push_begin + ; Access instance members of the inherited contract/interface, from the + ; instance scope of the inheriting contract/interface + node instance + attr (instance) push_symbol = "@instance" + edge heir.instance -> instance + edge instance -> @type_name.push_begin + + ; Base members can also be accessed (from the instance scope) qualified with + ; the base name (eg. `Base.something`) + node member_pop + attr (member_pop) pop_symbol = "." + edge heir.instance -> @type_name.pop_begin + edge @type_name.pop_end -> member_pop + edge member_pop -> instance + + ; Base namespace-like members (ie. enums, structs, etc) are also accessible as + ; our own namespace members + node ns_member + attr (ns_member) push_symbol = "." + edge heir.ns -> ns_member + edge ns_member -> @type_name.push_begin + + if (version-matches "< 0.7.0") { + ; `using` directives are inherited in Solidity < 0.7.0, so connect them to + ; our own extensions scope + node extensions_push_guard + attr (extensions_push_guard) push_symbol = "@extensions" + edge heir.extensions -> extensions_push_guard + edge extensions_push_guard -> @type_name.push_begin + } } +;; The next couple of rules setup a `.parent_refs` attribute to use in the +;; resolution algorithm to perform linearisation of a contract hierarchy. + ;; NOTE: we use anchors here to prevent the query engine from returning all the ;; sublists of possible parents @specifier [InheritanceSpecifier [InheritanceTypes . @parents [_]+ .]] { @@ -299,38 +344,34 @@ inherit .lexical_scope ;;; Contracts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@contract [ContractDefinition] { +@contract [ContractDefinition @name name: [Identifier]] { node @contract.lexical_scope - node @contract.super_scope + node @contract.extended_scope + node @contract.extensions node @contract.def node @contract.members - node @contract.type_members + node @contract.ns node @contract.modifiers - node @contract.state_vars + node @contract.instance - edge @contract.lexical_scope -> @contract.members - edge @contract.lexical_scope -> @contract.type_members - edge @contract.lexical_scope -> @contract.state_vars + attr (@contract.def) node_definition = @name + attr (@contract.def) definiens_node = @contract - ;; Modifiers are available as a contract type members through a special '@modifier' symbol - node modifier - attr (modifier) pop_symbol = "@modifier" - edge @contract.type_members -> modifier - edge modifier -> @contract.modifiers + edge @contract.lexical_scope -> @contract.instance - let @contract.enclosing_def = @contract.def -} + ; Instance scope can also see members and our namespace definitions + edge @contract.instance -> @contract.members + edge @contract.instance -> @contract.ns -@contract [ContractDefinition @name name: [Identifier]] { - attr (@contract.def) node_definition = @name - attr (@contract.def) definiens_node = @contract + let @contract.enclosing_def = @contract.def - ;; "instance" like access path - ;; we have two distinct paths: @typeof -> . for accesses to variables of the contract's type - ;; and () -> . for accesses through a `new` invocation (or casting) + ;; External "instance" scope access: either member access through a variable + ;; of the contract's type, or through calling (which happens on `new` + ;; invocations or casting). These should access only externally accessible + ;; members, such as functions and public variables. node member attr (member) pop_symbol = "." - edge member -> @contract.members + edge member -> @contract.instance node type_def attr (type_def) pop_symbol = "@typeof" @@ -342,81 +383,154 @@ inherit .lexical_scope edge @contract.def -> call edge call -> member - ;; "namespace" like access path - node type_member - attr (type_member) pop_symbol = "." - edge @contract.def -> type_member - edge type_member -> @contract.type_members - - ;; Define "this" and connect it to the contract definition + ;; "namespace" scope access + node ns_member + attr (ns_member) pop_symbol = "." + edge @contract.def -> ns_member + edge ns_member -> @contract.ns + + ; Finally there's an @instance guarded path used by derived contracts to + ; access instance accessible members + node instance + attr (instance) pop_symbol = "@instance" + edge @contract.def -> instance + edge instance -> @contract.instance + + ; "this" keyword is available in our lexical scope and can access any + ; externally available member node this attr (this) pop_symbol = "this" - edge this -> member - - ;; ... and make it available in the contract's lexical scope edge @contract.lexical_scope -> this + edge this -> member - ; Resolve the "this" keyword to the contract itself - node name_push - attr (name_push) push_symbol = (source-text @name) - edge this -> name_push - edge name_push -> @contract.lexical_scope - - ;; Define "super" effectively as if it was a state variable of a type connected by our super_scope - ;; super_scope will later connect to the base contract defs directly - node @contract.super - attr (@contract.super) pop_symbol = "super" - - node super_typeof - attr (super_typeof) push_symbol = "@typeof" - - edge @contract.super -> super_typeof - edge super_typeof -> @contract.super_scope - - ;; Finally make "super" available in the contract's lexical scope for function bodies to use - edge @contract.lexical_scope -> @contract.super - - ; NOTE: The keyword "super" itself resolves to each of its parent contracts. - ; See the related rules in the InheritanceSpecifier section above. + ;; Modifiers are available as a contract type members through a special '@modifier' guard + node modifier + attr (modifier) pop_symbol = "@modifier" + edge @contract.ns -> modifier + edge modifier -> @contract.modifiers - ;; This defines the sink of edges added from base contracts when setting this - ;; contract as the compilation context - attr (@contract.def) export_node = @contract.members + ; There may be attached functions to our type. For the general case of + ; variables of our type, that's already handled via normal lexical scope + ; resolution. But for casting/`new` invocations that we resolve through the + ; `()` guard above, we need to explicitly jump to the extension scope from + ; here to attempt resolving the attached function. We cannot jump back to the + ; parent scope because that would create a cycle in the graph. + node push_typeof + attr (push_typeof) push_symbol = "@typeof" + node push_name + attr (push_name) push_symbol = (source-text @name) + edge call -> push_typeof + edge push_typeof -> push_name + edge push_name -> JUMP_TO_SCOPE_NODE - ;; This node will eventually connect to the contract's members being compiled - ;; and grants access to definitions in that contract and all its parents - ;; (recursively) - node super_import - attr (super_import) pop_symbol = "." - edge @contract.super -> super_import + if (version-matches "< 0.5.0") { + ; For Solidity < 0.5.0 `this` also acts like an `address` + node address_ref + attr (address_ref) push_symbol = "%address" + node address_typeof + attr (address_typeof) push_symbol = "@typeof" + edge this -> address_typeof + edge address_typeof -> address_ref + edge address_ref -> @contract.lexical_scope + } - ;; This defines the source side of edges added to base contracts when setting - ;; a contract as compilation context; this allows this contract (a base) to - ;; access virtual methods in any sub-contract defined in the hierarchy - attr (@contract.def) import_nodes = [@contract.lexical_scope, super_import] + ; This is the connection point to resolve attached functions by `using for *` + node @contract.star_extension + attr (@contract.star_extension) push_symbol = "@*" + + if (version-matches "< 0.7.0") { + ; Expose extensions through an `@extensions` guard on Solidity < 0.7.0 so + ; that they can be accessed from sub contract extension scopes + node extensions_guard + attr (extensions_guard) pop_symbol = "@extensions" + edge @contract.def -> extensions_guard + edge extensions_guard -> @contract.extensions + + ; Since using directives are inherited, we need to *always* connect the push + ; extensions to the extended scope, regardless of whether this contract + ; contains any `using` directive. + edge @contract.extended_scope -> @contract.push_extensions + + ; For Solidity < 0.7.0 using directives are inherited, so we need to connect + ; always For newer versions, this connection only happens when there is a + ; `using for *` directive in the contract (see rule below) + edge @contract.star_extension -> @contract.extended_scope + } ; Path to resolve the built-in type for type() expressions node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_contract_type - attr (type_contract_type) push_symbol = "%typeContractType" + attr (type_contract_type) push_symbol = "%ContractTypeType" edge @contract.def -> type edge type -> type_contract_type - edge type_contract_type -> @contract.lexical_scope + edge type_contract_type -> @contract.parent_scope + + ; The following defines the connection nodes the resolution algorithm uses + ; *only when setting a compilation context/target*. + + ; This attribute defines the sink of edges added from base contracts when + ; setting this contract as the compilation context, and should provide access + ; to anything that can be reached through `super`. The instance scope is a bit + ; too broad, but `.members` is too narrow as it doesn't allow navigation to + ; parent contracts (and from the base we need to be able to reach all + ; contracts in the hierarchy). + attr (@contract.def) export_node = @contract.instance + + ; This node will eventually connect to the contract's members being compiled + ; and grants access to definitions in that contract and all its parents + ; (recursively). It only makes sense if `super` is defined (ie. if we have + ; parents), but we define it here to be able to use it in the declaration of + ; import nodes. This is the dual of the export_node above. + node @contract.super_import + attr (@contract.super_import) pop_symbol = "." + + ; This defines the source side of edges added to base contracts when setting + ; a contract as compilation context; this allows this contract (a base) to + ; access virtual methods in any sub-contract defined in the hierarchy (both + ; with and without `super`, hence the two connection points). + attr (@contract.def) import_nodes = [@contract.lexical_scope, @contract.super_import] } @contract [ContractDefinition @specifier [InheritanceSpecifier]] { + ; The `.heir` scoped variable allows the rules for `InheritanceSpecifier` + ; above to connect the instance scope of this contract to the parents. let @specifier.heir = @contract attr (@contract.def) parents = @specifier.parent_refs + + ; The rest of these statements deal with defining and connecting the `super` + ; keyword path. + + ; `super_scope` is where we hook all references to our parent contracts + node @contract.super_scope + + ; Define "super" in the lexical scope + node @contract.super + attr (@contract.super) pop_symbol = "super" + edge @contract.lexical_scope -> @contract.super + + ; This connects `super` to exported scopes from all contracts in the hierarchy + ; when setting a contract compilation target (see more detailed description + ; above on the definition of the `super_import` node). + edge @contract.super -> @contract.super_import + + ; Then connect it through an `@instance` guard to the parent contracts through + ; `super_scope`. This allows "instance"-like access to members of parents + ; through `super`. + node super_instance + attr (super_instance) push_symbol = "@instance" + edge @contract.super_import -> super_instance + edge super_instance -> @contract.super_scope } @contract [ContractDefinition [InheritanceSpecifier [InheritanceTypes [InheritanceType @type_name [IdentifierPath]] ]]] { - ;; The base contract defs are directly accesible through our special super scope + ;; The base contract defs are directly accesible through our super scope edge @contract.super_scope -> @type_name.push_begin } +; Pure definitions that cannot contain expressions @contract [ContractDefinition [ContractMembers [ContractMember @member ( [EnumDefinition] @@ -424,21 +538,39 @@ inherit .lexical_scope | [EventDefinition] | [ErrorDefinition] | [UserDefinedValueTypeDefinition] - | [FunctionDefinition] + )] +]] { + edge @member.lexical_scope -> @contract.lexical_scope +} + +; Definitions that can contain expressions need two scopes: +; - normal lexical scope for resolving types +; - extended scope (extended by using directives) for resolving expressions +@contract [ContractDefinition [ContractMembers + [ContractMember @member ( + [FunctionDefinition] | [ConstructorDefinition] - | [StateVariableDefinition] | [ModifierDefinition] | [FallbackFunctionDefinition] | [ReceiveFunctionDefinition] + | [UnnamedFunctionDefinition] + | [StateVariableDefinition] )] ]] { edge @member.lexical_scope -> @contract.lexical_scope + edge @member.extended_scope -> @contract.extended_scope } @contract [ContractDefinition [ContractMembers [ContractMember @using [UsingDirective]] ]] { - edge @contract.lexical_scope -> @using.def + ; Hook the using definition in the extensions scope + edge @contract.extensions -> @using.def + + ; Connect the extensions push path (this can happen multiple times if there + ; are multiple `using` directives in the contract, but that's allowed by the + ; graph builder). + edge @contract.extended_scope -> @contract.push_extensions } @contract [ContractDefinition [ContractMembers @@ -450,13 +582,20 @@ inherit .lexical_scope | [UserDefinedValueTypeDefinition] )] ]] { - edge @contract.type_members -> @member.def + ; These definition go into the "namespace" scope and are accessible externally + ; via qualified naming (eg. `Contract.MyStruct`) + edge @contract.ns -> @member.def } @contract [ContractDefinition [ContractMembers [ContractMember @state_var [StateVariableDefinition]] ]] { - edge @contract.state_vars -> @state_var.def + ; State variables are available to derived contracts. + ; TODO: this also exposes private state variables to derived contracts, but we + ; can't easily filter them because we don't have negative assertions in our + ; query language (we would need to modify this query for anything *not* + ; containing a `PrivateKeyword` node) + edge @contract.instance -> @state_var.def } ;; Public state variables are also exposed as external member functions @@ -485,13 +624,15 @@ inherit .lexical_scope [FunctionAttributes [FunctionAttribute ([ExternalKeyword] | [PublicKeyword])]] ]] ]] { - ; public or external functions are also accessible through the contract type - edge @contract.type_members -> @function.def + ; Public or external functions are also accessible through the contract type + ; (to retrieve their `.selector` for example) + edge @contract.ns -> @function.def } @contract [ContractDefinition members: [ContractMembers [ContractMember @modifier [ModifierDefinition]] ]] { + ; Modifiers live in their own special scope edge @contract.modifiers -> @modifier.def ;; This may prioritize this definition (when there are multiple options) @@ -500,6 +641,15 @@ inherit .lexical_scope attr (@modifier.def) parents = [@contract.def] } +@contract [ContractDefinition [ContractMembers [ContractMember + [UsingDirective [UsingTarget [Asterisk]]] +]]] { + ; Connect the star extension node to the resolution extended scope if there is + ; a `using for *` directive in the contract + edge @contract.star_extension -> @contract.extended_scope +} + +; This applies to both state variables and function definitions @override [OverrideSpecifier [OverridePathsDeclaration [OverridePaths @base_ident [IdentifierPath] ]]] { @@ -512,26 +662,32 @@ inherit .lexical_scope ;;; Interfaces ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@interface [InterfaceDefinition] { +@interface [InterfaceDefinition @name name: [Identifier]] { node @interface.lexical_scope node @interface.def node @interface.members - node @interface.type_members - - edge @interface.lexical_scope -> @interface.members - edge @interface.lexical_scope -> @interface.type_members -} + node @interface.ns + node @interface.instance -@interface [InterfaceDefinition @name name: [Identifier]] { attr (@interface.def) node_definition = @name attr (@interface.def) definiens_node = @interface - ;; "instance" like access path - ;; we have two distinct paths: @typeof -> . for accesses to variables of the contract's type - ;; and () -> . for accesses through a `new` invocation (or casting) + edge @interface.lexical_scope -> @interface.instance + + ; Interfaces don't contain expressions (or `using` directives), so the + ; extended scope is the same as the lexical scope + let @interface.extended_scope = @interface.lexical_scope + ; The extensions node is required for the inheritance rules, but not used in interfaces + let @interface.extensions = (node) + + edge @interface.instance -> @interface.members + edge @interface.instance -> @interface.ns + + ;; External "instance" like access path, to access members of a variable of + ;; the interface's type or through a casting call. node member attr (member) pop_symbol = "." - edge member -> @interface.members + edge member -> @interface.instance node typeof attr (typeof) pop_symbol = "@typeof" @@ -543,28 +699,43 @@ inherit .lexical_scope edge @interface.def -> call edge call -> member + ; From a call we may need to resolve using the extensions scope, in case there's + ; a `using` directive on our type. This path ends up jumping to scope just to + ; handle that case. + node push_typeof + attr (push_typeof) push_symbol = "@typeof" + node push_name + attr (push_name) push_symbol = (source-text @name) + edge call -> push_typeof + edge push_typeof -> push_name + edge push_name -> JUMP_TO_SCOPE_NODE + ;; "namespace" like access path - node type_member - attr (type_member) pop_symbol = "." - edge @interface.def -> type_member - edge type_member -> @interface.type_members + node ns_member + attr (ns_member) pop_symbol = "." + edge @interface.def -> ns_member + edge ns_member -> @interface.ns + + ; Finally there's guarded `@instance` path used by derived contracts to access + ; instance accessible members + node instance + attr (instance) pop_symbol = "@instance" + edge @interface.def -> instance + edge instance -> @interface.instance ; Path to resolve the built-in type for type() expressions node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_interface_type - attr (type_interface_type) push_symbol = "%typeInterfaceType" + attr (type_interface_type) push_symbol = "%InterfaceTypeType" edge @interface.def -> type edge type -> type_interface_type - edge type_interface_type -> @interface.lexical_scope + edge type_interface_type -> @interface.parent_scope } @interface [InterfaceDefinition @specifier [InheritanceSpecifier]] { let @specifier.heir = @interface attr (@interface.def) parents = @specifier.parent_refs - - ; Define a dummy "super" node required by the rules for InheritanceSpecifier - node @interface.super } @interface [InterfaceDefinition [InterfaceMembers @@ -578,7 +749,7 @@ inherit .lexical_scope )] ]] { edge @member.lexical_scope -> @interface.lexical_scope - edge @interface.type_members -> @member.def + edge @interface.ns -> @member.def } ;; Allow references (eg. variables of the interface type) to the interface to @@ -586,14 +757,14 @@ inherit .lexical_scope @interface [InterfaceDefinition members: [InterfaceMembers item: [ContractMember @function variant: [FunctionDefinition]] ]] { - edge @function.lexical_scope -> @interface.lexical_scope edge @interface.members -> @function.def + edge @function.extended_scope -> @interface.extended_scope } [InterfaceDefinition [InterfaceMembers [ContractMember @using [UsingDirective]]]] { ; using directives are not allowed in interfaces, but the grammar allows them ; so we need to create an artificial node here to connect to created edges from - ; the internal nodes + ; the instance nodes let @using.lexical_scope = (node) } @@ -602,38 +773,47 @@ inherit .lexical_scope ;;; Libraries ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@library [LibraryDefinition] { +@library [LibraryDefinition @name name: [Identifier]] { node @library.lexical_scope + node @library.extended_scope + node @library.extensions node @library.def - node @library.members + node @library.ns + node @library.modifiers - edge @library.lexical_scope -> @library.members -} - -@library [LibraryDefinition @name name: [Identifier]] { attr (@library.def) node_definition = @name attr (@library.def) definiens_node = @library + edge @library.lexical_scope -> @library.ns + node member attr (member) pop_symbol = "." edge @library.def -> member + edge member -> @library.ns - edge member -> @library.members + ; Access to modifiers is guarded by a @modifier symbol + node modifier + attr (modifier) pop_symbol = "@modifier" + edge @library.ns -> modifier + edge modifier -> @library.modifiers ; Path to resolve the built-in type for type() expressions (same as contracts) node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_library_type - attr (type_library_type) push_symbol = "%typeContractType" + attr (type_library_type) push_symbol = "%ContractTypeType" edge @library.def -> type edge type -> type_library_type edge type_library_type -> @library.lexical_scope + + ; This is the connection point to resolve attached functions by `using for *` + node @library.star_extension + attr (@library.star_extension) push_symbol = "@*" } @library [LibraryDefinition [LibraryMembers [ContractMember @member ( - [FunctionDefinition] - | [EnumDefinition] + [EnumDefinition] | [StructDefinition] | [EventDefinition] | [ErrorDefinition] @@ -641,13 +821,82 @@ inherit .lexical_scope )] ]] { edge @member.lexical_scope -> @library.lexical_scope - edge @library.members -> @member.def + edge @library.ns -> @member.def +} + +@library [LibraryDefinition [LibraryMembers + [ContractMember @member ( + [FunctionDefinition] + | [StateVariableDefinition [StateVariableAttributes [StateVariableAttribute [ConstantKeyword]]]] + )] +]] { + edge @member.lexical_scope -> @library.lexical_scope + edge @member.extended_scope -> @library.extended_scope + edge @library.ns -> @member.def +} + +@library [LibraryDefinition [LibraryMembers + [ContractMember @modifier [ModifierDefinition]] +]] { + edge @library.modifiers -> @modifier.def + edge @modifier.lexical_scope -> @library.lexical_scope + edge @modifier.extended_scope -> @library.extended_scope } @library [LibraryDefinition [LibraryMembers [ContractMember @using [UsingDirective]] ]] { - edge @library.lexical_scope -> @using.def + ; Expose the using directive from the extensions scope + edge @library.extensions -> @using.def + + ; Connect the extensions push path + edge @library.extended_scope -> @library.push_extensions +} + +@library [LibraryDefinition [LibraryMembers [ContractMember + [UsingDirective [UsingTarget [Asterisk]]] +]]] { + ; Connect the star extension node to the resolution extended scope if there is + ; a `using for *` directive in the library + edge @library.star_extension -> @library.extended_scope +} + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Extensions scope rules +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; For contracts (and libraries) navigating to the source unit lexical scope +;; *also* needs to (optionally) propagate an extensions scope to be able to +;; correctly bind `using` attached functions. +@contract_or_library ([ContractDefinition] | [LibraryDefinition]) { + ; The `.extended_scope` resolution scope used by function bodies and other + ; expressions. From there we need to (optionally) push the extensions scope + ; (ie. `using` directives definitions) to the scope stack. + ; We will connect the path to push the extensions *if* the contract/library + ; has a `using` directive. Also, the extended scope links to the lexical scope + ; of the contract/library directly, regardless of whether there is a `using` + ; directive or not. + ; TODO: if we had a query negation operator to detect when there is no `using` + ; directive, could we avoid connecting directly when there are extensions? + edge @contract_or_library.extended_scope -> @contract_or_library.lexical_scope + + ; The .extensions node is where `using` directives will hook the definitions + attr (@contract_or_library.extensions) is_exported + + ; Now we define the path to push the .extensions scope into the scope stack. + ; We connect this to the extended scope only when there are extensions in the + ; contract/library. + node @contract_or_library.push_extensions + attr (@contract_or_library.push_extensions) push_scoped_symbol = "@extend" + attr (@contract_or_library.push_extensions) scope = @contract_or_library.extensions + node drop_scopes + attr (drop_scopes) type = "drop_scopes" + node pop_extensions + attr (pop_extensions) pop_scoped_symbol = "@extend" + + edge @contract_or_library.push_extensions -> drop_scopes + edge drop_scopes -> pop_extensions + edge pop_extensions -> @contract_or_library.lexical_scope } @@ -655,8 +904,11 @@ inherit .lexical_scope ;;; Using directives ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; The UsingDirective node requires the enclosing context to setup a -;; .lexical_scope scoped variable for it to resolve both targets and subjects. +;; The UsingDirective node requires the enclosing context to setup an +;; .extended_scope scoped variable for it to resolve both targets and subjects. +;; The resolution connects to the extended scope in order to (potentially) push +;; the same extension scope again, to resolve chained calls that all make use of +;; attached functions. @using [UsingDirective] { ; This node acts as a definition in the sense that provides an entry point @@ -664,14 +916,15 @@ inherit .lexical_scope ; target type node @using.def - ; This internal node connects the other end of the popping path starting at - ; .def and resolves for the library/functions in the directive + ; This internal node connects the definition side of the clause to the target + ; for resolution, and allows handling the multiple cases of `using` syntax + ; easily node @using.clause } @using [UsingDirective [UsingClause @id_path [IdentifierPath]]] { ; resolve the library to be used in the directive - edge @id_path.push_end -> @using.lexical_scope + edge @id_path.push_end -> @using.extended_scope ; because we're using the whole library, we don't need to "consume" the ; attached function (as when using the deconstruction syntax), but we still @@ -693,7 +946,7 @@ inherit .lexical_scope ]] ]]] { ; resolve the function to be used in the directive - edge @id_path.push_end -> @using.lexical_scope + edge @id_path.push_end -> @using.extended_scope node dot attr (dot) pop_symbol = "." @@ -709,13 +962,20 @@ inherit .lexical_scope ; pop the type symbols to connect to the attached function (via @using.clause) node typeof attr (typeof) pop_symbol = "@typeof" + node cast + attr (cast) pop_symbol = "()" - edge @using.def -> @type_name.pop_begin + ; We connect to all_pop_begin to be able to resolve both qualified and + ; unqualified instances of the target type + edge @using.def -> @type_name.all_pop_begin edge @type_name.pop_end -> typeof edge typeof -> @using.clause + edge @type_name.pop_end -> cast + edge cast -> @using.clause - ; resolve the target type of the directive - edge @type_name.type_ref -> @using.lexical_scope + ; resolve the target type of the directive on the extended scope so the + ; extension scope gets re-pushed + edge @type_name.type_ref -> @using.extended_scope } [ContractMember @using [UsingDirective [UsingTarget [Asterisk]]]] { @@ -731,7 +991,7 @@ inherit .lexical_scope ;;; Type names ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; TypeName nodes should define two scoped variables: +;; TypeName nodes should define these scoped variables: ;; ;; - @type_name.type_ref represents the node in the graph where we're ready to ;; resolve the type, and thus should generally be connected to a (lexical) @@ -740,12 +1000,19 @@ inherit .lexical_scope ;; - @type_name.output represents the other end of the type and corresponds to a ;; state where the type has already been resolved so we can, for example ;; resolve its members (sink node, outside edges connect *to* here). +;; +;; - @type_name.pop_begin, @type_name.pop_end are used in a definition context, +;; ie. when we need to pop the type name symbol(s) from the symbol stack. +;; Additionally, @type_name.all_pop_begin links to each symbol in a typename +;; (ie. in an identifier path typename), which allows referring to a type both +;; qualified and unqualified. @type_name [TypeName @elementary [ElementaryType]] { let @type_name.type_ref = @elementary.ref let @type_name.output = @elementary.ref let @type_name.pop_begin = @elementary.pop let @type_name.pop_end = @elementary.pop + let @type_name.all_pop_begin = @elementary.pop } @type_name [TypeName @id_path [IdentifierPath]] { @@ -760,6 +1027,7 @@ inherit .lexical_scope let @type_name.pop_begin = @id_path.pop_begin let @type_name.pop_end = @id_path.pop_end + let @type_name.all_pop_begin = @id_path.all_pop_begin } @type_name [TypeName @type_variant ([ArrayTypeName] | [FunctionType])] { @@ -767,6 +1035,7 @@ inherit .lexical_scope let @type_name.output = @type_variant.output let @type_name.pop_begin = @type_variant.pop_begin let @type_name.pop_end = @type_variant.pop_end + let @type_name.all_pop_begin = @type_variant.pop_begin } @type_name [TypeName @mapping [MappingType]] { @@ -774,6 +1043,7 @@ inherit .lexical_scope let @type_name.output = @mapping.output let @type_name.pop_begin = @mapping.pop_begin let @type_name.pop_end = @mapping.pop_end + let @type_name.all_pop_begin = @mapping.pop_begin } @@ -788,76 +1058,130 @@ inherit .lexical_scope node @elementary.pop attr (@elementary.pop) pop_symbol = @elementary.symbol + + ; These variables are a bit redundant, but necessary to easily use elementary + ; types as mapping keys + let @elementary.pop_begin = @elementary.pop + let @elementary.pop_end = @elementary.pop + let @elementary.all_pop_begin = @elementary.pop + + let @elementary.push_begin = @elementary.ref + let @elementary.push_end = @elementary.ref } -@elementary [ElementaryType variant: [AddressType @address [AddressKeyword]]] { - let @elementary.symbol = (format "%{}" (source-text @address)) +@elementary [ElementaryType [AddressType]] { + let @elementary.symbol = "%address" } -@elementary [ElementaryType @keyword ( - [BoolKeyword] - | [ByteKeyword] - | [BytesKeyword] - | [StringKeyword] - | [IntKeyword] - | [UintKeyword] - | [FixedKeyword] - | [UfixedKeyword] -)] { +@elementary [ElementaryType [BoolKeyword]] { + let @elementary.symbol = "%bool" +} + +@elementary [ElementaryType [ByteKeyword]] { + let @elementary.symbol = "%byte" +} + +@elementary [ElementaryType @keyword [BytesKeyword]] { let @elementary.symbol = (format "%{}" (source-text @keyword)) } +@elementary [ElementaryType [StringKeyword]] { + let @elementary.symbol = "%string" +} + +@elementary [ElementaryType @keyword [IntKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "int") { + let @elementary.symbol = "%int256" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + +@elementary [ElementaryType @keyword [UintKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "uint") { + let @elementary.symbol = "%uint256" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + +@elementary [ElementaryType @keyword [FixedKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "fixed") { + let @elementary.symbol = "%fixed128x18" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + +@elementary [ElementaryType @keyword [UfixedKeyword]] { + let symbol = (source-text @keyword) + if (eq symbol "ufixed") { + let @elementary.symbol = "%ufixed128x18" + } else { + let @elementary.symbol = (format "%{}" symbol) + } +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Mappings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@mapping [MappingType] { +@mapping [MappingType + [MappingKey [MappingKeyType @key_type ([IdentifierPath] | [ElementaryType])]] + [MappingValue @value_type [TypeName]] +] { node @mapping.lexical_scope node @mapping.output -} -@mapping [MappingType [MappingKey [MappingKeyType @key_ident [IdentifierPath]]]] { - ; resolve key type - edge @key_ident.push_end -> @mapping.lexical_scope -} - -@mapping [MappingType [MappingValue @value_type [TypeName]]] { - ; for mapping types we don't need to push the type itself, because we don't need it (yet) - ; ditto for the pop path, because a mapping type cannot be the target of a using directive + ; Define the pushing path of the mapping type + ; ValueType <- top of the symbol stack + ; KeyType + ; %mapping <- bottom of the symbol stack + node mapping + attr (mapping) push_symbol = "%Mapping" + edge @mapping.output -> mapping + edge mapping -> @key_type.push_begin + edge @key_type.push_end -> @value_type.output + + ; Both key and value types need to be resolved + edge @value_type.type_ref -> @mapping.lexical_scope + edge @key_type.push_end -> @mapping.lexical_scope - ; The mapping's type exposes the `%index` (ie. `[]`) operator that returns the value type - ; This is similar to arrays, only in that case we have a built-in type where - ; we can define an index function. For mappings we hard-code in the rules directly. + ; The mapping's type exposes the `[]` operator that returns the value type. node typeof_input attr (typeof_input) pop_symbol = "@typeof" - - node index_member - attr (index_member) pop_symbol = "." - node index - attr (index) pop_symbol = "%index" - node index_call - attr (index_call) pop_symbol = "()" + edge @mapping.output -> typeof_input node typeof_output attr (typeof_output) push_symbol = "@typeof" - - edge @mapping.output -> typeof_input - edge typeof_input -> index_member - edge index_member -> index - edge index -> index_call - edge index_call -> typeof_output edge typeof_output -> @value_type.output - ; resolve the value type through our scope - edge @value_type.type_ref -> @mapping.lexical_scope + node index + attr (index) pop_symbol = "[]" + edge typeof_input -> index + edge index -> typeof_output + + ; Special case for mapping public state variables: they can be called + ; like a function with a key, and it's effectively the same as indexing it. + node getter_call + attr (getter_call) pop_symbol = "@as_getter" + edge typeof_input -> getter_call + edge getter_call -> typeof_output + + ; Now we define the "definition" route (aka. the pop route), to use in `using` directives only + ; This is the reverse of the pushing path above (to the `.output` node) + node pop_mapping + attr (pop_mapping) pop_symbol = "%Mapping" - ; We use the value_type's definition path as our own because it's needed when - ; a mapping is the target of a `using` directive. It's not correct, but we - ; don't have the analog referencing path either. let @mapping.pop_begin = @value_type.pop_begin - let @mapping.pop_end = @value_type.pop_end + edge @value_type.pop_end -> @key_type.pop_begin + edge @key_type.pop_end -> pop_mapping + let @mapping.pop_end = pop_mapping } @@ -871,47 +1195,69 @@ inherit .lexical_scope } @array [ArrayTypeName [TypeName] index: [Expression]] { - let @array.type = "%arrayFixed" + let @array.type_symbol = "%FixedArray" } @array [ArrayTypeName [OpenBracket] . [CloseBracket]] { - let @array.type = "%array" + let @array.type_symbol = "%Array" } @array [ArrayTypeName @type_name [TypeName]] { - ; First define the normal, reference route: - - ; We first push the array type `%array`, which should connect to two distinct paths: - ; 1. the typed path, which will use a jump scope entry to resolve the element type - ; 2. the hard-coded path to connect to any `using` directive + ; Define the pushing path of the array type + ; ValueType <- top of the symbol stack + ; %array / %arrayFixed <- bottom of the symbol stack node array - attr (array) push_symbol = @array.type + attr (array) push_symbol = @array.type_symbol edge @array.output -> array + edge array -> @type_name.output - ; For the first path, we need to define a scope jump entry for resolving the element type of the array - node entry - attr (entry) is_exported - node element - attr (element) pop_symbol = "%element" - edge entry -> element - edge element -> @type_name.output + ; Resolve the value type itself + edge @type_name.type_ref -> @array.lexical_scope + ; And also the "type erased" array type so we can resolve built-in members + edge array -> @array.lexical_scope - ; And then the path itself - node params - attr (params) push_scoped_symbol = "<>", scope = entry - edge array -> params + ; Define the path to resolve index access (aka the `[]` operator) - ; Second path, for `using` directives - edge array -> @type_name.output + node typeof_input + attr (typeof_input) pop_symbol = "@typeof" + edge @array.output -> typeof_input - ; Finally, both ends connect to our lexical scope - edge params -> @array.lexical_scope - edge @type_name.type_ref -> @array.lexical_scope + node typeof_output + attr (typeof_output) push_symbol = "@typeof" + edge typeof_output -> @type_name.output + + node index + attr (index) pop_symbol = "[]" + edge typeof_input -> index + edge index -> typeof_output + + ; Special case for public state variables of type array: they can be called + ; like a function with an index, and it's effectively the same as indexing the + ; array. + node getter_call + attr (getter_call) pop_symbol = "@as_getter" + edge typeof_input -> getter_call + edge getter_call -> typeof_output + + ; Define the special `.push()` built-in that returns the element type (for Solidity >= 0.6.0) + if (version-matches ">= 0.6.0") { + node built_in_member + attr (built_in_member) pop_symbol = "." + node push_built_in + attr (push_built_in) pop_symbol = "push" + node built_in_call + attr (built_in_call) pop_symbol = "()" + + edge typeof_input -> built_in_member + edge built_in_member -> push_built_in + edge push_built_in -> built_in_call + edge built_in_call -> typeof_output + } ; Now we define the "definition" route (aka. the pop route), to use in `using` directives only ; This is essentially the reverse of the second path above node pop_array - attr (pop_array) pop_symbol = @array.type + attr (pop_array) pop_symbol = @array.type_symbol let @array.pop_begin = @type_name.pop_begin edge @type_name.pop_end -> pop_array @@ -926,10 +1272,10 @@ inherit .lexical_scope @ftype [FunctionType @attrs [FunctionTypeAttributes]] { ; Compute the built-in type of the function ; %functionExternal provides access to .selector and .address - var type = "%function" + var type_symbol = "%Function" scan (source-text @attrs) { "external" { - set type = "%functionExternal" + set type_symbol = "%ExternalFunction" } } @@ -939,14 +1285,14 @@ inherit .lexical_scope ; This path pushes the function type to the symbol stack ; TODO: add parameter and return types to distinguish between different function types node function_type - attr (function_type) push_symbol = type + attr (function_type) push_symbol = type_symbol edge @ftype.output -> function_type edge function_type -> @ftype.lexical_scope ; the pop path for the using directive node pop_function_type - attr (pop_function_type) pop_symbol = type + attr (pop_function_type) pop_symbol = type_symbol let @ftype.pop_begin = pop_function_type let @ftype.pop_end = pop_function_type @@ -963,8 +1309,9 @@ inherit .lexical_scope @ftype [FunctionType [ReturnsDeclaration [ParametersDeclaration [Parameters . @param [Parameter] .]] ]] { - ; variables of a function type type can be "called" and resolve to the type of - ; the return parameter + ; Variables of a function type type can be "called" and resolve to the type of + ; the return parameter. This is only valid if the function returns a single + ; value. node typeof attr (typeof) pop_symbol = "@typeof" @@ -991,14 +1338,22 @@ inherit .lexical_scope ;; @id_path.pop_end. ;; ;; NOTE: most of the time, and unless this identifier path is the target of a -;; using directive this path will not be used and will form a disconnected -;; graph component. We currently have no way of determining when this path is -;; necessary, so we always construct it. +;; using directive this second path will not be used and will form a +;; disconnected graph component. We currently have no way of determining when +;; this path is necessary, so we always construct it. ;; ;; Additionally the IdentifierPath defines another scoped variable ;; @id_path.rightmost_identifier which corresponds to the identifier in the last -;; position in the path, from left to right. Useful for the using directive to -;; be able to pop the name of the attached function. +;; position in the path, from left to right. This is used in the using directive +;; rules to be able to pop the name of the attached function. + +@id_path [IdentifierPath] { + ; This node connects to all parts of the path, for popping. This allows to + ; connect at any point of the path. Useful for `using` directives when the + ; target type is fully qualified but we want to resolve for the unqualified + ; name. + node @id_path.all_pop_begin +} @id_path [IdentifierPath @name [Identifier]] { node @name.ref @@ -1007,6 +1362,8 @@ inherit .lexical_scope node @name.pop attr (@name.pop) pop_symbol = (source-text @name) + + edge @id_path.all_pop_begin -> @name.pop } @id_path [IdentifierPath @name [Identifier] .] { @@ -1074,14 +1431,15 @@ inherit .lexical_scope } @function [FunctionDefinition @attrs [FunctionAttributes]] { - var function_type = "%function" + var type_symbol = "%Function" scan (source-text @attrs) { "\\b(public|external)\\b" { - set function_type = "%functionExternal" + set type_symbol = "%ExternalFunction" } } node @function.lexical_scope + node @function.extended_scope node @function.def ; this path from the function definition to the scope allows attaching @@ -1089,7 +1447,7 @@ inherit .lexical_scope node typeof attr (typeof) push_symbol = "@typeof" node type_function - attr (type_function) push_symbol = function_type + attr (type_function) push_symbol = type_symbol edge @function.def -> typeof edge typeof -> type_function edge type_function -> @function.lexical_scope @@ -1101,12 +1459,12 @@ inherit .lexical_scope } @function [FunctionDefinition @params parameters: [ParametersDeclaration]] { - edge @params.lexical_scope -> @function.lexical_scope + edge @params.lexical_scope -> @function.extended_scope ;; Input parameters are available in the function scope - edge @function.lexical_scope -> @params.defs + edge @function.extended_scope -> @params.defs ;; ... and shadow other declarations - attr (@function.lexical_scope -> @params.defs) precedence = 1 + attr (@function.extended_scope -> @params.defs) precedence = 1 ;; Connect to paramaters for named argument resolution edge @function.def -> @params.names @@ -1115,12 +1473,12 @@ inherit .lexical_scope @function [FunctionDefinition returns: [ReturnsDeclaration @return_params [ParametersDeclaration] ]] { - edge @return_params.lexical_scope -> @function.lexical_scope + edge @return_params.lexical_scope -> @function.extended_scope ;; Return parameters are available in the function scope - edge @function.lexical_scope -> @return_params.defs + edge @function.extended_scope -> @return_params.defs ;; ... and shadow other declarations - attr (@function.lexical_scope -> @return_params.defs) precedence = 1 + attr (@function.extended_scope -> @return_params.defs) precedence = 1 } ;; Only functions that return a single value have an actual return type @@ -1137,13 +1495,13 @@ inherit .lexical_scope ;; Connect the function body's block lexical scope to the function @function [FunctionDefinition [FunctionBody @block [Block]]] { - edge @block.lexical_scope -> @function.lexical_scope + edge @block.lexical_scope -> @function.extended_scope } @function [FunctionDefinition [FunctionAttributes item: [FunctionAttribute @modifier [ModifierInvocation] ]]] { - edge @modifier.lexical_scope -> @function.lexical_scope + edge @modifier.lexical_scope -> @function.extended_scope } @modifier [ModifierInvocation @name [IdentifierPath]] { @@ -1154,12 +1512,40 @@ inherit .lexical_scope edge @name.push_end -> modifier edge modifier -> @modifier.lexical_scope + + ; This allows resolving @name in the more general scope in constructors (since + ; calling a parent constructor is parsed as a modifier invocation) + let @modifier.identifier = @name.push_end } @modifier [ModifierInvocation @args [ArgumentsDeclaration]] { edge @args.lexical_scope -> @modifier.lexical_scope } +;;; Unnamed functions (deprecated) +@unnamed_function [UnnamedFunctionDefinition] { + node @unnamed_function.lexical_scope + node @unnamed_function.extended_scope +} + +@unnamed_function [UnnamedFunctionDefinition @params parameters: [ParametersDeclaration]] { + edge @params.lexical_scope -> @unnamed_function.extended_scope + + edge @unnamed_function.extended_scope -> @params.defs + attr (@unnamed_function.extended_scope -> @params.defs) precedence = 1 +} + +@unnamed_function [UnnamedFunctionDefinition [FunctionBody @block [Block]]] { + edge @block.lexical_scope -> @unnamed_function.extended_scope +} + +@unnamed_function [UnnamedFunctionDefinition + [UnnamedFunctionAttributes [UnnamedFunctionAttribute @modifier [ModifierInvocation]]] +] { + edge @modifier.lexical_scope -> @unnamed_function.lexical_scope +} + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Constructors @@ -1167,16 +1553,17 @@ inherit .lexical_scope @constructor [ConstructorDefinition] { node @constructor.lexical_scope + node @constructor.extended_scope node @constructor.def } @constructor [ConstructorDefinition @params parameters: [ParametersDeclaration]] { - edge @params.lexical_scope -> @constructor.lexical_scope + edge @params.lexical_scope -> @constructor.extended_scope ;; Input parameters are available in the constructor scope - edge @constructor.lexical_scope -> @params.defs + edge @constructor.extended_scope -> @params.defs ;; ... and shadow other declarations - attr (@constructor.lexical_scope -> @params.defs) precedence = 1 + attr (@constructor.extended_scope -> @params.defs) precedence = 1 ;; Connect to paramaters for named argument resolution edge @constructor.def -> @params.names @@ -1184,13 +1571,14 @@ inherit .lexical_scope ;; Connect the constructor body's block lexical scope to the constructor @constructor [ConstructorDefinition @block [Block]] { - edge @block.lexical_scope -> @constructor.lexical_scope + edge @block.lexical_scope -> @constructor.extended_scope } @constructor [ConstructorDefinition [ConstructorAttributes item: [ConstructorAttribute @modifier [ModifierInvocation] ]]] { - edge @modifier.lexical_scope -> @constructor.lexical_scope + edge @modifier.lexical_scope -> @constructor.extended_scope + edge @modifier.identifier -> @constructor.lexical_scope } @contract [ContractDefinition [ContractMembers [ContractMember @@ -1200,7 +1588,9 @@ inherit .lexical_scope edge @contract.def -> @constructor.def } -;; Solidity < 0.5.0 constructors were declared as functions of the contract's name +;; Solidity < 0.5.0 constructors +;; They were declared as functions of the contract's name + @contract [ContractDefinition @contract_name [Identifier] [ContractMembers [ContractMember [FunctionDefinition @@ -1216,6 +1606,21 @@ inherit .lexical_scope } } +[ContractDefinition + @contract_name [Identifier] + [ContractMembers [ContractMember @function [FunctionDefinition + [FunctionName @function_name [Identifier]] + [FunctionAttributes [FunctionAttribute @modifier [ModifierInvocation]]] + ]]] +] { + if (version-matches "< 0.5.0") { + if (eq (source-text @contract_name) (source-text @function_name)) { + ; Parent constructor calls are parsed as modifier invocations + edge @modifier.identifier -> @function.lexical_scope + } + } +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Fallback and receive functions @@ -1223,14 +1628,15 @@ inherit .lexical_scope @fallback [FallbackFunctionDefinition] { node @fallback.lexical_scope + node @fallback.extended_scope } @fallback [FallbackFunctionDefinition @params parameters: [ParametersDeclaration]] { - edge @params.lexical_scope -> @fallback.lexical_scope + edge @params.lexical_scope -> @fallback.extended_scope ;; Input parameters are available in the fallback function scope - edge @fallback.lexical_scope -> @params.defs - attr (@fallback.lexical_scope -> @params.defs) precedence = 1 + edge @fallback.extended_scope -> @params.defs + attr (@fallback.extended_scope -> @params.defs) precedence = 1 } @fallback [FallbackFunctionDefinition returns: [ReturnsDeclaration @@ -1239,12 +1645,12 @@ inherit .lexical_scope edge @return_params.lexical_scope -> @fallback.lexical_scope ;; Return parameters are available in the fallback function scope - edge @fallback.lexical_scope -> @return_params.defs - attr (@fallback.lexical_scope -> @return_params.defs) precedence = 1 + edge @fallback.extended_scope -> @return_params.defs + attr (@fallback.extended_scope -> @return_params.defs) precedence = 1 } @fallback [FallbackFunctionDefinition [FunctionBody @block [Block]]] { - edge @block.lexical_scope -> @fallback.lexical_scope + edge @block.lexical_scope -> @fallback.extended_scope } @fallback [FallbackFunctionDefinition [FallbackFunctionAttributes @@ -1255,10 +1661,11 @@ inherit .lexical_scope @receive [ReceiveFunctionDefinition] { node @receive.lexical_scope + node @receive.extended_scope } @receive [ReceiveFunctionDefinition [FunctionBody @block [Block]]] { - edge @block.lexical_scope -> @receive.lexical_scope + edge @block.lexical_scope -> @receive.extended_scope } @receive [ReceiveFunctionDefinition [ReceiveFunctionAttributes @@ -1275,6 +1682,7 @@ inherit .lexical_scope @modifier [ModifierDefinition] { node @modifier.def node @modifier.lexical_scope + node @modifier.extended_scope } @modifier [ModifierDefinition @@ -1284,7 +1692,7 @@ inherit .lexical_scope attr (@modifier.def) node_definition = @name attr (@modifier.def) definiens_node = @modifier - edge @body.lexical_scope -> @modifier.lexical_scope + edge @body.lexical_scope -> @modifier.extended_scope ; Special case: bind the place holder statement `_` to the built-in ; `%placeholder`. This only happens in the body of a modifier. @@ -1299,11 +1707,11 @@ inherit .lexical_scope } @modifier [ModifierDefinition @params [ParametersDeclaration]] { - edge @params.lexical_scope -> @modifier.lexical_scope + edge @params.lexical_scope -> @modifier.extended_scope ;; Input parameters are available in the modifier scope - edge @modifier.lexical_scope -> @params.defs - attr (@modifier.lexical_scope -> @params.defs) precedence = 1 + edge @modifier.extended_scope -> @params.defs + attr (@modifier.extended_scope -> @params.defs) precedence = 1 } @@ -1391,7 +1799,6 @@ inherit .lexical_scope @expr_stmt [ExpressionStatement] { node @expr_stmt.lexical_scope - node @expr_stmt.defs } @@ -1399,32 +1806,46 @@ inherit .lexical_scope @stmt [Statement @var_decl [VariableDeclarationStatement]] { edge @var_decl.lexical_scope -> @stmt.lexical_scope - edge @stmt.defs -> @var_decl.defs + edge @stmt.defs -> @var_decl.def } @var_decl [VariableDeclarationStatement] { node @var_decl.lexical_scope - node @var_decl.defs + node @var_decl.def } @var_decl [VariableDeclarationStatement [VariableDeclarationType @var_type [TypeName]] @name name: [Identifier] ] { - node def - attr (def) node_definition = @name - attr (def) definiens_node = @var_decl + attr (@var_decl.def) node_definition = @name + attr (@var_decl.def) definiens_node = @var_decl - edge @var_decl.defs -> def edge @var_type.type_ref -> @var_decl.lexical_scope node typeof attr (typeof) push_symbol = "@typeof" - edge def -> typeof + edge @var_decl.def -> typeof edge typeof -> @var_type.output } +@var_decl [VariableDeclarationStatement + [VariableDeclarationType [VarKeyword]] + @name name: [Identifier] +] { + attr (@var_decl.def) node_definition = @name + attr (@var_decl.def) definiens_node = @var_decl +} + +@var_decl [VariableDeclarationStatement + [VariableDeclarationType [VarKeyword]] + [VariableDeclarationValue @value [Expression]] +] { + edge @var_decl.def -> @value.output +} + + ;;; Tuple deconstruction statements @@ -1498,11 +1919,20 @@ inherit .lexical_scope ;; For loops @stmt [Statement [ForStatement - initialization: [ForStatementInitialization - @init_stmt ([ExpressionStatement] - | [VariableDeclarationStatement] - | [TupleDeconstructionStatement]) - ] + initialization: [ForStatementInitialization @init_stmt [ExpressionStatement]] +]] { + edge @init_stmt.lexical_scope -> @stmt.lexical_scope +} + +@stmt [Statement [ForStatement + initialization: [ForStatementInitialization @init_stmt [VariableDeclarationStatement]] +]] { + edge @init_stmt.lexical_scope -> @stmt.lexical_scope + edge @stmt.init_defs -> @init_stmt.def +} + +@stmt [Statement [ForStatement + initialization: [ForStatementInitialization @init_stmt [TupleDeconstructionStatement]] ]] { edge @init_stmt.lexical_scope -> @stmt.lexical_scope edge @stmt.init_defs -> @init_stmt.defs @@ -1640,6 +2070,7 @@ inherit .lexical_scope @state_var [StateVariableDefinition] { node @state_var.lexical_scope + node @state_var.extended_scope node @state_var.def } @@ -1652,11 +2083,36 @@ inherit .lexical_scope edge @type_name.type_ref -> @state_var.lexical_scope - node typeof - attr (typeof) push_symbol = "@typeof" + node @state_var.typeof + attr (@state_var.typeof) push_symbol = "@typeof" - edge @state_var.def -> typeof - edge typeof -> @type_name.output + edge @state_var.def -> @state_var.typeof + edge @state_var.typeof -> @type_name.output +} + +@state_var [StateVariableDefinition + [StateVariableAttributes [StateVariableAttribute [PublicKeyword]]] +] { + ; Public state variables are used as functions when invoked from an external contract + node call + attr (call) pop_symbol = "()" + + ; In the general case using the getter can bind to the state variable's type + edge @state_var.def -> call + edge call -> @state_var.typeof + + ; Some complex types generate special getters (ie. arrays and mappings index + ; their contents, structs flatten most of their fields and return a tuple) + node getter + attr (getter) push_symbol = "@as_getter" + edge call -> getter + edge getter -> @state_var.typeof +} + +@state_var [StateVariableDefinition + [StateVariableDefinitionValue @value [Expression]] +] { + let @value.lexical_scope = @state_var.extended_scope } @@ -1664,13 +2120,11 @@ inherit .lexical_scope ;;; Enum definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@enum [EnumDefinition] { +@enum [EnumDefinition @name name: [Identifier]] { node @enum.lexical_scope node @enum.def node @enum.members -} -@enum [EnumDefinition @name name: [Identifier]] { attr (@enum.def) node_definition = @name attr (@enum.def) definiens_node = @enum @@ -1682,9 +2136,9 @@ inherit .lexical_scope ; Path to resolve the built-in type for enums (which is the same as for integer types) node type - attr (type) pop_symbol = "%type" + attr (type) pop_symbol = "@type" node type_enum_type - attr (type_enum_type) push_symbol = "%typeIntType" + attr (type_enum_type) push_symbol = "%IntTypeType" edge @enum.def -> type edge type -> type_enum_type edge type_enum_type -> @enum.lexical_scope @@ -1705,73 +2159,61 @@ inherit .lexical_scope ;;; Structure definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@struct [StructDefinition] { +@struct [StructDefinition @name name: [Identifier]] { node @struct.lexical_scope node @struct.def node @struct.members -} -@struct [StructDefinition @name name: [Identifier]] { - ; Since we use structs to define built-in types and some of them (ie. array) - ; have have a parametric type, we define two distinct paths to define a - ; struct: - ; 1. the normal, non parametric path, should drop scopes in the scope stack first of all - ; 2. the parametric path, that pops a scope to resolve the parametric type - ; Both of these connect to the node that pops the struct identifier symbol - - ; First the normal path - node struct_drop - attr (struct_drop) type = "drop_scopes" - edge @struct.def -> struct_drop - - ; Second path, pops the scope - node typed_params - attr (typed_params) pop_scoped_symbol = "<>" - edge @struct.def -> typed_params - - ; Connect both to the struct identifier - node def - attr (def) node_definition = @name - attr (def) definiens_node = @struct - edge struct_drop -> def - edge typed_params -> def - - ; On the other end, to properly close the second path we need to jump to the popped scope - ; (this is why on the other path we drop scopes) - edge @struct.lexical_scope -> JUMP_TO_SCOPE_NODE + attr (@struct.def) node_definition = @name + attr (@struct.def) definiens_node = @struct ; Now connect normally to the struct members - node type_def - attr (type_def) pop_symbol = "@typeof" + node @struct.typeof + attr (@struct.typeof) pop_symbol = "@typeof" node member attr (member) pop_symbol = "." - edge def -> type_def - edge type_def -> member + edge @struct.def -> @struct.typeof + edge @struct.typeof -> member edge member -> @struct.members ; Bind member names when using construction with named arguments node param_names attr (param_names) pop_symbol = "@param_names" - edge def -> param_names + edge @struct.def -> param_names edge param_names -> @struct.members + + ; Used as a function call (ie. casting), should bind to itself + node call + attr (call) pop_symbol = "()" + edge @struct.def -> call + edge call -> member } @struct [StructDefinition [StructMembers @member item: [StructMember @type_name [TypeName] @name name: [Identifier]] ]] { - node def - attr (def) node_definition = @name - attr (def) definiens_node = @member + node @member.def + attr (@member.def) node_definition = @name + attr (@member.def) definiens_node = @member - edge @struct.members -> def + edge @struct.members -> @member.def edge @type_name.type_ref -> @struct.lexical_scope - node typeof - attr (typeof) push_symbol = "@typeof" + node @member.typeof + attr (@member.typeof) push_symbol = "@typeof" - edge def -> typeof - edge typeof -> @type_name.output + edge @member.def -> @member.typeof + edge @member.typeof -> @type_name.output +} + +@struct [StructDefinition [StructMembers . @first_member [StructMember]]] { + ; As a public getter result, the value returned is a tuple with all our fields flattened + ; We only care about the first member for name binding, since tuples are not real types + node getter_call + attr (getter_call) pop_symbol = "@as_getter" + edge @struct.typeof -> getter_call + edge getter_call -> @first_member.typeof } @@ -1824,6 +2266,15 @@ inherit .lexical_scope node @error.params attr (@error.params) pop_symbol = "@param_names" edge @error.def -> @error.params + + ; Bind to built-in errorType for accessing built-in member `.selector` + node typeof + attr (typeof) push_symbol = "@typeof" + node error_type + attr (error_type) push_symbol = "%ErrorType" + edge @error.def -> typeof + edge typeof -> error_type + edge error_type -> @error.lexical_scope } @error [ErrorDefinition [ErrorParametersDeclaration [ErrorParameters @@ -1867,17 +2318,59 @@ inherit .lexical_scope edge @type_name.type_ref -> @constant.lexical_scope } -@user_type [UserDefinedValueTypeDefinition] { +@user_type [UserDefinedValueTypeDefinition @name [Identifier] @value_type [ElementaryType]] { node @user_type.lexical_scope node @user_type.def -} -@user_type [UserDefinedValueTypeDefinition @name [Identifier]] { - node def - attr (def) node_definition = @name - attr (def) definiens_node = @user_type + attr (@user_type.def) node_definition = @name + attr (@user_type.def) definiens_node = @user_type + + ; Provide member resolution through the built-in `%userTypeType` + ; Because the built-in is defined as a struct, we need to push an extra `@typeof` + node member_guard + attr (member_guard) pop_symbol = "." + node member + attr (member) push_symbol = "." + node typeof + attr (typeof) push_symbol = "@typeof" + node user_type_type + attr (user_type_type) push_symbol = "%UserDefinedValueType" - edge @user_type.def -> def + edge @user_type.def -> member_guard + edge member_guard -> member + edge member -> typeof + edge typeof -> user_type_type + edge user_type_type -> @user_type.lexical_scope + + ; Hard-code built-in functions `wrap` and `unwrap` in order to be able to + ; resolve their return types + node wrap + attr (wrap) pop_symbol = "wrap" + node wrap_call + attr (wrap_call) pop_symbol = "()" + node wrap_typeof + attr (wrap_typeof) push_symbol = "@typeof" + + edge member_guard -> wrap + edge wrap -> wrap_call + edge wrap_call -> wrap_typeof + edge wrap_typeof -> @value_type.ref + edge @value_type.ref -> @user_type.lexical_scope + + node unwrap + attr (unwrap) pop_symbol = "unwrap" + node unwrap_call + attr (unwrap_call) pop_symbol = "()" + node unwrap_typeof + attr (unwrap_typeof) push_symbol = "@typeof" + node type_ref + attr (type_ref) push_symbol = (source-text @name) + + edge member_guard -> unwrap + edge unwrap -> unwrap_call + edge unwrap_call -> unwrap_typeof + edge unwrap_typeof -> type_ref + edge type_ref -> @user_type.lexical_scope } @@ -1897,9 +2390,7 @@ inherit .lexical_scope } ;; Identifier expressions -@expr [Expression @name ( - variant: [Identifier] | variant: [SuperKeyword] | variant: [ThisKeyword] -)] { +@expr [Expression @name [Identifier]] { node ref attr (ref) node_reference = @name attr (ref) parents = [@expr.enclosing_def] @@ -1908,6 +2399,14 @@ inherit .lexical_scope edge @expr.output -> ref } +@expr [Expression @keyword ([ThisKeyword] | [SuperKeyword])] { + ; This is almost equivalent to the above rule, except it doesn't generate a reference + node keyword + attr (keyword) push_symbol = (source-text @keyword) + edge keyword -> @expr.lexical_scope + edge @expr.output -> keyword +} + ;; Member access expressions @expr [Expression [MemberAccessExpression @operand operand: [Expression] @@ -1926,10 +2425,7 @@ inherit .lexical_scope edge @expr.output -> @name.ref ; Shortcut path for expressions inside contracts with using X for * directives - node star - attr (star) push_symbol = "@*" - edge member -> star - edge star -> @expr.lexical_scope + edge member -> @expr.star_extension } ;; Special case: member accesses to `super` are tagged with "super" to rank @@ -1941,21 +2437,31 @@ inherit .lexical_scope attr (@name.ref) tag = "super" } +;; Elementary types used as expressions (eg. for type casting, or for built-ins like `string.concat`) +@expr [Expression @type [ElementaryType]] { + edge @expr.output -> @type.ref + edge @type.ref -> @expr.lexical_scope + + ; Elementary types can also be used for casting; instead of defining built-in + ; struct for each available elementary type, we define a special path here + node call + attr (call) pop_symbol = "()" + node typeof + attr (typeof) push_symbol = "@typeof" + edge @expr.output -> call + edge call -> typeof + edge typeof -> @type.ref +} + ;; Index access expressions @expr [Expression [IndexAccessExpression @operand operand: [Expression] ]] { - node index_call - attr (index_call) push_symbol = "()" node index - attr (index) push_symbol = "%index" - node index_member - attr (index_member) push_symbol = "." + attr (index) push_symbol = "[]" - edge @expr.output -> index_call - edge index_call -> index - edge index -> index_member - edge index_member -> @operand.output + edge @expr.output -> index + edge index -> @operand.output } ;; Type expressions @@ -1968,7 +2474,7 @@ inherit .lexical_scope node typeof attr (typeof) push_symbol = "@typeof" node type - attr (type) push_symbol = "%typeIntType" + attr (type) push_symbol = "%IntTypeType" edge @type_expr.output -> typeof edge typeof -> type @@ -1980,7 +2486,7 @@ inherit .lexical_scope node typeof attr (typeof) push_symbol = "@typeof" node type - attr (type) push_symbol = "%type" + attr (type) push_symbol = "@type" edge @type_expr.output -> typeof edge typeof -> type @@ -2044,7 +2550,7 @@ inherit .lexical_scope attr (@options.refs) push_symbol = "@param_names" node call_options - attr (call_options) push_symbol = "%callOptions" + attr (call_options) push_symbol = "%CallOptions" edge @options.refs -> call_options edge call_options -> @expr.lexical_scope @@ -2058,6 +2564,137 @@ inherit .lexical_scope } +;;; Payable +; These work like `address`, should they should bind to `%address` +@expr [Expression [PayableKeyword]] { + node ref + attr (ref) push_symbol = "%address" + + edge ref -> @expr.lexical_scope + edge @expr.output -> ref +} + + +;;; Tuple expressions + +; Parenthesized expressions are parsed as tuples of a single value +@expr [Expression [TupleExpression [TupleValues . [TupleValue @operand [Expression]] .]]] { + edge @expr.output -> @operand.output +} + +;;; Arithmetic, bitwise & logical operators, etc + +; Bind to the left operand only: assignment expressions +@expr [Expression [_ + @left_operand left_operand: [Expression] + ( + [Equal] + | [BarEqual] + | [PlusEqual] + | [MinusEqual] + | [CaretEqual] + | [SlashEqual] + | [PercentEqual] + | [AsteriskEqual] + | [AmpersandEqual] + | [LessThanLessThanEqual] + | [GreaterThanGreaterThanEqual] + | [GreaterThanGreaterThanGreaterThanEqual] + ) +]] { + edge @expr.output -> @left_operand.output +} + +; Unary operators postfix +@expr [Expression [_ + @operand operand: [Expression] + ([PlusPlus] | [MinusMinus]) +]] { + edge @expr.output -> @operand.output +} + +; Unary operators prefix +@expr [Expression [_ + ([PlusPlus] | [MinusMinus] | [Tilde] | [Bang] | [Minus] | [Plus]) + @operand operand: [Expression] +]] { + edge @expr.output -> @operand.output +} + +; Bind to both operands: logical and/or, arithmetic, bit-wise expressions +@expr [Expression [_ + @left_operand left_operand: [Expression] + ( + [BarBar] + | [AmpersandAmpersand] + + | [Plus] + | [Minus] + | [Asterisk] + | [Slash] + | [Percent] + | [AsteriskAsterisk] + + | [Bar] + | [Caret] + | [Ampersand] + + | [LessThanLessThan] + | [GreaterThanGreaterThan] + | [GreaterThanGreaterThanGreaterThan] + ) + @right_operand right_operand: [Expression] +]] { + edge @expr.output -> @left_operand.output + edge @expr.output -> @right_operand.output +} + +; Comparison operators bind to bool type +@expr [Expression [_ + ( + [EqualEqual] + | [BangEqual] + | [LessThan] + | [GreaterThan] + | [LessThanEqual] + | [GreaterThanEqual] + ) +]] { + node typeof + attr (typeof) push_symbol = "@typeof" + node bool + attr (bool) push_symbol = "%bool" + edge @expr.output -> typeof + edge typeof -> bool + edge bool -> @expr.lexical_scope +} + +; Ternary conditional expression binds to both branches +@expr [Expression [ConditionalExpression + @true_expression true_expression: [Expression] + @false_expression false_expression: [Expression] +]] { + edge @expr.output -> @true_expression.output + edge @expr.output -> @false_expression.output +} + + +;;; Literal Address Expressions +@expr [Expression [HexNumberExpression @hex_literal [HexLiteral]]] { + scan (source-text @hex_literal) { + "0x[0-9a-fA-F]{40}" { + ; Treat it as a valid address + node typeof + attr (typeof) push_symbol = "@typeof" + node address + attr (address) push_symbol = "%address" + edge @expr.output -> typeof + edge typeof -> address + edge address -> @expr.lexical_scope + } + } +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Yul @@ -2167,6 +2804,38 @@ inherit .lexical_scope ;; parameters) are functions (ie. the body of the function doesn't have access ;; to any outside variables) edge @fundef.lexical_scope -> @block.function_defs + ; Exception: but outside constants *are* available, so we provide a guarded + ; access to the parent lexical scope. This guard will be popped to link to + ; available constants. + node yul_function_guard + attr (yul_function_guard) push_symbol = "@in_yul_function" + edge @fundef.lexical_scope -> yul_function_guard + edge yul_function_guard -> @block.lexical_scope +} + +;; Constants need to be available inside Yul functions. This is an exception +;; since no other external identifiers are, so the path is guarded. We create a +;; scope in the source unit, contracts and libraries, and guard it from the +;; lexical scope, so we can link constant definitions here. See the dual path in +;; the rule above. +@constant_container ([SourceUnit] | [ContractDefinition] | [LibraryDefinition]) { + node @constant_container.yul_functions_guarded_scope + attr (@constant_container.yul_functions_guarded_scope) pop_symbol = "@in_yul_function" + edge @constant_container.lexical_scope -> @constant_container.yul_functions_guarded_scope +} + +;; Make top-level constants available inside Yul functions +@source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @constant [ConstantDefinition]]]] { + edge @source_unit.yul_functions_guarded_scope -> @constant.def +} + +;; Ditto for contracts, interfaces and libraries +@contract [_ members: [_ [ContractMember + @constant [StateVariableDefinition + [StateVariableAttributes [StateVariableAttribute [ConstantKeyword]]] + ] +]]] { + edge @contract.yul_functions_guarded_scope -> @constant.def } @fundef [YulFunctionDefinition @@ -2282,11 +2951,60 @@ inherit .lexical_scope node @path.lexical_scope } -@path [YulPath @name [YulIdentifier]] { +@path [YulPath . @name [YulIdentifier]] { node ref attr (ref) node_reference = @name edge ref -> @path.lexical_scope + + if (version-matches "< 0.7.0") { + ; Before Solidity 0.7.0 storage variables' `.offset` and `.slot` were + ; accessed by suffixing the name with `_offset` and `_slot` + scan (source-text @name) { + "^(.*)_(slot|offset|length)$" { + let symbol = $0 + let without_suffix = $1 + let suffix = $2 + + ; We bind the whole symbol to the built-in field for the known cases + node pop_ref + attr (pop_ref) pop_symbol = symbol + node push_suffixless + attr (push_suffixless) push_symbol = suffix + node member_of + attr (member_of) push_symbol = "." + node typeof + attr (typeof) push_symbol = "@typeof" + node yul_external + attr (yul_external) push_symbol = "%YulExternal" + + edge ref -> pop_ref + edge pop_ref -> push_suffixless + edge push_suffixless -> member_of + edge member_of -> typeof + edge typeof -> yul_external + edge yul_external -> @path.lexical_scope + } + } + } +} + +@path [YulPath [Period] @member [YulIdentifier] .] { + ; Yul variable members only apply to external variables and hence are + ; automatically bound to a special %YulExternal built-in + node ref + attr (ref) node_reference = @member + node member_of + attr (member_of) push_symbol = "." + node typeof + attr (typeof) push_symbol = "@typeof" + node yul_external + attr (yul_external) push_symbol = "%YulExternal" + + edge ref -> member_of + edge member_of -> typeof + edge typeof -> yul_external + edge yul_external -> @path.lexical_scope } @expr [YulExpression @funcall [YulFunctionCallExpression]] { diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins.rs b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins.rs index 492dbe0f36..ac045e03e6 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins.rs @@ -26,10 +26,14 @@ pub fn get_contents(version: &Version) -> &'static str { include_str!("./built_ins/0.7.0.sol") } else if *version < Version::new(0, 8, 2) { include_str!("./built_ins/0.8.0.sol") - } else if *version < Version::new(0, 8, 7) { + } else if *version < Version::new(0, 8, 4) { include_str!("./built_ins/0.8.2.sol") - } else if *version < Version::new(0, 8, 11) { + } else if *version < Version::new(0, 8, 7) { + include_str!("./built_ins/0.8.4.sol") + } else if *version < Version::new(0, 8, 8) { include_str!("./built_ins/0.8.7.sol") + } else if *version < Version::new(0, 8, 11) { + include_str!("./built_ins/0.8.8.sol") } else if *version < Version::new(0, 8, 18) { include_str!("./built_ins/0.8.11.sol") } else if *version < Version::new(0, 8, 24) { diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.11.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.11.sol index 282a1cb7e5..a012478422 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.11.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.11.sol @@ -18,27 +18,25 @@ contract $BuiltIns$ { function sha256(bytes memory) public returns (bytes32); function sha3(bytes memory) public returns (bytes32); function suicide(address payable recipient) public; - struct $abiType { + struct $AbiType { } struct $address { uint256 balance; function(bytes memory) returns (bool) call; function(bytes memory) returns (bool, bytes memory) callcode; function(bytes memory) returns (bool) delegatecall; - function(uint256) returns (bool) send; - function(uint256) transfer; + function(uint256 amount) returns (bool) send; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function($element) returns (uint) push; + function($ValueType element) returns (uint) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -47,38 +45,52 @@ contract $BuiltIns$ { function(uint) returns (bytes32) blockhash; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $functionExternal { - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; uint256 gas; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.17.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.17.sol index 453f95ccf2..3ad1ac662a 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.17.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.17.sol @@ -18,27 +18,25 @@ contract $BuiltIns$ { function sha256(bytes memory) public returns (bytes32); function sha3(bytes memory) public returns (bytes32); function suicide(address payable recipient) public; - struct $abiType { + struct $AbiType { } struct $address { uint256 balance; function(bytes memory) returns (bool) call; function(bytes memory) returns (bool, bytes memory) callcode; function(bytes memory) returns (bool) delegatecall; - function(uint256) returns (bool) send; - function(uint256) transfer; + function(uint256 amount) returns (bool) send; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function($element) returns (uint) push; + function($ValueType element) returns (uint) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -47,39 +45,53 @@ contract $BuiltIns$ { function(uint) returns (bytes32) blockhash; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; uint256 gas; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.22.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.22.sol index 49d650431a..e0928e5bb4 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.22.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.4.22.sol @@ -22,31 +22,29 @@ contract $BuiltIns$ { function sha256(bytes memory) public returns (bytes32); function sha3(bytes memory) public returns (bytes32); function suicide(address payable recipient) public; - struct $abiType { - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool) call; function(bytes memory) returns (bool, bytes memory) callcode; function(bytes memory) returns (bool) delegatecall; - function(uint256) returns (bool) send; - function(uint256) transfer; + function(uint256 amount) returns (bool) send; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function($element) returns (uint) push; + function($ValueType element) returns (uint) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -55,39 +53,53 @@ contract $BuiltIns$ { function(uint) returns (bytes32) blockhash; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; uint256 gas; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.0.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.0.sol index c722b7c163..18996d2bb1 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.0.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.0.sol @@ -20,32 +20,30 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function($element) returns (uint) push; + function($ValueType element) returns (uint) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -53,38 +51,52 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.3.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.3.sol index 49de4c27d9..5dd4bb0750 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.3.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.5.3.sol @@ -20,32 +20,30 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function($element) returns (uint) push; + function($ValueType element) returns (uint) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -53,40 +51,54 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.0.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.0.sol index 706f342a98..2fcabbc92e 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.0.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.0.sol @@ -20,33 +20,31 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -54,40 +52,54 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.2.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.2.sol index bbedd35ca0..dc00818947 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.2.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.2.sol @@ -20,33 +20,31 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -54,45 +52,59 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; + } + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.7.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.7.sol index 1bb40d1749..4a57dfa48f 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.7.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.7.sol @@ -20,33 +20,31 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -54,47 +52,61 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; + } + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { + } + struct $YulExternal { + uint slot; + uint offset; + uint length; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.8.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.8.sol index 51bc2829fd..a20e478f50 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.8.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.6.8.sol @@ -20,33 +20,31 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -54,49 +52,63 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $Function { + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; + } + struct $ExternalFunction { + bytes4 selector; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $txType tx; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.7.0.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.7.0.sol index ce5c90338a..6c4e69b5d9 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.7.0.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.7.0.sol @@ -20,33 +20,31 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -54,46 +52,58 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $selector selector; + struct $Function { + } + struct $ExternalFunction { + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address payable origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.0.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.0.sol index 67a4546951..4626514db5 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.0.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.0.sol @@ -15,12 +15,12 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -28,22 +28,20 @@ contract $BuiltIns$ { bytes32 codehash; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { uint chainid; address payable coinbase; uint difficulty; @@ -52,46 +50,58 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $selector selector; + struct $Function { + } + struct $ExternalFunction { + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.11.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.11.sol index a5a050182f..4fd057bb07 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.11.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.11.sol @@ -15,13 +15,13 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function(function(), $args) returns (bytes memory) encodeCall; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function(function() functionPointer, $Any[] functionArgumentsTuple) returns (bytes memory) encodeCall; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -29,22 +29,20 @@ contract $BuiltIns$ { bytes32 codehash; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { uint basefee; uint chainid; address payable coinbase; @@ -54,47 +52,66 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $address address; - $selector selector; + struct $ErrorType { + bytes4 selector; + } + struct $Function { + } + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $UserDefinedValueType { + function($WrappedType elementaryType) returns ($UserType) wrap; + function($UserType userType) returns ($WrappedType) unwrap; + } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.18.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.18.sol index 8fd9b32c01..edf82c7c7d 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.18.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.18.sol @@ -15,13 +15,13 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function(function(), $args) returns (bytes memory) encodeCall; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function(function() functionPointer, $Any[] functionArgumentsTuple) returns (bytes memory) encodeCall; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -29,22 +29,20 @@ contract $BuiltIns$ { bytes32 codehash; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { uint basefee; uint chainid; address payable coinbase; @@ -55,47 +53,66 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $address address; - $selector selector; + struct $ErrorType { + bytes4 selector; + } + struct $Function { + } + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $UserDefinedValueType { + function($WrappedType elementaryType) returns ($UserType) wrap; + function($UserType userType) returns ($WrappedType) unwrap; + } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.2.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.2.sol index c3be365f51..be45a8cbf4 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.2.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.2.sol @@ -15,12 +15,12 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -28,22 +28,20 @@ contract $BuiltIns$ { bytes32 codehash; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { uint chainid; address payable coinbase; uint difficulty; @@ -52,47 +50,59 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $address address; - $selector selector; + struct $Function { + } + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.24.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.24.sol index d461e13b67..5b537bd6f5 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.24.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.24.sol @@ -16,13 +16,13 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function(function(), $args) returns (bytes memory) encodeCall; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function(function() functionPointer, $Any[] functionArgumentsTuple) returns (bytes memory) encodeCall; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -30,22 +30,20 @@ contract $BuiltIns$ { bytes32 codehash; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { uint basefee; uint blobbasefee; uint chainid; @@ -57,47 +55,66 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $address address; - $selector selector; + struct $ErrorType { + bytes4 selector; + } + struct $Function { + } + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $UserDefinedValueType { + function($WrappedType elementaryType) returns ($UserType) wrap; + function($UserType userType) returns ($WrappedType) unwrap; + } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.26.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.26.sol index 51b4ea13a5..b27eff44b4 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.26.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.26.sol @@ -17,13 +17,13 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function(function(), $args) returns (bytes memory) encodeCall; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function(function() functionPointer, $Any[] functionArgumentsTuple) returns (bytes memory) encodeCall; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -31,22 +31,20 @@ contract $BuiltIns$ { bytes32 codehash; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { uint basefee; uint blobbasefee; uint chainid; @@ -58,47 +56,66 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $address address; - $selector selector; + struct $ErrorType { + bytes4 selector; + } + struct $Function { + } + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $UserDefinedValueType { + function($WrappedType elementaryType) returns ($UserType) wrap; + function($UserType userType) returns ($WrappedType) unwrap; + } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.4.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.4.sol new file mode 100644 index 0000000000..4ac08e94dd --- /dev/null +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.4.sol @@ -0,0 +1,111 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +contract $BuiltIns$ { + function addmod(uint x, uint y, uint k) public returns (uint); + function assert(bool condition) public; + function blockhash(uint blockNumber) public returns (bytes32); + function ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public returns (address); + function gasleft() public returns (uint256); + function keccak256(bytes memory) public returns (bytes32); + function mulmod(uint x, uint y, uint k) public returns (uint); + function require(bool condition) public; + function require(bool condition, string memory message) public; + function revert() public; + function revert(string memory reason) public; + function ripemd160(bytes memory) public returns (bytes20); + function selfdestruct(address payable recipient) public; + function sha256(bytes memory) public returns (bytes32); + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; + } + struct $address { + uint256 balance; + bytes code; + bytes32 codehash; + function(bytes memory) returns (bool, bytes memory) call; + function(bytes memory) returns (bool, bytes memory) delegatecall; + function(uint256 amount) returns (bool) send; + function(bytes memory) returns (bool, bytes memory) staticcall; + function(uint256 amount) transfer; + } + struct $Array { + uint length; + function() returns ($ValueType) push; + function($ValueType element) push; + function() pop; + } + struct $FixedArray { + uint length; + } + struct $BlockType { + uint chainid; + address payable coinbase; + uint difficulty; + uint gaslimit; + uint number; + uint timestamp; + } + struct $bytes { + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $CallOptions { + uint gas; + uint salt; + uint value; + } + struct $ErrorType { + bytes4 selector; + } + struct $Function { + } + struct $ExternalFunction { + address address; + bytes4 selector; + } + struct $MessageType { + bytes data; + address sender; + bytes4 sig; + uint value; + } + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; + } + struct $TransactionType { + uint gasprice; + address origin; + } + struct $ContractTypeType { + string name; + bytes creationCode; + bytes runtimeCode; + bytes4 interfaceId; + } + struct $InterfaceTypeType { + string name; + bytes4 interfaceId; + } + struct $IntTypeType { + int min; + int max; + } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; +} diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.7.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.7.sol index 0ca8106588..503367efb7 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.7.sol +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.7.sol @@ -15,12 +15,12 @@ contract $BuiltIns$ { function ripemd160(bytes memory) public returns (bytes20); function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); - struct $abiType { - function(bytes memory, $args) returns ($args) decode; - function($args) returns (bytes memory) encode; - function($args) returns (bytes memory) encodePacked; - function(bytes4 selector, $args) returns (bytes memory) encodeWithSelector; - function(string memory, $args) returns (bytes memory) encodeWithSignature; + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -28,22 +28,20 @@ contract $BuiltIns$ { bytes32 codehash; function(bytes memory) returns (bool, bytes memory) call; function(bytes memory) returns (bool, bytes memory) delegatecall; - function(uint256) returns (bool) send; + function(uint256 amount) returns (bool) send; function(bytes memory) returns (bool, bytes memory) staticcall; - function(uint256) transfer; + function(uint256 amount) transfer; } - struct $array { + struct $Array { uint length; - function(uint) returns ($element) $index; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType element) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; - function(uint) returns ($element) $index; } - struct $blockType { + struct $BlockType { uint basefee; uint chainid; address payable coinbase; @@ -53,47 +51,62 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { - function($args) returns (bytes memory) concat; + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $functionExternal { - $address address; - $selector selector; + struct $ErrorType { + bytes4 selector; + } + struct $Function { } - struct $msgType { + struct $ExternalFunction { + address address; + bytes4 selector; + } + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $string { - function($args) returns (string memory) concat; + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; } - struct $txType { + struct $TransactionType { uint gasprice; address origin; } - struct $typeContractType { + struct $ContractTypeType { string name; bytes creationCode; bytes runtimeCode; bytes4 interfaceId; } - struct $typeInterfaceType { + struct $InterfaceTypeType { string name; bytes4 interfaceId; } - struct $typeIntType { + struct $IntTypeType { int min; int max; } - $function $placeholder; - $abiType abi; - $blockType block; - $msgType msg; - $txType tx; + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.8.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.8.sol new file mode 100644 index 0000000000..ec34656dbc --- /dev/null +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.8.sol @@ -0,0 +1,116 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +contract $BuiltIns$ { + function addmod(uint x, uint y, uint k) public returns (uint); + function assert(bool condition) public; + function blockhash(uint blockNumber) public returns (bytes32); + function ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public returns (address); + function gasleft() public returns (uint256); + function keccak256(bytes memory) public returns (bytes32); + function mulmod(uint x, uint y, uint k) public returns (uint); + function require(bool condition) public; + function require(bool condition, string memory message) public; + function revert() public; + function revert(string memory reason) public; + function ripemd160(bytes memory) public returns (bytes20); + function selfdestruct(address payable recipient) public; + function sha256(bytes memory) public returns (bytes32); + struct $AbiType { + function(bytes memory encodedData, $Type[] encodedTypesTuple) returns ($Any[]) decode; + function($Any[] valuesToEncode) returns (bytes memory) encode; + function($Any[] valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Any[] functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Any[] valuesToEncode) returns (bytes memory) encodeWithSignature; + } + struct $address { + uint256 balance; + bytes code; + bytes32 codehash; + function(bytes memory) returns (bool, bytes memory) call; + function(bytes memory) returns (bool, bytes memory) delegatecall; + function(uint256 amount) returns (bool) send; + function(bytes memory) returns (bool, bytes memory) staticcall; + function(uint256 amount) transfer; + } + struct $Array { + uint length; + function() returns ($ValueType) push; + function($ValueType element) push; + function() pop; + } + struct $FixedArray { + uint length; + } + struct $BlockType { + uint basefee; + uint chainid; + address payable coinbase; + uint difficulty; + uint gaslimit; + uint number; + uint timestamp; + } + struct $bytes { + uint length; + } + struct $BytesType { + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; + } + struct $CallOptions { + uint gas; + uint salt; + uint value; + } + struct $ErrorType { + bytes4 selector; + } + struct $Function { + } + struct $ExternalFunction { + address address; + bytes4 selector; + } + struct $MessageType { + bytes data; + address sender; + bytes4 sig; + uint value; + } + struct $StringType { + function(string[] stringsToConcatenate) returns (string memory) concat; + } + struct $TransactionType { + uint gasprice; + address origin; + } + struct $ContractTypeType { + string name; + bytes creationCode; + bytes runtimeCode; + bytes4 interfaceId; + } + struct $InterfaceTypeType { + string name; + bytes4 interfaceId; + } + struct $IntTypeType { + int min; + int max; + } + struct $UserDefinedValueType { + function($WrappedType elementaryType) returns ($UserType) wrap; + function($UserType userType) returns ($WrappedType) unwrap; + } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; +} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/mod.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/mod.rs index f50520d789..e61b9a8f6b 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/mod.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/mod.rs @@ -16,5 +16,6 @@ mod mappings; mod modifiers; mod scoping; mod user_types; +mod using; mod variables; mod yul; diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/using.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/using.rs new file mode 100644 index 0000000000..58420ec02b --- /dev/null +++ b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/using.rs @@ -0,0 +1,10 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use anyhow::Result; + +use crate::bindings_assertions::runner::run; + +#[test] +fn inherited() -> Result<()> { + run("using", "inherited") +} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/arrays.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/arrays.rs index 63fdbbc1cb..80d84f86d5 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/arrays.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/arrays.rs @@ -8,3 +8,8 @@ use crate::bindings_output::runner::run; fn indexing() -> Result<()> { run("arrays", "indexing") } + +#[test] +fn length() -> Result<()> { + run("arrays", "length") +} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/built_ins.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/built_ins.rs index 328c698ec2..a28a9b2670 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/built_ins.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/built_ins.rs @@ -19,6 +19,11 @@ fn arrays() -> Result<()> { run("built_ins", "arrays") } +#[test] +fn bytes() -> Result<()> { + run("built_ins", "bytes") +} + #[test] fn function_type() -> Result<()> { run("built_ins", "function_type") @@ -39,6 +44,16 @@ fn shadowing() -> Result<()> { run("built_ins", "shadowing") } +#[test] +fn this() -> Result<()> { + run("built_ins", "this") +} + +#[test] +fn this_as_address() -> Result<()> { + run("built_ins", "this_as_address") +} + #[test] fn type_expr() -> Result<()> { run("built_ins", "type_expr") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/contracts.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/contracts.rs index c89e406696..a08b136dd9 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/contracts.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/contracts.rs @@ -4,6 +4,11 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn constructor_call_parent() -> Result<()> { + run("contracts", "constructor_call_parent") +} + #[test] fn constructor_invocation() -> Result<()> { run("contracts", "constructor_invocation") @@ -29,11 +34,76 @@ fn inheritance() -> Result<()> { run("contracts", "inheritance") } +#[test] +fn inherited_state_vars() -> Result<()> { + run("contracts", "inherited_state_vars") +} + +#[test] +fn internal_visibility() -> Result<()> { + run("contracts", "internal_visibility") +} + +#[test] +fn legacy_constructors() -> Result<()> { + run("contracts", "legacy_constructors") +} + +#[test] +fn legacy_function_options() -> Result<()> { + run("contracts", "legacy_function_options") +} + +#[test] +fn multi_inheritance() -> Result<()> { + run("contracts", "multi_inheritance") +} + +#[test] +fn public_array_getters() -> Result<()> { + run("contracts", "public_array_getters") +} + +#[test] +fn public_getter_members() -> Result<()> { + run("contracts", "public_getter_members") +} + #[test] fn public_getters() -> Result<()> { run("contracts", "public_getters") } +#[test] +fn public_inherited_getter() -> Result<()> { + run("contracts", "public_inherited_getter") +} + +#[test] +fn public_mapping_getters() -> Result<()> { + run("contracts", "public_mapping_getters") +} + +#[test] +fn public_struct_getter() -> Result<()> { + run("contracts", "public_struct_getter") +} + +#[test] +fn qualified_inherited() -> Result<()> { + run("contracts", "qualified_inherited") +} + +#[test] +fn qualified_parent_call() -> Result<()> { + run("contracts", "qualified_parent_call") +} + +#[test] +fn super_deep() -> Result<()> { + run("contracts", "super_deep") +} + #[test] fn super_linearisation() -> Result<()> { run("contracts", "super_linearisation") @@ -49,6 +119,11 @@ fn this_scope() -> Result<()> { run("contracts", "this_scope") } +#[test] +fn unnamed_function() -> Result<()> { + run("contracts", "unnamed_function") +} + #[test] fn virtual_lookup() -> Result<()> { run("contracts", "virtual_lookup") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/errors.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/errors.rs index 7725da2d61..dc6cfdeec4 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/errors.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/errors.rs @@ -8,3 +8,8 @@ use crate::bindings_output::runner::run; fn custom_types() -> Result<()> { run("errors", "custom_types") } + +#[test] +fn selector() -> Result<()> { + run("errors", "selector") +} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/expressions.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/expressions.rs index a23eba4c12..d4e1b6730d 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/expressions.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/expressions.rs @@ -4,11 +4,21 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn binary_operators() -> Result<()> { + run("expressions", "binary_operators") +} + #[test] fn call_options() -> Result<()> { run("expressions", "call_options") } +#[test] +fn elementary_casting() -> Result<()> { + run("expressions", "elementary_casting") +} + #[test] fn emit_named_args() -> Result<()> { run("expressions", "emit_named_args") @@ -29,6 +39,21 @@ fn funcalls_output() -> Result<()> { run("expressions", "funcalls_output") } +#[test] +fn legacy_call_options() -> Result<()> { + run("expressions", "legacy_call_options") +} + +#[test] +fn literal_address() -> Result<()> { + run("expressions", "literal_address") +} + +#[test] +fn literal_integers() -> Result<()> { + run("expressions", "literal_integers") +} + #[test] fn new_output() -> Result<()> { run("expressions", "new_output") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/interfaces.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/interfaces.rs index 360bf638c1..541e9aa52b 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/interfaces.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/interfaces.rs @@ -9,6 +9,11 @@ fn inheritance() -> Result<()> { run("interfaces", "inheritance") } +#[test] +fn own_types_access() -> Result<()> { + run("interfaces", "own_types_access") +} + #[test] fn simple() -> Result<()> { run("interfaces", "simple") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/libraries.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/libraries.rs index 6e61f22c32..8a84aabbdd 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/libraries.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/libraries.rs @@ -4,6 +4,26 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn constants() -> Result<()> { + run("libraries", "constants") +} + +#[test] +fn modifiers() -> Result<()> { + run("libraries", "modifiers") +} + +#[test] +fn modifiers_scope() -> Result<()> { + run("libraries", "modifiers_scope") +} + +#[test] +fn propagate_dynamic_scope() -> Result<()> { + run("libraries", "propagate_dynamic_scope") +} + #[test] fn visibility() -> Result<()> { run("libraries", "visibility") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/mod.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/mod.rs index ba2bdc21a4..ebe2bbe3a0 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/mod.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/mod.rs @@ -15,6 +15,7 @@ mod libraries; mod mappings; mod modifiers; mod structs; +mod user_types; mod using; mod variables; mod yul; diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/structs.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/structs.rs index 407534d917..9fb31f96dc 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/structs.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/structs.rs @@ -9,6 +9,11 @@ fn declaration() -> Result<()> { run("structs", "declaration") } +#[test] +fn function_call() -> Result<()> { + run("structs", "function_call") +} + #[test] fn named_params_construction() -> Result<()> { run("structs", "named_params_construction") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/user_types.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/user_types.rs new file mode 100644 index 0000000000..889783f382 --- /dev/null +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/user_types.rs @@ -0,0 +1,10 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use anyhow::Result; + +use crate::bindings_output::runner::run; + +#[test] +fn wrap_unwrap() -> Result<()> { + run("user_types", "wrap_unwrap") +} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/using.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/using.rs index 2019c4c6d1..7b8a7d7bff 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/using.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/using.rs @@ -4,6 +4,21 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn address() -> Result<()> { + run("using", "address") +} + +#[test] +fn casting() -> Result<()> { + run("using", "casting") +} + +#[test] +fn chained_calls() -> Result<()> { + run("using", "chained_calls") +} + #[test] fn deconstruction() -> Result<()> { run("using", "deconstruction") @@ -39,12 +54,72 @@ fn in_library() -> Result<()> { run("using", "in_library") } +#[test] +fn inherit_extension() -> Result<()> { + run("using", "inherit_extension") +} + +#[test] +fn inherited_types() -> Result<()> { + run("using", "inherited_types") +} + +#[test] +fn mappings() -> Result<()> { + run("using", "mappings") +} + +#[test] +fn on_interfaces_inherited() -> Result<()> { + run("using", "on_interfaces_inherited") +} + +#[test] +fn on_parameters() -> Result<()> { + run("using", "on_parameters") +} + +#[test] +fn on_state_var_initialization() -> Result<()> { + run("using", "on_state_var_initialization") +} + +#[test] +fn on_super_calls() -> Result<()> { + run("using", "on_super_calls") +} + +#[test] +fn qualified_type() -> Result<()> { + run("using", "qualified_type") +} + #[test] fn star() -> Result<()> { run("using", "star") } +#[test] +fn star_in_library() -> Result<()> { + run("using", "star_in_library") +} + +#[test] +fn star_inherited() -> Result<()> { + run("using", "star_inherited") +} + #[test] fn top_level() -> Result<()> { run("using", "top_level") } + +#[test] +fn uint_alias() -> Result<()> { + run("using", "uint_alias") +} + +#[test] +fn user_types() -> Result<()> { + run("using", "user_types") +} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/variables.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/variables.rs index c15dc0378f..b820477fa7 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/variables.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/variables.rs @@ -18,3 +18,8 @@ fn params() -> Result<()> { fn state_vars() -> Result<()> { run("variables", "state_vars") } + +#[test] +fn var_declaration() -> Result<()> { + run("variables", "var_declaration") +} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/yul.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/yul.rs index be4e184986..f16d3cda70 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/yul.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/yul.rs @@ -9,16 +9,36 @@ fn conditionals() -> Result<()> { run("yul", "conditionals") } +#[test] +fn constant_access_from_functions() -> Result<()> { + run("yul", "constant_access_from_functions") +} + #[test] fn functions() -> Result<()> { run("yul", "functions") } +#[test] +fn identifiers_with_dots() -> Result<()> { + run("yul", "identifiers_with_dots") +} + #[test] fn loops() -> Result<()> { run("yul", "loops") } +#[test] +fn slot_offset_members() -> Result<()> { + run("yul", "slot_offset_members") +} + +#[test] +fn slot_suffix() -> Result<()> { + run("yul", "slot_suffix") +} + #[test] fn variables() -> Result<()> { run("yul", "variables") diff --git a/crates/solidity/testing/perf/src/tests/definitions.rs b/crates/solidity/testing/perf/src/tests/definitions.rs index 047651d0f6..ecf6f92ccc 100644 --- a/crates/solidity/testing/perf/src/tests/definitions.rs +++ b/crates/solidity/testing/perf/src/tests/definitions.rs @@ -28,10 +28,13 @@ pub fn run(dependencies: Dependencies) -> Bindings { } in &files { bindings.add_user_file(path.to_str().unwrap(), parse_output.create_tree_cursor()); - definition_count += bindings.all_definitions().count(); + definition_count += bindings + .all_definitions() + .filter(|definition| definition.get_file().is_user()) + .count(); } - assert_eq!(definition_count, 2832, "Failed to fetch all definitions"); + assert_eq!(definition_count, 2322, "Failed to fetch all definitions"); bindings } diff --git a/crates/solidity/testing/perf/src/tests/init_bindings.rs b/crates/solidity/testing/perf/src/tests/init_bindings.rs index 78119d2533..4dc9af819a 100644 --- a/crates/solidity/testing/perf/src/tests/init_bindings.rs +++ b/crates/solidity/testing/perf/src/tests/init_bindings.rs @@ -2,7 +2,9 @@ use std::sync::Arc; use metaslang_bindings::PathResolver; use slang_solidity::bindings::{create_with_resolver, get_built_ins, Bindings}; +use slang_solidity::cst::TextIndex; use slang_solidity::parser::{ParseOutput, Parser}; +use slang_solidity::transform_built_ins_node; use crate::dataset::SOLC_VERSION; @@ -19,7 +21,10 @@ pub fn setup() -> ParseOutput { pub fn run(built_ins: ParseOutput) -> Bindings { let mut bindings = create_with_resolver(SOLC_VERSION, Arc::new(NoOpResolver {})); - bindings.add_system_file("built_ins.sol", built_ins.create_tree_cursor()); + let built_ins_cursor = + transform_built_ins_node(&built_ins.tree()).cursor_with_offset(TextIndex::ZERO); + + bindings.add_system_file("built_ins.sol", built_ins_cursor); bindings } diff --git a/crates/solidity/testing/perf/src/tests/references.rs b/crates/solidity/testing/perf/src/tests/references.rs index 5e237e2d69..070f357b4e 100644 --- a/crates/solidity/testing/perf/src/tests/references.rs +++ b/crates/solidity/testing/perf/src/tests/references.rs @@ -11,6 +11,10 @@ pub fn run(bindings: Bindings) { let mut resolved_references = 0_usize; for reference in bindings.all_references() { + if reference.get_file().is_system() { + // skip built-ins + continue; + } reference_count += 1; let resolution = reference.jump_to_definition(); @@ -19,10 +23,10 @@ pub fn run(bindings: Bindings) { } } - assert_eq!(reference_count, 1686, "Failed to fetch all references"); + assert_eq!(reference_count, 1652, "Failed to fetch all references"); assert_eq!( - resolved_references, 1353, + resolved_references, 1409, "Failed to resolve all references" ); } diff --git a/crates/solidity/testing/snapshots/bindings_assertions/using/inherited.sol b/crates/solidity/testing/snapshots/bindings_assertions/using/inherited.sol new file mode 100644 index 0000000000..6bcd410801 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_assertions/using/inherited.sol @@ -0,0 +1,16 @@ +library Lib { + function squared(int x) public returns (int) { return x * x; } + // ^def:1 +} + +contract Base { + using Lib for int; +} + +contract Test is Base { + function test(int x) public returns (int) { + return x.squared(); + // ^ref:1 (< 0.7.0) + // ^ref:! (>= 0.7.0) + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-success.txt new file mode 100644 index 0000000000..2e3248e35d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-success.txt @@ -0,0 +1,33 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function nop(uint x) internal {} + │ ─┬─ ┬ + │ ╰────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Lib for uint; + │ ─┬─ + │ ╰─── ref: 1 + 6 │ function test(uint256[] memory data) public { + │ ──┬─ ──┬─ + │ ╰───────────────────────── def: 5 + │ │ + │ ╰─── def: 6 + 7 │ data.length.nop(); + │ ──┬─ ───┬── ─┬─ + │ ╰────────────── ref: 6 + │ │ │ + │ ╰──────── ref: built-in + │ │ + │ ╰─── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/arrays/length/input.sol b/crates/solidity/testing/snapshots/bindings_output/arrays/length/input.sol new file mode 100644 index 0000000000..10925efe89 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/arrays/length/input.sol @@ -0,0 +1,9 @@ +library Lib { + function nop(uint x) internal {} +} +contract Test { + using Lib for uint; + function test(uint256[] memory data) public { + data.length.nop(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.4.11-failure.txt index 1f202ff321..9ff8c9567f 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.4.11-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.4.11-failure.txt @@ -59,4 +59,9 @@ References and definitions: │ ╰─────────── ref: 3 │ │ │ ╰─── ref: built-in + 9 │ uint256 v10 = address(this).balance; + │ ─┬─ ───┬─── + │ ╰─────────────────────────── def: 12 + │ │ + │ ╰───── ref: built-in ───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.5.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.5.0-success.txt index c51e30477e..d5f0a1db53 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.5.0-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/address/generated/0.5.0-success.txt @@ -59,4 +59,9 @@ References and definitions: │ ╰─────────── ref: 3 │ │ │ ╰─── ref: built-in + 9 │ uint256 v10 = address(this).balance; + │ ─┬─ ───┬─── + │ ╰─────────────────────────── def: 12 + │ │ + │ ╰───── ref: built-in ───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/address/input.sol b/crates/solidity/testing/snapshots/bindings_output/built_ins/address/input.sol index 7c97254b4d..769a5d8cc4 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/address/input.sol +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/address/input.sol @@ -6,5 +6,6 @@ contract Test { (bool v7, bytes memory v8) = recipient.staticcall(x1); recipient.transfer(1); bool v9 = recipient.send(1); + uint256 v10 = address(this).balance; } } diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.4.11-success.txt index 4f2a748f2f..7d6647ad22 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.4.11-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.4.11-success.txt @@ -1,76 +1,41 @@ # This file is generated automatically by infrastructure scripts. Please don't edit by hand. References and definitions: - ╭─[input.sol:1:1] - │ - 1 │ contract Test { - │ ──┬─ - │ ╰─── def: 1 - 2 │ uint[] a; - │ ┬ - │ ╰── def: 2 - 3 │ function testArray() public { - │ ────┬──── - │ ╰────── def: 3 - 4 │ uint[] storage b = new uint[](5); - │ ┬ - │ ╰── def: 4 - 5 │ assert(b.length == 5); - │ ───┬── ┬ ───┬── - │ ╰───────────── ref: built-in - │ │ │ - │ ╰───────── ref: 4 - │ │ - │ ╰──── ref: built-in - │ - 7 │ a.push(); - │ ┬ ──┬─ - │ ╰─────── ref: 2 - │ │ - │ ╰─── ref: built-in - 8 │ a.push(1); - │ ┬ ──┬─ - │ ╰─────── ref: 2 - │ │ - │ ╰─── ref: built-in - 9 │ a.pop(); - │ ┬ ─┬─ - │ ╰────── ref: 2 - │ │ - │ ╰─── ref: built-in - │ - 12 │ function testConcat() public { - │ ─────┬──── - │ ╰────── def: 5 - 13 │ bytes memory b1; - │ ─┬ - │ ╰── def: 6 - 14 │ bytes memory b2; - │ ─┬ - │ ╰── def: 7 - 15 │ bytes memory b3 = b1.concat(b2); - │ ─┬ ─┬ ───┬── ─┬ - │ ╰───────────────── def: 8 - │ │ │ │ - │ ╰──────────── ref: 6 - │ │ │ - │ ╰─────── ref: built-in - │ │ - │ ╰── ref: 7 - │ - 17 │ string memory s1; - │ ─┬ - │ ╰── def: 9 - 18 │ string memory s2; - │ ─┬ - │ ╰── def: 10 - 19 │ string memory s3 = s1.concat(s2); - │ ─┬ ─┬ ───┬── ─┬ - │ ╰───────────────── def: 11 - │ │ │ │ - │ ╰──────────── ref: 9 - │ │ │ - │ ╰─────── ref: built-in - │ │ - │ ╰── ref: 10 -────╯ + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ uint[] a; + │ ┬ + │ ╰── def: 2 + 3 │ function testArray() public { + │ ────┬──── + │ ╰────── def: 3 + 4 │ uint[] storage b = new uint[](5); + │ ┬ + │ ╰── def: 4 + 5 │ assert(b.length == 5); + │ ───┬── ┬ ───┬── + │ ╰───────────── ref: built-in + │ │ │ + │ ╰───────── ref: 4 + │ │ + │ ╰──── ref: built-in + │ + 7 │ a.push(); + │ ┬ ──┬─ + │ ╰─────── ref: 2 + │ │ + │ ╰─── ref: built-in + 8 │ a.push(1); + │ ┬ ──┬─ + │ ╰─────── ref: 2 + │ │ + │ ╰─── ref: built-in + 9 │ a.pop(); + │ ┬ ─┬─ + │ ╰────── ref: 2 + │ │ + │ ╰─── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.6.0-success.txt index 1253ccf796..c8f4c1481f 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.6.0-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/generated/0.6.0-success.txt @@ -1,76 +1,41 @@ # This file is generated automatically by infrastructure scripts. Please don't edit by hand. References and definitions: - ╭─[input.sol:1:1] - │ - 1 │ contract Test { - │ ──┬─ - │ ╰─── def: 1 - 2 │ uint[] a; - │ ┬ - │ ╰── def: 2 - 3 │ function testArray() public { - │ ────┬──── - │ ╰────── def: 3 - 4 │ uint[] storage b = new uint[](5); - │ ┬ - │ ╰── def: 4 - 5 │ assert(b.length == 5); - │ ───┬── ┬ ───┬── - │ ╰───────────── ref: built-in - │ │ │ - │ ╰───────── ref: 4 - │ │ - │ ╰──── ref: built-in - │ - 7 │ a.push(); - │ ┬ ──┬─ - │ ╰─────── ref: 2 - │ │ - │ ╰─── refs: built-in, built-in - 8 │ a.push(1); - │ ┬ ──┬─ - │ ╰─────── ref: 2 - │ │ - │ ╰─── refs: built-in, built-in - 9 │ a.pop(); - │ ┬ ─┬─ - │ ╰────── ref: 2 - │ │ - │ ╰─── ref: built-in - │ - 12 │ function testConcat() public { - │ ─────┬──── - │ ╰────── def: 5 - 13 │ bytes memory b1; - │ ─┬ - │ ╰── def: 6 - 14 │ bytes memory b2; - │ ─┬ - │ ╰── def: 7 - 15 │ bytes memory b3 = b1.concat(b2); - │ ─┬ ─┬ ───┬── ─┬ - │ ╰───────────────── def: 8 - │ │ │ │ - │ ╰──────────── ref: 6 - │ │ │ - │ ╰─────── ref: built-in - │ │ - │ ╰── ref: 7 - │ - 17 │ string memory s1; - │ ─┬ - │ ╰── def: 9 - 18 │ string memory s2; - │ ─┬ - │ ╰── def: 10 - 19 │ string memory s3 = s1.concat(s2); - │ ─┬ ─┬ ───┬── ─┬ - │ ╰───────────────── def: 11 - │ │ │ │ - │ ╰──────────── ref: 9 - │ │ │ - │ ╰─────── ref: built-in - │ │ - │ ╰── ref: 10 -────╯ + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ uint[] a; + │ ┬ + │ ╰── def: 2 + 3 │ function testArray() public { + │ ────┬──── + │ ╰────── def: 3 + 4 │ uint[] storage b = new uint[](5); + │ ┬ + │ ╰── def: 4 + 5 │ assert(b.length == 5); + │ ───┬── ┬ ───┬── + │ ╰───────────── ref: built-in + │ │ │ + │ ╰───────── ref: 4 + │ │ + │ ╰──── ref: built-in + │ + 7 │ a.push(); + │ ┬ ──┬─ + │ ╰─────── ref: 2 + │ │ + │ ╰─── refs: built-in, built-in + 8 │ a.push(1); + │ ┬ ──┬─ + │ ╰─────── ref: 2 + │ │ + │ ╰─── refs: built-in, built-in + 9 │ a.pop(); + │ ┬ ─┬─ + │ ╰────── ref: 2 + │ │ + │ ╰─── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/input.sol b/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/input.sol index 619d86dbb8..1646154c42 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/input.sol +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/arrays/input.sol @@ -8,14 +8,4 @@ contract Test { a.push(1); a.pop(); } - - function testConcat() public { - bytes memory b1; - bytes memory b2; - bytes memory b3 = b1.concat(b2); - - string memory s1; - string memory s2; - string memory s3 = s1.concat(s2); - } } diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/bytes/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/bytes/generated/0.4.11-success.txt new file mode 100644 index 0000000000..01319e37d0 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/bytes/generated/0.4.11-success.txt @@ -0,0 +1,51 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function testBytes() public { + │ ────┬──── + │ ╰────── def: 2 + 3 │ bytes memory b1; + │ ─┬ + │ ╰── def: 3 + 4 │ bytes memory b2; + │ ─┬ + │ ╰── def: 4 + 5 │ bytes memory b3 = bytes.concat(b1, b2); + │ ─┬ ───┬── ─┬ ─┬ + │ ╰──────────────────────── def: 5 + │ │ │ │ + │ ╰─────────── ref: built-in + │ │ │ + │ ╰────── ref: 3 + │ │ + │ ╰── ref: 4 + 6 │ b1.length; + │ ─┬ ───┬── + │ ╰───────── ref: 3 + │ │ + │ ╰──── ref: built-in + │ + 9 │ function testString() public { + │ ─────┬──── + │ ╰────── def: 6 + 10 │ string memory s1; + │ ─┬ + │ ╰── def: 7 + 11 │ string memory s2; + │ ─┬ + │ ╰── def: 8 + 12 │ string memory s3 = string.concat(s1, s2); + │ ─┬ ───┬── ─┬ ─┬ + │ ╰───────────────────────── def: 9 + │ │ │ │ + │ ╰─────────── ref: built-in + │ │ │ + │ ╰────── ref: 7 + │ │ + │ ╰── ref: 8 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/bytes/input.sol b/crates/solidity/testing/snapshots/bindings_output/built_ins/bytes/input.sol new file mode 100644 index 0000000000..d6da9002a3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/bytes/input.sol @@ -0,0 +1,14 @@ +contract Test { + function testBytes() public { + bytes memory b1; + bytes memory b2; + bytes memory b3 = bytes.concat(b1, b2); + b1.length; + } + + function testString() public { + string memory s1; + string memory s2; + string memory s3 = string.concat(s1, s2); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.11-failure.txt index b90ecb72e9..8164d93dfd 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.11-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.11-failure.txt @@ -10,19 +10,15 @@ References and definitions: │ ──┬─ │ ╰─── def: 2 3 │ bytes4 v1 = this.test.selector; - │ ─┬ ──┬─ ──┬─ ────┬─── + │ ─┬ ──┬─ ────┬─── │ ╰─────────────────────── def: 3 - │ │ │ │ - │ ╰───────────────── ref: 1 │ │ │ │ ╰──────────── ref: 2 │ │ │ ╰───── unresolved 4 │ address v2 = this.test.address; - │ ─┬ ──┬─ ──┬─ ───┬─── + │ ─┬ ──┬─ ───┬─── │ ╰────────────────────── def: 4 - │ │ │ │ - │ ╰──────────────── ref: 1 │ │ │ │ ╰─────────── ref: 2 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.21-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.21-failure.txt index 0d92e4506b..ec1fe46b15 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.21-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.4.21-failure.txt @@ -10,19 +10,15 @@ References and definitions: │ ──┬─ │ ╰─── def: 2 3 │ bytes4 v1 = this.test.selector; - │ ─┬ ──┬─ ──┬─ ────┬─── + │ ─┬ ──┬─ ────┬─── │ ╰─────────────────────── def: 3 - │ │ │ │ - │ ╰───────────────── ref: 1 │ │ │ │ ╰──────────── ref: 2 │ │ │ ╰───── ref: built-in 4 │ address v2 = this.test.address; - │ ─┬ ──┬─ ──┬─ ───┬─── + │ ─┬ ──┬─ ───┬─── │ ╰────────────────────── def: 4 - │ │ │ │ - │ ╰──────────────── ref: 1 │ │ │ │ ╰─────────── ref: 2 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.8.4-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.8.4-success.txt index 4e5d5be407..1b10c554b8 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.8.4-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/function_type/generated/0.8.4-success.txt @@ -10,19 +10,15 @@ References and definitions: │ ──┬─ │ ╰─── def: 2 3 │ bytes4 v1 = this.test.selector; - │ ─┬ ──┬─ ──┬─ ────┬─── + │ ─┬ ──┬─ ────┬─── │ ╰─────────────────────── def: 3 - │ │ │ │ - │ ╰───────────────── ref: 1 │ │ │ │ ╰──────────── ref: 2 │ │ │ ╰───── ref: built-in 4 │ address v2 = this.test.address; - │ ─┬ ──┬─ ──┬─ ───┬─── + │ ─┬ ──┬─ ───┬─── │ ╰────────────────────── def: 4 - │ │ │ │ - │ ╰──────────────── ref: 1 │ │ │ │ ╰─────────── ref: 2 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.11-failure.txt index 012ad3172e..1968dc3495 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.11-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.11-failure.txt @@ -124,14 +124,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── unresolved - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -142,14 +140,12 @@ References and definitions: │ │ │ ╰─────── unresolved 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── unresolved - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.21-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.21-failure.txt index 4ff6d6c42c..54e971d730 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.21-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.21-failure.txt @@ -124,14 +124,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── unresolved - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -142,14 +140,12 @@ References and definitions: │ │ │ ╰─────── unresolved 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── unresolved - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.22-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.22-failure.txt index 1282f7841d..fc3aaa04ce 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.22-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.4.22-failure.txt @@ -124,14 +124,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── unresolved - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -142,14 +140,12 @@ References and definitions: │ │ │ ╰─────── ref: built-in 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── ref: built-in - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.5.0-failure.txt index f901dcb995..3a79b59191 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.5.0-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.5.0-failure.txt @@ -124,14 +124,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── unresolved - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -142,14 +140,12 @@ References and definitions: │ │ │ ╰─────── ref: built-in 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── ref: built-in - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.13-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.13-failure.txt index 690910c0a7..43b3aa3a88 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.13-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.13-failure.txt @@ -121,14 +121,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── ref: built-in - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -139,14 +137,12 @@ References and definitions: │ │ │ ╰─────── ref: built-in 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── ref: built-in - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.24-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.24-success.txt index cda93f689d..4134c68526 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.24-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.24-success.txt @@ -121,14 +121,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── ref: built-in - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -139,14 +137,12 @@ References and definitions: │ │ │ ╰─────── ref: built-in 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── ref: built-in - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.27-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.27-success.txt index 5b04719552..1d9544857a 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.27-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.27-success.txt @@ -121,14 +121,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── ref: built-in - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -139,14 +137,12 @@ References and definitions: │ │ │ ╰─────── ref: built-in 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── ref: built-in - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.4-failure.txt index 835dcf5dcc..3c898c3511 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.4-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/functions/generated/0.8.4-failure.txt @@ -121,14 +121,12 @@ References and definitions: │ │ │ ╰── ref: 19 36 │ bytes memory v3 = abi.encodeCall(this.testMath, (1, 2, 3)); - │ ─┬ ─┬─ ─────┬──── ──┬─ ────┬─── + │ ─┬ ─┬─ ─────┬──── ────┬─── │ ╰───────────────────────────────── def: 21 - │ │ │ │ │ + │ │ │ │ │ ╰──────────────────────────── ref: built-in - │ │ │ │ + │ │ │ │ ╰──────────────────── unresolved - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: 5 37 │ bytes memory v4 = abi.encodePacked(10, 20); @@ -139,14 +137,12 @@ References and definitions: │ │ │ ╰─────── ref: built-in 38 │ bytes memory v5 = abi.encodeWithSelector(this.testMath.selector, (1, 2, 3)); - │ ─┬ ─┬─ ─────────┬──────── ──┬─ ────┬─── ────┬─── + │ ─┬ ─┬─ ─────────┬──────── ────┬─── ────┬─── │ ╰────────────────────────────────────────────────── def: 23 - │ │ │ │ │ │ + │ │ │ │ │ │ ╰───────────────────────────────────────────── ref: built-in - │ │ │ │ │ + │ │ │ │ │ ╰───────────────────────────────── ref: built-in - │ │ │ │ - │ ╰───────────────────── ref: 1 │ │ │ │ ╰────────────── ref: 5 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/this/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/this/generated/0.4.11-success.txt new file mode 100644 index 0000000000..c86bc2430b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/this/generated/0.4.11-success.txt @@ -0,0 +1,15 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function test() internal returns (uint) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ return address(this).balance; + │ ───┬─── + │ ╰───── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/this/input.sol b/crates/solidity/testing/snapshots/bindings_output/built_ins/this/input.sol new file mode 100644 index 0000000000..ac4a90eeb0 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/this/input.sol @@ -0,0 +1,5 @@ +library Lib { + function test() internal returns (uint) { + return address(this).balance; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.4.11-success.txt new file mode 100644 index 0000000000..e5572f9274 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.4.11-success.txt @@ -0,0 +1,16 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ this.balance; + │ ───┬─── + │ ╰───── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.5.0-failure.txt new file mode 100644 index 0000000000..8d1ee729e4 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.5.0-failure.txt @@ -0,0 +1,16 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ this.balance; + │ ───┬─── + │ ╰───── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/input.sol b/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/input.sol new file mode 100644 index 0000000000..06d15f15bd --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/input.sol @@ -0,0 +1,6 @@ +contract Test { + function test() public { + // This was valid before 0.5.0 + this.balance; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..fa35b69352 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/generated/0.4.11-failure.txt @@ -0,0 +1,27 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ConstantKeyword or Identifier or InternalKeyword or PrivateKeyword or PublicKeyword. + ╭─[input.sol:4:16] + │ + 4 │ ╭─▶ constructor() Base() { + 5 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base {} + │ ──┬─ + │ ╰─── def: 1 + │ + 3 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 2 + │ │ + │ ╰─── ref: 1 + 4 │ constructor() Base() { + │ ─────┬───── + │ ╰─────── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/generated/0.4.22-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/generated/0.4.22-success.txt new file mode 100644 index 0000000000..84795b192d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/generated/0.4.22-success.txt @@ -0,0 +1,18 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base {} + │ ──┬─ + │ ╰─── def: 1 + │ + 3 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 2 + │ │ + │ ╰─── ref: 1 + 4 │ constructor() Base() { + │ ──┬─ + │ ╰─── ref: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/input.sol new file mode 100644 index 0000000000..98fa43a3ea --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/constructor_call_parent/input.sol @@ -0,0 +1,6 @@ +contract Base {} + +contract Test is Base { + constructor() Base() { + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/inherited_state_vars/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/inherited_state_vars/generated/0.4.11-success.txt new file mode 100644 index 0000000000..64c83c5658 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/inherited_state_vars/generated/0.4.11-success.txt @@ -0,0 +1,36 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + 2 │ int in_base; + │ ───┬─── + │ ╰───── def: 2 + │ + 4 │ contract Middle is Base { + │ ───┬── ──┬─ + │ ╰──────────── def: 3 + │ │ + │ ╰─── ref: 1 + 5 │ int in_middle; + │ ────┬──── + │ ╰────── def: 4 + │ + 7 │ contract Test is Middle { + │ ──┬─ ───┬── + │ ╰───────────── def: 5 + │ │ + │ ╰──── ref: 3 + 8 │ function test() public { + │ ──┬─ + │ ╰─── def: 6 + 9 │ in_base; + │ ───┬─── + │ ╰───── ref: 2 + 10 │ in_middle; + │ ────┬──── + │ ╰────── ref: 4 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/inherited_state_vars/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/inherited_state_vars/input.sol new file mode 100644 index 0000000000..593a55a1c5 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/inherited_state_vars/input.sol @@ -0,0 +1,12 @@ +contract Base { + int in_base; +} +contract Middle is Base { + int in_middle; +} +contract Test is Middle { + function test() public { + in_base; + in_middle; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..507119f26e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/generated/0.4.11-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ abstract contract Ownable { + ┆ ┆ + 13 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/generated/0.6.0-success.txt new file mode 100644 index 0000000000..acd63c8cb7 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/generated/0.6.0-success.txt @@ -0,0 +1,41 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ abstract contract Ownable { + │ ───┬─── + │ ╰───── def: 1 + 2 │ address internal owner; + │ ──┬── + │ ╰──── def: 2 + 3 │ address default_visibility; + │ ─────────┬──────── + │ ╰────────── def: 3 + 4 │ function _internal_only() internal {} + │ ───────┬────── + │ ╰──────── def: 4 + │ + 6 │ contract Test is Ownable { + │ ──┬─ ───┬─── + │ ╰────────────── def: 5 + │ │ + │ ╰───── ref: 1 + 7 │ function test() public { + │ ──┬─ + │ ╰─── def: 6 + 8 │ owner; + │ ──┬── + │ ╰──── ref: 2 + 9 │ default_visibility; + │ ─────────┬──────── + │ ╰────────── ref: 3 + 10 │ _internal_only(); + │ ───────┬────── + │ ╰──────── ref: 4 + 11 │ Ownable._internal_only(); + │ ───┬─── ───────┬────── + │ ╰──────────────────── ref: 1 + │ │ + │ ╰──────── ref: 4 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/input.sol new file mode 100644 index 0000000000..48bd9c2fda --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/input.sol @@ -0,0 +1,13 @@ +abstract contract Ownable { + address internal owner; + address default_visibility; + function _internal_only() internal {} +} +contract Test is Ownable { + function test() public { + owner; + default_visibility; + _internal_only(); + Ownable._internal_only(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.4.11-success.txt new file mode 100644 index 0000000000..33d044032f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.4.11-success.txt @@ -0,0 +1,20 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + │ + 3 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 2 + │ │ + │ ╰─── ref: 1 + 4 │ function Test() public Base() {} + │ ──┬─ ──┬─ + │ ╰───────────────── def: 3 + │ │ + │ ╰─── ref: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.5.0-failure.txt new file mode 100644 index 0000000000..24988498b8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.5.0-failure.txt @@ -0,0 +1,20 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + │ + 3 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 2 + │ │ + │ ╰─── ref: 1 + 4 │ function Test() public Base() {} + │ ──┬─ ──┬─ + │ ╰───────────────── def: 3 + │ │ + │ ╰─── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/input.sol new file mode 100644 index 0000000000..eba69e5203 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/input.sol @@ -0,0 +1,5 @@ +contract Base { +} +contract Test is Base { + function Test() public Base() {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/generated/0.4.11-success.txt new file mode 100644 index 0000000000..e7f54749fd --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/generated/0.4.11-success.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract RefundVault { + │ ─────┬───── + │ ╰─────── def: 1 + 2 │ function deposit() public payable {} + │ ───┬─── + │ ╰───── def: 2 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 3 + 5 │ RefundVault public vault; + │ ─────┬───── ──┬── + │ ╰──────────────────── ref: 1 + │ │ + │ ╰──── def: 4 + 6 │ function test() internal { + │ ──┬─ + │ ╰─── def: 5 + 7 │ vault.deposit.value(msg.value)(); + │ ──┬── ───┬─── ──┬── ─┬─ ──┬── + │ ╰──────────────────────────── ref: 4 + │ │ │ │ │ + │ ╰───────────────────── ref: 2 + │ │ │ │ + │ ╰────────────── ref: built-in + │ │ │ + │ ╰───────── ref: built-in + │ │ + │ ╰──── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..065ccbdfad --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/generated/0.7.0-failure.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract RefundVault { + │ ─────┬───── + │ ╰─────── def: 1 + 2 │ function deposit() public payable {} + │ ───┬─── + │ ╰───── def: 2 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 3 + 5 │ RefundVault public vault; + │ ─────┬───── ──┬── + │ ╰──────────────────── ref: 1 + │ │ + │ ╰──── def: 4 + 6 │ function test() internal { + │ ──┬─ + │ ╰─── def: 5 + 7 │ vault.deposit.value(msg.value)(); + │ ──┬── ───┬─── ──┬── ─┬─ ──┬── + │ ╰──────────────────────────── ref: 4 + │ │ │ │ │ + │ ╰───────────────────── ref: 2 + │ │ │ │ + │ ╰────────────── unresolved + │ │ │ + │ ╰───────── ref: built-in + │ │ + │ ╰──── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/input.sol new file mode 100644 index 0000000000..d5fd938d05 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_function_options/input.sol @@ -0,0 +1,9 @@ +contract RefundVault { + function deposit() public payable {} +} +contract Test { + RefundVault public vault; + function test() internal { + vault.deposit.value(msg.value)(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/multi_inheritance/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/multi_inheritance/generated/0.4.11-success.txt new file mode 100644 index 0000000000..280b52987b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/multi_inheritance/generated/0.4.11-success.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base1 { + │ ──┬── + │ ╰──── def: 1 + 2 │ function base1() returns (int) { return 1; } + │ ──┬── + │ ╰──── def: 2 + │ + 5 │ contract Base2 { + │ ──┬── + │ ╰──── def: 3 + 6 │ function base2() returns (int) { return 2; } + │ ──┬── + │ ╰──── def: 4 + │ + 9 │ contract Derived is + │ ───┬─── + │ ╰───── def: 5 + 10 │ Base1, + │ ──┬── + │ ╰──── ref: 1 + 11 │ Base2 + │ ──┬── + │ ╰──── ref: 3 + │ + 13 │ function test() returns (int) { + │ ──┬─ + │ ╰─── def: 6 + 14 │ return base1() + base2(); + │ ──┬── ──┬── + │ ╰────────────── ref: 2 + │ │ + │ ╰──── ref: 4 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/multi_inheritance/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/multi_inheritance/input.sol new file mode 100644 index 0000000000..604fcfa794 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/multi_inheritance/input.sol @@ -0,0 +1,16 @@ +contract Base1 { + function base1() returns (int) { return 1; } +} + +contract Base2 { + function base2() returns (int) { return 2; } +} + +contract Derived is + Base1, + Base2 +{ + function test() returns (int) { + return base1() + base2(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/generated/0.4.11-success.txt new file mode 100644 index 0000000000..3c4e526ae4 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/generated/0.4.11-success.txt @@ -0,0 +1,30 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test(TokenState tokenState) public { + │ ──┬─ ─────┬──── ─────┬──── + │ ╰───────────────────────── def: 2 + │ │ │ + │ ╰───────────────── ref: 4 + │ │ + │ ╰────── def: 3 + 3 │ tokenState.owners(1).balance; + │ ─────┬──── ───┬── ───┬─── + │ ╰──────────────────────── ref: 3 + │ │ │ + │ ╰─────────────── ref: 5 + │ │ + │ ╰───── ref: built-in + │ + 6 │ contract TokenState { + │ ─────┬──── + │ ╰────── def: 4 + 7 │ address[] public owners; + │ ───┬── + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/input.sol new file mode 100644 index 0000000000..1fd95e6a5e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/input.sol @@ -0,0 +1,8 @@ +contract Test { + function test(TokenState tokenState) public { + tokenState.owners(1).balance; + } +} +contract TokenState { + address[] public owners; +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/generated/0.4.11-success.txt new file mode 100644 index 0000000000..503776d84b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/generated/0.4.11-success.txt @@ -0,0 +1,30 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + 2 │ address public owner; + │ ──┬── + │ ╰──── def: 2 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 3 + 5 │ function test(Base base) public { + │ ──┬─ ──┬─ ──┬─ + │ ╰───────────── def: 4 + │ │ │ + │ ╰──────── ref: 1 + │ │ + │ ╰─── def: 5 + 6 │ base.owner().balance; + │ ──┬─ ──┬── ───┬─── + │ ╰─────────────────── ref: 5 + │ │ │ + │ ╰────────────── ref: 2 + │ │ + │ ╰───── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/input.sol new file mode 100644 index 0000000000..eca1760059 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/input.sol @@ -0,0 +1,8 @@ +contract Base { + address public owner; +} +contract Test { + function test(Base base) public { + base.owner().balance; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_getters/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/public_getters/generated/0.4.11-success.txt index beb90fd893..7afdf26c48 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/public_getters/generated/0.4.11-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_getters/generated/0.4.11-success.txt @@ -26,10 +26,8 @@ References and definitions: │ ──┬─ │ ╰─── def: 6 10 │ return y + this.y() + f.x(); - │ ┬ ──┬─ ┬ ┬ ┬ + │ ┬ ┬ ┬ ┬ │ ╰─────────────────── ref: 4 - │ │ │ │ │ - │ ╰───────────── ref: 3 │ │ │ │ │ ╰────────── ref: 4 │ │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_inherited_getter/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/public_inherited_getter/generated/0.4.11-success.txt new file mode 100644 index 0000000000..fab1b7434b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_inherited_getter/generated/0.4.11-success.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract RegistrarAccess { + │ ───────┬─────── + │ ╰───────── def: 1 + 2 │ Root root; + │ ──┬─ ──┬─ + │ ╰──────── ref: 4 + │ │ + │ ╰─── def: 2 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + 4 │ root.controllers; + │ ──┬─ ─────┬───── + │ ╰─────────────── ref: 2 + │ │ + │ ╰─────── ref: 6 + │ + 8 │ contract Root is Controllable {} + │ ──┬─ ──────┬───── + │ ╰─────────────────── def: 4 + │ │ + │ ╰─────── ref: 5 + │ + 10 │ contract Controllable { + │ ──────┬───── + │ ╰─────── def: 5 + 11 │ mapping (address => bool) public controllers; + │ ─────┬───── + │ ╰─────── def: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_inherited_getter/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/public_inherited_getter/input.sol new file mode 100644 index 0000000000..5388a5d254 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_inherited_getter/input.sol @@ -0,0 +1,12 @@ +contract RegistrarAccess { + Root root; + function test() public { + root.controllers; + } +} + +contract Root is Controllable {} + +contract Controllable { + mapping (address => bool) public controllers; +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/generated/0.4.11-success.txt new file mode 100644 index 0000000000..84dff71c3f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/generated/0.4.11-success.txt @@ -0,0 +1,30 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test(TokenState tokenState) public { + │ ──┬─ ─────┬──── ─────┬──── + │ ╰───────────────────────── def: 2 + │ │ │ + │ ╰───────────────── ref: 4 + │ │ + │ ╰────── def: 3 + 3 │ tokenState.owners(1).balance; + │ ─────┬──── ───┬── ───┬─── + │ ╰──────────────────────── ref: 3 + │ │ │ + │ ╰─────────────── ref: 5 + │ │ + │ ╰───── ref: built-in + │ + 6 │ contract TokenState { + │ ─────┬──── + │ ╰────── def: 4 + 7 │ mapping(uint => address) public owners; + │ ───┬── + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/input.sol new file mode 100644 index 0000000000..69efebff11 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/input.sol @@ -0,0 +1,8 @@ +contract Test { + function test(TokenState tokenState) public { + tokenState.owners(1).balance; + } +} +contract TokenState { + mapping(uint => address) public owners; +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/generated/0.4.11-success.txt new file mode 100644 index 0000000000..28722902e6 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/generated/0.4.11-success.txt @@ -0,0 +1,37 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Owner { address owner; } + │ ──┬── ──┬── + │ ╰──────────────────── def: 2 + │ │ + │ ╰──── def: 3 + 3 │ Owner public owner; + │ ──┬── ──┬── + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 4 + │ + 5 │ contract Test { + │ ──┬─ + │ ╰─── def: 5 + 6 │ function test(Base base) public { + │ ──┬─ ──┬─ ──┬─ + │ ╰───────────── def: 6 + │ │ │ + │ ╰──────── ref: 1 + │ │ + │ ╰─── def: 7 + 7 │ base.owner().balance; + │ ──┬─ ──┬── ───┬─── + │ ╰─────────────────── ref: 7 + │ │ │ + │ ╰────────────── ref: 4 + │ │ + │ ╰───── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/input.sol new file mode 100644 index 0000000000..3c85bc3911 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/input.sol @@ -0,0 +1,9 @@ +contract Base { + struct Owner { address owner; } + Owner public owner; +} +contract Test { + function test(Base base) public { + base.owner().balance; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.4.11-success.txt new file mode 100644 index 0000000000..da81507f48 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.4.11-success.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + 2 │ bool renounced; + │ ────┬──── + │ ╰────── def: 2 + │ + 4 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 3 + │ │ + │ ╰─── ref: 1 + 5 │ function test() public { + │ ──┬─ + │ ╰─── def: 4 + 6 │ Base.renounced = true; + │ ──┬─ ────┬──── + │ ╰───────────── ref: 1 + │ │ + │ ╰────── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/input.sol new file mode 100644 index 0000000000..bc9b730d79 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/input.sol @@ -0,0 +1,8 @@ +contract Base { + bool renounced; +} +contract Test is Base { + function test() public { + Base.renounced = true; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/0.4.11-success.txt new file mode 100644 index 0000000000..e0763a81c8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/0.4.11-success.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function in_base() internal {} + │ ───┬─── + │ ╰───── def: 2 + │ + 4 │ contract Middle is Base {} + │ ───┬── ──┬─ + │ ╰──────────── def: 3 + │ │ + │ ╰─── ref: 1 + 5 │ contract Test is Middle { + │ ──┬─ ───┬── + │ ╰───────────── def: 4 + │ │ + │ ╰──── ref: 3 + 6 │ function test() public { + │ ──┬─ + │ ╰─── def: 5 + 7 │ Base.in_base(); + │ ──┬─ ───┬─── + │ ╰─────────── ref: 1 + │ │ + │ ╰───── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/input.sol new file mode 100644 index 0000000000..3e23b1b8b9 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/input.sol @@ -0,0 +1,9 @@ +contract Base { + function in_base() internal {} +} +contract Middle is Base {} +contract Test is Middle { + function test() public { + Base.in_base(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/generated/0.4.11-success.txt new file mode 100644 index 0000000000..66779a28d1 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/generated/0.4.11-success.txt @@ -0,0 +1,29 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function in_base() {} + │ ───┬─── + │ ╰───── def: 2 + │ + 4 │ contract Middle is Base {} + │ ───┬── ──┬─ + │ ╰──────────── def: 3 + │ │ + │ ╰─── ref: 1 + 5 │ contract Test is Middle { + │ ──┬─ ───┬── + │ ╰───────────── def: 4 + │ │ + │ ╰──── ref: 3 + 6 │ function in_base() { + │ ───┬─── + │ ╰───── def: 5 + 7 │ super.in_base(); + │ ───┬─── + │ ╰───── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/input.sol new file mode 100644 index 0000000000..0a933e7431 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/input.sol @@ -0,0 +1,9 @@ +contract Base { + function in_base() {} +} +contract Middle is Base {} +contract Test is Middle { + function in_base() { + super.in_base(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/super_linearisation/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/super_linearisation/generated/0.4.11-success.txt index e5d4bc6d71..5819b34073 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/super_linearisation/generated/0.4.11-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_linearisation/generated/0.4.11-success.txt @@ -19,9 +19,7 @@ References and definitions: │ ─┬─ │ ╰─── def: 4 6 │ super.foo(); - │ ──┬── ─┬─ - │ ╰──────── ref: 1 - │ │ + │ ─┬─ │ ╰─── ref: 2 │ 9 │ contract C is A { @@ -33,9 +31,7 @@ References and definitions: │ ─┬─ │ ╰─── def: 6 11 │ super.foo(); - │ ──┬── ─┬─ - │ ╰──────── ref: 1 - │ │ + │ ─┬─ │ ╰─── ref: 4 │ 14 │ contract D is B, C { @@ -49,8 +45,6 @@ References and definitions: │ ─┬─ │ ╰─── def: 8 16 │ super.foo(); - │ ──┬── ─┬─ - │ ╰──────── refs: 3, 5 - │ │ + │ ─┬─ │ ╰─── ref: 6 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.4.16-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.4.16-failure.txt index 1e7b1003b1..1e0d62fb2d 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.4.16-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.4.16-failure.txt @@ -28,8 +28,6 @@ References and definitions: │ │ │ ╰── ref: 1 13 │ return super.foo(); - │ ──┬── ─┬─ - │ ╰──────── ref: 1 - │ │ + │ ─┬─ │ ╰─── ref: 2 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.6.0-success.txt index c3f150295d..7feb70120a 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.6.0-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_scope/generated/0.6.0-success.txt @@ -22,8 +22,6 @@ References and definitions: │ │ │ ╰── ref: 1 13 │ return super.foo(); - │ ──┬── ─┬─ - │ ╰──────── ref: 1 - │ │ + │ ─┬─ │ ╰─── ref: 2 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/this_scope/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/this_scope/generated/0.4.11-success.txt index 2f9f1eb37e..ac355a829c 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/this_scope/generated/0.4.11-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/this_scope/generated/0.4.11-success.txt @@ -14,8 +14,6 @@ References and definitions: │ ─┬─ │ ╰─── def: 3 5 │ this.foo(); - │ ──┬─ ─┬─ - │ ╰─────── ref: 1 - │ │ + │ ─┬─ │ ╰─── ref: 2 ───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.4.11-success.txt new file mode 100644 index 0000000000..24a80f6855 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.4.11-success.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + │ + 3 │ revert(); + │ ───┬── + │ ╰──── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.4.22-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.4.22-success.txt new file mode 100644 index 0000000000..165fe5e41d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.4.22-success.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + │ + 3 │ revert(); + │ ───┬── + │ ╰──── refs: built-in, built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..17e5d6e85e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.6.0-failure.txt @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ConstantKeyword or Identifier or InternalKeyword or OverrideKeyword or PrivateKeyword or PublicKeyword. + ╭─[input.sol:2:25] + │ + 2 │ ╭─▶ function () payable { + ┆ ┆ + 4 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.6.5-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.6.5-failure.txt new file mode 100644 index 0000000000..1dda92db7e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.6.5-failure.txt @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ConstantKeyword or Identifier or ImmutableKeyword or InternalKeyword or OverrideKeyword or PrivateKeyword or PublicKeyword. + ╭─[input.sol:2:25] + │ + 2 │ ╭─▶ function () payable { + ┆ ┆ + 4 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.8.27-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.8.27-failure.txt new file mode 100644 index 0000000000..61ee40e68c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/generated/0.8.27-failure.txt @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ConstantKeyword or Identifier or ImmutableKeyword or InternalKeyword or OverrideKeyword or PrivateKeyword or PublicKeyword or TransientKeyword. + ╭─[input.sol:2:25] + │ + 2 │ ╭─▶ function () payable { + ┆ ┆ + 4 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/input.sol new file mode 100644 index 0000000000..e69d46f688 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/unnamed_function/input.sol @@ -0,0 +1,5 @@ +contract Test { + function () payable { + revert(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.4.16-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.4.16-failure.txt index 99eacf7c99..1a4864098f 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.4.16-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.4.16-failure.txt @@ -58,8 +58,6 @@ References and definitions: │ │ │ ╰── ref: 5 25 │ return super.foo(); - │ ──┬── ─┬─ - │ ╰──────── refs: 3, 5 - │ │ + │ ─┬─ │ ╰─── ref: 6 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.6.0-success.txt index 78ee0e6e94..c5f1386460 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.6.0-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/virtual_methods/generated/0.6.0-success.txt @@ -46,8 +46,6 @@ References and definitions: │ │ │ ╰── ref: 5 25 │ return super.foo(); - │ ──┬── ─┬─ - │ ╰──────── refs: 3, 5 - │ │ + │ ─┬─ │ ╰─── ref: 6 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/errors/selector/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/errors/selector/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..5bc593e595 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/errors/selector/generated/0.4.11-failure.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected Equal or Semicolon. + ╭─[input.sol:2:20] + │ + 2 │ error TestError(); + │ ─┬ + │ ╰── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ error TestError(); + │ ──┬── ────┬──── + │ ╰────────────── unresolved + │ │ + │ ╰────── def: 2 + │ + 4 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + 5 │ TestError.selector; + │ ────┬──── ────┬─── + │ ╰─────────────── ref: 2 + │ │ + │ ╰───── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/errors/selector/generated/0.8.4-success.txt b/crates/solidity/testing/snapshots/bindings_output/errors/selector/generated/0.8.4-success.txt new file mode 100644 index 0000000000..41e568485d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/errors/selector/generated/0.8.4-success.txt @@ -0,0 +1,21 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ error TestError(); + │ ────┬──── + │ ╰────── def: 2 + │ + 4 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + 5 │ TestError.selector; + │ ────┬──── ────┬─── + │ ╰─────────────── ref: 2 + │ │ + │ ╰───── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/errors/selector/input.sol b/crates/solidity/testing/snapshots/bindings_output/errors/selector/input.sol new file mode 100644 index 0000000000..1c9d61ed82 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/errors/selector/input.sol @@ -0,0 +1,7 @@ +contract Test { + error TestError(); + + function test() public { + TestError.selector; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/binary_operators/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/binary_operators/generated/0.4.11-success.txt new file mode 100644 index 0000000000..69f5695dea --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/binary_operators/generated/0.4.11-success.txt @@ -0,0 +1,100 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function nop_uint(uint x) public returns (uint) {} + │ ────┬─── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function nop_bool(bool x) public returns (bool) {} + │ ────┬─── ┬ + │ ╰──────────── def: 4 + │ │ + │ ╰── def: 5 + │ + 6 │ contract Test { + │ ──┬─ + │ ╰─── def: 6 + 7 │ using Lib for uint; + │ ─┬─ + │ ╰─── ref: 1 + 8 │ using Lib for bool; + │ ─┬─ + │ ╰─── ref: 1 + 9 │ function test(uint a, uint b) public { + │ ──┬─ ┬ ┬ + │ ╰────────────────── def: 7 + │ │ │ + │ ╰────────── def: 8 + │ │ + │ ╰── def: 9 + 10 │ (a += b).nop_uint(); + │ ┬ ┬ ────┬─── + │ ╰───────────────── ref: 8 + │ │ │ + │ ╰──────────── ref: 9 + │ │ + │ ╰───── ref: 2 + 11 │ (true ? a : b).nop_uint(); + │ ┬ ┬ ────┬─── + │ ╰──────────────── ref: 8 + │ │ │ + │ ╰──────────── ref: 9 + │ │ + │ ╰───── ref: 2 + 12 │ (a == b).nop_bool(); + │ ┬ ┬ ────┬─── + │ ╰───────────────── ref: 8 + │ │ │ + │ ╰──────────── ref: 9 + │ │ + │ ╰───── ref: 4 + 13 │ (a > b).nop_bool(); + │ ┬ ┬ ────┬─── + │ ╰──────────────── ref: 8 + │ │ │ + │ ╰──────────── ref: 9 + │ │ + │ ╰───── ref: 4 + 14 │ (a | b).nop_uint(); + │ ┬ ┬ ────┬─── + │ ╰──────────────── ref: 8 + │ │ │ + │ ╰──────────── ref: 9 + │ │ + │ ╰───── ref: 2 + 15 │ (a << 1).nop_uint(); + │ ┬ ────┬─── + │ ╰───────────────── ref: 8 + │ │ + │ ╰───── ref: 2 + 16 │ (a + b).nop_uint(); + │ ┬ ┬ ────┬─── + │ ╰──────────────── ref: 8 + │ │ │ + │ ╰──────────── ref: 9 + │ │ + │ ╰───── ref: 2 + 17 │ (a * b).nop_uint(); + │ ┬ ┬ ────┬─── + │ ╰──────────────── ref: 8 + │ │ │ + │ ╰──────────── ref: 9 + │ │ + │ ╰───── ref: 2 + 18 │ (a++).nop_uint(); + │ ┬ ────┬─── + │ ╰────────────── ref: 8 + │ │ + │ ╰───── ref: 2 + 19 │ (++a).nop_uint(); + │ ┬ ────┬─── + │ ╰──────────── ref: 8 + │ │ + │ ╰───── ref: 2 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/binary_operators/input.sol b/crates/solidity/testing/snapshots/bindings_output/expressions/binary_operators/input.sol new file mode 100644 index 0000000000..90d76c2564 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/binary_operators/input.sol @@ -0,0 +1,21 @@ +library Lib { + function nop_uint(uint x) public returns (uint) {} + function nop_bool(bool x) public returns (bool) {} +} + +contract Test { + using Lib for uint; + using Lib for bool; + function test(uint a, uint b) public { + (a += b).nop_uint(); + (true ? a : b).nop_uint(); + (a == b).nop_bool(); + (a > b).nop_bool(); + (a | b).nop_uint(); + (a << 1).nop_uint(); + (a + b).nop_uint(); + (a * b).nop_uint(); + (a++).nop_uint(); + (++a).nop_uint(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..f25c1ffe3c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.11-failure.txt @@ -0,0 +1,40 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or ThrowKeyword or TrueKeyword or UfixedKeyword or UintKeyword or VarKeyword or WhileKeyword. + ╭─[input.sol:6:9] + │ + 6 │ ╭─▶ payable(a).call(""); + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ using Lib for uint; + │ ─┬─ + │ ╰─── ref: 4 + │ + 4 │ function test(address a) public { + │ ──┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + 5 │ address(this).balance; + │ ───┬─── + │ ╰───── ref: built-in + │ + 11 │ library Lib { + │ ─┬─ + │ ╰─── def: 4 + 12 │ function noop(uint x) public returns (uint) {} + │ ──┬─ ┬ + │ ╰────────── def: 5 + │ │ + │ ╰── def: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.21-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.21-failure.txt new file mode 100644 index 0000000000..bdf6d7ee03 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.21-failure.txt @@ -0,0 +1,40 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or ThrowKeyword or TrueKeyword or UfixedKeyword or UintKeyword or VarKeyword or WhileKeyword. + ╭─[input.sol:6:9] + │ + 6 │ ╭─▶ payable(a).call(""); + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ using Lib for uint; + │ ─┬─ + │ ╰─── ref: 4 + │ + 4 │ function test(address a) public { + │ ──┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + 5 │ address(this).balance; + │ ───┬─── + │ ╰───── ref: built-in + │ + 11 │ library Lib { + │ ─┬─ + │ ╰─── def: 4 + 12 │ function noop(uint x) public returns (uint) {} + │ ──┬─ ┬ + │ ╰────────── def: 5 + │ │ + │ ╰── def: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.0-failure.txt new file mode 100644 index 0000000000..8ee42cb4f3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.0-failure.txt @@ -0,0 +1,40 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:6:9] + │ + 6 │ ╭─▶ payable(a).call(""); + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ using Lib for uint; + │ ─┬─ + │ ╰─── ref: 4 + │ + 4 │ function test(address a) public { + │ ──┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + 5 │ address(this).balance; + │ ───┬─── + │ ╰───── ref: built-in + │ + 11 │ library Lib { + │ ─┬─ + │ ╰─── def: 4 + 12 │ function noop(uint x) public returns (uint) {} + │ ──┬─ ┬ + │ ╰────────── def: 5 + │ │ + │ ╰── def: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.3-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.3-failure.txt new file mode 100644 index 0000000000..0563005915 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.3-failure.txt @@ -0,0 +1,40 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:6:9] + │ + 6 │ ╭─▶ payable(a).call(""); + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ using Lib for uint; + │ ─┬─ + │ ╰─── ref: 4 + │ + 4 │ function test(address a) public { + │ ──┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + 5 │ address(this).balance; + │ ───┬─── + │ ╰───── ref: built-in + │ + 11 │ library Lib { + │ ─┬─ + │ ╰─── def: 4 + 12 │ function noop(uint x) public returns (uint) {} + │ ──┬─ ┬ + │ ╰────────── def: 5 + │ │ + │ ╰── def: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.6.0-success.txt new file mode 100644 index 0000000000..55ec33f7cd --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.6.0-success.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ using Lib for uint; + │ ─┬─ + │ ╰─── ref: 4 + │ + 4 │ function test(address a) public { + │ ──┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + 5 │ address(this).balance; + │ ───┬─── + │ ╰───── ref: built-in + 6 │ payable(a).call(""); + │ ┬ ──┬─ + │ ╰──────── ref: 3 + │ │ + │ ╰─── ref: built-in + 7 │ uint(10).noop(); + │ ──┬─ + │ ╰─── ref: 5 + │ + 11 │ library Lib { + │ ─┬─ + │ ╰─── def: 4 + 12 │ function noop(uint x) public returns (uint) {} + │ ──┬─ ┬ + │ ╰────────── def: 5 + │ │ + │ ╰── def: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/input.sol b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/input.sol new file mode 100644 index 0000000000..db44f7978e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/input.sol @@ -0,0 +1,13 @@ +contract Test { + using Lib for uint; + + function test(address a) public { + address(this).balance; + payable(a).call(""); + uint(10).noop(); + } +} + +library Lib { + function noop(uint x) public returns (uint) {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.4.11-success.txt new file mode 100644 index 0000000000..4f39167043 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.4.11-success.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test(address rcpt, bytes memory data) public { + │ ──┬─ ──┬─ ──┬─ + │ ╰─────────────────────────────────── def: 2 + │ │ │ + │ ╰────────────────────── def: 3 + │ │ + │ ╰─── def: 4 + │ + 4 │ rcpt.call.value(1)(data); + │ ──┬─ ──┬─ ──┬── ──┬─ + │ ╰────────────────────── ref: 3 + │ │ │ │ + │ ╰───────────────── ref: built-in + │ │ │ + │ ╰──────────── ref: built-in + │ │ + │ ╰─── ref: 4 + 5 │ rcpt.call.gas(1)(data); + │ ──┬─ ──┬─ ─┬─ ──┬─ + │ ╰──────────────────── ref: 3 + │ │ │ │ + │ ╰─────────────── ref: built-in + │ │ │ + │ ╰─────────── ref: built-in + │ │ + │ ╰─── ref: 4 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..b15ce9308a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.7.0-failure.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test(address rcpt, bytes memory data) public { + │ ──┬─ ──┬─ ──┬─ + │ ╰─────────────────────────────────── def: 2 + │ │ │ + │ ╰────────────────────── def: 3 + │ │ + │ ╰─── def: 4 + │ + 4 │ rcpt.call.value(1)(data); + │ ──┬─ ──┬─ ──┬── ──┬─ + │ ╰────────────────────── ref: 3 + │ │ │ │ + │ ╰───────────────── ref: built-in + │ │ │ + │ ╰──────────── unresolved + │ │ + │ ╰─── ref: 4 + 5 │ rcpt.call.gas(1)(data); + │ ──┬─ ──┬─ ─┬─ ──┬─ + │ ╰──────────────────── ref: 3 + │ │ │ │ + │ ╰─────────────── ref: built-in + │ │ │ + │ ╰─────────── unresolved + │ │ + │ ╰─── ref: 4 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/input.sol b/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/input.sol new file mode 100644 index 0000000000..cc5d1f69ce --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/input.sol @@ -0,0 +1,7 @@ +contract Test { + function test(address rcpt, bytes memory data) public { + // this is valid on Solidity < 0.7.0 + rcpt.call.value(1)(data); + rcpt.call.gas(1)(data); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/literal_address/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_address/generated/0.4.11-success.txt new file mode 100644 index 0000000000..31773815f8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_address/generated/0.4.11-success.txt @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test(bytes memory data) public { + │ ──┬─ ──┬─ + │ ╰───────────────────── def: 2 + │ │ + │ ╰─── def: 3 + 3 │ 0x2d3fC875de7Fe7Da43AD0afa0E7023c9B91D06b1.delegatecall(data); + │ ──────┬───── ──┬─ + │ ╰──────────── ref: built-in + │ │ + │ ╰─── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/literal_address/input.sol b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_address/input.sol new file mode 100644 index 0000000000..2f58b86413 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_address/input.sol @@ -0,0 +1,5 @@ +contract Test { + function test(bytes memory data) public { + 0x2d3fC875de7Fe7Da43AD0afa0E7023c9B91D06b1.delegatecall(data); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/0.4.11-success.txt new file mode 100644 index 0000000000..e00ce09b33 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/0.4.11-success.txt @@ -0,0 +1,27 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function nop(uint256 x) internal {} + │ ─┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Lib for uint256; + │ ─┬─ + │ ╰─── ref: 1 + 6 │ function test() public { + │ ──┬─ + │ ╰─── def: 5 + 7 │ (50 * 10**uint(4)).nop(); + │ ─┬─ + │ ╰─── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/input.sol b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/input.sol new file mode 100644 index 0000000000..3ffcec21df --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/input.sol @@ -0,0 +1,9 @@ +library Lib { + function nop(uint256 x) internal {} +} +contract Test { + using Lib for uint256; + function test() public { + (50 * 10**uint(4)).nop(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/interfaces/own_types_access/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/interfaces/own_types_access/generated/0.4.11-success.txt new file mode 100644 index 0000000000..bfc96cf8da --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/interfaces/own_types_access/generated/0.4.11-success.txt @@ -0,0 +1,23 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ interface IFoo { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Bar { + │ ─┬─ + │ ╰─── def: 2 + 3 │ int value; + │ ──┬── + │ ╰──── def: 3 + │ + 5 │ function test(Bar memory bar); + │ ──┬─ ─┬─ ─┬─ + │ ╰────────────────── def: 4 + │ │ │ + │ ╰────────────── ref: 2 + │ │ + │ ╰─── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/interfaces/own_types_access/input.sol b/crates/solidity/testing/snapshots/bindings_output/interfaces/own_types_access/input.sol new file mode 100644 index 0000000000..23d18a2bd3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/interfaces/own_types_access/input.sol @@ -0,0 +1,6 @@ +interface IFoo { + struct Bar { + int value; + } + function test(Bar memory bar); +} diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/constants/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/libraries/constants/generated/0.4.11-success.txt new file mode 100644 index 0000000000..d83d224dfa --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/constants/generated/0.4.11-success.txt @@ -0,0 +1,34 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ uint private constant X = 1; + │ ┬ + │ ╰── def: 2 + 3 │ uint public constant Y = 2; + │ ┬ + │ ╰── def: 3 + │ + 5 │ function test() public returns (uint) { + │ ──┬─ + │ ╰─── def: 4 + 6 │ return X; + │ ┬ + │ ╰── ref: 2 + │ + 10 │ contract Test { + │ ──┬─ + │ ╰─── def: 5 + 11 │ function test() public { + │ ──┬─ + │ ╰─── def: 6 + 12 │ Lib.Y; + │ ─┬─ ┬ + │ ╰───── ref: 1 + │ │ + │ ╰── ref: 3 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/constants/input.sol b/crates/solidity/testing/snapshots/bindings_output/libraries/constants/input.sol new file mode 100644 index 0000000000..6990c22be9 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/constants/input.sol @@ -0,0 +1,14 @@ +library Lib { + uint private constant X = 1; + uint public constant Y = 2; + + function test() public returns (uint) { + return X; + } +} + +contract Test { + function test() public { + Lib.Y; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-success.txt new file mode 100644 index 0000000000..3fa6594466 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-success.txt @@ -0,0 +1,21 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ modifier withinRange() { + │ ─────┬───── + │ ╰─────── def: 2 + 3 │ _; + │ ┬ + │ ╰── ref: built-in + │ + 5 │ function test() internal withinRange() {} + │ ──┬─ ─────┬───── + │ ╰────────────────────────── def: 3 + │ │ + │ ╰─────── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/input.sol b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/input.sol new file mode 100644 index 0000000000..72cebbcaf9 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/input.sol @@ -0,0 +1,6 @@ +library Test { + modifier withinRange() { + _; + } + function test() internal withinRange() {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..6e61f4eb45 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.4.11-failure.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected Equal or Semicolon. + ╭─[input.sol:2:25] + │ + 2 │ error IndexOutOfBounds(); + │ ─┬ + │ ╰── Error occurred here. +───╯ +Error: Expected Equal or Semicolon. + ╭─[input.sol:5:28] + │ + 5 │ revert IndexOutOfBounds(); + │ ─┬ + │ ╰── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ error IndexOutOfBounds(); + │ ──┬── ────────┬─────── + │ ╰───────────────────── unresolved + │ │ + │ ╰───────── def: 2 + │ + 4 │ modifier test() { + │ ──┬─ + │ ╰─── def: 3 + 5 │ revert IndexOutOfBounds(); + │ ───┬── ────────┬─────── + │ ╰───────────────────── ref: built-in + │ │ + │ ╰───────── def: 4 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.4.22-failure.txt b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.4.22-failure.txt new file mode 100644 index 0000000000..622f19db63 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.4.22-failure.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected Equal or Semicolon. + ╭─[input.sol:2:25] + │ + 2 │ error IndexOutOfBounds(); + │ ─┬ + │ ╰── Error occurred here. +───╯ +Error: Expected Equal or Semicolon. + ╭─[input.sol:5:28] + │ + 5 │ revert IndexOutOfBounds(); + │ ─┬ + │ ╰── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ error IndexOutOfBounds(); + │ ──┬── ────────┬─────── + │ ╰───────────────────── unresolved + │ │ + │ ╰───────── def: 2 + │ + 4 │ modifier test() { + │ ──┬─ + │ ╰─── def: 3 + 5 │ revert IndexOutOfBounds(); + │ ───┬── ────────┬─────── + │ ╰───────────────────── refs: built-in, built-in + │ │ + │ ╰───────── def: 4 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.8.4-success.txt b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.8.4-success.txt new file mode 100644 index 0000000000..ef7dba6b93 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/generated/0.8.4-success.txt @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ error IndexOutOfBounds(); + │ ────────┬─────── + │ ╰───────── def: 2 + │ + 4 │ modifier test() { + │ ──┬─ + │ ╰─── def: 3 + 5 │ revert IndexOutOfBounds(); + │ ────────┬─────── + │ ╰───────── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/input.sol b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/input.sol new file mode 100644 index 0000000000..066b231b3f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers_scope/input.sol @@ -0,0 +1,7 @@ +library Lib { + error IndexOutOfBounds(); + + modifier test() { + revert IndexOutOfBounds(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/propagate_dynamic_scope/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/libraries/propagate_dynamic_scope/generated/0.4.11-success.txt new file mode 100644 index 0000000000..ce220baf55 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/propagate_dynamic_scope/generated/0.4.11-success.txt @@ -0,0 +1,49 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ interface IERC20Upgradable { + │ ────────┬─────── + │ ╰───────── def: 1 + 2 │ function allowance(address owner) external returns (uint256); + │ ────┬──── ──┬── + │ ╰──────────────────── def: 2 + │ │ + │ ╰──── def: 3 + │ + 4 │ library Math { + │ ──┬─ + │ ╰─── def: 4 + 5 │ function nop(uint256 x) public {} + │ ─┬─ ┬ + │ ╰───────────── def: 5 + │ │ + │ ╰── def: 6 + │ + 7 │ library Test { + │ ──┬─ + │ ╰─── def: 7 + 8 │ using Math for uint256; + │ ──┬─ + │ ╰─── ref: 4 + │ + 10 │ function test(IERC20Upgradable token) internal { + │ ──┬─ ────────┬─────── ──┬── + │ ╰────────────────────────── def: 8 + │ │ │ + │ ╰─────────────── ref: 1 + │ │ + │ ╰──── def: 9 + 11 │ token.allowance(msg.sender).nop(); + │ ──┬── ────┬──── ─┬─ ───┬── ─┬─ + │ ╰────────────────────────────── ref: 9 + │ │ │ │ │ + │ ╰────────────────────── ref: 2 + │ │ │ │ + │ ╰─────────────── ref: built-in + │ │ │ + │ ╰───────── ref: built-in + │ │ + │ ╰─── ref: 5 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/propagate_dynamic_scope/input.sol b/crates/solidity/testing/snapshots/bindings_output/libraries/propagate_dynamic_scope/input.sol new file mode 100644 index 0000000000..2c12057eb3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/propagate_dynamic_scope/input.sol @@ -0,0 +1,13 @@ +interface IERC20Upgradable { + function allowance(address owner) external returns (uint256); +} +library Math { + function nop(uint256 x) public {} +} +library Test { + using Math for uint256; + + function test(IERC20Upgradable token) internal { + token.allowance(msg.sender).nop(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/structs/function_call/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/structs/function_call/generated/0.4.11-success.txt new file mode 100644 index 0000000000..5e81f906d2 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/structs/function_call/generated/0.4.11-success.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { + │ ──┬── + │ ╰──── def: 2 + 3 │ int x; + │ ┬ + │ ╰── def: 3 + │ + 5 │ function test() public { + │ ──┬─ + │ ╰─── def: 4 + 6 │ Value(10).x; + │ ──┬── ┬ + │ ╰────────── ref: 2 + │ │ + │ ╰── ref: 3 + 7 │ Value({x: 10}).x; + │ ──┬── ┬ ┬ + │ ╰─────────────── ref: 2 + │ │ │ + │ ╰────────── ref: 3 + │ │ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/structs/function_call/input.sol b/crates/solidity/testing/snapshots/bindings_output/structs/function_call/input.sol new file mode 100644 index 0000000000..48f1b04eb8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/structs/function_call/input.sol @@ -0,0 +1,9 @@ +contract Test { + struct Value { + int x; + } + function test() public { + Value(10).x; + Value({x: 10}).x; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..b87a09cf85 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.4.11-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +───╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..cea0619d12 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.6.0-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or EnumKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword or StructKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +───╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.7.1-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.7.1-failure.txt new file mode 100644 index 0000000000..3505cedb20 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.7.1-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or EnumKeyword or FunctionKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword or StructKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +───╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.7.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.7.4-failure.txt new file mode 100644 index 0000000000..bd4b20a86b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.7.4-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or BoolKeyword or ByteKeyword or BytesKeyword or ContractKeyword or EnumKeyword or FixedKeyword or FunctionKeyword or Identifier or ImportKeyword or IntKeyword or InterfaceKeyword or LibraryKeyword or MappingKeyword or PragmaKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +───╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.0-failure.txt new file mode 100644 index 0000000000..619151156f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.0-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or BoolKeyword or BytesKeyword or ContractKeyword or EnumKeyword or FixedKeyword or FunctionKeyword or Identifier or ImportKeyword or IntKeyword or InterfaceKeyword or LibraryKeyword or MappingKeyword or PragmaKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +───╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.4-failure.txt new file mode 100644 index 0000000000..f56435985e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.4-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or BoolKeyword or BytesKeyword or ContractKeyword or EnumKeyword or ErrorKeyword or FixedKeyword or FunctionKeyword or Identifier or ImportKeyword or IntKeyword or InterfaceKeyword or LibraryKeyword or MappingKeyword or PragmaKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +───╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.8-success.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.8-success.txt new file mode 100644 index 0000000000..0563a6f694 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.8-success.txt @@ -0,0 +1,36 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ type ShortString is bytes32; + │ ─────┬───── + │ ╰─────── def: 1 + │ + 3 │ contract Test { + │ ──┬─ + │ ╰─── def: 2 + 4 │ function test(bytes32 data) public { + │ ──┬─ ──┬─ + │ ╰──────────────── def: 3 + │ │ + │ ╰─── def: 4 + 5 │ ShortString s = ShortString.wrap(data); + │ ─────┬───── ┬ ─────┬───── ──┬─ ──┬─ + │ ╰───────────────────────────────── ref: 1 + │ │ │ │ │ + │ ╰────────────────────────── def: 5 + │ │ │ │ + │ ╰───────────────── ref: 1 + │ │ │ + │ ╰──────── ref: built-in + │ │ + │ ╰─── ref: 4 + 6 │ ShortString.unwrap(s); + │ ─────┬───── ───┬── ┬ + │ ╰──────────────── ref: 1 + │ │ │ + │ ╰────── ref: built-in + │ │ + │ ╰── ref: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/input.sol b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/input.sol new file mode 100644 index 0000000000..f6bc7b63b9 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/input.sol @@ -0,0 +1,8 @@ +type ShortString is bytes32; + +contract Test { + function test(bytes32 data) public { + ShortString s = ShortString.wrap(data); + ShortString.unwrap(s); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..97aeb1b768 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.4.11-failure.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or ThrowKeyword or TrueKeyword or UfixedKeyword or UintKeyword or VarKeyword or WhileKeyword. + ╭─[input.sol:7:9] + │ + 7 │ ╭─▶ payable(_rcpt).sendValue(); + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Address { + │ ───┬─── + │ ╰───── def: 1 + 2 │ function sendValue(address payable recipient) internal {} + │ ────┬──── ────┬──── + │ ╰──────────────────────────────── def: 2 + │ │ + │ ╰────── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Address for address payable; + │ ───┬─── + │ ╰───── ref: 1 + 6 │ function test(address _rcpt) public { + │ ──┬─ ──┬── + │ ╰───────────────── def: 5 + │ │ + │ ╰──── def: 6 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.4.21-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.4.21-failure.txt new file mode 100644 index 0000000000..d4bb34a55a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.4.21-failure.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or ThrowKeyword or TrueKeyword or UfixedKeyword or UintKeyword or VarKeyword or WhileKeyword. + ╭─[input.sol:7:9] + │ + 7 │ ╭─▶ payable(_rcpt).sendValue(); + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Address { + │ ───┬─── + │ ╰───── def: 1 + 2 │ function sendValue(address payable recipient) internal {} + │ ────┬──── ────┬──── + │ ╰──────────────────────────────── def: 2 + │ │ + │ ╰────── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Address for address payable; + │ ───┬─── + │ ╰───── ref: 1 + 6 │ function test(address _rcpt) public { + │ ──┬─ ──┬── + │ ╰───────────────── def: 5 + │ │ + │ ╰──── def: 6 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.5.0-failure.txt new file mode 100644 index 0000000000..d1ae8bf8e8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.5.0-failure.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:7:9] + │ + 7 │ ╭─▶ payable(_rcpt).sendValue(); + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Address { + │ ───┬─── + │ ╰───── def: 1 + 2 │ function sendValue(address payable recipient) internal {} + │ ────┬──── ────┬──── + │ ╰──────────────────────────────── def: 2 + │ │ + │ ╰────── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Address for address payable; + │ ───┬─── + │ ╰───── ref: 1 + 6 │ function test(address _rcpt) public { + │ ──┬─ ──┬── + │ ╰───────────────── def: 5 + │ │ + │ ╰──── def: 6 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.5.3-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.5.3-failure.txt new file mode 100644 index 0000000000..05a55cb7be --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.5.3-failure.txt @@ -0,0 +1,35 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:7:9] + │ + 7 │ ╭─▶ payable(_rcpt).sendValue(); + 8 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Address { + │ ───┬─── + │ ╰───── def: 1 + 2 │ function sendValue(address payable recipient) internal {} + │ ────┬──── ────┬──── + │ ╰──────────────────────────────── def: 2 + │ │ + │ ╰────── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Address for address payable; + │ ───┬─── + │ ╰───── ref: 1 + 6 │ function test(address _rcpt) public { + │ ──┬─ ──┬── + │ ╰───────────────── def: 5 + │ │ + │ ╰──── def: 6 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.6.0-success.txt new file mode 100644 index 0000000000..48d9b99f62 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.6.0-success.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Address { + │ ───┬─── + │ ╰───── def: 1 + 2 │ function sendValue(address payable recipient) internal {} + │ ────┬──── ────┬──── + │ ╰──────────────────────────────── def: 2 + │ │ + │ ╰────── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Address for address payable; + │ ───┬─── + │ ╰───── ref: 1 + 6 │ function test(address _rcpt) public { + │ ──┬─ ──┬── + │ ╰───────────────── def: 5 + │ │ + │ ╰──── def: 6 + 7 │ payable(_rcpt).sendValue(); + │ ──┬── ────┬──── + │ ╰─────────────── ref: 6 + │ │ + │ ╰────── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/address/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/address/input.sol new file mode 100644 index 0000000000..06dcc8494d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/address/input.sol @@ -0,0 +1,9 @@ +library Address { + function sendValue(address payable recipient) internal {} +} +contract Test { + using Address for address payable; + function test(address _rcpt) public { + payable(_rcpt).sendValue(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/casting/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/casting/generated/0.4.11-success.txt new file mode 100644 index 0000000000..7c63d30e2f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/casting/generated/0.4.11-success.txt @@ -0,0 +1,41 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ interface IERC20 { + │ ───┬── + │ ╰──── def: 1 + │ + 3 │ library SafeERC20 { + │ ────┬──── + │ ╰────── def: 2 + 4 │ function safeApprove(IERC20 token) internal {} + │ ─────┬───── ───┬── ──┬── + │ ╰──────────────────── def: 3 + │ │ │ + │ ╰────────── ref: 1 + │ │ + │ ╰──── def: 4 + │ + 6 │ contract Test { + │ ──┬─ + │ ╰─── def: 5 + 7 │ using SafeERC20 for IERC20; + │ ────┬──── ───┬── + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── ref: 1 + 8 │ function test(address token) public { + │ ──┬─ ──┬── + │ ╰───────────────── def: 6 + │ │ + │ ╰──── def: 7 + 9 │ IERC20(token).safeApprove(); + │ ───┬── ──┬── ─────┬───── + │ ╰─────────────────────── ref: 1 + │ │ │ + │ ╰───────────────── ref: 7 + │ │ + │ ╰─────── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/casting/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/casting/input.sol new file mode 100644 index 0000000000..2f6cf1f80c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/casting/input.sol @@ -0,0 +1,11 @@ +interface IERC20 { +} +library SafeERC20 { + function safeApprove(IERC20 token) internal {} +} +contract Test { + using SafeERC20 for IERC20; + function test(address token) public { + IERC20(token).safeApprove(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/chained_calls/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/chained_calls/generated/0.4.11-success.txt new file mode 100644 index 0000000000..180ec2bfde --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/chained_calls/generated/0.4.11-success.txt @@ -0,0 +1,78 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Foo { + │ ─┬─ + │ ╰─── def: 1 + 2 │ struct Bar { + │ ─┬─ + │ ╰─── def: 2 + 3 │ uint value; + │ ──┬── + │ ╰──── def: 3 + │ + 5 │ function noop(uint x) public returns (uint) {} + │ ──┬─ ┬ + │ ╰────────── def: 4 + │ │ + │ ╰── def: 5 + 6 │ function bar(uint x) public returns (Bar) {} + │ ─┬─ ┬ ─┬─ + │ ╰─────────────────────────────── def: 6 + │ │ │ + │ ╰─────────────────────── def: 7 + │ │ + │ ╰─── ref: 2 + │ + 9 │ contract Test { + │ ──┬─ + │ ╰─── def: 8 + 10 │ using Foo for uint; + │ ─┬─ + │ ╰─── ref: 1 + 11 │ function test(uint a, Foo.Bar memory b) public { + │ ──┬─ ┬ ─┬─ ─┬─ ┬ + │ ╰──────────────────────────── def: 9 + │ │ │ │ │ + │ ╰──────────────────── def: 10 + │ │ │ │ + │ ╰──────────────── ref: 1 + │ │ │ + │ ╰──────────── ref: 2 + │ │ + │ ╰── def: 11 + 12 │ uint[] memory xs; + │ ─┬ + │ ╰── def: 12 + 13 │ a.noop().noop().noop(); + │ ┬ ──┬─ ──┬─ ──┬─ + │ ╰───────────────────── ref: 10 + │ │ │ │ + │ ╰───────────────── ref: 4 + │ │ │ + │ ╰────────── ref: 4 + │ │ + │ ╰─── ref: 4 + 14 │ b.value.noop().bar().value.noop(); + │ ┬ ──┬── ──┬─ ─┬─ ──┬── ──┬─ + │ ╰──────────────────────────────── ref: 11 + │ │ │ │ │ │ + │ ╰──────────────────────────── ref: 3 + │ │ │ │ │ + │ ╰────────────────────── ref: 4 + │ │ │ │ + │ ╰──────────────── ref: 6 + │ │ │ + │ ╰───────── ref: 3 + │ │ + │ ╰─── ref: 4 + 15 │ xs[5].noop().noop(); + │ ─┬ ──┬─ ──┬─ + │ ╰───────────────── ref: 12 + │ │ │ + │ ╰────────── ref: 4 + │ │ + │ ╰─── ref: 4 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/chained_calls/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/chained_calls/input.sol new file mode 100644 index 0000000000..0a0143ee1c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/chained_calls/input.sol @@ -0,0 +1,17 @@ +library Foo { + struct Bar { + uint value; + } + function noop(uint x) public returns (uint) {} + function bar(uint x) public returns (Bar) {} +} + +contract Test { + using Foo for uint; + function test(uint a, Foo.Bar memory b) public { + uint[] memory xs; + a.noop().noop().noop(); + b.value.noop().bar().value.noop(); + xs[5].noop().noop(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/generated/0.4.11-success.txt new file mode 100644 index 0000000000..d8aec265bc --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/generated/0.4.11-success.txt @@ -0,0 +1,44 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 2 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 3 │ function nop(uint256 x) {} + │ ─┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 5 │ contract Base { + │ ──┬─ + │ ╰─── def: 4 + 6 │ uint256 totalSupply; + │ ─────┬───── + │ ╰─────── def: 5 + │ + 8 │ contract Middle is Base { + │ ───┬── ──┬─ + │ ╰──────────── def: 6 + │ │ + │ ╰─── ref: 4 + 9 │ using Lib for uint256; + │ ─┬─ + │ ╰─── ref: 1 + │ + 11 │ contract Test is Middle { + │ ──┬─ ───┬── + │ ╰───────────── def: 7 + │ │ + │ ╰──── ref: 6 + 12 │ function test() public { + │ ──┬─ + │ ╰─── def: 8 + 13 │ totalSupply.nop(); + │ ─────┬───── ─┬─ + │ ╰─────────── ref: 5 + │ │ + │ ╰─── ref: 2 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..3aa3f58fd1 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/generated/0.7.0-failure.txt @@ -0,0 +1,44 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 2 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 3 │ function nop(uint256 x) {} + │ ─┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 5 │ contract Base { + │ ──┬─ + │ ╰─── def: 4 + 6 │ uint256 totalSupply; + │ ─────┬───── + │ ╰─────── def: 5 + │ + 8 │ contract Middle is Base { + │ ───┬── ──┬─ + │ ╰──────────── def: 6 + │ │ + │ ╰─── ref: 4 + 9 │ using Lib for uint256; + │ ─┬─ + │ ╰─── ref: 1 + │ + 11 │ contract Test is Middle { + │ ──┬─ ───┬── + │ ╰───────────── def: 7 + │ │ + │ ╰──── ref: 6 + 12 │ function test() public { + │ ──┬─ + │ ╰─── def: 8 + 13 │ totalSupply.nop(); + │ ─────┬───── ─┬─ + │ ╰─────────── ref: 5 + │ │ + │ ╰─── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/input.sol new file mode 100644 index 0000000000..6e5e05addb --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/inherit_extension/input.sol @@ -0,0 +1,15 @@ +// In Solidity < 0.7.0 using directives are inherited in sub contracts +library Lib { + function nop(uint256 x) {} +} +contract Base { + uint256 totalSupply; +} +contract Middle is Base { + using Lib for uint256; +} +contract Test is Middle { + function test() public { + totalSupply.nop(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/inherited_types/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/inherited_types/generated/0.4.11-success.txt new file mode 100644 index 0000000000..e4adbece8d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/inherited_types/generated/0.4.11-success.txt @@ -0,0 +1,52 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ interface IPool { + │ ──┬── + │ ╰──── def: 1 + 2 │ struct Info { + │ ──┬─ + │ ╰─── def: 2 + 3 │ uint256 amount; + │ ───┬── + │ ╰──── def: 3 + │ + 6 │ library Math { + │ ──┬─ + │ ╰─── def: 4 + 7 │ function nop(uint256 x) public {} + │ ─┬─ ┬ + │ ╰───────────── def: 5 + │ │ + │ ╰── def: 6 + │ + 9 │ contract Test is IPool { + │ ──┬─ ──┬── + │ ╰──────────── def: 7 + │ │ + │ ╰──── ref: 1 + 10 │ mapping(uint256 => Info) infos; + │ ──┬─ ──┬── + │ ╰────────── ref: 2 + │ │ + │ ╰──── def: 8 + 11 │ using Math for uint256; + │ ──┬─ + │ ╰─── ref: 4 + 12 │ function test(uint256 x) public { + │ ──┬─ ┬ + │ ╰───────────── def: 9 + │ │ + │ ╰── def: 10 + 13 │ infos[x].amount.nop(); + │ ──┬── ┬ ───┬── ─┬─ + │ ╰────────────────── ref: 8 + │ │ │ │ + │ ╰────────────── ref: 10 + │ │ │ + │ ╰──────── ref: 3 + │ │ + │ ╰─── ref: 5 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/inherited_types/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/inherited_types/input.sol new file mode 100644 index 0000000000..d136d3833a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/inherited_types/input.sol @@ -0,0 +1,15 @@ +interface IPool { + struct Info { + uint256 amount; + } +} +library Math { + function nop(uint256 x) public {} +} +contract Test is IPool { + mapping(uint256 => Info) infos; + using Math for uint256; + function test(uint256 x) public { + infos[x].amount.nop(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/mappings/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/mappings/generated/0.4.11-success.txt new file mode 100644 index 0000000000..6094b2e72e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/mappings/generated/0.4.11-success.txt @@ -0,0 +1,32 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ using Lib for mapping(address => uint); + │ ─┬─ + │ ╰─── ref: 4 + 3 │ mapping(address => uint) balances; + │ ────┬─── + │ ╰───── def: 2 + 4 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + 5 │ balances.nop(); + │ ────┬─── ─┬─ + │ ╰───────── ref: 2 + │ │ + │ ╰─── ref: 5 + │ + 8 │ library Lib { + │ ─┬─ + │ ╰─── def: 4 + 9 │ function nop(mapping(address => uint) storage m) internal {} + │ ─┬─ ┬ + │ ╰────────────────────────────────────── def: 5 + │ │ + │ ╰── def: 6 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/mappings/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/mappings/input.sol new file mode 100644 index 0000000000..07c9130933 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/mappings/input.sol @@ -0,0 +1,10 @@ +contract Test { + using Lib for mapping(address => uint); + mapping(address => uint) balances; + function test() public { + balances.nop(); + } +} +library Lib { + function nop(mapping(address => uint) storage m) internal {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.4.11-success.txt new file mode 100644 index 0000000000..f11a068098 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.4.11-success.txt @@ -0,0 +1,48 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library LibFoo { + │ ───┬── + │ ╰──── def: 1 + 2 │ function use_foo(IFoo x) public returns (int) {} + │ ───┬─── ──┬─ ┬ + │ ╰──────────── def: 2 + │ │ │ + │ ╰───── ref: 4 + │ │ + │ ╰── def: 3 + │ + 4 │ interface IFoo { + │ ──┬─ + │ ╰─── def: 4 + │ + 6 │ contract Base { + │ ──┬─ + │ ╰─── def: 5 + 7 │ using LibFoo for IFoo; + │ ───┬── ──┬─ + │ ╰───────────── ref: 1 + │ │ + │ ╰─── ref: 4 + │ + 9 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 6 + │ │ + │ ╰─── ref: 5 + 10 │ function test(address x) public { + │ ──┬─ ┬ + │ ╰───────────── def: 7 + │ │ + │ ╰── def: 8 + │ + 12 │ IFoo(x).use_foo(); + │ ──┬─ ┬ ───┬─── + │ ╰────────────── ref: 4 + │ │ │ + │ ╰─────────── ref: 8 + │ │ + │ ╰───── ref: 2 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..5afd65e4af --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.7.0-failure.txt @@ -0,0 +1,48 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library LibFoo { + │ ───┬── + │ ╰──── def: 1 + 2 │ function use_foo(IFoo x) public returns (int) {} + │ ───┬─── ──┬─ ┬ + │ ╰──────────── def: 2 + │ │ │ + │ ╰───── ref: 4 + │ │ + │ ╰── def: 3 + │ + 4 │ interface IFoo { + │ ──┬─ + │ ╰─── def: 4 + │ + 6 │ contract Base { + │ ──┬─ + │ ╰─── def: 5 + 7 │ using LibFoo for IFoo; + │ ───┬── ──┬─ + │ ╰───────────── ref: 1 + │ │ + │ ╰─── ref: 4 + │ + 9 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 6 + │ │ + │ ╰─── ref: 5 + 10 │ function test(address x) public { + │ ──┬─ ┬ + │ ╰───────────── def: 7 + │ │ + │ ╰── def: 8 + │ + 12 │ IFoo(x).use_foo(); + │ ──┬─ ┬ ───┬─── + │ ╰────────────── ref: 4 + │ │ │ + │ ╰─────────── ref: 8 + │ │ + │ ╰───── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/input.sol new file mode 100644 index 0000000000..c894206b75 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/input.sol @@ -0,0 +1,14 @@ +library LibFoo { + function use_foo(IFoo x) public returns (int) {} +} +interface IFoo { +} +contract Base { + using LibFoo for IFoo; +} +contract Test is Base { + function test(address x) public { + // should work for Solidity < 0.7.0 + IFoo(x).use_foo(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_parameters/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/on_parameters/generated/0.4.11-success.txt new file mode 100644 index 0000000000..4753580729 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_parameters/generated/0.4.11-success.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function nop(uint256 x) internal {} + │ ─┬─ ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Lib for uint256; + │ ─┬─ + │ ╰─── ref: 1 + 6 │ function test(uint256 x) public returns (uint256 y) { + │ ──┬─ ┬ ┬ + │ ╰──────────────────────────────────────── def: 5 + │ │ │ + │ ╰───────────────────────────── def: 6 + │ │ + │ ╰── def: 7 + 7 │ x.nop(); + │ ┬ ─┬─ + │ ╰────── ref: 6 + │ │ + │ ╰─── ref: 2 + 8 │ y.nop(); + │ ┬ ─┬─ + │ ╰────── ref: 7 + │ │ + │ ╰─── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_parameters/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/on_parameters/input.sol new file mode 100644 index 0000000000..135ab2423e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_parameters/input.sol @@ -0,0 +1,10 @@ +library Lib { + function nop(uint256 x) internal {} +} +contract Test { + using Lib for uint256; + function test(uint256 x) public returns (uint256 y) { + x.nop(); + y.nop(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_state_var_initialization/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/on_state_var_initialization/generated/0.4.11-success.txt new file mode 100644 index 0000000000..0dacde723a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_state_var_initialization/generated/0.4.11-success.txt @@ -0,0 +1,33 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function nop(uint256 x) returns (uint256) { return x; } + │ ─┬─ ┬ ┬ + │ ╰─────────────────────────────────────────── def: 2 + │ │ │ + │ ╰──────────────────────────────── def: 3 + │ │ + │ ╰── ref: 3 + │ + 4 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 5 │ using Lib for uint256; + │ ─┬─ + │ ╰─── ref: 1 + 6 │ uint256 private v1 = 1; + │ ─┬ + │ ╰── def: 5 + 7 │ uint256 private v2 = v1.nop(); + │ ─┬ ─┬ ─┬─ + │ ╰─────────── def: 6 + │ │ │ + │ ╰────── ref: 5 + │ │ + │ ╰─── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_state_var_initialization/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/on_state_var_initialization/input.sol new file mode 100644 index 0000000000..ff41b32b6e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_state_var_initialization/input.sol @@ -0,0 +1,8 @@ +library Lib { + function nop(uint256 x) returns (uint256) { return x; } +} +contract Test { + using Lib for uint256; + uint256 private v1 = 1; + uint256 private v2 = v1.nop(); +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_super_calls/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/on_super_calls/generated/0.4.11-success.txt new file mode 100644 index 0000000000..99cdf03840 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_super_calls/generated/0.4.11-success.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract A { + │ ┬ + │ ╰── def: 1 + 2 │ function total() public returns (uint256) {} + │ ──┬── + │ ╰──── def: 2 + │ + 4 │ contract B is A { + │ ┬ ┬ + │ ╰─────── def: 3 + │ │ + │ ╰── ref: 1 + 5 │ using Lib for uint256; + │ ─┬─ + │ ╰─── ref: 5 + 6 │ function total() public returns (uint256) { + │ ──┬── + │ ╰──── def: 4 + 7 │ return super.total().nop(); + │ ──┬── ─┬─ + │ ╰────────── ref: 2 + │ │ + │ ╰─── ref: 6 + │ + 10 │ library Lib { + │ ─┬─ + │ ╰─── def: 5 + 11 │ function nop(uint256 x) internal returns (uint256) {} + │ ─┬─ ┬ + │ ╰───────────── def: 6 + │ │ + │ ╰── def: 7 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_super_calls/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/on_super_calls/input.sol new file mode 100644 index 0000000000..5fde21f3a5 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_super_calls/input.sol @@ -0,0 +1,12 @@ +contract A { + function total() public returns (uint256) {} +} +contract B is A { + using Lib for uint256; + function total() public returns (uint256) { + return super.total().nop(); + } +} +library Lib { + function nop(uint256 x) internal returns (uint256) {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/qualified_type/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/qualified_type/generated/0.4.11-success.txt new file mode 100644 index 0000000000..d2c34aa894 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/qualified_type/generated/0.4.11-success.txt @@ -0,0 +1,49 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ struct Value { + │ ──┬── + │ ╰──── def: 2 + 3 │ int x; + │ ┬ + │ ╰── def: 3 + │ + 5 │ function getValue() external returns (Value memory) {} + │ ────┬─── ──┬── + │ ╰─────────────────────────────── def: 4 + │ │ + │ ╰──── ref: 2 + 6 │ function use(Value memory x) external {} + │ ─┬─ ──┬── ┬ + │ ╰────────────────── def: 5 + │ │ │ + │ ╰───────────── ref: 2 + │ │ + │ ╰── def: 6 + │ + 8 │ contract Test { + │ ──┬─ + │ ╰─── def: 7 + 9 │ using Lib for Lib.Value; + │ ─┬─ ─┬─ ──┬── + │ ╰───────────────── ref: 1 + │ │ │ + │ ╰───────── ref: 1 + │ │ + │ ╰──── ref: 2 + 10 │ function test() internal { + │ ──┬─ + │ ╰─── def: 8 + 11 │ Lib.getValue().use(); + │ ─┬─ ────┬─── ─┬─ + │ ╰────────────────── ref: 1 + │ │ │ + │ ╰─────────── ref: 4 + │ │ + │ ╰─── ref: 5 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/qualified_type/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/qualified_type/input.sol new file mode 100644 index 0000000000..b63cc756e5 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/qualified_type/input.sol @@ -0,0 +1,13 @@ +library Lib { + struct Value { + int x; + } + function getValue() external returns (Value memory) {} + function use(Value memory x) external {} +} +contract Test { + using Lib for Lib.Value; + function test() internal { + Lib.getValue().use(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/star/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/star/generated/0.4.11-success.txt index 63dd244363..f3c3ede787 100644 --- a/crates/solidity/testing/snapshots/bindings_output/using/star/generated/0.4.11-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/using/star/generated/0.4.11-success.txt @@ -1,45 +1,32 @@ # This file is generated automatically by infrastructure scripts. Please don't edit by hand. References and definitions: - ╭─[input.sol:1:1] - │ - 1 │ library Lib { - │ ─┬─ - │ ╰─── def: 1 - 2 │ struct Counter { - │ ───┬─── - │ ╰───── def: 2 - 3 │ uint value; - │ ──┬── - │ ╰──── def: 3 - │ - 6 │ function increment(Counter memory _counter) public {} - │ ────┬──── ───┬─── ────┬─── - │ ╰────────────────────────────── def: 4 - │ │ │ - │ ╰───────────────────── ref: 2 - │ │ - │ ╰───── def: 5 - │ - 9 │ contract Test { - │ ──┬─ - │ ╰─── def: 6 - 10 │ using Lib for *; - │ ─┬─ - │ ╰─── ref: 1 - │ - 12 │ function test(Lib.Counter memory c) public { - │ ──┬─ ─┬─ ───┬─── ┬ - │ ╰──────────────────────── def: 7 - │ │ │ │ - │ ╰──────────────────── ref: 1 - │ │ │ - │ ╰────────────── ref: 2 - │ │ - │ ╰── def: 8 - 13 │ c.increment(); - │ ┬ ────┬──── - │ ╰──────────── ref: 8 - │ │ - │ ╰────── ref: 4 -────╯ + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function increment(uint x) public {} + │ ────┬──── ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 5 │ contract Test { + │ ──┬─ + │ ╰─── def: 4 + 6 │ using Lib for *; + │ ─┬─ + │ ╰─── ref: 1 + │ + 8 │ function test(uint x) public { + │ ──┬─ ┬ + │ ╰────────── def: 5 + │ │ + │ ╰── def: 6 + 9 │ x.increment(); + │ ┬ ────┬──── + │ ╰──────────── ref: 6 + │ │ + │ ╰────── ref: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/star/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/star/input.sol index 90669136e3..af70c03cd9 100644 --- a/crates/solidity/testing/snapshots/bindings_output/using/star/input.sol +++ b/crates/solidity/testing/snapshots/bindings_output/using/star/input.sol @@ -1,15 +1,11 @@ library Lib { - struct Counter { - uint value; - } - - function increment(Counter memory _counter) public {} + function increment(uint x) public {} } contract Test { using Lib for *; - function test(Lib.Counter memory c) public { - c.increment(); + function test(uint x) public { + x.increment(); } } diff --git a/crates/solidity/testing/snapshots/bindings_output/using/star_in_library/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/star_in_library/generated/0.4.11-success.txt new file mode 100644 index 0000000000..dfe2b1d565 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/star_in_library/generated/0.4.11-success.txt @@ -0,0 +1,33 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ using Math for *; + │ ──┬─ + │ ╰─── ref: 4 + 3 │ function test(uint x) internal { + │ ──┬─ ┬ + │ ╰────────── def: 2 + │ │ + │ ╰── def: 3 + 4 │ x.add(1); + │ ┬ ─┬─ + │ ╰────── ref: 3 + │ │ + │ ╰─── ref: 5 + │ + 7 │ library Math { + │ ──┬─ + │ ╰─── def: 4 + 8 │ function add(uint x, uint y) internal {} + │ ─┬─ ┬ ┬ + │ ╰────────────────── def: 5 + │ │ │ + │ ╰────────── def: 6 + │ │ + │ ╰── def: 7 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/star_in_library/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/star_in_library/input.sol new file mode 100644 index 0000000000..91fcfeaceb --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/star_in_library/input.sol @@ -0,0 +1,9 @@ +library Lib { + using Math for *; + function test(uint x) internal { + x.add(1); + } +} +library Math { + function add(uint x, uint y) internal {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/generated/0.4.11-success.txt new file mode 100644 index 0000000000..0c749da6a4 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/generated/0.4.11-success.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function increment(uint x) public {} + │ ────┬──── ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 5 │ contract Base { + │ ──┬─ + │ ╰─── def: 4 + 6 │ using Lib for *; + │ ─┬─ + │ ╰─── ref: 1 + │ + 9 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 5 + │ │ + │ ╰─── ref: 4 + 10 │ function test(uint x) public { + │ ──┬─ ┬ + │ ╰────────── def: 6 + │ │ + │ ╰── def: 7 + │ + 12 │ x.increment(); + │ ┬ ────┬──── + │ ╰──────────── ref: 7 + │ │ + │ ╰────── ref: 2 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..d743ce1067 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/generated/0.7.0-failure.txt @@ -0,0 +1,38 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Lib { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function increment(uint x) public {} + │ ────┬──── ┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 5 │ contract Base { + │ ──┬─ + │ ╰─── def: 4 + 6 │ using Lib for *; + │ ─┬─ + │ ╰─── ref: 1 + │ + 9 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 5 + │ │ + │ ╰─── ref: 4 + 10 │ function test(uint x) public { + │ ──┬─ ┬ + │ ╰────────── def: 6 + │ │ + │ ╰── def: 7 + │ + 12 │ x.increment(); + │ ┬ ────┬──── + │ ╰──────────── ref: 7 + │ │ + │ ╰────── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/input.sol new file mode 100644 index 0000000000..1d77492bcd --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/star_inherited/input.sol @@ -0,0 +1,14 @@ +library Lib { + function increment(uint x) public {} +} + +contract Base { + using Lib for *; +} + +contract Test is Base { + function test(uint x) public { + // should resolve for Solidity < 0.7.0 + x.increment(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/uint_alias/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/uint_alias/generated/0.4.11-success.txt new file mode 100644 index 0000000000..d04e0ece4e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/uint_alias/generated/0.4.11-success.txt @@ -0,0 +1,32 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ using Lib for uint256; + │ ─┬─ + │ ╰─── ref: 4 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + 4 │ uint x; + │ ┬ + │ ╰── def: 3 + 5 │ x.nop(); + │ ┬ ─┬─ + │ ╰────── ref: 3 + │ │ + │ ╰─── ref: 5 + │ + 8 │ library Lib { + │ ─┬─ + │ ╰─── def: 4 + 9 │ function nop(uint256 x) external {} + │ ─┬─ ┬ + │ ╰───────────── def: 5 + │ │ + │ ╰── def: 6 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/uint_alias/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/uint_alias/input.sol new file mode 100644 index 0000000000..6785caf83f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/uint_alias/input.sol @@ -0,0 +1,10 @@ +contract Test { + using Lib for uint256; + function test() public { + uint x; + x.nop(); + } +} +library Lib { + function nop(uint256 x) external {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..5b3351888a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.4.11-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..59217924c2 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.6.0-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or EnumKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword or StructKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.7.1-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.7.1-failure.txt new file mode 100644 index 0000000000..d19bf6dfe0 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.7.1-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or EnumKeyword or FunctionKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword or StructKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.7.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.7.4-failure.txt new file mode 100644 index 0000000000..50dc41f2ab --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.7.4-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or BoolKeyword or ByteKeyword or BytesKeyword or ContractKeyword or EnumKeyword or FixedKeyword or FunctionKeyword or Identifier or ImportKeyword or IntKeyword or InterfaceKeyword or LibraryKeyword or MappingKeyword or PragmaKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.0-failure.txt new file mode 100644 index 0000000000..205226995e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.0-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or BoolKeyword or BytesKeyword or ContractKeyword or EnumKeyword or FixedKeyword or FunctionKeyword or Identifier or ImportKeyword or IntKeyword or InterfaceKeyword or LibraryKeyword or MappingKeyword or PragmaKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.4-failure.txt new file mode 100644 index 0000000000..c709a0526b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.4-failure.txt @@ -0,0 +1,13 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or BoolKeyword or BytesKeyword or ContractKeyword or EnumKeyword or ErrorKeyword or FixedKeyword or FunctionKeyword or Identifier or ImportKeyword or IntKeyword or InterfaceKeyword or LibraryKeyword or MappingKeyword or PragmaKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ type ShortString is bytes32; + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.8-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.8-success.txt new file mode 100644 index 0000000000..2ec0bb8683 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/generated/0.8.8-success.txt @@ -0,0 +1,67 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ type ShortString is bytes32; + │ ─────┬───── + │ ╰─────── def: 1 + │ + 3 │ contract Test { + │ ──┬─ + │ ╰─── def: 2 + 4 │ using Lib for ShortString; + │ ─┬─ ─────┬───── + │ ╰─────────────────── ref: 6 + │ │ + │ ╰─────── ref: 1 + 5 │ using Lib for bytes32; + │ ─┬─ + │ ╰─── ref: 6 + │ + 7 │ function test(bytes32 data) public { + │ ──┬─ ──┬─ + │ ╰──────────────── def: 3 + │ │ + │ ╰─── def: 4 + 8 │ ShortString s; + │ ─────┬───── ┬ + │ ╰───────── ref: 1 + │ │ + │ ╰── def: 5 + │ + 10 │ ShortString.wrap(data).nop(); + │ ─────┬───── ──┬─ ──┬─ ─┬─ + │ ╰────────────────────── ref: 1 + │ │ │ │ + │ ╰───────────── ref: built-in + │ │ │ + │ ╰──────── ref: 4 + │ │ + │ ╰─── ref: 7 + 11 │ ShortString.unwrap(s).pon(); + │ ─────┬───── ───┬── ┬ ─┬─ + │ ╰───────────────────── ref: 1 + │ │ │ │ + │ ╰─────────── ref: built-in + │ │ │ + │ ╰─────── ref: 5 + │ │ + │ ╰─── ref: 9 + │ + 15 │ library Lib { + │ ─┬─ + │ ╰─── def: 6 + 16 │ function nop(ShortString x) internal {} + │ ─┬─ ─────┬───── ┬ + │ ╰───────────────── def: 7 + │ │ │ + │ ╰───────── ref: 1 + │ │ + │ ╰── def: 8 + 17 │ function pon(bytes32 x) internal {} + │ ─┬─ ┬ + │ ╰───────────── def: 9 + │ │ + │ ╰── def: 10 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/user_types/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/user_types/input.sol new file mode 100644 index 0000000000..2cd5524ea3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/user_types/input.sol @@ -0,0 +1,18 @@ +type ShortString is bytes32; + +contract Test { + using Lib for ShortString; + using Lib for bytes32; + + function test(bytes32 data) public { + ShortString s; + + ShortString.wrap(data).nop(); + ShortString.unwrap(s).pon(); + } +} + +library Lib { + function nop(ShortString x) internal {} + function pon(bytes32 x) internal {} +} diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.4.11-success.txt new file mode 100644 index 0000000000..49bae9ee2c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.4.11-success.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { int x; } + │ ──┬── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function test(Value memory value) public { + │ ──┬─ ──┬── ──┬── + │ ╰────────────────────── def: 4 + │ │ │ + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 5 + 4 │ var v = value; + │ ┬ ──┬── + │ ╰────────── def: 6 + │ │ + │ ╰──── ref: 5 + 5 │ v.x; + │ ┬ ┬ + │ ╰──── refs: 6, 5 + │ │ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.5.0-failure.txt new file mode 100644 index 0000000000..b1aab5f30b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.5.0-failure.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ var v = value; + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { int x; } + │ ──┬── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function test(Value memory value) public { + │ ──┬─ ──┬── ──┬── + │ ╰────────────────────── def: 4 + │ │ │ + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.5.3-failure.txt b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.5.3-failure.txt new file mode 100644 index 0000000000..916fc51d48 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.5.3-failure.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ var v = value; + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { int x; } + │ ──┬── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function test(Value memory value) public { + │ ──┬─ ──┬── ──┬── + │ ╰────────────────────── def: 4 + │ │ │ + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..baeb9846cc --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.6.0-failure.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or PayableKeyword or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ var v = value; + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { int x; } + │ ──┬── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function test(Value memory value) public { + │ ──┬─ ──┬── ──┬── + │ ╰────────────────────── def: 4 + │ │ │ + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..d9a26d93af --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.7.0-failure.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or DoubleQuotedUnicodeStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or PayableKeyword or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or SingleQuotedUnicodeStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ var v = value; + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { int x; } + │ ──┬── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function test(Value memory value) public { + │ ──┬─ ──┬── ──┬── + │ ╰────────────────────── def: 4 + │ │ │ + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.8.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.8.0-failure.txt new file mode 100644 index 0000000000..4ab42efd3b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.8.0-failure.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or DoubleQuotedUnicodeStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or PayableKeyword or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or SingleQuotedUnicodeStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or UncheckedKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ var v = value; + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { int x; } + │ ──┬── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function test(Value memory value) public { + │ ──┬─ ──┬── ──┬── + │ ╰────────────────────── def: 4 + │ │ │ + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.8.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.8.4-failure.txt new file mode 100644 index 0000000000..bef3f48735 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/generated/0.8.4-failure.txt @@ -0,0 +1,31 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or BytesKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or DoubleQuotedUnicodeStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or PayableKeyword or ReturnKeyword or RevertKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or SingleQuotedUnicodeStringLiteral or StringKeyword or SuperKeyword or ThisKeyword or TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or UncheckedKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ var v = value; + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ struct Value { int x; } + │ ──┬── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ function test(Value memory value) public { + │ ──┬─ ──┬── ──┬── + │ ╰────────────────────── def: 4 + │ │ │ + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/input.sol b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/input.sol new file mode 100644 index 0000000000..2a03158592 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/var_declaration/input.sol @@ -0,0 +1,7 @@ +contract Test { + struct Value { int x; } + function test(Value memory value) public { + var v = value; + v.x; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..568d7b9b08 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.4.11-failure.txt @@ -0,0 +1,67 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword. + ╭─[input.sol:27:1] + │ + 27 │ uint256 constant TOP_LEVEL_CONST = 0; + │ ───────────────────┬────────────────── + │ ╰──────────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract InContracts { + │ ─────┬───── + │ ╰─────── def: 1 + 2 │ uint256 private constant CONTRACT_CONST = 1; + │ ───────┬────── + │ ╰──────── def: 2 + │ + 4 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 6 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 4 + │ │ + │ ╰───── def: 5 + 7 │ mstore(emptyPtr, CONTRACT_CONST) + │ ────┬─── ───────┬────── + │ ╰───────────────────── ref: 5 + │ │ + │ ╰──────── ref: 2 + 8 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 5 + │ │ + │ ╰───────── unresolved + │ + 14 │ library InLibraries { + │ ─────┬───── + │ ╰─────── def: 6 + 15 │ uint256 private constant LIB_CONST = 2; + │ ────┬──── + │ ╰────── def: 7 + │ + 17 │ function test() public { + │ ──┬─ + │ ╰─── def: 8 + │ + 19 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 9 + │ │ + │ ╰───── def: 10 + 20 │ mstore(emptyPtr, LIB_CONST) + │ ────┬─── ────┬──── + │ ╰──────────────── ref: 10 + │ │ + │ ╰────── ref: 7 + 21 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 10 + │ │ + │ ╰───────── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..19b7c69fae --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.6.0-failure.txt @@ -0,0 +1,67 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or EnumKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword or StructKeyword. + ╭─[input.sol:27:1] + │ + 27 │ uint256 constant TOP_LEVEL_CONST = 0; + │ ───────────────────┬────────────────── + │ ╰──────────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract InContracts { + │ ─────┬───── + │ ╰─────── def: 1 + 2 │ uint256 private constant CONTRACT_CONST = 1; + │ ───────┬────── + │ ╰──────── def: 2 + │ + 4 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 6 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 4 + │ │ + │ ╰───── def: 5 + 7 │ mstore(emptyPtr, CONTRACT_CONST) + │ ────┬─── ───────┬────── + │ ╰───────────────────── ref: 5 + │ │ + │ ╰──────── ref: 2 + 8 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 5 + │ │ + │ ╰───────── unresolved + │ + 14 │ library InLibraries { + │ ─────┬───── + │ ╰─────── def: 6 + 15 │ uint256 private constant LIB_CONST = 2; + │ ────┬──── + │ ╰────── def: 7 + │ + 17 │ function test() public { + │ ──┬─ + │ ╰─── def: 8 + │ + 19 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 9 + │ │ + │ ╰───── def: 10 + 20 │ mstore(emptyPtr, LIB_CONST) + │ ────┬─── ────┬──── + │ ╰──────────────── ref: 10 + │ │ + │ ╰────── ref: 7 + 21 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 10 + │ │ + │ ╰───────── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.7.1-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.7.1-failure.txt new file mode 100644 index 0000000000..19d15d5248 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.7.1-failure.txt @@ -0,0 +1,67 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or EnumKeyword or FunctionKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword or StructKeyword. + ╭─[input.sol:27:1] + │ + 27 │ uint256 constant TOP_LEVEL_CONST = 0; + │ ───────────────────┬────────────────── + │ ╰──────────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract InContracts { + │ ─────┬───── + │ ╰─────── def: 1 + 2 │ uint256 private constant CONTRACT_CONST = 1; + │ ───────┬────── + │ ╰──────── def: 2 + │ + 4 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 6 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 4 + │ │ + │ ╰───── def: 5 + 7 │ mstore(emptyPtr, CONTRACT_CONST) + │ ────┬─── ───────┬────── + │ ╰───────────────────── ref: 5 + │ │ + │ ╰──────── ref: 2 + 8 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 5 + │ │ + │ ╰───────── unresolved + │ + 14 │ library InLibraries { + │ ─────┬───── + │ ╰─────── def: 6 + 15 │ uint256 private constant LIB_CONST = 2; + │ ────┬──── + │ ╰────── def: 7 + │ + 17 │ function test() public { + │ ──┬─ + │ ╰─── def: 8 + │ + 19 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 9 + │ │ + │ ╰───── def: 10 + 20 │ mstore(emptyPtr, LIB_CONST) + │ ────┬─── ────┬──── + │ ╰──────────────── ref: 10 + │ │ + │ ╰────── ref: 7 + 21 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 10 + │ │ + │ ╰───────── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.7.4-success.txt b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.7.4-success.txt new file mode 100644 index 0000000000..38815261bc --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/generated/0.7.4-success.txt @@ -0,0 +1,63 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract InContracts { + │ ─────┬───── + │ ╰─────── def: 1 + 2 │ uint256 private constant CONTRACT_CONST = 1; + │ ───────┬────── + │ ╰──────── def: 2 + │ + 4 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 6 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 4 + │ │ + │ ╰───── def: 5 + 7 │ mstore(emptyPtr, CONTRACT_CONST) + │ ────┬─── ───────┬────── + │ ╰───────────────────── ref: 5 + │ │ + │ ╰──────── ref: 2 + 8 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 5 + │ │ + │ ╰───────── ref: 11 + │ + 14 │ library InLibraries { + │ ─────┬───── + │ ╰─────── def: 6 + 15 │ uint256 private constant LIB_CONST = 2; + │ ────┬──── + │ ╰────── def: 7 + │ + 17 │ function test() public { + │ ──┬─ + │ ╰─── def: 8 + │ + 19 │ function swap(emptyPtr) { + │ ──┬─ ────┬─── + │ ╰──────────── def: 9 + │ │ + │ ╰───── def: 10 + 20 │ mstore(emptyPtr, LIB_CONST) + │ ────┬─── ────┬──── + │ ╰──────────────── ref: 10 + │ │ + │ ╰────── ref: 7 + 21 │ mstore(emptyPtr, TOP_LEVEL_CONST) + │ ────┬─── ───────┬─────── + │ ╰────────────────────── ref: 10 + │ │ + │ ╰───────── ref: 11 + │ + 27 │ uint256 constant TOP_LEVEL_CONST = 0; + │ ───────┬─────── + │ ╰───────── def: 11 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/input.sol b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/input.sol new file mode 100644 index 0000000000..2dcf1ca5ad --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/constant_access_from_functions/input.sol @@ -0,0 +1,27 @@ +contract InContracts { + uint256 private constant CONTRACT_CONST = 1; + + function test() public { + assembly { + function swap(emptyPtr) { + mstore(emptyPtr, CONTRACT_CONST) + mstore(emptyPtr, TOP_LEVEL_CONST) + } + } + } +} + +library InLibraries { + uint256 private constant LIB_CONST = 2; + + function test() public { + assembly { + function swap(emptyPtr) { + mstore(emptyPtr, LIB_CONST) + mstore(emptyPtr, TOP_LEVEL_CONST) + } + } + } +} + +uint256 constant TOP_LEVEL_CONST = 0; diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..d14a31e3bf --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.4.11-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected CloseBrace or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or Equal or EqualColon or OpenBrace or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or YulAddKeyword or YulAddModKeyword or YulAddressKeyword or YulAndKeyword or YulBalanceKeyword or YulBlockHashKeyword or YulBreakKeyword or YulByteKeyword or YulCallCodeKeyword or YulCallDataCopyKeyword or YulCallDataLoadKeyword or YulCallDataSizeKeyword or YulCallKeyword or YulCallValueKeyword or YulCallerKeyword or YulChainIdKeyword or YulCoinBaseKeyword or YulContinueKeyword or YulCreateKeyword or YulDecimalLiteral or YulDelegateCallKeyword or YulDifficultyKeyword or YulDivKeyword or YulEqKeyword or YulExpKeyword or YulExtCodeCopyKeyword or YulExtCodeSizeKeyword or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulGasKeyword or YulGasLimitKeyword or YulGasPriceKeyword or YulGtKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulInvalidKeyword or YulIsZeroKeyword or YulJumpKeyword or YulJumpiKeyword or YulLetKeyword or YulLog0Keyword or YulLog1Keyword or YulLog2Keyword or YulLog3Keyword or YulLog4Keyword or YulLtKeyword or YulMLoadKeyword or YulMSizeKeyword or YulMStore8Keyword or YulMStoreKeyword or YulModKeyword or YulMulKeyword or YulMulModKeyword or YulNotKeyword or YulNumberKeyword or YulOrKeyword or YulOriginKeyword or YulPopKeyword or YulReturnKeyword or YulRevertKeyword or YulSDivKeyword or YulSLoadKeyword or YulSModKeyword or YulSStoreKeyword or YulSarKeyword or YulSelfBalanceKeyword or YulSelfDestructKeyword or YulSgtKeyword or YulSha3Keyword or YulShlKeyword or YulShrKeyword or YulSignExtendKeyword or YulSltKeyword or YulStopKeyword or YulSubKeyword or YulSuicideKeyword or YulSwitchKeyword or YulTimestampKeyword or YulTrueKeyword or YulXorKeyword. + ╭─[input.sol:4:18] + │ + 4 │ ╭─▶ let x.y.z := 0 + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ┬ + │ ╰── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.4.12-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.4.12-failure.txt new file mode 100644 index 0000000000..d64f0a606b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.4.12-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected CloseBrace or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or Equal or EqualColon or OpenBrace or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or YulAddKeyword or YulAddModKeyword or YulAddressKeyword or YulAndKeyword or YulBalanceKeyword or YulBlockHashKeyword or YulBreakKeyword or YulByteKeyword or YulCallCodeKeyword or YulCallDataCopyKeyword or YulCallDataLoadKeyword or YulCallDataSizeKeyword or YulCallKeyword or YulCallValueKeyword or YulCallerKeyword or YulChainIdKeyword or YulCoinBaseKeyword or YulContinueKeyword or YulCreate2Keyword or YulCreateKeyword or YulDecimalLiteral or YulDelegateCallKeyword or YulDifficultyKeyword or YulDivKeyword or YulEqKeyword or YulExpKeyword or YulExtCodeCopyKeyword or YulExtCodeSizeKeyword or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulGasKeyword or YulGasLimitKeyword or YulGasPriceKeyword or YulGtKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulInvalidKeyword or YulIsZeroKeyword or YulJumpKeyword or YulJumpiKeyword or YulKeccak256Keyword or YulLetKeyword or YulLog0Keyword or YulLog1Keyword or YulLog2Keyword or YulLog3Keyword or YulLog4Keyword or YulLtKeyword or YulMLoadKeyword or YulMSizeKeyword or YulMStore8Keyword or YulMStoreKeyword or YulModKeyword or YulMulKeyword or YulMulModKeyword or YulNotKeyword or YulNumberKeyword or YulOrKeyword or YulOriginKeyword or YulPopKeyword or YulReturnDataCopyKeyword or YulReturnDataSizeKeyword or YulReturnKeyword or YulRevertKeyword or YulSDivKeyword or YulSLoadKeyword or YulSModKeyword or YulSStoreKeyword or YulSarKeyword or YulSelfBalanceKeyword or YulSelfDestructKeyword or YulSgtKeyword or YulSha3Keyword or YulShlKeyword or YulShrKeyword or YulSignExtendKeyword or YulSltKeyword or YulStaticCallKeyword or YulStopKeyword or YulSubKeyword or YulSuicideKeyword or YulSwitchKeyword or YulTimestampKeyword or YulTrueKeyword or YulXorKeyword. + ╭─[input.sol:4:18] + │ + 4 │ ╭─▶ let x.y.z := 0 + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ┬ + │ ╰── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.5.0-failure.txt new file mode 100644 index 0000000000..a85be30fd2 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.5.0-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected CloseBrace or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or OpenBrace or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or YulAddKeyword or YulAddModKeyword or YulAddressKeyword or YulAndKeyword or YulBalanceKeyword or YulBlockHashKeyword or YulBreakKeyword or YulByteKeyword or YulCallCodeKeyword or YulCallDataCopyKeyword or YulCallDataLoadKeyword or YulCallDataSizeKeyword or YulCallKeyword or YulCallValueKeyword or YulCallerKeyword or YulChainIdKeyword or YulCoinBaseKeyword or YulContinueKeyword or YulCreate2Keyword or YulCreateKeyword or YulDecimalLiteral or YulDelegateCallKeyword or YulDifficultyKeyword or YulDivKeyword or YulEqKeyword or YulExpKeyword or YulExtCodeCopyKeyword or YulExtCodeHashKeyword or YulExtCodeSizeKeyword or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulGasKeyword or YulGasLimitKeyword or YulGasPriceKeyword or YulGtKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulInvalidKeyword or YulIsZeroKeyword or YulKeccak256Keyword or YulLetKeyword or YulLog0Keyword or YulLog1Keyword or YulLog2Keyword or YulLog3Keyword or YulLog4Keyword or YulLtKeyword or YulMLoadKeyword or YulMSizeKeyword or YulMStore8Keyword or YulMStoreKeyword or YulModKeyword or YulMulKeyword or YulMulModKeyword or YulNotKeyword or YulNumberKeyword or YulOrKeyword or YulOriginKeyword or YulPopKeyword or YulReturnDataCopyKeyword or YulReturnDataSizeKeyword or YulReturnKeyword or YulRevertKeyword or YulSDivKeyword or YulSLoadKeyword or YulSModKeyword or YulSStoreKeyword or YulSarKeyword or YulSelfBalanceKeyword or YulSelfDestructKeyword or YulSgtKeyword or YulShlKeyword or YulShrKeyword or YulSignExtendKeyword or YulSltKeyword or YulStaticCallKeyword or YulStopKeyword or YulSubKeyword or YulSwitchKeyword or YulTimestampKeyword or YulTrueKeyword or YulXorKeyword. + ╭─[input.sol:4:18] + │ + 4 │ ╭─▶ let x.y.z := 0 + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ┬ + │ ╰── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.5.8-success.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.5.8-success.txt new file mode 100644 index 0000000000..a50ffd562b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.5.8-success.txt @@ -0,0 +1,21 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ──┬── + │ ╰──── def: 3 + 5 │ let r := add(x.y.z, 20) + │ ┬ ──┬── + │ ╰─────────────── def: 4 + │ │ + │ ╰──── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..13ec567204 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.7.0-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected CloseBrace or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or OpenBrace or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or YulAddKeyword or YulAddModKeyword or YulAddressKeyword or YulAndKeyword or YulBalanceKeyword or YulBlockHashKeyword or YulBreakKeyword or YulByteKeyword or YulCallCodeKeyword or YulCallDataCopyKeyword or YulCallDataLoadKeyword or YulCallDataSizeKeyword or YulCallKeyword or YulCallValueKeyword or YulCallerKeyword or YulChainIdKeyword or YulCoinBaseKeyword or YulContinueKeyword or YulCreate2Keyword or YulCreateKeyword or YulDecimalLiteral or YulDelegateCallKeyword or YulDifficultyKeyword or YulDivKeyword or YulEqKeyword or YulExpKeyword or YulExtCodeCopyKeyword or YulExtCodeHashKeyword or YulExtCodeSizeKeyword or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulGasKeyword or YulGasLimitKeyword or YulGasPriceKeyword or YulGtKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulInvalidKeyword or YulIsZeroKeyword or YulKeccak256Keyword or YulLeaveKeyword or YulLetKeyword or YulLog0Keyword or YulLog1Keyword or YulLog2Keyword or YulLog3Keyword or YulLog4Keyword or YulLtKeyword or YulMLoadKeyword or YulMSizeKeyword or YulMStore8Keyword or YulMStoreKeyword or YulModKeyword or YulMulKeyword or YulMulModKeyword or YulNotKeyword or YulNumberKeyword or YulOrKeyword or YulOriginKeyword or YulPopKeyword or YulReturnDataCopyKeyword or YulReturnDataSizeKeyword or YulReturnKeyword or YulRevertKeyword or YulSDivKeyword or YulSLoadKeyword or YulSModKeyword or YulSStoreKeyword or YulSarKeyword or YulSelfBalanceKeyword or YulSelfDestructKeyword or YulSgtKeyword or YulShlKeyword or YulShrKeyword or YulSignExtendKeyword or YulSltKeyword or YulStaticCallKeyword or YulStopKeyword or YulSubKeyword or YulSwitchKeyword or YulTimestampKeyword or YulTrueKeyword or YulXorKeyword. + ╭─[input.sol:4:18] + │ + 4 │ ╭─▶ let x.y.z := 0 + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ┬ + │ ╰── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.18-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.18-failure.txt new file mode 100644 index 0000000000..ba89cdf44b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.18-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected CloseBrace or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or OpenBrace or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or YulAddKeyword or YulAddModKeyword or YulAddressKeyword or YulAndKeyword or YulBalanceKeyword or YulBaseFeeKeyword or YulBlockHashKeyword or YulBreakKeyword or YulByteKeyword or YulCallCodeKeyword or YulCallDataCopyKeyword or YulCallDataLoadKeyword or YulCallDataSizeKeyword or YulCallKeyword or YulCallValueKeyword or YulCallerKeyword or YulChainIdKeyword or YulCoinBaseKeyword or YulContinueKeyword or YulCreate2Keyword or YulCreateKeyword or YulDecimalLiteral or YulDelegateCallKeyword or YulDivKeyword or YulEqKeyword or YulExpKeyword or YulExtCodeCopyKeyword or YulExtCodeHashKeyword or YulExtCodeSizeKeyword or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulGasKeyword or YulGasLimitKeyword or YulGasPriceKeyword or YulGtKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulInvalidKeyword or YulIsZeroKeyword or YulKeccak256Keyword or YulLeaveKeyword or YulLetKeyword or YulLog0Keyword or YulLog1Keyword or YulLog2Keyword or YulLog3Keyword or YulLog4Keyword or YulLtKeyword or YulMLoadKeyword or YulMSizeKeyword or YulMStore8Keyword or YulMStoreKeyword or YulModKeyword or YulMulKeyword or YulMulModKeyword or YulNotKeyword or YulNumberKeyword or YulOrKeyword or YulOriginKeyword or YulPopKeyword or YulPrevRandaoKeyword or YulReturnDataCopyKeyword or YulReturnDataSizeKeyword or YulReturnKeyword or YulRevertKeyword or YulSDivKeyword or YulSLoadKeyword or YulSModKeyword or YulSStoreKeyword or YulSarKeyword or YulSelfBalanceKeyword or YulSelfDestructKeyword or YulSgtKeyword or YulShlKeyword or YulShrKeyword or YulSignExtendKeyword or YulSltKeyword or YulStaticCallKeyword or YulStopKeyword or YulSubKeyword or YulSwitchKeyword or YulTimestampKeyword or YulTrueKeyword or YulXorKeyword. + ╭─[input.sol:4:18] + │ + 4 │ ╭─▶ let x.y.z := 0 + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ┬ + │ ╰── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.24-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.24-failure.txt new file mode 100644 index 0000000000..1a4a9715b3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.24-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected CloseBrace or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or OpenBrace or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or YulAddKeyword or YulAddModKeyword or YulAddressKeyword or YulAndKeyword or YulBalanceKeyword or YulBaseFeeKeyword or YulBlobBaseFeeKeyword or YulBlobHashKeyword or YulBlockHashKeyword or YulBreakKeyword or YulByteKeyword or YulCallCodeKeyword or YulCallDataCopyKeyword or YulCallDataLoadKeyword or YulCallDataSizeKeyword or YulCallKeyword or YulCallValueKeyword or YulCallerKeyword or YulChainIdKeyword or YulCoinBaseKeyword or YulContinueKeyword or YulCreate2Keyword or YulCreateKeyword or YulDecimalLiteral or YulDelegateCallKeyword or YulDivKeyword or YulEqKeyword or YulExpKeyword or YulExtCodeCopyKeyword or YulExtCodeHashKeyword or YulExtCodeSizeKeyword or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulGasKeyword or YulGasLimitKeyword or YulGasPriceKeyword or YulGtKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulInvalidKeyword or YulIsZeroKeyword or YulKeccak256Keyword or YulLeaveKeyword or YulLetKeyword or YulLog0Keyword or YulLog1Keyword or YulLog2Keyword or YulLog3Keyword or YulLog4Keyword or YulLtKeyword or YulMCopyKeyword or YulMLoadKeyword or YulMSizeKeyword or YulMStore8Keyword or YulMStoreKeyword or YulModKeyword or YulMulKeyword or YulMulModKeyword or YulNotKeyword or YulNumberKeyword or YulOrKeyword or YulOriginKeyword or YulPopKeyword or YulPrevRandaoKeyword or YulReturnDataCopyKeyword or YulReturnDataSizeKeyword or YulReturnKeyword or YulRevertKeyword or YulSDivKeyword or YulSLoadKeyword or YulSModKeyword or YulSStoreKeyword or YulSarKeyword or YulSelfBalanceKeyword or YulSelfDestructKeyword or YulSgtKeyword or YulShlKeyword or YulShrKeyword or YulSignExtendKeyword or YulSltKeyword or YulStaticCallKeyword or YulStopKeyword or YulSubKeyword or YulSwitchKeyword or YulTLoadKeyword or YulTStoreKeyword or YulTimestampKeyword or YulTrueKeyword or YulXorKeyword. + ╭─[input.sol:4:18] + │ + 4 │ ╭─▶ let x.y.z := 0 + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ┬ + │ ╰── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.7-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.7-failure.txt new file mode 100644 index 0000000000..7572b37c42 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/generated/0.8.7-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected CloseBrace or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or OpenBrace or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or YulAddKeyword or YulAddModKeyword or YulAddressKeyword or YulAndKeyword or YulBalanceKeyword or YulBaseFeeKeyword or YulBlockHashKeyword or YulBreakKeyword or YulByteKeyword or YulCallCodeKeyword or YulCallDataCopyKeyword or YulCallDataLoadKeyword or YulCallDataSizeKeyword or YulCallKeyword or YulCallValueKeyword or YulCallerKeyword or YulChainIdKeyword or YulCoinBaseKeyword or YulContinueKeyword or YulCreate2Keyword or YulCreateKeyword or YulDecimalLiteral or YulDelegateCallKeyword or YulDifficultyKeyword or YulDivKeyword or YulEqKeyword or YulExpKeyword or YulExtCodeCopyKeyword or YulExtCodeHashKeyword or YulExtCodeSizeKeyword or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulGasKeyword or YulGasLimitKeyword or YulGasPriceKeyword or YulGtKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulInvalidKeyword or YulIsZeroKeyword or YulKeccak256Keyword or YulLeaveKeyword or YulLetKeyword or YulLog0Keyword or YulLog1Keyword or YulLog2Keyword or YulLog3Keyword or YulLog4Keyword or YulLtKeyword or YulMLoadKeyword or YulMSizeKeyword or YulMStore8Keyword or YulMStoreKeyword or YulModKeyword or YulMulKeyword or YulMulModKeyword or YulNotKeyword or YulNumberKeyword or YulOrKeyword or YulOriginKeyword or YulPopKeyword or YulReturnDataCopyKeyword or YulReturnDataSizeKeyword or YulReturnKeyword or YulRevertKeyword or YulSDivKeyword or YulSLoadKeyword or YulSModKeyword or YulSStoreKeyword or YulSarKeyword or YulSelfBalanceKeyword or YulSelfDestructKeyword or YulSgtKeyword or YulShlKeyword or YulShrKeyword or YulSignExtendKeyword or YulSltKeyword or YulStaticCallKeyword or YulStopKeyword or YulSubKeyword or YulSwitchKeyword or YulTimestampKeyword or YulTrueKeyword or YulXorKeyword. + ╭─[input.sol:4:18] + │ + 4 │ ╭─▶ let x.y.z := 0 + ┆ ┆ + 6 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let x.y.z := 0 + │ ┬ + │ ╰── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/input.sol b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/input.sol new file mode 100644 index 0000000000..84beae31ee --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/identifiers_with_dots/input.sol @@ -0,0 +1,8 @@ +contract Test { + function test() public { + assembly { + let x.y.z := 0 + let r := add(x.y.z, 20) + } + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.4.11-success.txt new file mode 100644 index 0000000000..6e244c0dcf --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.4.11-success.txt @@ -0,0 +1,30 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ bytes data; + │ ──┬─ + │ ╰─── def: 2 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 5 │ let s := sload(data.slot) + │ ┬ ──┬─ ──┬─ + │ ╰───────────────────── def: 4 + │ │ │ + │ ╰──────── ref: 2 + │ │ + │ ╰─── ref: built-in + 6 │ let o := sload(data.offset) + │ ┬ ──┬─ ───┬── + │ ╰─────────────────────── def: 5 + │ │ │ + │ ╰────────── ref: 2 + │ │ + │ ╰──── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.5.8-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.5.8-failure.txt new file mode 100644 index 0000000000..6ec15facf8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.5.8-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ bytes data; + │ ──┬─ + │ ╰─── def: 2 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 5 │ let s := sload(data.slot) + │ ┬ ────┬──── + │ ╰───────────────────── def: 4 + │ │ + │ ╰────── unresolved + 6 │ let o := sload(data.offset) + │ ┬ ─────┬───── + │ ╰─────────────────────── def: 5 + │ │ + │ ╰─────── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.7.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.7.0-success.txt new file mode 100644 index 0000000000..6e244c0dcf --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/generated/0.7.0-success.txt @@ -0,0 +1,30 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ bytes data; + │ ──┬─ + │ ╰─── def: 2 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 5 │ let s := sload(data.slot) + │ ┬ ──┬─ ──┬─ + │ ╰───────────────────── def: 4 + │ │ │ + │ ╰──────── ref: 2 + │ │ + │ ╰─── ref: built-in + 6 │ let o := sload(data.offset) + │ ┬ ──┬─ ───┬── + │ ╰─────────────────────── def: 5 + │ │ │ + │ ╰────────── ref: 2 + │ │ + │ ╰──── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/input.sol b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/input.sol new file mode 100644 index 0000000000..e35896c309 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_offset_members/input.sol @@ -0,0 +1,9 @@ +contract Test { + bytes data; + function test() public { + assembly { + let s := sload(data.slot) + let o := sload(data.offset) + } + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.4.11-success.txt new file mode 100644 index 0000000000..bb7557764a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.4.11-success.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ bytes data; + │ ──┬─ + │ ╰─── def: 2 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 5 │ let s := sload(data_slot) + │ ┬ ────┬──── + │ ╰───────────────────── def: 4 + │ │ + │ ╰────── ref: built-in + 6 │ let o := sload(data_offset) + │ ┬ ─────┬───── + │ ╰─────────────────────── def: 5 + │ │ + │ ╰─────── ref: built-in +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..8745d145dd --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.7.0-failure.txt @@ -0,0 +1,26 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ bytes data; + │ ──┬─ + │ ╰─── def: 2 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 + │ + 5 │ let s := sload(data_slot) + │ ┬ ────┬──── + │ ╰───────────────────── def: 4 + │ │ + │ ╰────── unresolved + 6 │ let o := sload(data_offset) + │ ┬ ─────┬───── + │ ╰─────────────────────── def: 5 + │ │ + │ ╰─────── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/input.sol b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/input.sol new file mode 100644 index 0000000000..67caad33a2 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/input.sol @@ -0,0 +1,9 @@ +contract Test { + bytes data; + function test() public { + assembly { + let s := sload(data_slot) + let o := sload(data_offset) + } + } +}