From 2117d8308318c911da654b636bdf0151c631024f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 16 Dec 2024 15:09:55 -0500 Subject: [PATCH 01/16] Remove bindings target context `{set,get}_context` methods --- crates/metaslang/bindings/src/builder/mod.rs | 28 ------- crates/metaslang/bindings/src/lib.rs | 79 ------------------- crates/metaslang/bindings/src/resolver/mod.rs | 13 +-- .../inputs/language/bindings/rules.msgb | 34 +------- .../bindings/generated/binding_rules.rs | 34 +------- .../outputs/cargo/tests/src/bindings.rs | 10 --- .../generated/contracts.rs | 10 --- .../tests/src/bindings_assertions/runner.rs | 8 -- .../cargo/tests/src/bindings_output/runner.rs | 8 -- .../solidity/outputs/cargo/tests/src/lib.rs | 1 - .../contracts/linearisation_with_context.sol | 26 ------ .../contracts/virtual_lookup.sol | 14 ---- .../generated/0.4.11-success.txt | 2 +- .../contracts/super_linearisation/input.sol | 1 - .../generated/0.4.11-success.txt | 2 +- .../contracts/virtual_lookup/input.sol | 1 - 16 files changed, 13 insertions(+), 258 deletions(-) delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings.rs delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/contracts/linearisation_with_context.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/contracts/virtual_lookup.sol diff --git a/crates/metaslang/bindings/src/builder/mod.rs b/crates/metaslang/bindings/src/builder/mod.rs index f768302d52..3628828d13 100644 --- a/crates/metaslang/bindings/src/builder/mod.rs +++ b/crates/metaslang/bindings/src/builder/mod.rs @@ -342,8 +342,6 @@ static SCOPE_TYPE: &str = "scope"; static DEBUG_ATTR_PREFIX: &str = "debug_"; static DEFINIENS_NODE_ATTR: &str = "definiens_node"; static EMPTY_SOURCE_SPAN_ATTR: &str = "empty_source_span"; -static EXPORT_NODE_ATTR: &str = "export_node"; -static IMPORT_NODES_ATTR: &str = "import_nodes"; static IS_DEFINITION_ATTR: &str = "is_definition"; static IS_ENDPOINT_ATTR: &str = "is_endpoint"; static IS_EXPORTED_ATTR: &str = "is_exported"; @@ -368,8 +366,6 @@ static POP_SCOPED_SYMBOL_ATTRS: Lazy> = Lazy::new(|| { DEFINIENS_NODE_ATTR, TAG_ATTR, PARENTS_ATTR, - EXPORT_NODE_ATTR, - IMPORT_NODES_ATTR, SYNTAX_TYPE_ATTR, EXTENSION_SCOPE_ATTR, INHERIT_EXTENSIONS_ATTR, @@ -383,8 +379,6 @@ static POP_SYMBOL_ATTRS: Lazy> = Lazy::new(|| { DEFINIENS_NODE_ATTR, TAG_ATTR, PARENTS_ATTR, - EXPORT_NODE_ATTR, - IMPORT_NODES_ATTR, SYNTAX_TYPE_ATTR, EXTENSION_SCOPE_ATTR, INHERIT_EXTENSIONS_ATTR, @@ -960,26 +954,6 @@ impl<'a, KT: KindTypes> Builder<'a, KT> { None => None, }; - let export_node = match node.attributes.get(EXPORT_NODE_ATTR) { - Some(export_node) => { - Some(self.node_handle_for_graph_node(export_node.as_graph_node_ref()?)) - } - None => None, - }; - - let import_nodes = match node.attributes.get(IMPORT_NODES_ATTR) { - Some(import_nodes) => import_nodes - .as_list()? - .iter() - .flat_map(|value| { - value - .as_graph_node_ref() - .map(|id| self.node_handle_for_graph_node(id)) - }) - .collect(), - None => Vec::new(), - }; - let extension_scope = match node.attributes.get(EXTENSION_SCOPE_ATTR) { Some(extension_scope) => { Some(self.node_handle_for_graph_node(extension_scope.as_graph_node_ref()?)) @@ -995,8 +969,6 @@ impl<'a, KT: KindTypes> Builder<'a, KT> { definiens, tag, parents, - export_node, - import_nodes, extension_scope, inherit_extensions, }, diff --git a/crates/metaslang/bindings/src/lib.rs b/crates/metaslang/bindings/src/lib.rs index e830f97004..6bb504a801 100644 --- a/crates/metaslang/bindings/src/lib.rs +++ b/crates/metaslang/bindings/src/lib.rs @@ -23,8 +23,6 @@ type CursorID = usize; pub use location::{BindingLocation, BuiltInLocation, UserFileLocation}; -pub struct DefinitionHandle(GraphHandle); - #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub(crate) enum Tag { Alias, @@ -36,8 +34,6 @@ pub(crate) struct DefinitionBindingInfo { definiens: Option>, tag: Option, parents: Vec, - export_node: Option, - import_nodes: Vec, extension_scope: Option, inherit_extensions: bool, } @@ -56,7 +52,6 @@ pub struct BindingGraph { references_info: HashMap, cursor_to_definitions: HashMap, cursor_to_references: HashMap, - context: Option, extension_hooks: HashSet, } @@ -140,7 +135,6 @@ impl BindingGraph { references_info: HashMap::new(), cursor_to_definitions: HashMap::new(), cursor_to_references: HashMap::new(), - context: None, extension_hooks: HashSet::new(), } } @@ -267,75 +261,6 @@ impl BindingGraph { .collect() } - pub fn get_context(&self) -> Option> { - self.context.and_then(|handle| self.to_definition(handle)) - } - - pub fn set_context(&mut self, context: &DefinitionHandle) { - assert!( - self.context.is_none(), - "Changing current binding context is not supported" - ); - let context_handle = context.0; - - assert!( - self.to_definition(context_handle).is_some(), - "Not a definition" - ); - self.context = Some(context_handle); - - // Retrieve export node from context - let Some(info) = self.definitions_info.get(&context_handle) else { - // no extra information for the definition; this shouldn't happen, - // but in that case we have nothing else to do - return; - }; - let Some(export_node) = info.export_node else { - // no export node in the context definition - return; - }; - - // Find all parents of the context - let all_parents = self.find_all_parents(context_handle); - - // Add stack graph edges to link to import nodes in all parents. This - // makes definitions in the export node scope reachable directly from - // all import nodes in all the parents. - for parent in &all_parents { - let Some(parent_info) = self.definitions_info.get(parent) else { - continue; - }; - for import_node in &parent_info.import_nodes { - self.stack_graph.add_edge(*import_node, export_node, 0); - } - } - } - - fn find_all_parents(&self, definition_handle: GraphHandle) -> HashSet { - let mut results = HashSet::new(); - let mut resolve_queue = Vec::new(); - resolve_queue.push(definition_handle); - - while let Some(definition) = resolve_queue.pop() { - let Some(definition_parents) = self - .definitions_info - .get(&definition) - .map(|info| &info.parents) - else { - continue; - }; - - let parents = self.resolve_handles(definition_parents); - for parent in &parents { - if !results.contains(&parent.handle) { - resolve_queue.push(parent.handle); - } - results.insert(parent.handle); - } - } - results - } - pub(crate) fn is_extension_hook(&self, node_handle: GraphHandle) -> bool { self.extension_hooks.contains(&node_handle) } @@ -443,10 +368,6 @@ impl<'a, KT: KindTypes + 'static> Definition<'a, KT> { .get(&self.handle) .map_or(false, |info| info.inherit_extensions) } - - pub fn to_handle(self) -> DefinitionHandle { - DefinitionHandle(self.handle) - } } impl Display for Definition<'_, KT> { diff --git a/crates/metaslang/bindings/src/resolver/mod.rs b/crates/metaslang/bindings/src/resolver/mod.rs index bcd01dc3b7..4ae11f2d37 100644 --- a/crates/metaslang/bindings/src/resolver/mod.rs +++ b/crates/metaslang/bindings/src/resolver/mod.rs @@ -293,19 +293,12 @@ impl<'a, KT: KindTypes + 'static> Resolver<'a, KT> { return; }; - // if the bindings has some context set, use it instead of the caller's - // to compute the full linearised ordering of methods - let resolution_context = match self.owner.get_context() { - Some(context) => context, - None => caller_context.clone(), - }; - #[allow(clippy::mutable_key_type)] - let parents = Self::resolve_parents_all(resolution_context.clone()); + let parents = Self::resolve_parents_all(caller_context.clone()); - let Some(mro) = c3::linearise(&resolution_context, &parents) else { + let Some(mro) = c3::linearise(caller_context, &parents) else { // linearisation failed - eprintln!("Linearisation of {resolution_context} failed"); + eprintln!("Linearisation of {caller_context} failed"); return; }; diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index 0033e7f90e..fb494632f1 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -442,31 +442,6 @@ inherit .star_extension 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]] { @@ -489,17 +464,16 @@ inherit .star_extension 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 (see more detailed description - ; above on the definition of the `super_import` node). - edge @contract.super -> @contract.super_import + node @contract.super_dot + attr (@contract.super_dot) pop_symbol = "." + edge @contract.super -> @contract.super_dot ; 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 @contract.super_dot -> super_instance edge super_instance -> @contract.super_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 4817a55eb7..c009037262 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 @@ -447,31 +447,6 @@ inherit .star_extension 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]] { @@ -494,17 +469,16 @@ inherit .star_extension 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 (see more detailed description - ; above on the definition of the `super_import` node). - edge @contract.super -> @contract.super_import + node @contract.super_dot + attr (@contract.super_dot) pop_symbol = "." + edge @contract.super -> @contract.super_dot ; 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 @contract.super_dot -> super_instance edge super_instance -> @contract.super_scope } diff --git a/crates/solidity/outputs/cargo/tests/src/bindings.rs b/crates/solidity/outputs/cargo/tests/src/bindings.rs deleted file mode 100644 index c5a9cf60dc..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings.rs +++ /dev/null @@ -1,10 +0,0 @@ -use slang_solidity::bindings::{BindingGraph, Definition}; - -pub fn lookup_definition_by_name<'a>( - binding_graph: &'a BindingGraph, - name: &str, -) -> Option> { - binding_graph - .all_definitions() - .find(|definition| definition.get_cursor().node().unparse() == name) -} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/contracts.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/contracts.rs index a3603d5024..88ca890f6b 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/contracts.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/contracts.rs @@ -24,16 +24,6 @@ fn linearisation_order() -> Result<()> { run("contracts", "linearisation_order") } -#[test] -fn linearisation_with_context() -> Result<()> { - run("contracts", "linearisation_with_context") -} - -#[test] -fn virtual_lookup() -> Result<()> { - run("contracts", "virtual_lookup") -} - #[test] fn virtual_single() -> Result<()> { run("contracts", "virtual_single") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs index f593e1937d..9483d30c3a 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs @@ -7,7 +7,6 @@ use semver::Version; use slang_solidity::parser::Parser; use slang_solidity::{bindings, diagnostic}; -use crate::bindings::lookup_definition_by_name; use crate::bindings_assertions::assertions::{ check_assertions, collect_assertions_into, Assertions, }; @@ -65,13 +64,6 @@ fn check_assertions_with_version(version: &Version, contents: &str) -> Result<() )?; } - if let Some(context) = multi_part.context { - let context_definition = lookup_definition_by_name(&binding_graph, context) - .expect("context definition to be found") - .to_handle(); - binding_graph.set_context(&context_definition); - } - let result = check_assertions(&binding_graph, &assertions, version); match result { diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/runner.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/runner.rs index 5daaf93288..218e694e4f 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/runner.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/runner.rs @@ -13,7 +13,6 @@ use slang_solidity::parser::{ParseOutput, Parser}; use super::graph::graphviz::render as render_graphviz_graph; use super::graph::mermaid::render as render_mermaid_graph; use super::renderer::render_bindings; -use crate::bindings::lookup_definition_by_name; use crate::generated::VERSION_BREAKS; use crate::multi_part_file::{split_multi_file, Part}; use crate::resolver::TestsPathResolver; @@ -66,13 +65,6 @@ pub fn run(group_name: &str, test_name: &str) -> Result<()> { }); } - if let Some(context) = multi_part.context { - let context_definition = lookup_definition_by_name(&binding_graph, context) - .expect("context definition to be found") - .to_handle(); - binding_graph.set_context(&context_definition); - } - let (bindings_output, all_resolved) = render_bindings(&binding_graph, &parsed_parts)?; let parse_success = parsed_parts.iter().all(|part| part.parse_output.is_valid()); diff --git a/crates/solidity/outputs/cargo/tests/src/lib.rs b/crates/solidity/outputs/cargo/tests/src/lib.rs index b62d53c1a2..519c795d76 100644 --- a/crates/solidity/outputs/cargo/tests/src/lib.rs +++ b/crates/solidity/outputs/cargo/tests/src/lib.rs @@ -3,7 +3,6 @@ use metaslang_bindings as _; mod binding_rules; -mod bindings; mod bindings_assertions; mod bindings_output; mod built_ins; diff --git a/crates/solidity/testing/snapshots/bindings_assertions/contracts/linearisation_with_context.sol b/crates/solidity/testing/snapshots/bindings_assertions/contracts/linearisation_with_context.sol deleted file mode 100644 index 482d99acd1..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/contracts/linearisation_with_context.sol +++ /dev/null @@ -1,26 +0,0 @@ -// --- context: D -contract A { - function foo() public {} - // ^def:1 -} -contract B is A { - function foo() public { - // ^def:2 - super.foo(); - // ^ref:1 - } -} -contract C is A { - function foo() public { - // ^def:3 - super.foo(); - // ^ref:2 - } -} -contract D is B, C { - function foo() public { - // ^def:4 - super.foo(); - // ^ref:3 - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/contracts/virtual_lookup.sol b/crates/solidity/testing/snapshots/bindings_assertions/contracts/virtual_lookup.sol deleted file mode 100644 index 34e13982e2..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/contracts/virtual_lookup.sol +++ /dev/null @@ -1,14 +0,0 @@ -// --- context: Derived -contract Base { - function foo() public {} - // ^def:1 - function bar() public { - foo(); - // Date: Mon, 16 Dec 2024 16:28:44 -0500 Subject: [PATCH 02/16] Use `Reference::definitions()` instead of `resolve_definition()` This results in some references being resolved to many ambiguous definitions, some of which we were able to resolve via ranking. --- .../tests/src/bindings_output/renderer.rs | 28 +++++++++---------- .../shadowing/generated/0.4.11-failure.txt | 4 +-- .../shadowing/generated/0.6.0-failure.txt | 4 +-- .../shadowing/generated/0.7.1-success.txt | 4 +-- .../generated/0.4.11-success.txt | 2 +- .../generated/0.4.16-failure.txt | 2 +- .../generated/0.6.0-success.txt | 2 +- .../diamond/generated/0.6.0-success.txt | 2 +- .../generated/0.6.0-success.txt | 2 +- .../using/global/generated/0.6.0-failure.txt | 2 +- .../using/global/generated/0.7.1-failure.txt | 2 +- .../using/global/generated/0.7.4-failure.txt | 2 +- .../using/global/generated/0.8.0-failure.txt | 2 +- .../using/global/generated/0.8.13-success.txt | 2 +- .../using/global/generated/0.8.4-failure.txt | 2 +- .../using/global/generated/0.8.8-failure.txt | 2 +- 16 files changed, 32 insertions(+), 32 deletions(-) diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/renderer.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/renderer.rs index b347b541d7..0d85b8390d 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/renderer.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/renderer.rs @@ -3,7 +3,6 @@ use std::ops::Range; use anyhow::Result; use ariadne::{Color, Config, FnCache, Label, Report, ReportBuilder, ReportKind, Source}; -use metaslang_bindings::ResolutionError; use slang_solidity::bindings::{BindingGraph, Definition, Reference}; use slang_solidity::diagnostic; @@ -111,33 +110,34 @@ fn build_report_for_part<'a>( start..end }; - let definition = reference.resolve_definition(); - let message = match definition { - Ok(definition) => { + let definitions = reference.definitions(); + let message = match definitions.len() { + 0 => { + all_resolved = false; + "unresolved".to_string() + } + 1 => { + let definition = definitions.first().unwrap(); if definition.get_file().is_system() { "ref: built-in".to_string() } else { let def_id = all_definitions .iter() - .position(|d| *d == definition) + .position(|d| d == definition) .unwrap(); format!("ref: {}", def_id + 1) } } - Err(ResolutionError::Unresolved) => { - all_resolved = false; - "unresolved".to_string() - } - Err(ResolutionError::AmbiguousDefinitions(ambiguous_definitions)) => { - let ref_labels = ambiguous_definitions + _ => { + let ref_labels = definitions .iter() - .filter_map(|ambiguous_definition| { - if ambiguous_definition.get_file().is_system() { + .filter_map(|definition| { + if definition.get_file().is_system() { Some("built-in".to_string()) } else { all_definitions .iter() - .position(|d| d == ambiguous_definition) + .position(|d| d == definition) .map(|index| format!("{}", index + 1)) } }) diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.4.11-failure.txt index abe2059ade..8c91b0251a 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.4.11-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.4.11-failure.txt @@ -29,10 +29,10 @@ References and definitions: │ ╰──── ref: 4 7 │ tx; │ ─┬ - │ ╰── ref: 2 + │ ╰── refs: 2, built-in 8 │ sha256(); │ ───┬── - │ ╰──── ref: 5 + │ ╰──── refs: 5, built-in │ 11 │ function sha256() public {} │ ───┬── diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.6.0-failure.txt index bc8b1ad05d..c4d155083b 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.6.0-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.6.0-failure.txt @@ -29,10 +29,10 @@ References and definitions: │ ╰──── ref: 4 7 │ tx; │ ─┬ - │ ╰── ref: 2 + │ ╰── refs: 2, built-in 8 │ sha256(); │ ───┬── - │ ╰──── ref: 5 + │ ╰──── refs: 5, built-in │ 11 │ function sha256() public {} │ ───┬── diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.7.1-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.7.1-success.txt index 2328f83440..89b9b0e9e7 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.7.1-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.7.1-success.txt @@ -21,10 +21,10 @@ References and definitions: │ ╰──── ref: 4 7 │ tx; │ ─┬ - │ ╰── ref: 2 + │ ╰── refs: 2, built-in 8 │ sha256(); │ ───┬── - │ ╰──── ref: 5 + │ ╰──── refs: 6, 5, built-in │ 11 │ function sha256() public {} │ ───┬── 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 a05550297e..8fd5f7d670 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 @@ -46,5 +46,5 @@ References and definitions: │ ╰─── def: 8 16 │ super.foo(); │ ─┬─ - │ ╰─── ref: 6 + │ ╰─── refs: 4, 6, 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 1a4864098f..26fde7c07e 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 @@ -59,5 +59,5 @@ References and definitions: │ ╰── ref: 5 25 │ return super.foo(); │ ─┬─ - │ ╰─── ref: 6 + │ ╰─── refs: 4, 6, 2 ────╯ 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 c5f1386460..6130d975a5 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 @@ -47,5 +47,5 @@ References and definitions: │ ╰── ref: 5 25 │ return super.foo(); │ ─┬─ - │ ╰─── ref: 6 + │ ╰─── refs: 4, 6, 2 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/modifiers/diamond/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/modifiers/diamond/generated/0.6.0-success.txt index 5df0924d4d..d58681576e 100644 --- a/crates/solidity/testing/snapshots/bindings_output/modifiers/diamond/generated/0.6.0-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/modifiers/diamond/generated/0.6.0-success.txt @@ -45,5 +45,5 @@ References and definitions: │ ──┬─ ─┬─ │ ╰──────────────── def: 8 │ │ - │ ╰─── ref: 4 + │ ╰─── refs: 6, 4, 2 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/modifiers/virtual_modifier/generated/0.6.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/modifiers/virtual_modifier/generated/0.6.0-success.txt index 9a2ec20102..827e4a93ca 100644 --- a/crates/solidity/testing/snapshots/bindings_output/modifiers/virtual_modifier/generated/0.6.0-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/modifiers/virtual_modifier/generated/0.6.0-success.txt @@ -28,5 +28,5 @@ References and definitions: │ ──┬─ ─┬─ │ ╰──────────────── def: 5 │ │ - │ ╰─── ref: 4 + │ ╰─── refs: 4, 2 ───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.6.0-failure.txt index 7b9380887a..cfc3174cc8 100644 --- a/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.6.0-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.6.0-failure.txt @@ -36,7 +36,7 @@ References and definitions: │ ──┬─ ───┬─── ┬ │ ╰──────────────────── def: 5 │ │ │ - │ ╰────────────── ref: 1 + │ ╰────────────── refs: 3, 1 │ │ │ ╰── def: 6 5 │ c.increment(); diff --git a/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.7.1-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.7.1-failure.txt index 8818c91b3a..3dfc14326c 100644 --- a/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.7.1-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.7.1-failure.txt @@ -43,7 +43,7 @@ References and definitions: │ ──┬─ ───┬─── ┬ │ ╰──────────────────── def: 7 │ │ │ - │ ╰────────────── ref: 1 + │ ╰────────────── refs: 5, 1 │ │ │ ╰── def: 8 5 │ c.increment(); diff --git a/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.7.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.7.4-failure.txt index 19f25ba046..d383a1d1ee 100644 --- a/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.7.4-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.7.4-failure.txt @@ -43,7 +43,7 @@ References and definitions: │ ──┬─ ───┬─── ┬ │ ╰──────────────────── def: 7 │ │ │ - │ ╰────────────── ref: 1 + │ ╰────────────── refs: 5, 1 │ │ │ ╰── def: 8 5 │ c.increment(); diff --git a/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.0-failure.txt index dd2e75f8c2..9ba5ad2980 100644 --- a/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.0-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.0-failure.txt @@ -43,7 +43,7 @@ References and definitions: │ ──┬─ ───┬─── ┬ │ ╰──────────────────── def: 7 │ │ │ - │ ╰────────────── ref: 1 + │ ╰────────────── refs: 5, 1 │ │ │ ╰── def: 8 5 │ c.increment(); diff --git a/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.13-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.13-success.txt index ee2ee4c284..00bd4d0ee5 100644 --- a/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.13-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.13-success.txt @@ -40,7 +40,7 @@ References and definitions: │ ──┬─ ───┬─── ┬ │ ╰──────────────────── def: 7 │ │ │ - │ ╰────────────── ref: 1 + │ ╰────────────── refs: 5, 1 │ │ │ ╰── def: 8 5 │ c.increment(); diff --git a/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.4-failure.txt index 5b849d8c4b..4c21e38795 100644 --- a/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.4-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.4-failure.txt @@ -43,7 +43,7 @@ References and definitions: │ ──┬─ ───┬─── ┬ │ ╰──────────────────── def: 7 │ │ │ - │ ╰────────────── ref: 1 + │ ╰────────────── refs: 5, 1 │ │ │ ╰── def: 8 5 │ c.increment(); diff --git a/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.8-failure.txt b/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.8-failure.txt index bdd41ff013..6908d13734 100644 --- a/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.8-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/using/global/generated/0.8.8-failure.txt @@ -43,7 +43,7 @@ References and definitions: │ ──┬─ ───┬─── ┬ │ ╰──────────────────── def: 7 │ │ │ - │ ╰────────────── ref: 1 + │ ╰────────────── refs: 5, 1 │ │ │ ╰── def: 8 5 │ c.increment(); From 9ed010d275c8411622939fc413c8c67525c212e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 16 Dec 2024 18:57:24 -0500 Subject: [PATCH 03/16] Migrate some binding assertions tests to snapshots --- .../bindings_assertions/generated/enums.rs | 10 ----- .../generated/interfaces.rs | 10 ----- .../src/bindings_assertions/generated/mod.rs | 5 --- .../generated/modifiers.rs | 10 ----- .../generated/user_types.rs | 10 ----- .../bindings_assertions/generated/using.rs | 10 ----- .../bindings_output/generated/user_types.rs | 15 +++++++ .../enums/in_state_vars.sol | 10 ----- .../interfaces/visibility.sol | 32 --------------- .../modifiers/placeholder.sol | 6 --- .../user_types/visibility.sol | 33 --------------- .../bindings_assertions/using/inherited.sol | 16 -------- .../visibility/generated/0.4.11-success.txt | 31 +++++++++----- .../interfaces/visibility/input.sol | 8 +++- .../in_contract/generated/0.4.11-failure.txt | 19 +++++++++ .../in_contract/generated/0.4.22-failure.txt | 19 +++++++++ .../in_contract/generated/0.6.0-failure.txt | 19 +++++++++ .../in_contract/generated/0.8.0-failure.txt | 19 +++++++++ .../in_contract/generated/0.8.4-failure.txt | 19 +++++++++ .../in_contract/generated/0.8.8-success.txt | 32 +++++++++++++++ .../user_types/in_contract/input.sol | 8 ++++ .../in_library/generated/0.4.11-failure.txt | 37 +++++++++++++++++ .../in_library/generated/0.4.22-failure.txt | 37 +++++++++++++++++ .../in_library/generated/0.6.0-failure.txt | 37 +++++++++++++++++ .../in_library/generated/0.8.0-failure.txt | 37 +++++++++++++++++ .../in_library/generated/0.8.4-failure.txt | 37 +++++++++++++++++ .../in_library/generated/0.8.8-success.txt | 41 +++++++++++++++++++ .../user_types/in_library/input.sol | 13 ++++++ .../top_level/generated/0.4.11-failure.txt | 29 +++++++++++++ .../top_level/generated/0.4.16-failure.txt | 36 ++++++++++++++++ .../top_level/generated/0.6.0-failure.txt | 36 ++++++++++++++++ .../top_level/generated/0.7.1-failure.txt | 36 ++++++++++++++++ .../top_level/generated/0.7.4-failure.txt | 36 ++++++++++++++++ .../top_level/generated/0.8.0-failure.txt | 36 ++++++++++++++++ .../top_level/generated/0.8.4-failure.txt | 36 ++++++++++++++++ .../top_level/generated/0.8.8-success.txt | 32 +++++++++++++++ .../user_types/top_level/input.sol | 8 ++++ 37 files changed, 701 insertions(+), 164 deletions(-) delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/enums.rs delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/interfaces.rs delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/modifiers.rs delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/user_types.rs delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/using.rs delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/enums/in_state_vars.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/interfaces/visibility.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/modifiers/placeholder.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/user_types/visibility.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/using/inherited.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.4.22-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.6.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.8.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.8.4-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.8.8-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.4.22-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.6.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.8.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.8.4-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.8.8-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/in_library/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.4.16-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.6.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.7.1-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.7.4-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.8.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.8.4-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.8.8-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/user_types/top_level/input.sol diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/enums.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/enums.rs deleted file mode 100644 index 03e8d7c029..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/enums.rs +++ /dev/null @@ -1,10 +0,0 @@ -// 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 in_state_vars() -> Result<()> { - run("enums", "in_state_vars") -} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/interfaces.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/interfaces.rs deleted file mode 100644 index 7d956ee7ae..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/interfaces.rs +++ /dev/null @@ -1,10 +0,0 @@ -// 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 visibility() -> Result<()> { - run("interfaces", "visibility") -} 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 e61b9a8f6b..50de0ca0cb 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 @@ -4,18 +4,13 @@ mod arrays; mod constants; mod contracts; mod control; -mod enums; mod errors; mod events; mod expressions; mod function_types; mod functions; mod imports; -mod interfaces; 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/modifiers.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/modifiers.rs deleted file mode 100644 index bd63a004e6..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/modifiers.rs +++ /dev/null @@ -1,10 +0,0 @@ -// 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 placeholder() -> Result<()> { - run("modifiers", "placeholder") -} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/user_types.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/user_types.rs deleted file mode 100644 index 66cd48f377..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/user_types.rs +++ /dev/null @@ -1,10 +0,0 @@ -// 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 visibility() -> Result<()> { - run("user_types", "visibility") -} 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 deleted file mode 100644 index 58420ec02b..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/using.rs +++ /dev/null @@ -1,10 +0,0 @@ -// 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/outputs/cargo/tests/src/bindings_output/generated/user_types.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/user_types.rs index 889783f382..cff4124f21 100644 --- 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 @@ -4,6 +4,21 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn in_contract() -> Result<()> { + run("user_types", "in_contract") +} + +#[test] +fn in_library() -> Result<()> { + run("user_types", "in_library") +} + +#[test] +fn top_level() -> Result<()> { + run("user_types", "top_level") +} + #[test] fn wrap_unwrap() -> Result<()> { run("user_types", "wrap_unwrap") diff --git a/crates/solidity/testing/snapshots/bindings_assertions/enums/in_state_vars.sol b/crates/solidity/testing/snapshots/bindings_assertions/enums/in_state_vars.sol deleted file mode 100644 index 7c0a1c0d2d..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/enums/in_state_vars.sol +++ /dev/null @@ -1,10 +0,0 @@ -contract Foo { - enum Answer { Yes, No } - // ^def:3 - // ^def:2 - // ^def:1 - Answer choice = Answer.Yes; - //= 0.8.8) - - function test() public returns (int32) { - Internal inter = Internal.wrap(10); - // ^ref:2 (>= 0.8.8) - //= 0.8.8) - TopLevel tl = TopLevel.wrap(20); - // ^ref:1 (>= 0.8.8) - //= 0.8.8) - return MyLib.LibType.unwrap(MyLib.create()); - // ^ref:3 - // ^ref:4 (>= 0.8.8) - // ^ref:3 (>= 0.8.8) - } -} - -type TopLevel is uint256; -// ^def:1 (>= 0.8.8) - -library MyLib { - // ^def:3 - type LibType is int32; - // ^def:4 (>= 0.8.8) - - function create() public returns (LibType) { - // ^ref:4 (>= 0.8.8) - return LibType.wrap(30); - // ^ref:4 (>= 0.8.8) - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/using/inherited.sol b/crates/solidity/testing/snapshots/bindings_assertions/using/inherited.sol deleted file mode 100644 index 6bcd410801..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/using/inherited.sol +++ /dev/null @@ -1,16 +0,0 @@ -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) - } -} diff --git a/crates/solidity/testing/snapshots/bindings_output/interfaces/visibility/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/interfaces/visibility/generated/0.4.11-success.txt index 7e688f770f..a8805838d5 100644 --- a/crates/solidity/testing/snapshots/bindings_output/interfaces/visibility/generated/0.4.11-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/interfaces/visibility/generated/0.4.11-success.txt @@ -18,16 +18,14 @@ References and definitions: │ ╰─────────────────── def: 5 │ │ │ ╰──── def: 6 - 4 │ function calculate() returns (Choice); - │ ────┬──── ───┬── - │ ╰──────────────────────── def: 7 - │ │ - │ ╰──── ref: 2 - 5 │ function get_book() returns (Book); - │ ────┬─── ──┬─ - │ ╰───────────────────── def: 8 - │ │ - │ ╰─── ref: 5 + 4 │ function calculate() external returns (int); + │ ────┬──── + │ ╰────── def: 7 + 5 │ function get_book() external returns (Book memory); + │ ────┬─── ──┬─ + │ ╰────────────────────────────── def: 8 + │ │ + │ ╰─── ref: 5 │ 8 │ contract Test { │ ──┬─ @@ -52,4 +50,17 @@ References and definitions: │ ╰──────── ref: 5 │ │ │ ╰─── def: 11 + │ + 12 │ function test(Example e) public returns (int) { + │ ──┬─ ───┬─── ┬ + │ ╰───────────── def: 12 + │ │ │ + │ ╰─────── ref: 1 + │ │ + │ ╰── def: 13 + 13 │ return e.calculate(); + │ ┬ ────┬──── + │ ╰──────────── ref: 13 + │ │ + │ ╰────── ref: 7 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/interfaces/visibility/input.sol b/crates/solidity/testing/snapshots/bindings_output/interfaces/visibility/input.sol index b509d7ea62..4e28e85fda 100644 --- a/crates/solidity/testing/snapshots/bindings_output/interfaces/visibility/input.sol +++ b/crates/solidity/testing/snapshots/bindings_output/interfaces/visibility/input.sol @@ -1,11 +1,15 @@ interface Example { enum Choice { One, Two } struct Book { string author; } - function calculate() returns (Choice); - function get_book() returns (Book); + function calculate() external returns (int); + function get_book() external returns (Book memory); } contract Test { Example.Choice choice = Example.Choice.One; Example.Book book; + + function test(Example e) public returns (int) { + return e.calculate(); + } } diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..5aa5ff3f9d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.4.11-failure.txt @@ -0,0 +1,19 @@ +# 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 CloseBrace or EnumKeyword or EventKeyword or FixedKeyword or FunctionKeyword or Identifier or IntKeyword or MappingKeyword or ModifierKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword or UsingKeyword. + ╭─[input.sol:2:5] + │ + 2 │ ╭─▶ type Internal is uint; + ┆ ┆ + 7 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.4.22-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.4.22-failure.txt new file mode 100644 index 0000000000..56126ea484 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.4.22-failure.txt @@ -0,0 +1,19 @@ +# 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 CloseBrace or ConstructorKeyword or EnumKeyword or EventKeyword or FixedKeyword or FunctionKeyword or Identifier or IntKeyword or MappingKeyword or ModifierKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword or UsingKeyword. + ╭─[input.sol:2:5] + │ + 2 │ ╭─▶ type Internal is uint; + ┆ ┆ + 7 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..445629933b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/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 AddressKeyword or BoolKeyword or ByteKeyword or BytesKeyword or CloseBrace or ConstructorKeyword or EnumKeyword or EventKeyword or FallbackKeyword or FixedKeyword or FunctionKeyword or Identifier or IntKeyword or MappingKeyword or ModifierKeyword or ReceiveKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword or UsingKeyword. + ╭─[input.sol:2:5] + │ + 2 │ ╭─▶ type Internal is uint; + ┆ ┆ + 7 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.8.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.8.0-failure.txt new file mode 100644 index 0000000000..c4c127cfa5 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.8.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 AddressKeyword or BoolKeyword or BytesKeyword or CloseBrace or ConstructorKeyword or EnumKeyword or EventKeyword or FallbackKeyword or FixedKeyword or FunctionKeyword or Identifier or IntKeyword or MappingKeyword or ModifierKeyword or ReceiveKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword or UsingKeyword. + ╭─[input.sol:2:5] + │ + 2 │ ╭─▶ type Internal is uint; + ┆ ┆ + 7 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.8.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.8.4-failure.txt new file mode 100644 index 0000000000..e1aa3a9f74 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.8.4-failure.txt @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or BoolKeyword or BytesKeyword or CloseBrace or ConstructorKeyword or EnumKeyword or ErrorKeyword or EventKeyword or FallbackKeyword or FixedKeyword or FunctionKeyword or Identifier or IntKeyword or MappingKeyword or ModifierKeyword or ReceiveKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword or UsingKeyword. + ╭─[input.sol:2:5] + │ + 2 │ ╭─▶ type Internal is uint; + ┆ ┆ + 7 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.8.8-success.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.8.8-success.txt new file mode 100644 index 0000000000..1125d6a19b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/generated/0.8.8-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 │ type Internal is uint; + │ ────┬─── + │ ╰───── def: 2 + │ + 4 │ function test() public returns (uint) { + │ ──┬─ + │ ╰─── def: 3 + 5 │ Internal inter = Internal.wrap(10); + │ ────┬─── ──┬── ────┬─── ──┬─ + │ ╰─────────────────────────── ref: 2 + │ │ │ │ + │ ╰──────────────────── def: 4 + │ │ │ + │ ╰────────── ref: 2 + │ │ + │ ╰─── ref: built-in + 6 │ return Internal.unwrap(inter); + │ ────┬─── ───┬── ──┬── + │ ╰────────────────── ref: 2 + │ │ │ + │ ╰────────── ref: built-in + │ │ + │ ╰──── ref: 4 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/input.sol b/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/input.sol new file mode 100644 index 0000000000..d11ee80514 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/in_contract/input.sol @@ -0,0 +1,8 @@ +contract Test { + type Internal is uint; + + function test() public returns (uint) { + Internal inter = Internal.wrap(10); + return Internal.unwrap(inter); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..c0606e01dd --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.4.11-failure.txt @@ -0,0 +1,37 @@ +# 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 CloseBrace or EnumKeyword or EventKeyword or FixedKeyword or FunctionKeyword or Identifier or IntKeyword or MappingKeyword or ModifierKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword or UsingKeyword. + ╭─[input.sol:8:5] + │ + 8 │ ╭─▶ type LibType is int32; + ┆ ┆ + 12 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public returns (int32) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ return MyLib.LibType.unwrap(MyLib.create()); + │ ──┬── ───┬─── ───┬── ──┬── ───┬── + │ ╰──────────────────────────────── ref: 3 + │ │ │ │ │ + │ ╰───────────────────────── unresolved + │ │ │ │ + │ ╰───────────────── unresolved + │ │ │ + │ ╰─────────── ref: 3 + │ │ + │ ╰──── unresolved + │ + 7 │ library MyLib { + │ ──┬── + │ ╰──── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.4.22-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.4.22-failure.txt new file mode 100644 index 0000000000..d938cff091 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.4.22-failure.txt @@ -0,0 +1,37 @@ +# 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 CloseBrace or ConstructorKeyword or EnumKeyword or EventKeyword or FixedKeyword or FunctionKeyword or Identifier or IntKeyword or MappingKeyword or ModifierKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword or UsingKeyword. + ╭─[input.sol:8:5] + │ + 8 │ ╭─▶ type LibType is int32; + ┆ ┆ + 12 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public returns (int32) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ return MyLib.LibType.unwrap(MyLib.create()); + │ ──┬── ───┬─── ───┬── ──┬── ───┬── + │ ╰──────────────────────────────── ref: 3 + │ │ │ │ │ + │ ╰───────────────────────── unresolved + │ │ │ │ + │ ╰───────────────── unresolved + │ │ │ + │ ╰─────────── ref: 3 + │ │ + │ ╰──── unresolved + │ + 7 │ library MyLib { + │ ──┬── + │ ╰──── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..4f8d2ea1ed --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.6.0-failure.txt @@ -0,0 +1,37 @@ +# 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 CloseBrace or ConstructorKeyword or EnumKeyword or EventKeyword or FallbackKeyword or FixedKeyword or FunctionKeyword or Identifier or IntKeyword or MappingKeyword or ModifierKeyword or ReceiveKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword or UsingKeyword. + ╭─[input.sol:8:5] + │ + 8 │ ╭─▶ type LibType is int32; + ┆ ┆ + 12 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public returns (int32) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ return MyLib.LibType.unwrap(MyLib.create()); + │ ──┬── ───┬─── ───┬── ──┬── ───┬── + │ ╰──────────────────────────────── ref: 3 + │ │ │ │ │ + │ ╰───────────────────────── unresolved + │ │ │ │ + │ ╰───────────────── unresolved + │ │ │ + │ ╰─────────── ref: 3 + │ │ + │ ╰──── unresolved + │ + 7 │ library MyLib { + │ ──┬── + │ ╰──── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.8.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.8.0-failure.txt new file mode 100644 index 0000000000..e6e1fab2ba --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.8.0-failure.txt @@ -0,0 +1,37 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or BoolKeyword or BytesKeyword or CloseBrace or ConstructorKeyword or EnumKeyword or EventKeyword or FallbackKeyword or FixedKeyword or FunctionKeyword or Identifier or IntKeyword or MappingKeyword or ModifierKeyword or ReceiveKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword or UsingKeyword. + ╭─[input.sol:8:5] + │ + 8 │ ╭─▶ type LibType is int32; + ┆ ┆ + 12 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public returns (int32) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ return MyLib.LibType.unwrap(MyLib.create()); + │ ──┬── ───┬─── ───┬── ──┬── ───┬── + │ ╰──────────────────────────────── ref: 3 + │ │ │ │ │ + │ ╰───────────────────────── unresolved + │ │ │ │ + │ ╰───────────────── unresolved + │ │ │ + │ ╰─────────── ref: 3 + │ │ + │ ╰──── unresolved + │ + 7 │ library MyLib { + │ ──┬── + │ ╰──── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.8.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.8.4-failure.txt new file mode 100644 index 0000000000..8441227922 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.8.4-failure.txt @@ -0,0 +1,37 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected AddressKeyword or BoolKeyword or BytesKeyword or CloseBrace or ConstructorKeyword or EnumKeyword or ErrorKeyword or EventKeyword or FallbackKeyword or FixedKeyword or FunctionKeyword or Identifier or IntKeyword or MappingKeyword or ModifierKeyword or ReceiveKeyword or StringKeyword or StructKeyword or UfixedKeyword or UintKeyword or UsingKeyword. + ╭─[input.sol:8:5] + │ + 8 │ ╭─▶ type LibType is int32; + ┆ ┆ + 12 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public returns (int32) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ return MyLib.LibType.unwrap(MyLib.create()); + │ ──┬── ───┬─── ───┬── ──┬── ───┬── + │ ╰──────────────────────────────── ref: 3 + │ │ │ │ │ + │ ╰───────────────────────── unresolved + │ │ │ │ + │ ╰───────────────── unresolved + │ │ │ + │ ╰─────────── ref: 3 + │ │ + │ ╰──── unresolved + │ + 7 │ library MyLib { + │ ──┬── + │ ╰──── def: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.8.8-success.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.8.8-success.txt new file mode 100644 index 0000000000..4d9130bcec --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/generated/0.8.8-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 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public returns (int32) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ return MyLib.LibType.unwrap(MyLib.create()); + │ ──┬── ───┬─── ───┬── ──┬── ───┬── + │ ╰──────────────────────────────── ref: 3 + │ │ │ │ │ + │ ╰───────────────────────── ref: 4 + │ │ │ │ + │ ╰───────────────── ref: built-in + │ │ │ + │ ╰─────────── ref: 3 + │ │ + │ ╰──── ref: 5 + │ + 7 │ library MyLib { + │ ──┬── + │ ╰──── def: 3 + 8 │ type LibType is int32; + │ ───┬─── + │ ╰───── def: 4 + │ + 10 │ function create() public returns (LibType) { + │ ───┬── ───┬─── + │ ╰────────────────────────────── def: 5 + │ │ + │ ╰───── ref: 4 + 11 │ return LibType.wrap(30); + │ ───┬─── ──┬─ + │ ╰────────── ref: 4 + │ │ + │ ╰─── ref: built-in +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/input.sol b/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/input.sol new file mode 100644 index 0000000000..db9e99f584 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/in_library/input.sol @@ -0,0 +1,13 @@ +contract Test { + function test() public returns (int32) { + return MyLib.LibType.unwrap(MyLib.create()); + } +} + +library MyLib { + type LibType is int32; + + function create() public returns (LibType) { + return LibType.wrap(30); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..5f9618804c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.4.11-failure.txt @@ -0,0 +1,29 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected OpenBrace or ReturnsKeyword or Semicolon. + ╭─[input.sol:2:28] + │ + 2 │ ╭─▶ function test() public pure returns (uint) { + ┆ ┆ + 5 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +Error: Expected ContractKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword. + ╭─[input.sol:8:1] + │ + 8 │ type TopLevel is uint256; + │ ─────────────┬──────────── + │ ╰────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public pure returns (uint) { + │ ──┬─ + │ ╰─── def: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.4.16-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.4.16-failure.txt new file mode 100644 index 0000000000..3ffc33cdf8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.4.16-failure.txt @@ -0,0 +1,36 @@ +# 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:8:1] + │ + 8 │ type TopLevel is uint256; + │ ─────────────┬──────────── + │ ╰────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public pure returns (uint) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ TopLevel tl = TopLevel.wrap(20); + │ ────┬─── ─┬ ────┬─── ──┬─ + │ ╰──────────────────────── unresolved + │ │ │ │ + │ ╰────────────────── def: 3 + │ │ │ + │ ╰────────── unresolved + │ │ + │ ╰─── unresolved + 4 │ return TopLevel.unwrap(tl); + │ ────┬─── ───┬── ─┬ + │ ╰─────────────── unresolved + │ │ │ + │ ╰─────── unresolved + │ │ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..2e44ebdbc7 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.6.0-failure.txt @@ -0,0 +1,36 @@ +# 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:8:1] + │ + 8 │ type TopLevel is uint256; + │ ─────────────┬──────────── + │ ╰────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public pure returns (uint) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ TopLevel tl = TopLevel.wrap(20); + │ ────┬─── ─┬ ────┬─── ──┬─ + │ ╰──────────────────────── unresolved + │ │ │ │ + │ ╰────────────────── def: 3 + │ │ │ + │ ╰────────── unresolved + │ │ + │ ╰─── unresolved + 4 │ return TopLevel.unwrap(tl); + │ ────┬─── ───┬── ─┬ + │ ╰─────────────── unresolved + │ │ │ + │ ╰─────── unresolved + │ │ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.7.1-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.7.1-failure.txt new file mode 100644 index 0000000000..30d1c80175 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.7.1-failure.txt @@ -0,0 +1,36 @@ +# 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:8:1] + │ + 8 │ type TopLevel is uint256; + │ ─────────────┬──────────── + │ ╰────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public pure returns (uint) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ TopLevel tl = TopLevel.wrap(20); + │ ────┬─── ─┬ ────┬─── ──┬─ + │ ╰──────────────────────── unresolved + │ │ │ │ + │ ╰────────────────── def: 3 + │ │ │ + │ ╰────────── unresolved + │ │ + │ ╰─── unresolved + 4 │ return TopLevel.unwrap(tl); + │ ────┬─── ───┬── ─┬ + │ ╰─────────────── unresolved + │ │ │ + │ ╰─────── unresolved + │ │ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.7.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.7.4-failure.txt new file mode 100644 index 0000000000..578099d762 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.7.4-failure.txt @@ -0,0 +1,36 @@ +# 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:8:1] + │ + 8 │ type TopLevel is uint256; + │ ─────────────┬──────────── + │ ╰────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public pure returns (uint) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ TopLevel tl = TopLevel.wrap(20); + │ ────┬─── ─┬ ────┬─── ──┬─ + │ ╰──────────────────────── unresolved + │ │ │ │ + │ ╰────────────────── def: 3 + │ │ │ + │ ╰────────── unresolved + │ │ + │ ╰─── unresolved + 4 │ return TopLevel.unwrap(tl); + │ ────┬─── ───┬── ─┬ + │ ╰─────────────── unresolved + │ │ │ + │ ╰─────── unresolved + │ │ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.8.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.8.0-failure.txt new file mode 100644 index 0000000000..3b384a5f6f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.8.0-failure.txt @@ -0,0 +1,36 @@ +# 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:8:1] + │ + 8 │ type TopLevel is uint256; + │ ─────────────┬──────────── + │ ╰────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public pure returns (uint) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ TopLevel tl = TopLevel.wrap(20); + │ ────┬─── ─┬ ────┬─── ──┬─ + │ ╰──────────────────────── unresolved + │ │ │ │ + │ ╰────────────────── def: 3 + │ │ │ + │ ╰────────── unresolved + │ │ + │ ╰─── unresolved + 4 │ return TopLevel.unwrap(tl); + │ ────┬─── ───┬── ─┬ + │ ╰─────────────── unresolved + │ │ │ + │ ╰─────── unresolved + │ │ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.8.4-failure.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.8.4-failure.txt new file mode 100644 index 0000000000..4b6f9d15c3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.8.4-failure.txt @@ -0,0 +1,36 @@ +# 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:8:1] + │ + 8 │ type TopLevel is uint256; + │ ─────────────┬──────────── + │ ╰────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public pure returns (uint) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ TopLevel tl = TopLevel.wrap(20); + │ ────┬─── ─┬ ────┬─── ──┬─ + │ ╰──────────────────────── unresolved + │ │ │ │ + │ ╰────────────────── def: 3 + │ │ │ + │ ╰────────── unresolved + │ │ + │ ╰─── unresolved + 4 │ return TopLevel.unwrap(tl); + │ ────┬─── ───┬── ─┬ + │ ╰─────────────── unresolved + │ │ │ + │ ╰─────── unresolved + │ │ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.8.8-success.txt b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.8.8-success.txt new file mode 100644 index 0000000000..eb13b01d0b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/generated/0.8.8-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 │ function test() public pure returns (uint) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ TopLevel tl = TopLevel.wrap(20); + │ ────┬─── ─┬ ────┬─── ──┬─ + │ ╰──────────────────────── ref: 4 + │ │ │ │ + │ ╰────────────────── def: 3 + │ │ │ + │ ╰────────── ref: 4 + │ │ + │ ╰─── ref: built-in + 4 │ return TopLevel.unwrap(tl); + │ ────┬─── ───┬── ─┬ + │ ╰─────────────── ref: 4 + │ │ │ + │ ╰─────── ref: built-in + │ │ + │ ╰── ref: 3 + │ + 8 │ type TopLevel is uint256; + │ ────┬─── + │ ╰───── def: 4 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/input.sol b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/input.sol new file mode 100644 index 0000000000..46dbe68b66 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/user_types/top_level/input.sol @@ -0,0 +1,8 @@ +contract Test { + function test() public pure returns (uint) { + TopLevel tl = TopLevel.wrap(20); + return TopLevel.unwrap(tl); + } +} + +type TopLevel is uint256; From cd7eb08f7aca467ed5dbc6ac38de851eb9fdb84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 16 Dec 2024 19:19:47 -0500 Subject: [PATCH 04/16] Migrate binding assertions for constants, control and arrays to snapshots --- .../bindings_assertions/generated/arrays.rs | 20 ------ .../bindings_assertions/generated/control.rs | 50 --------------- .../src/bindings_assertions/generated/mod.rs | 3 - .../generated/constants.rs | 6 +- .../src/bindings_output/generated/control.rs | 15 +++++ .../src/bindings_output/generated/mod.rs | 1 + .../bindings_assertions/arrays/fixed.sol | 9 --- .../arrays/nested_custom.sol | 41 ------------ .../bindings_assertions/arrays/simple.sol | 15 ----- .../constants/top_level.sol | 27 -------- .../bindings_assertions/control/do_while.sol | 17 ----- .../control/for_empty_init_or_cond.sol | 24 ------- .../bindings_assertions/control/for_stmt.sol | 32 ---------- .../control/for_tuple_decon.sol | 17 ----- .../bindings_assertions/control/if_else.sol | 28 --------- .../control/return_stmt.sol | 8 --- .../bindings_assertions/control/try_stmt.sol | 28 --------- .../bindings_assertions/control/unchecked.sol | 12 ---- .../control/while_stmt.sol | 17 ----- .../in_contract/generated/0.4.11-success.txt | 63 +++++++++++++++++++ .../in_contract/generated/0.4.22-success.txt | 63 +++++++++++++++++++ .../in_contract/generated/0.8.27-success.txt | 63 +++++++++++++++++++ .../constants/in_contract/input.sol} | 11 ---- .../top_level/generated/0.4.11-failure.txt | 45 +++++++++++++ .../top_level/generated/0.4.22-failure.txt | 45 +++++++++++++ .../top_level/generated/0.6.0-failure.txt | 57 +++++++++++++++++ .../top_level/generated/0.7.1-failure.txt | 57 +++++++++++++++++ .../top_level/generated/0.7.4-success.txt | 63 +++++++++++++++++++ .../top_level/generated/0.8.27-success.txt | 63 +++++++++++++++++++ .../constants/top_level/input.sol | 13 ++++ .../do_while/generated/0.4.11-success.txt | 27 ++++++++ .../control/do_while/input.sol | 9 +++ .../return_stmt/generated/0.4.11-success.txt | 18 ++++++ .../control/return_stmt/input.sol | 6 ++ .../unchecked/generated/0.4.11-failure.txt | 33 ++++++++++ .../unchecked/generated/0.5.0-failure.txt | 30 +++++++++ .../unchecked/generated/0.5.3-failure.txt | 30 +++++++++ .../unchecked/generated/0.6.0-failure.txt | 30 +++++++++ .../unchecked/generated/0.7.0-failure.txt | 30 +++++++++ .../unchecked/generated/0.8.0-success.txt | 26 ++++++++ .../control/unchecked/input.sol | 6 ++ 41 files changed, 796 insertions(+), 362 deletions(-) delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/arrays.rs delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/control.rs rename crates/solidity/outputs/cargo/tests/src/{bindings_assertions => bindings_output}/generated/constants.rs (64%) delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/arrays/fixed.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/arrays/nested_custom.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/arrays/simple.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/constants/top_level.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/control/do_while.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/control/for_empty_init_or_cond.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/control/for_stmt.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/control/for_tuple_decon.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/control/if_else.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/control/return_stmt.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/control/try_stmt.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/control/unchecked.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/control/while_stmt.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/constants/in_contract/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/constants/in_contract/generated/0.4.22-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/constants/in_contract/generated/0.8.27-success.txt rename crates/solidity/testing/snapshots/{bindings_assertions/constants/simple.sol => bindings_output/constants/in_contract/input.sol} (52%) create mode 100644 crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.4.22-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.6.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.7.1-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.7.4-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.8.27-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/constants/top_level/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/control/do_while/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/control/do_while/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/control/return_stmt/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/control/return_stmt/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.5.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.5.3-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.6.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.7.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.8.0-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/control/unchecked/input.sol diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/arrays.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/arrays.rs deleted file mode 100644 index c907eafd7d..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/arrays.rs +++ /dev/null @@ -1,20 +0,0 @@ -// 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 fixed() -> Result<()> { - run("arrays", "fixed") -} - -#[test] -fn nested_custom() -> Result<()> { - run("arrays", "nested_custom") -} - -#[test] -fn simple() -> Result<()> { - run("arrays", "simple") -} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/control.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/control.rs deleted file mode 100644 index 79f1c04d03..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/control.rs +++ /dev/null @@ -1,50 +0,0 @@ -// 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 do_while() -> Result<()> { - run("control", "do_while") -} - -#[test] -fn for_empty_init_or_cond() -> Result<()> { - run("control", "for_empty_init_or_cond") -} - -#[test] -fn for_stmt() -> Result<()> { - run("control", "for_stmt") -} - -#[test] -fn for_tuple_decon() -> Result<()> { - run("control", "for_tuple_decon") -} - -#[test] -fn if_else() -> Result<()> { - run("control", "if_else") -} - -#[test] -fn return_stmt() -> Result<()> { - run("control", "return_stmt") -} - -#[test] -fn try_stmt() -> Result<()> { - run("control", "try_stmt") -} - -#[test] -fn unchecked() -> Result<()> { - run("control", "unchecked") -} - -#[test] -fn while_stmt() -> Result<()> { - run("control", "while_stmt") -} 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 50de0ca0cb..16b5755f1f 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 @@ -1,9 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -mod arrays; -mod constants; mod contracts; -mod control; mod errors; mod events; mod expressions; diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/constants.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/constants.rs similarity index 64% rename from crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/constants.rs rename to crates/solidity/outputs/cargo/tests/src/bindings_output/generated/constants.rs index d8138e78b7..af753b0a73 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/constants.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/constants.rs @@ -2,11 +2,11 @@ use anyhow::Result; -use crate::bindings_assertions::runner::run; +use crate::bindings_output::runner::run; #[test] -fn simple() -> Result<()> { - run("constants", "simple") +fn in_contract() -> Result<()> { + run("constants", "in_contract") } #[test] diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/control.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/control.rs index f673d69920..99891fea5b 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/control.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/control.rs @@ -4,6 +4,11 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn do_while() -> Result<()> { + run("control", "do_while") +} + #[test] fn emit_event() -> Result<()> { run("control", "emit_event") @@ -44,11 +49,21 @@ fn if_else() -> Result<()> { run("control", "if_else") } +#[test] +fn return_stmt() -> Result<()> { + run("control", "return_stmt") +} + #[test] fn try_stmt() -> Result<()> { run("control", "try_stmt") } +#[test] +fn unchecked() -> Result<()> { + run("control", "unchecked") +} + #[test] fn while_stmt() -> Result<()> { run("control", "while_stmt") 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 ebe2bbe3a0..be537f784a 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 @@ -2,6 +2,7 @@ mod arrays; mod built_ins; +mod constants; mod contracts; mod control; mod enums; diff --git a/crates/solidity/testing/snapshots/bindings_assertions/arrays/fixed.sol b/crates/solidity/testing/snapshots/bindings_assertions/arrays/fixed.sol deleted file mode 100644 index 5ce6c200c4..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/arrays/fixed.sol +++ /dev/null @@ -1,9 +0,0 @@ -contract Test { - function test() public { - uint[5] memory values; - values.pop(); - // ^ref:! -- fixed size arrays should not bind pop/push - values.push(1); - // ^ref:! -- fixed size arrays should not bind pop/push - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/arrays/nested_custom.sol b/crates/solidity/testing/snapshots/bindings_assertions/arrays/nested_custom.sol deleted file mode 100644 index b9d71162e7..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/arrays/nested_custom.sol +++ /dev/null @@ -1,41 +0,0 @@ -contract CustomArrays { - uint constant SIZE = 5; - // ^def:7 - - struct Value { - // ^def:1 - uint value; - // ^def:2 - } - - Value[][SIZE] values; - // ^def:3 - // ^ref:7 - //= 0.7.4) - assert(MY_UINT > 100); - // ^ref:! (< 0.7.4) - // ^ref:4 (>= 0.7.4) - require(msg.sender == MY_ADDRESS); - // ^ref:! (< 0.7.4) - // ^ref:3 (>= 0.7.4) - } -} - -enum Direction { NORTH, SOUTH, EAST, WEST } -// ^def:1 (>= 0.6.0) -// ^def:2 (>= 0.6.0) - -address constant MY_ADDRESS = 0x777788889999AaAAbBbbCcccddDdeeeEfFFfCcCc; -// ^def:3 (>= 0.7.4) -uint256 constant MY_UINT = 123; -// ^def:4 (>= 0.7.4) -Direction constant MY_DIRECTION = Direction.EAST; -// ^ref:2 (>= 0.7.4) -// ^ref:1 (>= 0.7.4) -// ^def:5 (>= 0.7.4) -//= 0.7.4) diff --git a/crates/solidity/testing/snapshots/bindings_assertions/control/do_while.sol b/crates/solidity/testing/snapshots/bindings_assertions/control/do_while.sol deleted file mode 100644 index ee52272f5d..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/control/do_while.sol +++ /dev/null @@ -1,17 +0,0 @@ -contract Test { - function test() public returns (int) { - int i = 1; - // ^def:1 - do { - int odd = i % 2; - // ^def:2 - // ^ref:1 - i *= 3; - //= 0.5.0) - // ^ref:2 (< 0.5.0) - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/control/for_empty_init_or_cond.sol b/crates/solidity/testing/snapshots/bindings_assertions/control/for_empty_init_or_cond.sol deleted file mode 100644 index a3553c8694..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/control/for_empty_init_or_cond.sol +++ /dev/null @@ -1,24 +0,0 @@ -contract Test { - function empty_init() public { - int i = 1; - // ^def:1 - int x = 0; - // ^def:2 - for (; i < 10; i++) { - // ^ref:1 - // ^ref:1 - x += i; - // 10) break; - // ^ref:3 - } - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/control/for_stmt.sol b/crates/solidity/testing/snapshots/bindings_assertions/control/for_stmt.sol deleted file mode 100644 index 1fb24752fe..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/control/for_stmt.sol +++ /dev/null @@ -1,32 +0,0 @@ -contract Test { - function simple_loop() public returns (int) { - int x = 1; - // ^def:1 - for (int i = 0; i < 10; i++) { - // ^def:2 - // ^ref:2 - // ^ref:2 - x = x * 2; - //= 0.5.0) - // ^ref:2 (< 0.5.0) - } - - function loop_with_outside_var() public { - int z; - // ^def:3 - int w = 0; - // ^def:4 - for ( z = 10; z > 0; w += z) { - //^ref:3 - // ^ref:3 - // ^ref:4 - // ^ref:3 - z--; - // 1) { - //= 0.5.0) - // ^ref:4 (< 0.5.0) - // ^ref:! (>= 0.5.0) - // ^ref:3 (< 0.5.0) - // ^ref:2 - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/control/return_stmt.sol b/crates/solidity/testing/snapshots/bindings_assertions/control/return_stmt.sol deleted file mode 100644 index 532c19580f..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/control/return_stmt.sol +++ /dev/null @@ -1,8 +0,0 @@ -contract Test { - function test() returns (int) { - int x = 1; - // ^def:1 - return x; - // ^ref:1 - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/control/try_stmt.sol b/crates/solidity/testing/snapshots/bindings_assertions/control/try_stmt.sol deleted file mode 100644 index f28a2b0dec..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/control/try_stmt.sol +++ /dev/null @@ -1,28 +0,0 @@ -interface DataFeed { function getData(address token) external returns (uint value); } - -contract FeedConsumer { - DataFeed feed; - // ^def:1 - uint errorCount; - // ^def:2 - function rate(address token) public returns (uint value, bool success) { - // ^def:5 - // ^def:4 - // ^def:3 - try feed.getData(token) returns (uint v) { - // ^def:6 - // ^ref:3 - //= 0.8.0) - // ^ref:3 (>= 0.8.0) - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/control/while_stmt.sol b/crates/solidity/testing/snapshots/bindings_assertions/control/while_stmt.sol deleted file mode 100644 index 102037f5a7..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/control/while_stmt.sol +++ /dev/null @@ -1,17 +0,0 @@ -contract Test { - function test() public returns (int) { - int i = 1; - // ^def:1 - while (i < 100) { - // ^ref:1 - int odd = i % 2; - // ^def:2 - // ^ref:1 - i *= 3; - //= 0.5.0) - // ^ref:2 (< 0.5.0) - } -} diff --git a/crates/solidity/testing/snapshots/bindings_output/constants/in_contract/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/constants/in_contract/generated/0.4.11-success.txt new file mode 100644 index 0000000000..2468372adb --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/constants/in_contract/generated/0.4.11-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 Constants { + │ ────┬──── + │ ╰────── def: 1 + 2 │ enum Direction { NORTH, SOUTH, EAST, WEST } + │ ────┬──── ──┬── ──┬── ──┬─ ──┬─ + │ ╰───────────────────────────────── def: 2 + │ │ │ │ │ + │ ╰─────────────────────── def: 3 + │ │ │ │ + │ ╰──────────────── def: 4 + │ │ │ + │ ╰───────── def: 5 + │ │ + │ ╰─── def: 6 + │ + 4 │ address public constant MY_ADDRESS = 0x777788889999AaAAbBbbCcccddDdeeeEfFFfCcCc; + │ ─────┬──── + │ ╰────── def: 7 + 5 │ uint256 public constant MY_UINT = 123; + │ ───┬─── + │ ╰───── def: 8 + 6 │ Direction public constant MY_DIRECTION = Direction.EAST; + │ ────┬──── ──────┬───── ────┬──── ──┬─ + │ ╰──────────────────────────────────────────────────── ref: 2 + │ │ │ │ + │ ╰──────────────────────── def: 9 + │ │ │ + │ ╰─────────── ref: 2 + │ │ + │ ╰─── ref: 5 + │ + 8 │ function test() public { + │ ──┬─ + │ ╰─── def: 10 + 9 │ assert(MY_DIRECTION != Direction.NORTH); + │ ───┬── ──────┬───── ────┬──── ──┬── + │ ╰──────────────────────────────────── ref: built-in + │ │ │ │ + │ ╰────────────────────────── ref: 9 + │ │ │ + │ ╰──────────── ref: 2 + │ │ + │ ╰──── ref: 3 + 10 │ assert(MY_UINT > 100); + │ ───┬── ───┬─── + │ ╰──────────── ref: built-in + │ │ + │ ╰───── ref: 8 + 11 │ require(msg.sender == MY_ADDRESS); + │ ───┬─── ─┬─ ───┬── ─────┬──── + │ ╰────────────────────────────── ref: built-in + │ │ │ │ + │ ╰──────────────────────── ref: built-in + │ │ │ + │ ╰────────────────── ref: built-in + │ │ + │ ╰────── ref: 7 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/constants/in_contract/generated/0.4.22-success.txt b/crates/solidity/testing/snapshots/bindings_output/constants/in_contract/generated/0.4.22-success.txt new file mode 100644 index 0000000000..2b55a5f4b6 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/constants/in_contract/generated/0.4.22-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 Constants { + │ ────┬──── + │ ╰────── def: 1 + 2 │ enum Direction { NORTH, SOUTH, EAST, WEST } + │ ────┬──── ──┬── ──┬── ──┬─ ──┬─ + │ ╰───────────────────────────────── def: 2 + │ │ │ │ │ + │ ╰─────────────────────── def: 3 + │ │ │ │ + │ ╰──────────────── def: 4 + │ │ │ + │ ╰───────── def: 5 + │ │ + │ ╰─── def: 6 + │ + 4 │ address public constant MY_ADDRESS = 0x777788889999AaAAbBbbCcccddDdeeeEfFFfCcCc; + │ ─────┬──── + │ ╰────── def: 7 + 5 │ uint256 public constant MY_UINT = 123; + │ ───┬─── + │ ╰───── def: 8 + 6 │ Direction public constant MY_DIRECTION = Direction.EAST; + │ ────┬──── ──────┬───── ────┬──── ──┬─ + │ ╰──────────────────────────────────────────────────── ref: 2 + │ │ │ │ + │ ╰──────────────────────── def: 9 + │ │ │ + │ ╰─────────── ref: 2 + │ │ + │ ╰─── ref: 5 + │ + 8 │ function test() public { + │ ──┬─ + │ ╰─── def: 10 + 9 │ assert(MY_DIRECTION != Direction.NORTH); + │ ───┬── ──────┬───── ────┬──── ──┬── + │ ╰──────────────────────────────────── ref: built-in + │ │ │ │ + │ ╰────────────────────────── ref: 9 + │ │ │ + │ ╰──────────── ref: 2 + │ │ + │ ╰──── ref: 3 + 10 │ assert(MY_UINT > 100); + │ ───┬── ───┬─── + │ ╰──────────── ref: built-in + │ │ + │ ╰───── ref: 8 + 11 │ require(msg.sender == MY_ADDRESS); + │ ───┬─── ─┬─ ───┬── ─────┬──── + │ ╰────────────────────────────── refs: built-in, built-in + │ │ │ │ + │ ╰──────────────────────── ref: built-in + │ │ │ + │ ╰────────────────── ref: built-in + │ │ + │ ╰────── ref: 7 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/constants/in_contract/generated/0.8.27-success.txt b/crates/solidity/testing/snapshots/bindings_output/constants/in_contract/generated/0.8.27-success.txt new file mode 100644 index 0000000000..3276c8799b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/constants/in_contract/generated/0.8.27-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 Constants { + │ ────┬──── + │ ╰────── def: 1 + 2 │ enum Direction { NORTH, SOUTH, EAST, WEST } + │ ────┬──── ──┬── ──┬── ──┬─ ──┬─ + │ ╰───────────────────────────────── def: 2 + │ │ │ │ │ + │ ╰─────────────────────── def: 3 + │ │ │ │ + │ ╰──────────────── def: 4 + │ │ │ + │ ╰───────── def: 5 + │ │ + │ ╰─── def: 6 + │ + 4 │ address public constant MY_ADDRESS = 0x777788889999AaAAbBbbCcccddDdeeeEfFFfCcCc; + │ ─────┬──── + │ ╰────── def: 7 + 5 │ uint256 public constant MY_UINT = 123; + │ ───┬─── + │ ╰───── def: 8 + 6 │ Direction public constant MY_DIRECTION = Direction.EAST; + │ ────┬──── ──────┬───── ────┬──── ──┬─ + │ ╰──────────────────────────────────────────────────── ref: 2 + │ │ │ │ + │ ╰──────────────────────── def: 9 + │ │ │ + │ ╰─────────── ref: 2 + │ │ + │ ╰─── ref: 5 + │ + 8 │ function test() public { + │ ──┬─ + │ ╰─── def: 10 + 9 │ assert(MY_DIRECTION != Direction.NORTH); + │ ───┬── ──────┬───── ────┬──── ──┬── + │ ╰──────────────────────────────────── ref: built-in + │ │ │ │ + │ ╰────────────────────────── ref: 9 + │ │ │ + │ ╰──────────── ref: 2 + │ │ + │ ╰──── ref: 3 + 10 │ assert(MY_UINT > 100); + │ ───┬── ───┬─── + │ ╰──────────── ref: built-in + │ │ + │ ╰───── ref: 8 + 11 │ require(msg.sender == MY_ADDRESS); + │ ───┬─── ─┬─ ───┬── ─────┬──── + │ ╰────────────────────────────── refs: built-in, built-in, built-in + │ │ │ │ + │ ╰──────────────────────── ref: built-in + │ │ │ + │ ╰────────────────── ref: built-in + │ │ + │ ╰────── ref: 7 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_assertions/constants/simple.sol b/crates/solidity/testing/snapshots/bindings_output/constants/in_contract/input.sol similarity index 52% rename from crates/solidity/testing/snapshots/bindings_assertions/constants/simple.sol rename to crates/solidity/testing/snapshots/bindings_output/constants/in_contract/input.sol index 52d1f77830..7b2f2cec69 100644 --- a/crates/solidity/testing/snapshots/bindings_assertions/constants/simple.sol +++ b/crates/solidity/testing/snapshots/bindings_output/constants/in_contract/input.sol @@ -1,24 +1,13 @@ contract Constants { enum Direction { NORTH, SOUTH, EAST, WEST } - // ^def:1 - // ^def:2 address public constant MY_ADDRESS = 0x777788889999AaAAbBbbCcccddDdeeeEfFFfCcCc; - // ^def:3 uint256 public constant MY_UINT = 123; - // ^def:4 Direction public constant MY_DIRECTION = Direction.EAST; - // ^ref:2 - // ^ref:1 - // ^def:5 - // 100); - // ^ref:4 require(msg.sender == MY_ADDRESS); - // ^ref:3 } } diff --git a/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..7de3ee329c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.4.11-failure.txt @@ -0,0 +1,45 @@ +# 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:9:1] + │ + 9 │ ╭─▶ enum Direction { NORTH, SOUTH, EAST, WEST } + ┆ ┆ + 13 │ ├─▶ Direction constant MY_DIRECTION = Direction.EAST; + │ │ + │ ╰─────────────────────────────────────────────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Constants { + │ ────┬──── + │ ╰────── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + 3 │ assert(MY_DIRECTION != Direction.NORTH); + │ ───┬── ──────┬───── ────┬──── ──┬── + │ ╰──────────────────────────────────── ref: built-in + │ │ │ │ + │ ╰────────────────────────── unresolved + │ │ │ + │ ╰──────────── unresolved + │ │ + │ ╰──── unresolved + 4 │ assert(MY_UINT > 100); + │ ───┬── ───┬─── + │ ╰──────────── ref: built-in + │ │ + │ ╰───── unresolved + 5 │ require(msg.sender == MY_ADDRESS); + │ ───┬─── ─┬─ ───┬── ─────┬──── + │ ╰────────────────────────────── ref: built-in + │ │ │ │ + │ ╰──────────────────────── ref: built-in + │ │ │ + │ ╰────────────────── ref: built-in + │ │ + │ ╰────── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.4.22-failure.txt b/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.4.22-failure.txt new file mode 100644 index 0000000000..c828e4f49a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.4.22-failure.txt @@ -0,0 +1,45 @@ +# 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:9:1] + │ + 9 │ ╭─▶ enum Direction { NORTH, SOUTH, EAST, WEST } + ┆ ┆ + 13 │ ├─▶ Direction constant MY_DIRECTION = Direction.EAST; + │ │ + │ ╰─────────────────────────────────────────────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Constants { + │ ────┬──── + │ ╰────── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + 3 │ assert(MY_DIRECTION != Direction.NORTH); + │ ───┬── ──────┬───── ────┬──── ──┬── + │ ╰──────────────────────────────────── ref: built-in + │ │ │ │ + │ ╰────────────────────────── unresolved + │ │ │ + │ ╰──────────── unresolved + │ │ + │ ╰──── unresolved + 4 │ assert(MY_UINT > 100); + │ ───┬── ───┬─── + │ ╰──────────── ref: built-in + │ │ + │ ╰───── unresolved + 5 │ require(msg.sender == MY_ADDRESS); + │ ───┬─── ─┬─ ───┬── ─────┬──── + │ ╰────────────────────────────── refs: built-in, built-in + │ │ │ │ + │ ╰──────────────────────── ref: built-in + │ │ │ + │ ╰────────────────── ref: built-in + │ │ + │ ╰────── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..fedba1abe5 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.6.0-failure.txt @@ -0,0 +1,57 @@ +# 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:11:1] + │ + 11 │ ╭─▶ address constant MY_ADDRESS = 0x777788889999AaAAbBbbCcccddDdeeeEfFFfCcCc; + ┆ ┆ + 13 │ ├─▶ Direction constant MY_DIRECTION = Direction.EAST; + │ │ + │ ╰─────────────────────────────────────────────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Constants { + │ ────┬──── + │ ╰────── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + 3 │ assert(MY_DIRECTION != Direction.NORTH); + │ ───┬── ──────┬───── ────┬──── ──┬── + │ ╰──────────────────────────────────── ref: built-in + │ │ │ │ + │ ╰────────────────────────── unresolved + │ │ │ + │ ╰──────────── ref: 3 + │ │ + │ ╰──── ref: 4 + 4 │ assert(MY_UINT > 100); + │ ───┬── ───┬─── + │ ╰──────────── ref: built-in + │ │ + │ ╰───── unresolved + 5 │ require(msg.sender == MY_ADDRESS); + │ ───┬─── ─┬─ ───┬── ─────┬──── + │ ╰────────────────────────────── refs: built-in, built-in + │ │ │ │ + │ ╰──────────────────────── ref: built-in + │ │ │ + │ ╰────────────────── ref: built-in + │ │ + │ ╰────── unresolved + │ + 9 │ enum Direction { NORTH, SOUTH, EAST, WEST } + │ ────┬──── ──┬── ──┬── ──┬─ ──┬─ + │ ╰───────────────────────────────── def: 3 + │ │ │ │ │ + │ ╰─────────────────────── def: 4 + │ │ │ │ + │ ╰──────────────── def: 5 + │ │ │ + │ ╰───────── def: 6 + │ │ + │ ╰─── def: 7 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.7.1-failure.txt b/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.7.1-failure.txt new file mode 100644 index 0000000000..2fd1fb833a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.7.1-failure.txt @@ -0,0 +1,57 @@ +# 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:11:1] + │ + 11 │ ╭─▶ address constant MY_ADDRESS = 0x777788889999AaAAbBbbCcccddDdeeeEfFFfCcCc; + ┆ ┆ + 13 │ ├─▶ Direction constant MY_DIRECTION = Direction.EAST; + │ │ + │ ╰─────────────────────────────────────────────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Constants { + │ ────┬──── + │ ╰────── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + 3 │ assert(MY_DIRECTION != Direction.NORTH); + │ ───┬── ──────┬───── ────┬──── ──┬── + │ ╰──────────────────────────────────── ref: built-in + │ │ │ │ + │ ╰────────────────────────── unresolved + │ │ │ + │ ╰──────────── ref: 3 + │ │ + │ ╰──── ref: 4 + 4 │ assert(MY_UINT > 100); + │ ───┬── ───┬─── + │ ╰──────────── ref: built-in + │ │ + │ ╰───── unresolved + 5 │ require(msg.sender == MY_ADDRESS); + │ ───┬─── ─┬─ ───┬── ─────┬──── + │ ╰────────────────────────────── refs: built-in, built-in + │ │ │ │ + │ ╰──────────────────────── ref: built-in + │ │ │ + │ ╰────────────────── ref: built-in + │ │ + │ ╰────── unresolved + │ + 9 │ enum Direction { NORTH, SOUTH, EAST, WEST } + │ ────┬──── ──┬── ──┬── ──┬─ ──┬─ + │ ╰───────────────────────────────── def: 3 + │ │ │ │ │ + │ ╰─────────────────────── def: 4 + │ │ │ │ + │ ╰──────────────── def: 5 + │ │ │ + │ ╰───────── def: 6 + │ │ + │ ╰─── def: 7 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.7.4-success.txt b/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.7.4-success.txt new file mode 100644 index 0000000000..6340a38142 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/constants/top_level/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 Constants { + │ ────┬──── + │ ╰────── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + 3 │ assert(MY_DIRECTION != Direction.NORTH); + │ ───┬── ──────┬───── ────┬──── ──┬── + │ ╰──────────────────────────────────── ref: built-in + │ │ │ │ + │ ╰────────────────────────── ref: 10 + │ │ │ + │ ╰──────────── ref: 3 + │ │ + │ ╰──── ref: 4 + 4 │ assert(MY_UINT > 100); + │ ───┬── ───┬─── + │ ╰──────────── ref: built-in + │ │ + │ ╰───── ref: 9 + 5 │ require(msg.sender == MY_ADDRESS); + │ ───┬─── ─┬─ ───┬── ─────┬──── + │ ╰────────────────────────────── refs: built-in, built-in + │ │ │ │ + │ ╰──────────────────────── ref: built-in + │ │ │ + │ ╰────────────────── ref: built-in + │ │ + │ ╰────── ref: 8 + │ + 9 │ enum Direction { NORTH, SOUTH, EAST, WEST } + │ ────┬──── ──┬── ──┬── ──┬─ ──┬─ + │ ╰───────────────────────────────── def: 3 + │ │ │ │ │ + │ ╰─────────────────────── def: 4 + │ │ │ │ + │ ╰──────────────── def: 5 + │ │ │ + │ ╰───────── def: 6 + │ │ + │ ╰─── def: 7 + │ + 11 │ address constant MY_ADDRESS = 0x777788889999AaAAbBbbCcccddDdeeeEfFFfCcCc; + │ ─────┬──── + │ ╰────── def: 8 + 12 │ uint256 constant MY_UINT = 123; + │ ───┬─── + │ ╰───── def: 9 + 13 │ Direction constant MY_DIRECTION = Direction.EAST; + │ ────┬──── ──────┬───── ────┬──── ──┬─ + │ ╰───────────────────────────────────────────── ref: 3 + │ │ │ │ + │ ╰──────────────────────── def: 10 + │ │ │ + │ ╰─────────── ref: 3 + │ │ + │ ╰─── ref: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.8.27-success.txt b/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.8.27-success.txt new file mode 100644 index 0000000000..9c06258e2a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/constants/top_level/generated/0.8.27-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 Constants { + │ ────┬──── + │ ╰────── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + 3 │ assert(MY_DIRECTION != Direction.NORTH); + │ ───┬── ──────┬───── ────┬──── ──┬── + │ ╰──────────────────────────────────── ref: built-in + │ │ │ │ + │ ╰────────────────────────── ref: 10 + │ │ │ + │ ╰──────────── ref: 3 + │ │ + │ ╰──── ref: 4 + 4 │ assert(MY_UINT > 100); + │ ───┬── ───┬─── + │ ╰──────────── ref: built-in + │ │ + │ ╰───── ref: 9 + 5 │ require(msg.sender == MY_ADDRESS); + │ ───┬─── ─┬─ ───┬── ─────┬──── + │ ╰────────────────────────────── refs: built-in, built-in, built-in + │ │ │ │ + │ ╰──────────────────────── ref: built-in + │ │ │ + │ ╰────────────────── ref: built-in + │ │ + │ ╰────── ref: 8 + │ + 9 │ enum Direction { NORTH, SOUTH, EAST, WEST } + │ ────┬──── ──┬── ──┬── ──┬─ ──┬─ + │ ╰───────────────────────────────── def: 3 + │ │ │ │ │ + │ ╰─────────────────────── def: 4 + │ │ │ │ + │ ╰──────────────── def: 5 + │ │ │ + │ ╰───────── def: 6 + │ │ + │ ╰─── def: 7 + │ + 11 │ address constant MY_ADDRESS = 0x777788889999AaAAbBbbCcccddDdeeeEfFFfCcCc; + │ ─────┬──── + │ ╰────── def: 8 + 12 │ uint256 constant MY_UINT = 123; + │ ───┬─── + │ ╰───── def: 9 + 13 │ Direction constant MY_DIRECTION = Direction.EAST; + │ ────┬──── ──────┬───── ────┬──── ──┬─ + │ ╰───────────────────────────────────────────── ref: 3 + │ │ │ │ + │ ╰──────────────────────── def: 10 + │ │ │ + │ ╰─────────── ref: 3 + │ │ + │ ╰─── ref: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/constants/top_level/input.sol b/crates/solidity/testing/snapshots/bindings_output/constants/top_level/input.sol new file mode 100644 index 0000000000..c21197a9fa --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/constants/top_level/input.sol @@ -0,0 +1,13 @@ +contract Constants { + function test() public { + assert(MY_DIRECTION != Direction.NORTH); + assert(MY_UINT > 100); + require(msg.sender == MY_ADDRESS); + } +} + +enum Direction { NORTH, SOUTH, EAST, WEST } + +address constant MY_ADDRESS = 0x777788889999AaAAbBbbCcccddDdeeeEfFFfCcCc; +uint256 constant MY_UINT = 123; +Direction constant MY_DIRECTION = Direction.EAST; diff --git a/crates/solidity/testing/snapshots/bindings_output/control/do_while/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/control/do_while/generated/0.4.11-success.txt new file mode 100644 index 0000000000..8bce407887 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/control/do_while/generated/0.4.11-success.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 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + 3 │ int i = 1; + │ ┬ + │ ╰── def: 3 + │ + 5 │ int odd = i % 2; + │ ─┬─ ┬ + │ ╰─────── def: 4 + │ │ + │ ╰── ref: 3 + 6 │ i *= 3; + │ ┬ + │ ╰── ref: 3 + 7 │ } while (i < 100); + │ ┬ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/control/do_while/input.sol b/crates/solidity/testing/snapshots/bindings_output/control/do_while/input.sol new file mode 100644 index 0000000000..01b7f70a20 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/control/do_while/input.sol @@ -0,0 +1,9 @@ +contract Test { + function test() public { + int i = 1; + do { + int odd = i % 2; + i *= 3; + } while (i < 100); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/control/return_stmt/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/control/return_stmt/generated/0.4.11-success.txt new file mode 100644 index 0000000000..681d3679f8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/control/return_stmt/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 returns (int) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ int x = 1; + │ ┬ + │ ╰── def: 3 + 4 │ return x; + │ ┬ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/control/return_stmt/input.sol b/crates/solidity/testing/snapshots/bindings_output/control/return_stmt/input.sol new file mode 100644 index 0000000000..bc65797c17 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/control/return_stmt/input.sol @@ -0,0 +1,6 @@ +contract Test { + function test() public returns (int) { + int x = 1; + return x; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..f98332edd7 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.4.11-failure.txt @@ -0,0 +1,33 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected Identifier or MemoryKeyword or StorageKeyword. + ╭─[input.sol:4:19] + │ + 4 │ ╭─▶ unchecked { return c - b; } + 5 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function sub(uint a, uint b) public returns (uint) { + │ ─┬─ ┬ ┬ + │ ╰────────────────── def: 2 + │ │ │ + │ ╰────────── def: 3 + │ │ + │ ╰── def: 4 + 3 │ uint c = a; + │ ┬ ┬ + │ ╰────── def: 5 + │ │ + │ ╰── ref: 3 + 4 │ unchecked { return c - b; } + │ ────┬──── + │ ╰────── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.5.0-failure.txt new file mode 100644 index 0000000000..90ae120d31 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.5.0-failure.txt @@ -0,0 +1,30 @@ +# 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 SuperKeyword or ThisKeyword or TrueKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ unchecked { return c - b; } + 5 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function sub(uint a, uint b) public returns (uint) { + │ ─┬─ ┬ ┬ + │ ╰────────────────── def: 2 + │ │ │ + │ ╰────────── def: 3 + │ │ + │ ╰── def: 4 + 3 │ uint c = a; + │ ┬ ┬ + │ ╰────── def: 5 + │ │ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.5.3-failure.txt b/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.5.3-failure.txt new file mode 100644 index 0000000000..b0c56b5bb3 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.5.3-failure.txt @@ -0,0 +1,30 @@ +# 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 SuperKeyword or ThisKeyword or TrueKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ unchecked { return c - b; } + 5 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function sub(uint a, uint b) public returns (uint) { + │ ─┬─ ┬ ┬ + │ ╰────────────────── def: 2 + │ │ │ + │ ╰────────── def: 3 + │ │ + │ ╰── def: 4 + 3 │ uint c = a; + │ ┬ ┬ + │ ╰────── def: 5 + │ │ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..613f4dd3fd --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.6.0-failure.txt @@ -0,0 +1,30 @@ +# 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 SuperKeyword or ThisKeyword or TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ unchecked { return c - b; } + 5 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function sub(uint a, uint b) public returns (uint) { + │ ─┬─ ┬ ┬ + │ ╰────────────────── def: 2 + │ │ │ + │ ╰────────── def: 3 + │ │ + │ ╰── def: 4 + 3 │ uint c = a; + │ ┬ ┬ + │ ╰────── def: 5 + │ │ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.7.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.7.0-failure.txt new file mode 100644 index 0000000000..402ca9c862 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.7.0-failure.txt @@ -0,0 +1,30 @@ +# 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 SuperKeyword or ThisKeyword or TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword. + ╭─[input.sol:4:9] + │ + 4 │ ╭─▶ unchecked { return c - b; } + 5 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function sub(uint a, uint b) public returns (uint) { + │ ─┬─ ┬ ┬ + │ ╰────────────────── def: 2 + │ │ │ + │ ╰────────── def: 3 + │ │ + │ ╰── def: 4 + 3 │ uint c = a; + │ ┬ ┬ + │ ╰────── def: 5 + │ │ + │ ╰── ref: 3 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.8.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.8.0-success.txt new file mode 100644 index 0000000000..7d533c9776 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/control/unchecked/generated/0.8.0-success.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 │ function sub(uint a, uint b) public returns (uint) { + │ ─┬─ ┬ ┬ + │ ╰────────────────── def: 2 + │ │ │ + │ ╰────────── def: 3 + │ │ + │ ╰── def: 4 + 3 │ uint c = a; + │ ┬ ┬ + │ ╰────── def: 5 + │ │ + │ ╰── ref: 3 + 4 │ unchecked { return c - b; } + │ ┬ ┬ + │ ╰────── ref: 5 + │ │ + │ ╰── ref: 4 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/control/unchecked/input.sol b/crates/solidity/testing/snapshots/bindings_output/control/unchecked/input.sol new file mode 100644 index 0000000000..185af02dfe --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/control/unchecked/input.sol @@ -0,0 +1,6 @@ +contract Test { + function sub(uint a, uint b) public returns (uint) { + uint c = a; + unchecked { return c - b; } + } +} From ffc1c194dea1382c8b7b9c86bd597c296fe70ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 16 Dec 2024 19:29:20 -0500 Subject: [PATCH 05/16] Migrate events and errors binding assertions tests to snapshots --- .../bindings_assertions/generated/errors.rs | 20 ----- .../bindings_assertions/generated/events.rs | 20 ----- .../src/bindings_assertions/generated/mod.rs | 2 - .../src/bindings_output/generated/errors.rs | 10 +++ .../src/bindings_output/generated/events.rs | 10 +++ .../bindings_assertions/errors/typed_args.sol | 21 ------ .../bindings_assertions/events/emit_stmt.sol | 23 ------ .../bindings_assertions/events/named_args.sol | 18 ----- .../bindings_assertions/events/typed_args.sol | 22 ------ .../named_args/generated/0.4.11-failure.txt | 49 +++++++++++++ .../named_args/generated/0.4.22-failure.txt | 49 +++++++++++++ .../named_args/generated/0.8.4-success.txt | 44 +++++++++++ .../errors/named_args/input.sol} | 6 -- .../revert_stmt/generated/0.4.11-failure.txt | 73 +++++++++++++++++++ .../revert_stmt/generated/0.4.22-failure.txt | 73 +++++++++++++++++++ .../revert_stmt/generated/0.8.4-success.txt | 42 +++++++++++ .../errors/revert_stmt/input.sol} | 8 -- .../emit_stmt/generated/0.4.11-failure.txt | 56 ++++++++++++++ .../emit_stmt/generated/0.4.21-success.txt | 43 +++++++++++ .../events/emit_stmt/input.sol | 14 ++++ .../named_args/generated/0.4.11-failure.txt | 45 ++++++++++++ .../named_args/generated/0.4.21-success.txt | 43 +++++++++++ .../events/named_args/input.sol | 12 +++ 23 files changed, 563 insertions(+), 140 deletions(-) delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/errors.rs delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/events.rs delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/errors/typed_args.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/events/emit_stmt.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/events/named_args.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/events/typed_args.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/errors/named_args/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/errors/named_args/generated/0.4.22-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/errors/named_args/generated/0.8.4-success.txt rename crates/solidity/testing/snapshots/{bindings_assertions/errors/named_args.sol => bindings_output/errors/named_args/input.sol} (54%) create mode 100644 crates/solidity/testing/snapshots/bindings_output/errors/revert_stmt/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/errors/revert_stmt/generated/0.4.22-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/errors/revert_stmt/generated/0.8.4-success.txt rename crates/solidity/testing/snapshots/{bindings_assertions/errors/revert_stmt.sol => bindings_output/errors/revert_stmt/input.sol} (55%) create mode 100644 crates/solidity/testing/snapshots/bindings_output/events/emit_stmt/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/events/emit_stmt/generated/0.4.21-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/events/emit_stmt/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/events/named_args/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/events/named_args/generated/0.4.21-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/events/named_args/input.sol diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/errors.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/errors.rs deleted file mode 100644 index 2cdd2feae0..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/errors.rs +++ /dev/null @@ -1,20 +0,0 @@ -// 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 named_args() -> Result<()> { - run("errors", "named_args") -} - -#[test] -fn revert_stmt() -> Result<()> { - run("errors", "revert_stmt") -} - -#[test] -fn typed_args() -> Result<()> { - run("errors", "typed_args") -} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/events.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/events.rs deleted file mode 100644 index 07b975b280..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/events.rs +++ /dev/null @@ -1,20 +0,0 @@ -// 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 emit_stmt() -> Result<()> { - run("events", "emit_stmt") -} - -#[test] -fn named_args() -> Result<()> { - run("events", "named_args") -} - -#[test] -fn typed_args() -> Result<()> { - run("events", "typed_args") -} 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 16b5755f1f..54c0f14ba4 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 @@ -1,8 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. mod contracts; -mod errors; -mod events; mod expressions; mod function_types; mod functions; 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 dc6cfdeec4..8bb66f3b7d 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 @@ -9,6 +9,16 @@ fn custom_types() -> Result<()> { run("errors", "custom_types") } +#[test] +fn named_args() -> Result<()> { + run("errors", "named_args") +} + +#[test] +fn revert_stmt() -> Result<()> { + run("errors", "revert_stmt") +} + #[test] fn selector() -> Result<()> { run("errors", "selector") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/events.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/events.rs index 5e8a63f2a5..5acb97331d 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/events.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/events.rs @@ -8,3 +8,13 @@ use crate::bindings_output::runner::run; fn custom_types() -> Result<()> { run("events", "custom_types") } + +#[test] +fn emit_stmt() -> Result<()> { + run("events", "emit_stmt") +} + +#[test] +fn named_args() -> Result<()> { + run("events", "named_args") +} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/errors/typed_args.sol b/crates/solidity/testing/snapshots/bindings_assertions/errors/typed_args.sol deleted file mode 100644 index e4ed8b8c0f..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/errors/typed_args.sol +++ /dev/null @@ -1,21 +0,0 @@ -contract Test { - enum Cause { - //^def:1 - InsuficientFunds, - NotAuthorized, - //= 0.8.4) - // ^ref:1 (>= 0.8.4) - // ^ref:3 (>= 0.8.4) - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/events/emit_stmt.sol b/crates/solidity/testing/snapshots/bindings_assertions/events/emit_stmt.sol deleted file mode 100644 index 6a0cf6be32..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/events/emit_stmt.sol +++ /dev/null @@ -1,23 +0,0 @@ -contract Test { - event TestEvent(int id); - // ^def:1 - - function test_emit() public { - int x = 1; - // ^def:2 - - emit TestEvent(x); - // ^ref:2 (>= 0.4.21) - // ^ref:1 (>= 0.4.21) - emit Utils.Debug(x); - // ^ref:2 (>= 0.4.21) - // ^ref:4 (>= 0.4.21) - // ^ref:3 (>= 0.4.21) - } -} - -library Utils { - // ^def:3 - event Debug(int subject); - // ^def:4 -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/events/named_args.sol b/crates/solidity/testing/snapshots/bindings_assertions/events/named_args.sol deleted file mode 100644 index d50ec37a5f..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/events/named_args.sol +++ /dev/null @@ -1,18 +0,0 @@ -contract Test { - enum Severity { Info, Error } - // ^def:3 - - event Log ( - Severity level, - // ^def:1 - string message - // ^def:2 - ); - - function test() { - emit Log({message: "testing", level: Severity.Info}); - // ^ref:3 (>= 0.4.21) - // ^ref:1 (>= 0.4.21) - // ^ref:2 (>= 0.4.21) - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/events/typed_args.sol b/crates/solidity/testing/snapshots/bindings_assertions/events/typed_args.sol deleted file mode 100644 index af8d1f0ecb..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/events/typed_args.sol +++ /dev/null @@ -1,22 +0,0 @@ -contract Test { - enum Severity { - //^def:1 - Info, - //= 0.4.21) - // ^ref:1 (>= 0.4.21) - // ^ref:2 (>= 0.4.21) - } -} diff --git a/crates/solidity/testing/snapshots/bindings_output/errors/named_args/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/errors/named_args/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..d3f7313eda --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/errors/named_args/generated/0.4.11-failure.txt @@ -0,0 +1,49 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected Equal or Semicolon. + ╭─[input.sol:3:19] + │ + 3 │ ╭─▶ error Failure ( + ┆ ┆ + 6 │ ├─▶ ); + │ │ + │ ╰──────────── Error occurred here. +───╯ +Error: Expected Equal or Semicolon. + ╭─[input.sol:8:23] + │ + 8 │ revert Failure({cause: Cause.NotAuthorized, details: "not owner"}); + │ ──────────────────────────┬───────────────────────── + │ ╰─────────────────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ enum Cause { InsuficientFunds, NotAuthorized, InvalidDate } + │ ──┬── ────────┬─────── ──────┬────── ─────┬───── + │ ╰─────────────────────────────────────────────────── def: 2 + │ │ │ │ + │ ╰───────────────────────────────────── def: 3 + │ │ │ + │ ╰───────────────────── def: 4 + │ │ + │ ╰─────── def: 5 + 3 │ error Failure ( + │ ──┬── ───┬─── + │ ╰──────────── unresolved + │ │ + │ ╰───── def: 6 + │ + 7 │ function test() public { + │ ──┬─ + │ ╰─── def: 7 + 8 │ revert Failure({cause: Cause.NotAuthorized, details: "not owner"}); + │ ───┬── ───┬─── + │ ╰──────────── ref: built-in + │ │ + │ ╰───── def: 8 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/errors/named_args/generated/0.4.22-failure.txt b/crates/solidity/testing/snapshots/bindings_output/errors/named_args/generated/0.4.22-failure.txt new file mode 100644 index 0000000000..130a241a19 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/errors/named_args/generated/0.4.22-failure.txt @@ -0,0 +1,49 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected Equal or Semicolon. + ╭─[input.sol:3:19] + │ + 3 │ ╭─▶ error Failure ( + ┆ ┆ + 6 │ ├─▶ ); + │ │ + │ ╰──────────── Error occurred here. +───╯ +Error: Expected Equal or Semicolon. + ╭─[input.sol:8:23] + │ + 8 │ revert Failure({cause: Cause.NotAuthorized, details: "not owner"}); + │ ──────────────────────────┬───────────────────────── + │ ╰─────────────────────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ enum Cause { InsuficientFunds, NotAuthorized, InvalidDate } + │ ──┬── ────────┬─────── ──────┬────── ─────┬───── + │ ╰─────────────────────────────────────────────────── def: 2 + │ │ │ │ + │ ╰───────────────────────────────────── def: 3 + │ │ │ + │ ╰───────────────────── def: 4 + │ │ + │ ╰─────── def: 5 + 3 │ error Failure ( + │ ──┬── ───┬─── + │ ╰──────────── unresolved + │ │ + │ ╰───── def: 6 + │ + 7 │ function test() public { + │ ──┬─ + │ ╰─── def: 7 + 8 │ revert Failure({cause: Cause.NotAuthorized, details: "not owner"}); + │ ───┬── ───┬─── + │ ╰──────────── refs: built-in, built-in + │ │ + │ ╰───── def: 8 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/errors/named_args/generated/0.8.4-success.txt b/crates/solidity/testing/snapshots/bindings_output/errors/named_args/generated/0.8.4-success.txt new file mode 100644 index 0000000000..08fc95d39a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/errors/named_args/generated/0.8.4-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] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ enum Cause { InsuficientFunds, NotAuthorized, InvalidDate } + │ ──┬── ────────┬─────── ──────┬────── ─────┬───── + │ ╰─────────────────────────────────────────────────── def: 2 + │ │ │ │ + │ ╰───────────────────────────────────── def: 3 + │ │ │ + │ ╰───────────────────── def: 4 + │ │ + │ ╰─────── def: 5 + 3 │ error Failure ( + │ ───┬─── + │ ╰───── def: 6 + 4 │ Cause cause, + │ ──┬── ──┬── + │ ╰────────── ref: 2 + │ │ + │ ╰──── def: 7 + 5 │ string details + │ ───┬─── + │ ╰───── def: 8 + │ + 7 │ function test() public { + │ ──┬─ + │ ╰─── def: 9 + 8 │ revert Failure({cause: Cause.NotAuthorized, details: "not owner"}); + │ ───┬─── ──┬── ──┬── ──────┬────── ───┬─── + │ ╰────────────────────────────────────────── ref: 6 + │ │ │ │ │ + │ ╰────────────────────────────────── ref: 7 + │ │ │ │ + │ ╰─────────────────────────── ref: 2 + │ │ │ + │ ╰───────────────── ref: 4 + │ │ + │ ╰───── ref: 8 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_assertions/errors/named_args.sol b/crates/solidity/testing/snapshots/bindings_output/errors/named_args/input.sol similarity index 54% rename from crates/solidity/testing/snapshots/bindings_assertions/errors/named_args.sol rename to crates/solidity/testing/snapshots/bindings_output/errors/named_args/input.sol index 4258aa3142..42837d77c8 100644 --- a/crates/solidity/testing/snapshots/bindings_assertions/errors/named_args.sol +++ b/crates/solidity/testing/snapshots/bindings_output/errors/named_args/input.sol @@ -1,16 +1,10 @@ contract Test { enum Cause { InsuficientFunds, NotAuthorized, InvalidDate } - // ^def:3 error Failure ( Cause cause, - // ^def:1 string details - // ^def:2 ); function test() public { revert Failure({cause: Cause.NotAuthorized, details: "not owner"}); - // ^ref:1 (>= 0.8.4) - // ^ref:3 (>= 0.8.4) - // ^ref:2 (>= 0.8.4) } } diff --git a/crates/solidity/testing/snapshots/bindings_output/errors/revert_stmt/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/errors/revert_stmt/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..86bf4ee1e6 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/errors/revert_stmt/generated/0.4.11-failure.txt @@ -0,0 +1,73 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected Equal or Semicolon. + ╭─[input.sol:2:23] + │ + 2 │ error InvalidState(); + │ ─┬ + │ ╰── Error occurred here. +───╯ +Error: Expected Equal or Semicolon. + ╭─[input.sol:5:28] + │ + 5 │ revert InvalidState(); + │ ─┬ + │ ╰── Error occurred here. +───╯ +Error: Expected Equal or Semicolon. + ╭─[input.sol:10:21] + │ + 10 │ revert Utils.GenericError(code); + │ ─────────┬───────── + │ ╰─────────── Error occurred here. +────╯ +Error: Expected Equal or Semicolon. + ╭─[input.sol:15:23] + │ + 15 │ error GenericError(int code); + │ ─────┬──── + │ ╰────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ error InvalidState(); + │ ──┬── ──────┬───── + │ ╰───────────────── unresolved + │ │ + │ ╰─────── def: 2 + │ + 4 │ function testRevert() public { + │ ─────┬──── + │ ╰────── def: 3 + 5 │ revert InvalidState(); + │ ───┬── ──────┬───── + │ ╰───────────────── ref: built-in + │ │ + │ ╰─────── def: 4 + │ + 8 │ function testOtherRevert() public { + │ ───────┬─────── + │ ╰───────── def: 5 + 9 │ int code = 10; + │ ──┬─ + │ ╰─── def: 6 + 10 │ revert Utils.GenericError(code); + │ ───┬── ──┬── + │ ╰────────── ref: built-in + │ │ + │ ╰──── def: 7 + │ + 14 │ library Utils { + │ ──┬── + │ ╰──── def: 8 + 15 │ error GenericError(int code); + │ ──┬── ──────┬───── + │ ╰───────────────── unresolved + │ │ + │ ╰─────── def: 9 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/errors/revert_stmt/generated/0.4.22-failure.txt b/crates/solidity/testing/snapshots/bindings_output/errors/revert_stmt/generated/0.4.22-failure.txt new file mode 100644 index 0000000000..a747e4da42 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/errors/revert_stmt/generated/0.4.22-failure.txt @@ -0,0 +1,73 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected Equal or Semicolon. + ╭─[input.sol:2:23] + │ + 2 │ error InvalidState(); + │ ─┬ + │ ╰── Error occurred here. +───╯ +Error: Expected Equal or Semicolon. + ╭─[input.sol:5:28] + │ + 5 │ revert InvalidState(); + │ ─┬ + │ ╰── Error occurred here. +───╯ +Error: Expected Equal or Semicolon. + ╭─[input.sol:10:21] + │ + 10 │ revert Utils.GenericError(code); + │ ─────────┬───────── + │ ╰─────────── Error occurred here. +────╯ +Error: Expected Equal or Semicolon. + ╭─[input.sol:15:23] + │ + 15 │ error GenericError(int code); + │ ─────┬──── + │ ╰────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ error InvalidState(); + │ ──┬── ──────┬───── + │ ╰───────────────── unresolved + │ │ + │ ╰─────── def: 2 + │ + 4 │ function testRevert() public { + │ ─────┬──── + │ ╰────── def: 3 + 5 │ revert InvalidState(); + │ ───┬── ──────┬───── + │ ╰───────────────── refs: built-in, built-in + │ │ + │ ╰─────── def: 4 + │ + 8 │ function testOtherRevert() public { + │ ───────┬─────── + │ ╰───────── def: 5 + 9 │ int code = 10; + │ ──┬─ + │ ╰─── def: 6 + 10 │ revert Utils.GenericError(code); + │ ───┬── ──┬── + │ ╰────────── refs: built-in, built-in + │ │ + │ ╰──── def: 7 + │ + 14 │ library Utils { + │ ──┬── + │ ╰──── def: 8 + 15 │ error GenericError(int code); + │ ──┬── ──────┬───── + │ ╰───────────────── unresolved + │ │ + │ ╰─────── def: 9 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/errors/revert_stmt/generated/0.8.4-success.txt b/crates/solidity/testing/snapshots/bindings_output/errors/revert_stmt/generated/0.8.4-success.txt new file mode 100644 index 0000000000..37cf467138 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/errors/revert_stmt/generated/0.8.4-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 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ error InvalidState(); + │ ──────┬───── + │ ╰─────── def: 2 + │ + 4 │ function testRevert() public { + │ ─────┬──── + │ ╰────── def: 3 + 5 │ revert InvalidState(); + │ ──────┬───── + │ ╰─────── ref: 2 + │ + 8 │ function testOtherRevert() public { + │ ───────┬─────── + │ ╰───────── def: 4 + 9 │ int code = 10; + │ ──┬─ + │ ╰─── def: 5 + 10 │ revert Utils.GenericError(code); + │ ──┬── ──────┬───── ──┬─ + │ ╰────────────────────── ref: 6 + │ │ │ + │ ╰──────────── ref: 7 + │ │ + │ ╰─── ref: 5 + │ + 14 │ library Utils { + │ ──┬── + │ ╰──── def: 6 + 15 │ error GenericError(int code); + │ ──────┬───── ──┬─ + │ ╰──────────────── def: 7 + │ │ + │ ╰─── def: 8 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_assertions/errors/revert_stmt.sol b/crates/solidity/testing/snapshots/bindings_output/errors/revert_stmt/input.sol similarity index 55% rename from crates/solidity/testing/snapshots/bindings_assertions/errors/revert_stmt.sol rename to crates/solidity/testing/snapshots/bindings_output/errors/revert_stmt/input.sol index 189ed28f4b..3e2306e87b 100644 --- a/crates/solidity/testing/snapshots/bindings_assertions/errors/revert_stmt.sol +++ b/crates/solidity/testing/snapshots/bindings_output/errors/revert_stmt/input.sol @@ -1,24 +1,16 @@ contract Test { error InvalidState(); - // ^def:1 function testRevert() public { revert InvalidState(); - // ^ref:1 (>= 0.8.4) } function testOtherRevert() public { int code = 10; - // ^def:2 revert Utils.GenericError(code); - // ^ref:2 (>= 0.8.4) - // ^ref:4 (>= 0.8.4) - // ^ref:3 (>= 0.8.4) } } library Utils { - // ^def:3 error GenericError(int code); - // ^def:4 } diff --git a/crates/solidity/testing/snapshots/bindings_output/events/emit_stmt/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/events/emit_stmt/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..051829730c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/events/emit_stmt/generated/0.4.11-failure.txt @@ -0,0 +1,56 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected Equal or Semicolon. + ╭─[input.sol:7:23] + │ + 7 │ emit TestEvent(x); + │ ─┬─ + │ ╰─── Error occurred here. +───╯ +Error: Expected Equal or Semicolon. + ╭─[input.sol:8:19] + │ + 8 │ emit Utils.Debug(x); + │ ────┬──── + │ ╰────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ event TestEvent(int id); + │ ────┬──── ─┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 4 │ function test_emit() public { + │ ────┬──── + │ ╰────── def: 4 + 5 │ int x = 1; + │ ┬ + │ ╰── def: 5 + │ + 7 │ emit TestEvent(x); + │ ──┬─ ────┬──── + │ ╰───────────── unresolved + │ │ + │ ╰────── def: 6 + 8 │ emit Utils.Debug(x); + │ ──┬─ ──┬── + │ ╰───────── unresolved + │ │ + │ ╰──── def: 7 + │ + 12 │ library Utils { + │ ──┬── + │ ╰──── def: 8 + 13 │ event Debug(int subject); + │ ──┬── ───┬─── + │ ╰──────────────── def: 9 + │ │ + │ ╰───── def: 10 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/events/emit_stmt/generated/0.4.21-success.txt b/crates/solidity/testing/snapshots/bindings_output/events/emit_stmt/generated/0.4.21-success.txt new file mode 100644 index 0000000000..b86a2493b9 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/events/emit_stmt/generated/0.4.21-success.txt @@ -0,0 +1,43 @@ +# 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 │ event TestEvent(int id); + │ ────┬──── ─┬ + │ ╰───────────── def: 2 + │ │ + │ ╰── def: 3 + │ + 4 │ function test_emit() public { + │ ────┬──── + │ ╰────── def: 4 + 5 │ int x = 1; + │ ┬ + │ ╰── def: 5 + │ + 7 │ emit TestEvent(x); + │ ────┬──── ┬ + │ ╰──────── ref: 2 + │ │ + │ ╰── ref: 5 + 8 │ emit Utils.Debug(x); + │ ──┬── ──┬── ┬ + │ ╰──────────── ref: 6 + │ │ │ + │ ╰────── ref: 7 + │ │ + │ ╰── ref: 5 + │ + 12 │ library Utils { + │ ──┬── + │ ╰──── def: 6 + 13 │ event Debug(int subject); + │ ──┬── ───┬─── + │ ╰──────────────── def: 7 + │ │ + │ ╰───── def: 8 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/events/emit_stmt/input.sol b/crates/solidity/testing/snapshots/bindings_output/events/emit_stmt/input.sol new file mode 100644 index 0000000000..cd6492aa21 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/events/emit_stmt/input.sol @@ -0,0 +1,14 @@ +contract Test { + event TestEvent(int id); + + function test_emit() public { + int x = 1; + + emit TestEvent(x); + emit Utils.Debug(x); + } +} + +library Utils { + event Debug(int subject); +} diff --git a/crates/solidity/testing/snapshots/bindings_output/events/named_args/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/events/named_args/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..c949dae864 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/events/named_args/generated/0.4.11-failure.txt @@ -0,0 +1,45 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected Equal or Semicolon. + ╭─[input.sol:10:17] + │ + 10 │ emit Log({message: "testing", level: Severity.Info}); + │ ──────────────────────┬───────────────────── + │ ╰─────────────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ enum Severity { Info, Error } + │ ────┬─── ──┬─ ──┬── + │ ╰─────────────────── def: 2 + │ │ │ + │ ╰────────── def: 3 + │ │ + │ ╰──── def: 4 + │ + 4 │ event Log ( + │ ─┬─ + │ ╰─── def: 5 + 5 │ Severity level, + │ ────┬─── ──┬── + │ ╰─────────── ref: 2 + │ │ + │ ╰──── def: 6 + 6 │ string message + │ ───┬─── + │ ╰───── def: 7 + │ + 9 │ function test() { + │ ──┬─ + │ ╰─── def: 8 + 10 │ emit Log({message: "testing", level: Severity.Info}); + │ ──┬─ ─┬─ + │ ╰─────── unresolved + │ │ + │ ╰─── def: 9 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/events/named_args/generated/0.4.21-success.txt b/crates/solidity/testing/snapshots/bindings_output/events/named_args/generated/0.4.21-success.txt new file mode 100644 index 0000000000..33de65576c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/events/named_args/generated/0.4.21-success.txt @@ -0,0 +1,43 @@ +# 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 │ enum Severity { Info, Error } + │ ────┬─── ──┬─ ──┬── + │ ╰─────────────────── def: 2 + │ │ │ + │ ╰────────── def: 3 + │ │ + │ ╰──── def: 4 + │ + 4 │ event Log ( + │ ─┬─ + │ ╰─── def: 5 + 5 │ Severity level, + │ ────┬─── ──┬── + │ ╰─────────── ref: 2 + │ │ + │ ╰──── def: 6 + 6 │ string message + │ ───┬─── + │ ╰───── def: 7 + │ + 9 │ function test() { + │ ──┬─ + │ ╰─── def: 8 + 10 │ emit Log({message: "testing", level: Severity.Info}); + │ ─┬─ ───┬─── ──┬── ────┬─── ──┬─ + │ ╰───────────────────────────────────────────── ref: 5 + │ │ │ │ │ + │ ╰────────────────────────────────────── ref: 7 + │ │ │ │ + │ ╰─────────────────── ref: 6 + │ │ │ + │ ╰────────── ref: 2 + │ │ + │ ╰─── ref: 3 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/events/named_args/input.sol b/crates/solidity/testing/snapshots/bindings_output/events/named_args/input.sol new file mode 100644 index 0000000000..b06c4b10b9 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/events/named_args/input.sol @@ -0,0 +1,12 @@ +contract Test { + enum Severity { Info, Error } + + event Log ( + Severity level, + string message + ); + + function test() { + emit Log({message: "testing", level: Severity.Info}); + } +} From c7113d7089c3ac99a164a53ac62b61317d060202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 17 Dec 2024 12:44:46 -0500 Subject: [PATCH 06/16] Migrate functions/function types/scoping/imports bindings tests from assertions to snapshots --- .../generated/function_types.rs | 15 ----- .../generated/functions.rs | 10 --- .../src/bindings_assertions/generated/mod.rs | 3 - .../generated/function_types.rs | 5 ++ .../src/bindings_output/generated/imports.rs | 10 +++ .../src/bindings_output/generated/mod.rs | 1 + .../generated/scoping.rs | 7 ++- .../function_types/external.sol | 32 ---------- .../function_types/internal.sol | 21 ------- .../imports/path_imports.sol | 29 --------- .../imports/unresolved_aliases.sol | 17 ----- .../scoping/c99_scopes.sol | 29 --------- .../scoping/hoisting_scopes.sol | 17 ----- .../generated/0.4.11-success.txt | 62 +++++++++++++++++++ .../args_return_types/input.sol | 17 +++++ .../generated/0.4.11-success.txt | 52 ++++++++++++++++ .../imports/deconstruction/input.sol} | 12 ---- .../named/generated/0.4.11-success.txt | 42 +++++++++++++ .../imports/named/input.sol} | 6 -- .../c99_scopes/generated/0.4.11-success.txt | 32 ++++++++++ .../c99_scopes/generated/0.5.0-success.txt | 32 ++++++++++ .../scoping/c99_scopes/input.sol | 12 ++++ .../functions/generated/0.4.11-failure.txt | 42 +++++++++++++ .../functions/generated/0.6.0-failure.txt | 42 +++++++++++++ .../functions/generated/0.7.1-success.txt | 36 +++++++++++ .../scoping/functions/input.sol} | 9 --- .../generated/0.4.11-success.txt | 29 +++++++++ .../generated/0.5.0-failure.txt | 29 +++++++++ .../scoping/hoisting_scopes/input.sol | 10 +++ 29 files changed, 459 insertions(+), 201 deletions(-) delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/function_types.rs delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/functions.rs rename crates/solidity/outputs/cargo/tests/src/{bindings_assertions => bindings_output}/generated/scoping.rs (70%) delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/function_types/external.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/function_types/internal.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/imports/path_imports.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/imports/unresolved_aliases.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/scoping/c99_scopes.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/scoping/hoisting_scopes.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/function_types/args_return_types/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/function_types/args_return_types/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/imports/deconstruction/generated/0.4.11-success.txt rename crates/solidity/testing/snapshots/{bindings_assertions/imports/deconstruction_imports.sol => bindings_output/imports/deconstruction/input.sol} (60%) create mode 100644 crates/solidity/testing/snapshots/bindings_output/imports/named/generated/0.4.11-success.txt rename crates/solidity/testing/snapshots/{bindings_assertions/imports/named_imports.sol => bindings_output/imports/named/input.sol} (67%) create mode 100644 crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/generated/0.5.0-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/scoping/functions/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/scoping/functions/generated/0.6.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/scoping/functions/generated/0.7.1-success.txt rename crates/solidity/testing/snapshots/{bindings_assertions/functions/visibility.sol => bindings_output/scoping/functions/input.sol} (52%) create mode 100644 crates/solidity/testing/snapshots/bindings_output/scoping/hoisting_scopes/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/scoping/hoisting_scopes/generated/0.5.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/scoping/hoisting_scopes/input.sol diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/function_types.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/function_types.rs deleted file mode 100644 index 2d54ed42c5..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/function_types.rs +++ /dev/null @@ -1,15 +0,0 @@ -// 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 external() -> Result<()> { - run("function_types", "external") -} - -#[test] -fn internal() -> Result<()> { - run("function_types", "internal") -} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/functions.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/functions.rs deleted file mode 100644 index f275d23b2b..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/functions.rs +++ /dev/null @@ -1,10 +0,0 @@ -// 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 visibility() -> Result<()> { - run("functions", "visibility") -} 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 54c0f14ba4..c9e0169f58 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 @@ -2,10 +2,7 @@ mod contracts; mod expressions; -mod function_types; -mod functions; mod imports; mod mappings; -mod scoping; mod variables; mod yul; diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/function_types.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/function_types.rs index 75d90a18e8..a4ae744c50 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/function_types.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/function_types.rs @@ -4,6 +4,11 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn args_return_types() -> Result<()> { + run("function_types", "args_return_types") +} + #[test] fn call() -> Result<()> { run("function_types", "call") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/imports.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/imports.rs index 2917e63444..15ada57af2 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/imports.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/imports.rs @@ -9,7 +9,17 @@ fn alias_import() -> Result<()> { run("imports", "alias_import") } +#[test] +fn deconstruction() -> Result<()> { + run("imports", "deconstruction") +} + #[test] fn default() -> Result<()> { run("imports", "default") } + +#[test] +fn named() -> Result<()> { + run("imports", "named") +} 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 be537f784a..b8e08152db 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 interfaces; mod libraries; mod mappings; mod modifiers; +mod scoping; mod structs; mod user_types; mod using; diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/scoping.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/scoping.rs similarity index 70% rename from crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/scoping.rs rename to crates/solidity/outputs/cargo/tests/src/bindings_output/generated/scoping.rs index 5d7d6b535e..bb84c54ee9 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/scoping.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/scoping.rs @@ -2,13 +2,18 @@ use anyhow::Result; -use crate::bindings_assertions::runner::run; +use crate::bindings_output::runner::run; #[test] fn c99_scopes() -> Result<()> { run("scoping", "c99_scopes") } +#[test] +fn functions() -> Result<()> { + run("scoping", "functions") +} + #[test] fn hoisting_scopes() -> Result<()> { run("scoping", "hoisting_scopes") diff --git a/crates/solidity/testing/snapshots/bindings_assertions/function_types/external.sol b/crates/solidity/testing/snapshots/bindings_assertions/function_types/external.sol deleted file mode 100644 index cf312ed300..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/function_types/external.sol +++ /dev/null @@ -1,32 +0,0 @@ -contract Test { - struct Coords { - // ^def:1 - int x; - int y; - } - enum HitTest { - //^def:2 - Inside, - Outside - } - struct Box { - // ^def:3 - function (Coords memory) external returns (HitTest) hitTest; - // ^def:4 - // ^ref:2 - // ^ref:1 - } - Box[] boxes; - // ^def:5 - //=0.5.0) - // ^def:3 - { - uint x = 20; - // ^def:4 - return x + y; - // ^ref:3 - // ^ref:4 - } - } - - function another_func() returns (uint y) { - // ^def:5 - y = x + w; - //=0.5.0) - // ^ref:6 (<0.5.0) - // ^ref:1 - uint w = 5; - // ^def:6 - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/scoping/hoisting_scopes.sol b/crates/solidity/testing/snapshots/bindings_assertions/scoping/hoisting_scopes.sol deleted file mode 100644 index 03c71d7bcc..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/scoping/hoisting_scopes.sol +++ /dev/null @@ -1,17 +0,0 @@ -contract Foo { - function bar() returns (int x) { - // ^def:1 - x = y + z; - //=0.5.0) - // ^ref:2 (<0.5.0) - // ^ref:! (>=0.5.0) - int y = 5; - // ^def:2 - { - int z = 10; - // ^def:3 - } - } -} diff --git a/crates/solidity/testing/snapshots/bindings_output/function_types/args_return_types/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/function_types/args_return_types/generated/0.4.11-success.txt new file mode 100644 index 0000000000..3cd681320d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/function_types/args_return_types/generated/0.4.11-success.txt @@ -0,0 +1,62 @@ +# 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 Coords { + │ ───┬── + │ ╰──── def: 2 + 3 │ int x; + │ ┬ + │ ╰── def: 3 + 4 │ int y; + │ ┬ + │ ╰── def: 4 + │ + 6 │ enum HitTest { + │ ───┬─── + │ ╰───── def: 5 + 7 │ Inside, + │ ───┬── + │ ╰──── def: 6 + 8 │ Outside + │ ───┬─── + │ ╰───── def: 7 + │ + 10 │ struct Box { + │ ─┬─ + │ ╰─── def: 8 + 11 │ function (Coords memory) external returns (HitTest) hitTest; + │ ───┬── ───┬─── ───┬─── + │ ╰─────────────────────────────────────────────── ref: 2 + │ │ │ + │ ╰────────────── ref: 5 + │ │ + │ ╰───── def: 9 + │ + 14 │ function insideBox(Box memory b, Coords memory p) public returns (bool) { + │ ────┬──── ─┬─ ┬ ───┬── ┬ + │ ╰──────────────────────────────────── def: 10 + │ │ │ │ │ + │ ╰───────────────────────────── ref: 8 + │ │ │ │ + │ ╰─────────────────── def: 11 + │ │ │ + │ ╰───────────── ref: 2 + │ │ + │ ╰── def: 12 + 15 │ return b.hitTest(p) == HitTest.Inside; + │ ┬ ───┬─── ┬ ───┬─── ───┬── + │ ╰─────────────────────────────── ref: 11 + │ │ │ │ │ + │ ╰────────────────────────── ref: 9 + │ │ │ │ + │ ╰───────────────────── ref: 12 + │ │ │ + │ ╰──────────── ref: 5 + │ │ + │ ╰──── ref: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/function_types/args_return_types/input.sol b/crates/solidity/testing/snapshots/bindings_output/function_types/args_return_types/input.sol new file mode 100644 index 0000000000..c46817b725 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/function_types/args_return_types/input.sol @@ -0,0 +1,17 @@ +contract Test { + struct Coords { + int x; + int y; + } + enum HitTest { + Inside, + Outside + } + struct Box { + function (Coords memory) external returns (HitTest) hitTest; + } + + function insideBox(Box memory b, Coords memory p) public returns (bool) { + return b.hitTest(p) == HitTest.Inside; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/imports/deconstruction/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/imports/deconstruction/generated/0.4.11-success.txt new file mode 100644 index 0000000000..551f2b5912 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/imports/deconstruction/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: + ╭─[main.sol:1:1] + │ + 1 │ import {Foo} from "lib/foo.sol"; + │ ─┬─ + │ ╰─── def: 1 + │ │ + │ ╰─── ref: 5 + 2 │ import {Bar as LocalBar} from "lib/bar.sol"; + │ ─┬─ ────┬─── + │ ╰─────────────── ref: 7 + │ │ + │ ╰───── def: 2 + │ + 4 │ contract Sample { + │ ───┬── + │ ╰──── def: 3 + 5 │ function test() returns (int) { + │ ──┬─ + │ ╰─── def: 4 + 6 │ return Foo.foo() + LocalBar.bar(); + │ ─┬─ ─┬─ ────┬─── ─┬─ + │ ╰──────────────────────── refs: 1, 5 + │ │ │ │ + │ ╰──────────────────── ref: 6 + │ │ │ + │ ╰───────── refs: 2, 7 + │ │ + │ ╰─── ref: 8 +───╯ +References and definitions: + ╭─[lib/foo.sol:1:1] + │ + 1 │ library Foo { + │ ─┬─ + │ ╰─── def: 5 + 2 │ function foo() returns (int) { + │ ─┬─ + │ ╰─── def: 6 +───╯ +References and definitions: + ╭─[lib/bar.sol:1:1] + │ + 1 │ library Bar { + │ ─┬─ + │ ╰─── def: 7 + 2 │ function bar() returns (int) { + │ ─┬─ + │ ╰─── def: 8 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_assertions/imports/deconstruction_imports.sol b/crates/solidity/testing/snapshots/bindings_output/imports/deconstruction/input.sol similarity index 60% rename from crates/solidity/testing/snapshots/bindings_assertions/imports/deconstruction_imports.sol rename to crates/solidity/testing/snapshots/bindings_output/imports/deconstruction/input.sol index 4a43c59031..a2b0ec04bd 100644 --- a/crates/solidity/testing/snapshots/bindings_assertions/imports/deconstruction_imports.sol +++ b/crates/solidity/testing/snapshots/bindings_output/imports/deconstruction/input.sol @@ -1,35 +1,23 @@ // --- path: main.sol import {Foo} from "lib/foo.sol"; -// ^def:4 -// ^ref:6 import {Bar as LocalBar} from "lib/bar.sol"; -// ^ref:5 -// ^def:3 contract Sample { function test() returns (int) { return Foo.foo() + LocalBar.bar(); - // ^ref:2 - // ^ref:5 - // ^ref:1 - // ^ref:6 } } // --- path: lib/foo.sol library Foo { - // ^def:6 function foo() returns (int) { - // ^def:1 return 1; } } // --- path: lib/bar.sol library Bar { - // ^def:5 function bar() returns (int) { - // ^def:2 return 2; } } diff --git a/crates/solidity/testing/snapshots/bindings_output/imports/named/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/imports/named/generated/0.4.11-success.txt new file mode 100644 index 0000000000..413877ec6b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/imports/named/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: + ╭─[main.sol:1:1] + │ + 1 │ import * as foo from "lib/foo.sol"; + │ ─┬─ + │ ╰─── def: 1 + │ + 3 │ contract Example { + │ ───┬─── + │ ╰───── def: 2 + 4 │ function test(int x) returns (int) { + │ ──┬─ ┬ + │ ╰───────── def: 3 + │ │ + │ ╰── def: 4 + 5 │ return foo.Foo.test(x); + │ ─┬─ ─┬─ ──┬─ ┬ + │ ╰────────────── ref: 1 + │ │ │ │ + │ ╰────────── ref: 5 + │ │ │ + │ ╰───── ref: 6 + │ │ + │ ╰── ref: 4 +───╯ +References and definitions: + ╭─[lib/foo.sol:1:1] + │ + 1 │ library Foo { + │ ─┬─ + │ ╰─── def: 5 + 2 │ function test(int x) returns (int) { + │ ──┬─ ┬ + │ ╰───────── def: 6 + │ │ + │ ╰── def: 7 + 3 │ return x + 2; + │ ┬ + │ ╰── ref: 7 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_assertions/imports/named_imports.sol b/crates/solidity/testing/snapshots/bindings_output/imports/named/input.sol similarity index 67% rename from crates/solidity/testing/snapshots/bindings_assertions/imports/named_imports.sol rename to crates/solidity/testing/snapshots/bindings_output/imports/named/input.sol index 7c67b38745..bc5d06f066 100644 --- a/crates/solidity/testing/snapshots/bindings_assertions/imports/named_imports.sol +++ b/crates/solidity/testing/snapshots/bindings_output/imports/named/input.sol @@ -1,21 +1,15 @@ // --- path: main.sol import * as foo from "lib/foo.sol"; -// ^def:1 contract Example { function test(int x) returns (int) { return foo.Foo.test(x); - // ^ref:3 - // ^ref:2 - // ^ref:1 } } // --- path: lib/foo.sol library Foo { - // ^def:2 function test(int x) returns (int) { - // ^def:3 return x + 2; } } diff --git a/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/generated/0.4.11-success.txt new file mode 100644 index 0000000000..80e908b3ec --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/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 Foo { + │ ─┬─ + │ ╰─── def: 1 + 2 │ uint x = 10; + │ ┬ + │ ╰── def: 2 + │ + 4 │ function a_func(uint x) returns (uint) { + │ ───┬── ┬ + │ ╰─────────── def: 3 + │ │ + │ ╰── def: 4 + 5 │ uint y = x + 1; + │ ┬ ┬ + │ ╰────── def: 5 + │ │ + │ ╰── ref: 6 + │ + 7 │ uint x = 20; + │ ┬ + │ ╰── def: 6 + 8 │ return x + y; + │ ┬ ┬ + │ ╰────── ref: 6 + │ │ + │ ╰── ref: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/generated/0.5.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/generated/0.5.0-success.txt new file mode 100644 index 0000000000..47c9ba9b86 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/generated/0.5.0-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 Foo { + │ ─┬─ + │ ╰─── def: 1 + 2 │ uint x = 10; + │ ┬ + │ ╰── def: 2 + │ + 4 │ function a_func(uint x) returns (uint) { + │ ───┬── ┬ + │ ╰─────────── def: 3 + │ │ + │ ╰── def: 4 + 5 │ uint y = x + 1; + │ ┬ ┬ + │ ╰────── def: 5 + │ │ + │ ╰── ref: 4 + │ + 7 │ uint x = 20; + │ ┬ + │ ╰── def: 6 + 8 │ return x + y; + │ ┬ ┬ + │ ╰────── ref: 6 + │ │ + │ ╰── ref: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/input.sol b/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/input.sol new file mode 100644 index 0000000000..cd5d987c09 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/input.sol @@ -0,0 +1,12 @@ +contract Foo { + uint x = 10; + + function a_func(uint x) returns (uint) { + // Solidity < 0.5.0 binds the following `x` differently than >= 0.5.0 + uint y = x + 1; + { + uint x = 20; + return x + y; + } + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/scoping/functions/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/scoping/functions/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..280b41d177 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/functions/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 ContractKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword. + ╭─[input.sol:16:1] + │ + 16 │ ╭─▶ function top_level() returns (int) { + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Sample { + │ ───┬── + │ ╰──── def: 1 + 2 │ function test() returns (int) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ return from_sample() + top_level() + MyLib.from_lib(); + │ ─────┬───── ────┬──── ──┬── ────┬─── + │ ╰──────────────────────────────────────── ref: 3 + │ │ │ │ + │ ╰───────────────────────── unresolved + │ │ │ + │ ╰───────────── ref: 4 + │ │ + │ ╰───── ref: 5 + │ + 5 │ function from_sample() returns (int) { + │ ─────┬───── + │ ╰─────── def: 3 + │ + 10 │ library MyLib { + │ ──┬── + │ ╰──── def: 4 + 11 │ function from_lib() returns (int) { + │ ────┬─── + │ ╰───── def: 5 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/scoping/functions/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/scoping/functions/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..5ee8126d4d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/functions/generated/0.6.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 ContractKeyword or EnumKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword or StructKeyword. + ╭─[input.sol:16:1] + │ + 16 │ ╭─▶ function top_level() returns (int) { + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Sample { + │ ───┬── + │ ╰──── def: 1 + 2 │ function test() returns (int) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ return from_sample() + top_level() + MyLib.from_lib(); + │ ─────┬───── ────┬──── ──┬── ────┬─── + │ ╰──────────────────────────────────────── ref: 3 + │ │ │ │ + │ ╰───────────────────────── unresolved + │ │ │ + │ ╰───────────── ref: 4 + │ │ + │ ╰───── ref: 5 + │ + 5 │ function from_sample() returns (int) { + │ ─────┬───── + │ ╰─────── def: 3 + │ + 10 │ library MyLib { + │ ──┬── + │ ╰──── def: 4 + 11 │ function from_lib() returns (int) { + │ ────┬─── + │ ╰───── def: 5 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/scoping/functions/generated/0.7.1-success.txt b/crates/solidity/testing/snapshots/bindings_output/scoping/functions/generated/0.7.1-success.txt new file mode 100644 index 0000000000..c93c32149d --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/functions/generated/0.7.1-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 Sample { + │ ───┬── + │ ╰──── def: 1 + 2 │ function test() returns (int) { + │ ──┬─ + │ ╰─── def: 2 + 3 │ return from_sample() + top_level() + MyLib.from_lib(); + │ ─────┬───── ────┬──── ──┬── ────┬─── + │ ╰──────────────────────────────────────── ref: 3 + │ │ │ │ + │ ╰───────────────────────── ref: 6 + │ │ │ + │ ╰───────────── ref: 4 + │ │ + │ ╰───── ref: 5 + │ + 5 │ function from_sample() returns (int) { + │ ─────┬───── + │ ╰─────── def: 3 + │ + 10 │ library MyLib { + │ ──┬── + │ ╰──── def: 4 + 11 │ function from_lib() returns (int) { + │ ────┬─── + │ ╰───── def: 5 + │ + 16 │ function top_level() returns (int) { + │ ────┬──── + │ ╰────── def: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_assertions/functions/visibility.sol b/crates/solidity/testing/snapshots/bindings_output/scoping/functions/input.sol similarity index 52% rename from crates/solidity/testing/snapshots/bindings_assertions/functions/visibility.sol rename to crates/solidity/testing/snapshots/bindings_output/scoping/functions/input.sol index 5b5d57bf72..0cafd160d8 100644 --- a/crates/solidity/testing/snapshots/bindings_assertions/functions/visibility.sol +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/functions/input.sol @@ -1,27 +1,18 @@ contract Sample { function test() returns (int) { return from_sample() + top_level() + MyLib.from_lib(); - // ^ref:3 - // ^ref:4 - // ^ref:! (<0.7.1) - // ^ref:1 (>=0.7.1) - // ^ref:2 } function from_sample() returns (int) { - // ^def:2 return 1; } } library MyLib { - // ^def:4 function from_lib() returns (int) { - // ^def:3 return 3; } } function top_level() returns (int) { - // ^def:1 return 2; } diff --git a/crates/solidity/testing/snapshots/bindings_output/scoping/hoisting_scopes/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/scoping/hoisting_scopes/generated/0.4.11-success.txt new file mode 100644 index 0000000000..c16fd45f47 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/hoisting_scopes/generated/0.4.11-success.txt @@ -0,0 +1,29 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Foo { + │ ─┬─ + │ ╰─── def: 1 + │ + 3 │ function bar() returns (int x) { + │ ─┬─ ┬ + │ ╰──────────────────── def: 2 + │ │ + │ ╰── def: 3 + 4 │ x = y + z; + │ ┬ ┬ ┬ + │ ╰────────── ref: 3 + │ │ │ + │ ╰────── ref: 4 + │ │ + │ ╰── ref: 5 + 5 │ int y = 5; + │ ┬ + │ ╰── def: 4 + │ + 7 │ int z = 10; + │ ┬ + │ ╰── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/scoping/hoisting_scopes/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/scoping/hoisting_scopes/generated/0.5.0-failure.txt new file mode 100644 index 0000000000..31053e9636 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/hoisting_scopes/generated/0.5.0-failure.txt @@ -0,0 +1,29 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Foo { + │ ─┬─ + │ ╰─── def: 1 + │ + 3 │ function bar() returns (int x) { + │ ─┬─ ┬ + │ ╰──────────────────── def: 2 + │ │ + │ ╰── def: 3 + 4 │ x = y + z; + │ ┬ ┬ ┬ + │ ╰────────── ref: 3 + │ │ │ + │ ╰────── unresolved + │ │ + │ ╰── unresolved + 5 │ int y = 5; + │ ┬ + │ ╰── def: 4 + │ + 7 │ int z = 10; + │ ┬ + │ ╰── def: 5 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/scoping/hoisting_scopes/input.sol b/crates/solidity/testing/snapshots/bindings_output/scoping/hoisting_scopes/input.sol new file mode 100644 index 0000000000..24eb18d04e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/hoisting_scopes/input.sol @@ -0,0 +1,10 @@ +contract Foo { + // should resolve all correctly for < 0.5.0 + function bar() returns (int x) { + x = y + z; + int y = 5; + { + int z = 10; + } + } +} From 6cc223c04c08a9cb7a3edd04b0c7547d6016eb2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 17 Dec 2024 13:33:46 -0500 Subject: [PATCH 07/16] Finish migration of bindings assertions to snapshots Most remaining assertion tests were redundant as there were already snapshots that cover those cases. --- .../generated/contracts.rs | 35 ------ .../generated/expressions.rs | 35 ------ .../bindings_assertions/generated/imports.rs | 25 ---- .../bindings_assertions/generated/mappings.rs | 20 ---- .../src/bindings_assertions/generated/mod.rs | 7 -- .../generated/variables.rs | 25 ---- .../src/bindings_assertions/generated/yul.rs | 40 ------- .../bindings_output/generated/contracts.rs | 5 + .../bindings_output/generated/expressions.rs | 5 + .../src/bindings_output/generated/mappings.rs | 15 +++ .../bindings_output/generated/variables.rs | 5 + .../src/bindings_output/generated/yul.rs | 15 +++ .../solidity/outputs/cargo/tests/src/lib.rs | 1 - .../contracts/constructor_invocation.sol | 21 ---- .../contracts/inheritance.sol | 43 ------- .../contracts/linearisation_order.sol | 35 ------ .../contracts/virtual_single.sol | 20 ---- .../contracts/visibility.sol | 44 ------- .../bindings_assertions/expressions/basic.sol | 14 --- .../expressions/call_options.sol | 23 ---- .../expressions/call_output.sol | 17 --- .../expressions/function_call.sol | 29 ----- .../expressions/new_output.sol | 19 ---- .../expressions/type_expression.sol | 16 --- .../bindings_assertions/mappings/nested.sol | 33 ------ .../mappings/nested_custom.sol | 35 ------ .../bindings_assertions/mappings/simple.sol | 27 ----- .../variables/destructuring.sol | 27 ----- .../variables/local_vars.sol | 15 --- .../bindings_assertions/variables/params.sol | 21 ---- .../variables/state_vars.sol | 21 ---- .../bindings_assertions/yul/blocks.sol | 33 ------ .../bindings_assertions/yul/fun_scopes.sol | 34 ------ .../bindings_assertions/yul/functions.sol | 32 ------ .../bindings_assertions/yul/if_stmt.sol | 19 ---- .../bindings_assertions/yul/variables.sol | 17 --- .../diamond/generated/0.4.11-failure.txt | 51 +++++++++ .../diamond/generated/0.5.0-failure.txt | 62 ++++++++++ .../diamond/generated/0.6.0-success.txt | 41 +++++++ .../contracts/diamond/input.sol} | 3 - .../basic/generated/0.4.11-success.txt | 29 +++++ .../expressions/basic/input.sol | 7 ++ .../elementary/generated/0.4.11-failure.txt | 22 ++++ .../elementary/generated/0.4.16-success.txt | 49 ++++++++ .../mappings/elementary/input.sol | 15 +++ .../nested/generated/0.4.11-failure.txt | 22 ++++ .../nested/generated/0.4.16-success.txt | 61 ++++++++++ .../bindings_output/mappings/nested/input.sol | 15 +++ .../generated/0.4.11-success.txt | 72 ++++++++++++ .../mappings/nested_custom/input.sol | 15 +++ .../c99_scopes/generated/0.4.11-success.txt | 7 +- .../c99_scopes/generated/0.5.0-success.txt | 7 +- .../generated/0.4.11-success.txt | 67 +++++++++++ .../variables/destructuring/input.sol | 13 +++ .../yul/blocks/generated/0.4.11-success.txt | 47 ++++++++ .../bindings_output/yul/blocks/input.sol | 14 +++ .../functions/generated/0.4.11-success.txt | 107 +++++++++++------- .../bindings_output/yul/functions/input.sol | 22 +++- .../yul/labels/generated/0.4.11-success.txt | 46 ++++++++ .../yul/labels/generated/0.5.0-failure.txt | 37 ++++++ .../yul/labels/generated/0.6.0-failure.txt | 37 ++++++ .../yul/labels/generated/0.8.18-failure.txt | 37 ++++++ .../yul/labels/generated/0.8.24-failure.txt | 37 ++++++ .../yul/labels/generated/0.8.7-failure.txt | 37 ++++++ .../yul/labels/input.sol} | 8 -- .../stack_assign/generated/0.4.11-success.txt | 20 ++++ .../stack_assign/generated/0.5.0-failure.txt | 25 ++++ .../stack_assign/generated/0.6.0-failure.txt | 25 ++++ .../stack_assign/generated/0.8.18-failure.txt | 25 ++++ .../stack_assign/generated/0.8.24-failure.txt | 25 ++++ .../stack_assign/generated/0.8.7-failure.txt | 25 ++++ .../yul/stack_assign/input.sol} | 2 - 72 files changed, 1113 insertions(+), 849 deletions(-) delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/contracts.rs delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/expressions.rs delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/imports.rs delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/mappings.rs delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/variables.rs delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/yul.rs delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/contracts/constructor_invocation.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/contracts/inheritance.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/contracts/linearisation_order.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/contracts/virtual_single.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/contracts/visibility.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/expressions/basic.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/expressions/call_options.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/expressions/call_output.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/expressions/function_call.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/expressions/new_output.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/expressions/type_expression.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/mappings/nested.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/mappings/nested_custom.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/mappings/simple.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/variables/destructuring.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/variables/local_vars.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/variables/params.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/variables/state_vars.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/yul/blocks.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/yul/fun_scopes.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/yul/functions.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/yul/if_stmt.sol delete mode 100644 crates/solidity/testing/snapshots/bindings_assertions/yul/variables.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/diamond/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/diamond/generated/0.5.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/contracts/diamond/generated/0.6.0-success.txt rename crates/solidity/testing/snapshots/{bindings_assertions/contracts/diamond.sol => bindings_output/contracts/diamond/input.sol} (80%) create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/basic/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/expressions/basic/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/mappings/elementary/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/mappings/elementary/generated/0.4.16-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/mappings/elementary/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/mappings/nested/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/mappings/nested/generated/0.4.16-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/mappings/nested/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/mappings/nested_custom/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/mappings/nested_custom/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/variables/destructuring/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/variables/destructuring/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/blocks/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/blocks/input.sol create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.5.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.6.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.8.18-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.8.24-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.8.7-failure.txt rename crates/solidity/testing/snapshots/{bindings_assertions/yul/labels.sol => bindings_output/yul/labels/input.sol} (58%) create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/stack_assign/generated/0.4.11-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/stack_assign/generated/0.5.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/stack_assign/generated/0.6.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/stack_assign/generated/0.8.18-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/stack_assign/generated/0.8.24-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/yul/stack_assign/generated/0.8.7-failure.txt rename crates/solidity/testing/snapshots/{bindings_assertions/yul/stack_assign.sol => bindings_output/yul/stack_assign/input.sol} (74%) diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/contracts.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/contracts.rs deleted file mode 100644 index 88ca890f6b..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/contracts.rs +++ /dev/null @@ -1,35 +0,0 @@ -// 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 constructor_invocation() -> Result<()> { - run("contracts", "constructor_invocation") -} - -#[test] -fn diamond() -> Result<()> { - run("contracts", "diamond") -} - -#[test] -fn inheritance() -> Result<()> { - run("contracts", "inheritance") -} - -#[test] -fn linearisation_order() -> Result<()> { - run("contracts", "linearisation_order") -} - -#[test] -fn virtual_single() -> Result<()> { - run("contracts", "virtual_single") -} - -#[test] -fn visibility() -> Result<()> { - run("contracts", "visibility") -} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/expressions.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/expressions.rs deleted file mode 100644 index fcd9acd7cf..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/expressions.rs +++ /dev/null @@ -1,35 +0,0 @@ -// 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 basic() -> Result<()> { - run("expressions", "basic") -} - -#[test] -fn call_options() -> Result<()> { - run("expressions", "call_options") -} - -#[test] -fn call_output() -> Result<()> { - run("expressions", "call_output") -} - -#[test] -fn function_call() -> Result<()> { - run("expressions", "function_call") -} - -#[test] -fn new_output() -> Result<()> { - run("expressions", "new_output") -} - -#[test] -fn type_expression() -> Result<()> { - run("expressions", "type_expression") -} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/imports.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/imports.rs deleted file mode 100644 index 4f0628f5d1..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/imports.rs +++ /dev/null @@ -1,25 +0,0 @@ -// 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 deconstruction_imports() -> Result<()> { - run("imports", "deconstruction_imports") -} - -#[test] -fn named_imports() -> Result<()> { - run("imports", "named_imports") -} - -#[test] -fn path_imports() -> Result<()> { - run("imports", "path_imports") -} - -#[test] -fn unresolved_aliases() -> Result<()> { - run("imports", "unresolved_aliases") -} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/mappings.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/mappings.rs deleted file mode 100644 index 345164a53f..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/mappings.rs +++ /dev/null @@ -1,20 +0,0 @@ -// 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 nested() -> Result<()> { - run("mappings", "nested") -} - -#[test] -fn nested_custom() -> Result<()> { - run("mappings", "nested_custom") -} - -#[test] -fn simple() -> Result<()> { - run("mappings", "simple") -} 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 c9e0169f58..b8a2159452 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 @@ -1,8 +1 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -mod contracts; -mod expressions; -mod imports; -mod mappings; -mod variables; -mod yul; diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/variables.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/variables.rs deleted file mode 100644 index 31a2ddac36..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/variables.rs +++ /dev/null @@ -1,25 +0,0 @@ -// 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 destructuring() -> Result<()> { - run("variables", "destructuring") -} - -#[test] -fn local_vars() -> Result<()> { - run("variables", "local_vars") -} - -#[test] -fn params() -> Result<()> { - run("variables", "params") -} - -#[test] -fn state_vars() -> Result<()> { - run("variables", "state_vars") -} diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/yul.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/yul.rs deleted file mode 100644 index e324fe9095..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/yul.rs +++ /dev/null @@ -1,40 +0,0 @@ -// 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 blocks() -> Result<()> { - run("yul", "blocks") -} - -#[test] -fn fun_scopes() -> Result<()> { - run("yul", "fun_scopes") -} - -#[test] -fn functions() -> Result<()> { - run("yul", "functions") -} - -#[test] -fn if_stmt() -> Result<()> { - run("yul", "if_stmt") -} - -#[test] -fn labels() -> Result<()> { - run("yul", "labels") -} - -#[test] -fn stack_assign() -> Result<()> { - run("yul", "stack_assign") -} - -#[test] -fn variables() -> Result<()> { - run("yul", "variables") -} 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 a08b136dd9..8fe043c961 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 @@ -24,6 +24,11 @@ fn constructors() -> Result<()> { run("contracts", "constructors") } +#[test] +fn diamond() -> Result<()> { + run("contracts", "diamond") +} + #[test] fn fallback_receive() -> Result<()> { run("contracts", "fallback_receive") 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 d4e1b6730d..03d1ff3445 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 basic() -> Result<()> { + run("expressions", "basic") +} + #[test] fn binary_operators() -> Result<()> { run("expressions", "binary_operators") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/mappings.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/mappings.rs index c9a660ac10..6c1d13ffe2 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/mappings.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/mappings.rs @@ -9,7 +9,22 @@ fn custom_types() -> Result<()> { run("mappings", "custom_types") } +#[test] +fn elementary() -> Result<()> { + run("mappings", "elementary") +} + #[test] fn indexing() -> Result<()> { run("mappings", "indexing") } + +#[test] +fn nested() -> Result<()> { + run("mappings", "nested") +} + +#[test] +fn nested_custom() -> Result<()> { + run("mappings", "nested_custom") +} 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 b820477fa7..4837b7188e 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 @@ -4,6 +4,11 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn destructuring() -> Result<()> { + run("variables", "destructuring") +} + #[test] fn local_vars() -> Result<()> { run("variables", "local_vars") 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 f16d3cda70..2434ace98a 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 @@ -4,6 +4,11 @@ use anyhow::Result; use crate::bindings_output::runner::run; +#[test] +fn blocks() -> Result<()> { + run("yul", "blocks") +} + #[test] fn conditionals() -> Result<()> { run("yul", "conditionals") @@ -24,6 +29,11 @@ fn identifiers_with_dots() -> Result<()> { run("yul", "identifiers_with_dots") } +#[test] +fn labels() -> Result<()> { + run("yul", "labels") +} + #[test] fn loops() -> Result<()> { run("yul", "loops") @@ -39,6 +49,11 @@ fn slot_suffix() -> Result<()> { run("yul", "slot_suffix") } +#[test] +fn stack_assign() -> Result<()> { + run("yul", "stack_assign") +} + #[test] fn variables() -> Result<()> { run("yul", "variables") diff --git a/crates/solidity/outputs/cargo/tests/src/lib.rs b/crates/solidity/outputs/cargo/tests/src/lib.rs index 519c795d76..ea8b38a537 100644 --- a/crates/solidity/outputs/cargo/tests/src/lib.rs +++ b/crates/solidity/outputs/cargo/tests/src/lib.rs @@ -3,7 +3,6 @@ use metaslang_bindings as _; mod binding_rules; -mod bindings_assertions; mod bindings_output; mod built_ins; mod cst_output; diff --git a/crates/solidity/testing/snapshots/bindings_assertions/contracts/constructor_invocation.sol b/crates/solidity/testing/snapshots/bindings_assertions/contracts/constructor_invocation.sol deleted file mode 100644 index f54e0f15a0..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/contracts/constructor_invocation.sol +++ /dev/null @@ -1,21 +0,0 @@ -contract A { - // ^def:1 - function A(int x) {} - // ^def:2 - - constructor(int y) {} - // ^def:3 -} - -contract Test { - function foo() public { - new A({x: 2}); - // ^ref:1 - // ^ref:2 (< 0.5.0) - // ^ref:! (>= 0.5.0) - new A({y: 2}); - // ^ref:1 - // ^ref:3 (>= 0.4.22) - // ^ref:! (< 0.4.22) - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/contracts/inheritance.sol b/crates/solidity/testing/snapshots/bindings_assertions/contracts/inheritance.sol deleted file mode 100644 index fe9afbf55a..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/contracts/inheritance.sol +++ /dev/null @@ -1,43 +0,0 @@ -contract B1 { - // ^def:1 - function b1_func() returns (int) { - // ^def:2 - return 1; - } -} - -contract B2 { - // ^def:3 - enum E { E1, E2 } - // ^def:7 - function b2_func() returns (int) { - // ^def:4 - return 2; - } -} - -contract C is B1 { - // ^def:5 - // ^ref:1 - E e_at_c; - //= 0.6.2) - // ^ref:3 (>= 0.6.2) - // ^ref:2 (>= 0.6.2) - // ^ref:5 - // ^ref:4 - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/expressions/call_output.sol b/crates/solidity/testing/snapshots/bindings_assertions/expressions/call_output.sol deleted file mode 100644 index 7bb655b6c8..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/expressions/call_output.sol +++ /dev/null @@ -1,17 +0,0 @@ -contract Test { - struct Resource { - uint value; - // ^def:1 - } - - function test_call_output() public returns (uint) { - return get_resource().value; - // ^ref:1 - // ^ref:2 - } - - function get_resource() internal returns (Resource memory) { - // ^def:2 - return Resource(1); - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/expressions/function_call.sol b/crates/solidity/testing/snapshots/bindings_assertions/expressions/function_call.sol deleted file mode 100644 index 7dde629c86..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/expressions/function_call.sol +++ /dev/null @@ -1,29 +0,0 @@ -contract Test { - function playground() returns (int) { - int x = 1; - // ^def:1 - int y = 2; - // ^def:2 - int z = Utils.adder(x, y); - // ^ref:2 - // ^ref:1 - // ^ref:6 - // ^ref:5 - // ^def:3 - pointless(z, x); - //=0.5.3) - } - - function getSmallestValue() returns (Direction) { - // ^ref:1 - return type(Direction).min; - // ^ref:1 (>=0.5.3) - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/mappings/nested.sol b/crates/solidity/testing/snapshots/bindings_assertions/mappings/nested.sol deleted file mode 100644 index 03c6f9da37..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/mappings/nested.sol +++ /dev/null @@ -1,33 +0,0 @@ -contract NestedMapping { - mapping(address => mapping(uint256 => bool)) public nested; - // ^def:1 - - function get(address _addr1, uint256 _i) public view returns (bool) { - // ^def:2 - // ^def:3 - return nested[_addr1][_i]; - // ^ref:2 - // ^ref:3 - // ^ref:1 - } - - function set(address _addr1, uint256 _i, bool _boo) public { - // ^def:4 - // ^def:5 - // ^def:6 - nested[_addr1][_i] = _boo; - // ^ref:4 - // ^ref:5 - // ^ref:6 - // mapping(Kind => Values)) vaults; - // ^def:4 - // ^ref:2 - // ^ref:1 - - function store(address _addr, Kind _kind, uint _amount) public { - // ^def:5 - // ^def:6 - // ^def:7 - vaults[_addr][_kind].balance += _amount; - // ^ref:5 - // ^ref:3 - // ^ref:6 - // ^ref:7 - // uint256) public myMap; - // ^def:1 - - function get(address _addr) public view returns (uint256) { - // ^def:2 - return myMap[_addr]; - // ^ref:2 - // ^ref:1 - } - - function set(address _addr, uint256 _i) public { - // ^def:3 - // ^def:4 - myMap[_addr] = _i; - // ^ref:3 - // ^ref:4 - // x { - // ^def:1 - x := add(x_i, outer()) - // ^ref:2 - } - - r := inner(a) - // ^ref:3 - // ^ref:1 - // y { - // ^def:2 - y := inner() - // ^ref:! -- function is not visible here - r := add(a, 1) - // ^ref:! -- assembly functions cannot access Solidity variables - // b { - // ^def:1 - b := add(a, 1) - } - - { - r := add(outer1(x), inner(x)) - // ^ref:2 - // ^ref:1 - function inner(f) -> g { - // ^def:2 - g:= mul(f, outer2(f)) - // ^ref:3 - } - } - - function outer2(c) -> d { - // ^def:3 - d := mul(c, outer2_inner(c)) - // ^ref:4 - - function outer2_inner(e) -> f { - // ^def:4 - f := e - } - } - } - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/yul/if_stmt.sol b/crates/solidity/testing/snapshots/bindings_assertions/yul/if_stmt.sol deleted file mode 100644 index 903ffc0dd4..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/yul/if_stmt.sol +++ /dev/null @@ -1,19 +0,0 @@ -contract Test { - function test() public returns (uint256 r) { - // ^def:1 - uint256 x = 5; - // ^def:2 - assembly { - if gt(x, 2) { - //^ref:2 - r := foo() - // ^ref:3 - // z { - // ^def:3 - z := 1 - } - } - } -} diff --git a/crates/solidity/testing/snapshots/bindings_assertions/yul/variables.sol b/crates/solidity/testing/snapshots/bindings_assertions/yul/variables.sol deleted file mode 100644 index ffe029eb8d..0000000000 --- a/crates/solidity/testing/snapshots/bindings_assertions/yul/variables.sol +++ /dev/null @@ -1,17 +0,0 @@ -contract AssemblyVariables { - function yul_let(uint256 x) public returns (uint256 z) { - // ^def:2 - // ^def:1 - assembly { - let y := add(123, x) - // ^ref:1 - // ^def:3 - z := add(456, y) - // ^ref:3 - // uint256) public myMap; + │ ──┬── + │ ╰──── def: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/mappings/elementary/generated/0.4.16-success.txt b/crates/solidity/testing/snapshots/bindings_output/mappings/elementary/generated/0.4.16-success.txt new file mode 100644 index 0000000000..d047e28036 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/mappings/elementary/generated/0.4.16-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 │ contract Mapping { + │ ───┬─── + │ ╰───── def: 1 + 2 │ mapping(address => uint256) public myMap; + │ ──┬── + │ ╰──── def: 2 + │ + 4 │ function get(address _addr) public view returns (uint256) { + │ ─┬─ ──┬── + │ ╰───────────────── def: 3 + │ │ + │ ╰──── def: 4 + 5 │ return myMap[_addr]; + │ ──┬── ──┬── + │ ╰────────── ref: 2 + │ │ + │ ╰──── ref: 4 + │ + 8 │ function set(address _addr, uint256 _i) public { + │ ─┬─ ──┬── ─┬ + │ ╰───────────────────────────── def: 5 + │ │ │ + │ ╰──────────────── def: 6 + │ │ + │ ╰── def: 7 + 9 │ myMap[_addr] = _i; + │ ──┬── ──┬── ─┬ + │ ╰──────────────── ref: 2 + │ │ │ + │ ╰────────── ref: 6 + │ │ + │ ╰── ref: 7 + │ + 12 │ function remove(address _addr) public { + │ ───┬── ──┬── + │ ╰────────────────── def: 8 + │ │ + │ ╰──── def: 9 + 13 │ delete myMap[_addr]; + │ ──┬── ──┬── + │ ╰────────── ref: 2 + │ │ + │ ╰──── ref: 9 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/mappings/elementary/input.sol b/crates/solidity/testing/snapshots/bindings_output/mappings/elementary/input.sol new file mode 100644 index 0000000000..fe623b46ec --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/mappings/elementary/input.sol @@ -0,0 +1,15 @@ +contract Mapping { + mapping(address => uint256) public myMap; + + function get(address _addr) public view returns (uint256) { + return myMap[_addr]; + } + + function set(address _addr, uint256 _i) public { + myMap[_addr] = _i; + } + + function remove(address _addr) public { + delete myMap[_addr]; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/mappings/nested/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/mappings/nested/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..4c35e8044b --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/mappings/nested/generated/0.4.11-failure.txt @@ -0,0 +1,22 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected CloseBrace or OpenBrace or ReturnsKeyword or Semicolon. + ╭─[input.sol:4:5] + │ + 4 │ ╭─▶ function get(address _addr1, uint256 _i) public view returns (bool) { + ┆ ┆ + 14 │ ├─▶ } + │ │ + │ ╰─────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract NestedMapping { + │ ──────┬────── + │ ╰──────── def: 1 + 2 │ mapping(address => mapping(uint256 => bool)) public nested; + │ ───┬── + │ ╰──── def: 2 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/mappings/nested/generated/0.4.16-success.txt b/crates/solidity/testing/snapshots/bindings_output/mappings/nested/generated/0.4.16-success.txt new file mode 100644 index 0000000000..e3af1731f4 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/mappings/nested/generated/0.4.16-success.txt @@ -0,0 +1,61 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract NestedMapping { + │ ──────┬────── + │ ╰──────── def: 1 + 2 │ mapping(address => mapping(uint256 => bool)) public nested; + │ ───┬── + │ ╰──── def: 2 + │ + 4 │ function get(address _addr1, uint256 _i) public view returns (bool) { + │ ─┬─ ───┬── ─┬ + │ ╰────────────────────────────── def: 3 + │ │ │ + │ ╰──────────────── def: 4 + │ │ + │ ╰── def: 5 + 5 │ return nested[_addr1][_i]; + │ ───┬── ───┬── ─┬ + │ ╰─────────────── ref: 2 + │ │ │ + │ ╰──────── ref: 4 + │ │ + │ ╰── ref: 5 + │ + 8 │ function set(address _addr1, uint256 _i, bool _boo) public { + │ ─┬─ ───┬── ─┬ ──┬─ + │ ╰───────────────────────────────────────── def: 6 + │ │ │ │ + │ ╰─────────────────────────── def: 7 + │ │ │ + │ ╰───────────── def: 8 + │ │ + │ ╰─── def: 9 + 9 │ nested[_addr1][_i] = _boo; + │ ───┬── ───┬── ─┬ ──┬─ + │ ╰─────────────────────── ref: 2 + │ │ │ │ + │ ╰──────────────── ref: 7 + │ │ │ + │ ╰────────── ref: 8 + │ │ + │ ╰─── ref: 9 + │ + 12 │ function remove(address _addr1, uint256 _i) public { + │ ───┬── ───┬── ─┬ + │ ╰─────────────────────────────── def: 10 + │ │ │ + │ ╰──────────────── def: 11 + │ │ + │ ╰── def: 12 + 13 │ delete nested[_addr1][_i]; + │ ───┬── ───┬── ─┬ + │ ╰─────────────── ref: 2 + │ │ │ + │ ╰──────── ref: 11 + │ │ + │ ╰── ref: 12 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/mappings/nested/input.sol b/crates/solidity/testing/snapshots/bindings_output/mappings/nested/input.sol new file mode 100644 index 0000000000..d64391800f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/mappings/nested/input.sol @@ -0,0 +1,15 @@ +contract NestedMapping { + mapping(address => mapping(uint256 => bool)) public nested; + + function get(address _addr1, uint256 _i) public view returns (bool) { + return nested[_addr1][_i]; + } + + function set(address _addr1, uint256 _i, bool _boo) public { + nested[_addr1][_i] = _boo; + } + + function remove(address _addr1, uint256 _i) public { + delete nested[_addr1][_i]; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/mappings/nested_custom/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/mappings/nested_custom/generated/0.4.11-success.txt new file mode 100644 index 0000000000..2d003a2c09 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/mappings/nested_custom/generated/0.4.11-success.txt @@ -0,0 +1,72 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract NestedCustom { + │ ──────┬───── + │ ╰─────── def: 1 + 2 │ enum Kind { Alpha, Beta } + │ ──┬─ ──┬── ──┬─ + │ ╰───────────────── def: 2 + │ │ │ + │ ╰────────── def: 3 + │ │ + │ ╰─── def: 4 + 3 │ struct Values { + │ ───┬── + │ ╰──── def: 5 + 4 │ uint balance; + │ ───┬─── + │ ╰───── def: 6 + │ + 6 │ mapping(address => mapping(Kind => Values)) vaults; + │ ──┬─ ───┬── ───┬── + │ ╰────────────────────── ref: 2 + │ │ │ + │ ╰───────────── ref: 5 + │ │ + │ ╰──── def: 7 + │ + 8 │ function store(address _addr, Kind _kind, uint _amount) public { + │ ──┬── ──┬── ──┬─ ──┬── ───┬─── + │ ╰──────────────────────────────────────────── def: 8 + │ │ │ │ │ + │ ╰────────────────────────────── def: 9 + │ │ │ │ + │ ╰─────────────────────── ref: 2 + │ │ │ + │ ╰────────────────── def: 10 + │ │ + │ ╰───── def: 11 + 9 │ vaults[_addr][_kind].balance += _amount; + │ ───┬── ──┬── ──┬── ───┬─── ───┬─── + │ ╰───────────────────────────────────── ref: 7 + │ │ │ │ │ + │ ╰─────────────────────────────── ref: 9 + │ │ │ │ + │ ╰──────────────────────── ref: 10 + │ │ │ + │ ╰──────────────── ref: 6 + │ │ + │ ╰───── ref: 11 + │ + 12 │ function balance(address _addr, Kind _kind) public returns (uint) { + │ ───┬─── ──┬── ──┬─ ──┬── + │ ╰─────────────────────────────── def: 12 + │ │ │ │ + │ ╰──────────────── def: 13 + │ │ │ + │ ╰───────── ref: 2 + │ │ + │ ╰──── def: 14 + 13 │ return vaults[_addr][_kind].balance; + │ ───┬── ──┬── ──┬── ───┬─── + │ ╰────────────────────────── ref: 7 + │ │ │ │ + │ ╰──────────────────── ref: 13 + │ │ │ + │ ╰───────────── ref: 14 + │ │ + │ ╰───── ref: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/mappings/nested_custom/input.sol b/crates/solidity/testing/snapshots/bindings_output/mappings/nested_custom/input.sol new file mode 100644 index 0000000000..4418e4f2a1 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/mappings/nested_custom/input.sol @@ -0,0 +1,15 @@ +contract NestedCustom { + enum Kind { Alpha, Beta } + struct Values { + uint balance; + } + mapping(address => mapping(Kind => Values)) vaults; + + function store(address _addr, Kind _kind, uint _amount) public { + vaults[_addr][_kind].balance += _amount; + } + + function balance(address _addr, Kind _kind) public returns (uint) { + return vaults[_addr][_kind].balance; + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/generated/0.4.11-success.txt index 80e908b3ec..640cf4af63 100644 --- a/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/generated/0.4.11-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/generated/0.4.11-success.txt @@ -15,16 +15,17 @@ References and definitions: │ ╰─────────── def: 3 │ │ │ ╰── def: 4 - 5 │ uint y = x + 1; + │ + 6 │ uint y = x + 1; │ ┬ ┬ │ ╰────── def: 5 │ │ │ ╰── ref: 6 │ - 7 │ uint x = 20; + 8 │ uint x = 20; │ ┬ │ ╰── def: 6 - 8 │ return x + y; + 9 │ return x + y; │ ┬ ┬ │ ╰────── ref: 6 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/generated/0.5.0-success.txt b/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/generated/0.5.0-success.txt index 47c9ba9b86..40d94929e1 100644 --- a/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/generated/0.5.0-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/c99_scopes/generated/0.5.0-success.txt @@ -15,16 +15,17 @@ References and definitions: │ ╰─────────── def: 3 │ │ │ ╰── def: 4 - 5 │ uint y = x + 1; + │ + 6 │ uint y = x + 1; │ ┬ ┬ │ ╰────── def: 5 │ │ │ ╰── ref: 4 │ - 7 │ uint x = 20; + 8 │ uint x = 20; │ ┬ │ ╰── def: 6 - 8 │ return x + y; + 9 │ return x + y; │ ┬ ┬ │ ╰────── ref: 6 │ │ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/destructuring/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/variables/destructuring/generated/0.4.11-success.txt new file mode 100644 index 0000000000..9c6760cb16 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/destructuring/generated/0.4.11-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 │ library Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ enum Choice { Yes, No } + │ ───┬── ─┬─ ─┬ + │ ╰────────────── def: 2 + │ │ │ + │ ╰─────── def: 3 + │ │ + │ ╰── def: 4 + │ + 4 │ function test() public { + │ ──┬─ + │ ╰─── def: 5 + 5 │ (int x, int y) = (1, 2); + │ ┬ ┬ + │ ╰───────── def: 6 + │ │ + │ ╰── def: 7 + 6 │ (int z, , int w) = (1, 2, 3); + │ ┬ ┬ + │ ╰─────────── def: 8 + │ │ + │ ╰── def: 9 + 7 │ assert(x == z); + │ ───┬── ┬ ┬ + │ ╰─────────── ref: built-in + │ │ │ + │ ╰─────── ref: 6 + │ │ + │ ╰── ref: 8 + 8 │ assert(y < w); + │ ───┬── ┬ ┬ + │ ╰────────── ref: built-in + │ │ │ + │ ╰────── ref: 7 + │ │ + │ ╰── ref: 9 + 9 │ (, Choice c) = (Choice.Yes, Choice.No); + │ ───┬── ┬ ───┬── ─┬─ ───┬── ─┬ + │ ╰──────────────────────────────── ref: 2 + │ │ │ │ │ │ + │ ╰──────────────────────────── def: 10 + │ │ │ │ │ + │ ╰─────────────────── ref: 2 + │ │ │ │ + │ ╰────────────── ref: 3 + │ │ │ + │ ╰─────── ref: 2 + │ │ + │ ╰── ref: 4 + │ + 11 │ assert(c == Choice.No); + │ ───┬── ┬ ───┬── ─┬ + │ ╰─────────────────── ref: built-in + │ │ │ │ + │ ╰─────────────── ref: 10 + │ │ │ + │ ╰─────── ref: 2 + │ │ + │ ╰── ref: 4 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/variables/destructuring/input.sol b/crates/solidity/testing/snapshots/bindings_output/variables/destructuring/input.sol new file mode 100644 index 0000000000..c0c3323bb1 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/variables/destructuring/input.sol @@ -0,0 +1,13 @@ +library Test { + enum Choice { Yes, No } + + function test() public { + (int x, int y) = (1, 2); + (int z, , int w) = (1, 2, 3); + assert(x == z); + assert(y < w); + (, Choice c) = (Choice.Yes, Choice.No); + + assert(c == Choice.No); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/blocks/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/yul/blocks/generated/0.4.11-success.txt new file mode 100644 index 0000000000..cba6472fb8 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/blocks/generated/0.4.11-success.txt @@ -0,0 +1,47 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract AssemblyBlocks { + │ ───────┬────── + │ ╰──────── def: 1 + 2 │ function yul_let(uint256 x) public returns (uint256 z) { + │ ───┬─── ┬ ┬ + │ ╰────────────────────────────────────────── def: 2 + │ │ │ + │ ╰───────────────────────────── def: 3 + │ │ + │ ╰── def: 4 + │ + 4 │ let zero := 0 + │ ──┬─ + │ ╰─── def: 5 + 5 │ let v := zero + │ ┬ ──┬─ + │ ╰────────── def: 6 + │ │ + │ ╰─── ref: 5 + │ + 7 │ let y := x + │ ┬ ┬ + │ ╰─────── def: 7 + │ │ + │ ╰── ref: 3 + 8 │ z := v + │ ┬ ┬ + │ ╰─────── ref: 4 + │ │ + │ ╰── ref: 6 + 9 │ v := y + │ ┬ ┬ + │ ╰─────── ref: 6 + │ │ + │ ╰── ref: 7 + │ + 11 │ v := zero + │ ┬ ──┬─ + │ ╰────────── ref: 6 + │ │ + │ ╰─── ref: 5 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/blocks/input.sol b/crates/solidity/testing/snapshots/bindings_output/yul/blocks/input.sol new file mode 100644 index 0000000000..e86f82e37e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/blocks/input.sol @@ -0,0 +1,14 @@ +contract AssemblyBlocks { + function yul_let(uint256 x) public returns (uint256 z) { + assembly { + let zero := 0 + let v := zero + { + let y := x + z := v + v := y + } + v := zero + } + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/functions/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/yul/functions/generated/0.4.11-success.txt index 4d553b0505..60d3f2c7aa 100644 --- a/crates/solidity/testing/snapshots/bindings_output/yul/functions/generated/0.4.11-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/yul/functions/generated/0.4.11-success.txt @@ -14,49 +14,74 @@ References and definitions: │ │ │ ╰── def: 4 │ - 4 │ let y := add(x, 5) + 4 │ function outer1(a) -> b { + │ ───┬── ┬ ┬ + │ ╰──────────── def: 5 + │ │ │ + │ ╰──────── def: 6 + │ │ + │ ╰── def: 7 + 5 │ b := add(a, 1) │ ┬ ┬ - │ ╰─────────── def: 5 + │ ╰─────────── ref: 7 │ │ - │ ╰── ref: 3 - 5 │ x, y := swap(x, y) - │ ┬ ┬ ──┬─ ┬ ┬ - │ ╰────────────────── ref: 3 - │ │ │ │ │ - │ ╰─────────────── ref: 5 - │ │ │ │ - │ ╰──────── ref: 6 - │ │ │ - │ ╰───── ref: 3 - │ │ - │ ╰── ref: 5 - 6 │ r := add(x, y) - │ ┬ ┬ ┬ - │ ╰────────────── ref: 4 - │ │ │ - │ ╰───── ref: 3 - │ │ - │ ╰── ref: 5 + │ ╰── ref: 6 │ - 8 │ function swap(a, b) -> c, d { - │ ──┬─ ┬ ┬ ┬ ┬ - │ ╰───────────────── def: 6 - │ │ │ │ │ - │ ╰────────────── def: 7 - │ │ │ │ - │ ╰─────────── def: 8 - │ │ │ - │ ╰───── def: 9 + 9 │ r := add(outer1(x), inner(x)) + │ ┬ ───┬── ┬ ──┬── ┬ + │ ╰──────────────────────────── ref: 4 + │ │ │ │ │ + │ ╰──────────────── ref: 5 + │ │ │ │ + │ ╰──────────── ref: 3 + │ │ │ + │ ╰────── ref: 8 + │ │ + │ ╰── ref: 3 + 10 │ function inner(f) -> g { + │ ──┬── ┬ ┬ + │ ╰──────────── def: 8 + │ │ │ + │ ╰──────── def: 9 + │ │ + │ ╰── def: 10 + 11 │ g:= mul(f, outer2(f)) + │ ┬ ┬ ───┬── ┬ + │ ╰──────────────────── ref: 10 + │ │ │ │ + │ ╰──────────── ref: 9 + │ │ │ + │ ╰────── ref: 11 │ │ - │ ╰── def: 10 - 9 │ c := b - │ ┬ ┬ - │ ╰─────── ref: 9 - │ │ - │ ╰── ref: 8 - 10 │ d := a - │ ┬ ┬ - │ ╰─────── ref: 10 - │ │ - │ ╰── ref: 7 + │ ╰── ref: 9 + │ + 15 │ function outer2(c) -> d { + │ ───┬── ┬ ┬ + │ ╰──────────── def: 11 + │ │ │ + │ ╰──────── def: 12 + │ │ + │ ╰── def: 13 + 16 │ d := mul(c, outer2_inner(c)) + │ ┬ ┬ ──────┬───── ┬ + │ ╰─────────────────────────── ref: 13 + │ │ │ │ + │ ╰────────────────── ref: 12 + │ │ │ + │ ╰───────── ref: 14 + │ │ + │ ╰── ref: 12 + │ + 18 │ function outer2_inner(e) -> f { + │ ──────┬───── ┬ ┬ + │ ╰─────────────── def: 14 + │ │ │ + │ ╰──────── def: 15 + │ │ + │ ╰── def: 16 + 19 │ f := e + │ ┬ ┬ + │ ╰─────── ref: 16 + │ │ + │ ╰── ref: 15 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/functions/input.sol b/crates/solidity/testing/snapshots/bindings_output/yul/functions/input.sol index dab773ceed..92e7665759 100644 --- a/crates/solidity/testing/snapshots/bindings_output/yul/functions/input.sol +++ b/crates/solidity/testing/snapshots/bindings_output/yul/functions/input.sol @@ -1,13 +1,23 @@ contract AssemblyFunctions { function test(uint256 x) public returns (uint256 r) { assembly { - let y := add(x, 5) - x, y := swap(x, y) - r := add(x, y) + function outer1(a) -> b { + b := add(a, 1) + } + + { + r := add(outer1(x), inner(x)) + function inner(f) -> g { + g:= mul(f, outer2(f)) + } + } + + function outer2(c) -> d { + d := mul(c, outer2_inner(c)) - function swap(a, b) -> c, d { - c := b - d := a + function outer2_inner(e) -> f { + f := e + } } } } diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.4.11-success.txt new file mode 100644 index 0000000000..e43de255d9 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/labels/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 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let n := calldataload(4) + │ ┬ + │ ╰── def: 5 + 5 │ let a := 1 + │ ┬ + │ ╰── def: 6 + 6 │ let b := a + │ ┬ ┬ + │ ╰─────── def: 7 + │ │ + │ ╰── ref: 6 + 7 │ loop: + │ ──┬─ + │ ╰─── def: 3 + 8 │ jumpi(loopend, eq(n, 0)) + │ ───┬─── ┬ + │ ╰─────────── ref: 4 + │ │ + │ ╰── ref: 5 + 9 │ n := sub(n, 1) + │ ┬ ┬ + │ ╰─────────── ref: 5 + │ │ + │ ╰── ref: 5 + 10 │ jump(loop) + │ ──┬─ + │ ╰─── ref: 3 + 11 │ loopend: + │ ───┬─── + │ ╰───── def: 4 + 12 │ mstore(0, a) + │ ┬ + │ ╰── ref: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.5.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.5.0-failure.txt new file mode 100644 index 0000000000..cb06333245 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.5.0-failure.txt @@ -0,0 +1,37 @@ +# 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:7:13] + │ + 7 │ ╭─▶ loop: + ┆ ┆ + 14 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let n := calldataload(4) + │ ┬ + │ ╰── def: 3 + 5 │ let a := 1 + │ ┬ + │ ╰── def: 4 + 6 │ let b := a + │ ┬ ┬ + │ ╰─────── def: 5 + │ │ + │ ╰── ref: 4 + 7 │ loop: + │ ──┬─ + │ ╰─── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..c33fa5e91f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.6.0-failure.txt @@ -0,0 +1,37 @@ +# 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:7:13] + │ + 7 │ ╭─▶ loop: + ┆ ┆ + 14 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let n := calldataload(4) + │ ┬ + │ ╰── def: 3 + 5 │ let a := 1 + │ ┬ + │ ╰── def: 4 + 6 │ let b := a + │ ┬ ┬ + │ ╰─────── def: 5 + │ │ + │ ╰── ref: 4 + 7 │ loop: + │ ──┬─ + │ ╰─── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.8.18-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.8.18-failure.txt new file mode 100644 index 0000000000..9c2f8d01b7 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.8.18-failure.txt @@ -0,0 +1,37 @@ +# 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:7:13] + │ + 7 │ ╭─▶ loop: + ┆ ┆ + 14 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let n := calldataload(4) + │ ┬ + │ ╰── def: 3 + 5 │ let a := 1 + │ ┬ + │ ╰── def: 4 + 6 │ let b := a + │ ┬ ┬ + │ ╰─────── def: 5 + │ │ + │ ╰── ref: 4 + 7 │ loop: + │ ──┬─ + │ ╰─── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.8.24-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.8.24-failure.txt new file mode 100644 index 0000000000..f770ce5e93 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.8.24-failure.txt @@ -0,0 +1,37 @@ +# 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:7:13] + │ + 7 │ ╭─▶ loop: + ┆ ┆ + 14 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let n := calldataload(4) + │ ┬ + │ ╰── def: 3 + 5 │ let a := 1 + │ ┬ + │ ╰── def: 4 + 6 │ let b := a + │ ┬ ┬ + │ ╰─────── def: 5 + │ │ + │ ╰── ref: 4 + 7 │ loop: + │ ──┬─ + │ ╰─── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.8.7-failure.txt b/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.8.7-failure.txt new file mode 100644 index 0000000000..6c1b3a017c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/yul/labels/generated/0.8.7-failure.txt @@ -0,0 +1,37 @@ +# 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:7:13] + │ + 7 │ ╭─▶ loop: + ┆ ┆ + 14 │ ├─▶ } + │ │ + │ ╰─────────────── Error occurred here. +────╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract Test { + │ ──┬─ + │ ╰─── def: 1 + 2 │ function test() public { + │ ──┬─ + │ ╰─── def: 2 + │ + 4 │ let n := calldataload(4) + │ ┬ + │ ╰── def: 3 + 5 │ let a := 1 + │ ┬ + │ ╰── def: 4 + 6 │ let b := a + │ ┬ ┬ + │ ╰─────── def: 5 + │ │ + │ ╰── ref: 4 + 7 │ loop: + │ ──┬─ + │ ╰─── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_assertions/yul/labels.sol b/crates/solidity/testing/snapshots/bindings_output/yul/labels/input.sol similarity index 58% rename from crates/solidity/testing/snapshots/bindings_assertions/yul/labels.sol rename to crates/solidity/testing/snapshots/bindings_output/yul/labels/input.sol index 624f29f7fc..fc2ff87e10 100644 --- a/crates/solidity/testing/snapshots/bindings_assertions/yul/labels.sol +++ b/crates/solidity/testing/snapshots/bindings_output/yul/labels/input.sol @@ -1,22 +1,14 @@ contract Test { function test() public { - // ^def:dummy assembly { let n := calldataload(4) let a := 1 let b := a loop: - //= 0.5.0) - a add swap1 n := sub(n, 1) jump(loop) - // ^ref:1 (< 0.5.0) - // ^ref:! (>= 0.5.0) loopend: - // Date: Tue, 17 Dec 2024 13:46:52 -0500 Subject: [PATCH 08/16] Remove bindings assertions completely --- Cargo.lock | 1 - .../solidity/outputs/cargo/tests/Cargo.toml | 1 - crates/solidity/outputs/cargo/tests/build.rs | 5 - .../src/bindings_assertions/assertions.rs | 501 ------------------ .../src/bindings_assertions/generated/mod.rs | 1 - .../tests/src/bindings_assertions/mod.rs | 3 - .../tests/src/bindings_assertions/runner.rs | 80 --- 7 files changed, 592 deletions(-) delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/assertions.rs delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/mod.rs delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/mod.rs delete mode 100644 crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs diff --git a/Cargo.lock b/Cargo.lock index e688fcbb3b..a5a2c96c1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2437,7 +2437,6 @@ dependencies = [ "slang_solidity", "solidity_language", "strum_macros", - "thiserror", ] [[package]] diff --git a/crates/solidity/outputs/cargo/tests/Cargo.toml b/crates/solidity/outputs/cargo/tests/Cargo.toml index efa99b67e2..f719a7dfff 100644 --- a/crates/solidity/outputs/cargo/tests/Cargo.toml +++ b/crates/solidity/outputs/cargo/tests/Cargo.toml @@ -32,7 +32,6 @@ slang_solidity = { workspace = true, features = [ ] } solidity_language = { workspace = true } strum_macros = { workspace = true } -thiserror = { workspace = true } [lints] workspace = true diff --git a/crates/solidity/outputs/cargo/tests/build.rs b/crates/solidity/outputs/cargo/tests/build.rs index 8f5c982af6..364cd44dc9 100644 --- a/crates/solidity/outputs/cargo/tests/build.rs +++ b/crates/solidity/outputs/cargo/tests/build.rs @@ -14,11 +14,6 @@ fn main() -> Result<()> { &tests_crate.join("src/generated"), )?; - lang_def.generate_bindings_assertions_tests( - &snapshots_crate.join("bindings_assertions"), - &tests_crate.join("src/bindings_assertions/generated"), - )?; - lang_def.generate_bindings_output_tests( &snapshots_crate.join("bindings_output"), &tests_crate.join("src/bindings_output/generated"), diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/assertions.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/assertions.rs deleted file mode 100644 index fcc4d19547..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/assertions.rs +++ /dev/null @@ -1,501 +0,0 @@ -use core::fmt; -use std::cmp::Ordering; -use std::collections::HashMap; - -use once_cell::sync::Lazy; -use regex::Regex; -use semver::{Version, VersionReq}; -use slang_solidity::bindings::{BindingGraph, Definition}; -use slang_solidity::cst::{Cursor, TerminalKind}; -use thiserror::Error; - -#[derive(Debug, Error)] -pub enum AssertionError { - #[error("Invalid assertion at {0}:{1}")] - InvalidAssertion(usize, usize), - - #[error("Invalid version requirement at line {0}: `{1}`")] - InvalidVersionReq(usize, String), - - #[error("Duplicate assertion definition {0}")] - DuplicateDefinition(String), - - #[error("No assertions found in line {0}")] - NoAssertionsFound(usize), - - #[error("Failed {failed} of {total} bindings assertions:\n{errors:#?}")] - FailedAssertions { - failed: usize, - total: usize, - errors: Vec, - }, -} - -pub struct Assertions<'a> { - definitions: HashMap>, - references: Vec>, -} - -#[derive(Clone, Debug, PartialEq)] -struct DefinitionAssertion<'a> { - id: String, - cursor: Cursor, - file: &'a str, -} - -#[derive(Clone, Debug, PartialEq)] -struct ReferenceAssertion<'a> { - id: Option, - cursor: Cursor, - file: &'a str, - version_req: Option, -} - -impl<'a> Assertions<'a> { - pub fn new() -> Self { - Self { - definitions: HashMap::new(), - references: Vec::new(), - } - } - - fn count(&self) -> usize { - self.definitions.len() + self.references.len() - } - - fn insert_definition_assertion( - &mut self, - assertion: DefinitionAssertion<'a>, - ) -> Result<(), AssertionError> { - let id = &assertion.id; - if self.definitions.contains_key(id) { - Err(AssertionError::DuplicateDefinition(id.clone())) - } else { - self.definitions.insert(id.clone(), assertion); - Ok(()) - } - } - - fn insert_reference_assertion(&mut self, assertion: ReferenceAssertion<'a>) { - self.references.push(assertion); - } -} - -impl<'a> fmt::Display for DefinitionAssertion<'a> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - f, - "Assert Definition {id} {cursor}", - id = self.id, - cursor = DisplayCursor(&self.cursor, self.file), - ) - } -} - -impl<'a> fmt::Display for ReferenceAssertion<'a> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Assert ")?; - if let Some(id) = &self.id { - write!(f, "Reference {id}")?; - } else { - write!(f, "Unresolved Reference")?; - } - if let Some(version_req) = &self.version_req { - write!(f, " in versions {version_req}")?; - } - write!(f, " {}", DisplayCursor(&self.cursor, self.file)) - } -} - -struct DisplayCursor<'a>(&'a Cursor, &'a str); - -impl<'a> fmt::Display for DisplayCursor<'a> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let offset = self.0.text_offset(); - write!( - f, - "`{}` at {}:{}:{}", - self.0.node().unparse(), - self.1, - offset.line + 1, - offset.column + 1, - ) - } -} - -/// Collects bindings assertions in comments in the parsed source code -/// accessible through the given cursor. The definitions take the following form: -/// -/// uint x; -/// // ^def:1 -/// -/// asserts that at the CST node above the caret symbol `^` (same column, not -/// necessarily in the previous line), the identifier `x` should create a -/// binding definition, and assigns it an ID of '1'. -/// -/// Conversely, for references: -/// -/// return x + y; -/// // ^ref:! (>= 0.5.0) -/// // ^ref:1 -/// -/// asserts that the CST identifier node `x` should be a binding reference which -/// should be declared as a corresponding definition assertion with identifier -/// '1'; and that the CST identifier node `y` should be a binding reference that -/// is unresolved for version at or above 0.5.0. -/// -/// For assertion targets that are located at the column where the comment -/// begins the alternative anchor `<` can be used. For example: -/// -/// x = y + 1; -/// // ^ref:2 -/// //( - assertions: &mut Assertions<'a>, - mut cursor: Cursor, - file: &'a str, - version: &Version, -) -> Result { - let mut skipped = 0; - loop { - if cursor - .node() - .is_terminal_with_kind(TerminalKind::SingleLineComment) - { - match find_assertion_in_comment(&cursor, version, file)? { - Some(Assertion::Definition(assertion)) => { - assertions.insert_definition_assertion(assertion)?; - } - Some(Assertion::Reference(assertion)) => { - assertions.insert_reference_assertion(assertion); - } - Some(Assertion::Skipped) => { - skipped += 1; - } - None => { - let line = cursor.text_offset().line + 1; - return Err(AssertionError::NoAssertionsFound(line)); - } - } - } - - if !cursor.go_to_next() { - break; - } - } - - Ok(skipped) -} - -#[derive(Clone, Debug, PartialEq)] -enum Assertion<'a> { - Definition(DefinitionAssertion<'a>), - Reference(ReferenceAssertion<'a>), - Skipped, -} - -static ASSERTION_REGEX: Lazy = Lazy::new(|| { - Regex::new(r"(?[\^]|[<])(?ref|def):(?[0-9a-zA-Z_-]+|!)([\t ]*\((?[^)]+)\))?") - .unwrap() -}); - -fn find_assertion_in_comment<'a>( - comment: &Cursor, - version: &Version, - file: &'a str, -) -> Result>, AssertionError> { - let comment_offset = comment.text_offset(); - let comment_col = comment_offset.column; - let comment_str = comment.node().unparse(); - - let Some(captures) = ASSERTION_REGEX.captures(&comment_str) else { - return Ok(None); - }; - - let assertion_id = captures.name("id").unwrap().as_str(); - let assertion_type = captures.name("type").unwrap().as_str(); - let assertion_anchor = captures.name("anchor").unwrap(); - let assertion_col = comment_col - + if assertion_anchor.as_str() == "^" { - assertion_anchor.start() - } else { - 0 - }; - let version_req = match captures.name("version") { - Some(version) => { - let Ok(version_req) = VersionReq::parse(version.as_str()) else { - return Err(AssertionError::InvalidVersionReq( - comment_offset.line + 1, - version.as_str().to_owned(), - )); - }; - Some(version_req) - } - None => None, - }; - - if let Some(cursor) = search_asserted_node_backwards(comment.clone(), assertion_col) { - let assertion = match assertion_type { - "ref" => { - let id = if assertion_id == "!" { - // this should be an unresolved reference - None - } else { - Some(assertion_id.to_owned()) - }; - Assertion::Reference(ReferenceAssertion { - id, - cursor, - file, - version_req, - }) - } - "def" => Assertion::Definition(DefinitionAssertion { - id: assertion_id.to_owned(), - cursor, - file, - }), - _ => unreachable!("unknown assertion type"), - }; - Ok(Some(assertion)) - } else { - // Assertion target may not be parseable with the current version - if let Some(version_req) = version_req { - if !version_req.matches(version) { - return Ok(Some(Assertion::Skipped)); - } - } - Err(AssertionError::InvalidAssertion( - comment_offset.line + 1, - assertion_col + 1, - )) - } -} - -fn search_asserted_node_backwards(mut cursor: Cursor, anchor_column: usize) -> Option { - let starting_line = cursor.text_offset().line; - while cursor.go_to_previous() { - // Skip if the cursor is on the same line - if cursor.text_offset().line == starting_line { - continue; - } - - // Skip over trivia, to allow defining multiple assertions for the same - // line of code in multiple single line comments - if cursor.node().is_trivia() { - continue; - } - - let cursor_column = cursor.text_offset().column; - match cursor_column.cmp(&anchor_column) { - Ordering::Equal => return Some(cursor), - Ordering::Greater => continue, - Ordering::Less => (), - } - // Skip over empty nodes which the parser may insert to fulfill the - // grammar (eg. commonly an empty Statements node) - if cursor.text_range().is_empty() { - continue; - } - - // Node is not found, and probably the anchor is invalid - break; - } - None -} - -/// Checks that the given `assertions` are fulfilled in the given `binding_graph` for -/// the indicated `version`. Only references can have version requirements, and -/// the absence of a requirement means the assertion should hold for all -/// language versions. -/// -pub fn check_assertions( - binding_graph: &BindingGraph, - assertions: &Assertions<'_>, - version: &Version, -) -> Result { - let mut failures: Vec = Vec::new(); - - check_definitions( - binding_graph, - assertions.definitions.values(), - &mut failures, - ); - check_references( - binding_graph, - version, - assertions.references.iter(), - &assertions.definitions, - &mut failures, - ); - - let count = assertions.count(); - if failures.is_empty() { - Ok(count) - } else { - Err(AssertionError::FailedAssertions { - total: count, - failed: failures.len(), - errors: failures, - }) - } -} - -fn check_definitions<'a>( - binding_graph: &BindingGraph, - definitions: impl Iterator>, - failures: &mut Vec, -) { - for assertion in definitions { - if let Err(failure) = find_definition(binding_graph, assertion) { - failures.push(failure); - } - } -} - -fn find_definition<'a>( - binding_graph: &'a BindingGraph, - assertion: &DefinitionAssertion<'_>, -) -> Result, String> { - let DefinitionAssertion { cursor, .. } = assertion; - - let Some(definition) = binding_graph.definition_at(cursor) else { - return Err(format!("{assertion} failed: not found")); - }; - - Ok(definition) -} - -fn check_references<'a>( - binding_graph: &BindingGraph, - version: &Version, - references: impl Iterator>, - definitions: &HashMap>, - failures: &mut Vec, -) { - for assertion in references { - if let Err(failure) = - check_reference_assertion(binding_graph, definitions, version, assertion) - { - failures.push(failure); - } - } -} - -fn check_reference_assertion( - binding_graph: &BindingGraph, - definitions: &HashMap>, - version: &Version, - assertion: &ReferenceAssertion<'_>, -) -> Result<(), String> { - let ReferenceAssertion { - id, version_req, .. - } = assertion; - - let version_matches = if let Some(version_req) = version_req { - version_req.matches(version) - } else { - true - }; - - let resolution = match find_and_resolve_reference(binding_graph, assertion) { - Ok(resolution) => resolution, - Err(err) => { - if version_matches { - return Err(err); - } - // the reference was not found, but that's ok if the assertion - // should not match for this version - None - } - }; - - match (version_matches, id) { - (true, None) => { - if let Some(resolved_handle) = resolution { - let resolved_cursor = resolved_handle.get_cursor(); - let resolved_file = resolved_handle.get_file(); - return Err(format!( - "{assertion} failed: expected not to resolve, but instead resolved to {resolved}", - resolved = DisplayCursor(resolved_cursor, resolved_file.get_path()) - )); - } - } - (true, Some(_)) => { - let Some(resolved_handle) = resolution else { - return Err(format!( - "{assertion} failed: did not resolve or ambiguous resolution" - )); - }; - let resolved_cursor = resolved_handle.get_cursor(); - let expected_handle = - lookup_referenced_definition(binding_graph, definitions, assertion)?; - let expected_cursor = expected_handle.get_cursor(); - if expected_cursor != resolved_cursor { - return Err(format!( - "{assertion} failed: expected resolve to {expected}, but instead resolved to {resolved}", - resolved = DisplayCursor(resolved_cursor, resolved_handle.get_file().get_path()), - expected = DisplayCursor(expected_cursor, expected_handle.get_file().get_path()), - )); - } - } - (false, None) => { - if resolution.is_none() { - return Err(format!( - "{assertion} failed: expected to resolve in this version" - )); - } - } - (false, Some(_)) => { - if let Some(resolved_handle) = resolution { - let resolved_cursor = resolved_handle.get_cursor(); - let referenced_handle = - lookup_referenced_definition(binding_graph, definitions, assertion)?; - let referenced_cursor = referenced_handle.get_cursor(); - if referenced_cursor == resolved_cursor { - return Err(format!( - "{assertion} failed: expected to not resolve to {resolved} in this version", - resolved = - DisplayCursor(resolved_cursor, resolved_handle.get_file().get_path()), - )); - } - } - } - } - - Ok(()) -} - -fn find_and_resolve_reference<'a>( - binding_graph: &'a BindingGraph, - assertion: &ReferenceAssertion<'_>, -) -> Result>, String> { - let ReferenceAssertion { cursor, .. } = assertion; - - let Some(reference) = binding_graph.reference_at(cursor) else { - return Err(format!("{assertion} failed: not found")); - }; - - // For the purpose of binding assertions, any failure to resolve to a single - // definition will be treated as if it was unresolved - Ok(reference.resolve_definition().ok()) -} - -fn lookup_referenced_definition<'a>( - binding_graph: &'a BindingGraph, - definitions: &HashMap>, - assertion: &ReferenceAssertion<'_>, -) -> Result, String> { - let ReferenceAssertion { id, .. } = assertion; - let Some(id) = id else { - return Err(format!("{assertion} failed: should not attempt to resolve")); - }; - let Some(definition) = definitions.get(id) else { - return Err(format!("{assertion} failed: reference is undefined")); - }; - find_definition(binding_graph, definition) -} 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 deleted file mode 100644 index b8a2159452..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/mod.rs +++ /dev/null @@ -1 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/mod.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/mod.rs deleted file mode 100644 index 5b99d9a10e..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod assertions; -mod generated; -mod runner; diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs deleted file mode 100644 index 9483d30c3a..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs +++ /dev/null @@ -1,80 +0,0 @@ -use std::fs; -use std::rc::Rc; - -use anyhow::Result; -use infra_utils::cargo::CargoWorkspace; -use semver::Version; -use slang_solidity::parser::Parser; -use slang_solidity::{bindings, diagnostic}; - -use crate::bindings_assertions::assertions::{ - check_assertions, collect_assertions_into, Assertions, -}; -use crate::generated::VERSION_BREAKS; -use crate::multi_part_file::{split_multi_file, Part}; -use crate::resolver::TestsPathResolver; - -pub fn run(group_name: &str, test_name: &str) -> Result<()> { - let file_name = format!("{test_name}.sol"); - let data_dir = CargoWorkspace::locate_source_crate("solidity_testing_snapshots")? - .join("bindings_assertions") - .join(group_name); - let input_path = data_dir.join(file_name); - let contents = fs::read_to_string(input_path)?; - - for version in &VERSION_BREAKS { - check_assertions_with_version(version, &contents)?; - } - Ok(()) -} - -fn check_assertions_with_version(version: &Version, contents: &str) -> Result<()> { - let parser = Parser::create(version.clone())?; - let mut binding_graph = - bindings::create_with_resolver(version.clone(), Rc::new(TestsPathResolver {}))?; - - let mut assertions = Assertions::new(); - let mut skipped = 0; - - let multi_part = split_multi_file(contents); - - for Part { - name: file_path, - contents: file_contents, - } in &multi_part.parts - { - let parse_output = parser.parse(Parser::ROOT_KIND, file_contents); - - if !parse_output.is_valid() { - let report = parse_output - .errors() - .iter() - .map(|error| diagnostic::render(error, file_path, file_contents, false)) - .collect::>() - .join("\n"); - eprintln!("\nParse errors for version {version}\nFile: {file_path}\n{report}"); - } - - binding_graph.add_user_file(file_path, parse_output.create_tree_cursor()); - skipped += collect_assertions_into( - &mut assertions, - parse_output.create_tree_cursor(), - file_path, - version, - )?; - } - - let result = check_assertions(&binding_graph, &assertions, version); - - match result { - Ok(count) => { - assert!(count > 0, "No assertions found with version {version}"); - println!("Version {version}, {count} assertions OK, {skipped} skipped"); - } - Err(err) => { - panic!("Failed bindings assertions in version {version}:\n{err}"); - } - } - - Ok(()) -} From e695f07ec01f71acf12b7be319bb434d8aee9603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 17 Dec 2024 14:03:53 -0500 Subject: [PATCH 09/16] Remove parsing of context in bindings test files --- .../cargo/tests/src/multi_part_file.rs | 51 +------------------ 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/crates/solidity/outputs/cargo/tests/src/multi_part_file.rs b/crates/solidity/outputs/cargo/tests/src/multi_part_file.rs index 204f1f8c6e..e06f118d4e 100644 --- a/crates/solidity/outputs/cargo/tests/src/multi_part_file.rs +++ b/crates/solidity/outputs/cargo/tests/src/multi_part_file.rs @@ -9,7 +9,6 @@ pub(crate) struct Part<'a> { #[derive(Debug, PartialEq)] pub(crate) struct MultiPart<'a> { - pub(crate) context: Option<&'a str>, pub(crate) parts: Vec>, } @@ -24,23 +23,7 @@ pub(crate) struct MultiPart<'a> { /// case, the returned vector will contain a single entry with the contents /// below the separator line. /// -/// The leading section before the first path separator may contain context -/// information of the form: -/// // --- context: Derived -/// -/// Other than that, non-whitespace content is not allowed before the first -/// path separator. -/// pub fn split_multi_file(contents: &str) -> MultiPart<'_> { - let context_re = Regex::new(r"(?m)\A// -{3,} context: (.+)\s*\n").unwrap(); - let (context, contents) = match context_re.captures(contents) { - Some(context_capture) => ( - Some(context_capture.get(1).unwrap().as_str()), - &contents[context_capture.get(0).unwrap().end()..], - ), - None => (None, contents), - }; - let separator_re = Regex::new(r"(?m)^// -{3,} path: (.+)\s*\n").unwrap(); let mut last_path: Option<&str> = None; let mut last_start = None; @@ -80,7 +63,7 @@ pub fn split_multi_file(contents: &str) -> MultiPart<'_> { }; parts.push(last_part); - MultiPart { context, parts } + MultiPart { parts } } #[test] @@ -98,7 +81,6 @@ fn splits_a_multi_file() { "#}; let result = split_multi_file(multi_file_contents); - assert!(result.context.is_none()); assert_eq!(3, result.parts.len()); assert_eq!( result.parts[0], @@ -159,34 +141,3 @@ fn disallows_content_before_first_path_tag() { let _ = split_multi_file(file_contents); } - -#[test] -fn captures_context() { - let file_contents = indoc! {r#" - // --- context: Base - contract Base {} - "#}; - let result = split_multi_file(file_contents); - assert_eq!(Some("Base"), result.context); - assert_eq!(1, result.parts.len()); - assert_eq!("input.sol", result.parts[0].name); - assert_eq!("contract Base {}\n", result.parts[0].contents); -} - -#[test] -fn captures_context_and_split_a_multi_file() { - let file_contents = indoc! {r#" - // --- context: Derived - // --- path: lib/base.sol - contract Base {} - // --- path: main.sol - contract Derived is Base {} - "#}; - let result = split_multi_file(file_contents); - assert_eq!(Some("Derived"), result.context); - assert_eq!(2, result.parts.len()); - assert_eq!("lib/base.sol", result.parts[0].name); - assert_eq!("contract Base {}\n", result.parts[0].contents); - assert_eq!("main.sol", result.parts[1].name); - assert_eq!("contract Derived is Base {}\n", result.parts[1].contents); -} From 0fbd09269f5437864714a751642372b89629e363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 17 Dec 2024 14:04:16 -0500 Subject: [PATCH 10/16] Update public_api.txt --- crates/metaslang/bindings/generated/public_api.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/metaslang/bindings/generated/public_api.txt b/crates/metaslang/bindings/generated/public_api.txt index e0fe3e3212..99f0a388b9 100644 --- a/crates/metaslang/bindings/generated/public_api.txt +++ b/crates/metaslang/bindings/generated/public_api.txt @@ -31,9 +31,7 @@ pub fn metaslang_bindings::BindingGraph::all_definitions(&self) -> impl core pub fn metaslang_bindings::BindingGraph::all_references(&self) -> impl core::iter::traits::iterator::Iterator> + '_ pub fn metaslang_bindings::BindingGraph::create(version: semver::Version, binding_rules: &str, path_resolver: alloc::rc::Rc>) -> Self pub fn metaslang_bindings::BindingGraph::definition_at(&self, cursor: &metaslang_cst::cursor::Cursor) -> core::option::Option> -pub fn metaslang_bindings::BindingGraph::get_context(&self) -> core::option::Option> pub fn metaslang_bindings::BindingGraph::reference_at(&self, cursor: &metaslang_cst::cursor::Cursor) -> core::option::Option> -pub fn metaslang_bindings::BindingGraph::set_context(&mut self, context: &metaslang_bindings::DefinitionHandle) pub struct metaslang_bindings::BuiltInLocation impl core::clone::Clone for metaslang_bindings::BuiltInLocation pub fn metaslang_bindings::BuiltInLocation::clone(&self) -> metaslang_bindings::BuiltInLocation @@ -47,7 +45,6 @@ pub fn metaslang_bindings::Definition<'a, KT>::get_definiens_cursor(&self) -> &m pub fn metaslang_bindings::Definition<'a, KT>::get_file(&self) -> metaslang_bindings::FileDescriptor pub fn metaslang_bindings::Definition<'a, KT>::id(&self) -> usize pub fn metaslang_bindings::Definition<'a, KT>::name_location(&self) -> metaslang_bindings::BindingLocation -pub fn metaslang_bindings::Definition<'a, KT>::to_handle(self) -> metaslang_bindings::DefinitionHandle impl<'a, KT: core::clone::Clone + metaslang_cst::kinds::KindTypes + 'static> core::clone::Clone for metaslang_bindings::Definition<'a, KT> pub fn metaslang_bindings::Definition<'a, KT>::clone(&self) -> metaslang_bindings::Definition<'a, KT> impl core::cmp::Eq for metaslang_bindings::Definition<'_, KT> @@ -59,7 +56,6 @@ impl core::fmt::Display for metas pub fn metaslang_bindings::Definition<'_, KT>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result impl core::hash::Hash for metaslang_bindings::Definition<'_, KT> pub fn metaslang_bindings::Definition<'_, KT>::hash(&self, state: &mut H) -pub struct metaslang_bindings::DefinitionHandle(_) pub struct metaslang_bindings::Reference<'a, KT: metaslang_cst::kinds::KindTypes + 'static> impl<'a, KT: metaslang_cst::kinds::KindTypes + 'static> metaslang_bindings::Reference<'a, KT> pub fn metaslang_bindings::Reference<'a, KT>::definitions(&self) -> alloc::vec::Vec> From 862f38287716b017747d58bde735271fd12c80a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 17 Dec 2024 15:25:59 -0500 Subject: [PATCH 11/16] Remove `resolve_definition()` in favor of `definitions()` This also removes the ranking algorithm for resolution results, since it's no longer needed. --- .../bindings/generated/public_api.txt | 1 - crates/metaslang/bindings/src/lib.rs | 30 +--- crates/metaslang/bindings/src/resolver/mod.rs | 147 +----------------- .../testing/perf/src/tests/references.rs | 4 +- 4 files changed, 13 insertions(+), 169 deletions(-) diff --git a/crates/metaslang/bindings/generated/public_api.txt b/crates/metaslang/bindings/generated/public_api.txt index 99f0a388b9..e4b11e5bec 100644 --- a/crates/metaslang/bindings/generated/public_api.txt +++ b/crates/metaslang/bindings/generated/public_api.txt @@ -63,7 +63,6 @@ pub fn metaslang_bindings::Reference<'a, KT>::get_cursor(&self) -> &metaslang_cs pub fn metaslang_bindings::Reference<'a, KT>::get_file(&self) -> metaslang_bindings::FileDescriptor pub fn metaslang_bindings::Reference<'a, KT>::id(&self) -> usize pub fn metaslang_bindings::Reference<'a, KT>::location(&self) -> metaslang_bindings::BindingLocation -pub fn metaslang_bindings::Reference<'a, KT>::resolve_definition(&self) -> core::result::Result, metaslang_bindings::ResolutionError<'a, KT>> impl<'a, KT: core::clone::Clone + metaslang_cst::kinds::KindTypes + 'static> core::clone::Clone for metaslang_bindings::Reference<'a, KT> pub fn metaslang_bindings::Reference<'a, KT>::clone(&self) -> metaslang_bindings::Reference<'a, KT> impl core::cmp::PartialEq for metaslang_bindings::Reference<'_, KT> diff --git a/crates/metaslang/bindings/src/lib.rs b/crates/metaslang/bindings/src/lib.rs index 6bb504a801..6c658b1083 100644 --- a/crates/metaslang/bindings/src/lib.rs +++ b/crates/metaslang/bindings/src/lib.rs @@ -251,11 +251,11 @@ impl BindingGraph { // either definitions or references handles .iter() - .filter_map(|handle| { + .flat_map(|handle| { if self.stack_graph[*handle].is_definition() { - self.to_definition(*handle) + vec![self.to_definition(*handle).unwrap()] } else { - self.to_reference(*handle)?.non_recursive_resolve().ok() + self.to_reference(*handle).unwrap().non_recursive_resolve() } }) .collect() @@ -338,14 +338,6 @@ impl<'a, KT: KindTypes + 'static> Definition<'a, KT> { .expect("Definition does not have a valid file descriptor") } - pub(crate) fn has_tag(&self, tag: Tag) -> bool { - self.owner - .definitions_info - .get(&self.handle) - .and_then(|info| info.tag) - .is_some_and(|definition_tag| definition_tag == tag) - } - pub(crate) fn resolve_parents(&self) -> Vec> { self.owner .definitions_info @@ -446,28 +438,16 @@ impl<'a, KT: KindTypes + 'static> Reference<'a, KT> { .expect("Reference does not have a valid file descriptor") } - pub fn resolve_definition(&self) -> Result, ResolutionError<'a, KT>> { - Resolver::build_for(self, ResolveOptions::Full).first() - } - pub fn definitions(&self) -> Vec> { Resolver::build_for(self, ResolveOptions::Full).all() } pub(crate) fn non_recursive_resolve( &self, - ) -> Result, ResolutionError<'a, KT>> { + ) -> Vec> { // This was likely originated from a full resolution call, so cut // recursion here by restricting the resolution algorithm. - Resolver::build_for(self, ResolveOptions::NonRecursive).first() - } - - pub(crate) fn has_tag(&self, tag: Tag) -> bool { - self.owner - .references_info - .get(&self.handle) - .and_then(|info| info.tag) - .is_some_and(|reference_tag| reference_tag == tag) + Resolver::build_for(self, ResolveOptions::NonRecursive).all() } pub(crate) fn resolve_parents(&self) -> Vec> { diff --git a/crates/metaslang/bindings/src/resolver/mod.rs b/crates/metaslang/bindings/src/resolver/mod.rs index 4ae11f2d37..bca43991d3 100644 --- a/crates/metaslang/bindings/src/resolver/mod.rs +++ b/crates/metaslang/bindings/src/resolver/mod.rs @@ -9,7 +9,7 @@ use stack_graphs::stitching::{ }; use stack_graphs::CancellationError; -use crate::{BindingGraph, Definition, FileHandle, GraphHandle, Reference, ResolutionError, Tag}; +use crate::{BindingGraph, Definition, FileHandle, GraphHandle, Reference}; mod c3; @@ -40,7 +40,7 @@ pub(crate) struct Resolver<'a, KT: KindTypes + 'static> { owner: &'a BindingGraph, reference: Reference<'a, KT>, partials: PartialPaths, - results: Vec>, + results: Vec>, options: ResolveOptions, } @@ -50,18 +50,6 @@ pub(crate) enum ResolveOptions { NonRecursive, } -struct ResolvedPath<'a, KT: KindTypes + 'static> { - pub partial_path: PartialPath, - pub definition: Definition<'a, KT>, - pub score: f32, -} - -impl<'a, KT: KindTypes + 'static> ResolvedPath<'a, KT> { - pub fn len(&self) -> usize { - self.partial_path.edges.len() - } -} - /// Candidates for the forward stitching resolution process. This will inject /// edges to the the given extensions scopes at extension hook nodes when asked /// for forward candidates (ie. `get_forward_candidates`) by the resolution @@ -197,141 +185,18 @@ impl<'a, KT: KindTypes + 'static> Resolver<'a, KT> { .iter() .all(|other| !other.shadows(&mut self.partials, reference_path)) { - self.results.push(ResolvedPath { - definition: self - .owner + self.results.push( + self.owner .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); } } } - pub fn all(&self) -> Vec> { + pub fn all(self) -> Vec> { self.results - .iter() - .map(|path| path.definition.clone()) - .collect() - } - - pub fn first(&mut self) -> Result, ResolutionError<'a, KT>> { - if self.results.len() > 1 { - self.rank_results(); - - let top_score = self.results[0].score; - let mut results = self - .results - .iter() - .take_while(|result| (result.score - top_score).abs() < f32::EPSILON) - .map(|result| result.definition.clone()) - .collect::>(); - if results.len() > 1 { - Err(ResolutionError::AmbiguousDefinitions(results)) - } else { - Ok(results.swap_remove(0)) - } - } else { - self.results - .first() - .map(|path| path.definition.clone()) - .ok_or(ResolutionError::Unresolved) - } - } - - fn rank_results(&mut self) { - if self.results.is_empty() { - return; - } - self.mark_down_aliases(); - self.mark_down_built_ins(); - if self.options == ResolveOptions::Full { - self.rank_c3_methods(); - } - self.results.sort_by(|a, b| b.score.total_cmp(&a.score)); - } - - fn mark_down_aliases(&mut self) { - // compute min and max path lengths - let (min_len, max_len) = - self.results - .iter() - .fold((usize::MAX, usize::MIN), |(min_len, max_len), result| { - let len = result.len(); - (min_len.min(len), max_len.max(len)) - }); - - for result in &mut self.results { - // mark down alias definitions - #[allow(clippy::cast_precision_loss)] - if result.definition.has_tag(Tag::Alias) { - result.score -= 100.0; - - // but prioritize longer paths so that we can still return a - // result if we only have multiple aliases as possible - // definitions - result.score += (result.len() - min_len) as f32 / (1 + max_len - min_len) as f32; - } - } - } - - fn mark_down_built_ins(&mut self) { - for result in &mut self.results { - if result.definition.get_file().is_system() { - result.score -= 200.0; - } - } - } - - fn rank_c3_methods(&mut self) { - // compute the linearisation to use for ranking - let caller_parents = self.reference.resolve_parents(); - let Some(caller_context) = caller_parents.first() else { - // the reference does not provide an enclosing definition, so nothing to do here - return; - }; - - #[allow(clippy::mutable_key_type)] - let parents = Self::resolve_parents_all(caller_context.clone()); - - let Some(mro) = c3::linearise(caller_context, &parents) else { - // linearisation failed - eprintln!("Linearisation of {caller_context} failed"); - return; - }; - - let caller_context_index = mro.iter().position(|x| x == caller_context); - let super_call = self.reference.has_tag(Tag::Super); - - // Mark up user methods tagged C3 according to the computed linearisation. - // Because only contract functions are marked with the C3 tag, this has - // the added benefit of prioritizing them over globally defined - // functions. - for result in &mut self.results { - if result.definition.has_tag(Tag::C3) && result.definition.get_file().is_user() { - let definition_parents = result.definition.resolve_parents(); - let Some(definition_context) = definition_parents.first() else { - // this should not normally happen: the definition is tagged - // with the C3 selector but does not provide a resolvable - // enclosing definition - continue; - }; - - // find the definition context in the linearised result - #[allow(clippy::cast_precision_loss)] - if let Some(index) = mro.iter().position(|x| x == definition_context) { - // if this is a super call, ignore all implementations at or - // before (as in more derived) than the caller's - if !super_call - || (caller_context_index.is_none() || index > caller_context_index.unwrap()) - { - result.score += 100.0 * (mro.len() - index) as f32; - } - } - } - } } #[allow(clippy::mutable_key_type)] diff --git a/crates/solidity/testing/perf/src/tests/references.rs b/crates/solidity/testing/perf/src/tests/references.rs index c039149a6d..be54ac9a18 100644 --- a/crates/solidity/testing/perf/src/tests/references.rs +++ b/crates/solidity/testing/perf/src/tests/references.rs @@ -17,8 +17,8 @@ pub fn run(binding_graph: BindingGraph) { } reference_count += 1; - let resolution = reference.resolve_definition(); - if resolution.is_ok() { + let definitions = reference.definitions(); + if !definitions.is_empty() { resolved_references += 1; } } From a33b0e7cf3875d9027dc35fc9d5733321943307c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 17 Dec 2024 15:32:23 -0500 Subject: [PATCH 12/16] Remove C3 linearization algorithm implementation --- crates/metaslang/bindings/src/resolver/c3.rs | 244 ------------------ crates/metaslang/bindings/src/resolver/mod.rs | 8 - 2 files changed, 252 deletions(-) delete mode 100644 crates/metaslang/bindings/src/resolver/c3.rs diff --git a/crates/metaslang/bindings/src/resolver/c3.rs b/crates/metaslang/bindings/src/resolver/c3.rs deleted file mode 100644 index ae97ba945b..0000000000 --- a/crates/metaslang/bindings/src/resolver/c3.rs +++ /dev/null @@ -1,244 +0,0 @@ -use std::collections::{HashMap, VecDeque}; -use std::fmt::{Debug, Display}; -use std::hash::Hash; - -/// Produces a linearisation of a hierarchy of items using the C3 linearisation -/// algorithm. Given an item `A` with parents `(B1, B2)` in that order, the -/// linearisation of A can be defined as: -/// ``` -/// L(A) = [A] + merge(L(B1), L(B2), [B1, B2]) -/// ``` -/// The merge operation (defined below) will order the items of the vectors by -/// taking candidates that can only appear in the first position in all of the -/// vectors. -/// NOTE: parents are considered left-to-right as in the traditional C3 -/// linearisation algorithm, ie. Python style. -pub(crate) fn linearise( - target: &Item, - parents: &HashMap>, -) -> Option> { - let mut linearisations: HashMap> = HashMap::new(); - - // Keeps a running queue of pending linearisations. - let mut queue: VecDeque = VecDeque::new(); - queue.push_back(target.clone()); - - // When an item cannot be resolved, we save it here along the number of - // items already linearised. If we fail to linearise a second time, we use - // this to check if progress was made to avoid infinite loops with cycles. - let mut checkpoint = None; - - while let Some(item) = queue.pop_front() { - if linearisations.contains_key(&item) { - continue; - } - let item_parents = &parents[&item]; - let mut merge_set = Vec::new(); - for parent in item_parents { - match linearisations.get(parent) { - Some(parent_linearisation) => { - merge_set.push(parent_linearisation.clone()); - } - None => { - // Queue the parent with missing linearisation at the front to - // resolve it first (unless it's already queued) - if !queue.iter().any(|queued| queued == parent) { - queue.push_front(parent.clone()); - } - } - } - } - if merge_set.len() == item_parents.len() { - merge_set.push(item_parents.clone()); - let Some(merge_result) = merge(merge_set) else { - // Failed to linearise the current item; linearisation is not possible. - eprintln!("Linearisation of {item} failed"); - return None; - }; - - let mut result = Vec::new(); - result.push(item.clone()); - result.extend(merge_result); - - // Clear checkpoint if we just linearised it. - if matches!(checkpoint, Some((ref check_item, _)) if *check_item == item) { - checkpoint = None; - } - - linearisations.insert(item, result); - } else { - // We're missing linearisations of some parents, so re-enqueue the - // current item at the end and try again later, after hopefully - // recursively resolving the linearisation of the parents. - match checkpoint { - Some((ref check_item, items_linearised)) => { - if *check_item == item { - if items_linearised == linearisations.len() { - // no progress since last checkpoint; this indicates a cycle - eprintln!("Linearisation of {item} failed: cycle detected"); - return None; - } - // Update progress and re-try - checkpoint = Some((item.clone(), linearisations.len())); - } - } - None => { - // Create a checkpoint on the item we couldn't yet linearise. - checkpoint = Some((item.clone(), linearisations.len())); - } - } - queue.push_back(item); - } - } - - linearisations.remove(target) -} - -/// Merges the items in the set in C3 linearisation order. Returns None if -/// linearisation is not possible. -/// NOTE: Because we're dealing with vectors, we will be taking candidates from -/// the tails with `pop()` as it's more convenient, we will reverse all the -/// inputs. Both the inputs and the result are returned in natural order. -fn merge(mut set: Vec>) -> Option> { - set = set - .into_iter() - .filter_map(|mut subset| { - if subset.is_empty() { - None - } else { - subset.reverse(); - Some(subset) - } - }) - .collect(); - if set.is_empty() { - // Nothing to merge; this happens when linearising an item without parents - return Some(Vec::new()); - } - - let mut result = Vec::new(); - while let Some(found) = find_candidate(&set) { - set = remove_candidate_from_set(set, &found); - result.push(found); - } - // If set is empty, we successfully merged the set. - // Otherwise, linearisation is not possible. - if set.is_empty() { - Some(result) - } else { - None - } -} - -// Find a candidate in a set. A valid candidate can only appear in the last -// position in any vector in the set. -fn find_candidate(set: &Vec>) -> Option { - for subset in set { - let Some(candidate) = subset.last() else { - continue; - }; - if set.iter().all( - |subset| match subset.iter().position(|item| item == candidate) { - Some(position) => position == subset.len() - 1, - None => true, - }, - ) { - return Some(candidate.clone()); - } - } - None -} - -// Removes a candidate from the set. It should be a valid candidate, so it can -// only appear in the last position in each vector in the set. Removes empty -// vectors and returns the updated set. -fn remove_candidate_from_set( - set: Vec>, - element: &Item, -) -> Vec> { - set.into_iter() - .filter_map(|mut subset| { - if subset.last().expect("every vector in the set is not empty") == element { - subset.pop(); - } - if subset.is_empty() { - None - } else { - Some(subset) - } - }) - .collect() -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_merge_no_elements() { - assert_eq!(Some(vec![]), merge::<()>(vec![vec![]])); - } - - #[test] - fn test_merge_single_parent() { - assert_eq!(Some(vec!['A']), merge(vec![vec!['A'], vec!['A']])); - } - - #[test] - fn test_merge_two_parents() { - assert_eq!( - Some(vec!['A', 'B']), - merge(vec![vec!['A'], vec!['B'], vec!['A', 'B']]) - ); - } - - #[test] - fn test_merge_not_linearisable() { - assert_eq!(None, merge(vec![vec!['A', 'X'], vec![], vec!['X', 'A']])); - } - - #[test] - fn test_linearise() { - let mut parents = HashMap::new(); - parents.insert('A', vec![]); - parents.insert('B', vec!['A']); - parents.insert('C', vec!['A']); - parents.insert('D', vec!['B', 'C']); - parents.insert('E', vec!['C', 'B']); - - assert_eq!(Some(vec!['D', 'B', 'C', 'A']), linearise(&'D', &parents)); - assert_eq!(Some(vec!['E', 'C', 'B', 'A']), linearise(&'E', &parents)); - } - - #[test] - fn test_linearise_not_linearisable() { - let mut parents = HashMap::new(); - parents.insert('X', vec![]); - parents.insert('A', vec!['X']); - parents.insert('C', vec!['X', 'A']); - - assert_eq!(None, linearise(&'C', &parents)); - } - - #[test] - fn test_linearise_with_shallow_cycles() { - let mut parents = HashMap::new(); - parents.insert('B', vec!['A']); - parents.insert('A', vec!['B']); - - assert_eq!(None, linearise(&'A', &parents)); - assert_eq!(None, linearise(&'B', &parents)); - } - - #[test] - fn test_linearise_with_deep_cycles() { - let mut parents = HashMap::new(); - parents.insert('X', vec!['Y']); - parents.insert('Y', vec!['Z']); - parents.insert('Z', vec!['X']); - - assert_eq!(None, linearise(&'X', &parents)); - assert_eq!(None, linearise(&'Y', &parents)); - assert_eq!(None, linearise(&'Z', &parents)); - } -} diff --git a/crates/metaslang/bindings/src/resolver/mod.rs b/crates/metaslang/bindings/src/resolver/mod.rs index bca43991d3..0faec8248c 100644 --- a/crates/metaslang/bindings/src/resolver/mod.rs +++ b/crates/metaslang/bindings/src/resolver/mod.rs @@ -11,8 +11,6 @@ use stack_graphs::CancellationError; use crate::{BindingGraph, Definition, FileHandle, GraphHandle, Reference}; -mod c3; - /// The resolver executes algorithms to resolve a reference to one or more /// definitions. The reference may not be resolvable in the current state of the /// bindings (eg. you may still need to add an imported file), so it may not be @@ -30,12 +28,6 @@ mod c3; /// 2. Virtual methods: a reference should find valid paths to all available /// definitions in a class hierarchy. /// -/// The multiple definitions can be ranked by one or more secondary algorithms -/// to be applied by this resolver. For example, an alias import definition -/// would be downgraded, allowing the resolver to prefer the actual definition -/// if found (it may not be available yet). Or a topological ordering may be -/// applied to definitions pointing to virtual methods. -/// pub(crate) struct Resolver<'a, KT: KindTypes + 'static> { owner: &'a BindingGraph, reference: Reference<'a, KT>, From 009e9f388a546edb89b6d763719ba79611e23a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 17 Dec 2024 16:25:24 -0500 Subject: [PATCH 13/16] Remove `tag` graph attribute --- crates/metaslang/bindings/src/builder/mod.rs | 57 +------------------ crates/metaslang/bindings/src/lib.rs | 9 --- .../inputs/language/bindings/rules.msgb | 13 ----- .../bindings/generated/binding_rules.rs | 13 ----- 4 files changed, 2 insertions(+), 90 deletions(-) diff --git a/crates/metaslang/bindings/src/builder/mod.rs b/crates/metaslang/bindings/src/builder/mod.rs index 3628828d13..5ef0ca0610 100644 --- a/crates/metaslang/bindings/src/builder/mod.rs +++ b/crates/metaslang/bindings/src/builder/mod.rs @@ -245,27 +245,6 @@ //! //! ### Other node attributes introduced in Slang's usage of stack-graphs //! -//! #### `tag` attribute -//! -//! This is used to attach a specific meaning to the node, to alter the ranking -//! algorithm used when attempting to disambiguate between multiple definitions -//! found for a reference. This is an optional string attribute. -//! -//! Possible values: -//! -//! - "alias": marks a definition node as a semantic alias of another definition -//! (eg. an import alias) -//! -//! - "c3": used to mark a function/method definition to be a candidate in -//! disambiguation using the C3 linearisation algorithm. In order for C3 -//! linearisation to be possible, type hierarchy attributes need to be provided -//! as well (see `parents` attribute below). -//! -//! - "super": marks a reference as a call to super virtual call. This modifies -//! the C3 linearisation algorithm by eliminating the candidates that are at -//! or further down the hierarchy of where the reference occurs. To determine -//! where the reference occurs, we also use the `parents` attribute. -//! //! #### `parents` attribute //! //! Is used to convey semantic hierarchy. Can be applied to both definitions and @@ -278,20 +257,6 @@ //! later case, generally speaking they will need to be resolved at resolution //! time in order to be useful. //! -//! #### `export_node` and `import_nodes` -//! -//! These are used to define static fixed edges to add via `set_context()`. -//! Using `set_context()` will modify the underlying stack graph by inserting -//! edges from the `import_nodes` of all parents (resolved recursively) of the -//! given context, to the `export_node` associated with the context. -//! -//! This can be used to inject virtual method implementations defined in -//! subclasses in the scope of their parent classes, which are otherwise -//! lexically inaccessible. -//! -//! `export_node` is an optional graph node attribute, and `import_nodes` is an -//! optional list of graph nodes. Both apply only to definition nodes. -//! //! #### `extension_hook`, `extension_scope` and `inherit_extensions` //! //! These attributes enable the bindings API to resolve extension methods by @@ -328,7 +293,7 @@ use stack_graphs::arena::Handle; use stack_graphs::graph::{File, Node, NodeID, StackGraph}; use thiserror::Error; -use crate::{DefinitionBindingInfo, ReferenceBindingInfo, Tag}; +use crate::{DefinitionBindingInfo, ReferenceBindingInfo}; // Node type values static DROP_SCOPES_TYPE: &str = "drop_scopes"; @@ -354,7 +319,6 @@ static SCOPE_ATTR: &str = "scope"; static SOURCE_NODE_ATTR: &str = "source_node"; static SYMBOL_ATTR: &str = "symbol"; static SYNTAX_TYPE_ATTR: &str = "syntax_type"; -static TAG_ATTR: &str = "tag"; static TYPE_ATTR: &str = "type"; // Expected attributes per node type @@ -364,7 +328,6 @@ static POP_SCOPED_SYMBOL_ATTRS: Lazy> = Lazy::new(|| { SYMBOL_ATTR, IS_DEFINITION_ATTR, DEFINIENS_NODE_ATTR, - TAG_ATTR, PARENTS_ATTR, SYNTAX_TYPE_ATTR, EXTENSION_SCOPE_ATTR, @@ -377,7 +340,6 @@ static POP_SYMBOL_ATTRS: Lazy> = Lazy::new(|| { SYMBOL_ATTR, IS_DEFINITION_ATTR, DEFINIENS_NODE_ATTR, - TAG_ATTR, PARENTS_ATTR, SYNTAX_TYPE_ATTR, EXTENSION_SCOPE_ATTR, @@ -390,7 +352,6 @@ static PUSH_SCOPED_SYMBOL_ATTRS: Lazy> = Lazy::new(|| { SYMBOL_ATTR, SCOPE_ATTR, IS_REFERENCE_ATTR, - TAG_ATTR, PARENTS_ATTR, ]) }); @@ -399,7 +360,6 @@ static PUSH_SYMBOL_ATTRS: Lazy> = Lazy::new(|| { TYPE_ATTR, SYMBOL_ATTR, IS_REFERENCE_ATTR, - TAG_ATTR, PARENTS_ATTR, ]) }); @@ -590,8 +550,6 @@ pub enum BuildError { ExecutionError(ExecutionError), #[error("Expected exported symbol scope in {0}, got {1}")] SymbolScopeError(String, String), - #[error("Unknown tag ‘{0}’")] - UnknownTag(String), #[error("Parent must be either a reference or definition")] InvalidParent(GraphNodeRef), } @@ -934,16 +892,6 @@ impl<'a, KT: KindTypes> Builder<'a, KT> { None => Vec::new(), }; - let tag = match node.attributes.get(TAG_ATTR) { - Some(tag_value) => Some(match tag_value.as_str()? { - "alias" => Tag::Alias, - "c3" => Tag::C3, - "super" => Tag::Super, - other_type => return Err(BuildError::UnknownTag(other_type.to_string())), - }), - None => None, - }; - if stack_graph_node.is_definition() { let definiens = match node.attributes.get(DEFINIENS_NODE_ATTR) { Some(definiens_node) => { @@ -967,7 +915,6 @@ impl<'a, KT: KindTypes> Builder<'a, KT> { node_handle, DefinitionBindingInfo { definiens, - tag, parents, extension_scope, inherit_extensions, @@ -975,7 +922,7 @@ impl<'a, KT: KindTypes> Builder<'a, KT> { ); } else if stack_graph_node.is_reference() { self.references_info - .insert(node_handle, ReferenceBindingInfo { tag, parents }); + .insert(node_handle, ReferenceBindingInfo { parents }); } if Self::load_flag(node, EXTENSION_HOOK_ATTR)? { diff --git a/crates/metaslang/bindings/src/lib.rs b/crates/metaslang/bindings/src/lib.rs index 6c658b1083..bf7121ffeb 100644 --- a/crates/metaslang/bindings/src/lib.rs +++ b/crates/metaslang/bindings/src/lib.rs @@ -23,23 +23,14 @@ type CursorID = usize; pub use location::{BindingLocation, BuiltInLocation, UserFileLocation}; -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub(crate) enum Tag { - Alias, - C3, - Super, -} - pub(crate) struct DefinitionBindingInfo { definiens: Option>, - tag: Option, parents: Vec, extension_scope: Option, inherit_extensions: bool, } pub(crate) struct ReferenceBindingInfo { - tag: Option, parents: Vec, } diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index fb494632f1..f9dd24dc1b 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -239,7 +239,6 @@ inherit .star_extension node def attr (def) node_definition = @name attr (def) definiens_node = @symbol - attr (def) tag = "alias" ; deprioritize this definition edge @symbol.def -> def node import @@ -256,7 +255,6 @@ inherit .star_extension node def attr (def) node_definition = @alias attr (def) definiens_node = @symbol - attr (def) tag = "alias" ; deprioritize this definition edge @symbol.def -> def node import @@ -563,7 +561,6 @@ inherit .star_extension ;; This may prioritize this definition (when there are multiple options) ;; according to the C3 linerisation ordering - attr (@function.def) tag = "c3" attr (@function.def) parents = [@contract.def] } @@ -585,7 +582,6 @@ inherit .star_extension ;; This may prioritize this definition (when there are multiple options) ;; according to the C3 linerisation ordering - attr (@modifier.def) tag = "c3" attr (@modifier.def) parents = [@contract.def] } @@ -2320,15 +2316,6 @@ inherit .star_extension edge member -> @expr.star_extension } -;; Special case: member accesses to `super` are tagged with "super" to rank -;; virtual methods correctly -[MemberAccessExpression - operand: [Expression [SuperKeyword]] - @name member: [Identifier] -] { - 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 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 c009037262..6fc48e2d3c 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 @@ -244,7 +244,6 @@ inherit .star_extension node def attr (def) node_definition = @name attr (def) definiens_node = @symbol - attr (def) tag = "alias" ; deprioritize this definition edge @symbol.def -> def node import @@ -261,7 +260,6 @@ inherit .star_extension node def attr (def) node_definition = @alias attr (def) definiens_node = @symbol - attr (def) tag = "alias" ; deprioritize this definition edge @symbol.def -> def node import @@ -568,7 +566,6 @@ inherit .star_extension ;; This may prioritize this definition (when there are multiple options) ;; according to the C3 linerisation ordering - attr (@function.def) tag = "c3" attr (@function.def) parents = [@contract.def] } @@ -590,7 +587,6 @@ inherit .star_extension ;; This may prioritize this definition (when there are multiple options) ;; according to the C3 linerisation ordering - attr (@modifier.def) tag = "c3" attr (@modifier.def) parents = [@contract.def] } @@ -2325,15 +2321,6 @@ inherit .star_extension edge member -> @expr.star_extension } -;; Special case: member accesses to `super` are tagged with "super" to rank -;; virtual methods correctly -[MemberAccessExpression - operand: [Expression [SuperKeyword]] - @name member: [Identifier] -] { - 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 From 02905e44fcc5c6c918f1a9a74254676233eddfc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 17 Dec 2024 16:26:15 -0500 Subject: [PATCH 14/16] Update perf tests resolved reference count --- crates/solidity/testing/perf/src/tests/references.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/solidity/testing/perf/src/tests/references.rs b/crates/solidity/testing/perf/src/tests/references.rs index be54ac9a18..9ba38d9f31 100644 --- a/crates/solidity/testing/perf/src/tests/references.rs +++ b/crates/solidity/testing/perf/src/tests/references.rs @@ -26,7 +26,7 @@ pub fn run(binding_graph: BindingGraph) { assert_eq!(reference_count, 1652, "Failed to fetch all references"); assert_eq!( - resolved_references, 1409, + resolved_references, 1490, "Failed to resolve all references" ); } From cb802ad74ef6a36802b0c521094720af12d47001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Tue, 17 Dec 2024 17:39:18 -0500 Subject: [PATCH 15/16] Formatting fixes --- crates/metaslang/bindings/src/builder/mod.rs | 10 ++-------- crates/metaslang/bindings/src/lib.rs | 4 +--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/crates/metaslang/bindings/src/builder/mod.rs b/crates/metaslang/bindings/src/builder/mod.rs index 5ef0ca0610..77943da877 100644 --- a/crates/metaslang/bindings/src/builder/mod.rs +++ b/crates/metaslang/bindings/src/builder/mod.rs @@ -355,14 +355,8 @@ static PUSH_SCOPED_SYMBOL_ATTRS: Lazy> = Lazy::new(|| { PARENTS_ATTR, ]) }); -static PUSH_SYMBOL_ATTRS: Lazy> = Lazy::new(|| { - HashSet::from([ - TYPE_ATTR, - SYMBOL_ATTR, - IS_REFERENCE_ATTR, - PARENTS_ATTR, - ]) -}); +static PUSH_SYMBOL_ATTRS: Lazy> = + Lazy::new(|| HashSet::from([TYPE_ATTR, SYMBOL_ATTR, IS_REFERENCE_ATTR, PARENTS_ATTR])); static SCOPE_ATTRS: Lazy> = Lazy::new(|| { HashSet::from([ TYPE_ATTR, diff --git a/crates/metaslang/bindings/src/lib.rs b/crates/metaslang/bindings/src/lib.rs index bf7121ffeb..1588e48bdc 100644 --- a/crates/metaslang/bindings/src/lib.rs +++ b/crates/metaslang/bindings/src/lib.rs @@ -433,9 +433,7 @@ impl<'a, KT: KindTypes + 'static> Reference<'a, KT> { Resolver::build_for(self, ResolveOptions::Full).all() } - pub(crate) fn non_recursive_resolve( - &self, - ) -> Vec> { + pub(crate) fn non_recursive_resolve(&self) -> Vec> { // This was likely originated from a full resolution call, so cut // recursion here by restricting the resolution algorithm. Resolver::build_for(self, ResolveOptions::NonRecursive).all() From afed0c9cfccf56607083479c538b0344d2d56182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gir=C3=A1ldez?= Date: Mon, 23 Dec 2024 12:20:34 -0500 Subject: [PATCH 16/16] Add precedence to contract members and top-level definitions This fixes some ambiguities especially with built-ins. --- .../inputs/language/bindings/rules.msgb | 3 ++ .../bindings/generated/binding_rules.rs | 3 ++ .../src/bindings_output/generated/scoping.rs | 5 ++ .../shadowing/generated/0.4.11-failure.txt | 12 +++-- .../shadowing/generated/0.6.0-failure.txt | 12 +++-- .../shadowing/generated/0.7.1-success.txt | 11 ++++- .../built_ins/shadowing/input.sol | 4 ++ .../shadowing/generated/0.4.11-failure.txt | 13 +++++ .../shadowing/generated/0.6.0-failure.txt | 13 +++++ .../shadowing/generated/0.7.1-success.txt | 47 +++++++++++++++++++ .../scoping/shadowing/input.sol | 18 +++++++ 11 files changed, 129 insertions(+), 12 deletions(-) create mode 100644 crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/generated/0.4.11-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/generated/0.6.0-failure.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/generated/0.7.1-success.txt create mode 100644 crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/input.sol diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index f9dd24dc1b..28b345259a 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -93,6 +93,8 @@ inherit .star_extension )] ]] { edge @source_unit.lexical_scope -> @unit_member.def + attr (@source_unit.lexical_scope -> @unit_member.def) precedence = 1 + edge @source_unit.defs -> @unit_member.def ; In the general case, the lexical scope of the definition connects directly @@ -342,6 +344,7 @@ inherit .star_extension attr (@contract.def) extension_scope = @contract.extensions edge @contract.lexical_scope -> @contract.instance + attr (@contract.lexical_scope -> @contract.instance) precedence = 1 ; Instance scope can also see members and our namespace definitions edge @contract.instance -> @contract.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 6fc48e2d3c..62050f7e96 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 @@ -98,6 +98,8 @@ inherit .star_extension )] ]] { edge @source_unit.lexical_scope -> @unit_member.def + attr (@source_unit.lexical_scope -> @unit_member.def) precedence = 1 + edge @source_unit.defs -> @unit_member.def ; In the general case, the lexical scope of the definition connects directly @@ -347,6 +349,7 @@ inherit .star_extension attr (@contract.def) extension_scope = @contract.extensions edge @contract.lexical_scope -> @contract.instance + attr (@contract.lexical_scope -> @contract.instance) precedence = 1 ; Instance scope can also see members and our namespace definitions edge @contract.instance -> @contract.members diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/scoping.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/scoping.rs index bb84c54ee9..62b8bfcaa9 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/scoping.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/scoping.rs @@ -18,3 +18,8 @@ fn functions() -> Result<()> { fn hoisting_scopes() -> Result<()> { run("scoping", "hoisting_scopes") } + +#[test] +fn shadowing() -> Result<()> { + run("scoping", "shadowing") +} diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.4.11-failure.txt index 8c91b0251a..78a48ef873 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.4.11-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.4.11-failure.txt @@ -4,9 +4,11 @@ Parse errors: Error: Expected ContractKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword. ╭─[input.sol:14:1] │ - 14 │ function sha256() {} - │ ──────────┬────────── - │ ╰──────────── Error occurred here. + 14 │ ╭─▶ function sha256() {} + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. ────╯ References and definitions: ╭─[input.sol:1:1] @@ -29,10 +31,10 @@ References and definitions: │ ╰──── ref: 4 7 │ tx; │ ─┬ - │ ╰── refs: 2, built-in + │ ╰── ref: 2 8 │ sha256(); │ ───┬── - │ ╰──── refs: 5, built-in + │ ╰──── ref: 5 │ 11 │ function sha256() public {} │ ───┬── diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.6.0-failure.txt index c4d155083b..138fc56f6a 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.6.0-failure.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.6.0-failure.txt @@ -4,9 +4,11 @@ Parse errors: Error: Expected ContractKeyword or EnumKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword or StructKeyword. ╭─[input.sol:14:1] │ - 14 │ function sha256() {} - │ ──────────┬────────── - │ ╰──────────── Error occurred here. + 14 │ ╭─▶ function sha256() {} + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. ────╯ References and definitions: ╭─[input.sol:1:1] @@ -29,10 +31,10 @@ References and definitions: │ ╰──── ref: 4 7 │ tx; │ ─┬ - │ ╰── refs: 2, built-in + │ ╰── ref: 2 8 │ sha256(); │ ───┬── - │ ╰──── refs: 5, built-in + │ ╰──── ref: 5 │ 11 │ function sha256() public {} │ ───┬── diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.7.1-success.txt b/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.7.1-success.txt index 89b9b0e9e7..8dcd163b81 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.7.1-success.txt +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/generated/0.7.1-success.txt @@ -21,10 +21,10 @@ References and definitions: │ ╰──── ref: 4 7 │ tx; │ ─┬ - │ ╰── refs: 2, built-in + │ ╰── ref: 2 8 │ sha256(); │ ───┬── - │ ╰──── refs: 6, 5, built-in + │ ╰──── ref: 5 │ 11 │ function sha256() public {} │ ───┬── @@ -33,4 +33,11 @@ References and definitions: 14 │ function sha256() {} │ ───┬── │ ╰──── def: 6 + │ + 16 │ function top_level() { + │ ────┬──── + │ ╰────── def: 7 + 17 │ sha256(); + │ ───┬── + │ ╰──── ref: 6 ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/input.sol b/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/input.sol index 8b9de97686..f3cf2ca143 100644 --- a/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/input.sol +++ b/crates/solidity/testing/snapshots/bindings_output/built_ins/shadowing/input.sol @@ -12,3 +12,7 @@ contract Test { } function sha256() {} + +function top_level() { + sha256(); +} diff --git a/crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..a03488ff31 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/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 │ ╭─▶ function foo() {} + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..4cd2844ceb --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/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 │ ╭─▶ function foo() {} + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: diff --git a/crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/generated/0.7.1-success.txt b/crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/generated/0.7.1-success.txt new file mode 100644 index 0000000000..7927f0259a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/generated/0.7.1-success.txt @@ -0,0 +1,47 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ function foo() {} + │ ─┬─ + │ ╰─── def: 1 + 2 │ function bar() {} + │ ─┬─ + │ ╰─── def: 2 + │ + 4 │ contract Base { + │ ──┬─ + │ ╰─── def: 3 + 5 │ function bar() public {} + │ ─┬─ + │ ╰─── def: 4 + │ + 8 │ contract Test is Base { + │ ──┬─ ──┬─ + │ ╰─────────── def: 5 + │ │ + │ ╰─── ref: 3 + 9 │ int x; + │ ┬ + │ ╰── def: 6 + │ + 11 │ function test(int x) public { + │ ──┬─ ┬ + │ ╰───────── def: 7 + │ │ + │ ╰── def: 8 + 12 │ foo(); + │ ─┬─ + │ ╰─── ref: 9 + 13 │ bar(); + │ ─┬─ + │ ╰─── ref: 4 + 14 │ x; + │ ┬ + │ ╰── ref: 8 + │ + 17 │ function foo() internal {} + │ ─┬─ + │ ╰─── def: 9 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/input.sol b/crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/input.sol new file mode 100644 index 0000000000..914bdc9b1c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/scoping/shadowing/input.sol @@ -0,0 +1,18 @@ +function foo() {} +function bar() {} + +contract Base { + function bar() public {} +} + +contract Test is Base { + int x; + + function test(int x) public { + foo(); + bar(); + x; + } + + function foo() internal {} +}