diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 12d25e6f51..6baa3f30a2 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -2087,13 +2087,21 @@ inherit .star_extension edge minmax_replace -> @enum.lexical_scope } -@enum [EnumDefinition +@enum [EnumDefinition @name name: [Identifier] members: [EnumMembers @item [Identifier]] ] { node def attr (def) node_definition = @item attr (def) definiens_node = @item + node type_of + attr (type_of) push_symbol = "@typeof" + node type_def + attr (type_def) push_symbol = (source-text @name) + edge def -> type_of + edge type_of -> type_def + edge type_def -> @enum.lexical_scope + edge @enum.members -> 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 30a9d74008..d38e686eec 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 @@ -2092,13 +2092,21 @@ inherit .star_extension edge minmax_replace -> @enum.lexical_scope } -@enum [EnumDefinition +@enum [EnumDefinition @name name: [Identifier] members: [EnumMembers @item [Identifier]] ] { node def attr (def) node_definition = @item attr (def) definiens_node = @item + node type_of + attr (type_of) push_symbol = "@typeof" + node type_def + attr (type_def) push_symbol = (source-text @name) + edge def -> type_of + edge type_of -> type_def + edge type_def -> @enum.lexical_scope + edge @enum.members -> def } 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 5a10272c44..ed4d22c7d4 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,6 +14,11 @@ fn binding_enum() -> Result<()> { run("using", "binding_enum") } +#[test] +fn binding_enum_member() -> Result<()> { + run("using", "binding_enum_member") +} + #[test] fn casting() -> Result<()> { run("using", "casting") diff --git a/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..cf5e986cd3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/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 │ ╭─▶ enum Answer { + ┆ ┆ + 17 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/generated/0.6.0-success.txt new file mode 100644 index 0000000000..495d16b0fc --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/generated/0.6.0-success.txt @@ -0,0 +1,50 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ enum Answer { + │ ───┬── + │ ╰──── def: 1 + 2 │ Yes + │ ─┬─ + │ ╰─── def: 2 + │ + 5 │ library Id { + │ ─┬ + │ ╰── def: 3 + 6 │ function id(Answer ans) returns (Answer) { + │ ─┬ ───┬── ─┬─ ───┬── + │ ╰────────────────────────────── def: 4 + │ │ │ │ + │ ╰───────────────────────── ref: 1 + │ │ │ + │ ╰──────────────────── def: 5 + │ │ + │ ╰──── ref: 1 + 7 │ return ans; + │ ─┬─ + │ ╰─── ref: 5 + │ + 11 │ contract Test { + │ ──┬─ + │ ╰─── def: 6 + 12 │ using Id for Answer; + │ ─┬ ───┬── + │ ╰───────────── ref: 3 + │ │ + │ ╰──── ref: 1 + │ + 14 │ function testFunc() returns (Answer) { + │ ────┬─── ───┬── + │ ╰─────────────────────── def: 7 + │ │ + │ ╰──── ref: 1 + 15 │ Answer.Yes.id(); + │ ───┬── ─┬─ ─┬ + │ ╰─────────── ref: 1 + │ │ │ + │ ╰────── ref: 2 + │ │ + │ ╰── ref: 4 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/input.sol new file mode 100644 index 0000000000..05028ececd --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/input.sol @@ -0,0 +1,17 @@ +enum Answer { + Yes +} + +library Id { + function id(Answer ans) returns (Answer) { + return ans; + } +} + +contract Test { + using Id for Answer; + + function testFunc() returns (Answer) { + Answer.Yes.id(); + } +}