diff --git a/crates/infra/cli/src/commands/check/mod.rs b/crates/infra/cli/src/commands/check/mod.rs index 28bdc27550..00b103d166 100644 --- a/crates/infra/cli/src/commands/check/mod.rs +++ b/crates/infra/cli/src/commands/check/mod.rs @@ -6,7 +6,6 @@ use infra_utils::terminal::Terminal; use rayon::iter::{ParallelBridge, ParallelIterator}; use strum::IntoEnumIterator; -use crate::toolchains::mkdocs::Mkdocs; use crate::toolchains::wasm::WasmPackage; use crate::utils::{ClapExtensions, OrderedCommand}; @@ -26,12 +25,8 @@ impl CheckController { enum CheckCommand { /// Run 'cargo check' for all crates, features, and targets. Cargo, - /// Run `cargo doc` to generate Rustdoc documentation and check for any broken links. - Rustdoc, /// Check NPM packages for any outdated codegen steps. Npm, - /// Check mkdocs documentation for any build issues or broken links. - Mkdocs, } impl OrderedCommand for CheckCommand { @@ -40,9 +35,7 @@ impl OrderedCommand for CheckCommand { match self { CheckCommand::Cargo => check_cargo(), - CheckCommand::Rustdoc => check_rustdoc(), CheckCommand::Npm => check_npm(), - CheckCommand::Mkdocs => check_mkdocs(), }; Ok(()) @@ -50,24 +43,11 @@ impl OrderedCommand for CheckCommand { } fn check_cargo() { - // 'cargo clippy' will run both 'cargo check', and 'clippy' lints: Command::new("cargo") - .arg("clippy") + .arg("check") .flag("--workspace") .flag("--all-features") .flag("--all-targets") - .flag("--no-deps") - .add_build_rustflags() - .run(); -} - -fn check_rustdoc() { - Command::new("cargo") - .arg("doc") - .flag("--workspace") - .flag("--all-features") - .flag("--no-deps") - .flag("--document-private-items") .add_build_rustflags() .run(); } @@ -77,7 +57,3 @@ fn check_npm() { .par_bridge() .for_each(|package| package.build().unwrap()); } - -fn check_mkdocs() { - Mkdocs::check(); -} diff --git a/crates/infra/cli/src/commands/lint/mod.rs b/crates/infra/cli/src/commands/lint/mod.rs index c78b08b7cd..26b9569e33 100644 --- a/crates/infra/cli/src/commands/lint/mod.rs +++ b/crates/infra/cli/src/commands/lint/mod.rs @@ -2,11 +2,13 @@ use std::path::Path; use anyhow::Result; use clap::{Parser, ValueEnum}; +use infra_utils::cargo::CargoWorkspaceCommands; use infra_utils::commands::Command; use infra_utils::github::GitHub; use infra_utils::paths::{FileWalker, PathExtensions}; use infra_utils::terminal::Terminal; +use crate::toolchains::mkdocs::Mkdocs; use crate::toolchains::pipenv::PipEnv; use crate::utils::{ClapExtensions, OrderedCommand}; @@ -24,6 +26,12 @@ impl LintController { #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, ValueEnum)] enum LintCommand { + /// Run `cargo clippy` to check for any Rust lints. + Clippy, + /// Run `cargo doc` to generate Rustdoc documentation and check for any broken links. + Rustdoc, + /// Check mkdocs documentation for any build issues or broken links. + Mkdocs, /// Check for spelling issues in Markdown files. Cspell, /// Format all non-Rust source files. @@ -49,6 +57,9 @@ impl OrderedCommand for LintCommand { Terminal::step(format!("lint {name}", name = self.clap_name())); match self { + LintCommand::Clippy => run_clippy(), + LintCommand::Rustdoc => run_rustdoc(), + LintCommand::Mkdocs => run_mkdocs(), LintCommand::Cspell => run_cspell(), LintCommand::Prettier => run_prettier(), LintCommand::MarkdownLinkCheck => run_markdown_link_check()?, @@ -64,6 +75,32 @@ impl OrderedCommand for LintCommand { } } +fn run_clippy() { + Command::new("cargo") + .arg("clippy") + .flag("--workspace") + .flag("--all-features") + .flag("--all-targets") + .flag("--no-deps") + .add_build_rustflags() + .run(); +} + +fn run_rustdoc() { + Command::new("cargo") + .arg("doc") + .flag("--workspace") + .flag("--all-features") + .flag("--no-deps") + .flag("--document-private-items") + .add_build_rustflags() + .run(); +} + +fn run_mkdocs() { + Mkdocs::check(); +} + fn run_cspell() { Command::new("cspell") .arg("lint") diff --git a/crates/metaslang/bindings/Cargo.toml b/crates/metaslang/bindings/Cargo.toml index 2def5b1390..32a27207ff 100644 --- a/crates/metaslang/bindings/Cargo.toml +++ b/crates/metaslang/bindings/Cargo.toml @@ -10,10 +10,8 @@ description = "Computes semantic language bindings from parsed source code" homepage = "https://nomicfoundation.github.io/slang/" repository = "https://github.com/NomicFoundation/slang/" authors = [ + "Slang Team ", "Nomic Foundation ", - "Antony Blakey ", - "Igor Matuszewski ", - "Omar Tawfik ", ] readme = "README.md" diff --git a/crates/metaslang/cst/Cargo.toml b/crates/metaslang/cst/Cargo.toml index be86cca818..5402a3b5fd 100644 --- a/crates/metaslang/cst/Cargo.toml +++ b/crates/metaslang/cst/Cargo.toml @@ -10,10 +10,8 @@ description = "A generic library for building, navigating and querying concrete homepage = "https://nomicfoundation.github.io/slang/" repository = "https://github.com/NomicFoundation/slang/" authors = [ + "Slang Team ", "Nomic Foundation ", - "Antony Blakey ", - "Igor Matuszewski ", - "Omar Tawfik ", ] readme = "README.md" diff --git a/crates/metaslang/graph_builder/Cargo.toml b/crates/metaslang/graph_builder/Cargo.toml index c1d47a2f39..2d80aad528 100644 --- a/crates/metaslang/graph_builder/Cargo.toml +++ b/crates/metaslang/graph_builder/Cargo.toml @@ -10,10 +10,8 @@ description = "Construct graphs from parsed source code" homepage = "https://nomicfoundation.github.io/slang/" repository = "https://github.com/NomicFoundation/slang/" authors = [ + "Slang Team ", "Nomic Foundation ", - "Antony Blakey ", - "Igor Matuszewski ", - "Omar Tawfik ", ] readme = "README.md" diff --git a/crates/solidity/inputs/language/bindings/rules.msgb b/crates/solidity/inputs/language/bindings/rules.msgb index eeb5a00bc1..f9e7c34346 100644 --- a/crates/solidity/inputs/language/bindings/rules.msgb +++ b/crates/solidity/inputs/language/bindings/rules.msgb @@ -1033,13 +1033,19 @@ inherit .star_extension ;;; Mappings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; When there's a parsing error (like a name in parameters for versions below 0.8.18) +;;; we still need the basics to get bindings working +@mapping [MappingType] { + node @mapping.lexical_scope + node @mapping.output + node @mapping.pop_begin + node @mapping.pop_end +} + @mapping [MappingType [MappingKey [MappingKeyType @key_type ([IdentifierPath] | [ElementaryType])]] [MappingValue @value_type [TypeName]] ] { - node @mapping.lexical_scope - node @mapping.output - ; Define the pushing path of the mapping type ; ValueType <- top of the symbol stack ; KeyType @@ -1081,12 +1087,33 @@ inherit .star_extension node pop_mapping attr (pop_mapping) pop_symbol = "%Mapping" - let @mapping.pop_begin = @value_type.pop_begin + edge @mapping.pop_begin -> @value_type.pop_begin edge @value_type.pop_end -> @key_type.pop_begin edge @key_type.pop_end -> pop_mapping - let @mapping.pop_end = pop_mapping + edge pop_mapping -> @mapping.pop_end + + node @mapping.defs +} + +@mapping [MappingType + @key [MappingKey [MappingKeyType] @key_name [Identifier]] + [MappingValue] +] { + node @key.def + attr (@key.def) node_definition = @key_name + attr (@key.def) definiens_node = @key + edge @key.def -> @mapping.defs } +@mapping [MappingType + [MappingKey] + @value [MappingValue [TypeName] @value_name [Identifier]] +] { + node @value.def + attr (@value.def) node_definition = @value_name + attr (@value.def) definiens_node = @value + edge @value.def -> @mapping.defs +} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Arrays types @@ -2050,6 +2077,36 @@ inherit .star_extension edge @enum.def -> type edge type -> type_enum_type edge type_enum_type -> @enum.lexical_scope + + ; value_ref_typeof allows for an enum value to access the + ; functions associated to this type + node @enum.value_ref_typeof + attr (@enum.value_ref_typeof) push_symbol = "@typeof" + node value_ref_type + attr (value_ref_type) push_symbol = (source-text @name) + edge @enum.value_ref_typeof -> value_ref_type + edge value_ref_type -> @enum.lexical_scope + + ; Path to link min and max to the enum's scope (#1158) + ; It resolves paths of the form `type().min.` + if (version-matches ">= 0.6.8") { + node typeof + attr (typeof) pop_symbol = "@typeof" + + node built_in_member + attr (built_in_member) pop_symbol = "." + node min_built_in + attr (min_built_in) pop_symbol = "min" + node max_built_in + attr (max_built_in) pop_symbol = "max" + + edge type -> typeof + edge typeof -> built_in_member + edge built_in_member -> min_built_in + edge built_in_member -> max_built_in + edge min_built_in -> @enum.value_ref_typeof + edge max_built_in -> @enum.value_ref_typeof + } } @enum [EnumDefinition @@ -2059,6 +2116,7 @@ inherit .star_extension attr (def) node_definition = @item attr (def) definiens_node = @item + edge def -> @enum.value_ref_typeof edge @enum.members -> def } diff --git a/crates/solidity/outputs/cargo/cli/Cargo.toml b/crates/solidity/outputs/cargo/cli/Cargo.toml index 2e94f8d4d5..8ed87333f0 100644 --- a/crates/solidity/outputs/cargo/cli/Cargo.toml +++ b/crates/solidity/outputs/cargo/cli/Cargo.toml @@ -10,10 +10,8 @@ description = "This crate contains the 'slang_solidity' CLI/cargo binary. Please homepage = "https://nomicfoundation.github.io/slang/" repository = "https://github.com/NomicFoundation/slang/" authors = [ + "Slang Team ", "Nomic Foundation ", - "Antony Blakey ", - "Igor Matuszewski ", - "Omar Tawfik ", ] readme = "README.md" diff --git a/crates/solidity/outputs/cargo/crate/Cargo.toml b/crates/solidity/outputs/cargo/crate/Cargo.toml index 7e1508fdf2..6ad995a516 100644 --- a/crates/solidity/outputs/cargo/crate/Cargo.toml +++ b/crates/solidity/outputs/cargo/crate/Cargo.toml @@ -10,10 +10,8 @@ description = "A modular set of compiler APIs empowering the next generation of homepage = "https://nomicfoundation.github.io/slang/" repository = "https://github.com/NomicFoundation/slang/" authors = [ + "Slang Team ", "Nomic Foundation ", - "Antony Blakey ", - "Igor Matuszewski ", - "Omar Tawfik ", ] readme = "README.md" 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 af5af31975..36e269fe73 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 @@ -1038,13 +1038,19 @@ inherit .star_extension ;;; Mappings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; When there's a parsing error (like a name in parameters for versions below 0.8.18) +;;; we still need the basics to get bindings working +@mapping [MappingType] { + node @mapping.lexical_scope + node @mapping.output + node @mapping.pop_begin + node @mapping.pop_end +} + @mapping [MappingType [MappingKey [MappingKeyType @key_type ([IdentifierPath] | [ElementaryType])]] [MappingValue @value_type [TypeName]] ] { - node @mapping.lexical_scope - node @mapping.output - ; Define the pushing path of the mapping type ; ValueType <- top of the symbol stack ; KeyType @@ -1086,12 +1092,33 @@ inherit .star_extension node pop_mapping attr (pop_mapping) pop_symbol = "%Mapping" - let @mapping.pop_begin = @value_type.pop_begin + edge @mapping.pop_begin -> @value_type.pop_begin edge @value_type.pop_end -> @key_type.pop_begin edge @key_type.pop_end -> pop_mapping - let @mapping.pop_end = pop_mapping + edge pop_mapping -> @mapping.pop_end + + node @mapping.defs +} + +@mapping [MappingType + @key [MappingKey [MappingKeyType] @key_name [Identifier]] + [MappingValue] +] { + node @key.def + attr (@key.def) node_definition = @key_name + attr (@key.def) definiens_node = @key + edge @key.def -> @mapping.defs } +@mapping [MappingType + [MappingKey] + @value [MappingValue [TypeName] @value_name [Identifier]] +] { + node @value.def + attr (@value.def) node_definition = @value_name + attr (@value.def) definiens_node = @value + edge @value.def -> @mapping.defs +} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Arrays types @@ -2055,6 +2082,36 @@ inherit .star_extension edge @enum.def -> type edge type -> type_enum_type edge type_enum_type -> @enum.lexical_scope + + ; value_ref_typeof allows for an enum value to access the + ; functions associated to this type + node @enum.value_ref_typeof + attr (@enum.value_ref_typeof) push_symbol = "@typeof" + node value_ref_type + attr (value_ref_type) push_symbol = (source-text @name) + edge @enum.value_ref_typeof -> value_ref_type + edge value_ref_type -> @enum.lexical_scope + + ; Path to link min and max to the enum's scope (#1158) + ; It resolves paths of the form `type().min.` + if (version-matches ">= 0.6.8") { + node typeof + attr (typeof) pop_symbol = "@typeof" + + node built_in_member + attr (built_in_member) pop_symbol = "." + node min_built_in + attr (min_built_in) pop_symbol = "min" + node max_built_in + attr (max_built_in) pop_symbol = "max" + + edge type -> typeof + edge typeof -> built_in_member + edge built_in_member -> min_built_in + edge built_in_member -> max_built_in + edge min_built_in -> @enum.value_ref_typeof + edge max_built_in -> @enum.value_ref_typeof + } } @enum [EnumDefinition @@ -2064,6 +2121,7 @@ inherit .star_extension attr (def) node_definition = @item attr (def) definiens_node = @item + edge def -> @enum.value_ref_typeof edge @enum.members -> def } 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 03d1ff3445..c944702b5a 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 @@ -73,3 +73,8 @@ fn revert_named_args() -> Result<()> { fn type_expr() -> Result<()> { run("expressions", "type_expr") } + +#[test] +fn type_expr_minmax() -> Result<()> { + run("expressions", "type_expr_minmax") +} 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 6c1d13ffe2..a74e709e71 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 @@ -19,6 +19,11 @@ fn indexing() -> Result<()> { run("mappings", "indexing") } +#[test] +fn named_parameters() -> Result<()> { + run("mappings", "named_parameters") +} + #[test] fn nested() -> Result<()> { run("mappings", "nested") diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/using.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/using.rs index 7b8a7d7bff..ed4d22c7d4 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/using.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/generated/using.rs @@ -9,6 +9,16 @@ fn address() -> Result<()> { run("using", "address") } +#[test] +fn binding_enum() -> Result<()> { + run("using", "binding_enum") +} + +#[test] +fn binding_enum_member() -> Result<()> { + run("using", "binding_enum_member") +} + #[test] fn casting() -> Result<()> { run("using", "casting") diff --git a/crates/solidity/outputs/npm/package/package.json b/crates/solidity/outputs/npm/package/package.json index c7fba2b62c..925bac26c0 100644 --- a/crates/solidity/outputs/npm/package/package.json +++ b/crates/solidity/outputs/npm/package/package.json @@ -12,20 +12,12 @@ "bugs": "https://github.com/NomicFoundation/slang/issues/", "contributors": [ { - "name": "Nomic Foundation", - "email": "packages@nomic.foundation" - }, - { - "name": "Antony Blakey", - "email": "antony@nomic.foundation" + "name": "Slang Team", + "email": "slang@nomic.foundation" }, { - "name": "Igor Matuszewski", - "email": "igor@nomic.foundation" - }, - { - "name": "Omar Tawfik", - "email": "omar@nomic.foundation" + "name": "Nomic Foundation", + "email": "packages@nomic.foundation" } ], "publishConfig": { diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..a759f22a82 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/generated/0.4.11-failure.txt @@ -0,0 +1,14 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected ContractKeyword or ImportKeyword or InterfaceKeyword or LibraryKeyword or PragmaKeyword. + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ enum Answer { + ┆ ┆ + 18 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. +────╯ +References and definitions: +Definiens: diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/generated/0.6.0-failure.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/generated/0.6.0-failure.txt new file mode 100644 index 0000000000..ae4ac88a5c --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/generated/0.6.0-failure.txt @@ -0,0 +1,88 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ enum Answer { + │ ───┬── + │ ╰──── name: 1 + 2 │ Yes + │ ─┬─ + │ ╰─── name: 2 + │ + 5 │ library Id { + │ ─┬ + │ ╰── name: 3 + 6 │ function id(Answer ans) returns (Answer) { + │ ─┬ ───┬── ─┬─ ───┬── + │ ╰────────────────────────────── name: 4 + │ │ │ │ + │ ╰───────────────────────── ref: 1 + │ │ │ + │ ╰──────────────────── name: 5 + │ │ + │ ╰──── ref: 1 + 7 │ return ans; + │ ─┬─ + │ ╰─── ref: 5 + │ + 11 │ contract Test { + │ ──┬─ + │ ╰─── name: 6 + 12 │ using Id for Answer; + │ ─┬ ───┬── + │ ╰───────────── ref: 3 + │ │ + │ ╰──── ref: 1 + │ + 14 │ function testFunc() { + │ ────┬─── + │ ╰───── name: 7 + 15 │ type(Answer).min.id(); + │ ───┬── ─┬─ ─┬ + │ ╰──────────── ref: 1 + │ │ │ + │ ╰────── unresolved + │ │ + │ ╰── unresolved + 16 │ type(Answer).max.id(); + │ ───┬── ─┬─ ─┬ + │ ╰──────────── ref: 1 + │ │ │ + │ ╰────── unresolved + │ │ + │ ╰── unresolved +────╯ +Definiens: + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ enum Answer { + 2 │ │ Yes + │ │ ─┬─ + │ │ ╰─── definiens: 2 + 3 │ │ ├─▶ } + │ │ │ + │ │ ╰─────── definiens: 1 + 4 │ ╭─────▶ + ┆ ┆ ┆ + 6 │ │ ╭───▶ function id(Answer ans) returns (Answer) { + │ │ │ ─────┬──── + │ │ │ ╰────── definiens: 5 + ┆ ┆ ┆ + 8 │ │ ├───▶ } + │ │ │ + │ │ ╰─────────── definiens: 4 + 9 │ │ ├─────▶ } + │ │ │ + │ │ ╰─────────── definiens: 3 + 10 │ ╭─────────▶ + ┆ ┆ + 13 │ │ ╭───────▶ + ┆ ┆ ┆ + 17 │ │ ├───────▶ } + │ │ │ + │ │ ╰─────────────── definiens: 7 + 18 │ ├─────────▶ } + │ │ + │ ╰─────────────── definiens: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/generated/0.6.8-success.txt b/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/generated/0.6.8-success.txt new file mode 100644 index 0000000000..fa55cac0cf --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/generated/0.6.8-success.txt @@ -0,0 +1,88 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ enum Answer { + │ ───┬── + │ ╰──── name: 1 + 2 │ Yes + │ ─┬─ + │ ╰─── name: 2 + │ + 5 │ library Id { + │ ─┬ + │ ╰── name: 3 + 6 │ function id(Answer ans) returns (Answer) { + │ ─┬ ───┬── ─┬─ ───┬── + │ ╰────────────────────────────── name: 4 + │ │ │ │ + │ ╰───────────────────────── ref: 1 + │ │ │ + │ ╰──────────────────── name: 5 + │ │ + │ ╰──── ref: 1 + 7 │ return ans; + │ ─┬─ + │ ╰─── ref: 5 + │ + 11 │ contract Test { + │ ──┬─ + │ ╰─── name: 6 + 12 │ using Id for Answer; + │ ─┬ ───┬── + │ ╰───────────── ref: 3 + │ │ + │ ╰──── ref: 1 + │ + 14 │ function testFunc() { + │ ────┬─── + │ ╰───── name: 7 + 15 │ type(Answer).min.id(); + │ ───┬── ─┬─ ─┬ + │ ╰──────────── ref: 1 + │ │ │ + │ ╰────── ref: built-in + │ │ + │ ╰── ref: 4 + 16 │ type(Answer).max.id(); + │ ───┬── ─┬─ ─┬ + │ ╰──────────── ref: 1 + │ │ │ + │ ╰────── ref: built-in + │ │ + │ ╰── ref: 4 +────╯ +Definiens: + ╭─[input.sol:1:1] + │ + 1 │ ╭─▶ enum Answer { + 2 │ │ Yes + │ │ ─┬─ + │ │ ╰─── definiens: 2 + 3 │ │ ├─▶ } + │ │ │ + │ │ ╰─────── definiens: 1 + 4 │ ╭─────▶ + ┆ ┆ ┆ + 6 │ │ ╭───▶ function id(Answer ans) returns (Answer) { + │ │ │ ─────┬──── + │ │ │ ╰────── definiens: 5 + ┆ ┆ ┆ + 8 │ │ ├───▶ } + │ │ │ + │ │ ╰─────────── definiens: 4 + 9 │ │ ├─────▶ } + │ │ │ + │ │ ╰─────────── definiens: 3 + 10 │ ╭─────────▶ + ┆ ┆ + 13 │ │ ╭───────▶ + ┆ ┆ ┆ + 17 │ │ ├───────▶ } + │ │ │ + │ │ ╰─────────────── definiens: 7 + 18 │ ├─────────▶ } + │ │ + │ ╰─────────────── definiens: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/input.sol b/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/input.sol new file mode 100644 index 0000000000..df73d9d15a --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/expressions/type_expr_minmax/input.sol @@ -0,0 +1,18 @@ +enum Answer { + Yes +} + +library Id { + function id(Answer ans) returns (Answer) { + return ans; + } +} + +contract Test { + using Id for Answer; + + function testFunc() { + type(Answer).min.id(); + type(Answer).max.id(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/mappings/named_parameters/generated/0.4.11-failure.txt b/crates/solidity/testing/snapshots/bindings_output/mappings/named_parameters/generated/0.4.11-failure.txt new file mode 100644 index 0000000000..38a4e81a82 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/mappings/named_parameters/generated/0.4.11-failure.txt @@ -0,0 +1,61 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Parse errors: +Error: Expected EqualGreaterThan or PayableKeyword. + ╭─[input.sol:2:19] + │ + 2 │ mapping(address name => uint256) public justNameInKey; + │ ───────┬─────── + │ ╰───────── Error occurred here. +───╯ +Error: Expected CloseParen or OpenBracket. + ╭─[input.sol:4:30] + │ + 4 │ mapping(address => uint256 amount) public justNameInValue; + │ ───┬── + │ ╰──── Error occurred here. +───╯ +Error: Expected EqualGreaterThan or PayableKeyword. + ╭─[input.sol:6:19] + │ + 6 │ mapping(address name => uint256 amount) public nameInBoth; + │ ───────────┬────────── + │ ╰──────────── Error occurred here. +───╯ +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract NamedMapping { + │ ──────┬───── + │ ╰─────── name: 1 + 2 │ mapping(address name => uint256) public justNameInKey; + │ ──────┬────── + │ ╰──────── name: 2 + │ + 4 │ mapping(address => uint256 amount) public justNameInValue; + │ ───────┬─────── + │ ╰───────── name: 3 + │ + 6 │ mapping(address name => uint256 amount) public nameInBoth; + │ ─────┬──── + │ ╰────── name: 4 +───╯ +Definiens: + ╭─[input.sol:1:1] + │ + 1 │ ╭─────▶ contract NamedMapping { + 2 │ │ │ mapping(address name => uint256) public justNameInKey; + │ │ │ ────────────────────────────┬──────────────────────────── + │ │ │ ╰────────────────────────────── definiens: 2 + 3 │ │ ╭───▶ + 4 │ │ ├─│ ▶ mapping(address => uint256 amount) public justNameInValue; + │ │ │ │ + │ │ ╰──────────────────────────────────────────────────────────────────── definiens: 3 + 5 │ │ ╭─▶ + 6 │ │ ├─▶ mapping(address name => uint256 amount) public nameInBoth; + │ │ │ + │ │ ╰────────────────────────────────────────────────────────────────── definiens: 4 + 7 │ ├─────▶ } + │ │ + │ ╰─────────── definiens: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/mappings/named_parameters/generated/0.8.18-success.txt b/crates/solidity/testing/snapshots/bindings_output/mappings/named_parameters/generated/0.8.18-success.txt new file mode 100644 index 0000000000..35ceb63911 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/mappings/named_parameters/generated/0.8.18-success.txt @@ -0,0 +1,55 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ contract NamedMapping { + │ ──────┬───── + │ ╰─────── name: 1 + 2 │ mapping(address name => uint256) public justNameInKey; + │ ──┬─ ──────┬────── + │ ╰──────────────────────────────────── name: 3 + │ │ + │ ╰──────── name: 2 + │ + 4 │ mapping(address => uint256 amount) public justNameInValue; + │ ───┬── ───────┬─────── + │ ╰──────────────────────────── name: 5 + │ │ + │ ╰───────── name: 4 + │ + 6 │ mapping(address name => uint256 amount) public nameInBoth; + │ ──┬─ ───┬── ─────┬──── + │ ╰──────────────────────────────────────── name: 7 + │ │ │ + │ ╰─────────────────────── name: 8 + │ │ + │ ╰────── name: 6 +───╯ +Definiens: + ╭─[input.sol:1:1] + │ + 1 │ ╭─────▶ contract NamedMapping { + 2 │ │ │ mapping(address name => uint256) public justNameInKey; + │ │ │ ────────────────┬───────────┬──────────────────────────── + │ │ │ ╰────────────────────────────────────────── definiens: 3 + │ │ │ │ + │ │ │ ╰────────────────────────────── definiens: 2 + 3 │ │ ╭───▶ + 4 │ │ ├─│ ▶ mapping(address => uint256 amount) public justNameInValue; + │ │ │ │ ───────┬─────── + │ │ │ │ ╰─────────────────────────────────── definiens: 5 + │ │ │ │ + │ │ ╰──────────────────────────────────────────────────────────────────── definiens: 4 + 5 │ │ ╭─▶ + 6 │ │ ├─▶ mapping(address name => uint256 amount) public nameInBoth; + │ │ │ ──────┬───── ───────┬─────── + │ │ │ ╰────────────────────────────────────────────── definiens: 7 + │ │ │ │ + │ │ │ ╰────────────────────────────── definiens: 8 + │ │ │ + │ │ ╰────────────────────────────────────────────────────────────────── definiens: 6 + 7 │ ├─────▶ } + │ │ + │ ╰─────────── definiens: 1 +───╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/mappings/named_parameters/input.sol b/crates/solidity/testing/snapshots/bindings_output/mappings/named_parameters/input.sol new file mode 100644 index 0000000000..829ee9e02e --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/mappings/named_parameters/input.sol @@ -0,0 +1,7 @@ +contract NamedMapping { + mapping(address name => uint256) public justNameInKey; + + mapping(address => uint256 amount) public justNameInValue; + + mapping(address name => uint256 amount) public nameInBoth; +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/binding_enum/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum/generated/0.4.11-success.txt new file mode 100644 index 0000000000..c4e362d464 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum/generated/0.4.11-success.txt @@ -0,0 +1,102 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Id { + │ ─┬ + │ ╰── name: 1 + 2 │ enum Answer { + │ ───┬── + │ ╰──── name: 2 + 3 │ Yes + │ ─┬─ + │ ╰─── name: 3 + │ + 6 │ function id(Answer ans) returns (Answer) { + │ ─┬ ───┬── ─┬─ ───┬── + │ ╰────────────────────────────── name: 4 + │ │ │ │ + │ ╰───────────────────────── ref: 2 + │ │ │ + │ ╰──────────────────── name: 5 + │ │ + │ ╰──── ref: 2 + 7 │ return ans; + │ ─┬─ + │ ╰─── ref: 5 + │ + 11 │ contract Test { + │ ──┬─ + │ ╰─── name: 6 + 12 │ using Id for Id.Answer; + │ ─┬ ─┬ ───┬── + │ ╰──────────────── ref: 1 + │ │ │ + │ ╰───────── ref: 1 + │ │ + │ ╰──── ref: 2 + │ + 14 │ function testFunc() returns (Id.Answer) { + │ ────┬─── ─┬ ───┬── + │ ╰────────────────────────── name: 7 + │ │ │ + │ ╰───────── ref: 1 + │ │ + │ ╰──── ref: 2 + 15 │ Id.Answer value = Id.Answer.Yes; + │ ─┬ ───┬── ──┬── ─┬ ───┬── ─┬─ + │ ╰─────────────────────────────── ref: 1 + │ │ │ │ │ │ + │ ╰────────────────────────── ref: 2 + │ │ │ │ │ + │ ╰──────────────────── name: 8 + │ │ │ │ + │ ╰───────────── ref: 1 + │ │ │ + │ ╰──────── ref: 2 + │ │ + │ ╰─── ref: 3 + 16 │ value.id(); + │ ──┬── ─┬ + │ ╰─────── ref: 8 + │ │ + │ ╰── ref: 4 +────╯ +Definiens: + ╭─[input.sol:1:1] + │ + 1 │ ╭─────│ ▶ library Id { + 2 │ │ ╭─▶ enum Answer { + 3 │ │ │ Yes + │ │ │ ─┬─ + │ │ │ ╰─── definiens: 3 + 4 │ │ │ ├─▶ } + │ │ │ │ + │ │ │ ╰───────── definiens: 2 + 5 │ │ ╭───▶ + 6 │ │ │ function id(Answer ans) returns (Answer) { + │ │ │ ─────┬──── + │ │ │ ╰────── definiens: 5 + ┆ ┆ ┆ + 8 │ │ ├───▶ } + │ │ │ + │ │ ╰─────────── definiens: 4 + 9 │ │ ├───────▶ } + │ │ │ + │ │ ╰───────────── definiens: 1 + 10 │ ╭─────────▶ + ┆ ┆ + 13 │ │ ╭─────▶ + ┆ ┆ ┆ + 15 │ │ │ Id.Answer value = Id.Answer.Yes; + │ │ │ ──────────────────┬────────────────── + │ │ │ ╰──────────────────── definiens: 8 + ┆ ┆ ┆ + 17 │ │ ├─────▶ } + │ │ │ + │ │ ╰───────────── definiens: 7 + 18 │ ├─────────▶ } + │ │ + │ ╰─────────────── definiens: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/binding_enum/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum/input.sol new file mode 100644 index 0000000000..cb062d9843 --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum/input.sol @@ -0,0 +1,18 @@ +library Id { + enum Answer { + Yes + } + + function id(Answer ans) returns (Answer) { + return ans; + } +} + +contract Test { + using Id for Id.Answer; + + function testFunc() returns (Id.Answer) { + Id.Answer value = Id.Answer.Yes; + value.id(); + } +} diff --git a/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/generated/0.4.11-success.txt b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/generated/0.4.11-success.txt new file mode 100644 index 0000000000..58399ede7f --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/generated/0.4.11-success.txt @@ -0,0 +1,89 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +References and definitions: + ╭─[input.sol:1:1] + │ + 1 │ library Id { + │ ─┬ + │ ╰── name: 1 + 2 │ enum Answer { + │ ───┬── + │ ╰──── name: 2 + 3 │ Yes + │ ─┬─ + │ ╰─── name: 3 + │ + 6 │ function id(Answer ans) returns (Answer) { + │ ─┬ ───┬── ─┬─ ───┬── + │ ╰────────────────────────────── name: 4 + │ │ │ │ + │ ╰───────────────────────── ref: 2 + │ │ │ + │ ╰──────────────────── name: 5 + │ │ + │ ╰──── ref: 2 + 7 │ return ans; + │ ─┬─ + │ ╰─── ref: 5 + │ + 11 │ contract Test { + │ ──┬─ + │ ╰─── name: 6 + 12 │ using Id for Id.Answer; + │ ─┬ ─┬ ───┬── + │ ╰──────────────── ref: 1 + │ │ │ + │ ╰───────── ref: 1 + │ │ + │ ╰──── ref: 2 + │ + 14 │ function testFunc() returns (Id.Answer) { + │ ────┬─── ─┬ ───┬── + │ ╰────────────────────────── name: 7 + │ │ │ + │ ╰───────── ref: 1 + │ │ + │ ╰──── ref: 2 + 15 │ Id.Answer.Yes.id(); + │ ─┬ ───┬── ─┬─ ─┬ + │ ╰──────────────── ref: 1 + │ │ │ │ + │ ╰─────────── ref: 2 + │ │ │ + │ ╰────── ref: 3 + │ │ + │ ╰── ref: 4 +────╯ +Definiens: + ╭─[input.sol:1:1] + │ + 1 │ ╭─────│ ▶ library Id { + 2 │ │ ╭─▶ enum Answer { + 3 │ │ │ Yes + │ │ │ ─┬─ + │ │ │ ╰─── definiens: 3 + 4 │ │ │ ├─▶ } + │ │ │ │ + │ │ │ ╰───────── definiens: 2 + 5 │ │ ╭───▶ + 6 │ │ │ function id(Answer ans) returns (Answer) { + │ │ │ ─────┬──── + │ │ │ ╰────── definiens: 5 + ┆ ┆ ┆ + 8 │ │ ├───▶ } + │ │ │ + │ │ ╰─────────── definiens: 4 + 9 │ │ ├───────▶ } + │ │ │ + │ │ ╰───────────── definiens: 1 + 10 │ ╭─────────▶ + ┆ ┆ + 13 │ │ ╭─────▶ + ┆ ┆ ┆ + 16 │ │ ├─────▶ } + │ │ │ + │ │ ╰───────────── definiens: 7 + 17 │ ├─────────▶ } + │ │ + │ ╰─────────────── definiens: 6 +────╯ diff --git a/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/input.sol b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/input.sol new file mode 100644 index 0000000000..c84c0bf1dd --- /dev/null +++ b/crates/solidity/testing/snapshots/bindings_output/using/binding_enum_member/input.sol @@ -0,0 +1,17 @@ +library Id { + enum Answer { + Yes + } + + function id(Answer ans) returns (Answer) { + return ans; + } +} + +contract Test { + using Id for Id.Answer; + + function testFunc() returns (Id.Answer) { + Id.Answer.Yes.id(); + } +}