diff --git a/.circleci/config.yml b/.circleci/config.yml index dcfd82cb9154..097de5d7c97f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,8 +17,8 @@ parameters: default: "ghcr.io/argotorg/solidity-buildpack-deps@sha256:c0412c53e59ce0c96bde4c08e7332ea12e4cadba9bbac829621947897fa21272" ubuntu-2404-arm-docker-image: type: string - # ghcr.io/argotorg/solidity-buildpack-deps:ubuntu2404.arm-1 - default: "ghcr.io/argotorg/solidity-buildpack-deps@sha256:6cdb928fa8743d0b5d515c2c489b8d545c541f2370af28d5d3a71532056a0f22" + # ghcr.io/argotorg/solidity-buildpack-deps:ubuntu2404.arm-2 + default: "ghcr.io/argotorg/solidity-buildpack-deps@sha256:27b03c1c4688e5d69b10e0539460346a3dee3b10b0e04fb406b9707c6f0dd95e" ubuntu-2404-clang-docker-image: type: string # ghcr.io/argotorg/solidity-buildpack-deps:ubuntu2404.clang-7 @@ -710,6 +710,11 @@ defaults: requires: - b_ubu_static + - requires_b_ubu_static_arm: &requires_b_ubu_static_arm + <<: *on_all_tags_and_branches + requires: + - b_ubu_static_arm + - requires_b_archlinux: &requires_b_archlinux <<: *on_all_tags_and_branches requires: @@ -1113,7 +1118,7 @@ jobs: - solc/solc-static-linux - matrix_notify_failure_unless_pr - b_ubu_static_arm: + b_ubu_static_arm: &b_ubu_static_arm <<: *base_ubuntu2404_arm_large environment: <<: *base_ubuntu2404_arm_large_env @@ -1302,6 +1307,28 @@ jobs: steps: - soltest_all + t_ubu_arm_soltest: &t_ubu_arm_soltest + <<: *base_ubuntu2404_arm_medium + parallelism: 20 + environment: + <<: *base_ubuntu2404_arm_medium_env + EVM: << pipeline.parameters.evm-version >> + EOF_VERSION: 0 + OPTIMIZE: 0 + steps: + - checkout + - attach_workspace: + at: build + - run: + name: Create symbolic link with expected soltest binary name + command: | + ln --symbolic --relative build/test/soltest-linux-arm build/test/soltest + - run_soltest + - store_test_results: + path: test_results/ + - store_artifacts_test_results + - matrix_notify_failure_unless_pr + t_ubu_soltest_deprecated_evm_versions: &t_ubu_soltest_deprecated_evm_versions <<: *base_ubuntu2404_large parallelism: 50 @@ -1310,7 +1337,7 @@ jobs: - attach_workspace: at: build - run_soltest_all: - evm_versions: homestead byzantium + evm_versions: homestead byzantium constantinople petersburg - store_test_results: path: test_results/ - store_artifacts_test_results @@ -1364,6 +1391,24 @@ jobs: steps: - cmdline_tests + t_ubu_arm_cli: &t_ubu_arm_cli + <<: *base_ubuntu2404_arm_medium + parallelism: 8 # Should match number of tests in .circleci/parallel_cli_tests.py + steps: + - checkout + - attach_workspace: + at: build + - run: + name: Create symbolic link with expected solc and solfuzzer binaries name + command: | + ln --symbolic --relative build/solc/solc-static-linux-arm build/solc/solc + ln --symbolic --relative build/test/tools/solfuzzer-linux-arm build/test/tools/solfuzzer + - run_cmdline_tests + - store_test_results: + path: test_results/ + - store_artifacts_test_results + - matrix_notify_failure_unless_pr + t_ubu_force_release_cli: &t_ubu_force_release_cli <<: *t_ubu_cli @@ -1940,6 +1985,12 @@ jobs: # This job is only meant to run nightly so build time is not an issue. docker_layer_caching: false - checkout + - run: + name: Disable partial clone and fetch all objects + command: | + git config remote.origin.promisor false + git config --unset remote.origin.partialclonefilter + git fetch --refetch origin - run: name: Build and tag the container command: scripts/docker_deploy_manual.sh develop "file://$PWD" --no-push @@ -1994,8 +2045,10 @@ workflows: # Ubuntu build and tests - b_ubu: *requires_nothing - t_ubu_cli: *requires_b_ubu + - t_ubu_arm_cli: *requires_b_ubu_static_arm - t_ubu_locale: *requires_b_ubu - t_ubu_soltest_all: *requires_b_ubu + - t_ubu_arm_soltest: *requires_b_ubu_static_arm - b_ubu_clang: *requires_nothing - t_ubu_clang_soltest: *requires_b_ubu_clang - t_ubu_lsp: *requires_b_ubu diff --git a/.circleci/soltest_all.sh b/.circleci/soltest_all.sh index 9fbf6db58902..27c4c8a04c8c 100755 --- a/.circleci/soltest_all.sh +++ b/.circleci/soltest_all.sh @@ -31,7 +31,7 @@ REPODIR="$(realpath "$(dirname "$0")"/..)" # shellcheck source=scripts/common.sh source "${REPODIR}/scripts/common.sh" -DEFAULT_EVM_VALUES=(constantinople petersburg istanbul berlin london paris shanghai cancun prague osaka) +DEFAULT_EVM_VALUES=(istanbul berlin london paris shanghai cancun prague osaka) EVMS_WITH_EOF=(osaka) # Deserialize the EVM_VALUES array if it was provided as argument or diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e477cf3a8dd..f4d67e243bab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ include(EthPolicy) eth_policy() # project name and version should be set after cmake_policy CMP0048 -set(PROJECT_VERSION "0.8.31") +set(PROJECT_VERSION "0.8.32") # OSX target needed in order to support std::visit set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14") project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX) diff --git a/Changelog.md b/Changelog.md index aef0390f7acb..93edad52899a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,18 +1,30 @@ -### 0.8.31 (2025-12-03) +### 0.8.32 (2025-12-18) -Language Features: -* Yul: Introduce builtin `clz(x)` for counting the number of leading zero bits in a 256-bit word. +Important Bugfixes: +* Code Generator: Fix a bug in clearing/copying of arrays that straddle the end of storage, potentially resulting in assignment/initialization/`delete`/`push()`/`pop()` skipping some or all of the intended storage writes. -Compiler Features: +Bugfixes: +* Codegen: Fix internal compiler error when emitting events via module member access. +* TypeChecker: Fix error and event selectors not being considered compile-time constant. +* TypeChecker: Fix `string.concat` and `bytes.concat` with constant arguments not being considered compile-time constant. + + +### 0.8.31 (2025-12-03) + +Language Features: * Custom Storage Layout: Allow using `constant` state variables in the base slot expression. * DocString Parser: Warn about deprecation of inline assembly special comment `memory-safe-assembly`. -* ethdebug: Experimental support for instructions and source locations under EOF. -* EVM: Set default EVM Version to `osaka`. * Syntax Checker: Warn about deprecation of ABI coder v1. * Syntax Checker: Warn about deprecation of virtual modifiers. * Type Checker: Warn about deprecation of `send` and `transfer` functions on instances of `address`. * Type Checker: Warn about deprecation of comparisons between variables of contract types. +* Yul: Introduce builtin `clz(x)` for counting the number of leading zero bits in a 256-bit word. + + +Compiler Features: +* ethdebug: Experimental support for instructions and source locations under EOF. +* EVM: Set default EVM Version to `osaka`. Bugfixes: diff --git a/ReleaseChecklist.md b/ReleaseChecklist.md index b78edc2de2fd..9c3b2f89682d 100644 --- a/ReleaseChecklist.md +++ b/ReleaseChecklist.md @@ -42,6 +42,7 @@ At least a day before the release: - [ ] Get the posts reviewed and approved **before the release starts**. ### Changelog +- [ ] Ensure that all changelog entries are correctly classified as language or compiler features. - [ ] Sort the changelog entries alphabetically and correct any errors you notice. Commit it. - [ ] Update the changelog to include a release date. - [ ] Run `scripts/update_bugs_by_version.py` to regenerate `bugs_by_version.json` from the changelog and `bugs.json`. @@ -76,6 +77,7 @@ At least a day before the release: ### Docker - [ ] Make sure `docker-buildx` is installed. +- [ ] Run `echo $GHCR_TOKEN | docker login ghcr.io --username $GH_USERNAME --password-stdin` where `$GH_USERNAME` is your GitHub username and `$GHCR_TOKEN` is a PAT with `write:packages` scope. - [ ] Run `./scripts/docker_deploy_manual.sh v$VERSION`. ### Release solc-js diff --git a/deps/fmtlib b/deps/fmtlib index 40626af88bd7..407c905e45ad 160000 --- a/deps/fmtlib +++ b/deps/fmtlib @@ -1 +1 @@ -Subproject commit 40626af88bd7df9a5fb80be7b25ac85b122d6c21 +Subproject commit 407c905e45ad75fc29bf0f9bb7c5c2fd3475976f diff --git a/deps/nlohmann-json b/deps/nlohmann-json index 9cca280a4d0c..55f93686c015 160000 --- a/deps/nlohmann-json +++ b/deps/nlohmann-json @@ -1 +1 @@ -Subproject commit 9cca280a4d0ccf0c08f47a99aa71d1b0e52f8d03 +Subproject commit 55f93686c01528224f448c19128836e7df245f72 diff --git a/docs/bugs_by_version.json b/docs/bugs_by_version.json index 444f6bc73622..5282948776c2 100644 --- a/docs/bugs_by_version.json +++ b/docs/bugs_by_version.json @@ -2077,6 +2077,10 @@ "bugs": [], "released": "2025-12-03" }, + "0.8.32": { + "bugs": [], + "released": "2025-12-18" + }, "0.8.4": { "bugs": [ "UnsoundSpillInMutualRecursion", diff --git a/docs/contributing.rst b/docs/contributing.rst index 45b15e579db0..b5eb3c08ed09 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -34,6 +34,9 @@ the team and contributors are working on, you can join our public team call: The call takes place on `Jitsi `_. +New topics can be freely added to the `agenda `_ +and will be scheduled for discussion on the nearest call. + How to Report Issues ==================== diff --git a/docs/installing-solidity.rst b/docs/installing-solidity.rst index 01a2f382045b..97a754eaaab0 100644 --- a/docs/installing-solidity.rst +++ b/docs/installing-solidity.rst @@ -270,10 +270,11 @@ This means that: if you want to be sure whether you are downloading a wasm or an asm.js binary. - Use ``list.json`` instead of ``list.js`` and ``list.txt``. The JSON list format contains all the information from the old ones and more. - - Use https://binaries.soliditylang.org instead of https://solc-bin.ethereum.org. To keep things - simple we moved almost everything related to the compiler under the new ``soliditylang.org`` - domain and this applies to ``solc-bin`` too. While the new domain is recommended, the old one - is still fully supported and guaranteed to point at the same location. + +.. warning:: + - The solc-bin.ethereum.org domain is no longer supported. Going forward, + we recommend any tools which are still using it as the source of Solidity binaries + to switch to binaries.soliditylang.org. .. warning:: diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index d51eb3442bef..656f7514a409 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -3312,27 +3312,57 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) // TODO some members might be pure, but for example `address(0x123).balance` is not pure // although every subexpression is, so leaving this limited for now. if (auto tt = dynamic_cast(exprType)) + { if ( tt->actualType()->category() == Type::Category::Enum || tt->actualType()->category() == Type::Category::UserDefinedValueType ) annotation.isPure = true; + + // `concat` purity depends also on its arguments, but this is checked later, in visit(FunctionCall...) + // This covers `bytes.concat` and `string.concat`. + if (tt->actualType()->category() == Type::Category::Array) + { + if ( + auto const* funcType = dynamic_cast(annotation.type); + funcType && + ( + funcType->kind() == FunctionType::Kind::StringConcat || + funcType->kind() == FunctionType::Kind::BytesConcat + ) + ) + annotation.isPure = true; + } + } if ( auto const* functionType = dynamic_cast(exprType); functionType && functionType->hasDeclaration() && - dynamic_cast(&functionType->declaration()) && memberName == "selector" ) - if (auto const* parentAccess = dynamic_cast(&_memberAccess.expression())) + { + if (dynamic_cast(&functionType->declaration())) { - bool isPure = *parentAccess->expression().annotation().isPure; - if (auto const* exprInt = dynamic_cast(&parentAccess->expression())) - if (exprInt->name() == "this" || exprInt->name() == "super") - isPure = true; + if (auto const* parentAccess = dynamic_cast(&_memberAccess.expression())) + { + bool isPure = *parentAccess->expression().annotation().isPure; + // Accessing a function selector using `super|this.f.selector`. + if (auto const* exprInt = dynamic_cast(&parentAccess->expression())) + if (exprInt->name() == "this" || exprInt->name() == "super") + isPure = true; - annotation.isPure = isPure; + annotation.isPure = isPure; + } } + // In case of event or error definition the selector is always compile-time constant, as it can be + // a keccak256 hash of the event signature or a function selector in case of an error. + else if ( + dynamic_cast(&functionType->declaration()) || + dynamic_cast(&functionType->declaration()) + ) + annotation.isPure = true; + } + if ( auto const* varDecl = dynamic_cast(annotation.referencedDeclaration); !annotation.isPure.set() && @@ -3426,6 +3456,16 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) if (!annotation.isPure.set()) annotation.isPure = false; + if ( + auto const* funcType = dynamic_cast(annotation.type); + funcType && + funcType->kind() != FunctionType::Kind::Declaration && + funcType->kind() != FunctionType::Kind::Internal && + funcType->kind() != FunctionType::Kind::Error && + funcType->kind() != FunctionType::Kind::Event + ) + solAssert(funcType->isPure() == *annotation.isPure); + return false; } diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 6ab7423ed781..bae14d71a711 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -3892,7 +3892,9 @@ bool FunctionType::isPure() const m_kind == Kind::ABIDecode || m_kind == Kind::MetaType || m_kind == Kind::Wrap || - m_kind == Kind::Unwrap; + m_kind == Kind::Unwrap || + m_kind == Kind::BytesConcat || + m_kind == Kind::StringConcat; } TypePointers FunctionType::parseElementaryTypeVector(strings const& _types) diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 92db9d9589d9..c3dcf3647c80 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -2493,6 +2493,7 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) dynamic_cast(_memberAccess.annotation().referencedDeclaration) || dynamic_cast(_memberAccess.annotation().referencedDeclaration) || dynamic_cast(_memberAccess.annotation().referencedDeclaration) || + dynamic_cast(_memberAccess.annotation().referencedDeclaration) || category == Type::Category::TypeType || category == Type::Category::Module, "" diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 862ff7c9f592..e646d4d7eb7b 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -2678,6 +2678,7 @@ void IRGeneratorForStatements::endVisit(MemberAccess const& _memberAccess) dynamic_cast(_memberAccess.annotation().referencedDeclaration) || dynamic_cast(_memberAccess.annotation().referencedDeclaration) || dynamic_cast(_memberAccess.annotation().referencedDeclaration) || + dynamic_cast(_memberAccess.annotation().referencedDeclaration) || category == Type::Category::TypeType || category == Type::Category::Module, "" diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index dd637f83ab56..a927881b1d48 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -170,7 +170,7 @@ ASTPointer Parser::parse(CharStream& _charStream) expectToken(Token::Semicolon); } else - fatalParserError(7858_error, "Expected pragma, import directive or contract/interface/library/struct/enum/constant/function/error definition."); + fatalParserError(7858_error, "Expected pragma, import directive or contract/interface/library/user-defined type/constant/function/error/event definition."); } } solAssert(m_recursionDepth == 0, ""); diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2404.arm b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2404.arm index a24549d4b830..663928220a0e 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2404.arm +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2404.arm @@ -22,7 +22,7 @@ # (c) 2016-2025 solidity contributors. #------------------------------------------------------------------------------ FROM --platform=linux/arm64 buildpack-deps:noble AS base -LABEL version="1" +LABEL version="2" ARG DEBIAN_FRONTEND=noninteractive @@ -104,6 +104,7 @@ RUN <<-EOF EOF FROM base +COPY --from=libraries /usr/local/lib/libevmone* /usr/lib COPY --from=libraries /usr/lib /usr/lib COPY --from=libraries /usr/bin /usr/bin COPY --from=libraries /usr/include /usr/include diff --git a/test/cmdlineTests/standard_outputs_on_parsing_error/output.json b/test/cmdlineTests/standard_outputs_on_parsing_error/output.json index 6730d772ee02..39610363ee58 100644 --- a/test/cmdlineTests/standard_outputs_on_parsing_error/output.json +++ b/test/cmdlineTests/standard_outputs_on_parsing_error/output.json @@ -3,14 +3,14 @@ { "component": "general", "errorCode": "7858", - "formattedMessage": "ParserError: Expected pragma, import directive or contract/interface/library/struct/enum/constant/function/error definition. + "formattedMessage": "ParserError: Expected pragma, import directive or contract/interface/library/user-defined type/constant/function/error/event definition. --> C:5:14: | 5 | contract C {}} | ^ ", - "message": "Expected pragma, import directive or contract/interface/library/struct/enum/constant/function/error definition.", + "message": "Expected pragma, import directive or contract/interface/library/user-defined type/constant/function/error/event definition.", "severity": "error", "sourceLocation": { "end": 121, diff --git a/test/libsolidity/ASTJSON/emit_event_from_module_via_member_access.json b/test/libsolidity/ASTJSON/emit_event_from_module_via_member_access.json new file mode 100644 index 000000000000..a33847450bc2 --- /dev/null +++ b/test/libsolidity/ASTJSON/emit_event_from_module_via_member_access.json @@ -0,0 +1,1046 @@ +[ +{ + "absolutePath": "A.sol", + "exportedSymbols": { + "AContract": [ + 17 + ], + "TransferA": [ + 8 + ] + }, + "id": 18, + "nodeType": "SourceUnit", + "nodes": [ + { + "anonymous": false, + "eventSelector": "ef0684aa87ada311bea2dad2b653ce28cd604aa1c10a123df8fb2f789c3178f0", + "id": 8, + "name": "TransferA", + "nameLocation": "6:9:1", + "nodeType": "EventDefinition", + "parameters": { + "id": 7, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 2, + "indexed": true, + "mutability": "mutable", + "name": "from", + "nameLocation": "32:4:1", + "nodeType": "VariableDeclaration", + "scope": 8, + "src": "16:20:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 1, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "16:7:1", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "visibility": "internal" + }, + { + "constant": false, + "id": 4, + "indexed": true, + "mutability": "mutable", + "name": "to", + "nameLocation": "54:2:1", + "nodeType": "VariableDeclaration", + "scope": 8, + "src": "38:18:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 3, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "38:7:1", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "visibility": "internal" + }, + { + "constant": false, + "id": 6, + "indexed": false, + "mutability": "mutable", + "name": "amount", + "nameLocation": "63:6:1", + "nodeType": "VariableDeclaration", + "scope": 8, + "src": "58:11:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 5, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "58:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "visibility": "internal" + } + ], + "src": "15:55:1" + }, + "src": "0:71:1" + }, + { + "abstract": false, + "baseContracts": [], + "canonicalName": "AContract", + "contractDependencies": [], + "contractKind": "contract", + "fullyImplemented": true, + "id": 17, + "linearizedBaseContracts": [ + 17 + ], + "name": "AContract", + "nameLocation": "81:9:1", + "nodeType": "ContractDefinition", + "nodes": [ + { + "anonymous": false, + "eventSelector": "665f5beb8eab22c2d0fba9f14e33a83ad719ffbed2f484458c23490e8577adc9", + "id": 16, + "name": "TransferAContract", + "nameLocation": "103:17:1", + "nodeType": "EventDefinition", + "parameters": { + "id": 15, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 10, + "indexed": true, + "mutability": "mutable", + "name": "from", + "nameLocation": "137:4:1", + "nodeType": "VariableDeclaration", + "scope": 16, + "src": "121:20:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 9, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "121:7:1", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "visibility": "internal" + }, + { + "constant": false, + "id": 12, + "indexed": true, + "mutability": "mutable", + "name": "to", + "nameLocation": "159:2:1", + "nodeType": "VariableDeclaration", + "scope": 16, + "src": "143:18:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 11, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "143:7:1", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "visibility": "internal" + }, + { + "constant": false, + "id": 14, + "indexed": false, + "mutability": "mutable", + "name": "amount", + "nameLocation": "168:6:1", + "nodeType": "VariableDeclaration", + "scope": 16, + "src": "163:11:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 13, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "163:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "visibility": "internal" + } + ], + "src": "120:55:1" + }, + "src": "97:79:1" + } + ], + "scope": 18, + "src": "72:106:1", + "usedErrors": [], + "usedEvents": [ + 16 + ] + } + ], + "src": "0:179:1" +}, +{ + "absolutePath": "ERC20.sol", + "exportedSymbols": { + "A": [ + 19 + ], + "ERC20": [ + 74 + ] + }, + "id": 75, + "nodeType": "SourceUnit", + "nodes": [ + { + "absolutePath": "A.sol", + "file": "A.sol", + "id": 19, + "nameLocation": "12:1:2", + "nodeType": "ImportDirective", + "scope": 75, + "sourceUnit": 18, + "src": "0:27:2", + "symbolAliases": [], + "unitAlias": "A" + }, + { + "abstract": false, + "baseContracts": [], + "canonicalName": "ERC20", + "contractDependencies": [], + "contractKind": "contract", + "fullyImplemented": true, + "id": 74, + "linearizedBaseContracts": [ + 74 + ], + "name": "ERC20", + "nameLocation": "37:5:2", + "nodeType": "ContractDefinition", + "nodes": [ + { + "anonymous": false, + "eventSelector": "ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + "id": 27, + "name": "Transfer", + "nameLocation": "55:8:2", + "nodeType": "EventDefinition", + "parameters": { + "id": 26, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 21, + "indexed": true, + "mutability": "mutable", + "name": "from", + "nameLocation": "80:4:2", + "nodeType": "VariableDeclaration", + "scope": 27, + "src": "64:20:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 20, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "64:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "visibility": "internal" + }, + { + "constant": false, + "id": 23, + "indexed": true, + "mutability": "mutable", + "name": "to", + "nameLocation": "102:2:2", + "nodeType": "VariableDeclaration", + "scope": 27, + "src": "86:18:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 22, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "86:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "visibility": "internal" + }, + { + "constant": false, + "id": 25, + "indexed": false, + "mutability": "mutable", + "name": "amount", + "nameLocation": "111:6:2", + "nodeType": "VariableDeclaration", + "scope": 27, + "src": "106:11:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 24, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "106:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "visibility": "internal" + } + ], + "src": "63:55:2" + }, + "src": "49:70:2" + }, + { + "body": { + "id": 72, + "nodeType": "Block", + "src": "145:181:2", + "statements": [ + { + "eventCall": { + "arguments": [ + { + "arguments": [ + { + "hexValue": "31", + "id": 33, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "177:1:2", + "typeDescriptions": { + "typeIdentifier": "t_rational_1_by_1", + "typeString": "int_const 1" + }, + "value": "1" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_1_by_1", + "typeString": "int_const 1" + } + ], + "id": 32, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "169:7:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_address_$", + "typeString": "type(address)" + }, + "typeName": { + "id": 31, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "169:7:2", + "typeDescriptions": {} + } + }, + "id": 34, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "typeConversion", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "169:10:2", + "tryCall": false, + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "arguments": [ + { + "hexValue": "32", + "id": 37, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "189:1:2", + "typeDescriptions": { + "typeIdentifier": "t_rational_2_by_1", + "typeString": "int_const 2" + }, + "value": "2" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_2_by_1", + "typeString": "int_const 2" + } + ], + "id": 36, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "181:7:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_address_$", + "typeString": "type(address)" + }, + "typeName": { + "id": 35, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "181:7:2", + "typeDescriptions": {} + } + }, + "id": 38, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "typeConversion", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "181:10:2", + "tryCall": false, + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "hexValue": "33", + "id": 39, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "193:1:2", + "typeDescriptions": { + "typeIdentifier": "t_rational_3_by_1", + "typeString": "int_const 3" + }, + "value": "3" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_rational_3_by_1", + "typeString": "int_const 3" + } + ], + "id": 30, + "name": "Transfer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 27, + "src": "160:8:2", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,address,uint256)" + } + }, + "id": 40, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "160:35:2", + "tryCall": false, + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 41, + "nodeType": "EmitStatement", + "src": "155:40:2" + }, + { + "eventCall": { + "arguments": [ + { + "arguments": [ + { + "hexValue": "31", + "id": 47, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "230:1:2", + "typeDescriptions": { + "typeIdentifier": "t_rational_1_by_1", + "typeString": "int_const 1" + }, + "value": "1" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_1_by_1", + "typeString": "int_const 1" + } + ], + "id": 46, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "222:7:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_address_$", + "typeString": "type(address)" + }, + "typeName": { + "id": 45, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "222:7:2", + "typeDescriptions": {} + } + }, + "id": 48, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "typeConversion", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "222:10:2", + "tryCall": false, + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "arguments": [ + { + "hexValue": "32", + "id": 51, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "242:1:2", + "typeDescriptions": { + "typeIdentifier": "t_rational_2_by_1", + "typeString": "int_const 2" + }, + "value": "2" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_2_by_1", + "typeString": "int_const 2" + } + ], + "id": 50, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "234:7:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_address_$", + "typeString": "type(address)" + }, + "typeName": { + "id": 49, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "234:7:2", + "typeDescriptions": {} + } + }, + "id": 52, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "typeConversion", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "234:10:2", + "tryCall": false, + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "hexValue": "33", + "id": 53, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "246:1:2", + "typeDescriptions": { + "typeIdentifier": "t_rational_3_by_1", + "typeString": "int_const 3" + }, + "value": "3" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_rational_3_by_1", + "typeString": "int_const 3" + } + ], + "expression": { + "id": 42, + "name": "A", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 19, + "src": "210:1:2", + "typeDescriptions": { + "typeIdentifier": "t_module_18", + "typeString": "module \"A.sol\"" + } + }, + "id": 44, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberLocation": "212:9:2", + "memberName": "TransferA", + "nodeType": "MemberAccess", + "referencedDeclaration": 8, + "src": "210:11:2", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,address,uint256)" + } + }, + "id": 54, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "210:38:2", + "tryCall": false, + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 55, + "nodeType": "EmitStatement", + "src": "205:43:2" + }, + { + "eventCall": { + "arguments": [ + { + "arguments": [ + { + "hexValue": "31", + "id": 63, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "301:1:2", + "typeDescriptions": { + "typeIdentifier": "t_rational_1_by_1", + "typeString": "int_const 1" + }, + "value": "1" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_1_by_1", + "typeString": "int_const 1" + } + ], + "id": 62, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "293:7:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_address_$", + "typeString": "type(address)" + }, + "typeName": { + "id": 61, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "293:7:2", + "typeDescriptions": {} + } + }, + "id": 64, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "typeConversion", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "293:10:2", + "tryCall": false, + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "arguments": [ + { + "hexValue": "32", + "id": 67, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "313:1:2", + "typeDescriptions": { + "typeIdentifier": "t_rational_2_by_1", + "typeString": "int_const 2" + }, + "value": "2" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_2_by_1", + "typeString": "int_const 2" + } + ], + "id": 66, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "305:7:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_address_$", + "typeString": "type(address)" + }, + "typeName": { + "id": 65, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "305:7:2", + "typeDescriptions": {} + } + }, + "id": 68, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "typeConversion", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "305:10:2", + "tryCall": false, + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "hexValue": "33", + "id": 69, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "317:1:2", + "typeDescriptions": { + "typeIdentifier": "t_rational_3_by_1", + "typeString": "int_const 3" + }, + "value": "3" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_rational_3_by_1", + "typeString": "int_const 3" + } + ], + "expression": { + "expression": { + "id": 56, + "name": "A", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 19, + "src": "263:1:2", + "typeDescriptions": { + "typeIdentifier": "t_module_18", + "typeString": "module \"A.sol\"" + } + }, + "id": 59, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberLocation": "265:9:2", + "memberName": "AContract", + "nodeType": "MemberAccess", + "referencedDeclaration": 17, + "src": "263:11:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_contract$_AContract_$17_$", + "typeString": "type(contract AContract)" + } + }, + "id": 60, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberLocation": "275:17:2", + "memberName": "TransferAContract", + "nodeType": "MemberAccess", + "referencedDeclaration": 16, + "src": "263:29:2", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,address,uint256)" + } + }, + "id": 70, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "263:56:2", + "tryCall": false, + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 71, + "nodeType": "EmitStatement", + "src": "258:61:2" + } + ] + }, + "functionSelector": "26121ff0", + "id": 73, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "f", + "nameLocation": "133:1:2", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 28, + "nodeType": "ParameterList", + "parameters": [], + "src": "135:2:2" + }, + "returnParameters": { + "id": 29, + "nodeType": "ParameterList", + "parameters": [], + "src": "145:0:2" + }, + "scope": 74, + "src": "124:202:2", + "stateMutability": "nonpayable", + "virtual": false, + "visibility": "public" + } + ], + "scope": 75, + "src": "28:300:2", + "usedErrors": [], + "usedEvents": [ + 8, + 16, + 27 + ] + } + ], + "src": "0:329:2" +} +] diff --git a/test/libsolidity/ASTJSON/emit_event_from_module_via_member_access.sol b/test/libsolidity/ASTJSON/emit_event_from_module_via_member_access.sol new file mode 100644 index 000000000000..fa9614e21400 --- /dev/null +++ b/test/libsolidity/ASTJSON/emit_event_from_module_via_member_access.sol @@ -0,0 +1,18 @@ +==== Source: A.sol ==== +event TransferA(address indexed from, address indexed to, uint amount); +contract AContract { + event TransferAContract(address indexed from, address indexed to, uint amount); +} + +==== Source: ERC20.sol ==== +import * as A from "A.sol"; +contract ERC20 { + event Transfer(address indexed from, address indexed to, uint amount); + function f () public { + emit Transfer(address(1), address(2), 3); + emit A.TransferA(address(1), address(2), 3); + emit A.AContract.TransferAContract(address(1), address(2), 3); + } +} + +// ---- diff --git a/test/libsolidity/ASTJSON/error_from_module_via_member_access.json b/test/libsolidity/ASTJSON/error_from_module_via_member_access.json new file mode 100644 index 000000000000..db9062891a9b --- /dev/null +++ b/test/libsolidity/ASTJSON/error_from_module_via_member_access.json @@ -0,0 +1,544 @@ +[ +{ + "absolutePath": "A.sol", + "exportedSymbols": { + "AContract": [ + 9 + ], + "ErrorA": [ + 4 + ] + }, + "id": 10, + "nodeType": "SourceUnit", + "nodes": [ + { + "errorSelector": "23b0db14", + "id": 4, + "name": "ErrorA", + "nameLocation": "6:6:1", + "nodeType": "ErrorDefinition", + "parameters": { + "id": 3, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 2, + "mutability": "mutable", + "name": "msg", + "nameLocation": "20:3:1", + "nodeType": "VariableDeclaration", + "scope": 4, + "src": "13:10:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_string_memory_ptr", + "typeString": "string" + }, + "typeName": { + "id": 1, + "name": "string", + "nodeType": "ElementaryTypeName", + "src": "13:6:1", + "typeDescriptions": { + "typeIdentifier": "t_string_storage_ptr", + "typeString": "string" + } + }, + "visibility": "internal" + } + ], + "src": "12:12:1" + }, + "src": "0:25:1" + }, + { + "abstract": false, + "baseContracts": [], + "canonicalName": "AContract", + "contractDependencies": [], + "contractKind": "contract", + "fullyImplemented": true, + "id": 9, + "linearizedBaseContracts": [ + 9 + ], + "name": "AContract", + "nameLocation": "35:9:1", + "nodeType": "ContractDefinition", + "nodes": [ + { + "errorSelector": "e00f4941", + "id": 8, + "name": "ErrorAContract", + "nameLocation": "57:14:1", + "nodeType": "ErrorDefinition", + "parameters": { + "id": 7, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 6, + "mutability": "mutable", + "name": "msg", + "nameLocation": "79:3:1", + "nodeType": "VariableDeclaration", + "scope": 8, + "src": "72:10:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_string_memory_ptr", + "typeString": "string" + }, + "typeName": { + "id": 5, + "name": "string", + "nodeType": "ElementaryTypeName", + "src": "72:6:1", + "typeDescriptions": { + "typeIdentifier": "t_string_storage_ptr", + "typeString": "string" + } + }, + "visibility": "internal" + } + ], + "src": "71:12:1" + }, + "src": "51:33:1" + } + ], + "scope": 10, + "src": "26:60:1", + "usedErrors": [ + 8 + ], + "usedEvents": [] + } + ], + "src": "0:87:1" +}, +{ + "absolutePath": "B.sol", + "exportedSymbols": { + "A": [ + 11 + ], + "BContract": [ + 46 + ] + }, + "id": 47, + "nodeType": "SourceUnit", + "nodes": [ + { + "absolutePath": "A.sol", + "file": "A.sol", + "id": 11, + "nameLocation": "12:1:2", + "nodeType": "ImportDirective", + "scope": 47, + "sourceUnit": 10, + "src": "0:27:2", + "symbolAliases": [], + "unitAlias": "A" + }, + { + "abstract": false, + "baseContracts": [], + "canonicalName": "BContract", + "contractDependencies": [], + "contractKind": "contract", + "fullyImplemented": true, + "id": 46, + "linearizedBaseContracts": [ + 46 + ], + "name": "BContract", + "nameLocation": "37:9:2", + "nodeType": "ContractDefinition", + "nodes": [ + { + "errorSelector": "1e012d26", + "id": 15, + "name": "ErrorBContract", + "nameLocation": "59:14:2", + "nodeType": "ErrorDefinition", + "parameters": { + "id": 14, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 13, + "mutability": "mutable", + "name": "msg", + "nameLocation": "81:3:2", + "nodeType": "VariableDeclaration", + "scope": 15, + "src": "74:10:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_string_memory_ptr", + "typeString": "string" + }, + "typeName": { + "id": 12, + "name": "string", + "nodeType": "ElementaryTypeName", + "src": "74:6:2", + "typeDescriptions": { + "typeIdentifier": "t_string_storage_ptr", + "typeString": "string" + } + }, + "visibility": "internal" + } + ], + "src": "73:12:2" + }, + "src": "53:33:2" + }, + { + "body": { + "id": 22, + "nodeType": "Block", + "src": "113:52:2", + "statements": [ + { + "errorCall": { + "arguments": [ + { + "hexValue": "736f6d65206572726f72", + "id": 19, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "145:12:2", + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_b4ae9cd779cde5df80ff601d28c3fa893d24133d1b4e6fdffbb3a05b40d7a577", + "typeString": "literal_string \"some error\"" + }, + "value": "some error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_b4ae9cd779cde5df80ff601d28c3fa893d24133d1b4e6fdffbb3a05b40d7a577", + "typeString": "literal_string \"some error\"" + } + ], + "id": 18, + "name": "ErrorBContract", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 15, + "src": "130:14:2", + "typeDescriptions": { + "typeIdentifier": "t_function_error_pure$_t_string_memory_ptr_$returns$_t_error_$", + "typeString": "function (string memory) pure returns (error)" + } + }, + "id": 20, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "130:28:2", + "tryCall": false, + "typeDescriptions": { + "typeIdentifier": "t_error", + "typeString": "error" + } + }, + "id": 21, + "nodeType": "RevertStatement", + "src": "123:35:2" + } + ] + }, + "functionSelector": "c27fc305", + "id": 23, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "f1", + "nameLocation": "100:2:2", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 16, + "nodeType": "ParameterList", + "parameters": [], + "src": "103:2:2" + }, + "returnParameters": { + "id": 17, + "nodeType": "ParameterList", + "parameters": [], + "src": "113:0:2" + }, + "scope": 46, + "src": "91:74:2", + "stateMutability": "nonpayable", + "virtual": false, + "visibility": "public" + }, + { + "body": { + "id": 32, + "nodeType": "Block", + "src": "192:46:2", + "statements": [ + { + "errorCall": { + "arguments": [ + { + "hexValue": "736f6d65206572726f72", + "id": 29, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "218:12:2", + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_b4ae9cd779cde5df80ff601d28c3fa893d24133d1b4e6fdffbb3a05b40d7a577", + "typeString": "literal_string \"some error\"" + }, + "value": "some error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_b4ae9cd779cde5df80ff601d28c3fa893d24133d1b4e6fdffbb3a05b40d7a577", + "typeString": "literal_string \"some error\"" + } + ], + "expression": { + "id": 26, + "name": "A", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 11, + "src": "209:1:2", + "typeDescriptions": { + "typeIdentifier": "t_module_10", + "typeString": "module \"A.sol\"" + } + }, + "id": 28, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberLocation": "211:6:2", + "memberName": "ErrorA", + "nodeType": "MemberAccess", + "referencedDeclaration": 4, + "src": "209:8:2", + "typeDescriptions": { + "typeIdentifier": "t_function_error_pure$_t_string_memory_ptr_$returns$_t_error_$", + "typeString": "function (string memory) pure returns (error)" + } + }, + "id": 30, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "209:22:2", + "tryCall": false, + "typeDescriptions": { + "typeIdentifier": "t_error", + "typeString": "error" + } + }, + "id": 31, + "nodeType": "RevertStatement", + "src": "202:29:2" + } + ] + }, + "functionSelector": "9942ec6f", + "id": 33, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "f2", + "nameLocation": "179:2:2", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 24, + "nodeType": "ParameterList", + "parameters": [], + "src": "182:2:2" + }, + "returnParameters": { + "id": 25, + "nodeType": "ParameterList", + "parameters": [], + "src": "192:0:2" + }, + "scope": 46, + "src": "170:68:2", + "stateMutability": "nonpayable", + "virtual": false, + "visibility": "public" + }, + { + "body": { + "id": 44, + "nodeType": "Block", + "src": "265:64:2", + "statements": [ + { + "errorCall": { + "arguments": [ + { + "hexValue": "736f6d65206572726f72", + "id": 41, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "309:12:2", + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_b4ae9cd779cde5df80ff601d28c3fa893d24133d1b4e6fdffbb3a05b40d7a577", + "typeString": "literal_string \"some error\"" + }, + "value": "some error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_b4ae9cd779cde5df80ff601d28c3fa893d24133d1b4e6fdffbb3a05b40d7a577", + "typeString": "literal_string \"some error\"" + } + ], + "expression": { + "expression": { + "id": 36, + "name": "A", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 11, + "src": "282:1:2", + "typeDescriptions": { + "typeIdentifier": "t_module_10", + "typeString": "module \"A.sol\"" + } + }, + "id": 39, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberLocation": "284:9:2", + "memberName": "AContract", + "nodeType": "MemberAccess", + "referencedDeclaration": 9, + "src": "282:11:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_contract$_AContract_$9_$", + "typeString": "type(contract AContract)" + } + }, + "id": 40, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberLocation": "294:14:2", + "memberName": "ErrorAContract", + "nodeType": "MemberAccess", + "referencedDeclaration": 8, + "src": "282:26:2", + "typeDescriptions": { + "typeIdentifier": "t_function_error_pure$_t_string_memory_ptr_$returns$_t_error_$", + "typeString": "function (string memory) pure returns (error)" + } + }, + "id": 42, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "282:40:2", + "tryCall": false, + "typeDescriptions": { + "typeIdentifier": "t_error", + "typeString": "error" + } + }, + "id": 43, + "nodeType": "RevertStatement", + "src": "275:47:2" + } + ] + }, + "functionSelector": "aaf05f3d", + "id": 45, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "f3", + "nameLocation": "252:2:2", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 34, + "nodeType": "ParameterList", + "parameters": [], + "src": "255:2:2" + }, + "returnParameters": { + "id": 35, + "nodeType": "ParameterList", + "parameters": [], + "src": "265:0:2" + }, + "scope": 46, + "src": "243:86:2", + "stateMutability": "nonpayable", + "virtual": false, + "visibility": "public" + } + ], + "scope": 47, + "src": "28:303:2", + "usedErrors": [ + 4, + 8, + 15 + ], + "usedEvents": [] + } + ], + "src": "0:332:2" +} +] diff --git a/test/libsolidity/ASTJSON/error_from_module_via_member_access.sol b/test/libsolidity/ASTJSON/error_from_module_via_member_access.sol new file mode 100644 index 000000000000..74c29fabb29f --- /dev/null +++ b/test/libsolidity/ASTJSON/error_from_module_via_member_access.sol @@ -0,0 +1,22 @@ +==== Source: A.sol ==== +error ErrorA(string msg); +contract AContract { + error ErrorAContract(string msg); +} + +==== Source: B.sol ==== +import * as A from "A.sol"; +contract BContract { + error ErrorBContract(string msg); + function f1 () public { + revert ErrorBContract("some error"); + } + function f2 () public { + revert A.ErrorA("some error"); + } + function f3 () public { + revert A.AContract.ErrorAContract("some error"); + } +} + +// ---- diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index 1b66dd60fffb..890a51596af8 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -579,22 +579,16 @@ bool SemanticTest::checkGasCostExpectation(TestFunctionCall& io_test, bool _comp io_test.call().expectations.gasUsedForCodeDeposit.count(setting) ); - // We don't check gas if enforce gas cost is not active - // or test is run with abi encoder v1 only - // or gas used less than threshold for enforcing feature - // or the test has used up all available gas (test will fail anyway) - // or setting is "ir" and it's not included in expectations - // or if the called function is an isoltest builtin e.g. `smokeTest` or `storageEmpty` - if ( - !m_enforceGasCost || - m_gasUsed < m_enforceGasCostMinValue || - m_gasUsed >= InitialGas || - (setting == "ir" && io_test.call().expectations.gasUsedExcludingCode.count(setting) == 0) || - io_test.call().kind == FunctionCall::Kind::Builtin - ) + bool uninteresting = + m_gasUsed < m_enforceGasCostMinValue || // gas used less than threshold for enforcing feature + m_gasUsed >= InitialGas || // test has used up all available gas (test will fail anyway) + setting == "ir" || + io_test.call().kind == FunctionCall::Kind::Builtin; // isoltest builtin e.g. `smokeTest` or `storageEmpty` + bool gasValueMissing = !io_test.call().expectations.gasUsedExcludingCode.contains(setting); + if (!m_enforceGasCost || (gasValueMissing && uninteresting)) return true; - solAssert(!m_runWithABIEncoderV1Only, ""); + solAssert(!m_runWithABIEncoderV1Only); // NOTE: Cost excluding code is unlikely to be negative but it may still be possible due to refunds. // We'll deal with it when we actually have a test case like that. diff --git a/test/libsolidity/natspecJSON/emit_event_from_module_via_member_access.sol b/test/libsolidity/natspecJSON/emit_event_from_module_via_member_access.sol new file mode 100644 index 000000000000..39d1644fe581 --- /dev/null +++ b/test/libsolidity/natspecJSON/emit_event_from_module_via_member_access.sol @@ -0,0 +1,115 @@ +==== Source: A.sol ==== +/// @notice This event is emitted when a transfer from A occurs. +/// @param from The source account. +/// @param to The destination account. +/// @param amount The amount. +/// @dev A test case! +event TransferA(address indexed from, address indexed to, uint amount); + +contract AContract { + /// @notice This event is emitted when a transfer from AContract occurs. + /// @param from The source account. + /// @param to The destination account. + /// @param amount The amount. + /// @dev A test case! + event TransferAContract(address indexed from, address indexed to, uint amount); +} + +==== Source: ERC20.sol ==== +import * as A from "A.sol"; +contract ERC20 { + /// @notice This event is emitted when a transfer from ERC20 occurs. + /// @param from The source account. + /// @param to The destination account. + /// @param amount The amount. + /// @dev A test case! + event Transfer(address indexed from, address indexed to, uint amount); + + function test() public { + emit Transfer(address(1), address(5), 1); + emit A.AContract.TransferAContract(address(1), address(5), 1); + emit A.TransferA(address(1), address(5), 1); + } +} + +// ---- +// ---- +// A.sol:AContract devdoc +// { +// "events": { +// "TransferAContract(address,address,uint256)": { +// "details": "A test case!", +// "params": { +// "amount": "The amount.", +// "from": "The source account.", +// "to": "The destination account." +// } +// } +// }, +// "kind": "dev", +// "methods": {}, +// "version": 1 +// } +// +// A.sol:AContract userdoc +// { +// "events": { +// "TransferAContract(address,address,uint256)": { +// "notice": "This event is emitted when a transfer from AContract occurs." +// } +// }, +// "kind": "user", +// "methods": {}, +// "version": 1 +// } +// +// ERC20.sol:ERC20 devdoc +// { +// "events": { +// "Transfer(address,address,uint256)": { +// "details": "A test case!", +// "params": { +// "amount": "The amount.", +// "from": "The source account.", +// "to": "The destination account." +// } +// }, +// "TransferA(address,address,uint256)": { +// "details": "A test case!", +// "params": { +// "amount": "The amount.", +// "from": "The source account.", +// "to": "The destination account." +// } +// }, +// "TransferAContract(address,address,uint256)": { +// "details": "A test case!", +// "params": { +// "amount": "The amount.", +// "from": "The source account.", +// "to": "The destination account." +// } +// } +// }, +// "kind": "dev", +// "methods": {}, +// "version": 1 +// } +// +// ERC20.sol:ERC20 userdoc +// { +// "events": { +// "Transfer(address,address,uint256)": { +// "notice": "This event is emitted when a transfer from ERC20 occurs." +// }, +// "TransferA(address,address,uint256)": { +// "notice": "This event is emitted when a transfer from A occurs." +// }, +// "TransferAContract(address,address,uint256)": { +// "notice": "This event is emitted when a transfer from AContract occurs." +// } +// }, +// "kind": "user", +// "methods": {}, +// "version": 1 +// } diff --git a/test/libsolidity/natspecJSON/error_from_module_via_member_access.sol b/test/libsolidity/natspecJSON/error_from_module_via_member_access.sol new file mode 100644 index 000000000000..0c2e44e3cee7 --- /dev/null +++ b/test/libsolidity/natspecJSON/error_from_module_via_member_access.sol @@ -0,0 +1,127 @@ +==== Source: A.sol ==== +/// Something failed. +/// @dev an error. +/// @param a first parameter +/// @param b second parameter +error E(uint a, uint b); + +contract AContract { + /// Something failed. + /// @dev an error. + /// @param a first parameter + /// @param b second parameter + error EAContract(uint a, uint b); +} + +==== Source: ERC20.sol ==== +import * as A from "A.sol"; +contract ERC20 { + /// Something failed. + /// @dev an error. + /// @param a first parameter + /// @param b second parameter + error EERC20(uint a, uint b); + + function f(uint a) public pure { + if (a > 0) + revert EERC20(1, 2); + else if (a < 0) + revert A.AContract.EAContract(5, 6); + else + revert A.E(5, 6); + } +} + +// ---- +// ---- +// A.sol:AContract devdoc +// { +// "errors": { +// "EAContract(uint256,uint256)": [ +// { +// "details": "an error.", +// "params": { +// "a": "first parameter", +// "b": "second parameter" +// } +// } +// ] +// }, +// "kind": "dev", +// "methods": {}, +// "version": 1 +// } +// +// A.sol:AContract userdoc +// { +// "errors": { +// "EAContract(uint256,uint256)": [ +// { +// "notice": "Something failed." +// } +// ] +// }, +// "kind": "user", +// "methods": {}, +// "version": 1 +// } +// +// ERC20.sol:ERC20 devdoc +// { +// "errors": { +// "E(uint256,uint256)": [ +// { +// "details": "an error.", +// "params": { +// "a": "first parameter", +// "b": "second parameter" +// } +// } +// ], +// "EAContract(uint256,uint256)": [ +// { +// "details": "an error.", +// "params": { +// "a": "first parameter", +// "b": "second parameter" +// } +// } +// ], +// "EERC20(uint256,uint256)": [ +// { +// "details": "an error.", +// "params": { +// "a": "first parameter", +// "b": "second parameter" +// } +// } +// ] +// }, +// "kind": "dev", +// "methods": {}, +// "version": 1 +// } +// +// ERC20.sol:ERC20 userdoc +// { +// "errors": { +// "E(uint256,uint256)": [ +// { +// "notice": "Something failed." +// } +// ], +// "EAContract(uint256,uint256)": [ +// { +// "notice": "Something failed." +// } +// ], +// "EERC20(uint256,uint256)": [ +// { +// "notice": "Something failed." +// } +// ] +// }, +// "kind": "user", +// "methods": {}, +// "version": 1 +// } diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol index 8df4090c3662..78da59648a9d 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol @@ -38,6 +38,7 @@ contract C is B { } // ---- // test() -> 5, 10 -// gas irOptimized: 87337 +// gas irOptimized: 65040 +// gas irOptimized code: 26200 // gas legacy: 66250 // gas legacy code: 36400 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol index cdce1b95a529..739c4c84076b 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol @@ -21,5 +21,5 @@ contract C { // f(uint256[][1]): 32, 32, 1, 42 -> true // f(uint256[][1]): 32, 32, 8, 421, 422, 423, 424, 425, 426, 427, 428 -> true // gas irOptimized: 120978 -// gas legacy: 101568 -// gas legacyOptimized: 119092 +// gas legacy: 98324 +// gas legacyOptimized: 94348 diff --git a/test/libsolidity/semanticTests/array/array_storage_length_access.sol b/test/libsolidity/semanticTests/array/array_storage_length_access.sol index 47fddc5547bc..4f7308c24483 100644 --- a/test/libsolidity/semanticTests/array/array_storage_length_access.sol +++ b/test/libsolidity/semanticTests/array/array_storage_length_access.sol @@ -12,7 +12,7 @@ contract C { // set_get_length(uint256): 10 -> 10 // set_get_length(uint256): 20 -> 20 // set_get_length(uint256): 0xFF -> 0xFF -// gas irOptimized: 96690 +// gas irOptimized: 98764 // gas legacy: 128571 // gas legacyOptimized: 110143 // set_get_length(uint256): 0xFFF -> 0xFFF diff --git a/test/libsolidity/semanticTests/array/array_storage_push_empty_length_address.sol b/test/libsolidity/semanticTests/array/array_storage_push_empty_length_address.sol index 607e1ecd3547..bf06393a63ff 100644 --- a/test/libsolidity/semanticTests/array/array_storage_push_empty_length_address.sol +++ b/test/libsolidity/semanticTests/array/array_storage_push_empty_length_address.sol @@ -17,9 +17,9 @@ contract C { // set_get_length(uint256): 10 -> 10 // set_get_length(uint256): 20 -> 20 // set_get_length(uint256): 0 -> 0 -// gas irOptimized: 77628 -// gas legacy: 77730 -// gas legacyOptimized: 77162 +// gas irOptimized: 76123 +// gas legacy: 75618 +// gas legacyOptimized: 75076 // set_get_length(uint256): 0xFF -> 0xFF // gas irOptimized: 168565 // gas legacy: 696850 diff --git a/test/libsolidity/semanticTests/array/array_storage_push_pop.sol b/test/libsolidity/semanticTests/array/array_storage_push_pop.sol index a4c7d34d7fef..609944ddc086 100644 --- a/test/libsolidity/semanticTests/array/array_storage_push_pop.sol +++ b/test/libsolidity/semanticTests/array/array_storage_push_pop.sol @@ -13,9 +13,9 @@ contract C { // set_get_length(uint256): 1 -> 0 // set_get_length(uint256): 10 -> 0 // set_get_length(uint256): 20 -> 0 -// gas irOptimized: 106222 -// gas legacy: 105722 -// gas legacyOptimized: 103508 +// gas irOptimized: 87226 +// gas legacy: 85609 +// gas legacyOptimized: 83462 // set_get_length(uint256): 0xFF -> 0 // gas irOptimized: 833586 // gas legacy: 807764 diff --git a/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol b/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol index 060cafe39a78..68e4b5d62caa 100644 --- a/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol +++ b/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol @@ -41,15 +41,15 @@ contract c { // ---- // storageEmpty -> 1 // test_short() -> 1780731860627700044960722568376587075150542249149356309979516913770823710 -// gas legacy: 59838 -// gas legacyOptimized: 58606 +// gas legacy: 57661 +// gas legacyOptimized: 57073 // storageEmpty -> 0 // test_long() -> 67 -// gas irOptimized: 89148 +// gas irOptimized: 89482 // gas legacy: 101607 // gas legacyOptimized: 100479 // storageEmpty -> 0 // test_pop() -> 1780731860627700044960722568376592200742329637303199754547598369979433020 -// gas legacy: 61930 -// gas legacyOptimized: 59404 +// gas legacy: 58079 +// gas legacyOptimized: 56932 // storageEmpty -> 0 diff --git a/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol b/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol index b2be566a9df1..285bc5f6f878 100644 --- a/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol @@ -19,9 +19,9 @@ contract c { // gas legacyOptimized: 515555 // storageEmpty -> 0 // halfClear() -> -// gas irOptimized: 113961 -// gas legacy: 113257 -// gas legacyOptimized: 113120 +// gas irOptimized: 91472 +// gas legacy: 90567 +// gas legacyOptimized: 90457 // storageEmpty -> 0 // fullClear() -> // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_copy_long.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_copy_long.sol index c64d93c1208a..01d2d83f9a44 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_copy_long.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_copy_long.sol @@ -9,6 +9,6 @@ contract c { } // ---- // test() -> 0x20, 29, 0x0303030303030303030303030303030303030303030303030303030303000000 -// gas irOptimized: 109310 -// gas legacy: 101220 -// gas legacyOptimized: 123422 +// gas irOptimized: 85778 +// gas legacy: 97666 +// gas legacyOptimized: 96874 diff --git a/test/libsolidity/semanticTests/array/push/array_push_packed_array.sol b/test/libsolidity/semanticTests/array/push/array_push_packed_array.sol index e7a3bdbd1f18..e6c010230859 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_packed_array.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_packed_array.sol @@ -13,6 +13,6 @@ contract c { } // ---- // test() -> 1, 2, 3, 4 -// gas irOptimized: 93017 -// gas legacy: 92798 -// gas legacyOptimized: 92062 +// gas irOptimized: 92545 +// gas legacy: 92756 +// gas legacyOptimized: 92045 diff --git a/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol b/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol index 3b35719dbb8d..626c65871ff2 100644 --- a/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol +++ b/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol @@ -36,7 +36,7 @@ contract C { // f(uint256,uint256): 84, 128 -> // gas irOptimized: 118708 // gas legacy: 109977 -// gas legacyOptimized: 96331 +// gas legacyOptimized: 98446 // l() -> 2 // ll(uint256): 1 -> 85 // a(uint256,uint256): 0, 42 -> 64 diff --git a/test/libsolidity/semanticTests/cleanup/indexed_log_topic_during_explicit_downcast_during_emissions.sol b/test/libsolidity/semanticTests/cleanup/indexed_log_topic_during_explicit_downcast_during_emissions.sol index 742c02693df5..08bfac8c273b 100644 --- a/test/libsolidity/semanticTests/cleanup/indexed_log_topic_during_explicit_downcast_during_emissions.sol +++ b/test/libsolidity/semanticTests/cleanup/indexed_log_topic_during_explicit_downcast_during_emissions.sol @@ -12,6 +12,7 @@ contract C { // ---- // constructor() -> // ~ emit ev0(bytes1): #"1" -// gas legacy: 168735 +// gas legacy: 58919 +// gas legacy code: 33600 // j() -> // ~ emit ev0(bytes1): #"1" diff --git a/test/libsolidity/semanticTests/constants/assign_type_info.sol b/test/libsolidity/semanticTests/constants/assign_type_info.sol new file mode 100644 index 000000000000..0fca83d547bc --- /dev/null +++ b/test/libsolidity/semanticTests/constants/assign_type_info.sol @@ -0,0 +1,13 @@ +contract A { +} + +contract B { + bytes constant creationCode = type(A).creationCode; + bytes constant runtimeCode = type(A).runtimeCode; + + function nonEmptyCode() public pure returns (bool) { + return creationCode.length > 0 && runtimeCode.length > 0; + } +} +// ---- +// nonEmptyCode() -> true diff --git a/test/libsolidity/semanticTests/errors/error_throw_from_module_via_member_access.sol b/test/libsolidity/semanticTests/errors/error_throw_from_module_via_member_access.sol new file mode 100644 index 000000000000..f9b968694aa4 --- /dev/null +++ b/test/libsolidity/semanticTests/errors/error_throw_from_module_via_member_access.sol @@ -0,0 +1,31 @@ +==== Source: A.sol ==== +error ErrorA(string msg); +==== Source: B.sol ==== +import * as A from "A.sol"; + +error ErrorB(string msg); + +contract BContract { + error ErrorB(string msg); +} +==== Source: C.sol ==== +import * as B from "B.sol"; + +contract CContract { + function error1() external { + revert B.ErrorB("B error"); + } + + function error2() external { + revert B.BContract.ErrorB("B.BContract error"); + } + + function error3() external { + revert B.A.ErrorA("B.A error"); + } +} + +// ---- +// error1() -> FAILURE, hex"a5f9ec67", 0x20, 7, "B error" +// error2() -> FAILURE, hex"a5f9ec67", 0x20, 17, "B.BContract error" +// error3() -> FAILURE, hex"23b0db14", 0x20, 9, "B.A error" diff --git a/test/libsolidity/semanticTests/events/event_emit_from_module_via_member_access.sol b/test/libsolidity/semanticTests/events/event_emit_from_module_via_member_access.sol new file mode 100644 index 000000000000..b944ea1148a7 --- /dev/null +++ b/test/libsolidity/semanticTests/events/event_emit_from_module_via_member_access.sol @@ -0,0 +1,26 @@ +==== Source: A.sol ==== +event Transfer(address indexed _from, address indexed _to, uint256 _value); +==== Source: B.sol ==== +import * as A from "A.sol"; + +event Transfer(address indexed _from, address indexed _to, uint256 _value); + +contract BContract { + event Transfer(address indexed _from, address indexed _to, uint256 _value); +} +==== Source: C.sol ==== +import * as B from "B.sol"; + +contract CContract { + function returnAddress() external { + emit B.Transfer(address(0x0b), address(0x0c), 0x0d); + emit B.BContract.Transfer(address(0x0e), address(0x0f), 0x10); + emit B.A.Transfer(address(0x11), address(0x12), 0x13); + } +} + +// ---- +// returnAddress() -> +// ~ emit Transfer(address,address,uint256): #0x0b, #0x0c, 0x0d +// ~ emit Transfer(address,address,uint256): #0x0e, #0x0f, 0x10 +// ~ emit Transfer(address,address,uint256): #0x11, #0x12, 0x13 diff --git a/test/libsolidity/semanticTests/events/event_indexed_mixed.sol b/test/libsolidity/semanticTests/events/event_indexed_mixed.sol index ad753ef16fde..66c7f8b5faa4 100644 --- a/test/libsolidity/semanticTests/events/event_indexed_mixed.sol +++ b/test/libsolidity/semanticTests/events/event_indexed_mixed.sol @@ -11,6 +11,6 @@ contract C { // ---- // deposit() -> // ~ emit E(uint256,uint256,uint256,bytes): #0x02, 0x01, 0x03, 0x60, 0x03, "def" -// gas irOptimized: 23709 -// gas legacy: 24342 -// gas legacyOptimized: 23753 +// gas irOptimized: 23695 +// gas legacy: 24328 +// gas legacyOptimized: 23752 diff --git a/test/libsolidity/semanticTests/events/event_signature_in_library.sol b/test/libsolidity/semanticTests/events/event_signature_in_library.sol index d8dc0f15808d..0991cd28a302 100644 --- a/test/libsolidity/semanticTests/events/event_signature_in_library.sol +++ b/test/libsolidity/semanticTests/events/event_signature_in_library.sol @@ -18,4 +18,5 @@ contract C { // ---- // constructor() // ~ emit E((uint8,int16),(uint8,int16)): #0xad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5, 0x00, 0x00 -// gas legacy: 150602 +// gas legacy: 62552 +// gas legacy code: 1600 diff --git a/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol b/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol index 47feaf5258bb..e89eeba986fa 100644 --- a/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol +++ b/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol @@ -82,9 +82,9 @@ contract FixedFeeRegistrar is Registrar { // gas legacyOptimized code: 388000 // reserve(string), 69 ether: 0x20, 3, "abc" -> // ~ emit Changed(string): #0x4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 -// gas irOptimized: 45967 -// gas legacy: 46842 -// gas legacyOptimized: 46091 +// gas irOptimized: 45741 +// gas legacy: 46698 +// gas legacyOptimized: 45948 // owner(string): 0x20, 3, "abc" -> 0x1212121212121212121212121212120000000012 // reserve(string), 70 ether: 0x20, 3, "def" -> // ~ emit Changed(string): #0x34607c9bbfeb9c23509680f04363f298fdb0b5f9abe327304ecd1daca08cda9c diff --git a/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol b/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol index cb345757f8e1..35e083d5c263 100644 --- a/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol +++ b/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol @@ -55,42 +55,42 @@ contract test { // gas legacyOptimized: 178012 // gas legacyOptimized code: 1669600 // div(int256,int256): 3141592653589793238, 88714123 -> 35412542528203691288251815328 -// gas irOptimized: 22137 -// gas legacy: 22767 -// gas legacyOptimized: 22282 +// gas irOptimized: 22045 +// gas legacy: 22736 +// gas legacyOptimized: 22264 // exp(int256): 3141592653589793238 -> 23140692632779268978 -// gas irOptimized: 24545 -// gas legacy: 25203 -// gas legacyOptimized: 24357 +// gas irOptimized: 24452 +// gas legacy: 25124 +// gas legacyOptimized: 24351 // exp2(int256): 3141592653589793238 -> 8824977827076287620 -// gas irOptimized: 24257 -// gas legacy: 24864 -// gas legacyOptimized: 24110 +// gas irOptimized: 24162 +// gas legacy: 24787 +// gas legacyOptimized: 24105 // gm(int256,int256): 3141592653589793238, 88714123 -> 16694419339601 -// gas irOptimized: 22970 -// gas legacy: 23228 -// gas legacyOptimized: 22683 +// gas irOptimized: 22805 +// gas legacy: 23202 +// gas legacyOptimized: 22685 // log10(int256): 3141592653589793238 -> 4971498726941338506 -// gas irOptimized: 30609 -// gas legacy: 32934 -// gas legacyOptimized: 30323 +// gas irOptimized: 30300 +// gas legacy: 32841 +// gas legacyOptimized: 30249 // log2(int256): 3141592653589793238 -> 1651496129472318782 -// gas irOptimized: 28819 -// gas legacy: 31067 -// gas legacyOptimized: 28426 +// gas irOptimized: 28566 +// gas legacy: 30979 +// gas legacyOptimized: 28357 // mul(int256,int256): 3141592653589793238, 88714123 -> 278703637 -// gas irOptimized: 22225 -// gas legacy: 22807 -// gas legacyOptimized: 22295 +// gas irOptimized: 22147 +// gas legacy: 22775 +// gas legacyOptimized: 22288 // pow(int256,uint256): 3141592653589793238, 5 -> 306019684785281453040 -// gas irOptimized: 22635 -// gas legacy: 23508 +// gas irOptimized: 22488 +// gas legacy: 23453 // gas legacyOptimized: 22921 // sqrt(int256): 3141592653589793238 -> 1772453850905516027 -// gas irOptimized: 22650 -// gas legacy: 22802 -// gas legacyOptimized: 22422 +// gas irOptimized: 22458 +// gas legacy: 22784 +// gas legacyOptimized: 22420 // benchmark(int256): 3141592653589793238 -> 998882724338592125, 1000000000000000000, 1000000000000000000 -// gas irOptimized: 36630 -// gas legacy: 36673 -// gas legacyOptimized: 34729 +// gas irOptimized: 34893 +// gas legacy: 35244 +// gas legacyOptimized: 33996 diff --git a/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol b/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol index 5902ba4905b1..38d2a20baa2a 100644 --- a/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol +++ b/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol @@ -55,42 +55,42 @@ contract test { // gas legacyOptimized: 168857 // gas legacyOptimized code: 1556200 // div(uint256,uint256): 3141592653589793238, 88714123 -> 35412542528203691288251815328 -// gas irOptimized: 22004 -// gas legacy: 22497 -// gas legacyOptimized: 22010 +// gas irOptimized: 21912 +// gas legacy: 22475 +// gas legacyOptimized: 21998 // exp(uint256): 3141592653589793238 -> 23140692632779268978 -// gas irOptimized: 24444 -// gas legacy: 25104 -// gas legacyOptimized: 24258 +// gas irOptimized: 24334 +// gas legacy: 25026 +// gas legacyOptimized: 24253 // exp2(uint256): 3141592653589793238 -> 8824977827076287620 -// gas irOptimized: 24198 -// gas legacy: 24814 -// gas legacyOptimized: 24062 +// gas irOptimized: 24115 +// gas legacy: 24738 +// gas legacyOptimized: 24058 // gm(uint256,uint256): 3141592653589793238, 88714123 -> 16694419339601 -// gas irOptimized: 22950 -// gas legacy: 23269 -// gas legacyOptimized: 22724 +// gas irOptimized: 22786 +// gas legacy: 23244 +// gas legacyOptimized: 22727 // log10(uint256): 3141592653589793238 -> 0x44fe4fc084a52b8a -// gas irOptimized: 30269 -// gas legacy: 32898 -// gas legacyOptimized: 29925 +// gas irOptimized: 30079 +// gas legacy: 32808 +// gas legacyOptimized: 29912 // log2(uint256): 3141592653589793238 -> 1651496129472318782 -// gas irOptimized: 28235 -// gas legacy: 30986 -// gas legacyOptimized: 28001 +// gas irOptimized: 28107 +// gas legacy: 30900 +// gas legacyOptimized: 27994 // mul(uint256,uint256): 3141592653589793238, 88714123 -> 278703637 -// gas irOptimized: 22048 -// gas legacy: 22604 -// gas legacyOptimized: 22090 +// gas irOptimized: 21988 +// gas legacy: 22581 +// gas legacyOptimized: 22089 // pow(uint256,uint256): 3141592653589793238, 5 -> 306019684785281453040 -// gas irOptimized: 22406 -// gas legacy: 23245 -// gas legacyOptimized: 22646 +// gas irOptimized: 22316 +// gas legacy: 23196 +// gas legacyOptimized: 22652 // sqrt(uint256): 3141592653589793238 -> 1772453850905516027 -// gas irOptimized: 22672 -// gas legacy: 22820 -// gas legacyOptimized: 22440 +// gas irOptimized: 22481 +// gas legacy: 22803 +// gas legacyOptimized: 22439 // benchmark(uint256): 3141592653589793238 -> 998882724338592125, 1000000000000000000, 1000000000000000000 -// gas irOptimized: 35603 -// gas legacy: 35385 -// gas legacyOptimized: 33449 +// gas irOptimized: 33961 +// gas legacy: 34006 +// gas legacyOptimized: 32724 diff --git a/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol b/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol index 70a3004ac4b6..a98e83001a06 100644 --- a/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol +++ b/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol @@ -40,6 +40,6 @@ contract test { // gas legacyOptimized: 82667 // gas legacyOptimized code: 369200 // prb_pi() -> 3141592656369545286 -// gas irOptimized: 57478 +// gas irOptimized: 55036 // gas legacy: 100657 -// gas legacyOptimized: 75735 +// gas legacyOptimized: 74311 diff --git a/test/libsolidity/semanticTests/externalContracts/strings.sol b/test/libsolidity/semanticTests/externalContracts/strings.sol index cb9616bbe40b..8deb86ed517e 100644 --- a/test/libsolidity/semanticTests/externalContracts/strings.sol +++ b/test/libsolidity/semanticTests/externalContracts/strings.sol @@ -56,21 +56,21 @@ contract test { // gas legacyOptimized: 102639 // gas legacyOptimized code: 612400 // toSlice(string): 0x20, 11, "hello world" -> 11, 0xa0 -// gas irOptimized: 22660 -// gas legacy: 23190 -// gas legacyOptimized: 22508 +// gas irOptimized: 22646 +// gas legacy: 23168 +// gas legacyOptimized: 22488 // roundtrip(string): 0x20, 11, "hello world" -> 0x20, 11, "hello world" -// gas irOptimized: 23408 -// gas legacy: 23820 -// gas legacyOptimized: 23123 +// gas irOptimized: 23225 +// gas legacy: 23674 +// gas legacyOptimized: 22991 // utf8len(string): 0x20, 16, "\xf0\x9f\x98\x83\xf0\x9f\x98\x83\xf0\x9f\x98\x83\xf0\x9f\x98\x83" -> 4 # Input: "😃😃😃😃" # -// gas irOptimized: 24026 -// gas legacy: 25716 -// gas legacyOptimized: 24115 +// gas irOptimized: 23956 +// gas legacy: 25621 +// gas legacyOptimized: 24096 // multiconcat(string,uint256): 0x40, 3, 11, "hello world" -> 0x20, 0x58, 0x68656c6c6f20776f726c6468656c6c6f20776f726c6468656c6c6f20776f726c, 0x6468656c6c6f20776f726c6468656c6c6f20776f726c6468656c6c6f20776f72, 49027192869463622675296414541903001712009715982962058146354235762728281047040 # concatenating 3 times # -// gas irOptimized: 28440 -// gas legacy: 31621 -// gas legacyOptimized: 27914 +// gas irOptimized: 27630 +// gas legacy: 30778 +// gas legacyOptimized: 27519 // benchmark(string,bytes32): 0x40, 0x0842021, 8, "solidity" -> 0x2020 // gas irOptimized: 1976778 // gas legacy: 4234020 diff --git a/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol b/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol index 94a721323244..8eeaf7b51cad 100644 --- a/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol +++ b/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol @@ -15,8 +15,10 @@ contract Main { } // ---- // constructor(), 20 wei -> -// gas irOptimized: 100264 +// gas irOptimized: 56314 +// gas irOptimized code: 37400 // gas legacy: 57555 // gas legacy code: 53000 -// gas legacyOptimized: 100361 +// gas legacyOptimized: 56463 +// gas legacyOptimized code: 39600 // s() -> true diff --git a/test/libsolidity/semanticTests/functionTypes/store_function.sol b/test/libsolidity/semanticTests/functionTypes/store_function.sol index eeab740aa0fb..904bc705f725 100644 --- a/test/libsolidity/semanticTests/functionTypes/store_function.sol +++ b/test/libsolidity/semanticTests/functionTypes/store_function.sol @@ -25,7 +25,8 @@ contract C { } // ---- // t() -> 9 -// gas irOptimized: 99064 +// gas irOptimized: 77300 +// gas irOptimized code: 19000 // gas legacy: 79492 // gas legacy code: 69600 // gas legacyOptimized: 77587 diff --git a/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol b/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol index 90a3f9ec8c1f..f339b52445a4 100644 --- a/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol +++ b/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol @@ -22,10 +22,12 @@ contract D { // EVMVersion: >=constantinople // ---- // f() -> 1 -// gas irOptimized: 77051 +// gas irOptimized: 54014 +// gas irOptimized code: 20200 // gas legacy: 54553 // gas legacy code: 57800 // g() -> 5 -// gas irOptimized: 77106 +// gas irOptimized: 54042 +// gas irOptimized code: 20200 // gas legacy: 55090 // gas legacy code: 57800 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol index f64a2e12a10b..e9013d6f52be 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol @@ -22,6 +22,7 @@ contract B { } // ---- // g() -> 42 -// gas irOptimized: 80813 +// gas irOptimized: 54536 +// gas irOptimized code: 24800 // gas legacy: 55868 // gas legacy code: 66600 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol index 07beb2c537d8..36ed3706243a 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol @@ -22,7 +22,8 @@ contract B { } // ---- // g() -> 42 -// gas irOptimized: 100282 +// gas irOptimized: 54828 +// gas irOptimized code: 42000 // gas legacy: 56839 // gas legacy code: 123600 // gas legacyOptimized: 55001 diff --git a/test/libsolidity/semanticTests/inheritance/interface_inheritance_conversions.sol b/test/libsolidity/semanticTests/inheritance/interface_inheritance_conversions.sol index 2448b3e03bc2..95f48f60a12f 100644 --- a/test/libsolidity/semanticTests/inheritance/interface_inheritance_conversions.sol +++ b/test/libsolidity/semanticTests/inheritance/interface_inheritance_conversions.sol @@ -29,10 +29,10 @@ contract C is SubA, SubB { } // ---- // convertParent() -> 1 -// gas irOptimized: 85524 +// gas irOptimized: 21793 // convertSubA() -> 1, 2 -// gas irOptimized: 86155 -// gas legacy: 99047 +// gas irOptimized: 22459 +// gas legacy: 23286 // convertSubB() -> 1, 3 -// gas irOptimized: 86098 -// gas legacy: 98981 +// gas irOptimized: 22330 +// gas legacy: 23154 diff --git a/test/libsolidity/semanticTests/inlineAssembly/keccak_yul_optimization.sol b/test/libsolidity/semanticTests/inlineAssembly/keccak_yul_optimization.sol index 88088bbda84c..e3344bf5d588 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/keccak_yul_optimization.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/keccak_yul_optimization.sol @@ -24,10 +24,10 @@ contract C { } // ---- // f() -> 0xcdb56c384a9682c600315e3470157a4cf7638d0d33e9dae5c40ffd2644fc5a80 -// gas irOptimized: 22239 -// gas legacy: 23385 -// gas legacyOptimized: 23092 +// gas irOptimized: 22212 +// gas legacy: 23378 +// gas legacyOptimized: 23089 // g() -> 0xcdb56c384a9682c600315e3470157a4cf7638d0d33e9dae5c40ffd2644fc5a80 -// gas irOptimized: 21277 -// gas legacy: 21462 -// gas legacyOptimized: 21256 +// gas irOptimized: 21251 +// gas legacy: 21456 +// gas legacyOptimized: 21254 diff --git a/test/libsolidity/semanticTests/libraries/using_library_structs.sol b/test/libsolidity/semanticTests/libraries/using_library_structs.sol index c2ecf1036e88..15398e312d7e 100644 --- a/test/libsolidity/semanticTests/libraries/using_library_structs.sol +++ b/test/libsolidity/semanticTests/libraries/using_library_structs.sol @@ -20,5 +20,5 @@ contract Test { // ---- // library: Lib // f() -> 7, 8 -// gas irOptimized: 101818 +// gas irOptimized: 97577 // gas legacy: 101428 diff --git a/test/libsolidity/semanticTests/operators/userDefined/operator_making_pure_external_call.sol b/test/libsolidity/semanticTests/operators/userDefined/operator_making_pure_external_call.sol index 364e589e55c1..b901cab0351a 100644 --- a/test/libsolidity/semanticTests/operators/userDefined/operator_making_pure_external_call.sol +++ b/test/libsolidity/semanticTests/operators/userDefined/operator_making_pure_external_call.sol @@ -54,13 +54,15 @@ contract C { // EVMVersion: >=constantinople // ---- // testMul(int32,int32): 42, 10 -> 420 -// gas irOptimized: 102563 +// gas irOptimized: 54784 +// gas irOptimized code: 40600 // gas legacy: 57117 // gas legacy code: 127000 // gas legacyOptimized: 55246 // gas legacyOptimized code: 68400 // testInc(int32): 42 -> 43 -// gas irOptimized: 102386 +// gas irOptimized: 54621 +// gas irOptimized code: 40600 // gas legacy: 56378 // gas legacy code: 127000 // gas legacyOptimized: 54943 diff --git a/test/libsolidity/semanticTests/operators/userDefined/operator_making_view_external_call.sol b/test/libsolidity/semanticTests/operators/userDefined/operator_making_view_external_call.sol index 54048113c323..15501b3fc24e 100644 --- a/test/libsolidity/semanticTests/operators/userDefined/operator_making_view_external_call.sol +++ b/test/libsolidity/semanticTests/operators/userDefined/operator_making_view_external_call.sol @@ -60,13 +60,15 @@ contract C { // EVMVersion: >=constantinople // ---- // testMul(int32,int32): 42, 10 -> 420 -// gas irOptimized: 102563 +// gas irOptimized: 54784 +// gas irOptimized code: 40600 // gas legacy: 57117 // gas legacy code: 127000 // gas legacyOptimized: 55246 // gas legacyOptimized code: 68400 // testInc(int32): 42 -> 43 -// gas irOptimized: 102386 +// gas irOptimized: 54621 +// gas irOptimized code: 40600 // gas legacy: 56378 // gas legacy code: 127000 // gas legacyOptimized: 54943 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol b/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol index 0e0759d62aa1..acd9ea840895 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol @@ -120,29 +120,29 @@ contract ERC20 { // gas legacyOptimized: 127464 // gas legacyOptimized code: 285400 // totalSupply() -> 20 -// gas irOptimized: 23415 -// gas legacy: 23653 -// gas legacyOptimized: 23368 +// gas irOptimized: 23334 +// gas legacy: 23645 +// gas legacyOptimized: 23367 // transfer(address,uint256): 2, 5 -> true // ~ emit Transfer(address,address,uint256): #0x1212121212121212121212121212120000000012, #0x02, 0x05 -// gas irOptimized: 48471 -// gas legacy: 49572 -// gas legacyOptimized: 48575 +// gas irOptimized: 50997 +// gas legacy: 52323 +// gas legacyOptimized: 51380 // decreaseAllowance(address,uint256): 2, 0 -> true // ~ emit Approval(address,address,uint256): #0x1212121212121212121212121212120000000012, #0x02, 0x00 -// gas irOptimized: 26275 -// gas legacy: 27204 -// gas legacyOptimized: 26317 +// gas irOptimized: 26054 +// gas legacy: 27165 +// gas legacyOptimized: 26320 // decreaseAllowance(address,uint256): 2, 1 -> FAILURE, hex"4e487b71", 0x11 -// gas irOptimized: 24042 -// gas legacy: 24506 -// gas legacyOptimized: 24077 +// gas irOptimized: 23954 +// gas legacy: 24500 +// gas legacyOptimized: 24076 // transfer(address,uint256): 2, 14 -> true // ~ emit Transfer(address,address,uint256): #0x1212121212121212121212121212120000000012, #0x02, 0x0e -// gas irOptimized: 28571 -// gas legacy: 29672 -// gas legacyOptimized: 28675 +// gas irOptimized: 33897 +// gas legacy: 35223 +// gas legacyOptimized: 34280 // transfer(address,uint256): 2, 2 -> FAILURE, hex"4e487b71", 0x11 -// gas irOptimized: 24071 -// gas legacy: 24492 -// gas legacyOptimized: 24074 +// gas irOptimized: 23990 +// gas legacy: 24483 +// gas legacyOptimized: 24072 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/memory_to_storage.sol b/test/libsolidity/semanticTests/userDefinedValueType/memory_to_storage.sol index 40005a035735..6e07e74e9f71 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/memory_to_storage.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/memory_to_storage.sol @@ -23,9 +23,9 @@ contract C { // ---- // s() -> 0, 0, 0x00, 0 // f((uint8,uint16,bytes2,uint8)): 1, 0xff, "ab", 15 -> -// gas irOptimized: 44473 -// gas legacy: 46213 -// gas legacyOptimized: 44671 +// gas irOptimized: 44360 +// gas legacy: 46189 +// gas legacyOptimized: 44673 // s() -> 1, 0xff, 0x6162000000000000000000000000000000000000000000000000000000000000, 15 // g(uint16[]): 0x20, 3, 1, 2, 3 -> 0x20, 3, 1, 2, 3 // gas irOptimized: 68898 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/zero_cost_abstraction_comparison_elementary.sol b/test/libsolidity/semanticTests/userDefinedValueType/zero_cost_abstraction_comparison_elementary.sol index 2c5a15bb93ac..c254d9abdd9d 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/zero_cost_abstraction_comparison_elementary.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/zero_cost_abstraction_comparison_elementary.sol @@ -17,18 +17,18 @@ contract C { } // ---- // getX() -> 0 -// gas irOptimized: 23379 -// gas legacy: 23479 -// gas legacyOptimized: 23311 +// gas irOptimized: 23311 +// gas legacy: 23473 +// gas legacyOptimized: 23309 // setX(int256): 5 -> -// gas irOptimized: 43510 -// gas legacy: 43724 -// gas legacyOptimized: 43516 +// gas irOptimized: 43464 +// gas legacy: 43718 +// gas legacyOptimized: 43513 // getX() -> 5 -// gas irOptimized: 23379 -// gas legacy: 23479 -// gas legacyOptimized: 23311 +// gas irOptimized: 23311 +// gas legacy: 23473 +// gas legacyOptimized: 23309 // add(int256,int256): 200, 99 -> 299 -// gas irOptimized: 21764 -// gas legacy: 22394 -// gas legacyOptimized: 21813 +// gas irOptimized: 21623 +// gas legacy: 22354 +// gas legacyOptimized: 21768 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/zero_cost_abstraction_comparison_userdefined.sol b/test/libsolidity/semanticTests/userDefinedValueType/zero_cost_abstraction_comparison_userdefined.sol index 2f275c543b11..89f811862f40 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/zero_cost_abstraction_comparison_userdefined.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/zero_cost_abstraction_comparison_userdefined.sol @@ -18,18 +18,18 @@ contract C { } // ---- // getX() -> 0 -// gas irOptimized: 23379 -// gas legacy: 23608 -// gas legacyOptimized: 23311 +// gas irOptimized: 23311 +// gas legacy: 23599 +// gas legacyOptimized: 23309 // setX(int256): 5 -> -// gas irOptimized: 43510 -// gas legacy: 43724 -// gas legacyOptimized: 43516 +// gas irOptimized: 43464 +// gas legacy: 43718 +// gas legacyOptimized: 43513 // getX() -> 5 -// gas irOptimized: 23379 -// gas legacy: 23608 -// gas legacyOptimized: 23311 +// gas irOptimized: 23311 +// gas legacy: 23599 +// gas legacyOptimized: 23309 // add(int256,int256): 200, 99 -> 299 -// gas irOptimized: 21764 -// gas legacy: 22523 -// gas legacyOptimized: 21813 +// gas irOptimized: 21623 +// gas legacy: 22480 +// gas legacyOptimized: 21768 diff --git a/test/libsolidity/semanticTests/various/codebalance_assembly.sol b/test/libsolidity/semanticTests/various/codebalance_assembly.sol index fad0d3e5b465..6faffd639965 100644 --- a/test/libsolidity/semanticTests/various/codebalance_assembly.sol +++ b/test/libsolidity/semanticTests/various/codebalance_assembly.sol @@ -21,7 +21,8 @@ contract C { // EVMVersion: >=constantinople // ---- // constructor(), 23 wei -> -// gas legacy: 100517 +// gas legacy: 56667 +// gas legacy code: 42000 // f() -> 0 // g() -> 1 // h() -> 23 diff --git a/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol b/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol index 0ebf772fbad7..d1fae4b7fa72 100644 --- a/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol +++ b/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol @@ -17,4 +17,5 @@ contract C { } // ---- // constructor() -> -// gas irOptimized: 100415 +// gas irOptimized: 56611 +// gas irOptimized code: 39400 diff --git a/test/libsolidity/semanticTests/various/erc20.sol b/test/libsolidity/semanticTests/various/erc20.sol index 1cc77270f67b..13b914d9b80b 100644 --- a/test/libsolidity/semanticTests/various/erc20.sol +++ b/test/libsolidity/semanticTests/various/erc20.sol @@ -103,29 +103,29 @@ contract ERC20 { // gas legacyOptimized: 126934 // gas legacyOptimized code: 282000 // totalSupply() -> 20 -// gas irOptimized: 23415 -// gas legacy: 23524 -// gas legacyOptimized: 23368 +// gas irOptimized: 23334 +// gas legacy: 23519 +// gas legacyOptimized: 23367 // transfer(address,uint256): 2, 5 -> true // ~ emit Transfer(address,address,uint256): #0x1212121212121212121212121212120000000012, #0x02, 0x05 -// gas irOptimized: 48471 -// gas legacy: 49317 -// gas legacyOptimized: 48491 +// gas irOptimized: 51054 +// gas legacy: 52073 +// gas legacyOptimized: 51298 // decreaseAllowance(address,uint256): 2, 0 -> true // ~ emit Approval(address,address,uint256): #0x1212121212121212121212121212120000000012, #0x02, 0x00 -// gas irOptimized: 26275 -// gas legacy: 27012 -// gas legacyOptimized: 26275 +// gas irOptimized: 26087 +// gas legacy: 26977 +// gas legacyOptimized: 26279 // decreaseAllowance(address,uint256): 2, 1 -> FAILURE, hex"4e487b71", 0x11 -// gas irOptimized: 24042 -// gas legacy: 24467 +// gas irOptimized: 23981 +// gas legacy: 24462 // gas legacyOptimized: 24056 // transfer(address,uint256): 2, 14 -> true // ~ emit Transfer(address,address,uint256): #0x1212121212121212121212121212120000000012, #0x02, 0x0e -// gas irOptimized: 28571 -// gas legacy: 29417 -// gas legacyOptimized: 28591 +// gas irOptimized: 33954 +// gas legacy: 34973 +// gas legacyOptimized: 34198 // transfer(address,uint256): 2, 2 -> FAILURE, hex"4e487b71", 0x11 -// gas irOptimized: 24071 -// gas legacy: 24453 -// gas legacyOptimized: 24053 +// gas irOptimized: 24020 +// gas legacy: 24445 +// gas legacyOptimized: 24052 diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_call_indirect_2.sol b/test/libsolidity/smtCheckerTests/external_calls/external_call_indirect_2.sol index 16779bb89a1f..d6575fdc22ba 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_call_indirect_2.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_call_indirect_2.sol @@ -47,7 +47,7 @@ contract C { // ==== // SMTEngine: chc // SMTExtCalls: trusted -// SMTIgnoreOS: macos +// SMTSolvers: eld // ---- // Warning 6328: (434-455): CHC: Assertion violation happens here. // Warning 6328: (1270-1291): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_call_indirect_5.sol b/test/libsolidity/smtCheckerTests/external_calls/external_call_indirect_5.sol index 26d39838ef4b..da3077c84aa1 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_call_indirect_5.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_call_indirect_5.sol @@ -46,6 +46,7 @@ contract C { // SMTContract: C // SMTEngine: chc // SMTExtCalls: trusted +// SMTSolvers: eld // ---- // Warning 6328: (601-622): CHC: Assertion violation happens here. // Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/functions/functions_external_2.sol b/test/libsolidity/smtCheckerTests/functions/functions_external_2.sol index d3373b62d63a..cbac9fbbba3b 100644 --- a/test/libsolidity/smtCheckerTests/functions/functions_external_2.sol +++ b/test/libsolidity/smtCheckerTests/functions/functions_external_2.sol @@ -20,9 +20,9 @@ contract C } } // ==== -// SMTEngine: all +// SMTEngine: chc // SMTIgnoreCex: yes -// SMTIgnoreOS: macos +// SMTSolvers: eld // ---- // Warning 6328: (234-253): CHC: Assertion violation happens here. // Info 1391: CHC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/syntaxTests/array/concat/bytes_concat_valid_type_literal.sol b/test/libsolidity/syntaxTests/array/concat/bytes_concat_valid_type_literal.sol index f39e9039638d..ff003ca8a025 100644 --- a/test/libsolidity/syntaxTests/array/concat/bytes_concat_valid_type_literal.sol +++ b/test/libsolidity/syntaxTests/array/concat/bytes_concat_valid_type_literal.sol @@ -1,6 +1,6 @@ contract C { - function f() public pure { - bytes.concat( + function f() public pure returns (bytes memory) { + return bytes.concat( hex"00", hex"aabbcc", unicode"abc", diff --git a/test/libsolidity/syntaxTests/array/concat/bytes_concat_wrong_type_empty_string_literal.sol b/test/libsolidity/syntaxTests/array/concat/bytes_concat_wrong_type_empty_string_literal.sol index afba249f8d4a..a58cf9f3dd92 100644 --- a/test/libsolidity/syntaxTests/array/concat/bytes_concat_wrong_type_empty_string_literal.sol +++ b/test/libsolidity/syntaxTests/array/concat/bytes_concat_wrong_type_empty_string_literal.sol @@ -1,6 +1,6 @@ contract C { - function f() public pure { - bytes.concat(hex"", unicode"", ""); + function f() public pure returns (bytes memory) { + return bytes.concat(hex"", unicode"", ""); } } // ---- diff --git a/test/libsolidity/syntaxTests/constants/initialization/abi_decode_const_args.sol b/test/libsolidity/syntaxTests/constants/initialization/abi_decode_const_args.sol new file mode 100644 index 000000000000..6f597ae73a6e --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/initialization/abi_decode_const_args.sol @@ -0,0 +1,7 @@ +bytes constant aEncoded = abi.encode( + hex"aaaa" +); + +contract A { + bytes constant a = abi.decode(aEncoded, (bytes)); +} diff --git a/test/libsolidity/syntaxTests/constants/initialization/abi_decode_non_const_args.sol b/test/libsolidity/syntaxTests/constants/initialization/abi_decode_non_const_args.sol new file mode 100644 index 000000000000..e5772333a005 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/initialization/abi_decode_non_const_args.sol @@ -0,0 +1,9 @@ +contract A { + function encoded() private view returns (bytes memory) { + return abi.encode(hex"aaaa"); + } + + bytes constant a = abi.decode(encoded(), (bytes)); +} +// ---- +// TypeError 8349: (142-172): Initial value for constant variable has to be compile-time constant. diff --git a/test/libsolidity/syntaxTests/constants/initialization/abi_encode_call_const_args.sol b/test/libsolidity/syntaxTests/constants/initialization/abi_encode_call_const_args.sol new file mode 100644 index 000000000000..e716694cc311 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/initialization/abi_encode_call_const_args.sol @@ -0,0 +1,5 @@ +contract A { + bool constant FLAG = true; + function f(uint, bool) external {} + bytes constant fCallA = abi.encodeCall(A.f, (123, FLAG)); +} diff --git a/test/libsolidity/syntaxTests/constants/initialization/abi_encode_call_non_const_args.sol b/test/libsolidity/syntaxTests/constants/initialization/abi_encode_call_non_const_args.sol new file mode 100644 index 000000000000..b49213742efe --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/initialization/abi_encode_call_non_const_args.sol @@ -0,0 +1,11 @@ +contract A { + function f(uint a) external {} + + function getA() private view returns(uint) { + return 1; + } + + bytes constant fCallA = abi.encodeCall(A.f, (getA())); +} +// ---- +// TypeError 8349: (151-180): Initial value for constant variable has to be compile-time constant. diff --git a/test/libsolidity/syntaxTests/constants/abi_encoding_constant.sol b/test/libsolidity/syntaxTests/constants/initialization/abi_encoding_builtin_const_args.sol similarity index 100% rename from test/libsolidity/syntaxTests/constants/abi_encoding_constant.sol rename to test/libsolidity/syntaxTests/constants/initialization/abi_encoding_builtin_const_args.sol diff --git a/test/libsolidity/syntaxTests/constants/initialization/abi_encoding_builtin_non_const_args.sol b/test/libsolidity/syntaxTests/constants/initialization/abi_encoding_builtin_non_const_args.sol new file mode 100644 index 000000000000..7e399a0d00d4 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/initialization/abi_encoding_builtin_non_const_args.sol @@ -0,0 +1,13 @@ +contract C { + uint k = 1; + + bytes32 constant a = keccak256(abi.encode(1, k)); + bytes32 constant b = keccak256(abi.encodePacked(uint(1), k)); + bytes32 constant c = keccak256(abi.encodeWithSelector(0x12345678, k, 2)); + bytes32 constant d = keccak256(abi.encodeWithSignature("f()", 1, k)); +} +// ---- +// TypeError 8349: (55-82): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (109-148): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (175-226): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (253-300): Initial value for constant variable has to be compile-time constant. diff --git a/test/libsolidity/syntaxTests/constants/addmod_zero.sol b/test/libsolidity/syntaxTests/constants/initialization/addmod_by_zero.sol similarity index 100% rename from test/libsolidity/syntaxTests/constants/addmod_zero.sol rename to test/libsolidity/syntaxTests/constants/initialization/addmod_by_zero.sol diff --git a/test/libsolidity/syntaxTests/constants/addmod_mulmod_rational.sol b/test/libsolidity/syntaxTests/constants/initialization/addmod_mulmod_rational_arg.sol similarity index 100% rename from test/libsolidity/syntaxTests/constants/addmod_mulmod_rational.sol rename to test/libsolidity/syntaxTests/constants/initialization/addmod_mulmod_rational_arg.sol diff --git a/test/libsolidity/syntaxTests/constants/initialization/block_tx_msg_property.sol b/test/libsolidity/syntaxTests/constants/initialization/block_tx_msg_property.sol new file mode 100644 index 000000000000..54381a2573a1 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/initialization/block_tx_msg_property.sol @@ -0,0 +1,80 @@ +bytes32 constant blockhGlobal = blockhash(1); +bytes32 constant blobhGlobal = blobhash(1); +uint constant bfGlobal = block.basefee; +uint constant blobbfGlobal = block.blobbasefee; +uint constant chainIdGlobal = block.chainid; +address constant coinbaseGlobal = block.coinbase; +uint constant diffGlobal = block.difficulty; +uint constant gaslimitGlobal = block.gaslimit; +uint constant numberGlobal = block.number; +uint constant prevrandaoGlobal = block.prevrandao; +uint constant timestampGlobal = block.timestamp; +uint constant gGlobal = gasleft(); +bytes constant dataGlobal = msg.data; +address constant senderGlobal = msg.sender; +bytes4 constant sigGlobal = msg.sig; +uint constant valueGlobal = msg.value; +uint constant gaspriceGlobal = tx.gasprice; +address constant originGlobal = tx.origin; + +contract A { + bytes32 constant blockh = blockhash(1); + bytes32 constant blobh = blobhash(1); + uint constant bf = block.basefee; + uint constant blobbf = block.blobbasefee; + uint constant chainId = block.chainid; + address constant coinbase = block.coinbase; + uint constant diff = block.difficulty; + uint constant gaslimit = block.gaslimit; + uint constant number = block.number; + uint constant prevrandao = block.prevrandao; + uint constant timestamp = block.timestamp; + uint constant g = gasleft(); + bytes constant data = msg.data; + address constant sender = msg.sender; + bytes4 constant sig = msg.sig; + uint constant value = msg.value; + uint constant gasprice = tx.gasprice; + address constant origin = tx.origin; +} +// ==== +// EVMVersion: >=cancun +// ---- +// TypeError 8349: (32-44): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (77-88): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (115-128): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (159-176): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (208-221): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (257-271): Initial value for constant variable has to be compile-time constant. +// Warning 8417: (300-316): Since the VM version paris, "difficulty" was replaced by "prevrandao", which now returns a random number based on the beacon chain. +// TypeError 8349: (300-316): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (349-363): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (394-406): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (441-457): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (491-506): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (532-541): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (571-579): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (613-623): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (653-660): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (690-699): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (732-743): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (777-786): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (832-844): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (875-886): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (911-924): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (953-970): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (1000-1013): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (1047-1061): Initial value for constant variable has to be compile-time constant. +// Warning 8417: (1088-1104): Since the VM version paris, "difficulty" was replaced by "prevrandao", which now returns a random number based on the beacon chain. +// TypeError 8349: (1088-1104): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (1135-1149): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (1178-1190): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (1223-1239): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (1271-1286): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (1310-1319): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (1347-1355): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (1387-1397): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (1425-1432): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (1460-1469): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (1500-1511): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (1543-1552): Initial value for constant variable has to be compile-time constant. diff --git a/test/libsolidity/syntaxTests/constants/initialization/bytes_concat_const_args.sol b/test/libsolidity/syntaxTests/constants/initialization/bytes_concat_const_args.sol new file mode 100644 index 000000000000..2d87ba56c48f --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/initialization/bytes_concat_const_args.sol @@ -0,0 +1,11 @@ +bytes constant aaaa = hex"aaaa"; + +bytes constant abcGlobal = bytes.concat(aaaa, hex"bbbb", hex"cccc"); + +contract A { + bytes public constant abc = bytes.concat(aaaa, hex"bbbb", hex"cccc"); + + bytes public constant abcCopy = abc; + bytes public constant abcGlobalCopy = abcGlobal; + bytes public constant abcabc = bytes.concat(abc, abcGlobal); +} diff --git a/test/libsolidity/syntaxTests/constants/initialization/bytes_concat_non_const_args.sol b/test/libsolidity/syntaxTests/constants/initialization/bytes_concat_non_const_args.sol new file mode 100644 index 000000000000..225731c1ffde --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/initialization/bytes_concat_non_const_args.sol @@ -0,0 +1,17 @@ +contract A { + function getData() public view returns (bytes memory) { + return msg.data; + } + + function getDataPure() public pure returns (bytes memory) { + return hex"ffff"; + } + + bytes constant abData = bytes.concat(hex"aaaa", hex"bbbb", msg.data); + bytes constant abgetData = bytes.concat(hex"aaaa", hex"bbbb", getData()); + bytes constant abgetDataPure = bytes.concat(hex"aaaa", hex"bbbb", getDataPure()); +} +// ---- +// TypeError 8349: (230-274): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (307-352): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (389-438): Initial value for constant variable has to be compile-time constant. diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_1.sol b/test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_1.sol similarity index 100% rename from test/libsolidity/syntaxTests/constants/cyclic_dependency_1.sol rename to test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_1.sol diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol b/test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_2.sol similarity index 100% rename from test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol rename to test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_2.sol diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_3.sol b/test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_3.sol similarity index 100% rename from test/libsolidity/syntaxTests/constants/cyclic_dependency_3.sol rename to test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_3.sol diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol b/test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_4.sol similarity index 100% rename from test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol rename to test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_4.sol diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_5.sol b/test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_5.sol similarity index 100% rename from test/libsolidity/syntaxTests/constants/cyclic_dependency_5.sol rename to test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_5.sol diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_file_constants.sol b/test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_file.sol similarity index 100% rename from test/libsolidity/syntaxTests/constants/cyclic_dependency_file_constants.sol rename to test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_file.sol diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_file_and_library_constants.sol b/test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_file_and_library.sol similarity index 100% rename from test/libsolidity/syntaxTests/constants/cyclic_dependency_file_and_library_constants.sol rename to test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_file_and_library.sol diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_library_constants.sol b/test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_library.sol similarity index 100% rename from test/libsolidity/syntaxTests/constants/cyclic_dependency_library_constants.sol rename to test/libsolidity/syntaxTests/constants/initialization/constant_with_cyclic_dependency_library.sol diff --git a/test/libsolidity/syntaxTests/constants/division_by_zero.sol b/test/libsolidity/syntaxTests/constants/initialization/division_by_zero.sol similarity index 100% rename from test/libsolidity/syntaxTests/constants/division_by_zero.sol rename to test/libsolidity/syntaxTests/constants/initialization/division_by_zero.sol diff --git a/test/libsolidity/syntaxTests/constants/assign_constant_function_value.sol b/test/libsolidity/syntaxTests/constants/initialization/function_pointer_call.sol similarity index 100% rename from test/libsolidity/syntaxTests/constants/assign_constant_function_value.sol rename to test/libsolidity/syntaxTests/constants/initialization/function_pointer_call.sol diff --git a/test/libsolidity/syntaxTests/constants/initialization/math_builtin_opcode_based_const_args.sol b/test/libsolidity/syntaxTests/constants/initialization/math_builtin_opcode_based_const_args.sol new file mode 100644 index 000000000000..aa13e02b4d1e --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/initialization/math_builtin_opcode_based_const_args.sol @@ -0,0 +1,14 @@ +uint256 constant k = 7; +bytes constant data = hex"ffff"; + +uint256 constant amodGlobal = addmod(1, 8, k); +uint256 constant mmodGlobal = mulmod(1, 8, k); +bytes32 constant keccakGlobal = keccak256(hex"ffff"); +bytes32 constant keccakConstArgGlobal = keccak256(data); + +contract A { + uint256 constant amod = addmod(1, 8, k); + uint256 constant mmod = mulmod(1, 8, k); + bytes32 constant keccak = keccak256(hex"ffff"); + bytes32 constant keccakConstArg = keccak256(data); +} diff --git a/test/libsolidity/syntaxTests/constants/initialization/math_builtin_opcode_based_non_const_args.sol b/test/libsolidity/syntaxTests/constants/initialization/math_builtin_opcode_based_non_const_args.sol new file mode 100644 index 000000000000..208437ab7045 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/initialization/math_builtin_opcode_based_non_const_args.sol @@ -0,0 +1,12 @@ +contract A { + uint256 k = 7; + uint256 constant amod = addmod(1, 8, k); + uint256 constant mmod = mulmod(1, 8, k); + + bytes data = hex"ffff"; + bytes32 constant keccak = keccak256(data); +} +// ---- +// TypeError 8349: (60-75): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (105-120): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (181-196): Initial value for constant variable has to be compile-time constant. diff --git a/test/libsolidity/syntaxTests/constants/initialization/math_builtin_precompile_based_const_args.sol b/test/libsolidity/syntaxTests/constants/initialization/math_builtin_precompile_based_const_args.sol new file mode 100644 index 000000000000..57626ec2f362 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/initialization/math_builtin_precompile_based_const_args.sol @@ -0,0 +1,16 @@ +uint8 constant k = 1; +bytes constant data = hex"ffff"; + +bytes32 constant sGlobal = sha256(hex"ffff"); +bytes32 constant sConstArgGlobal = sha256(data); +address constant addrGlobal = ecrecover("1234", k, "0", abi.decode("", (bytes2))); +bytes20 constant ripemdGlobal = ripemd160(hex"ffff"); +bytes20 constant ripemdConstArgGlobal = ripemd160(data); + +contract A { + bytes32 constant s = sha256(hex"ffff"); + bytes32 constant sConstArg = sha256(data); + address constant addr = ecrecover("1234", k, "0", abi.decode("", (bytes2))); + bytes20 constant ripemd = ripemd160(hex"ffff"); + bytes20 constant ripemdConstArg = ripemd160(data); +} diff --git a/test/libsolidity/syntaxTests/constants/initialization/math_builtin_precompile_based_non_const_args.sol b/test/libsolidity/syntaxTests/constants/initialization/math_builtin_precompile_based_non_const_args.sol new file mode 100644 index 000000000000..fef5ccc88ca5 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/initialization/math_builtin_precompile_based_non_const_args.sol @@ -0,0 +1,10 @@ +contract A { + bytes data = hex"ffff"; + bytes32 constant sha = sha256(data); + bytes20 constant ripemd = ripemd160(data); + address constant addr = ecrecover("1234", 1, "0", abi.decode(data, (bytes2))); +} +// ---- +// TypeError 8349: (68-80): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (112-127): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (157-210): Initial value for constant variable has to be compile-time constant. diff --git a/test/libsolidity/syntaxTests/constants/mod_zero.sol b/test/libsolidity/syntaxTests/constants/initialization/modulo_by_zero.sol similarity index 100% rename from test/libsolidity/syntaxTests/constants/mod_zero.sol rename to test/libsolidity/syntaxTests/constants/initialization/modulo_by_zero.sol diff --git a/test/libsolidity/syntaxTests/constants/mulmod_zero.sol b/test/libsolidity/syntaxTests/constants/initialization/mulmod_by_zero.sol similarity index 100% rename from test/libsolidity/syntaxTests/constants/mulmod_zero.sol rename to test/libsolidity/syntaxTests/constants/initialization/mulmod_by_zero.sol diff --git a/test/libsolidity/syntaxTests/constants/initialization/string_concat_const_args.sol b/test/libsolidity/syntaxTests/constants/initialization/string_concat_const_args.sol new file mode 100644 index 000000000000..bc676d101573 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/initialization/string_concat_const_args.sol @@ -0,0 +1,9 @@ +string constant abcGlobal = string.concat("aaaa", "bbbb", "cccc"); + +contract A { + string public constant abc = string.concat("aaaa", "bbbb","cccc"); + + string public constant abcCopy = abc; + string public constant abcGlobalCopy = abcGlobal; + string public constant abcabc = string.concat(abc, abcGlobal); +} diff --git a/test/libsolidity/syntaxTests/constants/initialization/string_concat_non_const_args.sol b/test/libsolidity/syntaxTests/constants/initialization/string_concat_non_const_args.sol new file mode 100644 index 000000000000..f8b4aa6e29e7 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/initialization/string_concat_non_const_args.sol @@ -0,0 +1,14 @@ +contract A { + string name = "name"; + + function getName() public view returns (string memory) { + return name; + } + + string public constant abName = string.concat("aaaa", "bbbb", name); + + string public constant abgetName = string.concat("aaaa", "bbbb",getName()); +} +// ---- +// TypeError 8349: (165-200): Initial value for constant variable has to be compile-time constant. +// TypeError 8349: (242-281): Initial value for constant variable has to be compile-time constant. diff --git a/test/libsolidity/syntaxTests/constants/initialization/type_info.sol b/test/libsolidity/syntaxTests/constants/initialization/type_info.sol new file mode 100644 index 000000000000..51cfaa3a56e2 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/initialization/type_info.sol @@ -0,0 +1,23 @@ +string constant aNameGlobal = type(A).name; +bytes4 constant iNameGlobal = type(I).interfaceId; +uint256 constant minGlobal = type(uint256).min; +uint256 constant maxGlobal = type(uint256).max; +bytes constant creationCodeBGlobal = type(B).creationCode; +bytes constant runtimeCodeBGlobal = type(B).runtimeCode; + +contract B { +} + +interface I { + function hello() external pure; + function world(int) external pure; +} + +contract A { + string constant aName = type(A).name; + bytes4 constant iName = type(I).interfaceId; + uint256 constant min = type(uint256).min; + uint256 constant max = type(uint256).max; + bytes constant creationCodeB = type(B).creationCode; + bytes constant runtimeCodeB = type(B).runtimeCode; +} diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_constructor.sol b/test/libsolidity/syntaxTests/freeFunctions/free_constructor.sol index 7878983571ed..5e263606d660 100644 --- a/test/libsolidity/syntaxTests/freeFunctions/free_constructor.sol +++ b/test/libsolidity/syntaxTests/freeFunctions/free_constructor.sol @@ -1,3 +1,3 @@ constructor() {} // ---- -// ParserError 7858: (0-11): Expected pragma, import directive or contract/interface/library/struct/enum/constant/function/error definition. +// ParserError 7858: (0-11): Expected pragma, import directive or contract/interface/library/user-defined type/constant/function/error/event definition. diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_fallback.sol b/test/libsolidity/syntaxTests/freeFunctions/free_fallback.sol index 897ed5964752..cec4c7de07a0 100644 --- a/test/libsolidity/syntaxTests/freeFunctions/free_fallback.sol +++ b/test/libsolidity/syntaxTests/freeFunctions/free_fallback.sol @@ -1,3 +1,3 @@ fallback(){} // ---- -// ParserError 7858: (0-8): Expected pragma, import directive or contract/interface/library/struct/enum/constant/function/error definition. +// ParserError 7858: (0-8): Expected pragma, import directive or contract/interface/library/user-defined type/constant/function/error/event definition. diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_receive.sol b/test/libsolidity/syntaxTests/freeFunctions/free_receive.sol index 83dfee446347..ad021b221482 100644 --- a/test/libsolidity/syntaxTests/freeFunctions/free_receive.sol +++ b/test/libsolidity/syntaxTests/freeFunctions/free_receive.sol @@ -1,3 +1,3 @@ receive() {} // ---- -// ParserError 7858: (0-7): Expected pragma, import directive or contract/interface/library/struct/enum/constant/function/error definition. +// ParserError 7858: (0-7): Expected pragma, import directive or contract/interface/library/user-defined type/constant/function/error/event definition. diff --git a/test/libsolidity/syntaxTests/parsing/unexpected.sol b/test/libsolidity/syntaxTests/parsing/unexpected.sol index c6fae414c387..9dd495c8b529 100644 --- a/test/libsolidity/syntaxTests/parsing/unexpected.sol +++ b/test/libsolidity/syntaxTests/parsing/unexpected.sol @@ -1,3 +1,3 @@ unexpected // ---- -// ParserError 7858: (0-10): Expected pragma, import directive or contract/interface/library/struct/enum/constant/function/error definition. +// ParserError 7858: (0-10): Expected pragma, import directive or contract/interface/library/user-defined type/constant/function/error/event definition. diff --git a/test/libsolidity/syntaxTests/storageLayoutSpecifier/layout_specified_by_bytes_concat.sol b/test/libsolidity/syntaxTests/storageLayoutSpecifier/layout_specified_by_bytes_concat.sol index d341a5a764d2..77860af8ec0c 100644 --- a/test/libsolidity/syntaxTests/storageLayoutSpecifier/layout_specified_by_bytes_concat.sol +++ b/test/libsolidity/syntaxTests/storageLayoutSpecifier/layout_specified_by_bytes_concat.sol @@ -1,3 +1,3 @@ contract C layout at uint64(bytes8(bytes.concat("ABCD", "EFGH"))) {} // ---- -// TypeError 1139: (21-65): The base slot of the storage layout must be a compile-time constant expression. +// TypeError 1505: (21-65): The base slot expression contains elements that are not yet supported by the internal constant evaluator and therefore cannot be evaluated at compilation time. diff --git a/test/libsolidity/syntaxTests/storageLayoutSpecifier/layout_specified_by_function_empty_call_options.sol b/test/libsolidity/syntaxTests/storageLayoutSpecifier/layout_specified_by_function_empty_call_options.sol index e0b1f4e5cb61..79bcb8878624 100644 --- a/test/libsolidity/syntaxTests/storageLayoutSpecifier/layout_specified_by_function_empty_call_options.sol +++ b/test/libsolidity/syntaxTests/storageLayoutSpecifier/layout_specified_by_function_empty_call_options.sol @@ -3,4 +3,4 @@ contract A { } contract C is A layout at this.f{}() {} // ---- -// ParserError 7858: (98-99): Expected pragma, import directive or contract/interface/library/struct/enum/constant/function/error definition. +// ParserError 7858: (98-99): Expected pragma, import directive or contract/interface/library/user-defined type/constant/function/error/event definition. diff --git a/test/libsolidity/syntaxTests/storageLayoutSpecifier/layout_specified_by_kecak256.sol b/test/libsolidity/syntaxTests/storageLayoutSpecifier/layout_specified_by_kecak256.sol index 539a59c11c07..0b35d60d891e 100644 --- a/test/libsolidity/syntaxTests/storageLayoutSpecifier/layout_specified_by_kecak256.sol +++ b/test/libsolidity/syntaxTests/storageLayoutSpecifier/layout_specified_by_kecak256.sol @@ -1,3 +1,3 @@ contract C layout at uint(keccak256(bytes.concat("ABCD"))) {} // ---- -// TypeError 1139: (21-58): The base slot of the storage layout must be a compile-time constant expression. +// TypeError 1505: (21-58): The base slot expression contains elements that are not yet supported by the internal constant evaluator and therefore cannot be evaluated at compilation time. diff --git a/test/libsolidity/syntaxTests/types/functionTypes/selector/event_error_selector_pure_assignment.sol b/test/libsolidity/syntaxTests/types/functionTypes/selector/event_error_selector_pure_assignment.sol new file mode 100644 index 000000000000..263e8f8a1a68 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/functionTypes/selector/event_error_selector_pure_assignment.sol @@ -0,0 +1,20 @@ +event EvExt(); +error ErExt(); + +bytes32 constant eventExtSelectorGlobal = EvExt.selector; +bytes4 constant errorExtSelectorGlobal = ErExt.selector; + +contract C { + event Ev(); + error Er(); + + bytes4 constant errorExtSelector = ErExt.selector; + bytes32 constant eventExtSelector = EvExt.selector; + + bytes4 constant errorSelector = Er.selector; + bytes32 constant eventSelector = Ev.selector; + + bytes4 constant errorSelectorC = C.Er.selector; + bytes32 constant eventSelectorC = C.Ev.selector; +} +// ----