-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding definitions for mapping parameters (#1221)
Fixes #1213 I had to make the rule for `[MappingType]` fault-tolerant in order to accommodate for older versions of Solidity, by splitting it in two. Questions: - Is it possible to avoid having to make a query for each key or value parameter, and instead have `[Identifier]?` and query for its existence? - The nodes for the parameters are "hanging in the air", as they don't participate in anything useful. Should we attach them to the mapping somehow?
- Loading branch information
1 parent
72c0c76
commit be914d9
Showing
6 changed files
with
192 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 32 additions & 5 deletions
37
crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/binding_rules.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
crates/solidity/outputs/cargo/tests/src/bindings_output/generated/mappings.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
.../testing/snapshots/bindings_output/mappings/named_parameters/generated/0.4.11-failure.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# This file is generated automatically by infrastructure scripts. Please don't edit by hand. | ||
|
||
Parse errors: | ||
Error: Expected EqualGreaterThan or PayableKeyword. | ||
╭─[input.sol:2:19] | ||
│ | ||
2 │ mapping(address name => uint256) public justNameInKey; | ||
│ ───────┬─────── | ||
│ ╰───────── Error occurred here. | ||
───╯ | ||
Error: Expected CloseParen or OpenBracket. | ||
╭─[input.sol:4:30] | ||
│ | ||
4 │ mapping(address => uint256 amount) public justNameInValue; | ||
│ ───┬── | ||
│ ╰──── Error occurred here. | ||
───╯ | ||
Error: Expected EqualGreaterThan or PayableKeyword. | ||
╭─[input.sol:6:19] | ||
│ | ||
6 │ mapping(address name => uint256 amount) public nameInBoth; | ||
│ ───────────┬────────── | ||
│ ╰──────────── Error occurred here. | ||
───╯ | ||
References and definitions: | ||
╭─[input.sol:1:1] | ||
│ | ||
1 │ contract NamedMapping { | ||
│ ──────┬───── | ||
│ ╰─────── name: 1 | ||
2 │ mapping(address name => uint256) public justNameInKey; | ||
│ ──────┬────── | ||
│ ╰──────── name: 2 | ||
│ | ||
4 │ mapping(address => uint256 amount) public justNameInValue; | ||
│ ───────┬─────── | ||
│ ╰───────── name: 3 | ||
│ | ||
6 │ mapping(address name => uint256 amount) public nameInBoth; | ||
│ ─────┬──── | ||
│ ╰────── name: 4 | ||
───╯ | ||
Definiens: | ||
╭─[input.sol:1:1] | ||
│ | ||
1 │ ╭─────▶ contract NamedMapping { | ||
2 │ │ │ mapping(address name => uint256) public justNameInKey; | ||
│ │ │ ────────────────────────────┬──────────────────────────── | ||
│ │ │ ╰────────────────────────────── definiens: 2 | ||
3 │ │ ╭───▶ | ||
4 │ │ ├─│ ▶ mapping(address => uint256 amount) public justNameInValue; | ||
│ │ │ │ | ||
│ │ ╰──────────────────────────────────────────────────────────────────── definiens: 3 | ||
5 │ │ ╭─▶ | ||
6 │ │ ├─▶ mapping(address name => uint256 amount) public nameInBoth; | ||
│ │ │ | ||
│ │ ╰────────────────────────────────────────────────────────────────── definiens: 4 | ||
7 │ ├─────▶ } | ||
│ │ | ||
│ ╰─────────── definiens: 1 | ||
───╯ |
55 changes: 55 additions & 0 deletions
55
.../testing/snapshots/bindings_output/mappings/named_parameters/generated/0.8.18-success.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 │ contract NamedMapping { | ||
│ ──────┬───── | ||
│ ╰─────── name: 1 | ||
2 │ mapping(address name => uint256) public justNameInKey; | ||
│ ──┬─ ──────┬────── | ||
│ ╰──────────────────────────────────── name: 3 | ||
│ │ | ||
│ ╰──────── name: 2 | ||
│ | ||
4 │ mapping(address => uint256 amount) public justNameInValue; | ||
│ ───┬── ───────┬─────── | ||
│ ╰──────────────────────────── name: 5 | ||
│ │ | ||
│ ╰───────── name: 4 | ||
│ | ||
6 │ mapping(address name => uint256 amount) public nameInBoth; | ||
│ ──┬─ ───┬── ─────┬──── | ||
│ ╰──────────────────────────────────────── name: 7 | ||
│ │ │ | ||
│ ╰─────────────────────── name: 8 | ||
│ │ | ||
│ ╰────── name: 6 | ||
───╯ | ||
Definiens: | ||
╭─[input.sol:1:1] | ||
│ | ||
1 │ ╭─────▶ contract NamedMapping { | ||
2 │ │ │ mapping(address name => uint256) public justNameInKey; | ||
│ │ │ ────────────────┬───────────┬──────────────────────────── | ||
│ │ │ ╰────────────────────────────────────────── definiens: 3 | ||
│ │ │ │ | ||
│ │ │ ╰────────────────────────────── definiens: 2 | ||
3 │ │ ╭───▶ | ||
4 │ │ ├─│ ▶ mapping(address => uint256 amount) public justNameInValue; | ||
│ │ │ │ ───────┬─────── | ||
│ │ │ │ ╰─────────────────────────────────── definiens: 5 | ||
│ │ │ │ | ||
│ │ ╰──────────────────────────────────────────────────────────────────── definiens: 4 | ||
5 │ │ ╭─▶ | ||
6 │ │ ├─▶ mapping(address name => uint256 amount) public nameInBoth; | ||
│ │ │ ──────┬───── ───────┬─────── | ||
│ │ │ ╰────────────────────────────────────────────── definiens: 7 | ||
│ │ │ │ | ||
│ │ │ ╰────────────────────────────── definiens: 8 | ||
│ │ │ | ||
│ │ ╰────────────────────────────────────────────────────────────────── definiens: 6 | ||
7 │ ├─────▶ } | ||
│ │ | ||
│ ╰─────────── definiens: 1 | ||
───╯ |
7 changes: 7 additions & 0 deletions
7
crates/solidity/testing/snapshots/bindings_output/mappings/named_parameters/input.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
contract NamedMapping { | ||
mapping(address name => uint256) public justNameInKey; | ||
|
||
mapping(address => uint256 amount) public justNameInValue; | ||
|
||
mapping(address name => uint256 amount) public nameInBoth; | ||
} |