From 0f17d5a7dd9b4c73ad1305d09bc66d353e1b789f Mon Sep 17 00:00:00 2001 From: Beta Ziliani Date: Mon, 13 Jan 2025 13:40:09 -0300 Subject: [PATCH] Replacing per-member path with enum's value ref typenode --- .../inputs/language/bindings/rules.msgb | 62 +++++++++---------- .../bindings/generated/binding_rules.rs | 62 +++++++++---------- .../generated/0.6.0-failure.txt | 4 +- .../generated/0.6.0-failure.txt | 50 +++++++++++++++ .../{0.6.0-success.txt => 0.6.8-success.txt} | 0 5 files changed, 110 insertions(+), 68 deletions(-) create mode 100644 crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/generated/0.6.0-failure.txt rename crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/generated/{0.6.0-success.txt => 0.6.8-success.txt} (100%) diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index b5fc29714c..ddd661624c 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -2063,44 +2063,40 @@ inherit .star_extension ; Path to link min and max to the enum's scope (#1158) ; It resolves paths of the form `type().min.` - node typeof - attr (typeof) pop_symbol = "@typeof" + if (version-matches ">= 0.6.8") { + node typeof + attr (typeof) pop_symbol = "@typeof" - node built_in_member - attr (built_in_member) pop_symbol = "." - node min_built_in - attr (min_built_in) pop_symbol = "min" - node max_built_in - attr (max_built_in) pop_symbol = "max" - node minmax_type_of - attr (minmax_type_of) push_symbol = "@typeof" - node minmax_replace - attr (minmax_replace) push_symbol = (source-text @name) - - edge type -> typeof - edge typeof -> built_in_member - edge built_in_member -> min_built_in - edge built_in_member -> max_built_in - edge min_built_in -> minmax_type_of - edge max_built_in -> minmax_type_of - edge minmax_type_of -> minmax_replace - edge minmax_replace -> @enum.lexical_scope -} - -@enum [EnumDefinition @name name: [Identifier] - members: [EnumMembers @item [Identifier]] -] { + node built_in_member + attr (built_in_member) pop_symbol = "." + node min_built_in + attr (min_built_in) pop_symbol = "min" + node max_built_in + attr (max_built_in) pop_symbol = "max" + node @enum.value_ref_typeof + attr (@enum.value_ref_typeof) push_symbol = "@typeof" + node value_ref_type + attr (value_ref_type) push_symbol = (source-text @name) + + edge type -> typeof + edge typeof -> built_in_member + edge built_in_member -> min_built_in + edge built_in_member -> max_built_in + edge min_built_in -> @enum.value_ref_typeof + edge max_built_in -> @enum.value_ref_typeof + edge @enum.value_ref_typeof -> value_ref_type + edge value_ref_type -> @enum.lexical_scope + } +} + +@enum [EnumDefinition 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 + if (version-matches ">= 0.6.8") { + edge def -> @enum.value_ref_typeof + } 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 30c0a35aad..d19e374ad8 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 @@ -2068,44 +2068,40 @@ inherit .star_extension ; Path to link min and max to the enum's scope (#1158) ; It resolves paths of the form `type().min.` - node typeof - attr (typeof) pop_symbol = "@typeof" + if (version-matches ">= 0.6.8") { + node typeof + attr (typeof) pop_symbol = "@typeof" - node built_in_member - attr (built_in_member) pop_symbol = "." - node min_built_in - attr (min_built_in) pop_symbol = "min" - node max_built_in - attr (max_built_in) pop_symbol = "max" - node minmax_type_of - attr (minmax_type_of) push_symbol = "@typeof" - node minmax_replace - attr (minmax_replace) push_symbol = (source-text @name) - - edge type -> typeof - edge typeof -> built_in_member - edge built_in_member -> min_built_in - edge built_in_member -> max_built_in - edge min_built_in -> minmax_type_of - edge max_built_in -> minmax_type_of - edge minmax_type_of -> minmax_replace - edge minmax_replace -> @enum.lexical_scope -} - -@enum [EnumDefinition @name name: [Identifier] - members: [EnumMembers @item [Identifier]] -] { + node built_in_member + attr (built_in_member) pop_symbol = "." + node min_built_in + attr (min_built_in) pop_symbol = "min" + node max_built_in + attr (max_built_in) pop_symbol = "max" + node @enum.value_ref_typeof + attr (@enum.value_ref_typeof) push_symbol = "@typeof" + node value_ref_type + attr (value_ref_type) push_symbol = (source-text @name) + + edge type -> typeof + edge typeof -> built_in_member + edge built_in_member -> min_built_in + edge built_in_member -> max_built_in + edge min_built_in -> @enum.value_ref_typeof + edge max_built_in -> @enum.value_ref_typeof + edge @enum.value_ref_typeof -> value_ref_type + edge value_ref_type -> @enum.lexical_scope + } +} + +@enum [EnumDefinition 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 + if (version-matches ">= 0.6.8") { + edge def -> @enum.value_ref_typeof + } edge @enum.members -> def } diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/generated/0.6.0-failure.txt index 0b14b0d940..7c5560b7eb 100644 --- a/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/generated/0.6.0-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/generated/0.6.0-failure.txt @@ -44,12 +44,12 @@ References and definitions: │ │ │ │ ╰────── unresolved │ │ - │ ╰── ref: 4 + │ ╰── unresolved 16 │ type(Answer).max.id(); │ ───┬── ─┬─ ─┬ │ ╰──────────── ref: 1 │ │ │ │ ╰────── unresolved │ │ - │ ╰── ref: 4 + │ ╰── unresolved ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..12d33d6f84 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/generated/0.6.0-failure.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 + │ │ + │ ╰── unresolved +────╯ 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.8-success.txt similarity index 100% rename from crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/generated/0.6.0-success.txt rename to crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/generated/0.6.8-success.txt