-
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 binding rules to
typeof(<enum>).min
and max
, and to `<enum…
…>.<member>` so they work with extensions (#1177) Fixes #1158. Fixes #1196. Considerations: * ~~It's built on top of #1149~~ It's rebased on master. * ~~It's currently missing a test for `max`~~ * ~~I adapted an existing test, though maybe it's preferred to add a different one?~~ * I use the same test for min and max, I think it makes sense to have them together. I'm not so sure where to put it though. It's testing these functions, but also in combination with `using for`, so it can very well be moved to the `using` folder. EDITED
- Loading branch information
1 parent
f0a0403
commit 72c0c76
Showing
12 changed files
with
511 additions
and
0 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
31 changes: 31 additions & 0 deletions
31
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/expressions.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
crates/solidity/outputs/cargo/tests/src/bindings_output/generated/using.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
...sting/snapshots/bindings_output/expressions/type_expr_minmax/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,14 @@ | ||
# 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 │ ╭─▶ enum Answer { | ||
┆ ┆ | ||
18 │ ├─▶ } | ||
│ │ | ||
│ ╰─────── Error occurred here. | ||
────╯ | ||
References and definitions: | ||
Definiens: |
88 changes: 88 additions & 0 deletions
88
...esting/snapshots/bindings_output/expressions/type_expr_minmax/generated/0.6.0-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,88 @@ | ||
# This file is generated automatically by infrastructure scripts. Please don't edit by hand. | ||
|
||
References and definitions: | ||
╭─[input.sol:1:1] | ||
│ | ||
1 │ enum Answer { | ||
│ ───┬── | ||
│ ╰──── name: 1 | ||
2 │ Yes | ||
│ ─┬─ | ||
│ ╰─── name: 2 | ||
│ | ||
5 │ library Id { | ||
│ ─┬ | ||
│ ╰── name: 3 | ||
6 │ function id(Answer ans) returns (Answer) { | ||
│ ─┬ ───┬── ─┬─ ───┬── | ||
│ ╰────────────────────────────── name: 4 | ||
│ │ │ │ | ||
│ ╰───────────────────────── ref: 1 | ||
│ │ │ | ||
│ ╰──────────────────── name: 5 | ||
│ │ | ||
│ ╰──── ref: 1 | ||
7 │ return ans; | ||
│ ─┬─ | ||
│ ╰─── ref: 5 | ||
│ | ||
11 │ contract Test { | ||
│ ──┬─ | ||
│ ╰─── name: 6 | ||
12 │ using Id for Answer; | ||
│ ─┬ ───┬── | ||
│ ╰───────────── ref: 3 | ||
│ │ | ||
│ ╰──── ref: 1 | ||
│ | ||
14 │ function testFunc() { | ||
│ ────┬─── | ||
│ ╰───── name: 7 | ||
15 │ type(Answer).min.id(); | ||
│ ───┬── ─┬─ ─┬ | ||
│ ╰──────────── ref: 1 | ||
│ │ │ | ||
│ ╰────── unresolved | ||
│ │ | ||
│ ╰── unresolved | ||
16 │ type(Answer).max.id(); | ||
│ ───┬── ─┬─ ─┬ | ||
│ ╰──────────── ref: 1 | ||
│ │ │ | ||
│ ╰────── unresolved | ||
│ │ | ||
│ ╰── unresolved | ||
────╯ | ||
Definiens: | ||
╭─[input.sol:1:1] | ||
│ | ||
1 │ ╭─▶ enum Answer { | ||
2 │ │ Yes | ||
│ │ ─┬─ | ||
│ │ ╰─── definiens: 2 | ||
3 │ │ ├─▶ } | ||
│ │ │ | ||
│ │ ╰─────── definiens: 1 | ||
4 │ ╭─────▶ | ||
┆ ┆ ┆ | ||
6 │ │ ╭───▶ function id(Answer ans) returns (Answer) { | ||
│ │ │ ─────┬──── | ||
│ │ │ ╰────── definiens: 5 | ||
┆ ┆ ┆ | ||
8 │ │ ├───▶ } | ||
│ │ │ | ||
│ │ ╰─────────── definiens: 4 | ||
9 │ │ ├─────▶ } | ||
│ │ │ | ||
│ │ ╰─────────── definiens: 3 | ||
10 │ ╭─────────▶ | ||
┆ ┆ | ||
13 │ │ ╭───────▶ | ||
┆ ┆ ┆ | ||
17 │ │ ├───────▶ } | ||
│ │ │ | ||
│ │ ╰─────────────── definiens: 7 | ||
18 │ ├─────────▶ } | ||
│ │ | ||
│ ╰─────────────── definiens: 6 | ||
────╯ |
88 changes: 88 additions & 0 deletions
88
...esting/snapshots/bindings_output/expressions/type_expr_minmax/generated/0.6.8-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,88 @@ | ||
# This file is generated automatically by infrastructure scripts. Please don't edit by hand. | ||
|
||
References and definitions: | ||
╭─[input.sol:1:1] | ||
│ | ||
1 │ enum Answer { | ||
│ ───┬── | ||
│ ╰──── name: 1 | ||
2 │ Yes | ||
│ ─┬─ | ||
│ ╰─── name: 2 | ||
│ | ||
5 │ library Id { | ||
│ ─┬ | ||
│ ╰── name: 3 | ||
6 │ function id(Answer ans) returns (Answer) { | ||
│ ─┬ ───┬── ─┬─ ───┬── | ||
│ ╰────────────────────────────── name: 4 | ||
│ │ │ │ | ||
│ ╰───────────────────────── ref: 1 | ||
│ │ │ | ||
│ ╰──────────────────── name: 5 | ||
│ │ | ||
│ ╰──── ref: 1 | ||
7 │ return ans; | ||
│ ─┬─ | ||
│ ╰─── ref: 5 | ||
│ | ||
11 │ contract Test { | ||
│ ──┬─ | ||
│ ╰─── name: 6 | ||
12 │ using Id for Answer; | ||
│ ─┬ ───┬── | ||
│ ╰───────────── ref: 3 | ||
│ │ | ||
│ ╰──── ref: 1 | ||
│ | ||
14 │ function testFunc() { | ||
│ ────┬─── | ||
│ ╰───── name: 7 | ||
15 │ type(Answer).min.id(); | ||
│ ───┬── ─┬─ ─┬ | ||
│ ╰──────────── ref: 1 | ||
│ │ │ | ||
│ ╰────── ref: built-in | ||
│ │ | ||
│ ╰── ref: 4 | ||
16 │ type(Answer).max.id(); | ||
│ ───┬── ─┬─ ─┬ | ||
│ ╰──────────── ref: 1 | ||
│ │ │ | ||
│ ╰────── ref: built-in | ||
│ │ | ||
│ ╰── ref: 4 | ||
────╯ | ||
Definiens: | ||
╭─[input.sol:1:1] | ||
│ | ||
1 │ ╭─▶ enum Answer { | ||
2 │ │ Yes | ||
│ │ ─┬─ | ||
│ │ ╰─── definiens: 2 | ||
3 │ │ ├─▶ } | ||
│ │ │ | ||
│ │ ╰─────── definiens: 1 | ||
4 │ ╭─────▶ | ||
┆ ┆ ┆ | ||
6 │ │ ╭───▶ function id(Answer ans) returns (Answer) { | ||
│ │ │ ─────┬──── | ||
│ │ │ ╰────── definiens: 5 | ||
┆ ┆ ┆ | ||
8 │ │ ├───▶ } | ||
│ │ │ | ||
│ │ ╰─────────── definiens: 4 | ||
9 │ │ ├─────▶ } | ||
│ │ │ | ||
│ │ ╰─────────── definiens: 3 | ||
10 │ ╭─────────▶ | ||
┆ ┆ | ||
13 │ │ ╭───────▶ | ||
┆ ┆ ┆ | ||
17 │ │ ├───────▶ } | ||
│ │ │ | ||
│ │ ╰─────────────── definiens: 7 | ||
18 │ ├─────────▶ } | ||
│ │ | ||
│ ╰─────────────── definiens: 6 | ||
────╯ |
18 changes: 18 additions & 0 deletions
18
crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/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,18 @@ | ||
enum Answer { | ||
Yes | ||
} | ||
|
||
library Id { | ||
function id(Answer ans) returns (Answer) { | ||
return ans; | ||
} | ||
} | ||
|
||
contract Test { | ||
using Id for Answer; | ||
|
||
function testFunc() { | ||
type(Answer).min.id(); | ||
type(Answer).max.id(); | ||
} | ||
} |
Oops, something went wrong.