From aa18f1437932889cc47d3bcbff448b418274168e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 24 Oct 2024 17:23:53 -0400 Subject: [PATCH 01/66] Add test case which broke with query engine not skipping trivia in one-or-more operator --- .../bindings_output/generated/contracts.rs | 5 +++ .../generated/0.4.11-success.txt | 38 +++++++++++++++++++ .../contracts/multi_inheritance/input.sol | 16 ++++++++ 3 files changed, 59 insertions(+) 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 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..dddc237add 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 @@ -29,6 +29,11 @@ fn inheritance() -> Result<()> { run("contracts", "inheritance") } +#[test] +fn multi_inheritance() -> Result<()> { + run("contracts", "multi_inheritance") +} + #[test] fn public_getters() -> Result<()> { run("contracts", "public_getters") 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(); + } +} From 42bfde6b9ae44791ed7a74da1cd9cd780aa1320f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Fri, 25 Oct 2024 16:59:00 -0400 Subject: [PATCH 02/66] Make using directives inherited in Solidity < 0.7.0 --- .../solidity/inputs/language/bindings/rules.msgb | 10 +++++++++- .../bindings/generated/binding_rules.rs | 10 +++++++++- .../src/bindings_assertions/generated/mod.rs | 1 + .../src/bindings_assertions/generated/using.rs | 10 ++++++++++ .../bindings_assertions/using/inherited.sol | 16 ++++++++++++++++ 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/using.rs create mode 100644 crates/solidity/testing/snapshots/bindings_assertions/using/inherited.sol diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 42a3bd16e9..62dfaa2394 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -433,7 +433,15 @@ inherit .lexical_scope @contract [ContractDefinition [ContractMembers [ContractMember @using [UsingDirective]] ]] { - edge @contract.lexical_scope -> @using.def + if (version-matches "< 0.7.0") { + ; In Solidity < 0.7.0 using directives are inherited to derived contracts + ; Hence we make @using.def accessible through members, which is accessible + ; from derived contract's lexical scopes. + edge @contract.members -> @using.def + } else { + ; For Solidity >= 0.7.0, using directives are restricted to this contract only. + edge @contract.lexical_scope -> @using.def + } } @contract [ContractDefinition [ContractMembers 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 e60d727395..038ba24637 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 @@ -438,7 +438,15 @@ inherit .lexical_scope @contract [ContractDefinition [ContractMembers [ContractMember @using [UsingDirective]] ]] { - edge @contract.lexical_scope -> @using.def + if (version-matches "< 0.7.0") { + ; In Solidity < 0.7.0 using directives are inherited to derived contracts + ; Hence we make @using.def accessible through members, which is accessible + ; from derived contract's lexical scopes. + edge @contract.members -> @using.def + } else { + ; For Solidity >= 0.7.0, using directives are restricted to this contract only. + edge @contract.lexical_scope -> @using.def + } } @contract [ContractDefinition [ContractMembers 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/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) + } +} From 634b33bdfc68351c26fe36949f824b8ba068839c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Fri, 25 Oct 2024 17:39:10 -0400 Subject: [PATCH 03/66] Resolve elementary types in expressions and add their built-ins - `string` and `bytes` are exported as built-in variables resolving to types that provide a `concat` function - `address` can be used as a function to cast a parameter to `address` to eg. retrieve the balance --- .../inputs/language/bindings/rules.msgb | 6 + .../inputs/language/src/definition.rs | 14 ++- .../bindings/generated/binding_rules.rs | 6 + .../bindings/generated/built_ins/0.4.11.sol | 8 +- .../bindings/generated/built_ins/0.4.17.sol | 8 +- .../bindings/generated/built_ins/0.4.22.sol | 8 +- .../bindings/generated/built_ins/0.5.0.sol | 8 +- .../bindings/generated/built_ins/0.5.3.sol | 8 +- .../bindings/generated/built_ins/0.6.0.sol | 8 +- .../bindings/generated/built_ins/0.6.2.sol | 8 +- .../bindings/generated/built_ins/0.6.7.sol | 8 +- .../bindings/generated/built_ins/0.6.8.sol | 8 +- .../bindings/generated/built_ins/0.7.0.sol | 8 +- .../bindings/generated/built_ins/0.8.0.sol | 8 +- .../bindings/generated/built_ins/0.8.11.sol | 8 +- .../bindings/generated/built_ins/0.8.18.sol | 8 +- .../bindings/generated/built_ins/0.8.2.sol | 8 +- .../bindings/generated/built_ins/0.8.24.sol | 8 +- .../bindings/generated/built_ins/0.8.26.sol | 8 +- .../bindings/generated/built_ins/0.8.7.sol | 8 +- .../bindings_output/generated/built_ins.rs | 5 + .../address/generated/0.4.11-failure.txt | 7 ++ .../address/generated/0.5.0-success.txt | 7 ++ .../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 +++ 29 files changed, 305 insertions(+), 174 deletions(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 62dfaa2394..5bab64a96f 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -1936,6 +1936,12 @@ 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 +} + ;; Index access expressions @expr [Expression [IndexAccessExpression @operand operand: [Expression] diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 15a61a65da..cb897ed5bd 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -6626,6 +6626,11 @@ codegen_language_macros::compile!(Language( ) ], built_ins = [ + BuiltInFunction( + name = "$address", + parameters = [], + return_type = "$address" + ), BuiltInFunction( name = "addmod", parameters = ["uint x", "uint y", "uint k"], @@ -6886,6 +6891,11 @@ codegen_language_macros::compile!(Language( ), BuiltInType( name = "$bytes", + fields = [BuiltInField(definition = "uint length")], + functions = [] + ), + BuiltInType( + name = "$bytesType", fields = [], functions = [BuiltInFunction( name = "concat", @@ -6940,7 +6950,7 @@ codegen_language_macros::compile!(Language( functions = [] ), BuiltInType( - name = "$string", + name = "$stringType", fields = [], functions = [BuiltInFunction( name = "concat", @@ -6989,8 +6999,10 @@ codegen_language_macros::compile!(Language( BuiltInVariable(definition = "$function $placeholder"), BuiltInVariable(definition = "$abiType abi"), BuiltInVariable(definition = "$blockType block"), + BuiltInVariable(definition = "$bytesType $bytes"), BuiltInVariable(definition = "$msgType msg"), BuiltInVariable(definition = "uint now", enabled = Till("0.7.0")), + BuiltInVariable(definition = "$stringType $string"), BuiltInVariable(definition = "$txType 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 038ba24637..82bdc841c2 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 @@ -1941,6 +1941,12 @@ 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 +} + ;; Index access expressions @expr [Expression [IndexAccessExpression @operand operand: [Expression] 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..1669e20977 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public returns (address); @@ -47,6 +48,9 @@ contract $BuiltIns$ { function(uint) returns (bytes32) blockhash; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $functionExternal { @@ -60,7 +64,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -78,7 +82,9 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; uint now; + $stringType $string; $txType 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..9d42a87661 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public returns (address); @@ -47,6 +48,9 @@ contract $BuiltIns$ { function(uint) returns (bytes32) blockhash; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $functionExternal { @@ -61,7 +65,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -79,7 +83,9 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; uint now; + $stringType $string; $txType 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..c8677bd30f 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); @@ -55,6 +56,9 @@ contract $BuiltIns$ { function(uint) returns (bytes32) blockhash; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $functionExternal { @@ -69,7 +73,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -87,7 +91,9 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; uint now; + $stringType $string; $txType 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..3b12a421be 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); @@ -53,6 +54,9 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $functionExternal { @@ -66,7 +70,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -84,7 +88,9 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; uint now; + $stringType $string; $txType 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..6e8b5fe54f 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); @@ -53,6 +54,9 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $functionExternal { @@ -66,7 +70,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -86,7 +90,9 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; uint now; + $stringType $string; $txType 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..f3ac4be00c 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); @@ -54,6 +55,9 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $functionExternal { @@ -67,7 +71,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -87,7 +91,9 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; uint now; + $stringType $string; $txType 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..7bb7a4b4e1 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); @@ -54,6 +55,9 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $callOptions { @@ -72,7 +76,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -92,7 +96,9 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; uint now; + $stringType $string; $txType 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..847fceb0fa 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); @@ -54,6 +55,9 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $callOptions { @@ -72,7 +76,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -94,7 +98,9 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; uint now; + $stringType $string; $txType 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..67980f2dcd 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); @@ -54,6 +55,9 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $callOptions { @@ -72,7 +76,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -96,7 +100,9 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; uint now; + $stringType $string; $txType 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..9f61e88a34 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); @@ -54,6 +55,9 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $callOptions { @@ -70,7 +74,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -94,6 +98,8 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; + $stringType $string; $txType 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..8123ade46e 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); @@ -52,6 +53,9 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $callOptions { @@ -68,7 +72,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -92,6 +96,8 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; + $stringType $string; $txType 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..3f2f29612c 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); @@ -54,6 +55,9 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $callOptions { @@ -71,7 +75,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -95,6 +99,8 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; + $stringType $string; $txType 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..d2488f4b87 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); @@ -55,6 +56,9 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $callOptions { @@ -72,7 +76,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -96,6 +100,8 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; + $stringType $string; $txType 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..1264cca5e4 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); @@ -52,6 +53,9 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $callOptions { @@ -69,7 +73,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -93,6 +97,8 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; + $stringType $string; $txType 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..fe1eabdafc 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); @@ -57,6 +58,9 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $callOptions { @@ -74,7 +78,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -98,6 +102,8 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; + $stringType $string; $txType 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..fafb22d6a5 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); @@ -58,6 +59,9 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $callOptions { @@ -75,7 +79,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -99,6 +103,8 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; + $stringType $string; $txType 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..162a55d7cd 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 @@ -1,6 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { + function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); @@ -53,6 +54,9 @@ contract $BuiltIns$ { uint timestamp; } struct $bytes { + uint length; + } + struct $bytesType { function($args) returns (bytes memory) concat; } struct $callOptions { @@ -70,7 +74,7 @@ contract $BuiltIns$ { bytes4 sig; uint value; } - struct $string { + struct $stringType { function($args) returns (string memory) concat; } struct $txType { @@ -94,6 +98,8 @@ contract $BuiltIns$ { $function $placeholder; $abiType abi; $blockType block; + $bytesType $bytes; $msgType msg; + $stringType $string; $txType tx; } 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..d6ea76b7a1 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") 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..62b96090e3 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,11 @@ References and definitions: │ ╰─────────── ref: 3 │ │ │ ╰─── ref: built-in + 9 │ uint256 v10 = address(this).balance; + │ ─┬─ ──┬─ ───┬─── + │ ╰─────────────────────────── def: 12 + │ │ │ + │ ╰──────────── ref: 1 + │ │ + │ ╰───── 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..03aab82e21 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,11 @@ References and definitions: │ ╰─────────── ref: 3 │ │ │ ╰─── ref: built-in + 9 │ uint256 v10 = address(this).balance; + │ ─┬─ ──┬─ ───┬─── + │ ╰─────────────────────────── def: 12 + │ │ │ + │ ╰──────────── ref: 1 + │ │ + │ ╰───── 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); + } +} From 458855c55a735fcda5c22c230e1a233e58d8ed72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Fri, 25 Oct 2024 18:12:28 -0400 Subject: [PATCH 04/66] Bind constants as library members --- .../inputs/language/bindings/rules.msgb | 1 + .../bindings/generated/binding_rules.rs | 1 + .../bindings_output/generated/libraries.rs | 5 +++ .../constants/generated/0.4.11-success.txt | 34 +++++++++++++++++++ .../libraries/constants/input.sol | 14 ++++++++ 5 files changed, 55 insertions(+) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 5bab64a96f..d72519c3c2 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -640,6 +640,7 @@ inherit .lexical_scope | [StructDefinition] | [EventDefinition] | [ErrorDefinition] + | [StateVariableDefinition [StateVariableAttributes [StateVariableAttribute [ConstantKeyword]]]] | [UserDefinedValueTypeDefinition] )] ]] { 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 82bdc841c2..ba0bf96f00 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 @@ -645,6 +645,7 @@ inherit .lexical_scope | [StructDefinition] | [EventDefinition] | [ErrorDefinition] + | [StateVariableDefinition [StateVariableAttributes [StateVariableAttribute [ConstantKeyword]]]] | [UserDefinedValueTypeDefinition] )] ]] { 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..0d4a86c663 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,11 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn constants() -> Result<()> { + run("libraries", "constants") +} + #[test] fn visibility() -> Result<()> { run("libraries", "visibility") 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; + } +} From bcd0d1fd777d5b24f97eb20b980103d653972fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 28 Oct 2024 15:05:26 -0400 Subject: [PATCH 05/66] Propagate dynamic scopes when escaping a contract's lexical scope This makes resolving to attached functions on types even when the reference of those types happen in a different lexical scope. --- .../inputs/language/bindings/rules.msgb | 59 +++++++++----- .../bindings/generated/binding_rules.rs | 59 +++++++++----- .../src/bindings_output/generated/using.rs | 5 ++ .../generated/0.4.11-success.txt | 78 +++++++++++++++++++ .../using/chained_calls/input.sol | 17 ++++ 5 files changed, 180 insertions(+), 38 deletions(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index d72519c3c2..7b40caf0c3 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -62,13 +62,16 @@ 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 + + ; We may jump to scope here to resolve using the dynamic scope provided by + ; extensions declared with `using` directive + edge @source_unit.lexical_scope -> JUMP_TO_SCOPE_NODE } -;; Top-level definitions... +;; Top-level definitions (except contract handled below)... @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @unit_member ( - [ContractDefinition] - | [InterfaceDefinition] + [InterfaceDefinition] | [LibraryDefinition] | [StructDefinition] | [EnumDefinition] @@ -84,6 +87,28 @@ inherit .lexical_scope edge @source_unit.defs -> @unit_member.def } +@source_unit [SourceUnit [SourceUnitMembers + [SourceUnitMember @contract [ContractDefinition]] +]] { + edge @source_unit.lexical_scope -> @contract.def + edge @source_unit.defs -> @contract.def + + ; When "leaving" the contract lexical scope, ensure that the dynamic scope + ; (ie. `using` directives extensions) is propagated + node @contract.dynamic + attr (@contract.dynamic) is_exported + + node push + attr (push) push_scoped_symbol = "@dynamic", scope = @contract.dynamic + node pop + attr (pop) pop_scoped_symbol = "@dynamic" + + edge @contract.lexical_scope -> push + edge push -> pop + edge pop -> @source_unit.lexical_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 @@ -314,6 +339,13 @@ inherit .lexical_scope edge modifier -> @contract.modifiers let @contract.enclosing_def = @contract.def + + if (version-matches "< 0.7.0") { + ; In Solidity < 0.7.0 using directives are inherited to derived contracts. + ; Hence we make out dynamic scope accessible through members, which is accessible + ; from derived contract's lexical scopes. + edge @contract.members -> @contract.dynamic + } } @contract [ContractDefinition @name name: [Identifier]] { @@ -433,15 +465,8 @@ inherit .lexical_scope @contract [ContractDefinition [ContractMembers [ContractMember @using [UsingDirective]] ]] { - if (version-matches "< 0.7.0") { - ; In Solidity < 0.7.0 using directives are inherited to derived contracts - ; Hence we make @using.def accessible through members, which is accessible - ; from derived contract's lexical scopes. - edge @contract.members -> @using.def - } else { - ; For Solidity >= 0.7.0, using directives are restricted to this contract only. - edge @contract.lexical_scope -> @using.def - } + ; Expose the using directive from the dynamic scope + edge @contract.dynamic -> @using.def } @contract [ContractDefinition [ContractMembers @@ -1711,15 +1736,10 @@ inherit .lexical_scope ; 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 + ; 1. the normal, non parametric path ; 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 = "<>" @@ -1729,7 +1749,8 @@ inherit .lexical_scope node def attr (def) node_definition = @name attr (def) definiens_node = @struct - edge struct_drop -> def + + edge @struct.def -> def edge typed_params -> def ; On the other end, to properly close the second path we need to jump to the popped scope 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 ba0bf96f00..e63b712d12 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 @@ -67,13 +67,16 @@ 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 + + ; We may jump to scope here to resolve using the dynamic scope provided by + ; extensions declared with `using` directive + edge @source_unit.lexical_scope -> JUMP_TO_SCOPE_NODE } -;; Top-level definitions... +;; Top-level definitions (except contract handled below)... @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @unit_member ( - [ContractDefinition] - | [InterfaceDefinition] + [InterfaceDefinition] | [LibraryDefinition] | [StructDefinition] | [EnumDefinition] @@ -89,6 +92,28 @@ inherit .lexical_scope edge @source_unit.defs -> @unit_member.def } +@source_unit [SourceUnit [SourceUnitMembers + [SourceUnitMember @contract [ContractDefinition]] +]] { + edge @source_unit.lexical_scope -> @contract.def + edge @source_unit.defs -> @contract.def + + ; When "leaving" the contract lexical scope, ensure that the dynamic scope + ; (ie. `using` directives extensions) is propagated + node @contract.dynamic + attr (@contract.dynamic) is_exported + + node push + attr (push) push_scoped_symbol = "@dynamic", scope = @contract.dynamic + node pop + attr (pop) pop_scoped_symbol = "@dynamic" + + edge @contract.lexical_scope -> push + edge push -> pop + edge pop -> @source_unit.lexical_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 @@ -319,6 +344,13 @@ inherit .lexical_scope edge modifier -> @contract.modifiers let @contract.enclosing_def = @contract.def + + if (version-matches "< 0.7.0") { + ; In Solidity < 0.7.0 using directives are inherited to derived contracts. + ; Hence we make out dynamic scope accessible through members, which is accessible + ; from derived contract's lexical scopes. + edge @contract.members -> @contract.dynamic + } } @contract [ContractDefinition @name name: [Identifier]] { @@ -438,15 +470,8 @@ inherit .lexical_scope @contract [ContractDefinition [ContractMembers [ContractMember @using [UsingDirective]] ]] { - if (version-matches "< 0.7.0") { - ; In Solidity < 0.7.0 using directives are inherited to derived contracts - ; Hence we make @using.def accessible through members, which is accessible - ; from derived contract's lexical scopes. - edge @contract.members -> @using.def - } else { - ; For Solidity >= 0.7.0, using directives are restricted to this contract only. - edge @contract.lexical_scope -> @using.def - } + ; Expose the using directive from the dynamic scope + edge @contract.dynamic -> @using.def } @contract [ContractDefinition [ContractMembers @@ -1716,15 +1741,10 @@ inherit .lexical_scope ; 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 + ; 1. the normal, non parametric path ; 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 = "<>" @@ -1734,7 +1754,8 @@ inherit .lexical_scope node def attr (def) node_definition = @name attr (def) definiens_node = @struct - edge struct_drop -> def + + edge @struct.def -> def edge typed_params -> def ; On the other end, to properly close the second path we need to jump to the popped scope 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..159e396ab8 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,11 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn chained_calls() -> Result<()> { + run("using", "chained_calls") +} + #[test] fn deconstruction() -> Result<()> { run("using", "deconstruction") 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(); + } +} From 915fbd8aa728b08c2d822847ed16f219a9c351b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 28 Oct 2024 16:27:41 -0400 Subject: [PATCH 06/66] Bind elementary casting and struct construction to the resulting type --- .../inputs/language/bindings/rules.msgb | 27 ++++++++++++ .../inputs/language/src/definition.rs | 5 --- .../bindings/generated/binding_rules.rs | 27 ++++++++++++ .../bindings/generated/built_ins/0.4.11.sol | 1 - .../bindings/generated/built_ins/0.4.17.sol | 1 - .../bindings/generated/built_ins/0.4.22.sol | 1 - .../bindings/generated/built_ins/0.5.0.sol | 1 - .../bindings/generated/built_ins/0.5.3.sol | 1 - .../bindings/generated/built_ins/0.6.0.sol | 1 - .../bindings/generated/built_ins/0.6.2.sol | 1 - .../bindings/generated/built_ins/0.6.7.sol | 1 - .../bindings/generated/built_ins/0.6.8.sol | 1 - .../bindings/generated/built_ins/0.7.0.sol | 1 - .../bindings/generated/built_ins/0.8.0.sol | 1 - .../bindings/generated/built_ins/0.8.11.sol | 1 - .../bindings/generated/built_ins/0.8.18.sol | 1 - .../bindings/generated/built_ins/0.8.2.sol | 1 - .../bindings/generated/built_ins/0.8.24.sol | 1 - .../bindings/generated/built_ins/0.8.26.sol | 1 - .../bindings/generated/built_ins/0.8.7.sol | 1 - .../bindings_output/generated/expressions.rs | 5 +++ .../src/bindings_output/generated/structs.rs | 5 +++ .../generated/0.4.11-failure.txt | 42 +++++++++++++++++++ .../generated/0.4.21-failure.txt | 42 +++++++++++++++++++ .../generated/0.5.0-failure.txt | 42 +++++++++++++++++++ .../generated/0.5.3-failure.txt | 42 +++++++++++++++++++ .../generated/0.6.0-success.txt | 40 ++++++++++++++++++ .../expressions/elementary_casting/input.sol | 13 ++++++ .../generated/0.4.11-success.txt | 31 ++++++++++++++ .../structs/function_call/input.sol | 9 ++++ 30 files changed, 325 insertions(+), 22 deletions(-) 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/structs/function_call/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/structs/function_call/input.sol diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 7b40caf0c3..8a69818d3e 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -1771,6 +1771,12 @@ inherit .lexical_scope attr (param_names) pop_symbol = "@param_names" edge def -> param_names edge param_names -> @struct.members + + ; Used as a function call, should bind to itself + node call + attr (call) pop_symbol = "()" + edge def -> call + edge call -> member } @struct [StructDefinition [StructMembers @@ -1962,6 +1968,16 @@ inherit .lexical_scope @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 @@ -2081,6 +2097,17 @@ 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 +} + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Yul diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index cb897ed5bd..20dbf11d6e 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -6626,11 +6626,6 @@ codegen_language_macros::compile!(Language( ) ], built_ins = [ - BuiltInFunction( - name = "$address", - parameters = [], - return_type = "$address" - ), BuiltInFunction( name = "addmod", parameters = ["uint x", "uint y", "uint k"], 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 e63b712d12..bc896ba0c5 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 @@ -1776,6 +1776,12 @@ inherit .lexical_scope attr (param_names) pop_symbol = "@param_names" edge def -> param_names edge param_names -> @struct.members + + ; Used as a function call, should bind to itself + node call + attr (call) pop_symbol = "()" + edge def -> call + edge call -> member } @struct [StructDefinition [StructMembers @@ -1967,6 +1973,16 @@ inherit .lexical_scope @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 @@ -2086,6 +2102,17 @@ 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 +} + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Yul 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 1669e20977..81dbee099a 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public returns (address); 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 9d42a87661..898c64b554 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public returns (address); 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 c8677bd30f..a10f43f9b5 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); 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 3b12a421be..d41f1095ca 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); 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 6e8b5fe54f..262b93ae9f 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); 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 f3ac4be00c..9c965fc50f 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); 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 7bb7a4b4e1..5fee7a66c8 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); 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 847fceb0fa..18adb3237f 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); 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 67980f2dcd..7d8991cdfb 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); 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 9f61e88a34..a69834dc2b 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); 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 8123ade46e..2f2a6e3b37 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); 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 3f2f29612c..f17cd6d7fb 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); 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 d2488f4b87..d88b1009ce 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); 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 1264cca5e4..b0baecea97 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); 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 fe1eabdafc..3999e03748 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); 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 fafb22d6a5..4a5e8dfe13 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); 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 162a55d7cd..3ae9be4fb1 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 @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. contract $BuiltIns$ { - function $address() public returns ($address); function addmod(uint x, uint y, uint k) public returns (uint); function assert(bool condition) public; function blockhash(uint blockNumber) public returns (bytes32); 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..8d39cbc38c 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 @@ -9,6 +9,11 @@ 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") 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/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..d7b49cdaba --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.11-failure.txt @@ -0,0 +1,42 @@ +# 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 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 + │ │ + │ ╰───── 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..dfac6e4c83 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.4.21-failure.txt @@ -0,0 +1,42 @@ +# 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 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 + │ │ + │ ╰───── 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..0faa69fb8b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.0-failure.txt @@ -0,0 +1,42 @@ +# 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 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 + │ │ + │ ╰───── 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..e4d8db97f5 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.5.3-failure.txt @@ -0,0 +1,42 @@ +# 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 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 + │ │ + │ ╰───── 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..7f99301fc9 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/elementary_casting/generated/0.6.0-success.txt @@ -0,0 +1,40 @@ +# 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 + │ │ + │ ╰───── 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/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; + } +} From f2ab05535a1ebf8b67d70734fcbb7c7c4251b512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 28 Oct 2024 16:52:28 -0400 Subject: [PATCH 07/66] Fix calling parent constructors in constructors --- .../inputs/language/bindings/rules.msgb | 5 ++++ .../bindings/generated/binding_rules.rs | 5 ++++ .../bindings_output/generated/contracts.rs | 5 ++++ .../generated/0.4.11-failure.txt | 27 +++++++++++++++++++ .../generated/0.4.22-success.txt | 18 +++++++++++++ .../constructor_call_parent/input.sol | 6 +++++ 6 files changed, 66 insertions(+) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 8a69818d3e..52854457f5 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -1175,6 +1175,10 @@ 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]] { @@ -1212,6 +1216,7 @@ inherit .lexical_scope @modifier [ModifierInvocation] ]]] { edge @modifier.lexical_scope -> @constructor.lexical_scope + edge @modifier.identifier -> @constructor.lexical_scope } @contract [ContractDefinition [ContractMembers [ContractMember 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 bc896ba0c5..f2d356f86b 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 @@ -1180,6 +1180,10 @@ 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]] { @@ -1217,6 +1221,7 @@ inherit .lexical_scope @modifier [ModifierInvocation] ]]] { edge @modifier.lexical_scope -> @constructor.lexical_scope + edge @modifier.identifier -> @constructor.lexical_scope } @contract [ContractDefinition [ContractMembers [ContractMember 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 dddc237add..7199f538e1 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") 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() { + } +} From 13cf7e5a99dd0b9e786eb5200689ea9747e5671d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 29 Oct 2024 11:57:55 -0400 Subject: [PATCH 08/66] Bind arithmetic, logical, bit-wise, comparison, etc. expressions --- .../inputs/language/bindings/rules.msgb | 104 ++++++++++++++++++ .../bindings/generated/binding_rules.rs | 104 ++++++++++++++++++ .../bindings_output/generated/expressions.rs | 5 + .../generated/0.4.11-success.txt | 100 +++++++++++++++++ .../expressions/binary_operators/input.sol | 21 ++++ 5 files changed, 334 insertions(+) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 52854457f5..09ef3f996d 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -2113,6 +2113,110 @@ inherit .lexical_scope } +;;; 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, shift expressions, exponentiation +@expr [Expression [_ + @left_operand left_operand: [Expression] + ( + [Equal] + | [BarEqual] + | [PlusEqual] + | [MinusEqual] + | [CaretEqual] + | [SlashEqual] + | [PercentEqual] + | [AsteriskEqual] + | [AmpersandEqual] + | [LessThanLessThanEqual] + | [GreaterThanGreaterThanEqual] + | [GreaterThanGreaterThanGreaterThanEqual] + + | [LessThanLessThan] + | [GreaterThanGreaterThan] + | [GreaterThanGreaterThanGreaterThan] + + | [AsteriskAsterisk] + ) +]] { + 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] + + | [Bar] + | [Caret] + | [Ampersand] + ) + @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 +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Yul 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 f2d356f86b..a2e7c7ea16 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 @@ -2118,6 +2118,110 @@ inherit .lexical_scope } +;;; 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, shift expressions, exponentiation +@expr [Expression [_ + @left_operand left_operand: [Expression] + ( + [Equal] + | [BarEqual] + | [PlusEqual] + | [MinusEqual] + | [CaretEqual] + | [SlashEqual] + | [PercentEqual] + | [AsteriskEqual] + | [AmpersandEqual] + | [LessThanLessThanEqual] + | [GreaterThanGreaterThanEqual] + | [GreaterThanGreaterThanGreaterThanEqual] + + | [LessThanLessThan] + | [GreaterThanGreaterThan] + | [GreaterThanGreaterThanGreaterThan] + + | [AsteriskAsterisk] + ) +]] { + 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] + + | [Bar] + | [Caret] + | [Ampersand] + ) + @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 +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Yul 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 8d39cbc38c..87b921eb29 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,6 +4,11 @@ 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") 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(); + } +} From 5d8c379e9c8e9ceeb734f12cf3791adad259408a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 29 Oct 2024 13:25:53 -0400 Subject: [PATCH 09/66] Propagate the dynamic scope with resolving contract bases --- crates/metaslang/bindings/src/resolver/mod.rs | 19 +++++-- .../inputs/language/bindings/rules.msgb | 4 ++ .../bindings/generated/binding_rules.rs | 4 ++ .../bindings_output/generated/interfaces.rs | 5 ++ .../generated/0.4.11-success.txt | 52 +++++++++++++++++++ .../inherit_dynamic_scope/input.sol | 15 ++++++ 6 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 crates/solidity/testing/snapshots/bindings_output/interfaces/inherit_dynamic_scope/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/interfaces/inherit_dynamic_scope/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 09ef3f996d..6fdfb544c6 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -106,6 +106,10 @@ inherit .lexical_scope edge @contract.lexical_scope -> push edge push -> pop edge pop -> @source_unit.lexical_scope + + ; The .parent_scope for contracts also needs to propagate the dynamic scope + ; otherwise when resolving for contract bases we lose it. + let @contract.parent_scope = push } 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 a2e7c7ea16..844650ed5d 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 @@ -111,6 +111,10 @@ inherit .lexical_scope edge @contract.lexical_scope -> push edge push -> pop edge pop -> @source_unit.lexical_scope + + ; The .parent_scope for contracts also needs to propagate the dynamic scope + ; otherwise when resolving for contract bases we lose it. + let @contract.parent_scope = push } 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..b6df971292 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 @@ -4,6 +4,11 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn inherit_dynamic_scope() -> Result<()> { + run("interfaces", "inherit_dynamic_scope") +} + #[test] fn inheritance() -> Result<()> { run("interfaces", "inheritance") diff --git a/crates/solidity/testing/snapshots/bindings_output/interfaces/inherit_dynamic_scope/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/interfaces/inherit_dynamic_scope/generated/0.4.11-success.txt new file mode 100644 index 0000000000..e4adbece8d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/interfaces/inherit_dynamic_scope/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/interfaces/inherit_dynamic_scope/input.sol b/crates/solidity/testing/snapshots/bindings_output/interfaces/inherit_dynamic_scope/input.sol new file mode 100644 index 0000000000..d136d3833a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/interfaces/inherit_dynamic_scope/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(); + } +} From ddac8492f21bd4ae35bc77865c280bbc57f45e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 29 Oct 2024 14:49:11 -0400 Subject: [PATCH 10/66] Define a new scope for internal state variables for derived contracts --- .../inputs/language/bindings/rules.msgb | 19 ++++++++++++ .../bindings/generated/binding_rules.rs | 19 ++++++++++++ .../bindings_output/generated/contracts.rs | 5 ++++ .../generated/0.4.11-failure.txt | 13 ++++++++ .../generated/0.6.0-success.txt | 30 +++++++++++++++++++ .../contracts/internal_visibility/input.sol | 10 +++++++ 6 files changed, 96 insertions(+) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 6fdfb544c6..57d4bae93e 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -290,6 +290,12 @@ inherit .lexical_scope edge member -> typeof edge typeof -> @type_name.push_begin + ; Make internal members (state variables) accessible through the lexical scope + node internal + attr (internal) push_symbol = "@internal" + edge heir.lexical_scope -> internal + edge internal -> @type_name.push_begin + ;; Make base defs (eg. enums and structs) accessible as our own node type_member attr (type_member) push_symbol = "." @@ -331,6 +337,7 @@ inherit .lexical_scope node @contract.type_members node @contract.modifiers node @contract.state_vars + node @contract.internal edge @contract.lexical_scope -> @contract.members edge @contract.lexical_scope -> @contract.type_members @@ -379,6 +386,12 @@ inherit .lexical_scope edge @contract.def -> type_member edge type_member -> @contract.type_members + ; Finally there's an @internal path used by derived contracts to access our internal state variables + node internal + attr (internal) pop_symbol = "@internal" + edge @contract.def -> internal + edge internal -> @contract.internal + ;; Define "this" and connect it to the contract definition node this attr (this) pop_symbol = "this" @@ -489,6 +502,12 @@ inherit .lexical_scope [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 express that because we don't have negative assertions in our + ; query language + edge @contract.internal -> @state_var.def } ;; Public state variables are also exposed as external member functions 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 844650ed5d..c9871ac269 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 @@ -295,6 +295,12 @@ inherit .lexical_scope edge member -> typeof edge typeof -> @type_name.push_begin + ; Make internal members (state variables) accessible through the lexical scope + node internal + attr (internal) push_symbol = "@internal" + edge heir.lexical_scope -> internal + edge internal -> @type_name.push_begin + ;; Make base defs (eg. enums and structs) accessible as our own node type_member attr (type_member) push_symbol = "." @@ -336,6 +342,7 @@ inherit .lexical_scope node @contract.type_members node @contract.modifiers node @contract.state_vars + node @contract.internal edge @contract.lexical_scope -> @contract.members edge @contract.lexical_scope -> @contract.type_members @@ -384,6 +391,12 @@ inherit .lexical_scope edge @contract.def -> type_member edge type_member -> @contract.type_members + ; Finally there's an @internal path used by derived contracts to access our internal state variables + node internal + attr (internal) pop_symbol = "@internal" + edge @contract.def -> internal + edge internal -> @contract.internal + ;; Define "this" and connect it to the contract definition node this attr (this) pop_symbol = "this" @@ -494,6 +507,12 @@ inherit .lexical_scope [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 express that because we don't have negative assertions in our + ; query language + edge @contract.internal -> @state_var.def } ;; Public state variables are also exposed as external member functions 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 7199f538e1..dff8d88850 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 @@ -34,6 +34,11 @@ fn inheritance() -> Result<()> { run("contracts", "inheritance") } +#[test] +fn internal_visibility() -> Result<()> { + run("contracts", "internal_visibility") +} + #[test] fn multi_inheritance() -> Result<()> { run("contracts", "multi_inheritance") 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..343a25ac03 --- /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 { + ┆ ┆ + 10 │ ├─▶ } + │ │ + │ ╰─────── 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..73e0a51ed7 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/generated/0.6.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 │ abstract contract Ownable { + │ ───┬─── + │ ╰───── def: 1 + 2 │ address internal owner; + │ ──┬── + │ ╰──── def: 2 + 3 │ address default_visibility; + │ ─────────┬──────── + │ ╰────────── def: 3 + │ + 5 │ contract Test is Ownable { + │ ──┬─ ───┬─── + │ ╰────────────── def: 4 + │ │ + │ ╰───── ref: 1 + 6 │ function test() public { + │ ──┬─ + │ ╰─── def: 5 + 7 │ owner; + │ ──┬── + │ ╰──── ref: 2 + 8 │ default_visibility; + │ ─────────┬──────── + │ ╰────────── ref: 3 +───╯ 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..c2ef769390 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/input.sol @@ -0,0 +1,10 @@ +abstract contract Ownable { + address internal owner; + address default_visibility; +} +contract Test is Ownable { + function test() public { + owner; + default_visibility; + } +} From d3032c8262816deddc12aff4dd20fd1b5a411dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 29 Oct 2024 15:29:22 -0400 Subject: [PATCH 11/66] Propagate dynamic scope also from libraries And also provide alternative paths with and without propagating the dynamic scope. Otherwise, since scope accumulate on the stack it's possible we'll need to resolve an attached function with the wrong dynamic scope at the top of the scope stack. --- .../inputs/language/bindings/rules.msgb | 34 +++++++------ .../bindings/generated/binding_rules.rs | 34 +++++++------ .../bindings_output/generated/libraries.rs | 5 ++ .../generated/0.4.11-success.txt | 49 +++++++++++++++++++ .../propagate_dynamic_scope/input.sol | 13 +++++ 5 files changed, 107 insertions(+), 28 deletions(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 57d4bae93e..951457227d 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -68,11 +68,12 @@ inherit .lexical_scope edge @source_unit.lexical_scope -> JUMP_TO_SCOPE_NODE } -;; Top-level definitions (except contract handled below)... +;; (Most) Top-level definitions... @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @unit_member ( - [InterfaceDefinition] + [ContractDefinition] | [LibraryDefinition] + | [InterfaceDefinition] | [StructDefinition] | [EnumDefinition] | [FunctionDefinition] @@ -82,34 +83,38 @@ 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 } +;; For contracts (and libraries) navigating to the source unit lexical scope +;; *also* needs to propagate the dynamic scope to be able to correctly bind +;; `using` attached functions. @source_unit [SourceUnit [SourceUnitMembers - [SourceUnitMember @contract [ContractDefinition]] + [SourceUnitMember @contract_or_library ([ContractDefinition] | [LibraryDefinition])] ]] { - edge @source_unit.lexical_scope -> @contract.def - edge @source_unit.defs -> @contract.def - ; When "leaving" the contract lexical scope, ensure that the dynamic scope ; (ie. `using` directives extensions) is propagated - node @contract.dynamic - attr (@contract.dynamic) is_exported + node @contract_or_library.dynamic + attr (@contract_or_library.dynamic) is_exported node push - attr (push) push_scoped_symbol = "@dynamic", scope = @contract.dynamic + attr (push) push_scoped_symbol = "@dynamic", scope = @contract_or_library.dynamic node pop attr (pop) pop_scoped_symbol = "@dynamic" - edge @contract.lexical_scope -> push + edge @contract_or_library.lexical_scope -> push edge push -> pop edge pop -> @source_unit.lexical_scope ; The .parent_scope for contracts also needs to propagate the dynamic scope - ; otherwise when resolving for contract bases we lose it. - let @contract.parent_scope = push + ; otherwise when resolving for contract bases we lose it. This is not relevant + ; for libraries, but it doesn't matter that it's defined. + let @contract_or_library.parent_scope = push } @@ -699,7 +704,8 @@ inherit .lexical_scope @library [LibraryDefinition [LibraryMembers [ContractMember @using [UsingDirective]] ]] { - edge @library.lexical_scope -> @using.def + ; Expose the using directive from the dynamic scope + edge @library.dynamic -> @using.def } 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 c9871ac269..94c8d97c62 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 @@ -73,11 +73,12 @@ inherit .lexical_scope edge @source_unit.lexical_scope -> JUMP_TO_SCOPE_NODE } -;; Top-level definitions (except contract handled below)... +;; (Most) Top-level definitions... @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @unit_member ( - [InterfaceDefinition] + [ContractDefinition] | [LibraryDefinition] + | [InterfaceDefinition] | [StructDefinition] | [EnumDefinition] | [FunctionDefinition] @@ -87,34 +88,38 @@ 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 } +;; For contracts (and libraries) navigating to the source unit lexical scope +;; *also* needs to propagate the dynamic scope to be able to correctly bind +;; `using` attached functions. @source_unit [SourceUnit [SourceUnitMembers - [SourceUnitMember @contract [ContractDefinition]] + [SourceUnitMember @contract_or_library ([ContractDefinition] | [LibraryDefinition])] ]] { - edge @source_unit.lexical_scope -> @contract.def - edge @source_unit.defs -> @contract.def - ; When "leaving" the contract lexical scope, ensure that the dynamic scope ; (ie. `using` directives extensions) is propagated - node @contract.dynamic - attr (@contract.dynamic) is_exported + node @contract_or_library.dynamic + attr (@contract_or_library.dynamic) is_exported node push - attr (push) push_scoped_symbol = "@dynamic", scope = @contract.dynamic + attr (push) push_scoped_symbol = "@dynamic", scope = @contract_or_library.dynamic node pop attr (pop) pop_scoped_symbol = "@dynamic" - edge @contract.lexical_scope -> push + edge @contract_or_library.lexical_scope -> push edge push -> pop edge pop -> @source_unit.lexical_scope ; The .parent_scope for contracts also needs to propagate the dynamic scope - ; otherwise when resolving for contract bases we lose it. - let @contract.parent_scope = push + ; otherwise when resolving for contract bases we lose it. This is not relevant + ; for libraries, but it doesn't matter that it's defined. + let @contract_or_library.parent_scope = push } @@ -704,7 +709,8 @@ inherit .lexical_scope @library [LibraryDefinition [LibraryMembers [ContractMember @using [UsingDirective]] ]] { - edge @library.lexical_scope -> @using.def + ; Expose the using directive from the dynamic scope + edge @library.dynamic -> @using.def } 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 0d4a86c663..02cb24d50e 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 @@ -9,6 +9,11 @@ fn constants() -> Result<()> { run("libraries", "constants") } +#[test] +fn propagate_dynamic_scope() -> Result<()> { + run("libraries", "propagate_dynamic_scope") +} + #[test] fn visibility() -> Result<()> { run("libraries", "visibility") 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(); + } +} From a5f3eda0e1f7ebb51681d59a1477dac47da35764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 29 Oct 2024 16:13:09 -0400 Subject: [PATCH 12/66] Resolve using dynamic scope from an interface/contract casting --- .../inputs/language/bindings/rules.msgb | 22 ++++++++++ .../bindings/generated/binding_rules.rs | 22 ++++++++++ .../bindings_output/generated/interfaces.rs | 5 +++ .../generated/0.4.11-success.txt | 41 +++++++++++++++++++ .../casting_dynamic_scope/input.sol | 11 +++++ 5 files changed, 101 insertions(+) create mode 100644 crates/solidity/testing/snapshots/bindings_output/interfaces/casting_dynamic_scope/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/interfaces/casting_dynamic_scope/input.sol diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 951457227d..bf389718cf 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -385,6 +385,17 @@ inherit .lexical_scope edge @contract.def -> call edge call -> member + ; From a call we may need to resolve using the dynamic 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 = "." @@ -599,6 +610,17 @@ inherit .lexical_scope edge @interface.def -> call edge call -> member + ; From a call we may need to resolve using the dynamic 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 = "." 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 94c8d97c62..1a6d7b6fd6 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 @@ -390,6 +390,17 @@ inherit .lexical_scope edge @contract.def -> call edge call -> member + ; From a call we may need to resolve using the dynamic 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 = "." @@ -604,6 +615,17 @@ inherit .lexical_scope edge @interface.def -> call edge call -> member + ; From a call we may need to resolve using the dynamic 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 = "." 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 b6df971292..a2c66dd277 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 @@ -4,6 +4,11 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn casting_dynamic_scope() -> Result<()> { + run("interfaces", "casting_dynamic_scope") +} + #[test] fn inherit_dynamic_scope() -> Result<()> { run("interfaces", "inherit_dynamic_scope") diff --git a/crates/solidity/testing/snapshots/bindings_output/interfaces/casting_dynamic_scope/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/interfaces/casting_dynamic_scope/generated/0.4.11-success.txt new file mode 100644 index 0000000000..7c63d30e2f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/interfaces/casting_dynamic_scope/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/interfaces/casting_dynamic_scope/input.sol b/crates/solidity/testing/snapshots/bindings_output/interfaces/casting_dynamic_scope/input.sol new file mode 100644 index 0000000000..2f6cf1f80c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/interfaces/casting_dynamic_scope/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(); + } +} From 901501a378fc44909c5001707437f731514fb0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Wed, 30 Oct 2024 14:13:54 -0400 Subject: [PATCH 13/66] Resolve attached functions when applied to namespace qualified types --- .../inputs/language/bindings/rules.msgb | 15 +++++ .../bindings/generated/binding_rules.rs | 15 +++++ .../src/bindings_output/generated/using.rs | 5 ++ .../fqn_library/generated/0.4.11-success.txt | 56 +++++++++++++++++++ .../using/fqn_library/input.sol | 14 +++++ 5 files changed, 105 insertions(+) create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/fqn_library/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/fqn_library/input.sol diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index bf389718cf..44801ac7e8 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -706,6 +706,21 @@ inherit .lexical_scope edge @library.def -> type edge type -> type_library_type edge type_library_type -> @library.lexical_scope + + ; Provide a path to the parent lexical context that pushes our own name to the + ; symbol stack. This allows a local symbol (eg. a struct) defined and resolved + ; in this library to be fully qualified in order for `using` directives that + ; attach our own functions to our own types to be used (see + ; bindings_output/using/fqn_library test). + ; TODO: we should probably apply this same pattern to aliases from import + ; statements. + node push_member + attr (push_member) push_symbol = "." + node push_name + attr (push_name) push_symbol = (source-text @name) + edge @library.lexical_scope -> push_member + edge push_member -> push_name + edge push_name -> @library.parent_scope } @library [LibraryDefinition [LibraryMembers 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 1a6d7b6fd6..90d79f1f74 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 @@ -711,6 +711,21 @@ inherit .lexical_scope edge @library.def -> type edge type -> type_library_type edge type_library_type -> @library.lexical_scope + + ; Provide a path to the parent lexical context that pushes our own name to the + ; symbol stack. This allows a local symbol (eg. a struct) defined and resolved + ; in this library to be fully qualified in order for `using` directives that + ; attach our own functions to our own types to be used (see + ; bindings_output/using/fqn_library test). + ; TODO: we should probably apply this same pattern to aliases from import + ; statements. + node push_member + attr (push_member) push_symbol = "." + node push_name + attr (push_name) push_symbol = (source-text @name) + edge @library.lexical_scope -> push_member + edge push_member -> push_name + edge push_name -> @library.parent_scope } @library [LibraryDefinition [LibraryMembers 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 159e396ab8..c0c724364a 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 @@ -24,6 +24,11 @@ fn elementary_arrays() -> Result<()> { run("using", "elementary_arrays") } +#[test] +fn fqn_library() -> Result<()> { + run("using", "fqn_library") +} + #[test] fn function_types() -> Result<()> { run("using", "function_types") diff --git a/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/generated/0.4.11-success.txt new file mode 100644 index 0000000000..65c7474085 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/generated/0.4.11-success.txt @@ -0,0 +1,56 @@ +# 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 Lib for Lib.Value; + │ ─┬─ ─┬─ ──┬── + │ ╰───────────────── ref: 1 + │ │ │ + │ ╰───────── ref: 1 + │ │ + │ ╰──── ref: 2 + 3 │ struct Value { + │ ──┬── + │ ╰──── def: 2 + 4 │ int x; + │ ┬ + │ ╰── def: 3 + │ + 6 │ function getValue() external returns (Value memory) {} + │ ────┬─── ──┬── + │ ╰─────────────────────────────── def: 4 + │ │ + │ ╰──── ref: 2 + 7 │ function use(Value memory x) external {} + │ ─┬─ ──┬── ┬ + │ ╰────────────────── def: 5 + │ │ │ + │ ╰───────────── ref: 2 + │ │ + │ ╰── def: 6 + │ + 9 │ contract Test { + │ ──┬─ + │ ╰─── def: 7 + 10 │ using Lib for Lib.Value; + │ ─┬─ ─┬─ ──┬── + │ ╰───────────────── ref: 1 + │ │ │ + │ ╰───────── ref: 1 + │ │ + │ ╰──── ref: 2 + 11 │ function test() internal { + │ ──┬─ + │ ╰─── def: 8 + 12 │ Lib.getValue().use(); + │ ─┬─ ────┬─── ─┬─ + │ ╰────────────────── ref: 1 + │ │ │ + │ ╰─────────── ref: 4 + │ │ + │ ╰─── ref: 5 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/input.sol new file mode 100644 index 0000000000..9b736be55e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/input.sol @@ -0,0 +1,14 @@ +library Lib { + using Lib for Lib.Value; + 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(); + } +} From 1d566b422bfbd955a76ce816030e5df83452777e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Wed, 30 Oct 2024 16:18:48 -0400 Subject: [PATCH 14/66] Public getters are used as functions, so bind them as such --- .../inputs/language/bindings/rules.msgb | 19 ++++++++-- .../bindings/generated/binding_rules.rs | 19 ++++++++-- .../bindings_output/generated/contracts.rs | 5 +++ .../generated/0.4.11-success.txt | 37 +++++++++++++++++++ .../contracts/call_public_getter/input.sol | 9 +++++ 5 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/call_public_getter/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/call_public_getter/input.sol diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 44801ac7e8..7f6a123780 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -1744,11 +1744,22 @@ 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 = "()" + + edge @state_var.def -> call + edge call -> @state_var.typeof } 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 90d79f1f74..ee7456a2f8 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 @@ -1749,11 +1749,22 @@ 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 = "()" + + edge @state_var.def -> call + edge call -> @state_var.typeof } 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 dff8d88850..b8c118d107 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 call_public_getter() -> Result<()> { + run("contracts", "call_public_getter") +} + #[test] fn constructor_call_parent() -> Result<()> { run("contracts", "constructor_call_parent") diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/call_public_getter/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/call_public_getter/generated/0.4.11-success.txt new file mode 100644 index 0000000000..d054a7ad51 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/call_public_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 Value { int x; } + │ ──┬── ┬ + │ ╰──────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ Value public value; + │ ──┬── ──┬── + │ ╰───────────────── ref: 2 + │ │ + │ ╰──── def: 4 + │ + 5 │ contract Test { + │ ──┬─ + │ ╰─── def: 5 + 6 │ function test(Base base) public { + │ ──┬─ ──┬─ ──┬─ + │ ╰───────────── def: 6 + │ │ │ + │ ╰──────── ref: 1 + │ │ + │ ╰─── def: 7 + 7 │ base.value().x; + │ ──┬─ ──┬── ┬ + │ ╰───────────── ref: 7 + │ │ │ + │ ╰──────── ref: 4 + │ │ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/call_public_getter/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/call_public_getter/input.sol new file mode 100644 index 0000000000..c3e4959c62 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/call_public_getter/input.sol @@ -0,0 +1,9 @@ +contract Base { + struct Value { int x; } + Value public value; +} +contract Test { + function test(Base base) public { + base.value().x; + } +} From a38e8bd9a724841fabdacc98fe839607ac17518a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Wed, 30 Oct 2024 16:43:56 -0400 Subject: [PATCH 15/66] Functions can be called in derived contracts by qualifying with the name --- .../inputs/language/bindings/rules.msgb | 7 ++ .../bindings/generated/binding_rules.rs | 7 ++ .../generated/0.4.11-failure.txt | 2 +- .../generated/0.6.0-success.txt | 65 +++++++++++-------- .../contracts/internal_visibility/input.sol | 3 + 5 files changed, 56 insertions(+), 28 deletions(-) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 7f6a123780..4a81a70b3b 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -301,6 +301,13 @@ inherit .lexical_scope edge heir.lexical_scope -> internal edge internal -> @type_name.push_begin + ; Base members can also be accessed qualified with the base name (eg. `Base.something`) + node member_pop + attr (member_pop) pop_symbol = "." + edge heir.lexical_scope -> @type_name.pop_begin + edge @type_name.pop_end -> member_pop + edge member_pop -> member + ;; Make base defs (eg. enums and structs) accessible as our own node type_member attr (type_member) push_symbol = "." 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 ee7456a2f8..34ceba9883 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 @@ -306,6 +306,13 @@ inherit .lexical_scope edge heir.lexical_scope -> internal edge internal -> @type_name.push_begin + ; Base members can also be accessed qualified with the base name (eg. `Base.something`) + node member_pop + attr (member_pop) pop_symbol = "." + edge heir.lexical_scope -> @type_name.pop_begin + edge @type_name.pop_end -> member_pop + edge member_pop -> member + ;; Make base defs (eg. enums and structs) accessible as our own node type_member attr (type_member) push_symbol = "." 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 index 343a25ac03..507119f26e 100644 --- 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 @@ -6,7 +6,7 @@ Error: Expected ContractKeyword or ImportKeyword or InterfaceKeyword or LibraryK │ 1 │ ╭─▶ abstract contract Ownable { ┆ ┆ - 10 │ ├─▶ } + 13 │ ├─▶ } │ │ │ ╰─────── Error occurred here. ────╯ 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 index 73e0a51ed7..acd63c8cb7 100644 --- 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 @@ -1,30 +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 - │ - 5 │ contract Test is Ownable { - │ ──┬─ ───┬─── - │ ╰────────────── def: 4 - │ │ - │ ╰───── ref: 1 - 6 │ function test() public { - │ ──┬─ - │ ╰─── def: 5 - 7 │ owner; - │ ──┬── - │ ╰──── ref: 2 - 8 │ default_visibility; - │ ─────────┬──────── - │ ╰────────── ref: 3 -───╯ + ╭─[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 index c2ef769390..48bd9c2fda 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/input.sol +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/internal_visibility/input.sol @@ -1,10 +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(); } } From 3aab65d3e87ab3c2dfdfb1bac1354bda6af2045d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Wed, 30 Oct 2024 17:08:29 -0400 Subject: [PATCH 16/66] Add support for binding unnamed function declarations --- .../inputs/language/bindings/rules.msgb | 24 +++++++++++++++++++ .../bindings/generated/binding_rules.rs | 24 +++++++++++++++++++ .../bindings_output/generated/contracts.rs | 5 ++++ .../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 ++++ 9 files changed, 141 insertions(+) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 4a81a70b3b..b4feccc26b 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -497,6 +497,7 @@ inherit .lexical_scope | [ModifierDefinition] | [FallbackFunctionDefinition] | [ReceiveFunctionDefinition] + | [UnnamedFunctionDefinition] )] ]] { edge @member.lexical_scope -> @contract.lexical_scope @@ -1258,6 +1259,29 @@ inherit .lexical_scope edge @args.lexical_scope -> @modifier.lexical_scope } +;;; Unnamed functions (deprecated) +@unnamed_function [UnnamedFunctionDefinition] { + node @unnamed_function.lexical_scope +} + +@unnamed_function [UnnamedFunctionDefinition @params parameters: [ParametersDeclaration]] { + edge @params.lexical_scope -> @unnamed_function.lexical_scope + + edge @unnamed_function.lexical_scope -> @params.defs + attr (@unnamed_function.lexical_scope -> @params.defs) precedence = 1 +} + +@unnamed_function [UnnamedFunctionDefinition [FunctionBody @block [Block]]] { + edge @block.lexical_scope -> @unnamed_function.lexical_scope +} + +@unnamed_function [UnnamedFunctionDefinition + [UnnamedFunctionAttributes [UnnamedFunctionAttribute @modifier [ModifierInvocation]]] +] { + edge @modifier.lexical_scope -> @unnamed_function.lexical_scope +} + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Constructors 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 34ceba9883..5a26fda329 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 @@ -502,6 +502,7 @@ inherit .lexical_scope | [ModifierDefinition] | [FallbackFunctionDefinition] | [ReceiveFunctionDefinition] + | [UnnamedFunctionDefinition] )] ]] { edge @member.lexical_scope -> @contract.lexical_scope @@ -1263,6 +1264,29 @@ inherit .lexical_scope edge @args.lexical_scope -> @modifier.lexical_scope } +;;; Unnamed functions (deprecated) +@unnamed_function [UnnamedFunctionDefinition] { + node @unnamed_function.lexical_scope +} + +@unnamed_function [UnnamedFunctionDefinition @params parameters: [ParametersDeclaration]] { + edge @params.lexical_scope -> @unnamed_function.lexical_scope + + edge @unnamed_function.lexical_scope -> @params.defs + attr (@unnamed_function.lexical_scope -> @params.defs) precedence = 1 +} + +@unnamed_function [UnnamedFunctionDefinition [FunctionBody @block [Block]]] { + edge @block.lexical_scope -> @unnamed_function.lexical_scope +} + +@unnamed_function [UnnamedFunctionDefinition + [UnnamedFunctionAttributes [UnnamedFunctionAttribute @modifier [ModifierInvocation]]] +] { + edge @modifier.lexical_scope -> @unnamed_function.lexical_scope +} + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Constructors 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 b8c118d107..dcde4f1873 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 @@ -69,6 +69,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/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(); + } +} From 9d620d7267d6b21395a478f567a011ee88fa3c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Wed, 30 Oct 2024 17:31:55 -0400 Subject: [PATCH 17/66] Support old `var` declarations --- .../inputs/language/bindings/rules.msgb | 48 ++++++++++++++----- .../bindings/generated/binding_rules.rs | 48 ++++++++++++++----- .../bindings_output/generated/variables.rs | 5 ++ .../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 +++ 11 files changed, 299 insertions(+), 26 deletions(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index b4feccc26b..a842af61f7 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -1514,7 +1514,6 @@ inherit .lexical_scope @expr_stmt [ExpressionStatement] { node @expr_stmt.lexical_scope - node @expr_stmt.defs } @@ -1522,32 +1521,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 @@ -1621,11 +1634,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 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 5a26fda329..de7d79333c 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 @@ -1519,7 +1519,6 @@ inherit .lexical_scope @expr_stmt [ExpressionStatement] { node @expr_stmt.lexical_scope - node @expr_stmt.defs } @@ -1527,32 +1526,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 @@ -1626,11 +1639,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 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/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..cba3c06693 --- /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 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..78d95db9a6 --- /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 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..4368b04b1f --- /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 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..d21743dba7 --- /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 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..b82d508a46 --- /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 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..cbd378cc79 --- /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 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; + } +} From 7daa1f471066412deea934de819afb48725bb54c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Wed, 30 Oct 2024 17:56:09 -0400 Subject: [PATCH 18/66] Make inherited state vars accessible in all parent contracts --- .../inputs/language/bindings/rules.msgb | 5 +++ .../bindings/generated/binding_rules.rs | 5 +++ .../bindings_output/generated/contracts.rs | 5 +++ .../generated/0.4.11-success.txt | 36 +++++++++++++++++++ .../contracts/inherited_state_vars/input.sol | 12 +++++++ 5 files changed, 63 insertions(+) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index a842af61f7..782cbfc737 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -296,9 +296,12 @@ inherit .lexical_scope edge typeof -> @type_name.push_begin ; Make internal members (state variables) accessible through the lexical scope + ; and from the heir's internal scope (so that inherited internal variables can + ; be accessed) node internal attr (internal) push_symbol = "@internal" edge heir.lexical_scope -> internal + edge heir.internal -> internal edge internal -> @type_name.push_begin ; Base members can also be accessed qualified with the base name (eg. `Base.something`) @@ -592,6 +595,8 @@ inherit .lexical_scope node @interface.def node @interface.members node @interface.type_members + ; this is unused in interfaces, but required for the inheritance rules + node @interface.internal edge @interface.lexical_scope -> @interface.members edge @interface.lexical_scope -> @interface.type_members 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 de7d79333c..689979d540 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 @@ -301,9 +301,12 @@ inherit .lexical_scope edge typeof -> @type_name.push_begin ; Make internal members (state variables) accessible through the lexical scope + ; and from the heir's internal scope (so that inherited internal variables can + ; be accessed) node internal attr (internal) push_symbol = "@internal" edge heir.lexical_scope -> internal + edge heir.internal -> internal edge internal -> @type_name.push_begin ; Base members can also be accessed qualified with the base name (eg. `Base.something`) @@ -597,6 +600,8 @@ inherit .lexical_scope node @interface.def node @interface.members node @interface.type_members + ; this is unused in interfaces, but required for the inheritance rules + node @interface.internal edge @interface.lexical_scope -> @interface.members edge @interface.lexical_scope -> @interface.type_members 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 dcde4f1873..ca6d8b152b 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 @@ -39,6 +39,11 @@ 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") 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; + } +} From 0d2802ff6538b0214e320a1ce073827a7f050a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 31 Oct 2024 14:26:22 -0400 Subject: [PATCH 19/66] Normalize value type aliases to bind attached functions correctly --- .../inputs/language/bindings/rules.msgb | 18 ++++++++++- .../bindings/generated/binding_rules.rs | 18 ++++++++++- .../src/bindings_output/generated/using.rs | 5 +++ .../uint_alias/generated/0.4.11-success.txt | 32 +++++++++++++++++++ .../using/uint_alias/input.sol | 10 ++++++ 5 files changed, 81 insertions(+), 2 deletions(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 782cbfc737..9d4a193e54 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -910,7 +910,23 @@ inherit .lexical_scope | [FixedKeyword] | [UfixedKeyword] )] { - let @elementary.symbol = (format "%{}" (source-text @keyword)) + var symbol = (source-text @keyword) + ; Normalize type aliases + scan (source-text @keyword) { + "^uint$" { + set symbol = "uint256" + } + "^int$" { + set symbol = "int256" + } + "^fixed$" { + set symbol = "fixed128x18" + } + "^ufixed$" { + set symbol = "ufixed128x18" + } + } + let @elementary.symbol = (format "%{}" symbol) } 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 689979d540..b5ef32955e 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 @@ -915,7 +915,23 @@ inherit .lexical_scope | [FixedKeyword] | [UfixedKeyword] )] { - let @elementary.symbol = (format "%{}" (source-text @keyword)) + var symbol = (source-text @keyword) + ; Normalize type aliases + scan (source-text @keyword) { + "^uint$" { + set symbol = "uint256" + } + "^int$" { + set symbol = "int256" + } + "^fixed$" { + set symbol = "fixed128x18" + } + "^ufixed$" { + set symbol = "ufixed128x18" + } + } + let @elementary.symbol = (format "%{}" symbol) } 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 c0c724364a..f702a0b180 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 @@ -58,3 +58,8 @@ fn star() -> Result<()> { fn top_level() -> Result<()> { run("using", "top_level") } + +#[test] +fn uint_alias() -> Result<()> { + run("using", "uint_alias") +} 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 {} +} From 58ced151d979c6d69f9ee3dfe886733c95cd784f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 31 Oct 2024 14:56:24 -0400 Subject: [PATCH 20/66] Support binding literal hex addresses --- .../inputs/language/bindings/rules.msgb | 17 +++++++++++++++++ .../bindings/generated/binding_rules.rs | 17 +++++++++++++++++ .../bindings_output/generated/expressions.rs | 5 +++++ .../generated/0.4.11-success.txt | 19 +++++++++++++++++++ .../expressions/literal_address/input.sol | 5 +++++ 5 files changed, 63 insertions(+) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 9d4a193e54..14be0c2f87 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -2369,6 +2369,23 @@ inherit .lexical_scope } +;;; 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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 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 b5ef32955e..ae5710ec1e 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 @@ -2374,6 +2374,23 @@ inherit .lexical_scope } +;;; 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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 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 87b921eb29..3decc728e1 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 @@ -39,6 +39,11 @@ fn funcalls_output() -> Result<()> { run("expressions", "funcalls_output") } +#[test] +fn literal_address() -> Result<()> { + run("expressions", "literal_address") +} + #[test] fn new_output() -> Result<()> { run("expressions", "new_output") 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); + } +} From 438cb81bcac7dec0f455340aa794aa129703caaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 31 Oct 2024 15:07:21 -0400 Subject: [PATCH 21/66] Prior to 0.5.0, `this` could be used as an `address` --- .../inputs/language/bindings/rules.msgb | 11 +++++++++++ .../bindings/generated/binding_rules.rs | 11 +++++++++++ .../src/bindings_output/generated/built_ins.rs | 5 +++++ .../generated/0.4.11-success.txt | 18 ++++++++++++++++++ .../generated/0.5.0-failure.txt | 18 ++++++++++++++++++ .../built_ins/this_as_address/input.sol | 6 ++++++ .../generated/0.4.11-failure.txt | 4 ++-- .../generated/0.4.21-failure.txt | 4 ++-- .../generated/0.5.0-failure.txt | 4 ++-- .../generated/0.5.3-failure.txt | 4 ++-- .../generated/0.6.0-success.txt | 2 +- .../generated/0.5.0-failure.txt | 2 +- .../generated/0.5.3-failure.txt | 2 +- .../generated/0.6.0-failure.txt | 2 +- .../generated/0.7.0-failure.txt | 2 +- .../generated/0.8.0-failure.txt | 2 +- .../generated/0.8.4-failure.txt | 2 +- 17 files changed, 84 insertions(+), 15 deletions(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 14be0c2f87..f748215f70 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -432,6 +432,17 @@ inherit .lexical_scope edge this -> name_push edge name_push -> @contract.lexical_scope + ; For Solidity < 0.5.0 `this` also acts like an `address` + if (version-matches "< 0.5.0") { + 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 + } + ;; 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 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 ae5710ec1e..23ce64fd0f 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 @@ -437,6 +437,17 @@ inherit .lexical_scope edge this -> name_push edge name_push -> @contract.lexical_scope + ; For Solidity < 0.5.0 `this` also acts like an `address` + if (version-matches "< 0.5.0") { + 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 + } + ;; 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 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 d6ea76b7a1..db3f38eb8f 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 @@ -44,6 +44,11 @@ fn shadowing() -> Result<()> { run("built_ins", "shadowing") } +#[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/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..fc078552b0 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.4.11-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 Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ this.balance; + │ ──┬─ ───┬─── + │ ╰─────────── ref: 1 + │ │ + │ ╰───── 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..c075660094 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/this_as_address/generated/0.5.0-failure.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 Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ this.balance; + │ ──┬─ ───┬─── + │ ╰─────────── ref: 1 + │ │ + │ ╰───── 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/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 index d7b49cdaba..3b69ddc24e 100644 --- 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 @@ -1,7 +1,7 @@ # 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 ThrowKeyword or TrueKeyword or UfixedKeyword or UintKeyword or VarKeyword or WhileKeyword. +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(""); @@ -27,7 +27,7 @@ References and definitions: │ ╰── def: 3 5 │ address(this).balance; │ ──┬─ ───┬─── - │ ╰──────────── ref: built-in + │ ╰──────────── ref: 1 │ │ │ ╰───── ref: built-in │ 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 index dfac6e4c83..54e6396353 100644 --- 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 @@ -1,7 +1,7 @@ # 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 ThrowKeyword or TrueKeyword or UfixedKeyword or UintKeyword or VarKeyword or WhileKeyword. +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(""); @@ -27,7 +27,7 @@ References and definitions: │ ╰── def: 3 5 │ address(this).balance; │ ──┬─ ───┬─── - │ ╰──────────── ref: built-in + │ ╰──────────── ref: 1 │ │ │ ╰───── ref: built-in │ 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 index 0faa69fb8b..d52b1ac8b5 100644 --- 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 @@ -1,7 +1,7 @@ # 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 TrueKeyword or UfixedKeyword or UintKeyword or WhileKeyword. +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(""); @@ -27,7 +27,7 @@ References and definitions: │ ╰── def: 3 5 │ address(this).balance; │ ──┬─ ───┬─── - │ ╰──────────── ref: built-in + │ ╰──────────── ref: 1 │ │ │ ╰───── ref: built-in │ 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 index e4d8db97f5..5f69b56a43 100644 --- 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 @@ -1,7 +1,7 @@ # 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 TrueKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. +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(""); @@ -27,7 +27,7 @@ References and definitions: │ ╰── def: 3 5 │ address(this).balance; │ ──┬─ ───┬─── - │ ╰──────────── ref: built-in + │ ╰──────────── ref: 1 │ │ │ ╰───── ref: built-in │ 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 index 7f99301fc9..9ced7532c3 100644 --- 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 @@ -17,7 +17,7 @@ References and definitions: │ ╰── def: 3 5 │ address(this).balance; │ ──┬─ ───┬─── - │ ╰──────────── ref: built-in + │ ╰──────────── ref: 1 │ │ │ ╰───── ref: built-in 6 │ payable(a).call(""); 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 index cba3c06693..b1aab5f30b 100644 --- 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 @@ -1,7 +1,7 @@ # 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 TrueKeyword or UfixedKeyword or UintKeyword or WhileKeyword. +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; 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 index 78d95db9a6..916fc51d48 100644 --- 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 @@ -1,7 +1,7 @@ # 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 TrueKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. +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; 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 index 4368b04b1f..baeb9846cc 100644 --- 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 @@ -1,7 +1,7 @@ # 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 TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. +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; 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 index d21743dba7..d9a26d93af 100644 --- 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 @@ -1,7 +1,7 @@ # 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 TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. +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; 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 index b82d508a46..4ab42efd3b 100644 --- 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 @@ -1,7 +1,7 @@ # 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 TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or UncheckedKeyword or WhileKeyword. +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; 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 index cbd378cc79..bef3f48735 100644 --- 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 @@ -1,7 +1,7 @@ # 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 TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or UncheckedKeyword or WhileKeyword. +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; From 9cbb4fc91bce56f365399230b4d62ad79b044edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Fri, 1 Nov 2024 13:39:05 -0400 Subject: [PATCH 22/66] Add binding test cases for most of the remaining Sanctuary issues --- .../src/bindings_output/generated/arrays.rs | 5 ++ .../bindings_output/generated/contracts.rs | 15 +++++ .../bindings_output/generated/expressions.rs | 10 ++++ .../bindings_output/generated/libraries.rs | 5 ++ .../src/bindings_output/generated/mod.rs | 1 + .../bindings_output/generated/user_types.rs | 10 ++++ .../src/bindings_output/generated/using.rs | 20 +++++++ .../src/bindings_output/generated/yul.rs | 5 ++ .../length/generated/0.4.11-failure.txt | 33 +++++++++++ .../bindings_output/arrays/length/input.sol | 9 +++ .../generated/0.4.11-failure.txt | 20 +++++++ .../contracts/legacy_constructors/input.sol | 5 ++ .../generated/0.4.11-failure.txt | 13 +++++ .../generated/0.6.0-failure.txt | 26 +++++++++ .../contracts/qualified_inherited/input.sol | 8 +++ .../generated/0.4.11-failure.txt | 31 +++++++++++ .../contracts/qualified_parent_call/input.sol | 9 +++ .../generated/0.4.11-failure.txt | 35 ++++++++++++ .../expressions/legacy_call_options/input.sol | 7 +++ .../generated/0.4.11-failure.txt | 27 +++++++++ .../expressions/literal_integers/input.sol | 9 +++ .../modifiers/generated/0.4.11-failure.txt | 21 +++++++ .../libraries/modifiers/input.sol | 6 ++ .../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-failure.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-failure.txt | 31 +++++++++++ .../bindings_output/using/address/input.sol | 9 +++ .../decimal/generated/0.4.11-failure.txt | 53 ++++++++++++++++++ .../bindings_output/using/decimal/input.sol | 13 +++++ .../generated/0.4.11-failure.txt | 55 +++++++++++++++++++ .../using/deep_inheritance/input.sol | 15 +++++ ...{0.4.11-success.txt => 0.4.11-failure.txt} | 25 +++------ .../using/fqn_library/input.sol | 1 - .../using/min256/generated/0.4.11-failure.txt | 49 +++++++++++++++++ .../bindings_output/using/min256/input.sol | 15 +++++ .../generated/0.4.11-failure.txt | 48 ++++++++++++++++ .../using/on_interfaces_inherited/input.sol | 14 +++++ .../slot_suffix/generated/0.4.11-failure.txt | 20 +++++++ .../bindings_output/yul/slot_suffix/input.sol | 7 +++ 49 files changed, 930 insertions(+), 17 deletions(-) create mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_output/generated/user_types.rs create mode 100644 crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/arrays/length/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.4.11-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/qualified_inherited/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.6.0-failure.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-failure.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/expressions/legacy_call_options/generated/0.4.11-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_integers/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/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-failure.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-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/address/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/decimal/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/decimal/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/input.sol rename crates/solidity/testing/snapshots/bindings_output/using/fqn_library/generated/{0.4.11-success.txt => 0.4.11-failure.txt} (72%) create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/min256/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/min256/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.4.11-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/yul/slot_suffix/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/input.sol 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/contracts.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/contracts.rs index ca6d8b152b..b8f2f2df93 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 @@ -49,6 +49,11 @@ fn internal_visibility() -> Result<()> { run("contracts", "internal_visibility") } +#[test] +fn legacy_constructors() -> Result<()> { + run("contracts", "legacy_constructors") +} + #[test] fn multi_inheritance() -> Result<()> { run("contracts", "multi_inheritance") @@ -59,6 +64,16 @@ fn public_getters() -> Result<()> { run("contracts", "public_getters") } +#[test] +fn qualified_inherited() -> Result<()> { + run("contracts", "qualified_inherited") +} + +#[test] +fn qualified_parent_call() -> Result<()> { + run("contracts", "qualified_parent_call") +} + #[test] fn super_linearisation() -> Result<()> { run("contracts", "super_linearisation") 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 3decc728e1..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 @@ -39,11 +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/libraries.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/libraries.rs index 02cb24d50e..bb2f24cf19 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 @@ -9,6 +9,11 @@ fn constants() -> Result<()> { run("libraries", "constants") } +#[test] +fn modifiers() -> Result<()> { + run("libraries", "modifiers") +} + #[test] fn propagate_dynamic_scope() -> Result<()> { run("libraries", "propagate_dynamic_scope") 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/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 f702a0b180..a4ad90dc91 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,16 +4,31 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn address() -> Result<()> { + run("using", "address") +} + #[test] fn chained_calls() -> Result<()> { run("using", "chained_calls") } +#[test] +fn decimal() -> Result<()> { + run("using", "decimal") +} + #[test] fn deconstruction() -> Result<()> { run("using", "deconstruction") } +#[test] +fn deep_inheritance() -> Result<()> { + run("using", "deep_inheritance") +} + #[test] fn elementary() -> Result<()> { run("using", "elementary") @@ -49,6 +64,11 @@ fn in_library() -> Result<()> { run("using", "in_library") } +#[test] +fn on_interfaces_inherited() -> Result<()> { + run("using", "on_interfaces_inherited") +} + #[test] fn star() -> Result<()> { run("using", "star") 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..cbe0d9e2ea 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 @@ -19,6 +19,11 @@ fn loops() -> Result<()> { run("yul", "loops") } +#[test] +fn slot_suffix() -> Result<()> { + run("yul", "slot_suffix") +} + #[test] fn variables() -> Result<()> { run("yul", "variables") diff --git a/crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..2b52f7d3f5 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-failure.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 + │ │ + │ ╰─── unresolved +───╯ 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/contracts/legacy_constructors/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..24988498b8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.4.11-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/qualified_inherited/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..585e829d2c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/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 Base { + ┆ ┆ + 8 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +───╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..797e64ac01 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.6.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 │ abstract 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 + │ │ + │ ╰────── unresolved +───╯ 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..e9918df72c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/input.sol @@ -0,0 +1,8 @@ +abstract 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-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..13c3339463 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/0.4.11-failure.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 + │ │ + │ ╰───── unresolved +───╯ 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/expressions/legacy_call_options/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..b15ce9308a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.4.11-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_integers/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..9b4c04dca3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/0.4.11-failure.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(); + │ ─┬─ + │ ╰─── unresolved +───╯ 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/libraries/modifiers/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..7bd6f21b6e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-failure.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 │ _; + │ ┬ + │ ╰── unresolved + │ + 5 │ function test() internal withinRange() {} + │ ──┬─ ─────┬───── + │ ╰────────────────────────── def: 3 + │ │ + │ ╰─────── unresolved +───╯ 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/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-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.8-failure.txt new file mode 100644 index 0000000000..5040c83fd9 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.8-failure.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 + │ │ │ + │ ╰──────── unresolved + │ │ + │ ╰─── ref: 4 + 6 │ ShortString.unwrap(s); + │ ─────┬───── ───┬── ┬ + │ ╰──────────────── ref: 1 + │ │ │ + │ ╰────── unresolved + │ │ + │ ╰── 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..d0f6e9d6e6 --- /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 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..d5ac8d4d66 --- /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 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..6eea708e96 --- /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 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..e4173ecbdd --- /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 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-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..0257951997 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.6.0-failure.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 + │ │ + │ ╰────── unresolved +───╯ 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/decimal/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/decimal/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..5ed3900234 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/decimal/generated/0.4.11-failure.txt @@ -0,0 +1,53 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Decimal { + │ ───┬─── + │ ╰───── def: 1 + 2 │ struct D256 { + │ ──┬─ + │ ╰─── def: 2 + 3 │ uint256 value; + │ ──┬── + │ ╰──── def: 3 + │ + 5 │ function from(uint256 x) internal returns (D256) {} + │ ──┬─ ┬ ──┬─ + │ ╰───────────────────────────────────── def: 4 + │ │ │ + │ ╰────────────────────────── def: 5 + │ │ + │ ╰─── ref: 2 + 6 │ function div(D256 memory v) internal returns (D256) {} + │ ─┬─ ──┬─ ┬ ──┬─ + │ ╰───────────────────────────────────────── def: 6 + │ │ │ │ + │ ╰──────────────────────────────────── ref: 2 + │ │ │ + │ ╰────────────────────────── def: 7 + │ │ + │ ╰─── ref: 2 + │ + 8 │ contract Test { + │ ──┬─ + │ ╰─── def: 8 + 9 │ using Decimal for Decimal.D256; + │ ───┬─── ───┬─── ──┬─ + │ ╰────────────────────── ref: 1 + │ │ │ + │ ╰────────── ref: 1 + │ │ + │ ╰─── ref: 2 + 10 │ function test() public { + │ ──┬─ + │ ╰─── def: 9 + 11 │ Decimal.from(1).div(); + │ ───┬─── ──┬─ ─┬─ + │ ╰───────────────── ref: 1 + │ │ │ + │ ╰────────── ref: 4 + │ │ + │ ╰─── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/decimal/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/decimal/input.sol new file mode 100644 index 0000000000..0eb86910a2 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/decimal/input.sol @@ -0,0 +1,13 @@ +library Decimal { + struct D256 { + uint256 value; + } + function from(uint256 x) internal returns (D256) {} + function div(D256 memory v) internal returns (D256) {} +} +contract Test { + using Decimal for Decimal.D256; + function test() public { + Decimal.from(1).div(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..f19399d68f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/generated/0.4.11-failure.txt @@ -0,0 +1,55 @@ +# 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 │ contract Vars { + │ ──┬─ + │ ╰─── def: 2 + 3 │ IFoo internal constant foo = IFoo(address(0x0)); + │ ──┬─ ─┬─ ──┬─ + │ ╰──────────────────────────────── ref: 1 + │ │ │ + │ ╰────────── def: 3 + │ │ + │ ╰─── ref: 1 + │ + 5 │ library LibFoo { + │ ───┬── + │ ╰──── def: 4 + 6 │ function use_foo(IFoo f) internal {} + │ ───┬─── ──┬─ ┬ + │ ╰──────────── def: 5 + │ │ │ + │ ╰───── ref: 1 + │ │ + │ ╰── def: 6 + │ + 8 │ contract Base is Vars { + │ ──┬─ ──┬─ + │ ╰─────────── def: 7 + │ │ + │ ╰─── ref: 2 + │ + 10 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 8 + │ │ + │ ╰─── ref: 7 + 11 │ using LibFoo for IFoo; + │ ───┬── ──┬─ + │ ╰───────────── ref: 4 + │ │ + │ ╰─── ref: 1 + 12 │ function test() public { + │ ──┬─ + │ ╰─── def: 9 + 13 │ foo.use_foo(); + │ ─┬─ ───┬─── + │ ╰─────────── ref: 3 + │ │ + │ ╰───── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/input.sol new file mode 100644 index 0000000000..43408a5ed4 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/input.sol @@ -0,0 +1,15 @@ +interface IFoo {} +contract Vars { + IFoo internal constant foo = IFoo(address(0x0)); +} +library LibFoo { + function use_foo(IFoo f) internal {} +} +contract Base is Vars { +} +contract Test is Base { + using LibFoo for IFoo; + function test() public { + foo.use_foo(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/generated/0.4.11-failure.txt similarity index 72% rename from crates/solidity/testing/snapshots/bindings_output/using/fqn_library/generated/0.4.11-success.txt rename to crates/solidity/testing/snapshots/bindings_output/using/fqn_library/generated/0.4.11-failure.txt index 65c7474085..cc64b285a5 100644 --- a/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/generated/0.4.11-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/generated/0.4.11-failure.txt @@ -6,26 +6,19 @@ References and definitions: 1 │ library Lib { │ ─┬─ │ ╰─── def: 1 - 2 │ using Lib for Lib.Value; - │ ─┬─ ─┬─ ──┬── - │ ╰───────────────── ref: 1 - │ │ │ - │ ╰───────── ref: 1 - │ │ - │ ╰──── ref: 2 - 3 │ struct Value { + 2 │ struct Value { │ ──┬── │ ╰──── def: 2 - 4 │ int x; + 3 │ int x; │ ┬ │ ╰── def: 3 │ - 6 │ function getValue() external returns (Value memory) {} + 5 │ function getValue() external returns (Value memory) {} │ ────┬─── ──┬── │ ╰─────────────────────────────── def: 4 │ │ │ ╰──── ref: 2 - 7 │ function use(Value memory x) external {} + 6 │ function use(Value memory x) external {} │ ─┬─ ──┬── ┬ │ ╰────────────────── def: 5 │ │ │ @@ -33,24 +26,24 @@ References and definitions: │ │ │ ╰── def: 6 │ - 9 │ contract Test { + 8 │ contract Test { │ ──┬─ │ ╰─── def: 7 - 10 │ using Lib for Lib.Value; + 9 │ using Lib for Lib.Value; │ ─┬─ ─┬─ ──┬── │ ╰───────────────── ref: 1 │ │ │ │ ╰───────── ref: 1 │ │ │ ╰──── ref: 2 - 11 │ function test() internal { + 10 │ function test() internal { │ ──┬─ │ ╰─── def: 8 - 12 │ Lib.getValue().use(); + 11 │ Lib.getValue().use(); │ ─┬─ ────┬─── ─┬─ │ ╰────────────────── ref: 1 │ │ │ │ ╰─────────── ref: 4 │ │ - │ ╰─── ref: 5 + │ ╰─── unresolved ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/input.sol index 9b736be55e..b63cc756e5 100644 --- a/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/input.sol +++ b/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/input.sol @@ -1,5 +1,4 @@ library Lib { - using Lib for Lib.Value; struct Value { int x; } diff --git a/crates/solidity/testing/snapshots/bindings_output/using/min256/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/min256/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..4bdc22a2e2 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/min256/generated/0.4.11-failure.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 │ contract BasicToken { + │ ─────┬──── + │ ╰────── def: 1 + 2 │ function balanceOf() public returns (uint256); + │ ────┬──── + │ ╰────── def: 2 + │ + 4 │ contract Token is BasicToken { + │ ──┬── ─────┬──── + │ ╰────────────────── def: 3 + │ │ + │ ╰────── ref: 1 + │ + 6 │ library Lib { + │ ─┬─ + │ ╰─── def: 4 + 7 │ function min256(uint256 a) internal {} + │ ───┬── ┬ + │ ╰────────────── def: 5 + │ │ + │ ╰── def: 6 + │ + 9 │ contract Test { + │ ──┬─ + │ ╰─── def: 7 + 10 │ using Lib for uint256; + │ ─┬─ + │ ╰─── ref: 4 + 11 │ Token token; + │ ──┬── ──┬── + │ ╰────────── ref: 3 + │ │ + │ ╰──── def: 8 + 12 │ function test() public { + │ ──┬─ + │ ╰─── def: 9 + 13 │ token.balanceOf().min256(); + │ ──┬── ────┬──── ───┬── + │ ╰─────────────────────── ref: 8 + │ │ │ + │ ╰─────────────── ref: 2 + │ │ + │ ╰──── unresolved +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/min256/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/min256/input.sol new file mode 100644 index 0000000000..09b27be300 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/min256/input.sol @@ -0,0 +1,15 @@ +contract BasicToken { + function balanceOf() public returns (uint256); +} +contract Token is BasicToken { +} +library Lib { + function min256(uint256 a) internal {} +} +contract Test { + using Lib for uint256; + Token token; + function test() public { + token.balanceOf().min256(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..5afd65e4af --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.4.11-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/yul/slot_suffix/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..768d179868 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.4.11-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 Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test(bytes storage data) public { + │ ──┬─ ──┬─ + │ ╰────────────────────── def: 2 + │ │ + │ ╰─── def: 3 + │ + 4 │ let s := sload(data_slot) + │ ┬ ────┬──── + │ ╰───────────────────── def: 4 + │ │ + │ ╰────── 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..f2b5e647f7 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/input.sol @@ -0,0 +1,7 @@ +contract Test { + function test(bytes storage data) public { + assembly { + let s := sload(data_slot) + } + } +} From 28640a4d46c230b11179cc2a34f4f741c1feaa76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Fri, 1 Nov 2024 14:33:14 -0400 Subject: [PATCH 23/66] Make pushing the dynamic scope optional for libraries Both contracts and libraries can optionally push the dynamics scope when traversing to the parent lexical scope (ie. the source unit). But for libraries, they can also optionally push their name to correctly bind internal types which were extended (with `using`) by their qualified name (ie. `Lib.Type`). --- .../inputs/language/bindings/rules.msgb | 23 +++++--- .../bindings/generated/binding_rules.rs | 23 +++++--- .../src/bindings_output/generated/using.rs | 20 ++----- .../decimal/generated/0.4.11-failure.txt | 53 ------------------ .../bindings_output/using/decimal/input.sol | 13 ----- .../generated/0.4.11-failure.txt | 55 ------------------- .../using/deep_inheritance/input.sol | 15 ----- .../using/min256/generated/0.4.11-failure.txt | 49 ----------------- .../bindings_output/using/min256/input.sol | 15 ----- .../generated/0.4.11-success.txt} | 2 +- .../{fqn_library => qualified_type}/input.sol | 0 11 files changed, 34 insertions(+), 234 deletions(-) delete mode 100644 crates/solidity/testing/snapshots/bindings_output/using/decimal/generated/0.4.11-failure.txt delete mode 100644 crates/solidity/testing/snapshots/bindings_output/using/decimal/input.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/generated/0.4.11-failure.txt delete mode 100644 crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/input.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_output/using/min256/generated/0.4.11-failure.txt delete mode 100644 crates/solidity/testing/snapshots/bindings_output/using/min256/input.sol rename crates/solidity/testing/snapshots/bindings_output/using/{fqn_library/generated/0.4.11-failure.txt => qualified_type/generated/0.4.11-success.txt} (97%) rename crates/solidity/testing/snapshots/bindings_output/using/{fqn_library => qualified_type}/input.sol (100%) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index f748215f70..221d81f0b0 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -71,9 +71,7 @@ inherit .lexical_scope ;; (Most) Top-level definitions... @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @unit_member ( - [ContractDefinition] - | [LibraryDefinition] - | [InterfaceDefinition] + [InterfaceDefinition] | [StructDefinition] | [EnumDefinition] | [FunctionDefinition] @@ -92,29 +90,36 @@ inherit .lexical_scope } ;; For contracts (and libraries) navigating to the source unit lexical scope -;; *also* needs to propagate the dynamic scope to be able to correctly bind -;; `using` attached functions. +;; *also* needs to (optionally) propagate the dynamic scope to be able to +;; correctly bind `using` attached functions. @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @contract_or_library ([ContractDefinition] | [LibraryDefinition])] ]] { - ; When "leaving" the contract lexical scope, ensure that the dynamic scope - ; (ie. `using` directives extensions) is propagated + edge @source_unit.lexical_scope -> @contract_or_library.def + edge @source_unit.defs -> @contract_or_library.def + + ; When "leaving" the contract lexical scope we need to (optionally) propagate + ; the dynamic scope (ie. `using` directives extensions) node @contract_or_library.dynamic attr (@contract_or_library.dynamic) is_exported + node @contract_or_library.push_dynamic + node push attr (push) push_scoped_symbol = "@dynamic", scope = @contract_or_library.dynamic node pop attr (pop) pop_scoped_symbol = "@dynamic" - edge @contract_or_library.lexical_scope -> push + edge @contract_or_library.lexical_scope -> @contract_or_library.push_dynamic + edge @contract_or_library.push_dynamic -> push edge push -> pop edge pop -> @source_unit.lexical_scope + edge @contract_or_library.push_dynamic -> @source_unit.lexical_scope ; The .parent_scope for contracts also needs to propagate the dynamic scope ; otherwise when resolving for contract bases we lose it. This is not relevant ; for libraries, but it doesn't matter that it's defined. - let @contract_or_library.parent_scope = push + let @contract_or_library.parent_scope = @contract_or_library.push_dynamic } 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 23ce64fd0f..e769cc762a 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 @@ -76,9 +76,7 @@ inherit .lexical_scope ;; (Most) Top-level definitions... @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @unit_member ( - [ContractDefinition] - | [LibraryDefinition] - | [InterfaceDefinition] + [InterfaceDefinition] | [StructDefinition] | [EnumDefinition] | [FunctionDefinition] @@ -97,29 +95,36 @@ inherit .lexical_scope } ;; For contracts (and libraries) navigating to the source unit lexical scope -;; *also* needs to propagate the dynamic scope to be able to correctly bind -;; `using` attached functions. +;; *also* needs to (optionally) propagate the dynamic scope to be able to +;; correctly bind `using` attached functions. @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @contract_or_library ([ContractDefinition] | [LibraryDefinition])] ]] { - ; When "leaving" the contract lexical scope, ensure that the dynamic scope - ; (ie. `using` directives extensions) is propagated + edge @source_unit.lexical_scope -> @contract_or_library.def + edge @source_unit.defs -> @contract_or_library.def + + ; When "leaving" the contract lexical scope we need to (optionally) propagate + ; the dynamic scope (ie. `using` directives extensions) node @contract_or_library.dynamic attr (@contract_or_library.dynamic) is_exported + node @contract_or_library.push_dynamic + node push attr (push) push_scoped_symbol = "@dynamic", scope = @contract_or_library.dynamic node pop attr (pop) pop_scoped_symbol = "@dynamic" - edge @contract_or_library.lexical_scope -> push + edge @contract_or_library.lexical_scope -> @contract_or_library.push_dynamic + edge @contract_or_library.push_dynamic -> push edge push -> pop edge pop -> @source_unit.lexical_scope + edge @contract_or_library.push_dynamic -> @source_unit.lexical_scope ; The .parent_scope for contracts also needs to propagate the dynamic scope ; otherwise when resolving for contract bases we lose it. This is not relevant ; for libraries, but it doesn't matter that it's defined. - let @contract_or_library.parent_scope = push + let @contract_or_library.parent_scope = @contract_or_library.push_dynamic } 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 a4ad90dc91..943b122004 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 @@ -14,21 +14,11 @@ fn chained_calls() -> Result<()> { run("using", "chained_calls") } -#[test] -fn decimal() -> Result<()> { - run("using", "decimal") -} - #[test] fn deconstruction() -> Result<()> { run("using", "deconstruction") } -#[test] -fn deep_inheritance() -> Result<()> { - run("using", "deep_inheritance") -} - #[test] fn elementary() -> Result<()> { run("using", "elementary") @@ -39,11 +29,6 @@ fn elementary_arrays() -> Result<()> { run("using", "elementary_arrays") } -#[test] -fn fqn_library() -> Result<()> { - run("using", "fqn_library") -} - #[test] fn function_types() -> Result<()> { run("using", "function_types") @@ -69,6 +54,11 @@ fn on_interfaces_inherited() -> Result<()> { run("using", "on_interfaces_inherited") } +#[test] +fn qualified_type() -> Result<()> { + run("using", "qualified_type") +} + #[test] fn star() -> Result<()> { run("using", "star") diff --git a/crates/solidity/testing/snapshots/bindings_output/using/decimal/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/decimal/generated/0.4.11-failure.txt deleted file mode 100644 index 5ed3900234..0000000000 --- a/crates/solidity/testing/snapshots/bindings_output/using/decimal/generated/0.4.11-failure.txt +++ /dev/null @@ -1,53 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -References and definitions: - ╭─[input.sol:1:1] - │ - 1 │ library Decimal { - │ ───┬─── - │ ╰───── def: 1 - 2 │ struct D256 { - │ ──┬─ - │ ╰─── def: 2 - 3 │ uint256 value; - │ ──┬── - │ ╰──── def: 3 - │ - 5 │ function from(uint256 x) internal returns (D256) {} - │ ──┬─ ┬ ──┬─ - │ ╰───────────────────────────────────── def: 4 - │ │ │ - │ ╰────────────────────────── def: 5 - │ │ - │ ╰─── ref: 2 - 6 │ function div(D256 memory v) internal returns (D256) {} - │ ─┬─ ──┬─ ┬ ──┬─ - │ ╰───────────────────────────────────────── def: 6 - │ │ │ │ - │ ╰──────────────────────────────────── ref: 2 - │ │ │ - │ ╰────────────────────────── def: 7 - │ │ - │ ╰─── ref: 2 - │ - 8 │ contract Test { - │ ──┬─ - │ ╰─── def: 8 - 9 │ using Decimal for Decimal.D256; - │ ───┬─── ───┬─── ──┬─ - │ ╰────────────────────── ref: 1 - │ │ │ - │ ╰────────── ref: 1 - │ │ - │ ╰─── ref: 2 - 10 │ function test() public { - │ ──┬─ - │ ╰─── def: 9 - 11 │ Decimal.from(1).div(); - │ ───┬─── ──┬─ ─┬─ - │ ╰───────────────── ref: 1 - │ │ │ - │ ╰────────── ref: 4 - │ │ - │ ╰─── unresolved -────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/decimal/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/decimal/input.sol deleted file mode 100644 index 0eb86910a2..0000000000 --- a/crates/solidity/testing/snapshots/bindings_output/using/decimal/input.sol +++ /dev/null @@ -1,13 +0,0 @@ -library Decimal { - struct D256 { - uint256 value; - } - function from(uint256 x) internal returns (D256) {} - function div(D256 memory v) internal returns (D256) {} -} -contract Test { - using Decimal for Decimal.D256; - function test() public { - Decimal.from(1).div(); - } -} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/generated/0.4.11-failure.txt deleted file mode 100644 index f19399d68f..0000000000 --- a/crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/generated/0.4.11-failure.txt +++ /dev/null @@ -1,55 +0,0 @@ -# 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 │ contract Vars { - │ ──┬─ - │ ╰─── def: 2 - 3 │ IFoo internal constant foo = IFoo(address(0x0)); - │ ──┬─ ─┬─ ──┬─ - │ ╰──────────────────────────────── ref: 1 - │ │ │ - │ ╰────────── def: 3 - │ │ - │ ╰─── ref: 1 - │ - 5 │ library LibFoo { - │ ───┬── - │ ╰──── def: 4 - 6 │ function use_foo(IFoo f) internal {} - │ ───┬─── ──┬─ ┬ - │ ╰──────────── def: 5 - │ │ │ - │ ╰───── ref: 1 - │ │ - │ ╰── def: 6 - │ - 8 │ contract Base is Vars { - │ ──┬─ ──┬─ - │ ╰─────────── def: 7 - │ │ - │ ╰─── ref: 2 - │ - 10 │ contract Test is Base { - │ ──┬─ ──┬─ - │ ╰─────────── def: 8 - │ │ - │ ╰─── ref: 7 - 11 │ using LibFoo for IFoo; - │ ───┬── ──┬─ - │ ╰───────────── ref: 4 - │ │ - │ ╰─── ref: 1 - 12 │ function test() public { - │ ──┬─ - │ ╰─── def: 9 - 13 │ foo.use_foo(); - │ ─┬─ ───┬─── - │ ╰─────────── ref: 3 - │ │ - │ ╰───── unresolved -────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/input.sol deleted file mode 100644 index 43408a5ed4..0000000000 --- a/crates/solidity/testing/snapshots/bindings_output/using/deep_inheritance/input.sol +++ /dev/null @@ -1,15 +0,0 @@ -interface IFoo {} -contract Vars { - IFoo internal constant foo = IFoo(address(0x0)); -} -library LibFoo { - function use_foo(IFoo f) internal {} -} -contract Base is Vars { -} -contract Test is Base { - using LibFoo for IFoo; - function test() public { - foo.use_foo(); - } -} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/min256/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/min256/generated/0.4.11-failure.txt deleted file mode 100644 index 4bdc22a2e2..0000000000 --- a/crates/solidity/testing/snapshots/bindings_output/using/min256/generated/0.4.11-failure.txt +++ /dev/null @@ -1,49 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -References and definitions: - ╭─[input.sol:1:1] - │ - 1 │ contract BasicToken { - │ ─────┬──── - │ ╰────── def: 1 - 2 │ function balanceOf() public returns (uint256); - │ ────┬──── - │ ╰────── def: 2 - │ - 4 │ contract Token is BasicToken { - │ ──┬── ─────┬──── - │ ╰────────────────── def: 3 - │ │ - │ ╰────── ref: 1 - │ - 6 │ library Lib { - │ ─┬─ - │ ╰─── def: 4 - 7 │ function min256(uint256 a) internal {} - │ ───┬── ┬ - │ ╰────────────── def: 5 - │ │ - │ ╰── def: 6 - │ - 9 │ contract Test { - │ ──┬─ - │ ╰─── def: 7 - 10 │ using Lib for uint256; - │ ─┬─ - │ ╰─── ref: 4 - 11 │ Token token; - │ ──┬── ──┬── - │ ╰────────── ref: 3 - │ │ - │ ╰──── def: 8 - 12 │ function test() public { - │ ──┬─ - │ ╰─── def: 9 - 13 │ token.balanceOf().min256(); - │ ──┬── ────┬──── ───┬── - │ ╰─────────────────────── ref: 8 - │ │ │ - │ ╰─────────────── ref: 2 - │ │ - │ ╰──── unresolved -────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/min256/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/min256/input.sol deleted file mode 100644 index 09b27be300..0000000000 --- a/crates/solidity/testing/snapshots/bindings_output/using/min256/input.sol +++ /dev/null @@ -1,15 +0,0 @@ -contract BasicToken { - function balanceOf() public returns (uint256); -} -contract Token is BasicToken { -} -library Lib { - function min256(uint256 a) internal {} -} -contract Test { - using Lib for uint256; - Token token; - function test() public { - token.balanceOf().min256(); - } -} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/qualified_type/generated/0.4.11-success.txt similarity index 97% rename from crates/solidity/testing/snapshots/bindings_output/using/fqn_library/generated/0.4.11-failure.txt rename to crates/solidity/testing/snapshots/bindings_output/using/qualified_type/generated/0.4.11-success.txt index cc64b285a5..d2c34aa894 100644 --- a/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/generated/0.4.11-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/using/qualified_type/generated/0.4.11-success.txt @@ -45,5 +45,5 @@ References and definitions: │ │ │ │ ╰─────────── ref: 4 │ │ - │ ╰─── unresolved + │ ╰─── ref: 5 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/fqn_library/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/qualified_type/input.sol similarity index 100% rename from crates/solidity/testing/snapshots/bindings_output/using/fqn_library/input.sol rename to crates/solidity/testing/snapshots/bindings_output/using/qualified_type/input.sol From f7655e7884c3f217c998806bde0fa6df65dc3e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 4 Nov 2024 11:44:53 -0500 Subject: [PATCH 24/66] `_slot`/`_offset` suffixes for storage variables in Solidity < 0.7.0 --- .../inputs/language/bindings/rules.msgb | 18 +++++++++++++++++ .../bindings/generated/binding_rules.rs | 18 +++++++++++++++++ .../slot_suffix/generated/0.4.11-success.txt | 20 +++++++++++++++++++ .../{0.4.11-failure.txt => 0.7.0-failure.txt} | 0 4 files changed, 56 insertions(+) create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.4.11-success.txt rename crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/{0.4.11-failure.txt => 0.7.0-failure.txt} (100%) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 221d81f0b0..c691136ec4 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -2628,6 +2628,24 @@ inherit .lexical_scope 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)$" { + let symbol = $0 + let without_suffix = $1 + node pop_ref + attr (pop_ref) pop_symbol = symbol + node push_suffixless + attr (push_suffixless) push_symbol = without_suffix + edge ref -> pop_ref + edge pop_ref -> push_suffixless + edge push_suffixless -> @path.lexical_scope + } + } + } } @expr [YulExpression @funcall [YulFunctionCallExpression]] { 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 e769cc762a..256e736105 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 @@ -2633,6 +2633,24 @@ inherit .lexical_scope 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)$" { + let symbol = $0 + let without_suffix = $1 + node pop_ref + attr (pop_ref) pop_symbol = symbol + node push_suffixless + attr (push_suffixless) push_symbol = without_suffix + edge ref -> pop_ref + edge pop_ref -> push_suffixless + edge push_suffixless -> @path.lexical_scope + } + } + } } @expr [YulExpression @funcall [YulFunctionCallExpression]] { 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..431def7d7e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/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 Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test(bytes storage data) public { + │ ──┬─ ──┬─ + │ ╰────────────────────── def: 2 + │ │ + │ ╰─── def: 3 + │ + 4 │ let s := sload(data_slot) + │ ┬ ────┬──── + │ ╰───────────────────── def: 4 + │ │ + │ ╰────── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.7.0-failure.txt similarity index 100% rename from crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.4.11-failure.txt rename to crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/generated/0.7.0-failure.txt From b3bcf54d075c94bde3c62758ef86ccf7c42879f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 4 Nov 2024 14:14:01 -0500 Subject: [PATCH 25/66] Bind to the output of both operands for all arithmetic and bitwise operations --- crates/solidity/inputs/language/bindings/rules.msgb | 13 ++++++------- .../generated/bindings/generated/binding_rules.rs | 13 ++++++------- .../{0.4.11-failure.txt => 0.4.11-success.txt} | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) rename crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/{0.4.11-failure.txt => 0.4.11-success.txt} (93%) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index c691136ec4..d24e0de9ba 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -2289,7 +2289,7 @@ inherit .lexical_scope ;;; Arithmetic, bitwise & logical operators, etc -; Bind to the left operand only: assignment expressions, shift expressions, exponentiation +; Bind to the left operand only: assignment expressions @expr [Expression [_ @left_operand left_operand: [Expression] ( @@ -2305,12 +2305,6 @@ inherit .lexical_scope | [LessThanLessThanEqual] | [GreaterThanGreaterThanEqual] | [GreaterThanGreaterThanGreaterThanEqual] - - | [LessThanLessThan] - | [GreaterThanGreaterThan] - | [GreaterThanGreaterThanGreaterThan] - - | [AsteriskAsterisk] ) ]] { edge @expr.output -> @left_operand.output @@ -2344,10 +2338,15 @@ inherit .lexical_scope | [Asterisk] | [Slash] | [Percent] + | [AsteriskAsterisk] | [Bar] | [Caret] | [Ampersand] + + | [LessThanLessThan] + | [GreaterThanGreaterThan] + | [GreaterThanGreaterThanGreaterThan] ) @right_operand right_operand: [Expression] ]] { 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 256e736105..3136bb3812 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 @@ -2294,7 +2294,7 @@ inherit .lexical_scope ;;; Arithmetic, bitwise & logical operators, etc -; Bind to the left operand only: assignment expressions, shift expressions, exponentiation +; Bind to the left operand only: assignment expressions @expr [Expression [_ @left_operand left_operand: [Expression] ( @@ -2310,12 +2310,6 @@ inherit .lexical_scope | [LessThanLessThanEqual] | [GreaterThanGreaterThanEqual] | [GreaterThanGreaterThanGreaterThanEqual] - - | [LessThanLessThan] - | [GreaterThanGreaterThan] - | [GreaterThanGreaterThanGreaterThan] - - | [AsteriskAsterisk] ) ]] { edge @expr.output -> @left_operand.output @@ -2349,10 +2343,15 @@ inherit .lexical_scope | [Asterisk] | [Slash] | [Percent] + | [AsteriskAsterisk] | [Bar] | [Caret] | [Ampersand] + + | [LessThanLessThan] + | [GreaterThanGreaterThan] + | [GreaterThanGreaterThanGreaterThan] ) @right_operand right_operand: [Expression] ]] { diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/0.4.11-success.txt similarity index 93% rename from crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/0.4.11-failure.txt rename to crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/0.4.11-success.txt index 9b4c04dca3..e00ce09b33 100644 --- a/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/0.4.11-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/literal_integers/generated/0.4.11-success.txt @@ -23,5 +23,5 @@ References and definitions: │ ╰─── def: 5 7 │ (50 * 10**uint(4)).nop(); │ ─┬─ - │ ╰─── unresolved + │ ╰─── ref: 2 ───╯ From d6b7174070f8fc659ee972d73a0e29e3069cad6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 4 Nov 2024 14:44:54 -0500 Subject: [PATCH 26/66] Bind legacy call options `.value()` and `.gas()` on Solidity < 0.7.0 --- .../inputs/language/src/definition.rs | 18 ++++++++++ .../bindings/generated/built_ins/0.4.11.sol | 4 +++ .../bindings/generated/built_ins/0.4.17.sol | 4 +++ .../bindings/generated/built_ins/0.4.22.sol | 4 +++ .../bindings/generated/built_ins/0.5.0.sol | 4 +++ .../bindings/generated/built_ins/0.5.3.sol | 4 +++ .../bindings/generated/built_ins/0.6.0.sol | 4 +++ .../bindings/generated/built_ins/0.6.2.sol | 4 +++ .../bindings/generated/built_ins/0.6.7.sol | 4 +++ .../bindings/generated/built_ins/0.6.8.sol | 4 +++ .../bindings/generated/built_ins/0.7.0.sol | 2 ++ .../bindings/generated/built_ins/0.8.0.sol | 2 ++ .../bindings/generated/built_ins/0.8.11.sol | 2 ++ .../bindings/generated/built_ins/0.8.18.sol | 2 ++ .../bindings/generated/built_ins/0.8.2.sol | 2 ++ .../bindings/generated/built_ins/0.8.24.sol | 2 ++ .../bindings/generated/built_ins/0.8.26.sol | 2 ++ .../bindings/generated/built_ins/0.8.7.sol | 2 ++ .../generated/0.4.11-success.txt | 35 +++++++++++++++++++ .../{0.4.11-failure.txt => 0.7.0-failure.txt} | 0 .../address/generated/0.4.11-failure.txt | 2 +- .../address/generated/0.4.21-failure.txt | 2 +- .../using/address/generated/0.5.0-failure.txt | 2 +- .../using/address/generated/0.5.3-failure.txt | 2 +- 24 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.4.11-success.txt rename crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/{0.4.11-failure.txt => 0.7.0-failure.txt} (100%) diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 20dbf11d6e..58cfd537a2 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -6908,6 +6908,24 @@ codegen_language_macros::compile!(Language( functions = [], enabled = From("0.6.2") ), + BuiltInType( + name = "$function", + fields = [], + functions = [ + BuiltInFunction( + name = "gas", + parameters = ["uint"], + return_type = "$function", + enabled = Till("0.7.0") + ), + BuiltInFunction( + name = "value", + parameters = ["uint"], + return_type = "$function", + enabled = Till("0.7.0") + ) + ] + ), BuiltInType( name = "$functionExternal", fields = [ 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 81dbee099a..1200054cc4 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 @@ -52,6 +52,10 @@ contract $BuiltIns$ { struct $bytesType { function($args) returns (bytes memory) concat; } + struct $function { + function(uint) returns ($function) gas; + function(uint) returns ($function) value; + } struct $functionExternal { function(uint) returns ($function) gas; function(uint) returns ($function) value; 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 898c64b554..7975fd0f93 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 @@ -52,6 +52,10 @@ contract $BuiltIns$ { struct $bytesType { function($args) returns (bytes memory) concat; } + struct $function { + function(uint) returns ($function) gas; + function(uint) returns ($function) value; + } struct $functionExternal { $selector selector; function(uint) returns ($function) gas; 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 a10f43f9b5..4abc23481a 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 @@ -60,6 +60,10 @@ contract $BuiltIns$ { struct $bytesType { function($args) returns (bytes memory) concat; } + struct $function { + function(uint) returns ($function) gas; + function(uint) returns ($function) value; + } struct $functionExternal { $selector selector; function(uint) returns ($function) gas; 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 d41f1095ca..0a5cadd73e 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 @@ -58,6 +58,10 @@ contract $BuiltIns$ { struct $bytesType { function($args) returns (bytes memory) concat; } + struct $function { + function(uint) returns ($function) gas; + function(uint) returns ($function) value; + } struct $functionExternal { $selector selector; function(uint) returns ($function) gas; 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 262b93ae9f..d298a5a423 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 @@ -58,6 +58,10 @@ contract $BuiltIns$ { struct $bytesType { function($args) returns (bytes memory) concat; } + struct $function { + function(uint) returns ($function) gas; + function(uint) returns ($function) value; + } struct $functionExternal { $selector selector; function(uint) returns ($function) gas; 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 9c965fc50f..7ca66792d4 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 @@ -59,6 +59,10 @@ contract $BuiltIns$ { struct $bytesType { function($args) returns (bytes memory) concat; } + struct $function { + function(uint) returns ($function) gas; + function(uint) returns ($function) value; + } struct $functionExternal { $selector selector; function(uint) returns ($function) gas; 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 5fee7a66c8..be95f2d7e9 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 @@ -64,6 +64,10 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $function { + function(uint) returns ($function) gas; + function(uint) returns ($function) value; + } struct $functionExternal { $selector selector; function(uint) returns ($function) gas; 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 18adb3237f..1dd6124537 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 @@ -64,6 +64,10 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $function { + function(uint) returns ($function) gas; + function(uint) returns ($function) value; + } struct $functionExternal { $selector selector; function(uint) returns ($function) gas; 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 7d8991cdfb..53a13eef7a 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 @@ -64,6 +64,10 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $function { + function(uint) returns ($function) gas; + function(uint) returns ($function) value; + } struct $functionExternal { $selector selector; function(uint) returns ($function) gas; 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 a69834dc2b..634b34c165 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 @@ -64,6 +64,8 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $function { + } struct $functionExternal { $selector selector; } 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 2f2a6e3b37..9168eb3f39 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 @@ -62,6 +62,8 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $function { + } struct $functionExternal { $selector selector; } 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 f17cd6d7fb..8a262fd48c 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 @@ -64,6 +64,8 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $function { + } struct $functionExternal { $address address; $selector selector; 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 d88b1009ce..d345826c37 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 @@ -65,6 +65,8 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $function { + } struct $functionExternal { $address address; $selector selector; 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 b0baecea97..582fea1a9e 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 @@ -62,6 +62,8 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $function { + } struct $functionExternal { $address address; $selector selector; 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 3999e03748..2d9e339b52 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 @@ -67,6 +67,8 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $function { + } struct $functionExternal { $address address; $selector selector; 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 4a5e8dfe13..4cafdaf287 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 @@ -68,6 +68,8 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $function { + } struct $functionExternal { $address address; $selector selector; 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 3ae9be4fb1..0718a05647 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 @@ -63,6 +63,8 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $function { + } struct $functionExternal { $address address; $selector selector; 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.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.7.0-failure.txt similarity index 100% rename from crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.4.11-failure.txt rename to crates/solidity/testing/snapshots/bindings_output/expressions/legacy_call_options/generated/0.7.0-failure.txt 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 index d0f6e9d6e6..97aeb1b768 100644 --- 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 @@ -1,7 +1,7 @@ # 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 ThrowKeyword or TrueKeyword or UfixedKeyword or UintKeyword or VarKeyword or WhileKeyword. +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(); 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 index d5ac8d4d66..d4bb34a55a 100644 --- 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 @@ -1,7 +1,7 @@ # 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 ThrowKeyword or TrueKeyword or UfixedKeyword or UintKeyword or VarKeyword or WhileKeyword. +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(); 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 index 6eea708e96..d1ae8bf8e8 100644 --- 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 @@ -1,7 +1,7 @@ # 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 TrueKeyword or UfixedKeyword or UintKeyword or WhileKeyword. +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(); 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 index e4173ecbdd..05a55cb7be 100644 --- 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 @@ -1,7 +1,7 @@ # 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 TrueKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. +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(); From 5ec110baac1f23faeaea9fd5023dde459756fc23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 4 Nov 2024 15:14:33 -0500 Subject: [PATCH 27/66] Bind user defined types `.wrap()` and `.unwrap()` --- .../inputs/language/bindings/rules.msgb | 17 +++ .../inputs/language/src/definition.rs | 17 +++ .../bindings/generated/binding_rules.rs | 17 +++ .../generated/bindings/generated/built_ins.rs | 4 +- .../bindings/generated/built_ins/0.8.11.sol | 4 + .../bindings/generated/built_ins/0.8.18.sol | 4 + .../bindings/generated/built_ins/0.8.24.sol | 4 + .../bindings/generated/built_ins/0.8.26.sol | 4 + .../bindings/generated/built_ins/0.8.8.sol | 112 ++++++++++++++++++ .../{0.8.8-failure.txt => 0.8.8-success.txt} | 4 +- 10 files changed, 184 insertions(+), 3 deletions(-) create mode 100644 crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.8.sol rename crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/{0.8.8-failure.txt => 0.8.8-success.txt} (95%) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index d24e0de9ba..b9c3742b3e 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -2073,6 +2073,23 @@ inherit .lexical_scope attr (def) definiens_node = @user_type edge @user_type.def -> def + + ; 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 = "%userTypeType" + + edge def -> member_guard + edge member_guard -> member + edge member -> typeof + edge typeof -> user_type_type + edge user_type_type -> @user_type.lexical_scope } diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 58cfd537a2..d009df13d3 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -7009,6 +7009,23 @@ codegen_language_macros::compile!(Language( ], functions = [] ), + BuiltInType( + name = "$userTypeType", + fields = [], + functions = [ + BuiltInFunction( + name = "wrap", + parameters = ["$elementaryType"], + return_type = "$userType" + ), + BuiltInFunction( + name = "unwrap", + parameters = ["$userType"], + return_type = "$elementaryType" + ) + ], + enabled = From("0.8.8") + ), BuiltInVariable(definition = "$function $placeholder"), BuiltInVariable(definition = "$abiType abi"), BuiltInVariable(definition = "$blockType block"), 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 3136bb3812..b2cd299366 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 @@ -2078,6 +2078,23 @@ inherit .lexical_scope attr (def) definiens_node = @user_type edge @user_type.def -> def + + ; 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 = "%userTypeType" + + edge def -> member_guard + edge member_guard -> member + edge member -> typeof + edge typeof -> user_type_type + edge user_type_type -> @user_type.lexical_scope } 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..099369364a 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 @@ -28,8 +28,10 @@ pub fn get_contents(version: &Version) -> &'static str { include_str!("./built_ins/0.8.0.sol") } else if *version < Version::new(0, 8, 7) { include_str!("./built_ins/0.8.2.sol") - } else if *version < Version::new(0, 8, 11) { + } 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.8.11.sol b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.11.sol index 8a262fd48c..56b745dce8 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 @@ -97,6 +97,10 @@ contract $BuiltIns$ { int min; int max; } + struct $userTypeType { + function($elementaryType) returns ($userType) wrap; + function($userType) returns ($elementaryType) unwrap; + } $function $placeholder; $abiType abi; $blockType block; 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 d345826c37..83240fb25f 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 @@ -98,6 +98,10 @@ contract $BuiltIns$ { int min; int max; } + struct $userTypeType { + function($elementaryType) returns ($userType) wrap; + function($userType) returns ($elementaryType) unwrap; + } $function $placeholder; $abiType abi; $blockType block; 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 2d9e339b52..5d7f6fe9fa 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 @@ -100,6 +100,10 @@ contract $BuiltIns$ { int min; int max; } + struct $userTypeType { + function($elementaryType) returns ($userType) wrap; + function($userType) returns ($elementaryType) unwrap; + } $function $placeholder; $abiType abi; $blockType block; 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 4cafdaf287..7f495934d7 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 @@ -101,6 +101,10 @@ contract $BuiltIns$ { int min; int max; } + struct $userTypeType { + function($elementaryType) returns ($userType) wrap; + function($userType) returns ($elementaryType) unwrap; + } $function $placeholder; $abiType abi; $blockType block; 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..e6345261cc --- /dev/null +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.8.sol @@ -0,0 +1,112 @@ +// 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, $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 $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) returns (bool) send; + function(bytes memory) returns (bool, bytes memory) staticcall; + function(uint256) transfer; + } + struct $array { + uint length; + function(uint) returns ($element) $index; + function() returns ($element) push; + function($element) push; + function() pop; + } + struct $arrayFixed { + uint length; + function(uint) returns ($element) $index; + } + struct $blockType { + uint basefee; + uint chainid; + address payable coinbase; + uint difficulty; + uint gaslimit; + uint number; + uint timestamp; + } + struct $bytes { + uint length; + } + struct $bytesType { + function($args) returns (bytes memory) concat; + } + struct $callOptions { + uint gas; + uint salt; + uint value; + } + struct $function { + } + struct $functionExternal { + $address $address; + $selector selector; + } + struct $msgType { + bytes data; + address sender; + bytes4 sig; + uint value; + } + struct $stringType { + function($args) returns (string memory) concat; + } + struct $txType { + uint gasprice; + address origin; + } + struct $typeContractType { + string name; + bytes creationCode; + bytes runtimeCode; + bytes4 interfaceId; + } + struct $typeInterfaceType { + string name; + bytes4 interfaceId; + } + struct $typeIntType { + int min; + int max; + } + struct $userTypeType { + function($elementaryType) returns ($userType) wrap; + function($userType) returns ($elementaryType) unwrap; + } + $function $placeholder; + $abiType abi; + $blockType block; + $bytesType $bytes; + $msgType msg; + $stringType $string; + $SuperType super; + $ThisType this; + $txType tx; +} diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.8-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.8-success.txt similarity index 95% rename from crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.8-failure.txt rename to crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.8-success.txt index 5040c83fd9..0563a6f694 100644 --- a/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.8-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/wrap_unwrap/generated/0.8.8-success.txt @@ -23,14 +23,14 @@ References and definitions: │ │ │ │ │ ╰───────────────── ref: 1 │ │ │ - │ ╰──────── unresolved + │ ╰──────── ref: built-in │ │ │ ╰─── ref: 4 6 │ ShortString.unwrap(s); │ ─────┬───── ───┬── ┬ │ ╰──────────────── ref: 1 │ │ │ - │ ╰────── unresolved + │ ╰────── ref: built-in │ │ │ ╰── ref: 5 ───╯ From ac139866c4b8c47eb5b1a6998af2bcb502969033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 4 Nov 2024 15:33:55 -0500 Subject: [PATCH 28/66] Allow binding attached functions on typed casted expressions Applying a function call with a type will always return a value of that type, so a symbol stack `type,()` is equivalent to `type,@typeof`. Reflect on the binding entry point of the using clause. --- .../inputs/language/bindings/rules.msgb | 4 ++ .../bindings/generated/binding_rules.rs | 4 ++ .../{0.6.0-failure.txt => 0.6.0-success.txt} | 2 +- .../generated/0.4.11-success.txt | 48 +++++++++++++++++++ .../{0.4.11-failure.txt => 0.7.0-failure.txt} | 0 5 files changed, 57 insertions(+), 1 deletion(-) rename crates/solidity/testing/snapshots/bindings_output/using/address/generated/{0.6.0-failure.txt => 0.6.0-success.txt} (95%) create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.4.11-success.txt rename crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/{0.4.11-failure.txt => 0.7.0-failure.txt} (100%) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index b9c3742b3e..9b06d48c2a 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -833,10 +833,14 @@ 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 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 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 b2cd299366..ffa86d17ab 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 @@ -838,10 +838,14 @@ 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 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 diff --git a/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.6.0-success.txt similarity index 95% rename from crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.6.0-failure.txt rename to crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.6.0-success.txt index 0257951997..48d9b99f62 100644 --- a/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.6.0-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/using/address/generated/0.6.0-success.txt @@ -27,5 +27,5 @@ References and definitions: │ ──┬── ────┬──── │ ╰─────────────── ref: 6 │ │ - │ ╰────── unresolved + │ ╰────── ref: 2 ───╯ 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.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.7.0-failure.txt similarity index 100% rename from crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.4.11-failure.txt rename to crates/solidity/testing/snapshots/bindings_output/using/on_interfaces_inherited/generated/0.7.0-failure.txt From 6a560d5e6c640b35a74930cf7999ef242a0976d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 4 Nov 2024 16:01:40 -0500 Subject: [PATCH 29/66] Bind modifiers in libraries --- crates/solidity/inputs/language/bindings/rules.msgb | 13 +++++++++++++ .../generated/bindings/generated/binding_rules.rs | 13 +++++++++++++ .../{0.4.11-failure.txt => 0.4.11-success.txt} | 4 ++-- 3 files changed, 28 insertions(+), 2 deletions(-) rename crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/{0.4.11-failure.txt => 0.4.11-success.txt} (94%) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 9b06d48c2a..8554c99fb1 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -713,8 +713,14 @@ inherit .lexical_scope node @library.lexical_scope node @library.def node @library.members + node @library.modifiers edge @library.lexical_scope -> @library.members + + node modifier + attr (modifier) pop_symbol = "@modifier" + edge @library.members -> modifier + edge modifier -> @library.modifiers } @library [LibraryDefinition @name name: [Identifier]] { @@ -767,6 +773,13 @@ inherit .lexical_scope edge @library.members -> @member.def } +@library [LibraryDefinition [LibraryMembers + [ContractMember @modifier [ModifierDefinition]] +]] { + edge @library.modifiers -> @modifier.def + edge @modifier.lexical_scope -> @library.lexical_scope +} + @library [LibraryDefinition [LibraryMembers [ContractMember @using [UsingDirective]] ]] { 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 ffa86d17ab..17a42c7b7f 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 @@ -718,8 +718,14 @@ inherit .lexical_scope node @library.lexical_scope node @library.def node @library.members + node @library.modifiers edge @library.lexical_scope -> @library.members + + node modifier + attr (modifier) pop_symbol = "@modifier" + edge @library.members -> modifier + edge modifier -> @library.modifiers } @library [LibraryDefinition @name name: [Identifier]] { @@ -772,6 +778,13 @@ inherit .lexical_scope edge @library.members -> @member.def } +@library [LibraryDefinition [LibraryMembers + [ContractMember @modifier [ModifierDefinition]] +]] { + edge @library.modifiers -> @modifier.def + edge @modifier.lexical_scope -> @library.lexical_scope +} + @library [LibraryDefinition [LibraryMembers [ContractMember @using [UsingDirective]] ]] { diff --git a/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-success.txt similarity index 94% rename from crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-failure.txt rename to crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-success.txt index 7bd6f21b6e..3fa6594466 100644 --- a/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/libraries/modifiers/generated/0.4.11-success.txt @@ -11,11 +11,11 @@ References and definitions: │ ╰─────── def: 2 3 │ _; │ ┬ - │ ╰── unresolved + │ ╰── ref: built-in │ 5 │ function test() internal withinRange() {} │ ──┬─ ─────┬───── │ ╰────────────────────────── def: 3 │ │ - │ ╰─────── unresolved + │ ╰─────── ref: 2 ───╯ From 4df6b5447ea0d90e8cb5eebd506f02a238e283d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 4 Nov 2024 16:36:29 -0500 Subject: [PATCH 30/66] Bind legacy constructor parent invocations These are parsed as modifiers, and they need a similar treatment as parent constructor calls in new constructor definitions. --- .../inputs/language/bindings/rules.msgb | 19 +++++++++++++++++- .../bindings/generated/binding_rules.rs | 19 +++++++++++++++++- .../generated/0.4.11-success.txt | 20 +++++++++++++++++++ .../{0.4.11-failure.txt => 0.5.0-failure.txt} | 0 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.4.11-success.txt rename crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/{0.4.11-failure.txt => 0.5.0-failure.txt} (100%) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 8554c99fb1..f03c957c28 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -1377,7 +1377,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 @@ -1393,6 +1395,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 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 17a42c7b7f..c35fe17d8e 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 @@ -1382,7 +1382,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 @@ -1398,6 +1400,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 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.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.5.0-failure.txt similarity index 100% rename from crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.4.11-failure.txt rename to crates/solidity/testing/snapshots/bindings_output/contracts/legacy_constructors/generated/0.5.0-failure.txt From 6268c9de43206e0dcc32d26e103775e9e0ff9d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 4 Nov 2024 17:03:27 -0500 Subject: [PATCH 31/66] Allow qualified access to bind to internal members of parent contract --- crates/solidity/inputs/language/bindings/rules.msgb | 2 ++ .../generated/bindings/generated/binding_rules.rs | 2 ++ .../generated/0.4.11-failure.txt | 13 ------------- .../{0.6.0-failure.txt => 0.4.11-success.txt} | 8 ++++---- .../contracts/qualified_inherited/input.sol | 2 +- 5 files changed, 9 insertions(+), 18 deletions(-) delete mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.4.11-failure.txt rename crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/{0.6.0-failure.txt => 0.4.11-success.txt} (82%) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index f03c957c28..e3cb320648 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -315,6 +315,8 @@ inherit .lexical_scope edge heir.lexical_scope -> @type_name.pop_begin edge @type_name.pop_end -> member_pop edge member_pop -> member + ; Qualified access should also allow us to bind internal members of the parent contract + edge member_pop -> internal ;; Make base defs (eg. enums and structs) accessible as our own node type_member 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 c35fe17d8e..cfee44540a 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 @@ -320,6 +320,8 @@ inherit .lexical_scope edge heir.lexical_scope -> @type_name.pop_begin edge @type_name.pop_end -> member_pop edge member_pop -> member + ; Qualified access should also allow us to bind internal members of the parent contract + edge member_pop -> internal ;; Make base defs (eg. enums and structs) accessible as our own node type_member diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.4.11-failure.txt deleted file mode 100644 index 585e829d2c..0000000000 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.4.11-failure.txt +++ /dev/null @@ -1,13 +0,0 @@ -# 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 Base { - ┆ ┆ - 8 │ ├─▶ } - │ │ - │ ╰─────── Error occurred here. -───╯ -References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.4.11-success.txt similarity index 82% rename from crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.6.0-failure.txt rename to crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.4.11-success.txt index 797e64ac01..da81507f48 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.6.0-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/generated/0.4.11-success.txt @@ -3,9 +3,9 @@ References and definitions: ╭─[input.sol:1:1] │ - 1 │ abstract contract Base { - │ ──┬─ - │ ╰─── def: 1 + 1 │ contract Base { + │ ──┬─ + │ ╰─── def: 1 2 │ bool renounced; │ ────┬──── │ ╰────── def: 2 @@ -22,5 +22,5 @@ References and definitions: │ ──┬─ ────┬──── │ ╰───────────── ref: 1 │ │ - │ ╰────── unresolved + │ ╰────── 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 index e9918df72c..bc9b730d79 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/input.sol +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_inherited/input.sol @@ -1,4 +1,4 @@ -abstract contract Base { +contract Base { bool renounced; } contract Test is Base { From d8b5d903bf116c07def06a5c95dd258949955d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 4 Nov 2024 17:41:26 -0500 Subject: [PATCH 32/66] Resolve qualified members in any position in the inheritance chain This changes how the internal scope for contracts is laid out. Instead of linking everything (state vars, functions, parent bases) to the lexical scope, this is now done to an internal node, which then links to the lexical scope. The lexical scope also contains the path to apply any dynamic scope changes set in the contract (eg. any `using` directives). --- crates/solidity/inputs/language/bindings/rules.msgb | 11 ++++++----- .../src/generated/bindings/generated/binding_rules.rs | 11 ++++++----- .../{0.4.11-failure.txt => 0.4.11-success.txt} | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) rename crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/{0.4.11-failure.txt => 0.4.11-success.txt} (95%) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index e3cb320648..12b657b05b 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -305,14 +305,13 @@ inherit .lexical_scope ; be accessed) node internal attr (internal) push_symbol = "@internal" - edge heir.lexical_scope -> internal edge heir.internal -> internal edge internal -> @type_name.push_begin ; Base members can also be accessed qualified with the base name (eg. `Base.something`) node member_pop attr (member_pop) pop_symbol = "." - edge heir.lexical_scope -> @type_name.pop_begin + edge heir.internal -> @type_name.pop_begin edge @type_name.pop_end -> member_pop edge member_pop -> member ; Qualified access should also allow us to bind internal members of the parent contract @@ -361,9 +360,11 @@ inherit .lexical_scope node @contract.state_vars node @contract.internal - edge @contract.lexical_scope -> @contract.members - edge @contract.lexical_scope -> @contract.type_members - edge @contract.lexical_scope -> @contract.state_vars + edge @contract.lexical_scope -> @contract.internal + + edge @contract.internal -> @contract.members + edge @contract.internal -> @contract.type_members + edge @contract.internal -> @contract.state_vars ;; Modifiers are available as a contract type members through a special '@modifier' symbol node modifier 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 cfee44540a..b106ccded9 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 @@ -310,14 +310,13 @@ inherit .lexical_scope ; be accessed) node internal attr (internal) push_symbol = "@internal" - edge heir.lexical_scope -> internal edge heir.internal -> internal edge internal -> @type_name.push_begin ; Base members can also be accessed qualified with the base name (eg. `Base.something`) node member_pop attr (member_pop) pop_symbol = "." - edge heir.lexical_scope -> @type_name.pop_begin + edge heir.internal -> @type_name.pop_begin edge @type_name.pop_end -> member_pop edge member_pop -> member ; Qualified access should also allow us to bind internal members of the parent contract @@ -366,9 +365,11 @@ inherit .lexical_scope node @contract.state_vars node @contract.internal - edge @contract.lexical_scope -> @contract.members - edge @contract.lexical_scope -> @contract.type_members - edge @contract.lexical_scope -> @contract.state_vars + edge @contract.lexical_scope -> @contract.internal + + edge @contract.internal -> @contract.members + edge @contract.internal -> @contract.type_members + edge @contract.internal -> @contract.state_vars ;; Modifiers are available as a contract type members through a special '@modifier' symbol node modifier diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/0.4.11-success.txt similarity index 95% rename from crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/0.4.11-failure.txt rename to crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/0.4.11-success.txt index 13c3339463..e0763a81c8 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/0.4.11-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/qualified_parent_call/generated/0.4.11-success.txt @@ -27,5 +27,5 @@ References and definitions: │ ──┬─ ───┬─── │ ╰─────────── ref: 1 │ │ - │ ╰───── unresolved + │ ╰───── ref: 2 ───╯ From 92f5ebc98a1f874f5e8a51d065c172bdadc284a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 5 Nov 2024 11:06:17 -0500 Subject: [PATCH 33/66] Support `.selector` field for custom error types --- .../inputs/language/bindings/rules.msgb | 9 ++ .../inputs/language/src/definition.rs | 6 + .../bindings/generated/binding_rules.rs | 9 ++ .../generated/bindings/generated/built_ins.rs | 4 +- .../bindings/generated/built_ins/0.8.11.sol | 3 + .../bindings/generated/built_ins/0.8.18.sol | 3 + .../bindings/generated/built_ins/0.8.24.sol | 3 + .../bindings/generated/built_ins/0.8.26.sol | 3 + .../bindings/generated/built_ins/0.8.4.sol | 110 ++++++++++++++++++ .../bindings/generated/built_ins/0.8.7.sol | 3 + .../bindings/generated/built_ins/0.8.8.sol | 3 + .../src/bindings_output/generated/errors.rs | 5 + .../selector/generated/0.4.11-failure.txt | 31 +++++ .../selector/generated/0.8.4-success.txt | 21 ++++ .../bindings_output/errors/selector/input.sol | 7 ++ 15 files changed, 219 insertions(+), 1 deletion(-) create mode 100644 crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.4.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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 12b657b05b..5748cad196 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -2056,6 +2056,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 diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index d009df13d3..2e113d3cc3 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -6908,6 +6908,12 @@ codegen_language_macros::compile!(Language( functions = [], enabled = From("0.6.2") ), + BuiltInType( + name = "$errorType", + fields = [BuiltInField(definition = "bytes4 selector")], + functions = [], + enabled = From("0.8.4") + ), BuiltInType( name = "$function", fields = [], 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 b106ccded9..2e747b653e 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 @@ -2061,6 +2061,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 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 099369364a..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,8 +26,10 @@ 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, 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) { 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 56b745dce8..e6af4ae8b8 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 @@ -64,6 +64,9 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $errorType { + bytes4 selector; + } struct $function { } struct $functionExternal { 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 83240fb25f..d667976120 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 @@ -65,6 +65,9 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $errorType { + bytes4 selector; + } struct $function { } struct $functionExternal { 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 5d7f6fe9fa..fda66ce25b 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 @@ -67,6 +67,9 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $errorType { + bytes4 selector; + } struct $function { } struct $functionExternal { 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 7f495934d7..e12f9bddd7 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 @@ -68,6 +68,9 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $errorType { + bytes4 selector; + } struct $function { } struct $functionExternal { 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..de7ad0ae0f --- /dev/null +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/built_ins/0.8.4.sol @@ -0,0 +1,110 @@ +// 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, $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 $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) returns (bool) send; + function(bytes memory) returns (bool, bytes memory) staticcall; + function(uint256) transfer; + } + struct $array { + uint length; + function(uint) returns ($element) $index; + function() returns ($element) push; + function($element) push; + function() pop; + } + struct $arrayFixed { + uint length; + function(uint) returns ($element) $index; + } + struct $blockType { + uint chainid; + address payable coinbase; + uint difficulty; + uint gaslimit; + uint number; + uint timestamp; + } + struct $bytes { + uint length; + } + struct $bytesType { + function($args) returns (bytes memory) concat; + } + struct $callOptions { + uint gas; + uint salt; + uint value; + } + struct $errorType { + bytes4 selector; + } + struct $function { + } + struct $functionExternal { + $address $address; + $selector selector; + } + struct $msgType { + bytes data; + address sender; + bytes4 sig; + uint value; + } + struct $stringType { + function($args) returns (string memory) concat; + } + struct $txType { + uint gasprice; + address origin; + } + struct $typeContractType { + string name; + bytes creationCode; + bytes runtimeCode; + bytes4 interfaceId; + } + struct $typeInterfaceType { + string name; + bytes4 interfaceId; + } + struct $typeIntType { + int min; + int max; + } + $function $placeholder; + $abiType abi; + $blockType block; + $bytesType $bytes; + $msgType msg; + $stringType $string; + $SuperType super; + $ThisType this; + $txType 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 0718a05647..661ca1e963 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 @@ -63,6 +63,9 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $errorType { + bytes4 selector; + } struct $function { } struct $functionExternal { 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 index e6345261cc..7ecd85850d 100644 --- 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 @@ -63,6 +63,9 @@ contract $BuiltIns$ { uint salt; uint value; } + struct $errorType { + bytes4 selector; + } struct $function { } struct $functionExternal { 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/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; + } +} From f798acd2721b9407a9ad192a048b0a2bc03da6f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 5 Nov 2024 15:30:31 -0500 Subject: [PATCH 34/66] Binding rules: remove @contract.state_vars, rename type_members to ns --- .../inputs/language/bindings/rules.msgb | 59 +++++++++---------- .../bindings/generated/binding_rules.rs | 59 +++++++++---------- .../bindings/generated/built_ins/0.8.4.sol | 4 +- .../bindings/generated/built_ins/0.8.8.sol | 4 +- 4 files changed, 56 insertions(+), 70 deletions(-) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 5748cad196..9faf84b1d9 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -133,9 +133,7 @@ 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.internal } } @@ -318,11 +316,11 @@ inherit .lexical_scope edge member_pop -> internal ;; Make base defs (eg. enums and structs) accessible as our own - node type_member - attr (type_member) push_symbol = "." + node ns_member + attr (ns_member) push_symbol = "." - edge heir.type_members -> type_member - edge type_member -> @type_name.push_begin + edge heir.ns -> ns_member + edge ns_member -> @type_name.push_begin ; Resolve the "super" keyword to the inherited type edge heir.super -> @type_name.push_begin @@ -355,21 +353,19 @@ inherit .lexical_scope node @contract.super_scope node @contract.def node @contract.members - node @contract.type_members + node @contract.ns node @contract.modifiers - node @contract.state_vars node @contract.internal edge @contract.lexical_scope -> @contract.internal edge @contract.internal -> @contract.members - edge @contract.internal -> @contract.type_members - edge @contract.internal -> @contract.state_vars + edge @contract.internal -> @contract.ns ;; 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 @contract.ns -> modifier edge modifier -> @contract.modifiers let @contract.enclosing_def = @contract.def @@ -415,10 +411,10 @@ inherit .lexical_scope edge push_name -> JUMP_TO_SCOPE_NODE ;; "namespace" like access path - node type_member - attr (type_member) pop_symbol = "." - edge @contract.def -> type_member - edge type_member -> @contract.type_members + node ns_member + attr (ns_member) pop_symbol = "." + edge @contract.def -> ns_member + edge ns_member -> @contract.ns ; Finally there's an @internal path used by derived contracts to access our internal state variables node internal @@ -541,14 +537,12 @@ inherit .lexical_scope | [UserDefinedValueTypeDefinition] )] ]] { - edge @contract.type_members -> @member.def + 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 express that because we don't have negative assertions in our @@ -583,7 +577,7 @@ inherit .lexical_scope ]] ]] { ; public or external functions are also accessible through the contract type - edge @contract.type_members -> @function.def + edge @contract.ns -> @function.def } @contract [ContractDefinition members: [ContractMembers @@ -613,12 +607,12 @@ inherit .lexical_scope node @interface.lexical_scope node @interface.def node @interface.members - node @interface.type_members + node @interface.ns ; this is unused in interfaces, but required for the inheritance rules node @interface.internal edge @interface.lexical_scope -> @interface.members - edge @interface.lexical_scope -> @interface.type_members + edge @interface.lexical_scope -> @interface.ns } @interface [InterfaceDefinition @name name: [Identifier]] { @@ -654,10 +648,10 @@ inherit .lexical_scope 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 ; Path to resolve the built-in type for type() expressions node type @@ -688,7 +682,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 @@ -715,14 +709,15 @@ inherit .lexical_scope @library [LibraryDefinition] { node @library.lexical_scope node @library.def - node @library.members + node @library.ns node @library.modifiers - edge @library.lexical_scope -> @library.members + edge @library.lexical_scope -> @library.ns + ; Access to modifiers is guarded by a @modifier symbol node modifier attr (modifier) pop_symbol = "@modifier" - edge @library.members -> modifier + edge @library.ns -> modifier edge modifier -> @library.modifiers } @@ -734,7 +729,7 @@ inherit .lexical_scope attr (member) pop_symbol = "." edge @library.def -> member - edge member -> @library.members + edge member -> @library.ns ; Path to resolve the built-in type for type() expressions (same as contracts) node type @@ -773,7 +768,7 @@ inherit .lexical_scope )] ]] { edge @member.lexical_scope -> @library.lexical_scope - edge @library.members -> @member.def + edge @library.ns -> @member.def } @library [LibraryDefinition [LibraryMembers 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 2e747b653e..34870f94f2 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 @@ -138,9 +138,7 @@ 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.internal } } @@ -323,11 +321,11 @@ inherit .lexical_scope edge member_pop -> internal ;; Make base defs (eg. enums and structs) accessible as our own - node type_member - attr (type_member) push_symbol = "." + node ns_member + attr (ns_member) push_symbol = "." - edge heir.type_members -> type_member - edge type_member -> @type_name.push_begin + edge heir.ns -> ns_member + edge ns_member -> @type_name.push_begin ; Resolve the "super" keyword to the inherited type edge heir.super -> @type_name.push_begin @@ -360,21 +358,19 @@ inherit .lexical_scope node @contract.super_scope node @contract.def node @contract.members - node @contract.type_members + node @contract.ns node @contract.modifiers - node @contract.state_vars node @contract.internal edge @contract.lexical_scope -> @contract.internal edge @contract.internal -> @contract.members - edge @contract.internal -> @contract.type_members - edge @contract.internal -> @contract.state_vars + edge @contract.internal -> @contract.ns ;; 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 @contract.ns -> modifier edge modifier -> @contract.modifiers let @contract.enclosing_def = @contract.def @@ -420,10 +416,10 @@ inherit .lexical_scope edge push_name -> JUMP_TO_SCOPE_NODE ;; "namespace" like access path - node type_member - attr (type_member) pop_symbol = "." - edge @contract.def -> type_member - edge type_member -> @contract.type_members + node ns_member + attr (ns_member) pop_symbol = "." + edge @contract.def -> ns_member + edge ns_member -> @contract.ns ; Finally there's an @internal path used by derived contracts to access our internal state variables node internal @@ -546,14 +542,12 @@ inherit .lexical_scope | [UserDefinedValueTypeDefinition] )] ]] { - edge @contract.type_members -> @member.def + 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 express that because we don't have negative assertions in our @@ -588,7 +582,7 @@ inherit .lexical_scope ]] ]] { ; public or external functions are also accessible through the contract type - edge @contract.type_members -> @function.def + edge @contract.ns -> @function.def } @contract [ContractDefinition members: [ContractMembers @@ -618,12 +612,12 @@ inherit .lexical_scope node @interface.lexical_scope node @interface.def node @interface.members - node @interface.type_members + node @interface.ns ; this is unused in interfaces, but required for the inheritance rules node @interface.internal edge @interface.lexical_scope -> @interface.members - edge @interface.lexical_scope -> @interface.type_members + edge @interface.lexical_scope -> @interface.ns } @interface [InterfaceDefinition @name name: [Identifier]] { @@ -659,10 +653,10 @@ inherit .lexical_scope 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 ; Path to resolve the built-in type for type() expressions node type @@ -693,7 +687,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 @@ -720,14 +714,15 @@ inherit .lexical_scope @library [LibraryDefinition] { node @library.lexical_scope node @library.def - node @library.members + node @library.ns node @library.modifiers - edge @library.lexical_scope -> @library.members + edge @library.lexical_scope -> @library.ns + ; Access to modifiers is guarded by a @modifier symbol node modifier attr (modifier) pop_symbol = "@modifier" - edge @library.members -> modifier + edge @library.ns -> modifier edge modifier -> @library.modifiers } @@ -739,7 +734,7 @@ inherit .lexical_scope attr (member) pop_symbol = "." edge @library.def -> member - edge member -> @library.members + edge member -> @library.ns ; Path to resolve the built-in type for type() expressions (same as contracts) node type @@ -778,7 +773,7 @@ inherit .lexical_scope )] ]] { edge @member.lexical_scope -> @library.lexical_scope - edge @library.members -> @member.def + edge @library.ns -> @member.def } @library [LibraryDefinition [LibraryMembers 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 index de7ad0ae0f..1b600047e3 100644 --- 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 @@ -68,7 +68,7 @@ contract $BuiltIns$ { struct $function { } struct $functionExternal { - $address $address; + $address address; $selector selector; } struct $msgType { @@ -104,7 +104,5 @@ contract $BuiltIns$ { $bytesType $bytes; $msgType msg; $stringType $string; - $SuperType super; - $ThisType this; $txType 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 index 7ecd85850d..f053df3115 100644 --- 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 @@ -69,7 +69,7 @@ contract $BuiltIns$ { struct $function { } struct $functionExternal { - $address $address; + $address address; $selector selector; } struct $msgType { @@ -109,7 +109,5 @@ contract $BuiltIns$ { $bytesType $bytes; $msgType msg; $stringType $string; - $SuperType super; - $ThisType this; $txType tx; } From 6725fe5ea199e0e7d3efd20f6ca4019983d04a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 5 Nov 2024 16:51:57 -0500 Subject: [PATCH 35/66] Define `super` and push `using` extensions only when necessary --- .../inputs/language/bindings/rules.msgb | 138 ++++++++++-------- .../bindings/generated/binding_rules.rs | 138 ++++++++++-------- 2 files changed, 150 insertions(+), 126 deletions(-) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 9faf84b1d9..70b70217f5 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -63,8 +63,8 @@ inherit .lexical_scope ;; override specifiers) let @source_unit.parent_scope = @source_unit.lexical_scope - ; We may jump to scope here to resolve using the dynamic scope provided by - ; extensions declared with `using` directive + ; 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 } @@ -90,7 +90,7 @@ inherit .lexical_scope } ;; For contracts (and libraries) navigating to the source unit lexical scope -;; *also* needs to (optionally) propagate the dynamic scope to be able to +;; *also* needs to (optionally) propagate an extensions scope to be able to ;; correctly bind `using` attached functions. @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @contract_or_library ([ContractDefinition] | [LibraryDefinition])] @@ -98,28 +98,29 @@ inherit .lexical_scope edge @source_unit.lexical_scope -> @contract_or_library.def edge @source_unit.defs -> @contract_or_library.def - ; When "leaving" the contract lexical scope we need to (optionally) propagate - ; the dynamic scope (ie. `using` directives extensions) - node @contract_or_library.dynamic - attr (@contract_or_library.dynamic) is_exported + ; When "leaving" the contract lexical scope to the parent scope (ie. the + ; source unit) we need to (optionally) propagate the extensions scope (ie. + ; `using` directives extensions). Thus we introduce a parent_node and we will + ; connect the path to push the extensions *if* the contract/library has a + ; `using` directive. - node @contract_or_library.push_dynamic + node @contract_or_library.parent_scope + edge @contract_or_library.lexical_scope -> @contract_or_library.parent_scope + edge @contract_or_library.parent_scope -> @source_unit.lexical_scope - node push - attr (push) push_scoped_symbol = "@dynamic", scope = @contract_or_library.dynamic - node pop - attr (pop) pop_scoped_symbol = "@dynamic" + ; This .extensions node is where `using` directives will hook + node @contract_or_library.extensions + attr (@contract_or_library.extensions) is_exported - edge @contract_or_library.lexical_scope -> @contract_or_library.push_dynamic - edge @contract_or_library.push_dynamic -> push - edge push -> pop - edge pop -> @source_unit.lexical_scope - edge @contract_or_library.push_dynamic -> @source_unit.lexical_scope + ; Now we define the path to push the .extensions scope into the scope stack + 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 pop_extensions + attr (pop_extensions) pop_scoped_symbol = "@extend" - ; The .parent_scope for contracts also needs to propagate the dynamic scope - ; otherwise when resolving for contract bases we lose it. This is not relevant - ; for libraries, but it doesn't matter that it's defined. - let @contract_or_library.parent_scope = @contract_or_library.push_dynamic + edge @contract_or_library.push_extensions -> pop_extensions + edge pop_extensions -> @source_unit.lexical_scope } @@ -350,7 +351,6 @@ inherit .lexical_scope @contract [ContractDefinition] { node @contract.lexical_scope - node @contract.super_scope node @contract.def node @contract.members node @contract.ns @@ -372,10 +372,19 @@ inherit .lexical_scope if (version-matches "< 0.7.0") { ; In Solidity < 0.7.0 using directives are inherited to derived contracts. - ; Hence we make out dynamic scope accessible through members, which is accessible + ; Hence we make our extensions scope accessible through members, which is accessible ; from derived contract's lexical scopes. - edge @contract.members -> @contract.dynamic + edge @contract.members -> @contract.extensions } + + ; Path to resolve the built-in type for type() expressions + node type + attr (type) pop_symbol = "%type" + node type_contract_type + attr (type_contract_type) push_symbol = "%typeContractType" + edge @contract.def -> type + edge type -> type_contract_type + edge type_contract_type -> @contract.lexical_scope } @contract [ContractDefinition @name name: [Identifier]] { @@ -399,9 +408,9 @@ inherit .lexical_scope edge @contract.def -> call edge call -> member - ; From a call we may need to resolve using the dynamic scope, in case there's - ; a `using` directive on our type. This path ends up jumping to scope just to - ; handle that case. + ; 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 @@ -447,11 +456,34 @@ inherit .lexical_scope edge address_ref -> @contract.lexical_scope } + ;; This defines the sink of edges added from base contracts when setting this + ;; contract as the compilation context + attr (@contract.def) export_node = @contract.internal + + ;; 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 + 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 + attr (@contract.def) import_nodes = [@contract.lexical_scope, @contract.super_import] +} + +@contract [ContractDefinition @specifier [InheritanceSpecifier]] { + let @specifier.heir = @contract + attr (@contract.def) parents = @specifier.parent_refs + + node @contract.super_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" @@ -464,35 +496,9 @@ inherit .lexical_scope ; NOTE: The keyword "super" itself resolves to each of its parent contracts. ; See the related rules in the InheritanceSpecifier section above. - ;; 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 - - ;; 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 - - ;; 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] - - ; Path to resolve the built-in type for type() expressions - node type - attr (type) pop_symbol = "%type" - node type_contract_type - attr (type_contract_type) push_symbol = "%typeContractType" - edge @contract.def -> type - edge type -> type_contract_type - edge type_contract_type -> @contract.lexical_scope -} - -@contract [ContractDefinition @specifier [InheritanceSpecifier]] { - let @specifier.heir = @contract - attr (@contract.def) parents = @specifier.parent_refs + ; This connects `super` to exported scopes from all contracts in the hierarchy + ; when setting a contract compilation target + edge @contract.super -> @contract.super_import } @contract [ContractDefinition [InheritanceSpecifier [InheritanceTypes @@ -524,8 +530,11 @@ inherit .lexical_scope @contract [ContractDefinition [ContractMembers [ContractMember @using [UsingDirective]] ]] { - ; Expose the using directive from the dynamic scope - edge @contract.dynamic -> @using.def + ; Expose the using directive from the extensions scope + edge @contract.extensions -> @using.def + + ; Connect the extensions push path + edge @contract.parent_scope -> @contract.push_extensions } @contract [ContractDefinition [ContractMembers @@ -636,7 +645,7 @@ inherit .lexical_scope edge @interface.def -> call edge call -> member - ; From a call we may need to resolve using the dynamic scope, in case there's + ; 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 @@ -744,7 +753,7 @@ inherit .lexical_scope ; symbol stack. This allows a local symbol (eg. a struct) defined and resolved ; in this library to be fully qualified in order for `using` directives that ; attach our own functions to our own types to be used (see - ; bindings_output/using/fqn_library test). + ; bindings_output/using/qualified_type test). ; TODO: we should probably apply this same pattern to aliases from import ; statements. node push_member @@ -781,8 +790,11 @@ inherit .lexical_scope @library [LibraryDefinition [LibraryMembers [ContractMember @using [UsingDirective]] ]] { - ; Expose the using directive from the dynamic scope - edge @library.dynamic -> @using.def + ; Expose the using directive from the extensions scope + edge @library.extensions -> @using.def + + ; Connect the extensions push path + edge @library.parent_scope -> @library.push_extensions } 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 34870f94f2..4eab35f309 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 @@ -68,8 +68,8 @@ inherit .lexical_scope ;; override specifiers) let @source_unit.parent_scope = @source_unit.lexical_scope - ; We may jump to scope here to resolve using the dynamic scope provided by - ; extensions declared with `using` directive + ; 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 } @@ -95,7 +95,7 @@ inherit .lexical_scope } ;; For contracts (and libraries) navigating to the source unit lexical scope -;; *also* needs to (optionally) propagate the dynamic scope to be able to +;; *also* needs to (optionally) propagate an extensions scope to be able to ;; correctly bind `using` attached functions. @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @contract_or_library ([ContractDefinition] | [LibraryDefinition])] @@ -103,28 +103,29 @@ inherit .lexical_scope edge @source_unit.lexical_scope -> @contract_or_library.def edge @source_unit.defs -> @contract_or_library.def - ; When "leaving" the contract lexical scope we need to (optionally) propagate - ; the dynamic scope (ie. `using` directives extensions) - node @contract_or_library.dynamic - attr (@contract_or_library.dynamic) is_exported + ; When "leaving" the contract lexical scope to the parent scope (ie. the + ; source unit) we need to (optionally) propagate the extensions scope (ie. + ; `using` directives extensions). Thus we introduce a parent_node and we will + ; connect the path to push the extensions *if* the contract/library has a + ; `using` directive. - node @contract_or_library.push_dynamic + node @contract_or_library.parent_scope + edge @contract_or_library.lexical_scope -> @contract_or_library.parent_scope + edge @contract_or_library.parent_scope -> @source_unit.lexical_scope - node push - attr (push) push_scoped_symbol = "@dynamic", scope = @contract_or_library.dynamic - node pop - attr (pop) pop_scoped_symbol = "@dynamic" + ; This .extensions node is where `using` directives will hook + node @contract_or_library.extensions + attr (@contract_or_library.extensions) is_exported - edge @contract_or_library.lexical_scope -> @contract_or_library.push_dynamic - edge @contract_or_library.push_dynamic -> push - edge push -> pop - edge pop -> @source_unit.lexical_scope - edge @contract_or_library.push_dynamic -> @source_unit.lexical_scope + ; Now we define the path to push the .extensions scope into the scope stack + 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 pop_extensions + attr (pop_extensions) pop_scoped_symbol = "@extend" - ; The .parent_scope for contracts also needs to propagate the dynamic scope - ; otherwise when resolving for contract bases we lose it. This is not relevant - ; for libraries, but it doesn't matter that it's defined. - let @contract_or_library.parent_scope = @contract_or_library.push_dynamic + edge @contract_or_library.push_extensions -> pop_extensions + edge pop_extensions -> @source_unit.lexical_scope } @@ -355,7 +356,6 @@ inherit .lexical_scope @contract [ContractDefinition] { node @contract.lexical_scope - node @contract.super_scope node @contract.def node @contract.members node @contract.ns @@ -377,10 +377,19 @@ inherit .lexical_scope if (version-matches "< 0.7.0") { ; In Solidity < 0.7.0 using directives are inherited to derived contracts. - ; Hence we make out dynamic scope accessible through members, which is accessible + ; Hence we make our extensions scope accessible through members, which is accessible ; from derived contract's lexical scopes. - edge @contract.members -> @contract.dynamic + edge @contract.members -> @contract.extensions } + + ; Path to resolve the built-in type for type() expressions + node type + attr (type) pop_symbol = "%type" + node type_contract_type + attr (type_contract_type) push_symbol = "%typeContractType" + edge @contract.def -> type + edge type -> type_contract_type + edge type_contract_type -> @contract.lexical_scope } @contract [ContractDefinition @name name: [Identifier]] { @@ -404,9 +413,9 @@ inherit .lexical_scope edge @contract.def -> call edge call -> member - ; From a call we may need to resolve using the dynamic scope, in case there's - ; a `using` directive on our type. This path ends up jumping to scope just to - ; handle that case. + ; 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 @@ -452,11 +461,34 @@ inherit .lexical_scope edge address_ref -> @contract.lexical_scope } + ;; This defines the sink of edges added from base contracts when setting this + ;; contract as the compilation context + attr (@contract.def) export_node = @contract.internal + + ;; 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 + 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 + attr (@contract.def) import_nodes = [@contract.lexical_scope, @contract.super_import] +} + +@contract [ContractDefinition @specifier [InheritanceSpecifier]] { + let @specifier.heir = @contract + attr (@contract.def) parents = @specifier.parent_refs + + node @contract.super_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" @@ -469,35 +501,9 @@ inherit .lexical_scope ; NOTE: The keyword "super" itself resolves to each of its parent contracts. ; See the related rules in the InheritanceSpecifier section above. - ;; 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 - - ;; 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 - - ;; 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] - - ; Path to resolve the built-in type for type() expressions - node type - attr (type) pop_symbol = "%type" - node type_contract_type - attr (type_contract_type) push_symbol = "%typeContractType" - edge @contract.def -> type - edge type -> type_contract_type - edge type_contract_type -> @contract.lexical_scope -} - -@contract [ContractDefinition @specifier [InheritanceSpecifier]] { - let @specifier.heir = @contract - attr (@contract.def) parents = @specifier.parent_refs + ; This connects `super` to exported scopes from all contracts in the hierarchy + ; when setting a contract compilation target + edge @contract.super -> @contract.super_import } @contract [ContractDefinition [InheritanceSpecifier [InheritanceTypes @@ -529,8 +535,11 @@ inherit .lexical_scope @contract [ContractDefinition [ContractMembers [ContractMember @using [UsingDirective]] ]] { - ; Expose the using directive from the dynamic scope - edge @contract.dynamic -> @using.def + ; Expose the using directive from the extensions scope + edge @contract.extensions -> @using.def + + ; Connect the extensions push path + edge @contract.parent_scope -> @contract.push_extensions } @contract [ContractDefinition [ContractMembers @@ -641,7 +650,7 @@ inherit .lexical_scope edge @interface.def -> call edge call -> member - ; From a call we may need to resolve using the dynamic scope, in case there's + ; 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 @@ -749,7 +758,7 @@ inherit .lexical_scope ; symbol stack. This allows a local symbol (eg. a struct) defined and resolved ; in this library to be fully qualified in order for `using` directives that ; attach our own functions to our own types to be used (see - ; bindings_output/using/fqn_library test). + ; bindings_output/using/qualified_type test). ; TODO: we should probably apply this same pattern to aliases from import ; statements. node push_member @@ -786,8 +795,11 @@ inherit .lexical_scope @library [LibraryDefinition [LibraryMembers [ContractMember @using [UsingDirective]] ]] { - ; Expose the using directive from the dynamic scope - edge @library.dynamic -> @using.def + ; Expose the using directive from the extensions scope + edge @library.extensions -> @using.def + + ; Connect the extensions push path + edge @library.parent_scope -> @library.push_extensions } From ad343acfca89b931f38512a089e7f2bddc264dee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Wed, 6 Nov 2024 17:58:25 -0500 Subject: [PATCH 36/66] Reworked how resolution interacts with `using` directive extensions Both libraries and contracts now have two separate resolution scopes: `.lexical_scope` and `.extended_scope`. The extended scope connects back to the lexical scope by pushing into the scope stack any extensions introduced by `using` directives. Hence, this extended scope is used to resolve function bodies, function parameters and any other tree node that may contain an expression that uses the `using` attached functions. Also, the `using` definition path now circles back to the parent scope through the extended scope, thus pushing again the same extension scope, to correctly handle chained calls, ie. when we need to resolve to attached functions multiple times in the same resolution. --- .../inputs/language/bindings/rules.msgb | 175 +++++++++++------- .../bindings/generated/binding_rules.rs | 175 +++++++++++------- .../bindings_output/generated/interfaces.rs | 13 +- .../src/bindings_output/generated/using.rs | 10 + .../generated/0.4.11-success.txt | 23 +++ .../interfaces/own_types_access/input.sol | 6 + .../casting}/generated/0.4.11-success.txt | 0 .../casting}/input.sol | 0 .../generated/0.4.11-success.txt | 0 .../inherited_types}/input.sol | 0 10 files changed, 261 insertions(+), 141 deletions(-) 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 rename crates/solidity/testing/snapshots/bindings_output/{interfaces/casting_dynamic_scope => using/casting}/generated/0.4.11-success.txt (100%) rename crates/solidity/testing/snapshots/bindings_output/{interfaces/casting_dynamic_scope => using/casting}/input.sol (100%) rename crates/solidity/testing/snapshots/bindings_output/{interfaces/inherit_dynamic_scope => using/inherited_types}/generated/0.4.11-success.txt (100%) rename crates/solidity/testing/snapshots/bindings_output/{interfaces/inherit_dynamic_scope => using/inherited_types}/input.sol (100%) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 70b70217f5..f38336d8ab 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -21,6 +21,7 @@ inherit .enclosing_def inherit .parent_scope inherit .lexical_scope +inherit .extended_scope ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -62,16 +63,21 @@ 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 } -;; (Most) Top-level definitions... +;; Top-level definitions... @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @unit_member ( - [InterfaceDefinition] + [ContractDefinition] + | [LibraryDefinition] + | [InterfaceDefinition] | [StructDefinition] | [EnumDefinition] | [FunctionDefinition] @@ -89,24 +95,31 @@ inherit .lexical_scope 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 +} + + ;; 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. -@source_unit [SourceUnit [SourceUnitMembers +[SourceUnit [SourceUnitMembers [SourceUnitMember @contract_or_library ([ContractDefinition] | [LibraryDefinition])] ]] { - edge @source_unit.lexical_scope -> @contract_or_library.def - edge @source_unit.defs -> @contract_or_library.def - ; When "leaving" the contract lexical scope to the parent scope (ie. the ; source unit) we need to (optionally) propagate the extensions scope (ie. ; `using` directives extensions). Thus we introduce a parent_node and we will ; connect the path to push the extensions *if* the contract/library has a ; `using` directive. - node @contract_or_library.parent_scope - edge @contract_or_library.lexical_scope -> @contract_or_library.parent_scope - edge @contract_or_library.parent_scope -> @source_unit.lexical_scope + node @contract_or_library.extended_scope + edge @contract_or_library.extended_scope -> @contract_or_library.lexical_scope ; This .extensions node is where `using` directives will hook node @contract_or_library.extensions @@ -120,7 +133,7 @@ inherit .lexical_scope attr (pop_extensions) pop_scoped_symbol = "@extend" edge @contract_or_library.push_extensions -> pop_extensions - edge pop_extensions -> @source_unit.lexical_scope + edge pop_extensions -> @contract_or_library.lexical_scope } @@ -437,7 +450,7 @@ inherit .lexical_scope edge this -> member ;; ... and make it available in the contract's lexical scope - edge @contract.lexical_scope -> this + edge @contract.extended_scope -> this ; Resolve the "this" keyword to the contract itself node name_push @@ -490,8 +503,9 @@ inherit .lexical_scope 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 + ;; Finally make "super" available in the contract's extended lexical scope for + ;; function bodies to use + edge @contract.extended_scope -> @contract.super ; NOTE: The keyword "super" itself resolves to each of its parent contracts. ; See the related rules in the InheritanceSpecifier section above. @@ -508,6 +522,7 @@ inherit .lexical_scope edge @contract.super_scope -> @type_name.push_begin } +; Pure definitions that cannot contain expressions @contract [ContractDefinition [ContractMembers [ContractMember @member ( [EnumDefinition] @@ -515,16 +530,27 @@ 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 @@ -534,7 +560,7 @@ inherit .lexical_scope edge @contract.extensions -> @using.def ; Connect the extensions push path - edge @contract.parent_scope -> @contract.push_extensions + edge @contract.extended_scope -> @contract.push_extensions } @contract [ContractDefinition [ContractMembers @@ -622,6 +648,7 @@ inherit .lexical_scope edge @interface.lexical_scope -> @interface.members edge @interface.lexical_scope -> @interface.ns + let @interface.extended_scope = @interface.lexical_scope } @interface [InterfaceDefinition @name name: [Identifier]] { @@ -699,8 +726,8 @@ 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]]]] { @@ -748,31 +775,14 @@ inherit .lexical_scope edge @library.def -> type edge type -> type_library_type edge type_library_type -> @library.lexical_scope - - ; Provide a path to the parent lexical context that pushes our own name to the - ; symbol stack. This allows a local symbol (eg. a struct) defined and resolved - ; in this library to be fully qualified in order for `using` directives that - ; attach our own functions to our own types to be used (see - ; bindings_output/using/qualified_type test). - ; TODO: we should probably apply this same pattern to aliases from import - ; statements. - node push_member - attr (push_member) push_symbol = "." - node push_name - attr (push_name) push_symbol = (source-text @name) - edge @library.lexical_scope -> push_member - edge push_member -> push_name - edge push_name -> @library.parent_scope } @library [LibraryDefinition [LibraryMembers [ContractMember @member ( - [FunctionDefinition] - | [EnumDefinition] + [EnumDefinition] | [StructDefinition] | [EventDefinition] | [ErrorDefinition] - | [StateVariableDefinition [StateVariableAttributes [StateVariableAttribute [ConstantKeyword]]]] | [UserDefinedValueTypeDefinition] )] ]] { @@ -780,6 +790,17 @@ inherit .lexical_scope 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]] ]] { @@ -794,7 +815,7 @@ inherit .lexical_scope edge @library.extensions -> @using.def ; Connect the extensions push path - edge @library.parent_scope -> @library.push_extensions + edge @library.extended_scope -> @library.push_extensions } @@ -818,7 +839,7 @@ inherit .lexical_scope @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 @@ -859,13 +880,16 @@ inherit .lexical_scope 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 + ; resolve the target type of the directive on the extended scope so the + ; extension scope gets re-pushed edge @type_name.type_ref -> @using.lexical_scope } @@ -897,6 +921,7 @@ inherit .lexical_scope 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]] { @@ -911,6 +936,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])] { @@ -918,6 +944,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]] { @@ -1159,6 +1186,14 @@ inherit .lexical_scope ;; position in the path, from left to right. Useful for the using directive 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 attr (@name.ref) node_reference = @name @@ -1166,6 +1201,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] .] { @@ -1241,6 +1278,7 @@ inherit .lexical_scope } node @function.lexical_scope + node @function.extended_scope node @function.def ; this path from the function definition to the scope allows attaching @@ -1260,12 +1298,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 @@ -1277,9 +1315,9 @@ inherit .lexical_scope edge @return_params.lexical_scope -> @function.lexical_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 @@ -1296,13 +1334,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]] { @@ -1326,17 +1364,18 @@ inherit .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.lexical_scope + edge @params.lexical_scope -> @unnamed_function.extended_scope - edge @unnamed_function.lexical_scope -> @params.defs - attr (@unnamed_function.lexical_scope -> @params.defs) precedence = 1 + 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.lexical_scope + edge @block.lexical_scope -> @unnamed_function.extended_scope } @unnamed_function [UnnamedFunctionDefinition @@ -1353,16 +1392,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 @@ -1370,13 +1410,13 @@ 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 } @@ -1427,14 +1467,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 @@ -1443,12 +1484,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 @@ -1459,10 +1500,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 @@ -1479,6 +1521,7 @@ inherit .lexical_scope @modifier [ModifierDefinition] { node @modifier.def node @modifier.lexical_scope + node @modifier.extended_scope } @modifier [ModifierDefinition @@ -1488,7 +1531,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. @@ -1503,11 +1546,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 } 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 4eab35f309..c8ed3fe57f 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,7 @@ inherit .enclosing_def inherit .parent_scope inherit .lexical_scope +inherit .extended_scope ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -67,16 +68,21 @@ 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 } -;; (Most) Top-level definitions... +;; Top-level definitions... @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember @unit_member ( - [InterfaceDefinition] + [ContractDefinition] + | [LibraryDefinition] + | [InterfaceDefinition] | [StructDefinition] | [EnumDefinition] | [FunctionDefinition] @@ -94,24 +100,31 @@ inherit .lexical_scope 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 +} + + ;; 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. -@source_unit [SourceUnit [SourceUnitMembers +[SourceUnit [SourceUnitMembers [SourceUnitMember @contract_or_library ([ContractDefinition] | [LibraryDefinition])] ]] { - edge @source_unit.lexical_scope -> @contract_or_library.def - edge @source_unit.defs -> @contract_or_library.def - ; When "leaving" the contract lexical scope to the parent scope (ie. the ; source unit) we need to (optionally) propagate the extensions scope (ie. ; `using` directives extensions). Thus we introduce a parent_node and we will ; connect the path to push the extensions *if* the contract/library has a ; `using` directive. - node @contract_or_library.parent_scope - edge @contract_or_library.lexical_scope -> @contract_or_library.parent_scope - edge @contract_or_library.parent_scope -> @source_unit.lexical_scope + node @contract_or_library.extended_scope + edge @contract_or_library.extended_scope -> @contract_or_library.lexical_scope ; This .extensions node is where `using` directives will hook node @contract_or_library.extensions @@ -125,7 +138,7 @@ inherit .lexical_scope attr (pop_extensions) pop_scoped_symbol = "@extend" edge @contract_or_library.push_extensions -> pop_extensions - edge pop_extensions -> @source_unit.lexical_scope + edge pop_extensions -> @contract_or_library.lexical_scope } @@ -442,7 +455,7 @@ inherit .lexical_scope edge this -> member ;; ... and make it available in the contract's lexical scope - edge @contract.lexical_scope -> this + edge @contract.extended_scope -> this ; Resolve the "this" keyword to the contract itself node name_push @@ -495,8 +508,9 @@ inherit .lexical_scope 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 + ;; Finally make "super" available in the contract's extended lexical scope for + ;; function bodies to use + edge @contract.extended_scope -> @contract.super ; NOTE: The keyword "super" itself resolves to each of its parent contracts. ; See the related rules in the InheritanceSpecifier section above. @@ -513,6 +527,7 @@ inherit .lexical_scope edge @contract.super_scope -> @type_name.push_begin } +; Pure definitions that cannot contain expressions @contract [ContractDefinition [ContractMembers [ContractMember @member ( [EnumDefinition] @@ -520,16 +535,27 @@ 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 @@ -539,7 +565,7 @@ inherit .lexical_scope edge @contract.extensions -> @using.def ; Connect the extensions push path - edge @contract.parent_scope -> @contract.push_extensions + edge @contract.extended_scope -> @contract.push_extensions } @contract [ContractDefinition [ContractMembers @@ -627,6 +653,7 @@ inherit .lexical_scope edge @interface.lexical_scope -> @interface.members edge @interface.lexical_scope -> @interface.ns + let @interface.extended_scope = @interface.lexical_scope } @interface [InterfaceDefinition @name name: [Identifier]] { @@ -704,8 +731,8 @@ 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]]]] { @@ -753,31 +780,14 @@ inherit .lexical_scope edge @library.def -> type edge type -> type_library_type edge type_library_type -> @library.lexical_scope - - ; Provide a path to the parent lexical context that pushes our own name to the - ; symbol stack. This allows a local symbol (eg. a struct) defined and resolved - ; in this library to be fully qualified in order for `using` directives that - ; attach our own functions to our own types to be used (see - ; bindings_output/using/qualified_type test). - ; TODO: we should probably apply this same pattern to aliases from import - ; statements. - node push_member - attr (push_member) push_symbol = "." - node push_name - attr (push_name) push_symbol = (source-text @name) - edge @library.lexical_scope -> push_member - edge push_member -> push_name - edge push_name -> @library.parent_scope } @library [LibraryDefinition [LibraryMembers [ContractMember @member ( - [FunctionDefinition] - | [EnumDefinition] + [EnumDefinition] | [StructDefinition] | [EventDefinition] | [ErrorDefinition] - | [StateVariableDefinition [StateVariableAttributes [StateVariableAttribute [ConstantKeyword]]]] | [UserDefinedValueTypeDefinition] )] ]] { @@ -785,6 +795,17 @@ inherit .lexical_scope 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]] ]] { @@ -799,7 +820,7 @@ inherit .lexical_scope edge @library.extensions -> @using.def ; Connect the extensions push path - edge @library.parent_scope -> @library.push_extensions + edge @library.extended_scope -> @library.push_extensions } @@ -823,7 +844,7 @@ inherit .lexical_scope @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 @@ -864,13 +885,16 @@ inherit .lexical_scope 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 + ; resolve the target type of the directive on the extended scope so the + ; extension scope gets re-pushed edge @type_name.type_ref -> @using.lexical_scope } @@ -902,6 +926,7 @@ inherit .lexical_scope 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]] { @@ -916,6 +941,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])] { @@ -923,6 +949,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]] { @@ -1164,6 +1191,14 @@ inherit .lexical_scope ;; position in the path, from left to right. Useful for the using directive 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 attr (@name.ref) node_reference = @name @@ -1171,6 +1206,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] .] { @@ -1246,6 +1283,7 @@ inherit .lexical_scope } node @function.lexical_scope + node @function.extended_scope node @function.def ; this path from the function definition to the scope allows attaching @@ -1265,12 +1303,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 @@ -1282,9 +1320,9 @@ inherit .lexical_scope edge @return_params.lexical_scope -> @function.lexical_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 @@ -1301,13 +1339,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]] { @@ -1331,17 +1369,18 @@ inherit .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.lexical_scope + edge @params.lexical_scope -> @unnamed_function.extended_scope - edge @unnamed_function.lexical_scope -> @params.defs - attr (@unnamed_function.lexical_scope -> @params.defs) precedence = 1 + 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.lexical_scope + edge @block.lexical_scope -> @unnamed_function.extended_scope } @unnamed_function [UnnamedFunctionDefinition @@ -1358,16 +1397,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 @@ -1375,13 +1415,13 @@ 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 } @@ -1432,14 +1472,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 @@ -1448,12 +1489,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 @@ -1464,10 +1505,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 @@ -1484,6 +1526,7 @@ inherit .lexical_scope @modifier [ModifierDefinition] { node @modifier.def node @modifier.lexical_scope + node @modifier.extended_scope } @modifier [ModifierDefinition @@ -1493,7 +1536,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. @@ -1508,11 +1551,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 } 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 a2c66dd277..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 @@ -5,18 +5,13 @@ use anyhow::Result; use crate::bindings_output::runner::run; #[test] -fn casting_dynamic_scope() -> Result<()> { - run("interfaces", "casting_dynamic_scope") -} - -#[test] -fn inherit_dynamic_scope() -> Result<()> { - run("interfaces", "inherit_dynamic_scope") +fn inheritance() -> Result<()> { + run("interfaces", "inheritance") } #[test] -fn inheritance() -> Result<()> { - run("interfaces", "inheritance") +fn own_types_access() -> Result<()> { + run("interfaces", "own_types_access") } #[test] 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 943b122004..075690eb02 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 @@ -9,6 +9,11 @@ fn address() -> Result<()> { run("using", "address") } +#[test] +fn casting() -> Result<()> { + run("using", "casting") +} + #[test] fn chained_calls() -> Result<()> { run("using", "chained_calls") @@ -49,6 +54,11 @@ fn in_library() -> Result<()> { run("using", "in_library") } +#[test] +fn inherited_types() -> Result<()> { + run("using", "inherited_types") +} + #[test] fn on_interfaces_inherited() -> Result<()> { run("using", "on_interfaces_inherited") 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/interfaces/casting_dynamic_scope/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/casting/generated/0.4.11-success.txt similarity index 100% rename from crates/solidity/testing/snapshots/bindings_output/interfaces/casting_dynamic_scope/generated/0.4.11-success.txt rename to crates/solidity/testing/snapshots/bindings_output/using/casting/generated/0.4.11-success.txt diff --git a/crates/solidity/testing/snapshots/bindings_output/interfaces/casting_dynamic_scope/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/casting/input.sol similarity index 100% rename from crates/solidity/testing/snapshots/bindings_output/interfaces/casting_dynamic_scope/input.sol rename to crates/solidity/testing/snapshots/bindings_output/using/casting/input.sol diff --git a/crates/solidity/testing/snapshots/bindings_output/interfaces/inherit_dynamic_scope/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/inherited_types/generated/0.4.11-success.txt similarity index 100% rename from crates/solidity/testing/snapshots/bindings_output/interfaces/inherit_dynamic_scope/generated/0.4.11-success.txt rename to crates/solidity/testing/snapshots/bindings_output/using/inherited_types/generated/0.4.11-success.txt diff --git a/crates/solidity/testing/snapshots/bindings_output/interfaces/inherit_dynamic_scope/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/inherited_types/input.sol similarity index 100% rename from crates/solidity/testing/snapshots/bindings_output/interfaces/inherit_dynamic_scope/input.sol rename to crates/solidity/testing/snapshots/bindings_output/using/inherited_types/input.sol From 5c4754a7bc556e5a2f5d4f6ee8b42fa84e8074db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 7 Nov 2024 13:00:15 -0500 Subject: [PATCH 37/66] Fix binding state variable initialization value through the extended scope --- .../inputs/language/bindings/rules.msgb | 6 ++++ .../bindings/generated/binding_rules.rs | 6 ++++ .../src/bindings_output/generated/using.rs | 5 +++ .../generated/0.4.11-success.txt | 33 +++++++++++++++++++ .../on_state_var_initialization/input.sol | 8 +++++ 5 files changed, 58 insertions(+) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index f38336d8ab..2283cfa9c1 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -1939,6 +1939,12 @@ inherit .extended_scope edge call -> @state_var.typeof } +@state_var [StateVariableDefinition + [StateVariableDefinitionValue @value [Expression]] +] { + let @value.lexical_scope = @state_var.extended_scope +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Enum definitions 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 c8ed3fe57f..852108fb9f 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 @@ -1944,6 +1944,12 @@ inherit .extended_scope edge call -> @state_var.typeof } +@state_var [StateVariableDefinition + [StateVariableDefinitionValue @value [Expression]] +] { + let @value.lexical_scope = @state_var.extended_scope +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Enum definitions 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 075690eb02..3e424ecbc4 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 @@ -64,6 +64,11 @@ fn on_interfaces_inherited() -> Result<()> { run("using", "on_interfaces_inherited") } +#[test] +fn on_state_var_initialization() -> Result<()> { + run("using", "on_state_var_initialization") +} + #[test] fn qualified_type() -> Result<()> { run("using", "qualified_type") 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(); +} From b027ba5266f38883d0e18ca33b27c561db3b8597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 14 Nov 2024 18:02:21 -0500 Subject: [PATCH 38/66] Allow `using` directives to be inherited in Solidity < 0.7.0 --- .../inputs/language/bindings/rules.msgb | 34 ++++++++++---- .../bindings/generated/binding_rules.rs | 34 ++++++++++---- .../src/bindings_output/generated/using.rs | 5 +++ .../generated/0.4.11-success.txt | 44 +++++++++++++++++++ .../generated/0.7.0-failure.txt | 44 +++++++++++++++++++ .../using/inherit_extension/input.sol | 15 +++++++ 6 files changed, 160 insertions(+), 16 deletions(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 2283cfa9c1..774150e9c0 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -338,6 +338,14 @@ inherit .extended_scope ; Resolve the "super" keyword to the inherited type edge heir.super -> @type_name.push_begin + + if (version-matches "< 0.7.0") { + ; `using` directives are inherited in Solidity < 0.7.0 + 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 + } } ;; NOTE: we use anchors here to prevent the query engine from returning all the @@ -383,13 +391,6 @@ inherit .extended_scope let @contract.enclosing_def = @contract.def - if (version-matches "< 0.7.0") { - ; In Solidity < 0.7.0 using directives are inherited to derived contracts. - ; Hence we make our extensions scope accessible through members, which is accessible - ; from derived contract's lexical scopes. - edge @contract.members -> @contract.extensions - } - ; Path to resolve the built-in type for type() expressions node type attr (type) pop_symbol = "%type" @@ -444,6 +445,15 @@ inherit .extended_scope edge @contract.def -> internal edge internal -> @contract.internal + 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 + } + ;; Define "this" and connect it to the contract definition node this attr (this) pop_symbol = "this" @@ -485,6 +495,13 @@ inherit .extended_scope ;; 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, @contract.super_import] + + if (version-matches "< 0.7.0") { + ; For Solidity < 0.7.0 using directives are inherited, so 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 + } } @contract [ContractDefinition @specifier [InheritanceSpecifier]] { @@ -643,8 +660,9 @@ inherit .extended_scope node @interface.def node @interface.members node @interface.ns - ; this is unused in interfaces, but required for the inheritance rules + ; these are unused in interfaces, but required for the inheritance rules node @interface.internal + node @interface.extensions edge @interface.lexical_scope -> @interface.members edge @interface.lexical_scope -> @interface.ns 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 852108fb9f..f9e133ffbf 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 @@ -343,6 +343,14 @@ inherit .extended_scope ; Resolve the "super" keyword to the inherited type edge heir.super -> @type_name.push_begin + + if (version-matches "< 0.7.0") { + ; `using` directives are inherited in Solidity < 0.7.0 + 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 + } } ;; NOTE: we use anchors here to prevent the query engine from returning all the @@ -388,13 +396,6 @@ inherit .extended_scope let @contract.enclosing_def = @contract.def - if (version-matches "< 0.7.0") { - ; In Solidity < 0.7.0 using directives are inherited to derived contracts. - ; Hence we make our extensions scope accessible through members, which is accessible - ; from derived contract's lexical scopes. - edge @contract.members -> @contract.extensions - } - ; Path to resolve the built-in type for type() expressions node type attr (type) pop_symbol = "%type" @@ -449,6 +450,15 @@ inherit .extended_scope edge @contract.def -> internal edge internal -> @contract.internal + 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 + } + ;; Define "this" and connect it to the contract definition node this attr (this) pop_symbol = "this" @@ -490,6 +500,13 @@ inherit .extended_scope ;; 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, @contract.super_import] + + if (version-matches "< 0.7.0") { + ; For Solidity < 0.7.0 using directives are inherited, so 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 + } } @contract [ContractDefinition @specifier [InheritanceSpecifier]] { @@ -648,8 +665,9 @@ inherit .extended_scope node @interface.def node @interface.members node @interface.ns - ; this is unused in interfaces, but required for the inheritance rules + ; these are unused in interfaces, but required for the inheritance rules node @interface.internal + node @interface.extensions edge @interface.lexical_scope -> @interface.members edge @interface.lexical_scope -> @interface.ns 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 3e424ecbc4..1a2ce69d14 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 @@ -54,6 +54,11 @@ 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") 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(); + } +} From d0945ef82a55ce8ea7a4e8297489611a1e6e1278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 7 Nov 2024 16:19:46 -0500 Subject: [PATCH 39/66] Fix extension binding for function return parameters --- .../inputs/language/bindings/rules.msgb | 2 +- .../bindings/generated/binding_rules.rs | 2 +- .../src/bindings_output/generated/using.rs | 5 +++ .../generated/0.4.11-success.txt | 38 +++++++++++++++++++ .../using/on_parameters/input.sol | 10 +++++ 5 files changed, 55 insertions(+), 2 deletions(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 774150e9c0..5b7fdf1798 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -1330,7 +1330,7 @@ inherit .extended_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.extended_scope -> @return_params.defs 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 f9e133ffbf..632979e8e8 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 @@ -1335,7 +1335,7 @@ inherit .extended_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.extended_scope -> @return_params.defs 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 1a2ce69d14..56416a0cf2 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 @@ -69,6 +69,11 @@ 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") 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(); + } +} From 05c933542e69975d3c3d45ce164ab17e11909cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 7 Nov 2024 16:33:56 -0500 Subject: [PATCH 40/66] External functions have legacy call options --- .../bindings_output/generated/contracts.rs | 5 +++ .../generated/0.4.11-success.txt | 35 +++++++++++++++++++ .../generated/0.7.0-failure.txt | 35 +++++++++++++++++++ .../legacy_function_options/input.sol | 9 +++++ 4 files changed, 84 insertions(+) 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 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 b8f2f2df93..0722971d19 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 @@ -54,6 +54,11 @@ 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") 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)(); + } +} From 172d7a8ef2569cd3aef64f5abe7e0c1e441e0142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 7 Nov 2024 17:11:58 -0500 Subject: [PATCH 41/66] Ensure extensions are pushed before resolving `super` and `this` --- .../inputs/language/bindings/rules.msgb | 4 +- .../bindings/generated/binding_rules.rs | 4 +- .../src/bindings_output/generated/using.rs | 5 +++ .../generated/0.4.11-success.txt | 40 +++++++++++++++++++ .../using/on_super_calls/input.sol | 12 ++++++ 5 files changed, 61 insertions(+), 4 deletions(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 5b7fdf1798..99dcd43cc3 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -460,7 +460,7 @@ inherit .extended_scope edge this -> member ;; ... and make it available in the contract's lexical scope - edge @contract.extended_scope -> this + edge @contract.lexical_scope -> this ; Resolve the "this" keyword to the contract itself node name_push @@ -522,7 +522,7 @@ inherit .extended_scope ;; Finally make "super" available in the contract's extended lexical scope for ;; function bodies to use - edge @contract.extended_scope -> @contract.super + 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. 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 632979e8e8..c629399760 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 @@ -465,7 +465,7 @@ inherit .extended_scope edge this -> member ;; ... and make it available in the contract's lexical scope - edge @contract.extended_scope -> this + edge @contract.lexical_scope -> this ; Resolve the "this" keyword to the contract itself node name_push @@ -527,7 +527,7 @@ inherit .extended_scope ;; Finally make "super" available in the contract's extended lexical scope for ;; function bodies to use - edge @contract.extended_scope -> @contract.super + 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. 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 56416a0cf2..c7da908853 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 @@ -79,6 +79,11 @@ 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") 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..8d948edffa --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/on_super_calls/generated/0.4.11-success.txt @@ -0,0 +1,40 @@ +# 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: 1 + │ │ │ + │ ╰────────── 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) {} +} From 0f7ff8131c286db73df064d860e1e12350ee96dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 11 Nov 2024 15:37:41 -0500 Subject: [PATCH 42/66] Attempt to simplify contract/interface instance scope --- .../inputs/language/bindings/rules.msgb | 101 +++++++++--------- .../bindings/generated/binding_rules.rs | 101 +++++++++--------- .../bindings_output/generated/contracts.rs | 5 + .../super_deep/generated/0.4.11-success.txt | 31 ++++++ .../contracts/super_deep/input.sol | 9 ++ 5 files changed, 145 insertions(+), 102 deletions(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 99dcd43cc3..9e1a4a5777 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -129,10 +129,13 @@ inherit .extended_scope 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 -> pop_extensions + edge @contract_or_library.push_extensions -> drop_scopes + edge drop_scopes -> pop_extensions edge pop_extensions -> @contract_or_library.lexical_scope } @@ -301,20 +304,8 @@ inherit .extended_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 internal members (state variables) accessible through the lexical scope - ; and from the heir's internal scope (so that inherited internal variables can - ; be accessed) + ; Make instance members accessible through the lexical scope and from the + ; heir's internal scope (so that inherited internal variables can be accessed) node internal attr (internal) push_symbol = "@internal" edge heir.internal -> internal @@ -325,7 +316,6 @@ inherit .extended_scope attr (member_pop) pop_symbol = "." edge heir.internal -> @type_name.pop_begin edge @type_name.pop_end -> member_pop - edge member_pop -> member ; Qualified access should also allow us to bind internal members of the parent contract edge member_pop -> internal @@ -410,7 +400,7 @@ inherit .extended_scope ;; and () -> . for accesses through a `new` invocation (or casting) node member attr (member) pop_symbol = "." - edge member -> @contract.members + edge member -> @contract.internal node type_def attr (type_def) pop_symbol = "@typeof" @@ -439,21 +429,12 @@ inherit .extended_scope edge @contract.def -> ns_member edge ns_member -> @contract.ns - ; Finally there's an @internal path used by derived contracts to access our internal state variables + ; Finally there's an @internal path used by derived contracts to access instance accessible members node internal attr (internal) pop_symbol = "@internal" edge @contract.def -> internal edge internal -> @contract.internal - 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 - } - ;; Define "this" and connect it to the contract definition node this attr (this) pop_symbol = "this" @@ -497,9 +478,16 @@ inherit .extended_scope attr (@contract.def) import_nodes = [@contract.lexical_scope, @contract.super_import] if (version-matches "< 0.7.0") { - ; For Solidity < 0.7.0 using directives are inherited, so we need to - ; *always* connect the push extensions to the extended scope, regardless of - ; whether this contract contains any `using` directive. + ; 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 } } @@ -510,15 +498,22 @@ inherit .extended_scope node @contract.super_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 + ;; 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 + ; This connects `super` to exported scopes from all contracts in the hierarchy + ; when setting a contract compilation target + edge @contract.super -> @contract.super_import + + ; This allows "instance"-like access to subtypes and implementors of this + ; interface + node super_internal + attr (super_internal) push_symbol = "@internal" + edge @contract.super_import -> super_internal + edge super_internal -> @contract.super_scope ;; Finally make "super" available in the contract's extended lexical scope for ;; function bodies to use @@ -526,10 +521,6 @@ inherit .extended_scope ; NOTE: The keyword "super" itself resolves to each of its parent contracts. ; See the related rules in the InheritanceSpecifier section above. - - ; This connects `super` to exported scopes from all contracts in the hierarchy - ; when setting a contract compilation target - edge @contract.super -> @contract.super_import } @contract [ContractDefinition [InheritanceSpecifier [InheritanceTypes @@ -664,9 +655,20 @@ inherit .extended_scope node @interface.internal node @interface.extensions - edge @interface.lexical_scope -> @interface.members - edge @interface.lexical_scope -> @interface.ns + edge @interface.lexical_scope -> @interface.internal let @interface.extended_scope = @interface.lexical_scope + + edge @interface.internal -> @interface.members + edge @interface.internal -> @interface.ns + + ; Path to resolve the built-in type for type() expressions + node type + attr (type) pop_symbol = "%type" + node type_interface_type + attr (type_interface_type) push_symbol = "%typeInterfaceType" + edge @interface.def -> type + edge type -> type_interface_type + edge type_interface_type -> @interface.lexical_scope } @interface [InterfaceDefinition @name name: [Identifier]] { @@ -678,7 +680,7 @@ inherit .extended_scope ;; and () -> . for accesses through a `new` invocation (or casting) node member attr (member) pop_symbol = "." - edge member -> @interface.members + edge member -> @interface.internal node typeof attr (typeof) pop_symbol = "@typeof" @@ -707,14 +709,11 @@ inherit .extended_scope edge @interface.def -> ns_member edge ns_member -> @interface.ns - ; Path to resolve the built-in type for type() expressions - node type - attr (type) pop_symbol = "%type" - node type_interface_type - attr (type_interface_type) push_symbol = "%typeInterfaceType" - edge @interface.def -> type - edge type -> type_interface_type - edge type_interface_type -> @interface.lexical_scope + ; Finally there's an @internal path used by derived contracts to access instance accessible members + node internal + attr (internal) pop_symbol = "@internal" + edge @interface.def -> internal + edge internal -> @interface.internal } @interface [InterfaceDefinition @specifier [InheritanceSpecifier]] { 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 c629399760..78f6372656 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 @@ -134,10 +134,13 @@ inherit .extended_scope 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 -> pop_extensions + edge @contract_or_library.push_extensions -> drop_scopes + edge drop_scopes -> pop_extensions edge pop_extensions -> @contract_or_library.lexical_scope } @@ -306,20 +309,8 @@ inherit .extended_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 internal members (state variables) accessible through the lexical scope - ; and from the heir's internal scope (so that inherited internal variables can - ; be accessed) + ; Make instance members accessible through the lexical scope and from the + ; heir's internal scope (so that inherited internal variables can be accessed) node internal attr (internal) push_symbol = "@internal" edge heir.internal -> internal @@ -330,7 +321,6 @@ inherit .extended_scope attr (member_pop) pop_symbol = "." edge heir.internal -> @type_name.pop_begin edge @type_name.pop_end -> member_pop - edge member_pop -> member ; Qualified access should also allow us to bind internal members of the parent contract edge member_pop -> internal @@ -415,7 +405,7 @@ inherit .extended_scope ;; and () -> . for accesses through a `new` invocation (or casting) node member attr (member) pop_symbol = "." - edge member -> @contract.members + edge member -> @contract.internal node type_def attr (type_def) pop_symbol = "@typeof" @@ -444,21 +434,12 @@ inherit .extended_scope edge @contract.def -> ns_member edge ns_member -> @contract.ns - ; Finally there's an @internal path used by derived contracts to access our internal state variables + ; Finally there's an @internal path used by derived contracts to access instance accessible members node internal attr (internal) pop_symbol = "@internal" edge @contract.def -> internal edge internal -> @contract.internal - 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 - } - ;; Define "this" and connect it to the contract definition node this attr (this) pop_symbol = "this" @@ -502,9 +483,16 @@ inherit .extended_scope attr (@contract.def) import_nodes = [@contract.lexical_scope, @contract.super_import] if (version-matches "< 0.7.0") { - ; For Solidity < 0.7.0 using directives are inherited, so we need to - ; *always* connect the push extensions to the extended scope, regardless of - ; whether this contract contains any `using` directive. + ; 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 } } @@ -515,15 +503,22 @@ inherit .extended_scope node @contract.super_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 + ;; 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 + ; This connects `super` to exported scopes from all contracts in the hierarchy + ; when setting a contract compilation target + edge @contract.super -> @contract.super_import + + ; This allows "instance"-like access to subtypes and implementors of this + ; interface + node super_internal + attr (super_internal) push_symbol = "@internal" + edge @contract.super_import -> super_internal + edge super_internal -> @contract.super_scope ;; Finally make "super" available in the contract's extended lexical scope for ;; function bodies to use @@ -531,10 +526,6 @@ inherit .extended_scope ; NOTE: The keyword "super" itself resolves to each of its parent contracts. ; See the related rules in the InheritanceSpecifier section above. - - ; This connects `super` to exported scopes from all contracts in the hierarchy - ; when setting a contract compilation target - edge @contract.super -> @contract.super_import } @contract [ContractDefinition [InheritanceSpecifier [InheritanceTypes @@ -669,9 +660,20 @@ inherit .extended_scope node @interface.internal node @interface.extensions - edge @interface.lexical_scope -> @interface.members - edge @interface.lexical_scope -> @interface.ns + edge @interface.lexical_scope -> @interface.internal let @interface.extended_scope = @interface.lexical_scope + + edge @interface.internal -> @interface.members + edge @interface.internal -> @interface.ns + + ; Path to resolve the built-in type for type() expressions + node type + attr (type) pop_symbol = "%type" + node type_interface_type + attr (type_interface_type) push_symbol = "%typeInterfaceType" + edge @interface.def -> type + edge type -> type_interface_type + edge type_interface_type -> @interface.lexical_scope } @interface [InterfaceDefinition @name name: [Identifier]] { @@ -683,7 +685,7 @@ inherit .extended_scope ;; and () -> . for accesses through a `new` invocation (or casting) node member attr (member) pop_symbol = "." - edge member -> @interface.members + edge member -> @interface.internal node typeof attr (typeof) pop_symbol = "@typeof" @@ -712,14 +714,11 @@ inherit .extended_scope edge @interface.def -> ns_member edge ns_member -> @interface.ns - ; Path to resolve the built-in type for type() expressions - node type - attr (type) pop_symbol = "%type" - node type_interface_type - attr (type_interface_type) push_symbol = "%typeInterfaceType" - edge @interface.def -> type - edge type -> type_interface_type - edge type_interface_type -> @interface.lexical_scope + ; Finally there's an @internal path used by derived contracts to access instance accessible members + node internal + attr (internal) pop_symbol = "@internal" + edge @interface.def -> internal + edge internal -> @interface.internal } @interface [InterfaceDefinition @specifier [InheritanceSpecifier]] { 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 0722971d19..f8a0aa37aa 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 @@ -79,6 +79,11 @@ 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") 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..5cf281f5af --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/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() {} + │ ───┬─── + │ ╰───── 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: 3 + │ │ + │ ╰───── 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(); + } +} From 7aa82dfdea62320463875e84911331ab5ee9ce69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 12 Nov 2024 11:11:30 -0500 Subject: [PATCH 43/66] Remove the generic type resolution for arrays and hard-code built-in in rules The generic typing doesn't make much sense in Solidity since it doesn't have generics. But some of the built-ins act as if those existed. Case in point: `array.push()`. But using jump to scope to resolve the array's element type conflicts with our other use of jump scopes which is extension scopes. Thus, this commit removes the special handling for arrays (and therefore structs in general) and instead hard-codes the `push()` built-in in the rules file. --- .../inputs/language/bindings/rules.msgb | 119 +++++++----------- .../inputs/language/src/definition.rs | 11 +- .../bindings/generated/binding_rules.rs | 119 +++++++----------- .../bindings/generated/built_ins/0.4.11.sol | 2 - .../bindings/generated/built_ins/0.4.17.sol | 2 - .../bindings/generated/built_ins/0.4.22.sol | 2 - .../bindings/generated/built_ins/0.5.0.sol | 2 - .../bindings/generated/built_ins/0.5.3.sol | 2 - .../bindings/generated/built_ins/0.6.0.sol | 2 - .../bindings/generated/built_ins/0.6.2.sol | 2 - .../bindings/generated/built_ins/0.6.7.sol | 2 - .../bindings/generated/built_ins/0.6.8.sol | 2 - .../bindings/generated/built_ins/0.7.0.sol | 2 - .../bindings/generated/built_ins/0.8.0.sol | 2 - .../bindings/generated/built_ins/0.8.11.sol | 2 - .../bindings/generated/built_ins/0.8.18.sol | 2 - .../bindings/generated/built_ins/0.8.2.sol | 2 - .../bindings/generated/built_ins/0.8.24.sol | 2 - .../bindings/generated/built_ins/0.8.26.sol | 2 - .../bindings/generated/built_ins/0.8.4.sol | 2 - .../bindings/generated/built_ins/0.8.7.sol | 2 - .../bindings/generated/built_ins/0.8.8.sol | 2 - ...{0.4.11-failure.txt => 0.4.11-success.txt} | 2 +- 23 files changed, 96 insertions(+), 193 deletions(-) rename crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/{0.4.11-failure.txt => 0.4.11-success.txt} (96%) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 9e1a4a5777..49a64efc5c 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -1035,28 +1035,20 @@ inherit .extended_scope ; 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 - ; 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 = "()" + attr (index) pop_symbol = "[]" 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_input -> index + edge index -> typeof_output edge typeof_output -> @value_type.output ; resolve the value type through our scope @@ -1082,34 +1074,45 @@ inherit .extended_scope } @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 node array attr (array) push_symbol = @array.type edge @array.output -> array - ; 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 - - ; And then the path itself - node params - attr (params) push_scoped_symbol = "<>", scope = entry - edge array -> params - - ; Second path, for `using` directives edge array -> @type_name.output - ; Finally, both ends connect to our lexical scope - edge params -> @array.lexical_scope edge @type_name.type_ref -> @array.lexical_scope + edge array -> @array.lexical_scope + + ; Define some built-in functions and operators that return the element's type + ; typeof_input or member is where all these definitions begin + node typeof_input + attr (typeof_input) pop_symbol = "@typeof" + node member + attr (member) pop_symbol = "." + edge @array.output -> typeof_input + edge typeof_input -> member + + ; and all of them end in typeof_output connecting to the element type + node typeof_output + attr (typeof_output) push_symbol = "@typeof" + edge typeof_output -> @type_name.output + + ; Define the path to resolve index access (aka the `[]` operator) + node index + attr (index) pop_symbol = "[]" + edge typeof_input -> index + edge index -> 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 push_built_in + attr (push_built_in) pop_symbol = "push" + node call + attr (call) pop_symbol = "()" + edge member -> push_built_in + edge push_built_in -> call + edge 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 @@ -1926,6 +1929,7 @@ inherit .extended_scope @state_var [StateVariableDefinition] { node @state_var.lexical_scope + node @state_var.extended_scope node @state_var.def } @@ -2008,56 +2012,33 @@ inherit .extended_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 - ; 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 - - ; 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.def -> 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 member attr (member) pop_symbol = "." - edge def -> type_def + edge @struct.def -> type_def edge type_def -> 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, should bind to itself node call attr (call) pop_symbol = "()" - edge def -> call + edge @struct.def -> call edge call -> member } @@ -2292,17 +2273,11 @@ inherit .extended_scope @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 = "." - - edge @expr.output -> index_call - edge index_call -> index - edge index -> index_member - edge index_member -> @operand.output + attr (index) push_symbol = "[]" + + edge @expr.output -> index + edge index -> @operand.output } ;; Type expressions diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 2e113d3cc3..f7feb7e121 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -6830,11 +6830,6 @@ codegen_language_macros::compile!(Language( name = "$array", fields = [BuiltInField(definition = "uint length")], functions = [ - BuiltInFunction( - name = "$index", - parameters = ["uint"], - return_type = "$element" - ), BuiltInFunction( name = "push", parameters = [], @@ -6858,11 +6853,7 @@ codegen_language_macros::compile!(Language( BuiltInType( name = "$arrayFixed", fields = [BuiltInField(definition = "uint length")], - functions = [BuiltInFunction( - name = "$index", - parameters = ["uint"], - return_type = "$element" - )] + functions = [] ), BuiltInType( name = "$blockType", 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 78f6372656..d25dee3270 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 @@ -1040,28 +1040,20 @@ inherit .extended_scope ; 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 - ; 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 = "()" + attr (index) pop_symbol = "[]" 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_input -> index + edge index -> typeof_output edge typeof_output -> @value_type.output ; resolve the value type through our scope @@ -1087,34 +1079,45 @@ inherit .extended_scope } @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 node array attr (array) push_symbol = @array.type edge @array.output -> array - ; 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 - - ; And then the path itself - node params - attr (params) push_scoped_symbol = "<>", scope = entry - edge array -> params - - ; Second path, for `using` directives edge array -> @type_name.output - ; Finally, both ends connect to our lexical scope - edge params -> @array.lexical_scope edge @type_name.type_ref -> @array.lexical_scope + edge array -> @array.lexical_scope + + ; Define some built-in functions and operators that return the element's type + ; typeof_input or member is where all these definitions begin + node typeof_input + attr (typeof_input) pop_symbol = "@typeof" + node member + attr (member) pop_symbol = "." + edge @array.output -> typeof_input + edge typeof_input -> member + + ; and all of them end in typeof_output connecting to the element type + node typeof_output + attr (typeof_output) push_symbol = "@typeof" + edge typeof_output -> @type_name.output + + ; Define the path to resolve index access (aka the `[]` operator) + node index + attr (index) pop_symbol = "[]" + edge typeof_input -> index + edge index -> 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 push_built_in + attr (push_built_in) pop_symbol = "push" + node call + attr (call) pop_symbol = "()" + edge member -> push_built_in + edge push_built_in -> call + edge 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 @@ -1931,6 +1934,7 @@ inherit .extended_scope @state_var [StateVariableDefinition] { node @state_var.lexical_scope + node @state_var.extended_scope node @state_var.def } @@ -2013,56 +2017,33 @@ inherit .extended_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 - ; 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 - - ; 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.def -> 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 member attr (member) pop_symbol = "." - edge def -> type_def + edge @struct.def -> type_def edge type_def -> 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, should bind to itself node call attr (call) pop_symbol = "()" - edge def -> call + edge @struct.def -> call edge call -> member } @@ -2297,17 +2278,11 @@ inherit .extended_scope @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 = "." - - edge @expr.output -> index_call - edge index_call -> index - edge index -> index_member - edge index_member -> @operand.output + attr (index) push_symbol = "[]" + + edge @expr.output -> index + edge index -> @operand.output } ;; Type expressions 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 1200054cc4..d7805fc05e 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 @@ -30,13 +30,11 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function($element) returns (uint) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { address payable coinbase; 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 7975fd0f93..01f0d73a3f 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 @@ -30,13 +30,11 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function($element) returns (uint) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { address payable coinbase; 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 4abc23481a..d57f6288ba 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 @@ -38,13 +38,11 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function($element) returns (uint) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { address payable coinbase; 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 0a5cadd73e..2d2a60e286 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 @@ -37,13 +37,11 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function($element) returns (uint) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { address payable coinbase; 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 d298a5a423..81c206a985 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 @@ -37,13 +37,11 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function($element) returns (uint) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { address payable coinbase; 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 7ca66792d4..5543bbe614 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 @@ -37,14 +37,12 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function() returns ($element) push; function($element) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { address payable coinbase; 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 be95f2d7e9..5141829876 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 @@ -37,14 +37,12 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function() returns ($element) push; function($element) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { address payable coinbase; 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 1dd6124537..0911cb8672 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 @@ -37,14 +37,12 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function() returns ($element) push; function($element) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { address payable coinbase; 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 53a13eef7a..e842ce4b21 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 @@ -37,14 +37,12 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function() returns ($element) push; function($element) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { address payable coinbase; 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 634b34c165..8a79c62142 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 @@ -37,14 +37,12 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function() returns ($element) push; function($element) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { address payable coinbase; 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 9168eb3f39..07452d0050 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 @@ -34,14 +34,12 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function() returns ($element) push; function($element) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { uint chainid; 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 e6af4ae8b8..98330bb063 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 @@ -35,14 +35,12 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function() returns ($element) push; function($element) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { uint basefee; 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 d667976120..116dff6600 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 @@ -35,14 +35,12 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function() returns ($element) push; function($element) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { uint basefee; 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 582fea1a9e..8214500c64 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 @@ -34,14 +34,12 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function() returns ($element) push; function($element) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { uint chainid; 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 fda66ce25b..e703c6ed42 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 @@ -36,14 +36,12 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function() returns ($element) push; function($element) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { uint basefee; 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 e12f9bddd7..426ff39b2d 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 @@ -37,14 +37,12 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function() returns ($element) push; function($element) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { uint basefee; 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 index 1b600047e3..6a5244aa2f 100644 --- 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 @@ -34,14 +34,12 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function() returns ($element) push; function($element) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { uint chainid; 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 661ca1e963..c1b10cae46 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 @@ -34,14 +34,12 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function() returns ($element) push; function($element) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { uint basefee; 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 index f053df3115..212294a258 100644 --- 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 @@ -34,14 +34,12 @@ contract $BuiltIns$ { } struct $array { uint length; - function(uint) returns ($element) $index; function() returns ($element) push; function($element) push; function() pop; } struct $arrayFixed { uint length; - function(uint) returns ($element) $index; } struct $blockType { uint basefee; diff --git a/crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-success.txt similarity index 96% rename from crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-failure.txt rename to crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-success.txt index 2b52f7d3f5..2e3248e35d 100644 --- a/crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/arrays/length/generated/0.4.11-success.txt @@ -29,5 +29,5 @@ References and definitions: │ │ │ │ ╰──────── ref: built-in │ │ - │ ╰─── unresolved + │ ╰─── ref: 2 ───╯ From 172e5eda2af8f2966f95856c20944e3f699ef1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 12 Nov 2024 12:16:20 -0500 Subject: [PATCH 44/66] Bind user defined type's `wrap` and `unwrap` functions return types --- .../inputs/language/bindings/rules.msgb | 43 +++++++++--- .../bindings/generated/binding_rules.rs | 43 +++++++++--- .../src/bindings_output/generated/using.rs | 5 ++ .../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 +++++ 11 files changed, 236 insertions(+), 18 deletions(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 49a64efc5c..2ab77b91ee 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -2162,17 +2162,12 @@ inherit .extended_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 - - edge @user_type.def -> def + 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` @@ -2185,11 +2180,41 @@ inherit .extended_scope node user_type_type attr (user_type_type) push_symbol = "%userTypeType" - edge def -> member_guard + 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 } 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 d25dee3270..448eb76d22 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 @@ -2167,17 +2167,12 @@ inherit .extended_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 - - edge @user_type.def -> def + 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` @@ -2190,11 +2185,41 @@ inherit .extended_scope node user_type_type attr (user_type_type) push_symbol = "%userTypeType" - edge def -> member_guard + 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 } 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 c7da908853..1e40dd6718 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 @@ -103,3 +103,8 @@ fn top_level() -> Result<()> { fn uint_alias() -> Result<()> { run("using", "uint_alias") } + +#[test] +fn user_types() -> Result<()> { + run("using", "user_types") +} 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 {} +} From 757111d99882cd5c7ed9c7863fa3f224cf697739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 12 Nov 2024 15:40:30 -0500 Subject: [PATCH 45/66] Only connect the star extension scope `using for *` when there is one This prevents creating unnecessary paths in the stack graph when there is not a `using for *` directive. Unfortunately for Solidity < 0.7.0 we need to do it anyway because using directives are inherited. --- .../inputs/language/bindings/rules.msgb | 34 +++++++-- .../bindings/generated/binding_rules.rs | 34 +++++++-- .../src/bindings_output/generated/using.rs | 5 ++ .../using/star/generated/0.4.11-success.txt | 71 ++++++++----------- .../bindings_output/using/star/input.sol | 10 +-- .../generated/0.4.11-success.txt | 38 ++++++++++ .../generated/0.7.0-failure.txt | 38 ++++++++++ .../using/star_inherited/input.sol | 14 ++++ 8 files changed, 185 insertions(+), 59 deletions(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 2ab77b91ee..be669a941f 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -23,6 +23,11 @@ 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 + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Source unit (aka .sol file) @@ -70,6 +75,10 @@ inherit .extended_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... @@ -388,7 +397,17 @@ inherit .extended_scope attr (type_contract_type) push_symbol = "%typeContractType" edge @contract.def -> type edge type -> type_contract_type - edge type_contract_type -> @contract.lexical_scope + edge type_contract_type -> @contract.parent_scope + + ; This is the connection point to resolve attached function by `using for *` + node @contract.star_extension + attr (@contract.star_extension) push_symbol = "@*" + if (version-matches "< 0.7.0") { + ; 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 + } } @contract [ContractDefinition @name name: [Identifier]] { @@ -641,6 +660,14 @@ inherit .extended_scope edge @base_ident.push_end -> @override.parent_scope } +@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 +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Interfaces @@ -2263,10 +2290,7 @@ inherit .extended_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 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 448eb76d22..09e6c9b747 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 @@ -28,6 +28,11 @@ 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 + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Source unit (aka .sol file) @@ -75,6 +80,10 @@ inherit .extended_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... @@ -393,7 +402,17 @@ inherit .extended_scope attr (type_contract_type) push_symbol = "%typeContractType" edge @contract.def -> type edge type -> type_contract_type - edge type_contract_type -> @contract.lexical_scope + edge type_contract_type -> @contract.parent_scope + + ; This is the connection point to resolve attached function by `using for *` + node @contract.star_extension + attr (@contract.star_extension) push_symbol = "@*" + if (version-matches "< 0.7.0") { + ; 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 + } } @contract [ContractDefinition @name name: [Identifier]] { @@ -646,6 +665,14 @@ inherit .extended_scope edge @base_ident.push_end -> @override.parent_scope } +@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 +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Interfaces @@ -2268,10 +2295,7 @@ inherit .extended_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 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 1e40dd6718..b52b618c30 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 @@ -94,6 +94,11 @@ fn star() -> Result<()> { run("using", "star") } +#[test] +fn star_inherited() -> Result<()> { + run("using", "star_inherited") +} + #[test] fn top_level() -> Result<()> { run("using", "top_level") 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_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(); + } +} From aecab6fb1cfcfffceba2f41277b77c050a307aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 12 Nov 2024 15:43:22 -0500 Subject: [PATCH 46/66] Bind array and mappings accesses through public getter functions --- .../inputs/language/bindings/rules.msgb | 24 ++++++++-- .../bindings/generated/binding_rules.rs | 24 ++++++++-- .../bindings_output/generated/contracts.rs | 10 ++++ .../generated/0.4.11-success.txt | 42 +++++++++++++++++ .../contracts/public_array_getters/input.sol | 12 +++++ .../generated/0.4.11-success.txt | 46 +++++++++++++++++++ .../public_mapping_getters/input.sol | 12 +++++ 7 files changed, 160 insertions(+), 10 deletions(-) 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_mapping_getters/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/input.sol diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index be669a941f..19dc67fee6 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -1066,17 +1066,23 @@ inherit .star_extension node typeof_input attr (typeof_input) pop_symbol = "@typeof" - - node index - attr (index) pop_symbol = "[]" + edge @mapping.output -> typeof_input node typeof_output attr (typeof_output) push_symbol = "@typeof" + edge typeof_output -> @value_type.output - edge @mapping.output -> typeof_input + node index + attr (index) pop_symbol = "[]" edge typeof_input -> index edge index -> typeof_output - edge typeof_output -> @value_type.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 = "()" + edge typeof_input -> getter_call + edge getter_call -> typeof_output ; resolve the value type through our scope edge @value_type.type_ref -> @mapping.lexical_scope @@ -1141,6 +1147,14 @@ inherit .star_extension edge call -> 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 = "()" + 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 essentially the reverse of the second path above node pop_array 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 09e6c9b747..671fb9bd9b 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 @@ -1071,17 +1071,23 @@ inherit .star_extension node typeof_input attr (typeof_input) pop_symbol = "@typeof" - - node index - attr (index) pop_symbol = "[]" + edge @mapping.output -> typeof_input node typeof_output attr (typeof_output) push_symbol = "@typeof" + edge typeof_output -> @value_type.output - edge @mapping.output -> typeof_input + node index + attr (index) pop_symbol = "[]" edge typeof_input -> index edge index -> typeof_output - edge typeof_output -> @value_type.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 = "()" + edge typeof_input -> getter_call + edge getter_call -> typeof_output ; resolve the value type through our scope edge @value_type.type_ref -> @mapping.lexical_scope @@ -1146,6 +1152,14 @@ inherit .star_extension edge call -> 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 = "()" + 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 essentially the reverse of the second path above node pop_array 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 f8a0aa37aa..13746a93dd 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 @@ -64,11 +64,21 @@ fn multi_inheritance() -> Result<()> { run("contracts", "multi_inheritance") } +#[test] +fn public_array_getters() -> Result<()> { + run("contracts", "public_array_getters") +} + #[test] fn public_getters() -> Result<()> { run("contracts", "public_getters") } +#[test] +fn public_mapping_getters() -> Result<()> { + run("contracts", "public_mapping_getters") +} + #[test] fn qualified_inherited() -> Result<()> { run("contracts", "qualified_inherited") 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..d08ee290be --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/generated/0.4.11-success.txt @@ -0,0 +1,42 @@ +# 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 uint; + │ ─┬─ + │ ╰─── ref: 1 + 6 │ function test(TokenState tokenState) public { + │ ──┬─ ─────┬──── ─────┬──── + │ ╰───────────────────────── def: 5 + │ │ │ + │ ╰───────────────── ref: 7 + │ │ + │ ╰────── def: 6 + 7 │ tokenState.values(1).nop(); + │ ─────┬──── ───┬── ─┬─ + │ ╰──────────────────── ref: 6 + │ │ │ + │ ╰─────────── ref: 8 + │ │ + │ ╰─── ref: 2 + │ + 10 │ contract TokenState { + │ ─────┬──── + │ ╰────── def: 7 + 11 │ uint[] public values; + │ ───┬── + │ ╰──── def: 8 +────╯ 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..fe753d210d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_array_getters/input.sol @@ -0,0 +1,12 @@ +library Lib { + function nop(uint256 x) internal {} +} +contract Test { + using Lib for uint; + function test(TokenState tokenState) public { + tokenState.values(1).nop(); + } +} +contract TokenState { + uint[] public values; +} 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..3c091da5a8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/generated/0.4.11-success.txt @@ -0,0 +1,46 @@ +# 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 uint; + │ ─┬─ + │ ╰─── ref: 1 + 6 │ function test(TokenState tokenState) public { + │ ──┬─ ─────┬──── ─────┬──── + │ ╰───────────────────────── def: 5 + │ │ │ + │ ╰───────────────── ref: 7 + │ │ + │ ╰────── def: 6 + 7 │ tokenState.balanceOf(msg.sender).nop(); + │ ─────┬──── ────┬──── ─┬─ ───┬── ─┬─ + │ ╰──────────────────────────────── ref: 6 + │ │ │ │ │ + │ ╰────────────────────── ref: 8 + │ │ │ │ + │ ╰─────────────── ref: built-in + │ │ │ + │ ╰───────── ref: built-in + │ │ + │ ╰─── ref: 2 + │ + 10 │ contract TokenState { + │ ─────┬──── + │ ╰────── def: 7 + 11 │ mapping(address => uint) public balanceOf; + │ ────┬──── + │ ╰────── def: 8 +────╯ 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..194f10090f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_mapping_getters/input.sol @@ -0,0 +1,12 @@ +library Lib { + function nop(uint256 x) internal {} +} +contract Test { + using Lib for uint; + function test(TokenState tokenState) public { + tokenState.balanceOf(msg.sender).nop(); + } +} +contract TokenState { + mapping(address => uint) public balanceOf; +} From a9f09867c1c0aabc118415cb62171c7a472a03d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 12 Nov 2024 16:35:47 -0500 Subject: [PATCH 47/66] Support attaching functions to mappings with `using` --- .../inputs/language/bindings/rules.msgb | 42 +++++++++++++++---- .../bindings/generated/binding_rules.rs | 42 +++++++++++++++---- .../src/bindings_output/generated/using.rs | 5 +++ .../mappings/generated/0.4.11-success.txt | 32 ++++++++++++++ .../bindings_output/using/mappings/input.sol | 10 +++++ 5 files changed, 113 insertions(+), 18 deletions(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 19dc67fee6..64a74e9893 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -994,6 +994,9 @@ inherit .star_extension @type_name [TypeName @mapping [MappingType]] { let @type_name.type_ref = @mapping.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 } @@ -1008,6 +1011,15 @@ inherit .star_extension 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]]] { @@ -1048,19 +1060,22 @@ inherit .star_extension ;;; 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 -} + node @mapping.type + attr (@mapping.type) push_symbol = "%mapping" + edge @mapping.output -> @mapping.type -@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 + edge @mapping.type -> @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 `[]` operator that returns the value type. @@ -1086,6 +1101,15 @@ inherit .star_extension ; resolve the value type through our scope edge @value_type.type_ref -> @mapping.lexical_scope + + ; Now we define the "definition" route (aka. the pop route), to use in `using` directives only + node pop_mapping + attr (pop_mapping) pop_symbol = "%mapping" + + let @mapping.pop_begin = @value_type.pop_begin + edge @value_type.pop_end -> @key_type.pop_begin + edge @key_type.pop_end -> pop_mapping + let @mapping.pop_end = pop_mapping } 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 671fb9bd9b..ff4d0177a5 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 @@ -999,6 +999,9 @@ inherit .star_extension @type_name [TypeName @mapping [MappingType]] { let @type_name.type_ref = @mapping.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 } @@ -1013,6 +1016,15 @@ inherit .star_extension 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]]] { @@ -1053,19 +1065,22 @@ inherit .star_extension ;;; 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 -} + node @mapping.type + attr (@mapping.type) push_symbol = "%mapping" + edge @mapping.output -> @mapping.type -@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 + edge @mapping.type -> @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 `[]` operator that returns the value type. @@ -1091,6 +1106,15 @@ inherit .star_extension ; resolve the value type through our scope edge @value_type.type_ref -> @mapping.lexical_scope + + ; Now we define the "definition" route (aka. the pop route), to use in `using` directives only + node pop_mapping + attr (pop_mapping) pop_symbol = "%mapping" + + let @mapping.pop_begin = @value_type.pop_begin + edge @value_type.pop_end -> @key_type.pop_begin + edge @key_type.pop_end -> pop_mapping + let @mapping.pop_end = pop_mapping } 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 b52b618c30..9b35857fae 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 @@ -64,6 +64,11 @@ 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") 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 {} +} From 54217b29b7206768ed9d0f391d38368ca25f2036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Fri, 15 Nov 2024 17:57:19 -0500 Subject: [PATCH 48/66] Clean up and add more documentation to the binding rules --- .../inputs/language/bindings/rules.msgb | 555 ++++++++++-------- .../bindings/generated/binding_rules.rs | 555 ++++++++++-------- 2 files changed, 604 insertions(+), 506 deletions(-) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 64a74e9893..47e9bf7ccc 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -115,40 +115,6 @@ inherit .star_extension } -;; 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. -[SourceUnit [SourceUnitMembers - [SourceUnitMember @contract_or_library ([ContractDefinition] | [LibraryDefinition])] -]] { - ; When "leaving" the contract lexical scope to the parent scope (ie. the - ; source unit) we need to (optionally) propagate the extensions scope (ie. - ; `using` directives extensions). Thus we introduce a parent_node and we will - ; connect the path to push the extensions *if* the contract/library has a - ; `using` directive. - - node @contract_or_library.extended_scope - edge @contract_or_library.extended_scope -> @contract_or_library.lexical_scope - - ; This .extensions node is where `using` directives will hook - node @contract_or_library.extensions - attr (@contract_or_library.extensions) is_exported - - ; Now we define the path to push the .extensions scope into the scope stack - 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 -} - - ;; 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 @@ -159,11 +125,14 @@ inherit .star_extension [SourceUnitMember @contract [ContractDefinition name: ["%BuiltIns%"]]] ]] { if (is-system-file FILE_PATH) { - edge @source_unit.defs -> @contract.internal + 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 } @@ -174,7 +143,7 @@ inherit .star_extension edge @source_unit.defs -> @using.def } -;; ... and imports +;; Import connections to the source unit @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember [ImportDirective [ImportClause @import ( @@ -313,33 +282,34 @@ inherit .star_extension ;; interface), aka the source unit edge @type_name.push_end -> heir.parent_scope - ; Make instance members accessible through the lexical scope and from the - ; heir's internal scope (so that inherited internal variables can be accessed) - node internal - attr (internal) push_symbol = "@internal" - edge heir.internal -> internal - edge internal -> @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 qualified with the base name (eg. `Base.something`) + ; 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.internal -> @type_name.pop_begin + edge heir.instance -> @type_name.pop_begin edge @type_name.pop_end -> member_pop - ; Qualified access should also allow us to bind internal members of the parent contract - edge member_pop -> internal + edge member_pop -> instance - ;; Make base defs (eg. enums and structs) accessible as our own + ; 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 - ; Resolve the "super" keyword to the inherited type + ; Resolve the "super" keyword reference to the inherited type edge heir.super -> @type_name.push_begin if (version-matches "< 0.7.0") { - ; `using` directives are inherited in Solidity < 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 @@ -347,6 +317,9 @@ inherit .star_extension } } +;; 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 [_]+ .]] { @@ -369,57 +342,34 @@ inherit .star_extension ;;; Contracts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@contract [ContractDefinition] { +@contract [ContractDefinition @name name: [Identifier]] { node @contract.lexical_scope + node @contract.extended_scope + node @contract.extensions node @contract.def node @contract.members node @contract.ns node @contract.modifiers - node @contract.internal + node @contract.instance - edge @contract.lexical_scope -> @contract.internal + attr (@contract.def) node_definition = @name + attr (@contract.def) definiens_node = @contract - edge @contract.internal -> @contract.members - edge @contract.internal -> @contract.ns + edge @contract.lexical_scope -> @contract.instance - ;; Modifiers are available as a contract type members through a special '@modifier' symbol - node modifier - attr (modifier) pop_symbol = "@modifier" - edge @contract.ns -> modifier - edge modifier -> @contract.modifiers + ; Instance scope can also see members and our namespace definitions + edge @contract.instance -> @contract.members + edge @contract.instance -> @contract.ns let @contract.enclosing_def = @contract.def - ; Path to resolve the built-in type for type() expressions - node type - attr (type) pop_symbol = "%type" - node type_contract_type - attr (type_contract_type) push_symbol = "%typeContractType" - edge @contract.def -> type - edge type -> type_contract_type - edge type_contract_type -> @contract.parent_scope - - ; This is the connection point to resolve attached function by `using for *` - node @contract.star_extension - attr (@contract.star_extension) push_symbol = "@*" - if (version-matches "< 0.7.0") { - ; 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 - } -} - -@contract [ContractDefinition @name name: [Identifier]] { - attr (@contract.def) node_definition = @name - attr (@contract.def) definiens_node = @contract - - ;; "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.internal + edge member -> @contract.members node type_def attr (type_def) pop_symbol = "@typeof" @@ -431,45 +381,54 @@ inherit .star_extension edge @contract.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 + ;; "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 @internal path used by derived contracts to access instance accessible members - node internal - attr (internal) pop_symbol = "@internal" - edge @contract.def -> internal - edge internal -> @contract.internal + ; 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 - ;; Define "this" and connect it to the contract definition + ; "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 + ; ... and resolves 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 - ; For Solidity < 0.5.0 `this` also acts like an `address` + ;; 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 + + ; 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 + 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 @@ -479,22 +438,9 @@ inherit .star_extension edge address_ref -> @contract.lexical_scope } - ;; This defines the sink of edges added from base contracts when setting this - ;; contract as the compilation context - attr (@contract.def) export_node = @contract.internal - - ;; 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 - 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 - attr (@contract.def) import_nodes = [@contract.lexical_scope, @contract.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 @@ -508,35 +454,77 @@ inherit .star_extension ; 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" + node type_contract_type + attr (type_contract_type) push_symbol = "%typeContractType" + edge @contract.def -> type + edge type -> type_contract_type + 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" 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 + ; 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 + ; 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 - ; This allows "instance"-like access to subtypes and implementors of this - ; interface - node super_internal - attr (super_internal) push_symbol = "@internal" - edge @contract.super_import -> super_internal - edge super_internal -> @contract.super_scope - - ;; Finally make "super" available in the contract's extended lexical scope for - ;; function bodies to use - edge @contract.lexical_scope -> @contract.super + ; 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 ; NOTE: The keyword "super" itself resolves to each of its parent contracts. ; See the related rules in the InheritanceSpecifier section above. @@ -545,7 +533,7 @@ inherit .star_extension @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 } @@ -583,10 +571,12 @@ inherit .star_extension @contract [ContractDefinition [ContractMembers [ContractMember @using [UsingDirective]] ]] { - ; Expose the using directive from the extensions scope + ; Hook the using definition in the extensions scope edge @contract.extensions -> @using.def - ; Connect the extensions push path + ; 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 } @@ -599,6 +589,8 @@ inherit .star_extension | [UserDefinedValueTypeDefinition] )] ]] { + ; These definition go into the "namespace" scope and are accessible externally + ; via qualified naming (eg. `Contract.MyStruct`) edge @contract.ns -> @member.def } @@ -607,9 +599,10 @@ inherit .star_extension ]] { ; State variables are available to derived contracts. ; TODO: this also exposes private state variables to derived contracts, but we - ; can't easily express that because we don't have negative assertions in our - ; query language - edge @contract.internal -> @state_var.def + ; 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 @@ -638,13 +631,15 @@ inherit .star_extension [FunctionAttributes [FunctionAttribute ([ExternalKeyword] | [PublicKeyword])]] ]] ]] { - ; public or external functions are also accessible through the contract type + ; 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) @@ -653,13 +648,6 @@ inherit .star_extension attr (@modifier.def) parents = [@contract.def] } -@override [OverrideSpecifier [OverridePathsDeclaration [OverridePaths - @base_ident [IdentifierPath] -]]] { - ;; Resolve overriden bases when listed in the function or modifiers modifiers - edge @base_ident.push_end -> @override.parent_scope -} - @contract [ContractDefinition [ContractMembers [ContractMember [UsingDirective [UsingTarget [Asterisk]]] ]]] { @@ -668,46 +656,45 @@ inherit .star_extension edge @contract.star_extension -> @contract.extended_scope } +; This applies to both state variables and function definitions +@override [OverrideSpecifier [OverridePathsDeclaration [OverridePaths + @base_ident [IdentifierPath] +]]] { + ;; Resolve overriden bases when listed in the function or modifiers modifiers + edge @base_ident.push_end -> @override.parent_scope +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Interfaces ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@interface [InterfaceDefinition] { +@interface [InterfaceDefinition @name name: [Identifier]] { node @interface.lexical_scope node @interface.def node @interface.members node @interface.ns - ; these are unused in interfaces, but required for the inheritance rules - node @interface.internal - node @interface.extensions + node @interface.instance - edge @interface.lexical_scope -> @interface.internal - let @interface.extended_scope = @interface.lexical_scope + attr (@interface.def) node_definition = @name + attr (@interface.def) definiens_node = @interface - edge @interface.internal -> @interface.members - edge @interface.internal -> @interface.ns + edge @interface.lexical_scope -> @interface.instance - ; Path to resolve the built-in type for type() expressions - node type - attr (type) pop_symbol = "%type" - node type_interface_type - attr (type_interface_type) push_symbol = "%typeInterfaceType" - edge @interface.def -> type - edge type -> type_interface_type - edge type_interface_type -> @interface.lexical_scope -} + ; 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) -@interface [InterfaceDefinition @name name: [Identifier]] { - attr (@interface.def) node_definition = @name - attr (@interface.def) definiens_node = @interface + edge @interface.instance -> @interface.members + edge @interface.instance -> @interface.ns - ;; "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" 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.internal + edge member -> @interface.instance node typeof attr (typeof) pop_symbol = "@typeof" @@ -736,11 +723,21 @@ inherit .star_extension edge @interface.def -> ns_member edge ns_member -> @interface.ns - ; Finally there's an @internal path used by derived contracts to access instance accessible members - node internal - attr (internal) pop_symbol = "@internal" - edge @interface.def -> internal - edge internal -> @interface.internal + ; 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" + node type_interface_type + attr (type_interface_type) push_symbol = "%typeInterfaceType" + edge @interface.def -> type + edge type -> type_interface_type + edge type_interface_type -> @interface.parent_scope } @interface [InterfaceDefinition @specifier [InheritanceSpecifier]] { @@ -777,7 +774,7 @@ inherit .star_extension [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) } @@ -786,31 +783,30 @@ inherit .star_extension ;;; Libraries ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@library [LibraryDefinition] { +@library [LibraryDefinition @name name: [Identifier]] { node @library.lexical_scope + node @library.extended_scope + node @library.extensions node @library.def node @library.ns node @library.modifiers - edge @library.lexical_scope -> @library.ns - - ; Access to modifiers is guarded by a @modifier symbol - node modifier - attr (modifier) pop_symbol = "@modifier" - edge @library.ns -> modifier - edge modifier -> @library.modifiers -} - -@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 + ; 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" @@ -863,12 +859,54 @@ inherit .star_extension } +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; 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 +} + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; 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 @@ -876,8 +914,9 @@ inherit .star_extension ; 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 } @@ -905,7 +944,7 @@ inherit .star_extension ]] ]]] { ; 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 = "." @@ -934,7 +973,7 @@ inherit .star_extension ; resolve the target type of the directive on the extended scope so the ; extension scope gets re-pushed - edge @type_name.type_ref -> @using.lexical_scope + edge @type_name.type_ref -> @using.extended_scope } [ContractMember @using [UsingDirective [UsingTarget [Asterisk]]]] { @@ -950,7 +989,7 @@ inherit .star_extension ;;; 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) @@ -959,6 +998,12 @@ inherit .star_extension ;; - @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 @@ -1067,12 +1112,16 @@ inherit .star_extension node @mapping.lexical_scope node @mapping.output - node @mapping.type - attr (@mapping.type) push_symbol = "%mapping" - edge @mapping.output -> @mapping.type - - edge @mapping.type -> @key_type.push_begin + ; 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 @@ -1099,10 +1148,8 @@ inherit .star_extension edge typeof_input -> getter_call edge getter_call -> typeof_output - ; resolve the value type through our scope - edge @value_type.type_ref -> @mapping.lexical_scope - ; 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" @@ -1123,54 +1170,42 @@ inherit .star_extension } @array [ArrayTypeName [TypeName] index: [Expression]] { - let @array.type = "%arrayFixed" + let @array.type_symbol = "%arrayFixed" } @array [ArrayTypeName [OpenBracket] . [CloseBracket]] { - let @array.type = "%array" + let @array.type_symbol = "%array" } @array [ArrayTypeName @type_name [TypeName]] { + ; 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 + ; 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 - ; Define some built-in functions and operators that return the element's type - ; typeof_input or member is where all these definitions begin + ; Define the path to resolve index access (aka the `[]` operator) + node typeof_input attr (typeof_input) pop_symbol = "@typeof" - node member - attr (member) pop_symbol = "." edge @array.output -> typeof_input - edge typeof_input -> member - ; and all of them end in typeof_output connecting to the element type node typeof_output attr (typeof_output) push_symbol = "@typeof" edge typeof_output -> @type_name.output - ; Define the path to resolve index access (aka the `[]` operator) node index attr (index) pop_symbol = "[]" edge typeof_input -> index edge index -> 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 push_built_in - attr (push_built_in) pop_symbol = "push" - node call - attr (call) pop_symbol = "()" - edge member -> push_built_in - edge push_built_in -> call - edge call -> 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. @@ -1179,10 +1214,25 @@ inherit .star_extension 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 @@ -1197,10 +1247,10 @@ inherit .star_extension @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 = "%functionExternal" } } @@ -1210,14 +1260,14 @@ inherit .star_extension ; 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 @@ -1234,8 +1284,9 @@ inherit .star_extension @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" @@ -1262,14 +1313,14 @@ inherit .star_extension ;; @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 @@ -1355,10 +1406,10 @@ inherit .star_extension } @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 = "%functionExternal" } } @@ -1371,7 +1422,7 @@ inherit .star_extension 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 @@ -2036,13 +2087,11 @@ inherit .star_extension ;;; 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 @@ -2100,7 +2149,7 @@ inherit .star_extension edge @struct.def -> param_names edge param_names -> @struct.members - ; Used as a function call, should bind to itself + ; Used as a function call (ie. casting), should bind to itself node call attr (call) pop_symbol = "()" edge @struct.def -> call 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 ff4d0177a5..47926d0d4f 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 @@ -120,40 +120,6 @@ inherit .star_extension } -;; 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. -[SourceUnit [SourceUnitMembers - [SourceUnitMember @contract_or_library ([ContractDefinition] | [LibraryDefinition])] -]] { - ; When "leaving" the contract lexical scope to the parent scope (ie. the - ; source unit) we need to (optionally) propagate the extensions scope (ie. - ; `using` directives extensions). Thus we introduce a parent_node and we will - ; connect the path to push the extensions *if* the contract/library has a - ; `using` directive. - - node @contract_or_library.extended_scope - edge @contract_or_library.extended_scope -> @contract_or_library.lexical_scope - - ; This .extensions node is where `using` directives will hook - node @contract_or_library.extensions - attr (@contract_or_library.extensions) is_exported - - ; Now we define the path to push the .extensions scope into the scope stack - 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 -} - - ;; 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 @@ -164,11 +130,14 @@ inherit .star_extension [SourceUnitMember @contract [ContractDefinition name: ["%BuiltIns%"]]] ]] { if (is-system-file FILE_PATH) { - edge @source_unit.defs -> @contract.internal + 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 } @@ -179,7 +148,7 @@ inherit .star_extension edge @source_unit.defs -> @using.def } -;; ... and imports +;; Import connections to the source unit @source_unit [SourceUnit [SourceUnitMembers [SourceUnitMember [ImportDirective [ImportClause @import ( @@ -318,33 +287,34 @@ inherit .star_extension ;; interface), aka the source unit edge @type_name.push_end -> heir.parent_scope - ; Make instance members accessible through the lexical scope and from the - ; heir's internal scope (so that inherited internal variables can be accessed) - node internal - attr (internal) push_symbol = "@internal" - edge heir.internal -> internal - edge internal -> @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 qualified with the base name (eg. `Base.something`) + ; 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.internal -> @type_name.pop_begin + edge heir.instance -> @type_name.pop_begin edge @type_name.pop_end -> member_pop - ; Qualified access should also allow us to bind internal members of the parent contract - edge member_pop -> internal + edge member_pop -> instance - ;; Make base defs (eg. enums and structs) accessible as our own + ; 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 - ; Resolve the "super" keyword to the inherited type + ; Resolve the "super" keyword reference to the inherited type edge heir.super -> @type_name.push_begin if (version-matches "< 0.7.0") { - ; `using` directives are inherited in Solidity < 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 @@ -352,6 +322,9 @@ inherit .star_extension } } +;; 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 [_]+ .]] { @@ -374,57 +347,34 @@ inherit .star_extension ;;; Contracts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@contract [ContractDefinition] { +@contract [ContractDefinition @name name: [Identifier]] { node @contract.lexical_scope + node @contract.extended_scope + node @contract.extensions node @contract.def node @contract.members node @contract.ns node @contract.modifiers - node @contract.internal + node @contract.instance - edge @contract.lexical_scope -> @contract.internal + attr (@contract.def) node_definition = @name + attr (@contract.def) definiens_node = @contract - edge @contract.internal -> @contract.members - edge @contract.internal -> @contract.ns + edge @contract.lexical_scope -> @contract.instance - ;; Modifiers are available as a contract type members through a special '@modifier' symbol - node modifier - attr (modifier) pop_symbol = "@modifier" - edge @contract.ns -> modifier - edge modifier -> @contract.modifiers + ; Instance scope can also see members and our namespace definitions + edge @contract.instance -> @contract.members + edge @contract.instance -> @contract.ns let @contract.enclosing_def = @contract.def - ; Path to resolve the built-in type for type() expressions - node type - attr (type) pop_symbol = "%type" - node type_contract_type - attr (type_contract_type) push_symbol = "%typeContractType" - edge @contract.def -> type - edge type -> type_contract_type - edge type_contract_type -> @contract.parent_scope - - ; This is the connection point to resolve attached function by `using for *` - node @contract.star_extension - attr (@contract.star_extension) push_symbol = "@*" - if (version-matches "< 0.7.0") { - ; 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 - } -} - -@contract [ContractDefinition @name name: [Identifier]] { - attr (@contract.def) node_definition = @name - attr (@contract.def) definiens_node = @contract - - ;; "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.internal + edge member -> @contract.members node type_def attr (type_def) pop_symbol = "@typeof" @@ -436,45 +386,54 @@ inherit .star_extension edge @contract.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 + ;; "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 @internal path used by derived contracts to access instance accessible members - node internal - attr (internal) pop_symbol = "@internal" - edge @contract.def -> internal - edge internal -> @contract.internal + ; 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 - ;; Define "this" and connect it to the contract definition + ; "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 + ; ... and resolves 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 - ; For Solidity < 0.5.0 `this` also acts like an `address` + ;; 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 + + ; 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 + 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 @@ -484,22 +443,9 @@ inherit .star_extension edge address_ref -> @contract.lexical_scope } - ;; This defines the sink of edges added from base contracts when setting this - ;; contract as the compilation context - attr (@contract.def) export_node = @contract.internal - - ;; 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 - 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 - attr (@contract.def) import_nodes = [@contract.lexical_scope, @contract.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 @@ -513,35 +459,77 @@ inherit .star_extension ; 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" + node type_contract_type + attr (type_contract_type) push_symbol = "%typeContractType" + edge @contract.def -> type + edge type -> type_contract_type + 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" 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 + ; 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 + ; 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 - ; This allows "instance"-like access to subtypes and implementors of this - ; interface - node super_internal - attr (super_internal) push_symbol = "@internal" - edge @contract.super_import -> super_internal - edge super_internal -> @contract.super_scope - - ;; Finally make "super" available in the contract's extended lexical scope for - ;; function bodies to use - edge @contract.lexical_scope -> @contract.super + ; 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 ; NOTE: The keyword "super" itself resolves to each of its parent contracts. ; See the related rules in the InheritanceSpecifier section above. @@ -550,7 +538,7 @@ inherit .star_extension @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 } @@ -588,10 +576,12 @@ inherit .star_extension @contract [ContractDefinition [ContractMembers [ContractMember @using [UsingDirective]] ]] { - ; Expose the using directive from the extensions scope + ; Hook the using definition in the extensions scope edge @contract.extensions -> @using.def - ; Connect the extensions push path + ; 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 } @@ -604,6 +594,8 @@ inherit .star_extension | [UserDefinedValueTypeDefinition] )] ]] { + ; These definition go into the "namespace" scope and are accessible externally + ; via qualified naming (eg. `Contract.MyStruct`) edge @contract.ns -> @member.def } @@ -612,9 +604,10 @@ inherit .star_extension ]] { ; State variables are available to derived contracts. ; TODO: this also exposes private state variables to derived contracts, but we - ; can't easily express that because we don't have negative assertions in our - ; query language - edge @contract.internal -> @state_var.def + ; 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 @@ -643,13 +636,15 @@ inherit .star_extension [FunctionAttributes [FunctionAttribute ([ExternalKeyword] | [PublicKeyword])]] ]] ]] { - ; public or external functions are also accessible through the contract type + ; 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) @@ -658,13 +653,6 @@ inherit .star_extension attr (@modifier.def) parents = [@contract.def] } -@override [OverrideSpecifier [OverridePathsDeclaration [OverridePaths - @base_ident [IdentifierPath] -]]] { - ;; Resolve overriden bases when listed in the function or modifiers modifiers - edge @base_ident.push_end -> @override.parent_scope -} - @contract [ContractDefinition [ContractMembers [ContractMember [UsingDirective [UsingTarget [Asterisk]]] ]]] { @@ -673,46 +661,45 @@ inherit .star_extension edge @contract.star_extension -> @contract.extended_scope } +; This applies to both state variables and function definitions +@override [OverrideSpecifier [OverridePathsDeclaration [OverridePaths + @base_ident [IdentifierPath] +]]] { + ;; Resolve overriden bases when listed in the function or modifiers modifiers + edge @base_ident.push_end -> @override.parent_scope +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Interfaces ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@interface [InterfaceDefinition] { +@interface [InterfaceDefinition @name name: [Identifier]] { node @interface.lexical_scope node @interface.def node @interface.members node @interface.ns - ; these are unused in interfaces, but required for the inheritance rules - node @interface.internal - node @interface.extensions + node @interface.instance - edge @interface.lexical_scope -> @interface.internal - let @interface.extended_scope = @interface.lexical_scope + attr (@interface.def) node_definition = @name + attr (@interface.def) definiens_node = @interface - edge @interface.internal -> @interface.members - edge @interface.internal -> @interface.ns + edge @interface.lexical_scope -> @interface.instance - ; Path to resolve the built-in type for type() expressions - node type - attr (type) pop_symbol = "%type" - node type_interface_type - attr (type_interface_type) push_symbol = "%typeInterfaceType" - edge @interface.def -> type - edge type -> type_interface_type - edge type_interface_type -> @interface.lexical_scope -} + ; 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) -@interface [InterfaceDefinition @name name: [Identifier]] { - attr (@interface.def) node_definition = @name - attr (@interface.def) definiens_node = @interface + edge @interface.instance -> @interface.members + edge @interface.instance -> @interface.ns - ;; "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" 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.internal + edge member -> @interface.instance node typeof attr (typeof) pop_symbol = "@typeof" @@ -741,11 +728,21 @@ inherit .star_extension edge @interface.def -> ns_member edge ns_member -> @interface.ns - ; Finally there's an @internal path used by derived contracts to access instance accessible members - node internal - attr (internal) pop_symbol = "@internal" - edge @interface.def -> internal - edge internal -> @interface.internal + ; 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" + node type_interface_type + attr (type_interface_type) push_symbol = "%typeInterfaceType" + edge @interface.def -> type + edge type -> type_interface_type + edge type_interface_type -> @interface.parent_scope } @interface [InterfaceDefinition @specifier [InheritanceSpecifier]] { @@ -782,7 +779,7 @@ inherit .star_extension [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) } @@ -791,31 +788,30 @@ inherit .star_extension ;;; Libraries ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@library [LibraryDefinition] { +@library [LibraryDefinition @name name: [Identifier]] { node @library.lexical_scope + node @library.extended_scope + node @library.extensions node @library.def node @library.ns node @library.modifiers - edge @library.lexical_scope -> @library.ns - - ; Access to modifiers is guarded by a @modifier symbol - node modifier - attr (modifier) pop_symbol = "@modifier" - edge @library.ns -> modifier - edge modifier -> @library.modifiers -} - -@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 + ; 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" @@ -868,12 +864,54 @@ inherit .star_extension } +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; 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 +} + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; 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 @@ -881,8 +919,9 @@ inherit .star_extension ; 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 } @@ -910,7 +949,7 @@ inherit .star_extension ]] ]]] { ; 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 = "." @@ -939,7 +978,7 @@ inherit .star_extension ; resolve the target type of the directive on the extended scope so the ; extension scope gets re-pushed - edge @type_name.type_ref -> @using.lexical_scope + edge @type_name.type_ref -> @using.extended_scope } [ContractMember @using [UsingDirective [UsingTarget [Asterisk]]]] { @@ -955,7 +994,7 @@ inherit .star_extension ;;; 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) @@ -964,6 +1003,12 @@ inherit .star_extension ;; - @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 @@ -1072,12 +1117,16 @@ inherit .star_extension node @mapping.lexical_scope node @mapping.output - node @mapping.type - attr (@mapping.type) push_symbol = "%mapping" - edge @mapping.output -> @mapping.type - - edge @mapping.type -> @key_type.push_begin + ; 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 @@ -1104,10 +1153,8 @@ inherit .star_extension edge typeof_input -> getter_call edge getter_call -> typeof_output - ; resolve the value type through our scope - edge @value_type.type_ref -> @mapping.lexical_scope - ; 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" @@ -1128,54 +1175,42 @@ inherit .star_extension } @array [ArrayTypeName [TypeName] index: [Expression]] { - let @array.type = "%arrayFixed" + let @array.type_symbol = "%arrayFixed" } @array [ArrayTypeName [OpenBracket] . [CloseBracket]] { - let @array.type = "%array" + let @array.type_symbol = "%array" } @array [ArrayTypeName @type_name [TypeName]] { + ; 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 + ; 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 - ; Define some built-in functions and operators that return the element's type - ; typeof_input or member is where all these definitions begin + ; Define the path to resolve index access (aka the `[]` operator) + node typeof_input attr (typeof_input) pop_symbol = "@typeof" - node member - attr (member) pop_symbol = "." edge @array.output -> typeof_input - edge typeof_input -> member - ; and all of them end in typeof_output connecting to the element type node typeof_output attr (typeof_output) push_symbol = "@typeof" edge typeof_output -> @type_name.output - ; Define the path to resolve index access (aka the `[]` operator) node index attr (index) pop_symbol = "[]" edge typeof_input -> index edge index -> 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 push_built_in - attr (push_built_in) pop_symbol = "push" - node call - attr (call) pop_symbol = "()" - edge member -> push_built_in - edge push_built_in -> call - edge call -> 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. @@ -1184,10 +1219,25 @@ inherit .star_extension 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 @@ -1202,10 +1252,10 @@ inherit .star_extension @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 = "%functionExternal" } } @@ -1215,14 +1265,14 @@ inherit .star_extension ; 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 @@ -1239,8 +1289,9 @@ inherit .star_extension @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" @@ -1267,14 +1318,14 @@ inherit .star_extension ;; @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 @@ -1360,10 +1411,10 @@ inherit .star_extension } @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 = "%functionExternal" } } @@ -1376,7 +1427,7 @@ inherit .star_extension 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 @@ -2041,13 +2092,11 @@ inherit .star_extension ;;; 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 @@ -2105,7 +2154,7 @@ inherit .star_extension edge @struct.def -> param_names edge param_names -> @struct.members - ; Used as a function call, should bind to itself + ; Used as a function call (ie. casting), should bind to itself node call attr (call) pop_symbol = "()" edge @struct.def -> call From 05d27d66976ee287ac14348a6f886f0a6b9a85ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 18 Nov 2024 15:41:48 -0500 Subject: [PATCH 49/66] Use PascalCase for most built-in types Excluded are special cases such as `%address` since the symbol is directly constructed from the keyword. --- .../inputs/language/bindings/rules.msgb | 42 ++++----- .../inputs/language/src/definition.rs | 90 +++++++++---------- .../bindings/generated/binding_rules.rs | 42 ++++----- .../bindings/generated/built_ins/0.4.11.sol | 54 +++++------ .../bindings/generated/built_ins/0.4.17.sol | 56 ++++++------ .../bindings/generated/built_ins/0.4.22.sol | 64 ++++++------- .../bindings/generated/built_ins/0.5.0.sol | 66 +++++++------- .../bindings/generated/built_ins/0.5.3.sol | 66 +++++++------- .../bindings/generated/built_ins/0.6.0.sol | 68 +++++++------- .../bindings/generated/built_ins/0.6.2.sol | 70 +++++++-------- .../bindings/generated/built_ins/0.6.7.sol | 70 +++++++-------- .../bindings/generated/built_ins/0.6.8.sol | 70 +++++++-------- .../bindings/generated/built_ins/0.7.0.sol | 62 ++++++------- .../bindings/generated/built_ins/0.8.0.sol | 62 ++++++------- .../bindings/generated/built_ins/0.8.11.sol | 76 ++++++++-------- .../bindings/generated/built_ins/0.8.18.sol | 76 ++++++++-------- .../bindings/generated/built_ins/0.8.2.sol | 64 ++++++------- .../bindings/generated/built_ins/0.8.24.sol | 76 ++++++++-------- .../bindings/generated/built_ins/0.8.26.sol | 76 ++++++++-------- .../bindings/generated/built_ins/0.8.4.sol | 66 +++++++------- .../bindings/generated/built_ins/0.8.7.sol | 66 +++++++------- .../bindings/generated/built_ins/0.8.8.sol | 74 +++++++-------- 22 files changed, 728 insertions(+), 728 deletions(-) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 47e9bf7ccc..8a0548462b 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -463,9 +463,9 @@ inherit .star_extension ; 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.parent_scope @@ -732,9 +732,9 @@ inherit .star_extension ; 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.parent_scope @@ -809,9 +809,9 @@ inherit .star_extension ; 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 @@ -1117,7 +1117,7 @@ inherit .star_extension ; KeyType ; %mapping <- bottom of the symbol stack node mapping - attr (mapping) push_symbol = "%mapping" + attr (mapping) push_symbol = "%Mapping" edge @mapping.output -> mapping edge mapping -> @key_type.push_begin edge @key_type.push_end -> @value_type.output @@ -1151,7 +1151,7 @@ inherit .star_extension ; 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" + attr (pop_mapping) pop_symbol = "%Mapping" let @mapping.pop_begin = @value_type.pop_begin edge @value_type.pop_end -> @key_type.pop_begin @@ -1170,11 +1170,11 @@ inherit .star_extension } @array [ArrayTypeName [TypeName] index: [Expression]] { - let @array.type_symbol = "%arrayFixed" + let @array.type_symbol = "%FixedArray" } @array [ArrayTypeName [OpenBracket] . [CloseBracket]] { - let @array.type_symbol = "%array" + let @array.type_symbol = "%Array" } @array [ArrayTypeName @type_name [TypeName]] { @@ -1247,10 +1247,10 @@ inherit .star_extension @ftype [FunctionType @attrs [FunctionTypeAttributes]] { ; Compute the built-in type of the function ; %functionExternal provides access to .selector and .address - var type_symbol = "%function" + var type_symbol = "%Function" scan (source-text @attrs) { "external" { - set type_symbol = "%functionExternal" + set type_symbol = "%ExternalFunction" } } @@ -1406,10 +1406,10 @@ inherit .star_extension } @function [FunctionDefinition @attrs [FunctionAttributes]] { - var type_symbol = "%function" + var type_symbol = "%Function" scan (source-text @attrs) { "\\b(public|external)\\b" { - set type_symbol = "%functionExternal" + set type_symbol = "%ExternalFunction" } } @@ -2103,9 +2103,9 @@ inherit .star_extension ; 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 @@ -2229,7 +2229,7 @@ inherit .star_extension node typeof attr (typeof) push_symbol = "@typeof" node error_type - attr (error_type) push_symbol = "%errorType" + attr (error_type) push_symbol = "%ErrorType" edge @error.def -> typeof edge typeof -> error_type edge error_type -> @error.lexical_scope @@ -2292,7 +2292,7 @@ inherit .star_extension node typeof attr (typeof) push_symbol = "@typeof" node user_type_type - attr (user_type_type) push_symbol = "%userTypeType" + attr (user_type_type) push_symbol = "%UserTypeType" edge @user_type.def -> member_guard edge member_guard -> member @@ -2426,7 +2426,7 @@ inherit .star_extension 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 @@ -2438,7 +2438,7 @@ inherit .star_extension 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 @@ -2502,7 +2502,7 @@ inherit .star_extension 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 diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index f7feb7e121..fad531ac10 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -6733,42 +6733,42 @@ 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", "$Types"], + return_type = "$Types", enabled = From("0.5.0") ), BuiltInFunction( name = "encode", - parameters = ["$args"], + parameters = ["$Types"], return_type = "bytes memory", enabled = From("0.4.22") ), BuiltInFunction( name = "encodeCall", - parameters = ["function()", "$args"], + parameters = ["function()", "$Args"], return_type = "bytes memory", enabled = From("0.8.11") ), BuiltInFunction( name = "encodePacked", - parameters = ["$args"], + parameters = ["$Args"], return_type = "bytes memory", enabled = From("0.4.22") ), BuiltInFunction( name = "encodeWithSelector", - parameters = ["bytes4 selector", "$args"], + parameters = ["bytes4 selector", "$Args"], return_type = "bytes memory", enabled = From("0.4.22") ), BuiltInFunction( name = "encodeWithSignature", - parameters = ["string memory", "$args"], + parameters = ["string memory", "$Args"], return_type = "bytes memory", enabled = From("0.4.22") ) @@ -6827,36 +6827,36 @@ codegen_language_macros::compile!(Language( ] ), BuiltInType( - name = "$array", + name = "$Array", fields = [BuiltInField(definition = "uint length")], functions = [ BuiltInFunction( name = "push", parameters = [], - return_type = "$element", + return_type = "$ValueType", enabled = From("0.6.0") ), BuiltInFunction( name = "push", - parameters = ["$element"], + parameters = ["$ValueType"], return_type = "uint", enabled = Till("0.6.0") ), BuiltInFunction( name = "push", - parameters = ["$element"], + parameters = ["$ValueType"], enabled = From("0.6.0") ), BuiltInFunction(name = "pop", parameters = []) ] ), BuiltInType( - name = "$arrayFixed", + name = "$FixedArray", fields = [BuiltInField(definition = "uint length")], 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")), @@ -6881,16 +6881,16 @@ codegen_language_macros::compile!(Language( functions = [] ), BuiltInType( - name = "$bytesType", + name = "$BytesType", fields = [], functions = [BuiltInFunction( name = "concat", - parameters = ["$args"], + parameters = ["$Args"], return_type = "bytes memory" )] ), BuiltInType( - name = "$callOptions", + name = "$CallOptions", fields = [ BuiltInField(definition = "uint gas"), BuiltInField(definition = "uint salt"), @@ -6900,52 +6900,52 @@ codegen_language_macros::compile!(Language( enabled = From("0.6.2") ), BuiltInType( - name = "$errorType", + name = "$ErrorType", fields = [BuiltInField(definition = "bytes4 selector")], functions = [], enabled = From("0.8.4") ), BuiltInType( - name = "$function", + name = "$Function", fields = [], functions = [ BuiltInFunction( name = "gas", parameters = ["uint"], - return_type = "$function", + return_type = "function()", enabled = Till("0.7.0") ), BuiltInFunction( name = "value", parameters = ["uint"], - return_type = "$function", + return_type = "function()", enabled = Till("0.7.0") ) ] ), BuiltInType( - name = "$functionExternal", + 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", + return_type = "function()", enabled = Till("0.7.0") ), BuiltInFunction( name = "value", parameters = ["uint"], - return_type = "$function", + 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")), @@ -6960,16 +6960,16 @@ codegen_language_macros::compile!(Language( functions = [] ), BuiltInType( - name = "$stringType", + name = "$StringType", fields = [], functions = [BuiltInFunction( name = "concat", - parameters = ["$args"], + parameters = ["$Args"], return_type = "string memory" )] ), BuiltInType( - name = "$txType", + name = "$TransactionType", fields = [ BuiltInField(definition = "uint gasprice"), BuiltInField( @@ -6981,7 +6981,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")), @@ -6991,7 +6991,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")) @@ -6999,7 +6999,7 @@ 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")) @@ -7007,29 +7007,29 @@ codegen_language_macros::compile!(Language( functions = [] ), BuiltInType( - name = "$userTypeType", + name = "$UserTypeType", fields = [], functions = [ BuiltInFunction( name = "wrap", - parameters = ["$elementaryType"], - return_type = "$userType" + parameters = ["$WrappedType"], + return_type = "$UserType" ), BuiltInFunction( name = "unwrap", - parameters = ["$userType"], - return_type = "$elementaryType" + parameters = ["$UserType"], + return_type = "$WrappedType" ) ], enabled = From("0.8.8") ), - BuiltInVariable(definition = "$function $placeholder"), - BuiltInVariable(definition = "$abiType abi"), - BuiltInVariable(definition = "$blockType block"), - BuiltInVariable(definition = "$bytesType $bytes"), - BuiltInVariable(definition = "$msgType msg"), + 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 = "$stringType $string"), - 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 47926d0d4f..580dbfae21 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 @@ -468,9 +468,9 @@ inherit .star_extension ; 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.parent_scope @@ -737,9 +737,9 @@ inherit .star_extension ; 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.parent_scope @@ -814,9 +814,9 @@ inherit .star_extension ; 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 @@ -1122,7 +1122,7 @@ inherit .star_extension ; KeyType ; %mapping <- bottom of the symbol stack node mapping - attr (mapping) push_symbol = "%mapping" + attr (mapping) push_symbol = "%Mapping" edge @mapping.output -> mapping edge mapping -> @key_type.push_begin edge @key_type.push_end -> @value_type.output @@ -1156,7 +1156,7 @@ inherit .star_extension ; 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" + attr (pop_mapping) pop_symbol = "%Mapping" let @mapping.pop_begin = @value_type.pop_begin edge @value_type.pop_end -> @key_type.pop_begin @@ -1175,11 +1175,11 @@ inherit .star_extension } @array [ArrayTypeName [TypeName] index: [Expression]] { - let @array.type_symbol = "%arrayFixed" + let @array.type_symbol = "%FixedArray" } @array [ArrayTypeName [OpenBracket] . [CloseBracket]] { - let @array.type_symbol = "%array" + let @array.type_symbol = "%Array" } @array [ArrayTypeName @type_name [TypeName]] { @@ -1252,10 +1252,10 @@ inherit .star_extension @ftype [FunctionType @attrs [FunctionTypeAttributes]] { ; Compute the built-in type of the function ; %functionExternal provides access to .selector and .address - var type_symbol = "%function" + var type_symbol = "%Function" scan (source-text @attrs) { "external" { - set type_symbol = "%functionExternal" + set type_symbol = "%ExternalFunction" } } @@ -1411,10 +1411,10 @@ inherit .star_extension } @function [FunctionDefinition @attrs [FunctionAttributes]] { - var type_symbol = "%function" + var type_symbol = "%Function" scan (source-text @attrs) { "\\b(public|external)\\b" { - set type_symbol = "%functionExternal" + set type_symbol = "%ExternalFunction" } } @@ -2108,9 +2108,9 @@ inherit .star_extension ; 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 @@ -2234,7 +2234,7 @@ inherit .star_extension node typeof attr (typeof) push_symbol = "@typeof" node error_type - attr (error_type) push_symbol = "%errorType" + attr (error_type) push_symbol = "%ErrorType" edge @error.def -> typeof edge typeof -> error_type edge error_type -> @error.lexical_scope @@ -2297,7 +2297,7 @@ inherit .star_extension node typeof attr (typeof) push_symbol = "@typeof" node user_type_type - attr (user_type_type) push_symbol = "%userTypeType" + attr (user_type_type) push_symbol = "%UserTypeType" edge @user_type.def -> member_guard edge member_guard -> member @@ -2431,7 +2431,7 @@ inherit .star_extension 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 @@ -2443,7 +2443,7 @@ inherit .star_extension 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 @@ -2507,7 +2507,7 @@ inherit .star_extension 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 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 d7805fc05e..499eb25414 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,7 +18,7 @@ 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; @@ -28,15 +28,15 @@ contract $BuiltIns$ { function(uint256) returns (bool) send; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function($element) returns (uint) push; + function($ValueType) returns (uint) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -47,45 +47,45 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $function { - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $Function { + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $functionExternal { - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; uint256 gas; address payable sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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 { } - $function $placeholder; - $abiType abi; - $blockType block; - $bytesType $bytes; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $stringType $string; - $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 01f0d73a3f..332f858690 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,7 +18,7 @@ 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; @@ -28,15 +28,15 @@ contract $BuiltIns$ { function(uint256) returns (bool) send; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function($element) returns (uint) push; + function($ValueType) returns (uint) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -47,46 +47,46 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $function { - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $Function { + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; uint256 gas; address payable sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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 { } - $function $placeholder; - $abiType abi; - $blockType block; - $bytesType $bytes; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $stringType $string; - $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 d57f6288ba..7a1775459c 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,11 +22,11 @@ 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($Types) 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 $address { uint256 balance; @@ -36,15 +36,15 @@ contract $BuiltIns$ { function(uint256) returns (bool) send; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function($element) returns (uint) push; + function($ValueType) returns (uint) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -55,46 +55,46 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $function { - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $Function { + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; uint256 gas; address payable sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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 { } - $function $placeholder; - $abiType abi; - $blockType block; - $bytesType $bytes; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $stringType $string; - $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 2d2a60e286..c6c26e0c86 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,12 +20,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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -35,15 +35,15 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function($element) returns (uint) push; + function($ValueType) returns (uint) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -53,45 +53,45 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $function { - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $Function { + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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 { } - $function $placeholder; - $abiType abi; - $blockType block; - $bytesType $bytes; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $stringType $string; - $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 81c206a985..0346de509a 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,12 +20,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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -35,15 +35,15 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function($element) returns (uint) push; + function($ValueType) returns (uint) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -53,47 +53,47 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $function { - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $Function { + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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 { } - $function $placeholder; - $abiType abi; - $blockType block; - $bytesType $bytes; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $stringType $string; - $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 5543bbe614..a13c4e542c 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,12 +20,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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -35,16 +35,16 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -54,47 +54,47 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $function { - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $Function { + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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 { } - $function $placeholder; - $abiType abi; - $blockType block; - $bytesType $bytes; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $stringType $string; - $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 5141829876..38b69ef7b9 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,12 +20,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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -35,16 +35,16 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -54,52 +54,52 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $function { - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $Function { + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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 { } - $function $placeholder; - $abiType abi; - $blockType block; - $bytesType $bytes; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $stringType $string; - $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 0911cb8672..b08813644a 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,12 +20,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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -35,16 +35,16 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -54,54 +54,54 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $function { - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $Function { + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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 { } - $function $placeholder; - $abiType abi; - $blockType block; - $bytesType $bytes; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $stringType $string; - $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 e842ce4b21..00bb851f84 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,12 +20,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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -35,16 +35,16 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -54,56 +54,56 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $function { - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $Function { + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $functionExternal { - $selector selector; - function(uint) returns ($function) gas; - function(uint) returns ($function) value; + struct $ExternalFunction { + bytes4 selector; + function(uint) returns (function()) gas; + function(uint) returns (function()) value; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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; - $bytesType $bytes; - $msgType msg; + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; uint now; - $stringType $string; - $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 8a79c62142..59693bdbf7 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,12 +20,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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -35,16 +35,16 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { address payable coinbase; uint difficulty; uint gaslimit; @@ -54,51 +54,51 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $function { + struct $Function { } - struct $functionExternal { - $selector selector; + struct $ExternalFunction { + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address payable sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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; - $bytesType $bytes; - $msgType msg; - $stringType $string; - $txType tx; + $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 07452d0050..d79985d35e 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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -32,16 +32,16 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { uint chainid; address payable coinbase; uint difficulty; @@ -52,51 +52,51 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $function { + struct $Function { } - struct $functionExternal { - $selector selector; + struct $ExternalFunction { + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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; - $bytesType $bytes; - $msgType msg; - $stringType $string; - $txType tx; + $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 98330bb063..80f0a726c7 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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -33,16 +33,16 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { uint basefee; uint chainid; address payable coinbase; @@ -54,59 +54,59 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $errorType { + struct $ErrorType { bytes4 selector; } - struct $function { + struct $Function { } - struct $functionExternal { - $address address; - $selector selector; + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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; } - struct $userTypeType { - function($elementaryType) returns ($userType) wrap; - function($userType) returns ($elementaryType) unwrap; - } - $function $placeholder; - $abiType abi; - $blockType block; - $bytesType $bytes; - $msgType msg; - $stringType $string; - $txType tx; + struct $UserTypeType { + function($WrappedType) returns ($UserType) wrap; + function($UserType) returns ($WrappedType) unwrap; + } + $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 116dff6600..dc48f023b3 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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -33,16 +33,16 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { uint basefee; uint chainid; address payable coinbase; @@ -55,59 +55,59 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $errorType { + struct $ErrorType { bytes4 selector; } - struct $function { + struct $Function { } - struct $functionExternal { - $address address; - $selector selector; + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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; } - struct $userTypeType { - function($elementaryType) returns ($userType) wrap; - function($userType) returns ($elementaryType) unwrap; - } - $function $placeholder; - $abiType abi; - $blockType block; - $bytesType $bytes; - $msgType msg; - $stringType $string; - $txType tx; + struct $UserTypeType { + function($WrappedType) returns ($UserType) wrap; + function($UserType) returns ($WrappedType) unwrap; + } + $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 8214500c64..cd29e13de1 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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -32,16 +32,16 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { uint chainid; address payable coinbase; uint difficulty; @@ -52,52 +52,52 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $function { + struct $Function { } - struct $functionExternal { - $address address; - $selector selector; + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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; - $bytesType $bytes; - $msgType msg; - $stringType $string; - $txType tx; + $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 e703c6ed42..cc072c1e80 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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -34,16 +34,16 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { uint basefee; uint blobbasefee; uint chainid; @@ -57,59 +57,59 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $errorType { + struct $ErrorType { bytes4 selector; } - struct $function { + struct $Function { } - struct $functionExternal { - $address address; - $selector selector; + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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; } - struct $userTypeType { - function($elementaryType) returns ($userType) wrap; - function($userType) returns ($elementaryType) unwrap; - } - $function $placeholder; - $abiType abi; - $blockType block; - $bytesType $bytes; - $msgType msg; - $stringType $string; - $txType tx; + struct $UserTypeType { + function($WrappedType) returns ($UserType) wrap; + function($UserType) returns ($WrappedType) unwrap; + } + $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 426ff39b2d..8aebc5b1b9 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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -35,16 +35,16 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { uint basefee; uint blobbasefee; uint chainid; @@ -58,59 +58,59 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $errorType { + struct $ErrorType { bytes4 selector; } - struct $function { + struct $Function { } - struct $functionExternal { - $address address; - $selector selector; + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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; } - struct $userTypeType { - function($elementaryType) returns ($userType) wrap; - function($userType) returns ($elementaryType) unwrap; - } - $function $placeholder; - $abiType abi; - $blockType block; - $bytesType $bytes; - $msgType msg; - $stringType $string; - $txType tx; + struct $UserTypeType { + function($WrappedType) returns ($UserType) wrap; + function($UserType) returns ($WrappedType) unwrap; + } + $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 index 6a5244aa2f..66c234728d 100644 --- 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 @@ -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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -32,16 +32,16 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { uint chainid; address payable coinbase; uint difficulty; @@ -52,55 +52,55 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $errorType { + struct $ErrorType { bytes4 selector; } - struct $function { + struct $Function { } - struct $functionExternal { - $address address; - $selector selector; + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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; - $bytesType $bytes; - $msgType msg; - $stringType $string; - $txType tx; + $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 c1b10cae46..b1f85bd53f 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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -32,16 +32,16 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { uint basefee; uint chainid; address payable coinbase; @@ -53,55 +53,55 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $errorType { + struct $ErrorType { bytes4 selector; } - struct $function { + struct $Function { } - struct $functionExternal { - $address address; - $selector selector; + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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; - $bytesType $bytes; - $msgType msg; - $stringType $string; - $txType tx; + $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 index 212294a258..7eb9115f2e 100644 --- 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 @@ -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, $Types) returns ($Types) decode; + function($Types) 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 $address { uint256 balance; @@ -32,16 +32,16 @@ contract $BuiltIns$ { function(bytes memory) returns (bool, bytes memory) staticcall; function(uint256) transfer; } - struct $array { + struct $Array { uint length; - function() returns ($element) push; - function($element) push; + function() returns ($ValueType) push; + function($ValueType) push; function() pop; } - struct $arrayFixed { + struct $FixedArray { uint length; } - struct $blockType { + struct $BlockType { uint basefee; uint chainid; address payable coinbase; @@ -53,59 +53,59 @@ contract $BuiltIns$ { struct $bytes { uint length; } - struct $bytesType { - function($args) returns (bytes memory) concat; + struct $BytesType { + function($Args) returns (bytes memory) concat; } - struct $callOptions { + struct $CallOptions { uint gas; uint salt; uint value; } - struct $errorType { + struct $ErrorType { bytes4 selector; } - struct $function { + struct $Function { } - struct $functionExternal { - $address address; - $selector selector; + struct $ExternalFunction { + address address; + bytes4 selector; } - struct $msgType { + struct $MessageType { bytes data; address sender; bytes4 sig; uint value; } - struct $stringType { - function($args) returns (string memory) concat; + struct $StringType { + function($Args) 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; } - struct $userTypeType { - function($elementaryType) returns ($userType) wrap; - function($userType) returns ($elementaryType) unwrap; - } - $function $placeholder; - $abiType abi; - $blockType block; - $bytesType $bytes; - $msgType msg; - $stringType $string; - $txType tx; + struct $UserTypeType { + function($WrappedType) returns ($UserType) wrap; + function($UserType) returns ($WrappedType) unwrap; + } + $Function $placeholder; + $AbiType abi; + $BlockType block; + $BytesType $bytes; + $MessageType msg; + $StringType $string; + $TransactionType tx; } From 45791823d8268ad9d4d50377d53f98607c94525a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 19 Nov 2024 19:32:28 -0500 Subject: [PATCH 50/66] Bind members of Yul external variables --- .../inputs/language/bindings/rules.msgb | 22 +++++++++++++- .../inputs/language/src/definition.rs | 11 +++++++ .../bindings/generated/binding_rules.rs | 22 +++++++++++++- .../bindings/generated/built_ins/0.4.11.sol | 5 ++++ .../bindings/generated/built_ins/0.4.17.sol | 5 ++++ .../bindings/generated/built_ins/0.4.22.sol | 5 ++++ .../bindings/generated/built_ins/0.5.0.sol | 5 ++++ .../bindings/generated/built_ins/0.5.3.sol | 5 ++++ .../bindings/generated/built_ins/0.6.0.sol | 5 ++++ .../bindings/generated/built_ins/0.6.2.sol | 5 ++++ .../bindings/generated/built_ins/0.6.7.sol | 5 ++++ .../bindings/generated/built_ins/0.6.8.sol | 5 ++++ .../bindings/generated/built_ins/0.7.0.sol | 5 ++++ .../bindings/generated/built_ins/0.8.0.sol | 5 ++++ .../bindings/generated/built_ins/0.8.11.sol | 5 ++++ .../bindings/generated/built_ins/0.8.18.sol | 5 ++++ .../bindings/generated/built_ins/0.8.2.sol | 5 ++++ .../bindings/generated/built_ins/0.8.24.sol | 5 ++++ .../bindings/generated/built_ins/0.8.26.sol | 5 ++++ .../bindings/generated/built_ins/0.8.4.sol | 5 ++++ .../bindings/generated/built_ins/0.8.7.sol | 5 ++++ .../bindings/generated/built_ins/0.8.8.sol | 5 ++++ .../src/bindings_output/generated/yul.rs | 5 ++++ .../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 | 20 ++++++++----- .../slot_suffix/generated/0.7.0-failure.txt | 18 +++++++---- .../bindings_output/yul/slot_suffix/input.sol | 4 ++- 30 files changed, 276 insertions(+), 16 deletions(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 8a0548462b..a9bbafec36 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -2867,9 +2867,11 @@ inherit .star_extension edge @path.lexical_scope -> @expr.lexical_scope } -@path [YulPath @name [YulIdentifier]] { +@path [YulPath] { node @path.lexical_scope +} +@path [YulPath . @name [YulIdentifier]] { node ref attr (ref) node_reference = @name @@ -2894,6 +2896,24 @@ inherit .star_extension } } +@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_variable + attr (yul_variable) push_symbol = "%YulExternal" + + edge ref -> member_of + edge member_of -> typeof + edge typeof -> yul_variable + edge yul_variable -> @path.lexical_scope +} + @expr [YulExpression @funcall [YulFunctionCallExpression]] { edge @funcall.lexical_scope -> @expr.lexical_scope } diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index fad531ac10..6b86eb5a84 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -7023,6 +7023,17 @@ codegen_language_macros::compile!(Language( ], 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"), 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 580dbfae21..01038c1eaa 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 @@ -2872,9 +2872,11 @@ inherit .star_extension edge @path.lexical_scope -> @expr.lexical_scope } -@path [YulPath @name [YulIdentifier]] { +@path [YulPath] { node @path.lexical_scope +} +@path [YulPath . @name [YulIdentifier]] { node ref attr (ref) node_reference = @name @@ -2899,6 +2901,24 @@ inherit .star_extension } } +@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_variable + attr (yul_variable) push_symbol = "%YulExternal" + + edge ref -> member_of + edge member_of -> typeof + edge typeof -> yul_variable + edge yul_variable -> @path.lexical_scope +} + @expr [YulExpression @funcall [YulFunctionCallExpression]] { edge @funcall.lexical_scope -> @expr.lexical_scope } 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 499eb25414..4e3105da55 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 @@ -80,6 +80,11 @@ contract $BuiltIns$ { } struct $IntTypeType { } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 332f858690..a498afc11d 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 @@ -81,6 +81,11 @@ contract $BuiltIns$ { } struct $IntTypeType { } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 7a1775459c..52d488972b 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 @@ -89,6 +89,11 @@ contract $BuiltIns$ { } struct $IntTypeType { } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 c6c26e0c86..2120032a9d 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 @@ -86,6 +86,11 @@ contract $BuiltIns$ { } struct $IntTypeType { } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 0346de509a..933d2b2974 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 @@ -88,6 +88,11 @@ contract $BuiltIns$ { } struct $IntTypeType { } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 a13c4e542c..9fc956e1d0 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 @@ -89,6 +89,11 @@ contract $BuiltIns$ { } struct $IntTypeType { } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 38b69ef7b9..723268f886 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 @@ -94,6 +94,11 @@ contract $BuiltIns$ { } struct $IntTypeType { } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 b08813644a..028e6a6409 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 @@ -96,6 +96,11 @@ contract $BuiltIns$ { } struct $IntTypeType { } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 00bb851f84..212f7519a6 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 @@ -98,6 +98,11 @@ contract $BuiltIns$ { int min; int max; } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 59693bdbf7..039badc54c 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 @@ -94,6 +94,11 @@ contract $BuiltIns$ { int min; int max; } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 d79985d35e..a0b984ddbd 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 @@ -92,6 +92,11 @@ contract $BuiltIns$ { int min; int max; } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 80f0a726c7..0c8ef5cf21 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 @@ -102,6 +102,11 @@ contract $BuiltIns$ { function($WrappedType) returns ($UserType) wrap; function($UserType) returns ($WrappedType) unwrap; } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 dc48f023b3..b0c1e383af 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 @@ -103,6 +103,11 @@ contract $BuiltIns$ { function($WrappedType) returns ($UserType) wrap; function($UserType) returns ($WrappedType) unwrap; } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 cd29e13de1..06bcad256f 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 @@ -93,6 +93,11 @@ contract $BuiltIns$ { int min; int max; } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 cc072c1e80..6b3c804653 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 @@ -105,6 +105,11 @@ contract $BuiltIns$ { function($WrappedType) returns ($UserType) wrap; function($UserType) returns ($WrappedType) unwrap; } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 8aebc5b1b9..22b2a69ffc 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 @@ -106,6 +106,11 @@ contract $BuiltIns$ { function($WrappedType) returns ($UserType) wrap; function($UserType) returns ($WrappedType) unwrap; } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 index 66c234728d..f4a45098fb 100644 --- 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 @@ -96,6 +96,11 @@ contract $BuiltIns$ { int min; int max; } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 b1f85bd53f..136be02900 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 @@ -97,6 +97,11 @@ contract $BuiltIns$ { int min; int max; } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 index 7eb9115f2e..ce56d9c9f8 100644 --- 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 @@ -101,6 +101,11 @@ contract $BuiltIns$ { function($WrappedType) returns ($UserType) wrap; function($UserType) returns ($WrappedType) unwrap; } + struct $YulExternal { + uint slot; + uint offset; + uint length; + } $Function $placeholder; $AbiType abi; $BlockType block; 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 cbe0d9e2ea..46aa3d6ad4 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 @@ -19,6 +19,11 @@ 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") 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 index 431def7d7e..c7e17557b8 100644 --- 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 @@ -6,15 +6,21 @@ References and definitions: 1 │ contract Test { │ ──┬─ │ ╰─── def: 1 - 2 │ function test(bytes storage data) public { - │ ──┬─ ──┬─ - │ ╰────────────────────── def: 2 - │ │ - │ ╰─── def: 3 + 2 │ bytes data; + │ ──┬─ + │ ╰─── def: 2 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 │ - 4 │ let s := sload(data_slot) + 5 │ let s := sload(data_slot) │ ┬ ────┬──── │ ╰───────────────────── def: 4 │ │ - │ ╰────── ref: 3 + │ ╰────── ref: 2 + 6 │ let o := sload(data_offset) + │ ┬ ─────┬───── + │ ╰─────────────────────── def: 5 + │ │ + │ ╰─────── ref: 2 ───╯ 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 index 768d179868..8745d145dd 100644 --- 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 @@ -6,15 +6,21 @@ References and definitions: 1 │ contract Test { │ ──┬─ │ ╰─── def: 1 - 2 │ function test(bytes storage data) public { - │ ──┬─ ──┬─ - │ ╰────────────────────── def: 2 - │ │ - │ ╰─── def: 3 + 2 │ bytes data; + │ ──┬─ + │ ╰─── def: 2 + 3 │ function test() public { + │ ──┬─ + │ ╰─── def: 3 │ - 4 │ let s := sload(data_slot) + 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 index f2b5e647f7..67caad33a2 100644 --- a/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/input.sol +++ b/crates/solidity/testing/snapshots/bindings_output/yul/slot_suffix/input.sol @@ -1,7 +1,9 @@ contract Test { - function test(bytes storage data) public { + bytes data; + function test() public { assembly { let s := sload(data_slot) + let o := sload(data_offset) } } } From 9aab1b366b8285197de6a480fd09c43176822b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Wed, 20 Nov 2024 12:02:04 -0500 Subject: [PATCH 51/66] Fix binding structs as public getter results A public getter will never return a complex data type, and a special getter function is generated for arrays, mappings and structs. Arrays and mappings we were already handling, but this commit makes that more explicit. For structs, we bind the type of the first field. There is a caveat here: if the first field is not a type that can be flattened and returned in a public getter we're still binding it, instead of the first field that can be returned. But I don't see a way to be 100% correct here. --- .../inputs/language/bindings/rules.msgb | 45 ++++++++---- .../bindings/generated/binding_rules.rs | 45 ++++++++---- .../bindings_output/generated/contracts.rs | 15 ++-- .../generated/0.4.11-success.txt | 66 +++++++---------- .../contracts/public_array_getters/input.sol | 8 +-- .../generated/0.4.11-success.txt | 30 ++++++++ .../input.sol | 5 +- .../generated/0.4.11-success.txt | 70 +++++++------------ .../public_mapping_getters/input.sol | 8 +-- .../generated/0.4.11-success.txt | 26 +++---- .../contracts/public_struct_getter/input.sol | 9 +++ 11 files changed, 184 insertions(+), 143 deletions(-) create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/generated/0.4.11-success.txt rename crates/solidity/testing/snapshots/bindings_output/contracts/{call_public_getter => public_getter_members}/input.sol (51%) rename crates/solidity/testing/snapshots/bindings_output/contracts/{call_public_getter => public_struct_getter}/generated/0.4.11-success.txt (55%) create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/input.sol diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index a9bbafec36..f63b44a53a 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -1144,7 +1144,7 @@ inherit .star_extension ; 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 = "()" + attr (getter_call) pop_symbol = "@as_getter" edge typeof_input -> getter_call edge getter_call -> typeof_output @@ -1210,7 +1210,7 @@ inherit .star_extension ; like a function with an index, and it's effectively the same as indexing the ; array. node getter_call - attr (getter_call) pop_symbol = "()" + attr (getter_call) pop_symbol = "@as_getter" edge typeof_input -> getter_call edge getter_call -> typeof_output @@ -2072,8 +2072,16 @@ inherit .star_extension 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 @@ -2135,12 +2143,12 @@ inherit .star_extension 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 @struct.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 @@ -2159,19 +2167,28 @@ inherit .star_extension @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 } 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 01038c1eaa..f062f43628 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 @@ -1149,7 +1149,7 @@ inherit .star_extension ; 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 = "()" + attr (getter_call) pop_symbol = "@as_getter" edge typeof_input -> getter_call edge getter_call -> typeof_output @@ -1215,7 +1215,7 @@ inherit .star_extension ; like a function with an index, and it's effectively the same as indexing the ; array. node getter_call - attr (getter_call) pop_symbol = "()" + attr (getter_call) pop_symbol = "@as_getter" edge typeof_input -> getter_call edge getter_call -> typeof_output @@ -2077,8 +2077,16 @@ inherit .star_extension 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 @@ -2140,12 +2148,12 @@ inherit .star_extension 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 @struct.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 @@ -2164,19 +2172,28 @@ inherit .star_extension @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 } 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 13746a93dd..c9277a60e3 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,11 +4,6 @@ use anyhow::Result; use crate::bindings_output::runner::run; -#[test] -fn call_public_getter() -> Result<()> { - run("contracts", "call_public_getter") -} - #[test] fn constructor_call_parent() -> Result<()> { run("contracts", "constructor_call_parent") @@ -69,6 +64,11 @@ 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") @@ -79,6 +79,11 @@ 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") 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 index d08ee290be..3c4e526ae4 100644 --- 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 @@ -1,42 +1,30 @@ # 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 uint; - │ ─┬─ - │ ╰─── ref: 1 - 6 │ function test(TokenState tokenState) public { - │ ──┬─ ─────┬──── ─────┬──── - │ ╰───────────────────────── def: 5 - │ │ │ - │ ╰───────────────── ref: 7 - │ │ - │ ╰────── def: 6 - 7 │ tokenState.values(1).nop(); - │ ─────┬──── ───┬── ─┬─ - │ ╰──────────────────── ref: 6 - │ │ │ - │ ╰─────────── ref: 8 - │ │ - │ ╰─── ref: 2 - │ - 10 │ contract TokenState { - │ ─────┬──── - │ ╰────── def: 7 - 11 │ uint[] public values; - │ ───┬── - │ ╰──── def: 8 -────╯ + ╭─[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 index fe753d210d..1fd95e6a5e 100644 --- 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 @@ -1,12 +1,8 @@ -library Lib { - function nop(uint256 x) internal {} -} contract Test { - using Lib for uint; function test(TokenState tokenState) public { - tokenState.values(1).nop(); + tokenState.owners(1).balance; } } contract TokenState { - uint[] public values; + 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/call_public_getter/input.sol b/crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/input.sol similarity index 51% rename from crates/solidity/testing/snapshots/bindings_output/contracts/call_public_getter/input.sol rename to crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/input.sol index c3e4959c62..eca1760059 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/call_public_getter/input.sol +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_getter_members/input.sol @@ -1,9 +1,8 @@ contract Base { - struct Value { int x; } - Value public value; + address public owner; } contract Test { function test(Base base) public { - base.value().x; + base.owner().balance; } } 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 index 3c091da5a8..84dff71c3f 100644 --- 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 @@ -1,46 +1,30 @@ # 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 uint; - │ ─┬─ - │ ╰─── ref: 1 - 6 │ function test(TokenState tokenState) public { - │ ──┬─ ─────┬──── ─────┬──── - │ ╰───────────────────────── def: 5 - │ │ │ - │ ╰───────────────── ref: 7 - │ │ - │ ╰────── def: 6 - 7 │ tokenState.balanceOf(msg.sender).nop(); - │ ─────┬──── ────┬──── ─┬─ ───┬── ─┬─ - │ ╰──────────────────────────────── ref: 6 - │ │ │ │ │ - │ ╰────────────────────── ref: 8 - │ │ │ │ - │ ╰─────────────── ref: built-in - │ │ │ - │ ╰───────── ref: built-in - │ │ - │ ╰─── ref: 2 - │ - 10 │ contract TokenState { - │ ─────┬──── - │ ╰────── def: 7 - 11 │ mapping(address => uint) public balanceOf; - │ ────┬──── - │ ╰────── def: 8 -────╯ + ╭─[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 index 194f10090f..69efebff11 100644 --- 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 @@ -1,12 +1,8 @@ -library Lib { - function nop(uint256 x) internal {} -} contract Test { - using Lib for uint; function test(TokenState tokenState) public { - tokenState.balanceOf(msg.sender).nop(); + tokenState.owners(1).balance; } } contract TokenState { - mapping(address => uint) public balanceOf; + mapping(uint => address) public owners; } diff --git a/crates/solidity/testing/snapshots/bindings_output/contracts/call_public_getter/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/generated/0.4.11-success.txt similarity index 55% rename from crates/solidity/testing/snapshots/bindings_output/contracts/call_public_getter/generated/0.4.11-success.txt rename to crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/generated/0.4.11-success.txt index d054a7ad51..28722902e6 100644 --- a/crates/solidity/testing/snapshots/bindings_output/contracts/call_public_getter/generated/0.4.11-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/contracts/public_struct_getter/generated/0.4.11-success.txt @@ -6,12 +6,12 @@ References and definitions: 1 │ contract Base { │ ──┬─ │ ╰─── def: 1 - 2 │ struct Value { int x; } - │ ──┬── ┬ - │ ╰──────────── def: 2 - │ │ - │ ╰── def: 3 - 3 │ Value public value; + 2 │ struct Owner { address owner; } + │ ──┬── ──┬── + │ ╰──────────────────── def: 2 + │ │ + │ ╰──── def: 3 + 3 │ Owner public owner; │ ──┬── ──┬── │ ╰───────────────── ref: 2 │ │ @@ -27,11 +27,11 @@ References and definitions: │ ╰──────── ref: 1 │ │ │ ╰─── def: 7 - 7 │ base.value().x; - │ ──┬─ ──┬── ┬ - │ ╰───────────── ref: 7 - │ │ │ - │ ╰──────── ref: 4 - │ │ - │ ╰── ref: 3 + 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; + } +} From 2b3ae36a07321088bba6b474bc16b17de76a69ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Wed, 20 Nov 2024 12:25:33 -0500 Subject: [PATCH 52/66] Rename built-in type for User Defined Value Types --- crates/solidity/inputs/language/bindings/rules.msgb | 2 +- crates/solidity/inputs/language/src/definition.rs | 2 +- .../crate/src/generated/bindings/generated/binding_rules.rs | 2 +- .../crate/src/generated/bindings/generated/built_ins/0.8.11.sol | 2 +- .../crate/src/generated/bindings/generated/built_ins/0.8.18.sol | 2 +- .../crate/src/generated/bindings/generated/built_ins/0.8.24.sol | 2 +- .../crate/src/generated/bindings/generated/built_ins/0.8.26.sol | 2 +- .../crate/src/generated/bindings/generated/built_ins/0.8.8.sol | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index f63b44a53a..7f0a93c662 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -2309,7 +2309,7 @@ inherit .star_extension node typeof attr (typeof) push_symbol = "@typeof" node user_type_type - attr (user_type_type) push_symbol = "%UserTypeType" + attr (user_type_type) push_symbol = "%UserDefinedValueType" edge @user_type.def -> member_guard edge member_guard -> member diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 6b86eb5a84..9ea379fe5c 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -7007,7 +7007,7 @@ codegen_language_macros::compile!(Language( functions = [] ), BuiltInType( - name = "$UserTypeType", + name = "$UserDefinedValueType", fields = [], functions = [ BuiltInFunction( 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 f062f43628..1cb52fcbf7 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 @@ -2314,7 +2314,7 @@ inherit .star_extension node typeof attr (typeof) push_symbol = "@typeof" node user_type_type - attr (user_type_type) push_symbol = "%UserTypeType" + attr (user_type_type) push_symbol = "%UserDefinedValueType" edge @user_type.def -> member_guard edge member_guard -> member 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 0c8ef5cf21..bf57c4cb95 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 @@ -98,7 +98,7 @@ contract $BuiltIns$ { int min; int max; } - struct $UserTypeType { + struct $UserDefinedValueType { function($WrappedType) returns ($UserType) wrap; function($UserType) returns ($WrappedType) unwrap; } 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 b0c1e383af..8d83a0b3e4 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 @@ -99,7 +99,7 @@ contract $BuiltIns$ { int min; int max; } - struct $UserTypeType { + struct $UserDefinedValueType { function($WrappedType) returns ($UserType) wrap; function($UserType) returns ($WrappedType) unwrap; } 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 6b3c804653..7f7ae83b01 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 @@ -101,7 +101,7 @@ contract $BuiltIns$ { int min; int max; } - struct $UserTypeType { + struct $UserDefinedValueType { function($WrappedType) returns ($UserType) wrap; function($UserType) returns ($WrappedType) unwrap; } 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 22b2a69ffc..a12d09d6bc 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 @@ -102,7 +102,7 @@ contract $BuiltIns$ { int min; int max; } - struct $UserTypeType { + struct $UserDefinedValueType { function($WrappedType) returns ($UserType) wrap; function($UserType) returns ($WrappedType) unwrap; } 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 index ce56d9c9f8..a1a5b5d07b 100644 --- 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 @@ -97,7 +97,7 @@ contract $BuiltIns$ { int min; int max; } - struct $UserTypeType { + struct $UserDefinedValueType { function($WrappedType) returns ($UserType) wrap; function($UserType) returns ($WrappedType) unwrap; } From 1163b079fe50bdf997a669fab2a2a4ec7a094425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Wed, 20 Nov 2024 12:57:33 -0500 Subject: [PATCH 53/66] Add names to most parameters of built-in functions --- .../inputs/language/src/definition.rs | 36 +++++++++---------- .../bindings/generated/built_ins/0.4.11.sol | 18 +++++----- .../bindings/generated/built_ins/0.4.17.sol | 18 +++++----- .../bindings/generated/built_ins/0.4.22.sol | 26 +++++++------- .../bindings/generated/built_ins/0.5.0.sol | 28 +++++++-------- .../bindings/generated/built_ins/0.5.3.sol | 28 +++++++-------- .../bindings/generated/built_ins/0.6.0.sol | 28 +++++++-------- .../bindings/generated/built_ins/0.6.2.sol | 28 +++++++-------- .../bindings/generated/built_ins/0.6.7.sol | 28 +++++++-------- .../bindings/generated/built_ins/0.6.8.sol | 28 +++++++-------- .../bindings/generated/built_ins/0.7.0.sol | 20 +++++------ .../bindings/generated/built_ins/0.8.0.sol | 20 +++++------ .../bindings/generated/built_ins/0.8.11.sol | 26 +++++++------- .../bindings/generated/built_ins/0.8.18.sol | 26 +++++++------- .../bindings/generated/built_ins/0.8.2.sol | 20 +++++------ .../bindings/generated/built_ins/0.8.24.sol | 26 +++++++------- .../bindings/generated/built_ins/0.8.26.sol | 26 +++++++------- .../bindings/generated/built_ins/0.8.4.sol | 20 +++++------ .../bindings/generated/built_ins/0.8.7.sol | 20 +++++------ .../bindings/generated/built_ins/0.8.8.sol | 24 ++++++------- 20 files changed, 247 insertions(+), 247 deletions(-) diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 9ea379fe5c..196b044d2a 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -6738,37 +6738,37 @@ codegen_language_macros::compile!(Language( functions = [ BuiltInFunction( name = "decode", - parameters = ["bytes memory", "$Types"], + parameters = ["bytes memory encodedData", "$Types encodedTypesTuple"], return_type = "$Types", enabled = From("0.5.0") ), BuiltInFunction( name = "encode", - parameters = ["$Types"], + parameters = ["$Args valuesToEncode"], return_type = "bytes memory", enabled = From("0.4.22") ), BuiltInFunction( name = "encodeCall", - parameters = ["function()", "$Args"], + parameters = ["function() functionPointer", "$Args functionArgumentsTuple"], return_type = "bytes memory", enabled = From("0.8.11") ), BuiltInFunction( name = "encodePacked", - parameters = ["$Args"], + parameters = ["$Args valuesToEncode"], return_type = "bytes memory", enabled = From("0.4.22") ), BuiltInFunction( name = "encodeWithSelector", - parameters = ["bytes4 selector", "$Args"], + parameters = ["bytes4 selector", "$Args functionArgumentsTuple"], return_type = "bytes memory", enabled = From("0.4.22") ), BuiltInFunction( name = "encodeWithSignature", - parameters = ["string memory", "$Args"], + parameters = ["string memory signature", "$Args valuesToEncode"], return_type = "bytes memory", enabled = From("0.4.22") ) @@ -6814,7 +6814,7 @@ codegen_language_macros::compile!(Language( ), BuiltInFunction( name = "send", - parameters = ["uint256"], + parameters = ["uint256 amount"], return_type = "bool" ), BuiltInFunction( @@ -6823,7 +6823,7 @@ 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( @@ -6838,13 +6838,13 @@ codegen_language_macros::compile!(Language( ), BuiltInFunction( name = "push", - parameters = ["$ValueType"], + parameters = ["$ValueType element"], return_type = "uint", enabled = Till("0.6.0") ), BuiltInFunction( name = "push", - parameters = ["$ValueType"], + parameters = ["$ValueType element"], enabled = From("0.6.0") ), BuiltInFunction(name = "pop", parameters = []) @@ -6885,7 +6885,7 @@ codegen_language_macros::compile!(Language( fields = [], functions = [BuiltInFunction( name = "concat", - parameters = ["$Args"], + parameters = ["$Args bytesToConcatenate"], return_type = "bytes memory" )] ), @@ -6911,13 +6911,13 @@ codegen_language_macros::compile!(Language( functions = [ BuiltInFunction( name = "gas", - parameters = ["uint"], + parameters = ["uint amount"], return_type = "function()", enabled = Till("0.7.0") ), BuiltInFunction( name = "value", - parameters = ["uint"], + parameters = ["uint amount"], return_type = "function()", enabled = Till("0.7.0") ) @@ -6932,13 +6932,13 @@ codegen_language_macros::compile!(Language( functions = [ BuiltInFunction( name = "gas", - parameters = ["uint"], + parameters = ["uint amount"], return_type = "function()", enabled = Till("0.7.0") ), BuiltInFunction( name = "value", - parameters = ["uint"], + parameters = ["uint amount"], return_type = "function()", enabled = Till("0.7.0") ) @@ -6964,7 +6964,7 @@ codegen_language_macros::compile!(Language( fields = [], functions = [BuiltInFunction( name = "concat", - parameters = ["$Args"], + parameters = ["$Args stringsToConcatenate"], return_type = "string memory" )] ), @@ -7012,12 +7012,12 @@ codegen_language_macros::compile!(Language( functions = [ BuiltInFunction( name = "wrap", - parameters = ["$WrappedType"], + parameters = ["$WrappedType elementaryType"], return_type = "$UserType" ), BuiltInFunction( name = "unwrap", - parameters = ["$UserType"], + parameters = ["$UserType userType"], return_type = "$WrappedType" ) ], 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 4e3105da55..e6031a2c25 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 @@ -25,12 +25,12 @@ contract $BuiltIns$ { 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 { uint length; - function($ValueType) returns (uint) push; + function($ValueType element) returns (uint) push; function() pop; } struct $FixedArray { @@ -48,15 +48,15 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $Function { - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $ExternalFunction { - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $MessageType { bytes data; @@ -66,7 +66,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 a498afc11d..18e0f4f960 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 @@ -25,12 +25,12 @@ contract $BuiltIns$ { 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 { uint length; - function($ValueType) returns (uint) push; + function($ValueType element) returns (uint) push; function() pop; } struct $FixedArray { @@ -48,16 +48,16 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $Function { - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $ExternalFunction { bytes4 selector; - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $MessageType { bytes data; @@ -67,7 +67,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 52d488972b..3558a73f1a 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 @@ -23,22 +23,22 @@ contract $BuiltIns$ { function sha3(bytes memory) public returns (bytes32); function suicide(address payable recipient) public; struct $AbiType { - function($Types) 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; + function($Args valuesToEncode) returns (bytes memory) encode; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args 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 { uint length; - function($ValueType) returns (uint) push; + function($ValueType element) returns (uint) push; function() pop; } struct $FixedArray { @@ -56,16 +56,16 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $Function { - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $ExternalFunction { bytes4 selector; - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $MessageType { bytes data; @@ -75,7 +75,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 2120032a9d..365807be4a 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 @@ -21,23 +21,23 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args 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 { uint length; - function($ValueType) returns (uint) push; + function($ValueType element) returns (uint) push; function() pop; } struct $FixedArray { @@ -54,16 +54,16 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $Function { - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $ExternalFunction { bytes4 selector; - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $MessageType { bytes data; @@ -72,7 +72,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 933d2b2974..962c44516e 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 @@ -21,23 +21,23 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args 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 { uint length; - function($ValueType) returns (uint) push; + function($ValueType element) returns (uint) push; function() pop; } struct $FixedArray { @@ -54,16 +54,16 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $Function { - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $ExternalFunction { bytes4 selector; - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $MessageType { bytes data; @@ -72,7 +72,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 9fc956e1d0..a61ee7d337 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 @@ -21,24 +21,24 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args 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 { uint length; function() returns ($ValueType) push; - function($ValueType) push; + function($ValueType element) push; function() pop; } struct $FixedArray { @@ -55,16 +55,16 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $Function { - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $ExternalFunction { bytes4 selector; - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $MessageType { bytes data; @@ -73,7 +73,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 723268f886..970182e4c8 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 @@ -21,24 +21,24 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args 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 { uint length; function() returns ($ValueType) push; - function($ValueType) push; + function($ValueType element) push; function() pop; } struct $FixedArray { @@ -55,7 +55,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -63,13 +63,13 @@ contract $BuiltIns$ { uint value; } struct $Function { - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $ExternalFunction { bytes4 selector; - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $MessageType { bytes data; @@ -78,7 +78,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 028e6a6409..8117413c32 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 @@ -21,24 +21,24 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args 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 { uint length; function() returns ($ValueType) push; - function($ValueType) push; + function($ValueType element) push; function() pop; } struct $FixedArray { @@ -55,7 +55,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -63,13 +63,13 @@ contract $BuiltIns$ { uint value; } struct $Function { - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $ExternalFunction { bytes4 selector; - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $MessageType { bytes data; @@ -78,7 +78,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 212f7519a6..7729502cff 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 @@ -21,24 +21,24 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args 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 { uint length; function() returns ($ValueType) push; - function($ValueType) push; + function($ValueType element) push; function() pop; } struct $FixedArray { @@ -55,7 +55,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -63,13 +63,13 @@ contract $BuiltIns$ { uint value; } struct $Function { - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $ExternalFunction { bytes4 selector; - function(uint) returns (function()) gas; - function(uint) returns (function()) value; + function(uint amount) returns (function()) gas; + function(uint amount) returns (function()) value; } struct $MessageType { bytes data; @@ -78,7 +78,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 039badc54c..6d01d31b6e 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 @@ -21,24 +21,24 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args 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 { uint length; function() returns ($ValueType) push; - function($ValueType) push; + function($ValueType element) push; function() pop; } struct $FixedArray { @@ -55,7 +55,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -74,7 +74,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 a0b984ddbd..d166afdac4 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 @@ -16,11 +16,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -28,14 +28,14 @@ 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 { uint length; function() returns ($ValueType) push; - function($ValueType) push; + function($ValueType element) push; function() pop; } struct $FixedArray { @@ -53,7 +53,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -72,7 +72,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 bf57c4cb95..c419a8b9bb 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 @@ -16,12 +16,12 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function(function() functionPointer, $Args functionArgumentsTuple) returns (bytes memory) encodeCall; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -29,14 +29,14 @@ 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 { uint length; function() returns ($ValueType) push; - function($ValueType) push; + function($ValueType element) push; function() pop; } struct $FixedArray { @@ -55,7 +55,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -78,7 +78,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; @@ -99,8 +99,8 @@ contract $BuiltIns$ { int max; } struct $UserDefinedValueType { - function($WrappedType) returns ($UserType) wrap; - function($UserType) returns ($WrappedType) unwrap; + function($WrappedType elementaryType) returns ($UserType) wrap; + function($UserType userType) returns ($WrappedType) unwrap; } struct $YulExternal { uint slot; 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 8d83a0b3e4..2d25af2771 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 @@ -16,12 +16,12 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function(function() functionPointer, $Args functionArgumentsTuple) returns (bytes memory) encodeCall; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -29,14 +29,14 @@ 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 { uint length; function() returns ($ValueType) push; - function($ValueType) push; + function($ValueType element) push; function() pop; } struct $FixedArray { @@ -56,7 +56,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -79,7 +79,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; @@ -100,8 +100,8 @@ contract $BuiltIns$ { int max; } struct $UserDefinedValueType { - function($WrappedType) returns ($UserType) wrap; - function($UserType) returns ($WrappedType) unwrap; + function($WrappedType elementaryType) returns ($UserType) wrap; + function($UserType userType) returns ($WrappedType) unwrap; } struct $YulExternal { uint slot; 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 06bcad256f..4a97115c9f 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 @@ -16,11 +16,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -28,14 +28,14 @@ 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 { uint length; function() returns ($ValueType) push; - function($ValueType) push; + function($ValueType element) push; function() pop; } struct $FixedArray { @@ -53,7 +53,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -73,7 +73,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 7f7ae83b01..5b017eeddf 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 @@ -17,12 +17,12 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function(function() functionPointer, $Args functionArgumentsTuple) returns (bytes memory) encodeCall; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -30,14 +30,14 @@ 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 { uint length; function() returns ($ValueType) push; - function($ValueType) push; + function($ValueType element) push; function() pop; } struct $FixedArray { @@ -58,7 +58,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -81,7 +81,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; @@ -102,8 +102,8 @@ contract $BuiltIns$ { int max; } struct $UserDefinedValueType { - function($WrappedType) returns ($UserType) wrap; - function($UserType) returns ($WrappedType) unwrap; + function($WrappedType elementaryType) returns ($UserType) wrap; + function($UserType userType) returns ($WrappedType) unwrap; } struct $YulExternal { uint slot; 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 a12d09d6bc..f071ec1b24 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 @@ -18,12 +18,12 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function(function() functionPointer, $Args functionArgumentsTuple) returns (bytes memory) encodeCall; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -31,14 +31,14 @@ 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 { uint length; function() returns ($ValueType) push; - function($ValueType) push; + function($ValueType element) push; function() pop; } struct $FixedArray { @@ -59,7 +59,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -82,7 +82,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; @@ -103,8 +103,8 @@ contract $BuiltIns$ { int max; } struct $UserDefinedValueType { - function($WrappedType) returns ($UserType) wrap; - function($UserType) returns ($WrappedType) unwrap; + function($WrappedType elementaryType) returns ($UserType) wrap; + function($UserType userType) returns ($WrappedType) unwrap; } struct $YulExternal { uint slot; 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 index f4a45098fb..233fd9bc5b 100644 --- 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 @@ -16,11 +16,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -28,14 +28,14 @@ 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 { uint length; function() returns ($ValueType) push; - function($ValueType) push; + function($ValueType element) push; function() pop; } struct $FixedArray { @@ -53,7 +53,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -76,7 +76,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 136be02900..be5a5eb33f 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 @@ -16,11 +16,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -28,14 +28,14 @@ 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 { uint length; function() returns ($ValueType) push; - function($ValueType) push; + function($ValueType element) push; function() pop; } struct $FixedArray { @@ -54,7 +54,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -77,7 +77,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 index a1a5b5d07b..900db19925 100644 --- 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 @@ -16,11 +16,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory, $Types) returns ($Types) decode; - function($Types) 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; + function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; + function($Args valuesToEncode) returns (bytes memory) encode; + function($Args valuesToEncode) returns (bytes memory) encodePacked; + function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; + function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; } struct $address { uint256 balance; @@ -28,14 +28,14 @@ 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 { uint length; function() returns ($ValueType) push; - function($ValueType) push; + function($ValueType element) push; function() pop; } struct $FixedArray { @@ -54,7 +54,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args) returns (bytes memory) concat; + function($Args bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -77,7 +77,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args) returns (string memory) concat; + function($Args stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; @@ -98,8 +98,8 @@ contract $BuiltIns$ { int max; } struct $UserDefinedValueType { - function($WrappedType) returns ($UserType) wrap; - function($UserType) returns ($WrappedType) unwrap; + function($WrappedType elementaryType) returns ($UserType) wrap; + function($UserType userType) returns ($WrappedType) unwrap; } struct $YulExternal { uint slot; From 576ae45769ab1ed0ab19b0eaa4187b0e6e6bb9a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 21 Nov 2024 11:55:49 -0500 Subject: [PATCH 54/66] Define a `%this` built-in to use in the context of libraries We are usually binding `this` to the enclosing contract type, but it can also be used in library code. For this special ocasion, bind it to a built-in. This will need to be resolved later to the actual contract instance by the backend. --- .../inputs/language/bindings/rules.msgb | 10 ++++++++++ .../solidity/inputs/language/src/definition.rs | 3 ++- .../bindings/generated/binding_rules.rs | 10 ++++++++++ .../bindings/generated/built_ins/0.4.11.sol | 1 + .../bindings/generated/built_ins/0.4.17.sol | 1 + .../bindings/generated/built_ins/0.4.22.sol | 1 + .../bindings/generated/built_ins/0.5.0.sol | 1 + .../bindings/generated/built_ins/0.5.3.sol | 1 + .../bindings/generated/built_ins/0.6.0.sol | 1 + .../bindings/generated/built_ins/0.6.2.sol | 1 + .../bindings/generated/built_ins/0.6.7.sol | 1 + .../bindings/generated/built_ins/0.6.8.sol | 1 + .../bindings/generated/built_ins/0.7.0.sol | 1 + .../bindings/generated/built_ins/0.8.0.sol | 1 + .../bindings/generated/built_ins/0.8.11.sol | 1 + .../bindings/generated/built_ins/0.8.18.sol | 1 + .../bindings/generated/built_ins/0.8.2.sol | 1 + .../bindings/generated/built_ins/0.8.24.sol | 1 + .../bindings/generated/built_ins/0.8.26.sol | 1 + .../bindings/generated/built_ins/0.8.4.sol | 1 + .../bindings/generated/built_ins/0.8.7.sol | 1 + .../bindings/generated/built_ins/0.8.8.sol | 1 + .../src/bindings_output/generated/built_ins.rs | 5 +++++ .../built_ins/this/generated/0.4.11-success.txt | 17 +++++++++++++++++ .../bindings_output/built_ins/this/input.sol | 5 +++++ 25 files changed, 68 insertions(+), 1 deletion(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 7f0a93c662..5d95a86f7c 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -815,6 +815,16 @@ inherit .star_extension edge @library.def -> type edge type -> type_library_type edge type_library_type -> @library.lexical_scope + + ; Define `this` inside libraries to resolve to a special built-in placeholder + node this + attr (this) pop_symbol = "this" + node this_built_in + attr (this_built_in) push_symbol = "%this" + + edge @library.lexical_scope -> this + edge this -> this_built_in + edge this_built_in -> @library.parent_scope } @library [LibraryDefinition [LibraryMembers diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 196b044d2a..3362ce5e79 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -7041,6 +7041,7 @@ codegen_language_macros::compile!(Language( BuiltInVariable(definition = "$MessageType msg"), BuiltInVariable(definition = "uint now", enabled = Till("0.7.0")), BuiltInVariable(definition = "$StringType $string"), - BuiltInVariable(definition = "$TransactionType tx") + BuiltInVariable(definition = "$TransactionType tx"), + BuiltInVariable(definition = "$ThisType $this") ] )); 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 1cb52fcbf7..4529653078 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 @@ -820,6 +820,16 @@ inherit .star_extension edge @library.def -> type edge type -> type_library_type edge type_library_type -> @library.lexical_scope + + ; Define `this` inside libraries to resolve to a special built-in placeholder + node this + attr (this) pop_symbol = "this" + node this_built_in + attr (this_built_in) push_symbol = "%this" + + edge @library.lexical_scope -> this + edge this -> this_built_in + edge this_built_in -> @library.parent_scope } @library [LibraryDefinition [LibraryMembers 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 e6031a2c25..814626de5a 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 @@ -93,4 +93,5 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 18e0f4f960..094f70c443 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 @@ -94,4 +94,5 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 3558a73f1a..99358fe00f 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 @@ -102,4 +102,5 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 365807be4a..2356e702b8 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 @@ -99,4 +99,5 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 962c44516e..dffaa6111a 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 @@ -101,4 +101,5 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 a61ee7d337..8c0aee733f 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 @@ -102,4 +102,5 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 970182e4c8..94b4918f24 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 @@ -107,4 +107,5 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 8117413c32..adf406e41e 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 @@ -109,4 +109,5 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 7729502cff..ff6e4dfdc6 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 @@ -111,4 +111,5 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 6d01d31b6e..083da2d7e5 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 @@ -106,4 +106,5 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 d166afdac4..e9e0ed24b1 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 @@ -104,4 +104,5 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 c419a8b9bb..e7a5e458b4 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 @@ -114,4 +114,5 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 2d25af2771..8e4feb0044 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 @@ -115,4 +115,5 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 4a97115c9f..6fd03405ee 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 @@ -105,4 +105,5 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 5b017eeddf..3520c696d6 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 @@ -117,4 +117,5 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 f071ec1b24..243b3cd5fb 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 @@ -118,4 +118,5 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 index 233fd9bc5b..cd836dec94 100644 --- 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 @@ -108,4 +108,5 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 be5a5eb33f..d18a550bf0 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 @@ -109,4 +109,5 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 index 900db19925..574d548159 100644 --- 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 @@ -113,4 +113,5 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; + $ThisType $this; } 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 db3f38eb8f..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 @@ -44,6 +44,11 @@ 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") 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..414dd6bc09 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/this/generated/0.4.11-success.txt @@ -0,0 +1,17 @@ +# 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 + │ │ + │ ╰───── 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; + } +} From c6b73c638db8d3ba63f33768dbead0020306b6b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 21 Nov 2024 18:08:57 -0500 Subject: [PATCH 55/66] Bind inherited public getters --- .../inputs/language/bindings/rules.msgb | 2 +- .../bindings/generated/binding_rules.rs | 2 +- .../bindings_output/generated/contracts.rs | 5 +++ .../generated/0.4.11-success.txt | 35 +++++++++++++++++++ .../public_inherited_getter/input.sol | 12 +++++++ 5 files changed, 54 insertions(+), 2 deletions(-) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 5d95a86f7c..54e578ede7 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -369,7 +369,7 @@ inherit .star_extension ;; 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" 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 4529653078..126c22d209 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 @@ -374,7 +374,7 @@ inherit .star_extension ;; 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" 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 c9277a60e3..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 @@ -74,6 +74,11 @@ 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") 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; +} From a015082be31d297cfac3bde0e929374704e88c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 21 Nov 2024 19:54:35 -0500 Subject: [PATCH 56/66] Fix scope bindings for modifiers in libraries --- .../inputs/language/bindings/rules.msgb | 1 + .../bindings/generated/binding_rules.rs | 1 + .../bindings_output/generated/libraries.rs | 5 +++ .../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 ++++ 7 files changed, 109 insertions(+) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 54e578ede7..862274887e 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -856,6 +856,7 @@ inherit .star_extension ]] { edge @library.modifiers -> @modifier.def edge @modifier.lexical_scope -> @library.lexical_scope + edge @modifier.extended_scope -> @library.extended_scope } @library [LibraryDefinition [LibraryMembers 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 126c22d209..2723ae41b4 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 @@ -861,6 +861,7 @@ inherit .star_extension ]] { edge @library.modifiers -> @modifier.def edge @modifier.lexical_scope -> @library.lexical_scope + edge @modifier.extended_scope -> @library.extended_scope } @library [LibraryDefinition [LibraryMembers 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 bb2f24cf19..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 @@ -14,6 +14,11 @@ 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") 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(); + } +} From fc929d3f75afc7d4ae02ed02af1f911a6ece64cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 21 Nov 2024 19:43:52 -0500 Subject: [PATCH 57/66] Bind attached functions when there's a `using .. for *` in a library --- .../inputs/language/bindings/rules.msgb | 11 +++++++ .../bindings/generated/binding_rules.rs | 11 +++++++ .../src/bindings_output/generated/using.rs | 5 +++ .../generated/0.4.11-success.txt | 33 +++++++++++++++++++ .../using/star_in_library/input.sol | 9 +++++ 5 files changed, 69 insertions(+) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 862274887e..dfcbd62869 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -825,6 +825,10 @@ inherit .star_extension edge @library.lexical_scope -> this edge this -> this_built_in edge this_built_in -> @library.parent_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 @@ -869,6 +873,13 @@ inherit .star_extension 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 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 2723ae41b4..2bbad49801 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 @@ -830,6 +830,10 @@ inherit .star_extension edge @library.lexical_scope -> this edge this -> this_built_in edge this_built_in -> @library.parent_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 @@ -874,6 +878,13 @@ inherit .star_extension 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 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 9b35857fae..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 @@ -99,6 +99,11 @@ 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") 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 {} +} From 90a4f2688f23dd7200c60221046ff1a794b267ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Thu, 21 Nov 2024 19:24:01 -0500 Subject: [PATCH 58/66] Allow Yul functions to access external constants --- .../inputs/language/bindings/rules.msgb | 32 +++++++++ .../bindings/generated/binding_rules.rs | 32 +++++++++ .../src/bindings_output/generated/yul.rs | 5 ++ .../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 ++++++++ 8 files changed, 360 insertions(+) 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 diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index dfcbd62869..562d7efd99 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -2795,6 +2795,38 @@ inherit .star_extension ;; 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 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 2bbad49801..271cba909e 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 @@ -2800,6 +2800,38 @@ inherit .star_extension ;; 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 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 46aa3d6ad4..28556aca1e 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,6 +9,11 @@ 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") 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; From d5823c0ec3057ead65ef11e9a908dda968a84adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 25 Nov 2024 14:47:39 -0500 Subject: [PATCH 59/66] `this` and `super` don't generate references This avoids some oddities, such as `this` used in libraries which we previously had to bind to an artificial built-in. --- .../inputs/language/bindings/rules.msgb | 37 +++++-------------- .../inputs/language/src/definition.rs | 3 +- .../bindings/generated/binding_rules.rs | 37 +++++-------------- .../bindings/generated/built_ins/0.4.11.sol | 1 - .../bindings/generated/built_ins/0.4.17.sol | 1 - .../bindings/generated/built_ins/0.4.22.sol | 1 - .../bindings/generated/built_ins/0.5.0.sol | 1 - .../bindings/generated/built_ins/0.5.3.sol | 1 - .../bindings/generated/built_ins/0.6.0.sol | 1 - .../bindings/generated/built_ins/0.6.2.sol | 1 - .../bindings/generated/built_ins/0.6.7.sol | 1 - .../bindings/generated/built_ins/0.6.8.sol | 1 - .../bindings/generated/built_ins/0.7.0.sol | 1 - .../bindings/generated/built_ins/0.8.0.sol | 1 - .../bindings/generated/built_ins/0.8.11.sol | 1 - .../bindings/generated/built_ins/0.8.18.sol | 1 - .../bindings/generated/built_ins/0.8.2.sol | 1 - .../bindings/generated/built_ins/0.8.24.sol | 1 - .../bindings/generated/built_ins/0.8.26.sol | 1 - .../bindings/generated/built_ins/0.8.4.sol | 1 - .../bindings/generated/built_ins/0.8.7.sol | 1 - .../bindings/generated/built_ins/0.8.8.sol | 1 - .../address/generated/0.4.11-failure.txt | 4 +- .../address/generated/0.5.0-success.txt | 4 +- .../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 | 4 +- .../generated/0.4.11-success.txt | 4 +- .../generated/0.5.0-failure.txt | 4 +- .../generated/0.4.11-success.txt | 4 +- .../super_deep/generated/0.4.11-success.txt | 4 +- .../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.16-failure.txt | 4 +- .../generated/0.6.0-success.txt | 4 +- .../generated/0.4.11-failure.txt | 4 +- .../generated/0.4.21-failure.txt | 4 +- .../generated/0.5.0-failure.txt | 4 +- .../generated/0.5.3-failure.txt | 4 +- .../generated/0.6.0-success.txt | 4 +- .../generated/0.4.11-success.txt | 4 +- 52 files changed, 94 insertions(+), 238 deletions(-) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 562d7efd99..3d13b6a214 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -304,9 +304,6 @@ inherit .star_extension edge heir.ns -> ns_member edge ns_member -> @type_name.push_begin - ; Resolve the "super" keyword reference to the inherited type - edge heir.super -> @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 @@ -401,12 +398,6 @@ inherit .star_extension edge @contract.lexical_scope -> this edge this -> member - ; ... and resolves 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 - ;; Modifiers are available as a contract type members through a special '@modifier' guard node modifier attr (modifier) pop_symbol = "@modifier" @@ -525,9 +516,6 @@ inherit .star_extension attr (super_instance) push_symbol = "@instance" edge @contract.super_import -> super_instance edge super_instance -> @contract.super_scope - - ; NOTE: The keyword "super" itself resolves to each of its parent contracts. - ; See the related rules in the InheritanceSpecifier section above. } @contract [ContractDefinition [InheritanceSpecifier [InheritanceTypes @@ -743,9 +731,6 @@ inherit .star_extension @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 @@ -816,16 +801,6 @@ inherit .star_extension edge type -> type_library_type edge type_library_type -> @library.lexical_scope - ; Define `this` inside libraries to resolve to a special built-in placeholder - node this - attr (this) pop_symbol = "this" - node this_built_in - attr (this_built_in) push_symbol = "%this" - - edge @library.lexical_scope -> this - edge this -> this_built_in - edge this_built_in -> @library.parent_scope - ; This is the connection point to resolve attached functions by `using for *` node @library.star_extension attr (@library.star_extension) push_symbol = "@*" @@ -2387,9 +2362,7 @@ inherit .star_extension } ;; 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] @@ -2398,6 +2371,14 @@ inherit .star_extension 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] diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 3362ce5e79..196b044d2a 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -7041,7 +7041,6 @@ codegen_language_macros::compile!(Language( BuiltInVariable(definition = "$MessageType msg"), BuiltInVariable(definition = "uint now", enabled = Till("0.7.0")), BuiltInVariable(definition = "$StringType $string"), - BuiltInVariable(definition = "$TransactionType tx"), - BuiltInVariable(definition = "$ThisType $this") + 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 271cba909e..4e8dd00449 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 @@ -309,9 +309,6 @@ inherit .star_extension edge heir.ns -> ns_member edge ns_member -> @type_name.push_begin - ; Resolve the "super" keyword reference to the inherited type - edge heir.super -> @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 @@ -406,12 +403,6 @@ inherit .star_extension edge @contract.lexical_scope -> this edge this -> member - ; ... and resolves 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 - ;; Modifiers are available as a contract type members through a special '@modifier' guard node modifier attr (modifier) pop_symbol = "@modifier" @@ -530,9 +521,6 @@ inherit .star_extension attr (super_instance) push_symbol = "@instance" edge @contract.super_import -> super_instance edge super_instance -> @contract.super_scope - - ; NOTE: The keyword "super" itself resolves to each of its parent contracts. - ; See the related rules in the InheritanceSpecifier section above. } @contract [ContractDefinition [InheritanceSpecifier [InheritanceTypes @@ -748,9 +736,6 @@ inherit .star_extension @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 @@ -821,16 +806,6 @@ inherit .star_extension edge type -> type_library_type edge type_library_type -> @library.lexical_scope - ; Define `this` inside libraries to resolve to a special built-in placeholder - node this - attr (this) pop_symbol = "this" - node this_built_in - attr (this_built_in) push_symbol = "%this" - - edge @library.lexical_scope -> this - edge this -> this_built_in - edge this_built_in -> @library.parent_scope - ; This is the connection point to resolve attached functions by `using for *` node @library.star_extension attr (@library.star_extension) push_symbol = "@*" @@ -2392,9 +2367,7 @@ inherit .star_extension } ;; 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] @@ -2403,6 +2376,14 @@ inherit .star_extension 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] 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 814626de5a..e6031a2c25 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 @@ -93,5 +93,4 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 094f70c443..18e0f4f960 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 @@ -94,5 +94,4 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 99358fe00f..3558a73f1a 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 @@ -102,5 +102,4 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 2356e702b8..365807be4a 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 @@ -99,5 +99,4 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 dffaa6111a..962c44516e 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 @@ -101,5 +101,4 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 8c0aee733f..a61ee7d337 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 @@ -102,5 +102,4 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 94b4918f24..970182e4c8 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 @@ -107,5 +107,4 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 adf406e41e..8117413c32 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 @@ -109,5 +109,4 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 ff6e4dfdc6..7729502cff 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 @@ -111,5 +111,4 @@ contract $BuiltIns$ { uint now; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 083da2d7e5..6d01d31b6e 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 @@ -106,5 +106,4 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 e9e0ed24b1..d166afdac4 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 @@ -104,5 +104,4 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 e7a5e458b4..c419a8b9bb 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 @@ -114,5 +114,4 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 8e4feb0044..2d25af2771 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 @@ -115,5 +115,4 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 6fd03405ee..4a97115c9f 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 @@ -105,5 +105,4 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 3520c696d6..5b017eeddf 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 @@ -117,5 +117,4 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 243b3cd5fb..f071ec1b24 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 @@ -118,5 +118,4 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 index cd836dec94..233fd9bc5b 100644 --- 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 @@ -108,5 +108,4 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 d18a550bf0..be5a5eb33f 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 @@ -109,5 +109,4 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 index 574d548159..900db19925 100644 --- 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 @@ -113,5 +113,4 @@ contract $BuiltIns$ { $MessageType msg; $StringType $string; $TransactionType tx; - $ThisType $this; } 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 62b96090e3..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 @@ -60,10 +60,8 @@ References and definitions: │ │ │ ╰─── ref: built-in 9 │ uint256 v10 = address(this).balance; - │ ─┬─ ──┬─ ───┬─── + │ ─┬─ ───┬─── │ ╰─────────────────────────── def: 12 - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── 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 03aab82e21..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 @@ -60,10 +60,8 @@ References and definitions: │ │ │ ╰─── ref: built-in 9 │ uint256 v10 = address(this).balance; - │ ─┬─ ──┬─ ───┬─── + │ ─┬─ ───┬─── │ ╰─────────────────────────── def: 12 - │ │ │ - │ ╰──────────── ref: 1 │ │ │ ╰───── ref: built-in ───╯ 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 index 414dd6bc09..c86bc2430b 100644 --- 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 @@ -10,8 +10,6 @@ References and definitions: │ ──┬─ │ ╰─── def: 2 3 │ return address(this).balance; - │ ──┬─ ───┬─── - │ ╰──────────── ref: built-in - │ │ + │ ───┬─── │ ╰───── ref: built-in ───╯ 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 index fc078552b0..e5572f9274 100644 --- 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 @@ -11,8 +11,6 @@ References and definitions: │ ╰─── def: 2 │ 4 │ this.balance; - │ ──┬─ ───┬─── - │ ╰─────────── ref: 1 - │ │ + │ ───┬─── │ ╰───── 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 index c075660094..8d1ee729e4 100644 --- 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 @@ -11,8 +11,6 @@ References and definitions: │ ╰─── def: 2 │ 4 │ this.balance; - │ ──┬─ ───┬─── - │ ╰─────────── ref: 1 - │ │ + │ ───┬─── │ ╰───── unresolved ───╯ 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/super_deep/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/contracts/super_deep/generated/0.4.11-success.txt index 5cf281f5af..66779a28d1 100644 --- 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 @@ -24,8 +24,6 @@ References and definitions: │ ───┬─── │ ╰───── def: 5 7 │ super.in_base(); - │ ──┬── ───┬─── - │ ╰──────────── ref: 3 - │ │ + │ ───┬─── │ ╰───── ref: 2 ───╯ 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/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/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 index 3b69ddc24e..f25c1ffe3c 100644 --- 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 @@ -26,9 +26,7 @@ References and definitions: │ │ │ ╰── def: 3 5 │ address(this).balance; - │ ──┬─ ───┬─── - │ ╰──────────── ref: 1 - │ │ + │ ───┬─── │ ╰───── ref: built-in │ 11 │ library Lib { 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 index 54e6396353..bdf6d7ee03 100644 --- 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 @@ -26,9 +26,7 @@ References and definitions: │ │ │ ╰── def: 3 5 │ address(this).balance; - │ ──┬─ ───┬─── - │ ╰──────────── ref: 1 - │ │ + │ ───┬─── │ ╰───── ref: built-in │ 11 │ library Lib { 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 index d52b1ac8b5..8ee42cb4f3 100644 --- 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 @@ -26,9 +26,7 @@ References and definitions: │ │ │ ╰── def: 3 5 │ address(this).balance; - │ ──┬─ ───┬─── - │ ╰──────────── ref: 1 - │ │ + │ ───┬─── │ ╰───── ref: built-in │ 11 │ library Lib { 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 index 5f69b56a43..0563005915 100644 --- 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 @@ -26,9 +26,7 @@ References and definitions: │ │ │ ╰── def: 3 5 │ address(this).balance; - │ ──┬─ ───┬─── - │ ╰──────────── ref: 1 - │ │ + │ ───┬─── │ ╰───── ref: built-in │ 11 │ library Lib { 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 index 9ced7532c3..55ec33f7cd 100644 --- 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 @@ -16,9 +16,7 @@ References and definitions: │ │ │ ╰── def: 3 5 │ address(this).balance; - │ ──┬─ ───┬─── - │ ╰──────────── ref: 1 - │ │ + │ ───┬─── │ ╰───── ref: built-in 6 │ payable(a).call(""); │ ┬ ──┬─ 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 index 8d948edffa..99cdf03840 100644 --- 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 @@ -22,9 +22,7 @@ References and definitions: │ ──┬── │ ╰──── def: 4 7 │ return super.total().nop(); - │ ──┬── ──┬── ─┬─ - │ ╰──────────────── ref: 1 - │ │ │ + │ ──┬── ─┬─ │ ╰────────── ref: 2 │ │ │ ╰─── ref: 6 From 476807952b38ebdf0779dcbedde8b6720f3bc0af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 26 Nov 2024 17:21:33 -0500 Subject: [PATCH 60/66] Refactor elementary types handling in binding rules --- .../inputs/language/bindings/rules.msgb | 83 ++++++++++++------- .../bindings/generated/binding_rules.rs | 83 ++++++++++++------- 2 files changed, 106 insertions(+), 60 deletions(-) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 3d13b6a214..b6ddfbbf0d 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -1064,37 +1064,60 @@ inherit .star_extension let @elementary.push_end = @elementary.ref } -@elementary [ElementaryType variant: [AddressType @address [AddressKeyword]]] { - let @elementary.symbol = (format "%{}" (source-text @address)) -} - -@elementary [ElementaryType @keyword ( - [BoolKeyword] - | [ByteKeyword] - | [BytesKeyword] - | [StringKeyword] - | [IntKeyword] - | [UintKeyword] - | [FixedKeyword] - | [UfixedKeyword] -)] { - var symbol = (source-text @keyword) - ; Normalize type aliases - scan (source-text @keyword) { - "^uint$" { - set symbol = "uint256" - } - "^int$" { - set symbol = "int256" - } - "^fixed$" { - set symbol = "fixed128x18" - } - "^ufixed$" { - set symbol = "ufixed128x18" - } +@elementary [ElementaryType [AddressType]] { + let @elementary.symbol = "%address" +} + +@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) } - let @elementary.symbol = (format "%{}" symbol) } 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 4e8dd00449..bd445c9010 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 @@ -1069,37 +1069,60 @@ inherit .star_extension let @elementary.push_end = @elementary.ref } -@elementary [ElementaryType variant: [AddressType @address [AddressKeyword]]] { - let @elementary.symbol = (format "%{}" (source-text @address)) -} - -@elementary [ElementaryType @keyword ( - [BoolKeyword] - | [ByteKeyword] - | [BytesKeyword] - | [StringKeyword] - | [IntKeyword] - | [UintKeyword] - | [FixedKeyword] - | [UfixedKeyword] -)] { - var symbol = (source-text @keyword) - ; Normalize type aliases - scan (source-text @keyword) { - "^uint$" { - set symbol = "uint256" - } - "^int$" { - set symbol = "int256" - } - "^fixed$" { - set symbol = "fixed128x18" - } - "^ufixed$" { - set symbol = "ufixed128x18" - } +@elementary [ElementaryType [AddressType]] { + let @elementary.symbol = "%address" +} + +@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) } - let @elementary.symbol = (format "%{}" symbol) } From 5ed161baf9cfea5c1e219b84a60131242878f428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 26 Nov 2024 17:33:18 -0500 Subject: [PATCH 61/66] Bind `x_slot` in Solidity <= 0.5.0 to the `slot` built-in --- .../inputs/language/bindings/rules.msgb | 27 ++++++++++++++----- .../bindings/generated/binding_rules.rs | 27 ++++++++++++++----- .../slot_suffix/generated/0.4.11-success.txt | 4 +-- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index b6ddfbbf0d..0a4b6e4913 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -2956,16 +2956,29 @@ inherit .star_extension ; 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)$" { + "^(.*)_(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 = without_suffix + 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 -> @path.lexical_scope + edge push_suffixless -> member_of + edge member_of -> typeof + edge typeof -> yul_external + edge yul_external -> @path.lexical_scope } } } @@ -2980,13 +2993,13 @@ inherit .star_extension attr (member_of) push_symbol = "." node typeof attr (typeof) push_symbol = "@typeof" - node yul_variable - attr (yul_variable) push_symbol = "%YulExternal" + node yul_external + attr (yul_external) push_symbol = "%YulExternal" edge ref -> member_of edge member_of -> typeof - edge typeof -> yul_variable - edge yul_variable -> @path.lexical_scope + 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/binding_rules.rs b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/binding_rules.rs index bd445c9010..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 @@ -2961,16 +2961,29 @@ inherit .star_extension ; 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)$" { + "^(.*)_(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 = without_suffix + 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 -> @path.lexical_scope + edge push_suffixless -> member_of + edge member_of -> typeof + edge typeof -> yul_external + edge yul_external -> @path.lexical_scope } } } @@ -2985,13 +2998,13 @@ inherit .star_extension attr (member_of) push_symbol = "." node typeof attr (typeof) push_symbol = "@typeof" - node yul_variable - attr (yul_variable) push_symbol = "%YulExternal" + node yul_external + attr (yul_external) push_symbol = "%YulExternal" edge ref -> member_of edge member_of -> typeof - edge typeof -> yul_variable - edge yul_variable -> @path.lexical_scope + edge typeof -> yul_external + edge yul_external -> @path.lexical_scope } @expr [YulExpression @funcall [YulFunctionCallExpression]] { 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 index c7e17557b8..bb7557764a 100644 --- 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 @@ -17,10 +17,10 @@ References and definitions: │ ┬ ────┬──── │ ╰───────────────────── def: 4 │ │ - │ ╰────── ref: 2 + │ ╰────── ref: built-in 6 │ let o := sload(data_offset) │ ┬ ─────┬───── │ ╰─────────────────────── def: 5 │ │ - │ ╰─────── ref: 2 + │ ╰─────── ref: built-in ───╯ From a6b610cb50d70a917db233672d911d2d453bc0c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 26 Nov 2024 17:46:51 -0500 Subject: [PATCH 62/66] Add test case with Yul identifiers with dots --- .../src/bindings_output/generated/yul.rs | 5 ++++ .../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 ++++++ 10 files changed, 216 insertions(+) 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 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 28556aca1e..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 @@ -19,6 +19,11 @@ fn functions() -> Result<()> { run("yul", "functions") } +#[test] +fn identifiers_with_dots() -> Result<()> { + run("yul", "identifiers_with_dots") +} + #[test] fn loops() -> Result<()> { run("yul", "loops") 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..93fccc5c32 --- /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 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..6bfc55ddb8 --- /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 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) + } + } +} From 4c19da043ebcb9322119c82c77df33242c7b2102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 26 Nov 2024 18:19:04 -0500 Subject: [PATCH 63/66] Tweak some parameters of built-in functions --- .../inputs/language/src/definition.rs | 21 +++++++++++-------- .../bindings/generated/built_ins/0.4.11.sol | 4 ++-- .../bindings/generated/built_ins/0.4.17.sol | 4 ++-- .../bindings/generated/built_ins/0.4.22.sol | 12 +++++------ .../bindings/generated/built_ins/0.5.0.sol | 14 ++++++------- .../bindings/generated/built_ins/0.5.3.sol | 14 ++++++------- .../bindings/generated/built_ins/0.6.0.sol | 14 ++++++------- .../bindings/generated/built_ins/0.6.2.sol | 14 ++++++------- .../bindings/generated/built_ins/0.6.7.sol | 14 ++++++------- .../bindings/generated/built_ins/0.6.8.sol | 14 ++++++------- .../bindings/generated/built_ins/0.7.0.sol | 14 ++++++------- .../bindings/generated/built_ins/0.8.0.sol | 14 ++++++------- .../bindings/generated/built_ins/0.8.11.sol | 16 +++++++------- .../bindings/generated/built_ins/0.8.18.sol | 16 +++++++------- .../bindings/generated/built_ins/0.8.2.sol | 14 ++++++------- .../bindings/generated/built_ins/0.8.24.sol | 16 +++++++------- .../bindings/generated/built_ins/0.8.26.sol | 16 +++++++------- .../bindings/generated/built_ins/0.8.4.sol | 14 ++++++------- .../bindings/generated/built_ins/0.8.7.sol | 14 ++++++------- .../bindings/generated/built_ins/0.8.8.sol | 14 ++++++------- 20 files changed, 138 insertions(+), 135 deletions(-) diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 196b044d2a..e738024870 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -6738,37 +6738,40 @@ codegen_language_macros::compile!(Language( functions = [ BuiltInFunction( name = "decode", - parameters = ["bytes memory encodedData", "$Types encodedTypesTuple"], - return_type = "$Types", + parameters = ["bytes memory encodedData", "$Type[] encodedTypesTuple"], + return_type = "$Any[]", enabled = From("0.5.0") ), BuiltInFunction( name = "encode", - parameters = ["$Args valuesToEncode"], + parameters = ["$Any[] valuesToEncode"], return_type = "bytes memory", enabled = From("0.4.22") ), BuiltInFunction( name = "encodeCall", - parameters = ["function() functionPointer", "$Args functionArgumentsTuple"], + parameters = [ + "function() functionPointer", + "$Any[] functionArgumentsTuple" + ], return_type = "bytes memory", enabled = From("0.8.11") ), BuiltInFunction( name = "encodePacked", - parameters = ["$Args valuesToEncode"], + parameters = ["$Any[] valuesToEncode"], return_type = "bytes memory", enabled = From("0.4.22") ), BuiltInFunction( name = "encodeWithSelector", - parameters = ["bytes4 selector", "$Args functionArgumentsTuple"], + parameters = ["bytes4 selector", "$Any[] functionArgumentsTuple"], return_type = "bytes memory", enabled = From("0.4.22") ), BuiltInFunction( name = "encodeWithSignature", - parameters = ["string memory signature", "$Args valuesToEncode"], + parameters = ["string memory signature", "$Any[] valuesToEncode"], return_type = "bytes memory", enabled = From("0.4.22") ) @@ -6885,7 +6888,7 @@ codegen_language_macros::compile!(Language( fields = [], functions = [BuiltInFunction( name = "concat", - parameters = ["$Args bytesToConcatenate"], + parameters = ["bytes[] bytesToConcatenate"], return_type = "bytes memory" )] ), @@ -6964,7 +6967,7 @@ codegen_language_macros::compile!(Language( fields = [], functions = [BuiltInFunction( name = "concat", - parameters = ["$Args stringsToConcatenate"], + parameters = ["string[] stringsToConcatenate"], return_type = "string memory" )] ), 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 e6031a2c25..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 @@ -48,7 +48,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $Function { function(uint amount) returns (function()) gas; @@ -66,7 +66,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 18e0f4f960..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 @@ -48,7 +48,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $Function { function(uint amount) returns (function()) gas; @@ -67,7 +67,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 3558a73f1a..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 @@ -23,10 +23,10 @@ contract $BuiltIns$ { function sha3(bytes memory) public returns (bytes32); function suicide(address payable recipient) public; struct $AbiType { - function($Args valuesToEncode) returns (bytes memory) encode; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -56,7 +56,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $Function { function(uint amount) returns (function()) gas; @@ -75,7 +75,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 365807be4a..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 @@ -21,11 +21,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -54,7 +54,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $Function { function(uint amount) returns (function()) gas; @@ -72,7 +72,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 962c44516e..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 @@ -21,11 +21,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -54,7 +54,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $Function { function(uint amount) returns (function()) gas; @@ -72,7 +72,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 a61ee7d337..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 @@ -21,11 +21,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -55,7 +55,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $Function { function(uint amount) returns (function()) gas; @@ -73,7 +73,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 970182e4c8..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 @@ -21,11 +21,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -55,7 +55,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -78,7 +78,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 8117413c32..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 @@ -21,11 +21,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -55,7 +55,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -78,7 +78,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 7729502cff..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 @@ -21,11 +21,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -55,7 +55,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -78,7 +78,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 6d01d31b6e..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 @@ -21,11 +21,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -55,7 +55,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -74,7 +74,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 d166afdac4..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 @@ -16,11 +16,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -53,7 +53,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -72,7 +72,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 c419a8b9bb..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 @@ -16,12 +16,12 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function(function() functionPointer, $Args functionArgumentsTuple) returns (bytes memory) encodeCall; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -55,7 +55,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -78,7 +78,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 2d25af2771..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 @@ -16,12 +16,12 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function(function() functionPointer, $Args functionArgumentsTuple) returns (bytes memory) encodeCall; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -56,7 +56,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -79,7 +79,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 4a97115c9f..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 @@ -16,11 +16,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -53,7 +53,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -73,7 +73,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 5b017eeddf..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 @@ -17,12 +17,12 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function(function() functionPointer, $Args functionArgumentsTuple) returns (bytes memory) encodeCall; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -58,7 +58,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -81,7 +81,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 f071ec1b24..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 @@ -18,12 +18,12 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function(function() functionPointer, $Args functionArgumentsTuple) returns (bytes memory) encodeCall; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -59,7 +59,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -82,7 +82,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 index 233fd9bc5b..4ac08e94dd 100644 --- 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 @@ -16,11 +16,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -53,7 +53,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -76,7 +76,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 be5a5eb33f..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 @@ -16,11 +16,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -54,7 +54,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -77,7 +77,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; 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 index 900db19925..ec34656dbc 100644 --- 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 @@ -16,11 +16,11 @@ contract $BuiltIns$ { function selfdestruct(address payable recipient) public; function sha256(bytes memory) public returns (bytes32); struct $AbiType { - function(bytes memory encodedData, $Types encodedTypesTuple) returns ($Types) decode; - function($Args valuesToEncode) returns (bytes memory) encode; - function($Args valuesToEncode) returns (bytes memory) encodePacked; - function(bytes4 selector, $Args functionArgumentsTuple) returns (bytes memory) encodeWithSelector; - function(string memory signature, $Args valuesToEncode) returns (bytes memory) encodeWithSignature; + 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; @@ -54,7 +54,7 @@ contract $BuiltIns$ { uint length; } struct $BytesType { - function($Args bytesToConcatenate) returns (bytes memory) concat; + function(bytes[] bytesToConcatenate) returns (bytes memory) concat; } struct $CallOptions { uint gas; @@ -77,7 +77,7 @@ contract $BuiltIns$ { uint value; } struct $StringType { - function($Args stringsToConcatenate) returns (string memory) concat; + function(string[] stringsToConcatenate) returns (string memory) concat; } struct $TransactionType { uint gasprice; From f6d3113544a3508e9833f0ad90eb4939340eb2c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 26 Nov 2024 20:07:44 -0500 Subject: [PATCH 64/66] Update snapshots after merge --- .../yul/identifiers_with_dots/generated/0.4.11-failure.txt | 2 +- .../yul/identifiers_with_dots/generated/0.4.12-failure.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 index 93fccc5c32..d14a31e3bf 100644 --- 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 @@ -1,7 +1,7 @@ # 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 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. +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 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 index 6bfc55ddb8..d64f0a606b 100644 --- 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 @@ -1,7 +1,7 @@ # 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 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. +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 From a865d10fafb7a96b59996a7517ab186202a95d67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 26 Nov 2024 20:08:23 -0500 Subject: [PATCH 65/66] Update performance test counts and ignore built-ins in them --- crates/solidity/testing/perf/src/tests/definitions.rs | 7 +++++-- crates/solidity/testing/perf/src/tests/init_bindings.rs | 7 ++++++- crates/solidity/testing/perf/src/tests/references.rs | 8 ++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/crates/solidity/testing/perf/src/tests/definitions.rs b/crates/solidity/testing/perf/src/tests/definitions.rs index 7cd63bc824..41a9e61f4a 100644 --- a/crates/solidity/testing/perf/src/tests/definitions.rs +++ b/crates/solidity/testing/perf/src/tests/definitions.rs @@ -32,10 +32,13 @@ pub fn run(dependencies: Dependencies) -> Bindings { path.to_str().unwrap(), tree.cursor_with_offset(TextIndex::ZERO), ); - 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..ca68102869 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" ); } From c278a6cc6bc0501e80be44c5f6762ca151fbe2cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Wed, 27 Nov 2024 09:43:32 -0500 Subject: [PATCH 66/66] Fix formatting --- crates/solidity/testing/perf/src/tests/init_bindings.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/solidity/testing/perf/src/tests/init_bindings.rs b/crates/solidity/testing/perf/src/tests/init_bindings.rs index ca68102869..4dc9af819a 100644 --- a/crates/solidity/testing/perf/src/tests/init_bindings.rs +++ b/crates/solidity/testing/perf/src/tests/init_bindings.rs @@ -21,8 +21,8 @@ pub fn setup() -> ParseOutput { pub fn run(built_ins: ParseOutput) -> Bindings { let mut bindings = create_with_resolver(SOLC_VERSION, Arc::new(NoOpResolver {})); - let built_ins_cursor = transform_built_ins_node(&built_ins.tree()) - .cursor_with_offset(TextIndex::ZERO); + 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);