diff --git a/crates/codegen/testing/src/bindings_output.rs b/crates/codegen/testing/src/bindings_output.rs index 826aaf8252..0129cff3ad 100644 --- a/crates/codegen/testing/src/bindings_output.rs +++ b/crates/codegen/testing/src/bindings_output.rs @@ -9,7 +9,7 @@ use infra_utils::codegen::CodegenFileSystem; use infra_utils::paths::FileWalker; pub fn generate_bindings_output_tests( - _language: &Language, + language: &Language, data_dir: &Path, output_dir: &Path, ) -> Result<()> { @@ -17,7 +17,7 @@ pub fn generate_bindings_output_tests( let mut fs = CodegenFileSystem::new(data_dir)?; - generate_mod_file(&mut fs, &output_dir.join("mod.rs"), &tests)?; + generate_mod_file(language, &mut fs, &output_dir.join("mod.rs"), &tests)?; for (group_name, test_files) in &tests { generate_unit_test_file( @@ -58,6 +58,7 @@ fn collect_bindings_tests(data_dir: &Path) -> Result>, @@ -70,9 +71,28 @@ fn generate_mod_file( buffer }); + let version_breaks = language.collect_breaking_versions(); + let version_breaks_len = version_breaks.len(); + let version_breaks_str = version_breaks + .iter() + .fold(String::new(), |mut buffer, version| { + writeln!( + buffer, + "Version::new({}, {}, {}),", + version.major, version.minor, version.patch + ) + .unwrap(); + buffer + }); + let contents = format!( " + use semver::Version; {module_declarations_str} + + pub const VERSION_BREAKS: [Version; {version_breaks_len}] = [ + {version_breaks_str} + ]; ", ); 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 6c44b6f97e..1635c52c11 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 @@ -1,3 +1,40 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. +use semver::Version; mod lexical; + +pub const VERSION_BREAKS: [Version; 33] = [ + Version::new(0, 4, 11), + Version::new(0, 4, 12), + Version::new(0, 4, 14), + Version::new(0, 4, 16), + Version::new(0, 4, 21), + Version::new(0, 4, 22), + Version::new(0, 4, 25), + Version::new(0, 5, 0), + Version::new(0, 5, 3), + Version::new(0, 5, 5), + Version::new(0, 5, 8), + Version::new(0, 5, 10), + Version::new(0, 5, 12), + Version::new(0, 5, 14), + Version::new(0, 6, 0), + Version::new(0, 6, 2), + Version::new(0, 6, 5), + Version::new(0, 6, 7), + Version::new(0, 6, 8), + Version::new(0, 6, 11), + Version::new(0, 7, 0), + Version::new(0, 7, 1), + Version::new(0, 7, 4), + Version::new(0, 8, 0), + Version::new(0, 8, 4), + Version::new(0, 8, 7), + Version::new(0, 8, 8), + Version::new(0, 8, 10), + Version::new(0, 8, 13), + Version::new(0, 8, 18), + Version::new(0, 8, 19), + Version::new(0, 8, 22), + Version::new(0, 8, 24), +]; 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 1ceb9de308..ac34148627 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/runner.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/runner.rs @@ -1,7 +1,8 @@ use std::fmt; -use std::fs::{self, create_dir_all, File}; +use std::fs::{self, create_dir_all}; +use std::io::BufWriter; use std::ops::Range; -use std::path::{Path, PathBuf}; +use std::path::Path; use anyhow::Result; use ariadne::{Color, Config, Label, Report, ReportBuilder, ReportKind, Source}; @@ -15,6 +16,8 @@ use slang_solidity::bindings::{Bindings, Handle}; use slang_solidity::language::Language; use slang_solidity::parse_output::ParseOutput; +use super::generated::VERSION_BREAKS; + pub fn run(group_name: &str, file_name: &str) -> Result<()> { let data_dir = CargoWorkspace::locate_source_crate("solidity_testing_snapshots")? .join("bindings_output") @@ -22,27 +25,38 @@ pub fn run(group_name: &str, file_name: &str) -> Result<()> { let input_path = data_dir.join(file_name); let input = fs::read_to_string(&input_path)?; - // TODO: de-hardcode this and parse with different versions? - let version = Language::SUPPORTED_VERSIONS.last().unwrap(); - let language = Language::new(version.clone())?; + let mut last_graph_output = None; + let mut last_bindings_output = None; - let parse_output = language.parse(Language::ROOT_KIND, &input); - assert!(parse_output.is_valid()); + for version in &VERSION_BREAKS { + let language = Language::new(version.clone())?; - let output_dir = data_dir.join("generated"); - create_dir_all(&output_dir)?; + let parse_output = language.parse(Language::ROOT_KIND, &input); + assert!(parse_output.is_valid()); - let graph_output_path = output_dir.join(format!("{file_name}.mmd")); - output_graph(version, &parse_output, graph_output_path)?; + let output_dir = data_dir.join("generated"); + create_dir_all(&output_dir)?; - let bindings_output_path = output_dir.join(format!("{file_name}.txt")); - output_bindings( - version, - &parse_output, - &input, - &input_path, - bindings_output_path, - )?; + let graph_output = output_graph(version, &parse_output)?; + match last_graph_output { + Some(ref last) if last == &graph_output => (), + _ => { + let graph_output_path = output_dir.join(format!("{file_name}-{version}.mmd")); + fs::write(graph_output_path, &graph_output)?; + last_graph_output = Some(graph_output); + } + }; + + let bindings_output = output_bindings(version, &parse_output, &input, &input_path)?; + match last_bindings_output { + Some(ref last) if last == &bindings_output => (), + _ => { + let bindings_output_path = output_dir.join(format!("{file_name}-{version}.txt")); + fs::write(bindings_output_path, &bindings_output)?; + last_bindings_output = Some(bindings_output); + } + } + } Ok(()) } @@ -54,7 +68,7 @@ const VARIABLE_DEBUG_ATTR: &str = "__variable"; const LOCATION_DEBUG_ATTR: &str = "__location"; const MATCH_DEBUG_ATTR: &str = "__match"; -fn output_graph(version: &Version, parse_output: &ParseOutput, output_path: PathBuf) -> Result<()> { +fn output_graph(version: &Version, parse_output: &ParseOutput) -> Result { let graph_builder = Bindings::get_graph_builder()?; let tree = parse_output.create_tree_cursor(); @@ -77,9 +91,7 @@ fn output_graph(version: &Version, parse_output: &ParseOutput, output_path: Path graph_builder.execute_into(&mut graph, &tree, &execution_config, &NoCancellation)?; - fs::write(output_path, format!("{}", print_graph_as_mermaid(&graph)))?; - - Ok(()) + Ok(format!("{}", print_graph_as_mermaid(&graph))) } fn print_graph_as_mermaid(graph: &Graph) -> impl fmt::Display + '_ { @@ -133,8 +145,7 @@ fn output_bindings( parse_output: &ParseOutput, input: &str, input_path: &Path, - output_path: PathBuf, -) -> Result<()> { +) -> Result { let mut bindings = Bindings::create(version.clone()); bindings.add_file( input_path.to_str().unwrap(), @@ -193,8 +204,9 @@ fn output_bindings( } let report = builder.finish(); - let output_file = File::create(output_path)?; - report.write((file_id, Source::from(input)), output_file)?; + let mut buffer = BufWriter::new(Vec::new()); + report.write((file_id, Source::from(input)), &mut buffer)?; - Ok(()) + let result = String::from_utf8(buffer.buffer().to_vec())?; + Ok(result) } diff --git a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/local_vars.sol-0.4.11.mmd b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/local_vars.sol-0.4.11.mmd new file mode 100644 index 0000000000..6584c20616 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/local_vars.sol-0.4.11.mmd @@ -0,0 +1,148 @@ +graph TD + N0["`**0** @(1, 1) +ROOT_NODE +#null`"] + N1["`**1** @(1, 1) +@source_unit.lexical_scope +line 20 column 21`"] + N1 --> N4 + N2["`**2** @(1, 1) +@source_unit.defs +line 23 column 21`"] + N2 --> N4 + N3["`**3** @(1, 1) +@definition.lexical_scope +line 39 column 20`"] + N3 --> N1 + N3 --> N6 + N3 --> N8 + N4["`**4** @(1, 1) +@definition.defs +line 40 column 20`"] + N4 --> N9 + N5["`**5** @(2, 1) +@definition.lexical_scope +line 39 column 20`"] + N5 --> N3 + N5 --> N13 + N6["`**6** @(2, 1) +@definition.defs +line 40 column 20`"] + N6 --> N10 + N7["`**7** @(6, 1) +@definition.lexical_scope +line 39 column 20`"] + N7 --> N3 + N7 --> N15 + N8["`**8** @(6, 1) +@definition.defs +line 40 column 20`"] + N8 --> N11 + N9[\"`**Foo** @(1, 1) +def +line 75 column 8`"/] + N10[\"`**bar** @(2, 1) +def +line 96 column 8`"/] + N11[\"`**baz** @(6, 1) +def +line 96 column 8`"/] + N12["`**12** @(2, 29) +@param.lexical_scope +line 108 column 15`"] + N12 --> N5 + N13["`**13** @(2, 29) +@param.defs +line 109 column 15`"] + N14["`**14** @(7, 29) +@param.lexical_scope +line 108 column 15`"] + N14 --> N7 + N15["`**15** @(7, 29) +@param.defs +line 109 column 15`"] + N16["`**16** @(2, 34) +@block.lexical_scope +line 183 column 15`"] + N16 --> N5 + N16 --> N21 + N16 --> N23 + N17["`**17** @(2, 34) +@block.defs +line 184 column 15`"] + N17 --> N21 + N17 --> N23 + N18["`**18** @(7, 33) +@block.lexical_scope +line 183 column 15`"] + N18 --> N7 + N18 --> N25 + N19["`**19** @(7, 33) +@block.defs +line 184 column 15`"] + N19 --> N25 + N20["`**20** @(3, 1) +@stmt.lexical_scope +line 188 column 14`"] + N20 --> N16 + N21["`**21** @(3, 1) +@stmt.defs +line 189 column 14`"] + N21 --> N26 + N22["`**22** @(4, 1) +@stmt.lexical_scope +line 188 column 14`"] + N22 --> N16 + N23["`**23** @(4, 1) +@stmt.defs +line 189 column 14`"] + N24["`**24** @(8, 1) +@stmt.lexical_scope +line 188 column 14`"] + N24 --> N18 + N25["`**25** @(8, 1) +@stmt.defs +line 189 column 14`"] + N26[\"`**x** @(3, 1) +def +line 250 column 8`"/] + N27["`**27** @(3, 17) +@expr.lexical_scope +line 338 column 14`"] + N27 --> N20 + N28["`**28** @(4, 15) +@expr.lexical_scope +line 338 column 14`"] + N28 --> N22 + N29["`**29** @(4, 15) +@expr.lexical_scope +line 338 column 14`"] + N29 --> N28 + N30["`**30** @(4, 19) +@expr.lexical_scope +line 338 column 14`"] + N30 --> N28 + N31["`**31** @(8, 15) +@expr.lexical_scope +line 338 column 14`"] + N31 --> N24 + N32["`**32** @(8, 15) +@expr.lexical_scope +line 338 column 14`"] + N32 --> N31 + N33["`**33** @(8, 19) +@expr.lexical_scope +line 338 column 14`"] + N33 --> N31 + N34[/"`**x** @(4, 15) +ref +line 342 column 8`"\] + N34 --> N29 + N35[/"`**w** @(8, 15) +ref +line 342 column 8`"\] + N35 --> N32 + N36[/"`**x** @(8, 19) +ref +line 342 column 8`"\] + N36 --> N33 diff --git a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/local_vars.sol-0.4.11.txt b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/local_vars.sol-0.4.11.txt new file mode 100644 index 0000000000..3c00c4f7d5 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/local_vars.sol-0.4.11.txt @@ -0,0 +1,25 @@ +References and definitions: + ╭─[local_vars.sol:1:1] + │ + 1 │ contract Foo { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function bar() returns (uint) { + │ ─┬─ + │ ╰─── def: 2 + 3 │ uint x = 10; + │ ┬ + │ ╰── def: 3 + 4 │ return x + 2; + │ ┬ + │ ╰── ref: 3 + │ + 7 │ function baz() returns (int) { + │ ─┬─ + │ ╰─── def: 4 + 8 │ return w + x; + │ ┬ ┬ + │ ╰────── unresolved + │ │ + │ ╰── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/local_vars.sol.mmd b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/local_vars.sol-0.5.0.mmd similarity index 83% rename from crates/solidity/testing/snapshots/bindings_output/lexical/generated/local_vars.sol.mmd rename to crates/solidity/testing/snapshots/bindings_output/lexical/generated/local_vars.sol-0.5.0.mmd index 1da799b5f4..b558c9da3c 100644 --- a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/local_vars.sol.mmd +++ b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/local_vars.sol-0.5.0.mmd @@ -29,12 +29,12 @@ line 39 column 20`"] @definition.defs line 40 column 20`"] N6 --> N10 - N7["`**7** @(9, 1) + N7["`**7** @(6, 1) @definition.lexical_scope line 39 column 20`"] N7 --> N3 N7 --> N15 - N8["`**8** @(9, 1) + N8["`**8** @(6, 1) @definition.defs line 40 column 20`"] N8 --> N11 @@ -44,7 +44,7 @@ line 75 column 8`"/] N10[\"`**bar** @(2, 1) def line 96 column 8`"/] - N11[\"`**baz** @(9, 1) + N11[\"`**baz** @(6, 1) def line 96 column 8`"/] N12["`**12** @(2, 29) @@ -54,11 +54,11 @@ line 108 column 15`"] N13["`**13** @(2, 29) @param.defs line 109 column 15`"] - N14["`**14** @(10, 29) + N14["`**14** @(7, 29) @param.lexical_scope line 108 column 15`"] N14 --> N7 - N15["`**15** @(10, 29) + N15["`**15** @(7, 29) @param.defs line 109 column 15`"] N16["`**16** @(2, 34) @@ -68,11 +68,11 @@ line 183 column 15`"] N17["`**17** @(2, 34) @block.defs line 184 column 15`"] - N18["`**18** @(10, 33) + N18["`**18** @(7, 33) @block.lexical_scope line 183 column 15`"] N18 --> N7 - N19["`**19** @(10, 33) + N19["`**19** @(7, 33) @block.defs line 184 column 15`"] N20["`**20** @(3, 1) @@ -92,12 +92,12 @@ line 188 column 14`"] N23["`**23** @(4, 1) @stmt.defs line 189 column 14`"] - N24["`**24** @(11, 1) + N24["`**24** @(8, 1) @stmt.lexical_scope line 188 column 14`"] N24 --> N18 N24 --> N25 - N25["`**25** @(11, 1) + N25["`**25** @(8, 1) @stmt.defs line 189 column 14`"] N26[\"`**x** @(3, 1) @@ -107,39 +107,39 @@ line 250 column 8`"/] @expr.lexical_scope line 338 column 14`"] N27 --> N20 - N28["`**28** @(6, 15) + N28["`**28** @(4, 15) @expr.lexical_scope line 338 column 14`"] N28 --> N22 - N29["`**29** @(6, 15) + N29["`**29** @(4, 15) @expr.lexical_scope line 338 column 14`"] N29 --> N28 - N30["`**30** @(6, 19) + N30["`**30** @(4, 19) @expr.lexical_scope line 338 column 14`"] N30 --> N28 - N31["`**31** @(11, 15) + N31["`**31** @(8, 15) @expr.lexical_scope line 338 column 14`"] N31 --> N24 - N32["`**32** @(11, 15) + N32["`**32** @(8, 15) @expr.lexical_scope line 338 column 14`"] N32 --> N31 - N33["`**33** @(11, 19) + N33["`**33** @(8, 19) @expr.lexical_scope line 338 column 14`"] N33 --> N31 - N34[/"`**x** @(6, 15) + N34[/"`**x** @(4, 15) ref line 342 column 8`"\] N34 --> N29 - N35[/"`**w** @(11, 15) + N35[/"`**w** @(8, 15) ref line 342 column 8`"\] N35 --> N32 - N36[/"`**x** @(11, 19) + N36[/"`**x** @(8, 19) ref line 342 column 8`"\] N36 --> N33 diff --git a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/local_vars.sol.txt b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/local_vars.sol.txt deleted file mode 100644 index 6f0f443eaa..0000000000 --- a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/local_vars.sol.txt +++ /dev/null @@ -1,26 +0,0 @@ -References and definitions: - ╭─[local_vars.sol:1:1] - │ - 1 │ contract Foo { - │ ─┬─ - │ ╰─── def: 1 - 2 │ function bar() returns (uint) { - │ ─┬─ - │ ╰─── def: 2 - 3 │ uint x = 10; - │ ┬ - │ ╰── def: 3 - │ - 6 │ return x + 2; - │ ┬ - │ ╰── ref: 3 - │ - 10 │ function baz() returns (int) { - │ ─┬─ - │ ╰─── def: 4 - 11 │ return w + x; - │ ┬ ┬ - │ ╰────── unresolved - │ │ - │ ╰── unresolved -────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/params.sol-0.4.11.mmd b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/params.sol-0.4.11.mmd new file mode 100644 index 0000000000..a711772c2c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/params.sol-0.4.11.mmd @@ -0,0 +1,139 @@ +graph TD + N0["`**0** @(1, 1) +ROOT_NODE +#null`"] + N1["`**1** @(1, 1) +@source_unit.lexical_scope +line 20 column 21`"] + N1 --> N4 + N2["`**2** @(1, 1) +@source_unit.defs +line 23 column 21`"] + N2 --> N4 + N3["`**3** @(1, 1) +@definition.lexical_scope +line 39 column 20`"] + N3 --> N1 + N3 --> N6 + N3 --> N8 + N4["`**4** @(1, 1) +@definition.defs +line 40 column 20`"] + N4 --> N9 + N5["`**5** @(2, 1) +@definition.lexical_scope +line 39 column 20`"] + N5 --> N3 + N5 --> N13 + N5 --> N15 + N6["`**6** @(2, 1) +@definition.defs +line 40 column 20`"] + N6 --> N10 + N7["`**7** @(5, 1) +@definition.lexical_scope +line 39 column 20`"] + N7 --> N3 + N7 --> N17 + N8["`**8** @(5, 1) +@definition.defs +line 40 column 20`"] + N8 --> N11 + N9[\"`**Foo** @(1, 1) +def +line 75 column 8`"/] + N10[\"`**bar** @(2, 1) +def +line 96 column 8`"/] + N11[\"`**baz** @(5, 1) +def +line 96 column 8`"/] + N12["`**12** @(2, 18) +@param.lexical_scope +line 108 column 15`"] + N12 --> N5 + N13["`**13** @(2, 18) +@param.defs +line 109 column 15`"] + N13 --> N18 + N14["`**14** @(2, 35) +@param.lexical_scope +line 108 column 15`"] + N14 --> N5 + N15["`**15** @(2, 35) +@param.defs +line 109 column 15`"] + N16["`**16** @(6, 29) +@param.lexical_scope +line 108 column 15`"] + N16 --> N7 + N17["`**17** @(6, 29) +@param.defs +line 109 column 15`"] + N18[\"`**z** @(2, 18) +def +line 113 column 8`"/] + N19["`**19** @(2, 40) +@block.lexical_scope +line 183 column 15`"] + N19 --> N5 + N19 --> N24 + N20["`**20** @(2, 40) +@block.defs +line 184 column 15`"] + N20 --> N24 + N21["`**21** @(6, 33) +@block.lexical_scope +line 183 column 15`"] + N21 --> N7 + N21 --> N26 + N22["`**22** @(6, 33) +@block.defs +line 184 column 15`"] + N22 --> N26 + N23["`**23** @(3, 1) +@stmt.lexical_scope +line 188 column 14`"] + N23 --> N19 + N24["`**24** @(3, 1) +@stmt.defs +line 189 column 14`"] + N25["`**25** @(7, 1) +@stmt.lexical_scope +line 188 column 14`"] + N25 --> N21 + N26["`**26** @(7, 1) +@stmt.defs +line 189 column 14`"] + N27["`**27** @(3, 15) +@expr.lexical_scope +line 338 column 14`"] + N27 --> N23 + N28["`**28** @(3, 15) +@expr.lexical_scope +line 338 column 14`"] + N28 --> N27 + N29["`**29** @(3, 19) +@expr.lexical_scope +line 338 column 14`"] + N29 --> N27 + N30["`**30** @(7, 15) +@expr.lexical_scope +line 338 column 14`"] + N30 --> N25 + N31["`**31** @(7, 15) +@expr.lexical_scope +line 338 column 14`"] + N31 --> N30 + N32["`**32** @(7, 19) +@expr.lexical_scope +line 338 column 14`"] + N32 --> N30 + N33[/"`**z** @(3, 15) +ref +line 342 column 8`"\] + N33 --> N28 + N34[/"`**z** @(7, 15) +ref +line 342 column 8`"\] + N34 --> N31 diff --git a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/params.sol-0.4.11.txt b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/params.sol-0.4.11.txt new file mode 100644 index 0000000000..6ca5ebfcbe --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/params.sol-0.4.11.txt @@ -0,0 +1,22 @@ +References and definitions: + ╭─[params.sol:1:1] + │ + 1 │ contract Foo { + │ ─┬─ + │ ╰─── def: 1 + 2 │ function bar(uint z) returns (uint) { + │ ─┬─ ┬ + │ ╰────────── def: 2 + │ │ + │ ╰── def: 3 + 3 │ return z + 1; + │ ┬ + │ ╰── ref: 3 + │ + 6 │ function baz() returns (int) { + │ ─┬─ + │ ╰─── def: 4 + 7 │ return z + 2; + │ ┬ + │ ╰── unresolved +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/params.sol.mmd b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/params.sol-0.5.0.mmd similarity index 84% rename from crates/solidity/testing/snapshots/bindings_output/lexical/generated/params.sol.mmd rename to crates/solidity/testing/snapshots/bindings_output/lexical/generated/params.sol-0.5.0.mmd index 714396fce2..c318b02116 100644 --- a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/params.sol.mmd +++ b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/params.sol-0.5.0.mmd @@ -30,12 +30,12 @@ line 39 column 20`"] @definition.defs line 40 column 20`"] N6 --> N10 - N7["`**7** @(8, 1) + N7["`**7** @(5, 1) @definition.lexical_scope line 39 column 20`"] N7 --> N3 N7 --> N17 - N8["`**8** @(8, 1) + N8["`**8** @(5, 1) @definition.defs line 40 column 20`"] N8 --> N11 @@ -45,7 +45,7 @@ line 75 column 8`"/] N10[\"`**bar** @(2, 1) def line 96 column 8`"/] - N11[\"`**baz** @(8, 1) + N11[\"`**baz** @(5, 1) def line 96 column 8`"/] N12["`**12** @(2, 18) @@ -63,11 +63,11 @@ line 108 column 15`"] N15["`**15** @(2, 35) @param.defs line 109 column 15`"] - N16["`**16** @(9, 29) + N16["`**16** @(6, 29) @param.lexical_scope line 108 column 15`"] N16 --> N7 - N17["`**17** @(9, 29) + N17["`**17** @(6, 29) @param.defs line 109 column 15`"] N18[\"`**z** @(2, 18) @@ -80,11 +80,11 @@ line 183 column 15`"] N20["`**20** @(2, 40) @block.defs line 184 column 15`"] - N21["`**21** @(9, 33) + N21["`**21** @(6, 33) @block.lexical_scope line 183 column 15`"] N21 --> N7 - N22["`**22** @(9, 33) + N22["`**22** @(6, 33) @block.defs line 184 column 15`"] N23["`**23** @(3, 1) @@ -95,43 +95,43 @@ line 188 column 14`"] N24["`**24** @(3, 1) @stmt.defs line 189 column 14`"] - N25["`**25** @(10, 1) + N25["`**25** @(7, 1) @stmt.lexical_scope line 188 column 14`"] N25 --> N21 N25 --> N26 - N26["`**26** @(10, 1) + N26["`**26** @(7, 1) @stmt.defs line 189 column 14`"] - N27["`**27** @(5, 15) + N27["`**27** @(3, 15) @expr.lexical_scope line 338 column 14`"] N27 --> N23 - N28["`**28** @(5, 15) + N28["`**28** @(3, 15) @expr.lexical_scope line 338 column 14`"] N28 --> N27 - N29["`**29** @(5, 19) + N29["`**29** @(3, 19) @expr.lexical_scope line 338 column 14`"] N29 --> N27 - N30["`**30** @(10, 15) + N30["`**30** @(7, 15) @expr.lexical_scope line 338 column 14`"] N30 --> N25 - N31["`**31** @(10, 15) + N31["`**31** @(7, 15) @expr.lexical_scope line 338 column 14`"] N31 --> N30 - N32["`**32** @(10, 19) + N32["`**32** @(7, 19) @expr.lexical_scope line 338 column 14`"] N32 --> N30 - N33[/"`**z** @(5, 15) + N33[/"`**z** @(3, 15) ref line 342 column 8`"\] N33 --> N28 - N34[/"`**z** @(10, 15) + N34[/"`**z** @(7, 15) ref line 342 column 8`"\] N34 --> N31 diff --git a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/params.sol.txt b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/params.sol.txt deleted file mode 100644 index f39f9ec74e..0000000000 --- a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/params.sol.txt +++ /dev/null @@ -1,23 +0,0 @@ -References and definitions: - ╭─[params.sol:1:1] - │ - 1 │ contract Foo { - │ ─┬─ - │ ╰─── def: 1 - 2 │ function bar(uint z) returns (uint) { - │ ─┬─ ┬ - │ ╰────────── def: 2 - │ │ - │ ╰── def: 3 - │ - 5 │ return z + 1; - │ ┬ - │ ╰── ref: 3 - │ - 9 │ function baz() returns (int) { - │ ─┬─ - │ ╰─── def: 4 - 10 │ return z + 2; - │ ┬ - │ ╰── unresolved -────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/state_vars.sol-0.4.11.mmd b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/state_vars.sol-0.4.11.mmd new file mode 100644 index 0000000000..6285bc690f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/state_vars.sol-0.4.11.mmd @@ -0,0 +1,180 @@ +graph TD + N0["`**0** @(1, 1) +ROOT_NODE +#null`"] + N1["`**1** @(1, 1) +@source_unit.lexical_scope +line 20 column 21`"] + N1 --> N4 + N1 --> N10 + N2["`**2** @(1, 1) +@source_unit.defs +line 23 column 21`"] + N2 --> N4 + N2 --> N10 + N3["`**3** @(1, 1) +@definition.lexical_scope +line 39 column 20`"] + N3 --> N1 + N3 --> N6 + N3 --> N8 + N3 --> N37 + N4["`**4** @(1, 1) +@definition.defs +line 40 column 20`"] + N4 --> N13 + N5["`**5** @(3, 1) +@definition.lexical_scope +line 39 column 20`"] + N5 --> N3 + N5 --> N19 + N6["`**6** @(3, 1) +@definition.defs +line 40 column 20`"] + N6 --> N15 + N7["`**7** @(7, 1) +@definition.lexical_scope +line 39 column 20`"] + N7 --> N3 + N7 --> N21 + N8["`**8** @(7, 1) +@definition.defs +line 40 column 20`"] + N8 --> N16 + N9["`**9** @(12, 1) +@definition.lexical_scope +line 39 column 20`"] + N9 --> N1 + N9 --> N12 + N10["`**10** @(12, 1) +@definition.defs +line 40 column 20`"] + N10 --> N14 + N11["`**11** @(14, 1) +@definition.lexical_scope +line 39 column 20`"] + N11 --> N9 + N11 --> N23 + N12["`**12** @(14, 1) +@definition.defs +line 40 column 20`"] + N12 --> N17 + N13[\"`**Foo** @(1, 1) +def +line 75 column 8`"/] + N14[\"`**Bar** @(12, 1) +def +line 75 column 8`"/] + N15[\"`**bar** @(3, 1) +def +line 96 column 8`"/] + N16[\"`**baz** @(7, 1) +def +line 96 column 8`"/] + N17[\"`**quux** @(14, 1) +def +line 96 column 8`"/] + N18["`**18** @(4, 29) +@param.lexical_scope +line 108 column 15`"] + N18 --> N5 + N19["`**19** @(4, 29) +@param.defs +line 109 column 15`"] + N20["`**20** @(8, 29) +@param.lexical_scope +line 108 column 15`"] + N20 --> N7 + N21["`**21** @(8, 29) +@param.defs +line 109 column 15`"] + N22["`**22** @(14, 30) +@param.lexical_scope +line 108 column 15`"] + N22 --> N11 + N23["`**23** @(14, 30) +@param.defs +line 109 column 15`"] + N24["`**24** @(4, 34) +@block.lexical_scope +line 183 column 15`"] + N24 --> N5 + N24 --> N31 + N25["`**25** @(4, 34) +@block.defs +line 184 column 15`"] + N25 --> N31 + N26["`**26** @(8, 33) +@block.lexical_scope +line 183 column 15`"] + N26 --> N7 + N26 --> N33 + N27["`**27** @(8, 33) +@block.defs +line 184 column 15`"] + N27 --> N33 + N28["`**28** @(14, 35) +@block.lexical_scope +line 183 column 15`"] + N28 --> N11 + N28 --> N35 + N29["`**29** @(14, 35) +@block.defs +line 184 column 15`"] + N29 --> N35 + N30["`**30** @(5, 1) +@stmt.lexical_scope +line 188 column 14`"] + N30 --> N24 + N31["`**31** @(5, 1) +@stmt.defs +line 189 column 14`"] + N32["`**32** @(9, 1) +@stmt.lexical_scope +line 188 column 14`"] + N32 --> N26 + N33["`**33** @(9, 1) +@stmt.defs +line 189 column 14`"] + N34["`**34** @(15, 1) +@stmt.lexical_scope +line 188 column 14`"] + N34 --> N28 + N35["`**35** @(15, 1) +@stmt.defs +line 189 column 14`"] + N36["`**36** @(2, 1) +@state_var.lexical_scope +line 273 column 19`"] + N36 --> N3 + N37["`**37** @(2, 1) +@state_var.defs +line 274 column 19`"] + N37 --> N38 + N38[\"`**x** @(2, 1) +def +line 278 column 8`"/] + N39["`**39** @(5, 15) +@expr.lexical_scope +line 338 column 14`"] + N39 --> N30 + N40["`**40** @(9, 15) +@expr.lexical_scope +line 338 column 14`"] + N40 --> N32 + N41["`**41** @(15, 15) +@expr.lexical_scope +line 338 column 14`"] + N41 --> N34 + N42[/"`**x** @(5, 15) +ref +line 342 column 8`"\] + N42 --> N39 + N43[/"`**y** @(9, 15) +ref +line 342 column 8`"\] + N43 --> N40 + N44[/"`**x** @(15, 15) +ref +line 342 column 8`"\] + N44 --> N41 diff --git a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/state_vars.sol.txt b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/state_vars.sol-0.4.11.txt similarity index 77% rename from crates/solidity/testing/snapshots/bindings_output/lexical/generated/state_vars.sol.txt rename to crates/solidity/testing/snapshots/bindings_output/lexical/generated/state_vars.sol-0.4.11.txt index 7ebdec1747..dc057bc5f8 100644 --- a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/state_vars.sol.txt +++ b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/state_vars.sol-0.4.11.txt @@ -8,27 +8,27 @@ References and definitions: │ ┬ │ ╰── def: 2 │ - 5 │ function bar() returns (uint) { + 4 │ function bar() returns (uint) { │ ─┬─ │ ╰─── def: 3 - 6 │ return x; + 5 │ return x; │ ┬ │ ╰── ref: 2 │ - 10 │ function baz() returns (int) { + 8 │ function baz() returns (int) { │ ─┬─ │ ╰─── def: 4 - 11 │ return y; + 9 │ return y; │ ┬ │ ╰── unresolved │ - 16 │ contract Bar { + 13 │ contract Bar { │ ─┬─ │ ╰─── def: 5 - 17 │ function quux() returns (uint) { + 14 │ function quux() returns (uint) { │ ──┬─ │ ╰─── def: 6 - 18 │ return x; + 15 │ return x; │ ┬ │ ╰── unresolved ────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/state_vars.sol.mmd b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/state_vars.sol-0.5.0.mmd similarity index 75% rename from crates/solidity/testing/snapshots/bindings_output/lexical/generated/state_vars.sol.mmd rename to crates/solidity/testing/snapshots/bindings_output/lexical/generated/state_vars.sol-0.5.0.mmd index 6ed386e3e4..1d7a09086d 100644 --- a/crates/solidity/testing/snapshots/bindings_output/lexical/generated/state_vars.sol.mmd +++ b/crates/solidity/testing/snapshots/bindings_output/lexical/generated/state_vars.sol-0.5.0.mmd @@ -32,112 +32,112 @@ line 39 column 20`"] @definition.defs line 40 column 20`"] N6 --> N15 - N7["`**7** @(9, 1) + N7["`**7** @(7, 1) @definition.lexical_scope line 39 column 20`"] N7 --> N3 N7 --> N21 - N8["`**8** @(9, 1) + N8["`**8** @(7, 1) @definition.defs line 40 column 20`"] N8 --> N16 - N9["`**9** @(15, 1) + N9["`**9** @(12, 1) @definition.lexical_scope line 39 column 20`"] N9 --> N1 N9 --> N12 - N10["`**10** @(15, 1) + N10["`**10** @(12, 1) @definition.defs line 40 column 20`"] N10 --> N14 - N11["`**11** @(17, 1) + N11["`**11** @(14, 1) @definition.lexical_scope line 39 column 20`"] N11 --> N9 N11 --> N23 - N12["`**12** @(17, 1) + N12["`**12** @(14, 1) @definition.defs line 40 column 20`"] N12 --> N17 N13[\"`**Foo** @(1, 1) def line 75 column 8`"/] - N14[\"`**Bar** @(15, 1) + N14[\"`**Bar** @(12, 1) def line 75 column 8`"/] N15[\"`**bar** @(3, 1) def line 96 column 8`"/] - N16[\"`**baz** @(9, 1) + N16[\"`**baz** @(7, 1) def line 96 column 8`"/] - N17[\"`**quux** @(17, 1) + N17[\"`**quux** @(14, 1) def line 96 column 8`"/] - N18["`**18** @(5, 29) + N18["`**18** @(4, 29) @param.lexical_scope line 108 column 15`"] N18 --> N5 - N19["`**19** @(5, 29) + N19["`**19** @(4, 29) @param.defs line 109 column 15`"] - N20["`**20** @(10, 29) + N20["`**20** @(8, 29) @param.lexical_scope line 108 column 15`"] N20 --> N7 - N21["`**21** @(10, 29) + N21["`**21** @(8, 29) @param.defs line 109 column 15`"] - N22["`**22** @(17, 30) + N22["`**22** @(14, 30) @param.lexical_scope line 108 column 15`"] N22 --> N11 - N23["`**23** @(17, 30) + N23["`**23** @(14, 30) @param.defs line 109 column 15`"] - N24["`**24** @(5, 34) + N24["`**24** @(4, 34) @block.lexical_scope line 183 column 15`"] N24 --> N5 - N25["`**25** @(5, 34) + N25["`**25** @(4, 34) @block.defs line 184 column 15`"] - N26["`**26** @(10, 33) + N26["`**26** @(8, 33) @block.lexical_scope line 183 column 15`"] N26 --> N7 - N27["`**27** @(10, 33) + N27["`**27** @(8, 33) @block.defs line 184 column 15`"] - N28["`**28** @(17, 35) + N28["`**28** @(14, 35) @block.lexical_scope line 183 column 15`"] N28 --> N11 - N29["`**29** @(17, 35) + N29["`**29** @(14, 35) @block.defs line 184 column 15`"] - N30["`**30** @(6, 1) + N30["`**30** @(5, 1) @stmt.lexical_scope line 188 column 14`"] N30 --> N24 N30 --> N31 - N31["`**31** @(6, 1) + N31["`**31** @(5, 1) @stmt.defs line 189 column 14`"] - N32["`**32** @(11, 1) + N32["`**32** @(9, 1) @stmt.lexical_scope line 188 column 14`"] N32 --> N26 N32 --> N33 - N33["`**33** @(11, 1) + N33["`**33** @(9, 1) @stmt.defs line 189 column 14`"] - N34["`**34** @(18, 1) + N34["`**34** @(15, 1) @stmt.lexical_scope line 188 column 14`"] N34 --> N28 N34 --> N35 - N35["`**35** @(18, 1) + N35["`**35** @(15, 1) @stmt.defs line 189 column 14`"] N36["`**36** @(2, 1) @@ -151,27 +151,27 @@ line 274 column 19`"] N38[\"`**x** @(2, 1) def line 278 column 8`"/] - N39["`**39** @(6, 15) + N39["`**39** @(5, 15) @expr.lexical_scope line 338 column 14`"] N39 --> N30 - N40["`**40** @(11, 15) + N40["`**40** @(9, 15) @expr.lexical_scope line 338 column 14`"] N40 --> N32 - N41["`**41** @(18, 15) + N41["`**41** @(15, 15) @expr.lexical_scope line 338 column 14`"] N41 --> N34 - N42[/"`**x** @(6, 15) + N42[/"`**x** @(5, 15) ref line 342 column 8`"\] N42 --> N39 - N43[/"`**y** @(11, 15) + N43[/"`**y** @(9, 15) ref line 342 column 8`"\] N43 --> N40 - N44[/"`**x** @(18, 15) + N44[/"`**x** @(15, 15) ref line 342 column 8`"\] N44 --> N41 diff --git a/crates/solidity/testing/snapshots/bindings_output/lexical/local_vars.sol b/crates/solidity/testing/snapshots/bindings_output/lexical/local_vars.sol index f4c3a060ce..850377875f 100644 --- a/crates/solidity/testing/snapshots/bindings_output/lexical/local_vars.sol +++ b/crates/solidity/testing/snapshots/bindings_output/lexical/local_vars.sol @@ -1,15 +1,10 @@ contract Foo { function bar() returns (uint) { uint x = 10; - // ^def:1 - return x + 2; - // ^ref:1 } function baz() returns (int) { return w + x; - // ^ref:! - // ^ref:! } } diff --git a/crates/solidity/testing/snapshots/bindings_output/lexical/params.sol b/crates/solidity/testing/snapshots/bindings_output/lexical/params.sol index 730a1187f1..07f1b0b653 100644 --- a/crates/solidity/testing/snapshots/bindings_output/lexical/params.sol +++ b/crates/solidity/testing/snapshots/bindings_output/lexical/params.sol @@ -1,13 +1,9 @@ contract Foo { function bar(uint z) returns (uint) { - // ^def:1 - return z + 1; - // ^ref:1 } function baz() returns (int) { return z + 2; - // ^ref:! } } diff --git a/crates/solidity/testing/snapshots/bindings_output/lexical/state_vars.sol b/crates/solidity/testing/snapshots/bindings_output/lexical/state_vars.sol index d903525486..954dd2b3dd 100644 --- a/crates/solidity/testing/snapshots/bindings_output/lexical/state_vars.sol +++ b/crates/solidity/testing/snapshots/bindings_output/lexical/state_vars.sol @@ -1,21 +1,17 @@ contract Foo { uint x; - // ^def:1 function bar() returns (uint) { return x; - // ^ref:1 } function baz() returns (int) { return y; - // ^ref:! } } contract Bar { function quux() returns (uint) { return x; - // ^ref:! } }