diff --git a/.circleci/config.yml b/.circleci/config.yml index e41500b1e..f016a48c5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,20 +9,20 @@ version: 2.1 parameters: ubuntu-2004-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:ubuntu2004-13 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:aa64242ecba4f040a839eadfaf20e8489cf93d1cb96ab90df2b240cdbbfe7f7c" + # solbuildpackpusher/solidity-buildpack-deps:ubuntu2004-14 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:d1ef23849db4c5462b248d89c111da4009b153cbd5002cb8755b0580312be581" ubuntu-2004-clang-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:ubuntu2004.clang-13 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:caaf8d42aaf07397d1540e570f096a4fb1ef11fda7da3f1141d8852ec8322a9e" + # solbuildpackpusher/solidity-buildpack-deps:ubuntu2004.clang-14 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:beb8c91998ec0df99a488900b3723a06f1122f0954fc73786b6c53fd73a6408d" ubuntu-1604-clang-ossfuzz-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:ubuntu1604.clang.ossfuzz-18 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:048002d71a1f86f83dedb79dd057760b752256c75646ba5ad5c1bbe92e1695aa" + # solbuildpackpusher/solidity-buildpack-deps:ubuntu1604.clang.ossfuzz-19 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:8c9bf1813c261d781f4c65fceed2dfb3ecf5be9ecf49bddbd250b570a7f3baea" emscripten-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:emscripten-11 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:0ad7c65e8c54d926ba9cb80d56246e4fc49f9284ad5188aaaa4834f46ab0c315" + # solbuildpackpusher/solidity-buildpack-deps:emscripten-13 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:f1c13f3450d1f2e53ea18ac1ac1a17e932573cb9a5ccd0fd9ef6dd44f6402fa9" evm-version: type: string default: london @@ -36,7 +36,7 @@ commands: parameters: event: type: enum - enum: ["failure", "success"] + enum: ["failure", "success", "release"] condition: type: string steps: @@ -58,6 +58,10 @@ commands: [[ "<< parameters.event >>" == "failure" ]] && message=" ❌ [${workflow_name}] Job ${job} failed on **${CIRCLE_BRANCH}**. Please see [build ${CIRCLE_BUILD_NUM}](${CIRCLE_BUILD_URL}) for details." [[ "<< parameters.event >>" == "success" ]] && message=" ✅ [${workflow_name}] Job ${job} succeeded on **${CIRCLE_BRANCH}**. Please see [build ${CIRCLE_BUILD_NUM}](${CIRCLE_BUILD_URL}) for details." + [[ "<< parameters.event >>" == "release" ]] && message=" 📦 Release binaries for version **${CIRCLE_TAG}** are ready and attached as artifacts to [build ${CIRCLE_BUILD_NUM}](${CIRCLE_BUILD_URL}). **Please make sure the whole workflow succeeded before using them.**" + + # The release notification only makes sense on tagged commits. If the commit is untagged, just bail out. + [[ "<< parameters.event >>" == "release" ]] && { [[ $CIRCLE_TAG != "" ]] || { echo "Not a tagged commit - notification skipped."; exit 0; } } curl "https://api.gitter.im/v1/rooms/${GITTER_NOTIFY_ROOM_ID}/chatMessages" \ --request POST \ @@ -81,6 +85,34 @@ commands: event: success condition: on_success + gitter_notify_release_unless_pr: + description: "Posts a release notification to the main room on Gitter (if not running on a PR)." + steps: + - gitter_notify_unless_pr: + event: release + condition: on_success + + prepare_bytecode_report: + description: "Generate bytecode report and upload it as an artifact." + parameters: + label: + type: string + steps: + - run: mkdir test-cases/ + - run: cd test-cases && ../scripts/isolate_tests.py ../test/ + - run: cd test-cases && ../scripts/bytecodecompare/prepare_report.py ../build/solc/solc --interface standard-json --report-file "../bytecode-report-<< parameters.label >>-json.txt" + - run: cd test-cases && ../scripts/bytecodecompare/prepare_report.py ../build/solc/solc --interface cli --report-file "../bytecode-report-<< parameters.label >>-cli.txt" + - store_artifacts: + path: bytecode-report-<< parameters.label >>-json.txt + - store_artifacts: + path: bytecode-report-<< parameters.label >>-cli.txt + - persist_to_workspace: + root: . + paths: + - bytecode-report-<< parameters.label >>-json.txt + - bytecode-report-<< parameters.label >>-cli.txt + - gitter_notify_failure_unless_pr + defaults: # -------------------------------------------------------------------------- @@ -211,7 +243,7 @@ defaults: command: pip install --user deepdiff colorama - run: name: Executing solc LSP test suite - command: ./test/lsp.py ./build/solc/solc + command: ./test/lsp.py ./build/solc/solc --non-interactive - gitter_notify_failure_unless_pr - steps_build: &steps_build @@ -418,6 +450,13 @@ defaults: tags: only: /.*/ + - workflow_trigger_on_releases: &workflow_trigger_on_releases + filters: + tags: + only: /^v.*/ + branches: + ignore: /.*/ + - workflow_ubuntu2004: &workflow_ubuntu2004 <<: *workflow_trigger_on_tags requires: @@ -588,6 +627,20 @@ defaults: project: brink binary_type: native nodejs_version: '16' + - job_native_test_ext_chainlink: &job_native_test_ext_chainlink + <<: *workflow_ubuntu2004_static + name: t_native_test_ext_chainlink + project: chainlink + binary_type: native + nodejs_version: '16' + resource_class: large # Tests run out of memory on a smaller machine + - job_native_test_ext_gp2: &job_native_test_ext_gp2 + <<: *workflow_ubuntu2004_static + name: t_native_test_ext_gp2 + project: gp2 + binary_type: native + # NOTE: Tests crash on nodejs 17: "Error: error:0308010C:digital envelope routines::unsupported" + nodejs_version: '16' - job_ems_test_ext_colony: &job_ems_test_ext_colony <<: *workflow_emscripten name: t_ems_test_ext_colony @@ -620,7 +673,7 @@ jobs: pip install --user codespell - run: name: Check spelling - command: ~/.local/bin/codespell -S "*.enc,.git,Dockerfile*" -I ./scripts/codespell_whitelist.txt + command: ~/.local/bin/codespell --skip "*.enc,.git,Dockerfile*,LICENSE,codespell_whitelist.txt,codespell_ignored_lines.txt" --ignore-words ./scripts/codespell_whitelist.txt --exclude-file ./scripts/codespell_ignored_lines.txt - gitter_notify_failure_unless_pr chk_docs_examples: @@ -672,9 +725,17 @@ jobs: name: Install pip command: apt -q update && apt install -y python3-pip - run: - name: Install pylint - command: python3 -m pip install pylint z3-solver pygments-lexer-solidity parsec tabulate deepdiff colorama - # also z3-solver, parsec and tabulate to make sure pylint knows about this module, pygments-lexer-solidity for docs + name: Install pylint and dependencies of the scripts that will be linted + command: python3 -m pip install + pylint + z3-solver + pygments-lexer-solidity + parsec + tabulate + deepdiff + colorama + requests + - run: pylint --version - run: name: Linting Python Scripts command: ./scripts/pylint_all.py @@ -887,11 +948,14 @@ jobs: environment: TERM: xterm MAKEFLAGS: -j 5 + # Build without Z3. We won't be running SMT tests on Arch because that requires a specific + # version of Z3 and the one with the official repos is often not the one we need. + USE_Z3: OFF steps: - run: name: Install build dependencies command: | - pacman --noconfirm -Syu --noprogressbar --needed base-devel boost cmake z3 cvc4 git openssh tar + pacman --noconfirm -Syu --noprogressbar --needed base-devel boost cmake cvc4 git openssh tar - checkout - run: *run_build - store_artifacts: *artifacts_solc @@ -1007,7 +1071,7 @@ jobs: TERM: xterm # For Archlinux we do not have prebuilt docker images and we would need to build evmone from source, # thus we forgo semantics tests to speed things up. - SOLTEST_FLAGS: --no-semantic-tests + SOLTEST_FLAGS: --no-semantic-tests --no-smt steps: - run: name: Install runtime dependencies @@ -1017,22 +1081,15 @@ jobs: condition: true <<: *steps_soltest - t_ubu_soltest_enforce_yul: &t_ubu_soltest_enforce_yul - <<: *base_ubuntu2004 - parallelism: 20 - environment: - EVM: << pipeline.parameters.evm-version >> - SOLTEST_FLAGS: --enforce-via-yul - OPTIMIZE: 0 - TERM: xterm - <<: *steps_soltest - t_ubu_clang_soltest: &t_ubu_clang_soltest <<: *base_ubuntu2004_clang parallelism: 20 environment: EVM: << pipeline.parameters.evm-version >> OPTIMIZE: 0 + # The high parallelism in this job is causing the SMT tests to run out of memory, + # so disabling for now. + SOLTEST_FLAGS: --no-smt <<: *steps_soltest t_ubu_release_soltest_all: &t_ubu_release_soltest_all @@ -1219,16 +1276,70 @@ jobs: - checkout - attach_workspace: at: . + - run: + name: Install dependencies of helper scripts + command: | + sudo apt update + sudo apt install python3-pip --assume-yes --no-install-recommends + python3 -m pip install requests --user - run: name: Combine benchmark reports command: cat reports/externalTests/benchmark-*.json | scripts/externalTests/merge_benchmarks.sh > reports/externalTests/all-benchmarks.json - run: name: Summarize reports command: cat reports/externalTests/all-benchmarks.json | scripts/externalTests/summarize_benchmarks.sh > reports/externalTests/summarized-benchmarks.json + - run: + name: Download reports from base branch + command: | + if [[ $CIRCLE_PULL_REQUEST != "" ]]; then + mkdir reports/externalTests/base-branch/ + cd reports/externalTests/base-branch/ + + pr_id=$(echo "$CIRCLE_PULL_REQUEST" | sed 's|\(.*\)\/||') + scripts_dir=../../../scripts + + # Our main goal here is to provide new benchmarks, the diff is optional. When benchmarks from + # the previous run are not available for whatever reason, we still succeed and just skip the diff. + # download_benchmarks.py exits with status 2 in that case. + if "${scripts_dir}/externalTests/download_benchmarks.py" --base-of-pr "$pr_id" || [[ $? == 2 ]]; then + echo 'export SKIP_BENCHMARK_DIFF=true' >> $BASH_ENV + fi + fi + - run: + name: Diff benchmarks + command: | + if [[ $CIRCLE_PULL_REQUEST != "" && $SKIP_BENCHMARK_DIFF != "true" ]]; then + cd reports/externalTests/ + mkdir diff/ + scripts_dir=../../scripts + + "${scripts_dir}/externalTests/benchmark_diff.py" table \ + --output-format markdown \ + --style humanized \ + base-branch/summarized-benchmarks-*.json \ + summarized-benchmarks.json > diff/benchmark-diff-summarized-table-markdown-humanized.md + "${scripts_dir}/externalTests/benchmark_diff.py" table \ + --output-format markdown \ + --style absolute \ + base-branch/summarized-benchmarks-*.json \ + summarized-benchmarks.json > diff/benchmark-diff-summarized-table-markdown-absolute.md + "${scripts_dir}/externalTests/benchmark_diff.py" inplace \ + --style absolute \ + base-branch/summarized-benchmarks-*.json \ + summarized-benchmarks.json > diff/benchmark-diff-summarized-inplace-absolute.md + "${scripts_dir}/externalTests/benchmark_diff.py" inplace \ + --style absolute \ + base-branch/all-benchmarks-*.json \ + all-benchmarks.json > diff/benchmark-diff-all-table-inplace-absolute.md + fi - store_artifacts: path: reports/externalTests/all-benchmarks.json - store_artifacts: path: reports/externalTests/summarized-benchmarks.json + - store_artifacts: + path: reports/externalTests/diff/ + - store_artifacts: + path: reports/externalTests/base-branch/ b_win: &b_win <<: *base_win_powershell_large @@ -1288,7 +1399,7 @@ jobs: command: Get-Content ./test/lsp.py - run: name: Executing solc LSP test suite - command: python ./test/lsp.py .\build\solc\Release\solc.exe + command: python ./test/lsp.py .\build\solc\Release\solc.exe --non-interactive - store_test_results: *store_test_results - store_artifacts: *artifacts_test_results - gitter_notify_failure_unless_pr @@ -1302,20 +1413,8 @@ jobs: - checkout - attach_workspace: at: build - - run: mkdir test-cases/ - - run: cd test-cases && ../scripts/isolate_tests.py ../test/ - - run: cd test-cases && ../scripts/bytecodecompare/prepare_report.py ../build/solc/solc --interface standard-json --report-file ../bytecode-report-ubuntu-json.txt - - run: cd test-cases && ../scripts/bytecodecompare/prepare_report.py ../build/solc/solc --interface cli --report-file ../bytecode-report-ubuntu-cli.txt - - store_artifacts: - path: bytecode-report-ubuntu-json.txt - - store_artifacts: - path: bytecode-report-ubuntu-cli.txt - - persist_to_workspace: - root: . - paths: - - bytecode-report-ubuntu-json.txt - - bytecode-report-ubuntu-cli.txt - - gitter_notify_failure_unless_pr + - prepare_bytecode_report: + label: "ubuntu" b_bytecode_osx: <<: *base_osx @@ -1323,20 +1422,8 @@ jobs: - checkout - attach_workspace: at: . - - run: mkdir test-cases/ - - run: cd test-cases && ../scripts/isolate_tests.py ../test/ - - run: cd test-cases && ../scripts/bytecodecompare/prepare_report.py ../build/solc/solc --interface standard-json --report-file ../bytecode-report-osx-json.txt - - run: cd test-cases && ../scripts/bytecodecompare/prepare_report.py ../build/solc/solc --interface cli --report-file ../bytecode-report-osx-cli.txt - - store_artifacts: - path: bytecode-report-osx-json.txt - - store_artifacts: - path: bytecode-report-osx-cli.txt - - persist_to_workspace: - root: . - paths: - - bytecode-report-osx-json.txt - - bytecode-report-osx-cli.txt - - gitter_notify_failure_unless_pr + - prepare_bytecode_report: + label: "osx" b_bytecode_win: <<: *base_win_cmd @@ -1416,6 +1503,47 @@ jobs: path: all-bytecode-reports.zip - gitter_notify_failure_unless_pr + c_release_binaries: + <<: *base_ubuntu2004 + steps: + - checkout + - attach_workspace: + at: workspace + - run: + name: Gather and rename binaries from dependent jobs + command: | + mkdir github/ + cp workspace/solc/solc github/solc-static-linux + cp workspace/build/solc/solc github/solc-macos + cp workspace/solc/Release/solc.exe github/solc-windows.exe + cp workspace/soljson.js github/soljson.js + + cd github/ + tar --create --file ../github-binaries.tar * + - store_artifacts: + path: github-binaries.tar + - run: + name: Rename binaries to solc-bin naming convention + command: | + full_version=$( + github/solc-static-linux --version | + sed -En 's/^Version: ([0-9.]+.*\+commit\.[0-9a-f]+(\.mod)?).*$/\1/p' + ) + + mkdir -p solc-bin/{linux-amd64,macosx-amd64,windows-amd64,bin} + + mv github/solc-static-linux "solc-bin/linux-amd64/solc-linux-amd64-v${full_version}" + mv github/solc-macos "solc-bin/macosx-amd64/solc-macosx-amd64-v${full_version}" + mv github/solc-windows.exe "solc-bin/windows-amd64/solc-windows-amd64-v${full_version}.exe" + mv github/soljson.js "solc-bin/bin/soljson-v${full_version}.js" + + cd solc-bin/ + tar --create --file ../solc-bin-binaries.tar * + - store_artifacts: + path: solc-bin-binaries.tar + - gitter_notify_failure_unless_pr + - gitter_notify_release_unless_pr + workflows: version: 2 @@ -1456,7 +1584,6 @@ workflows: - t_ubu_cli: *workflow_ubuntu2004 - t_ubu_locale: *workflow_ubuntu2004 - t_ubu_soltest_all: *workflow_ubuntu2004 - - t_ubu_soltest_enforce_yul: *workflow_ubuntu2004 - b_ubu_clang: *workflow_trigger_on_tags - t_ubu_clang_soltest: *workflow_ubuntu2004_clang - t_ubu_lsp: *workflow_ubuntu2004 @@ -1486,6 +1613,8 @@ workflows: - t_ems_ext: *job_native_test_ext_prb_math - t_ems_ext: *job_native_test_ext_elementfi - t_ems_ext: *job_native_test_ext_brink + - t_ems_ext: *job_native_test_ext_chainlink + - t_ems_ext: *job_native_test_ext_gp2 - c_ext_benchmarks: <<: *workflow_trigger_on_tags @@ -1504,6 +1633,8 @@ workflows: - t_native_test_ext_prb_math - t_native_test_ext_elementfi - t_native_test_ext_brink + - t_native_test_ext_chainlink + - t_native_test_ext_gp2 # Windows build and tests - b_win: *workflow_trigger_on_tags @@ -1536,6 +1667,15 @@ workflows: - b_bytecode_osx - b_bytecode_ems + # Final artifacts + - c_release_binaries: + <<: *workflow_trigger_on_releases + requires: + - b_ubu_static + - b_osx + - b_win_release + - b_ems + nightly: triggers: diff --git a/.circleci/osx_install_dependencies.sh b/.circleci/osx_install_dependencies.sh index 37502a742..766091fdf 100755 --- a/.circleci/osx_install_dependencies.sh +++ b/.circleci/osx_install_dependencies.sh @@ -61,11 +61,11 @@ then ./scripts/install_obsolete_jsoncpp_1_7_4.sh # z3 - z3_version="4.8.17" + z3_version="4.11.0" z3_dir="z3-${z3_version}-x64-osx-10.16" z3_package="${z3_dir}.zip" wget "https://github.com/Z3Prover/z3/releases/download/z3-${z3_version}/${z3_package}" - validate_checksum "$z3_package" 189667930517aee07f1ce36485d5924a9a2cb4f8c3c9586b03e714a2c657541a + validate_checksum "$z3_package" b6a4a6d587e4bfb0643db81129f0f447692fae13d4bd1bd4d93f1c0301b75ffc unzip "$z3_package" rm "$z3_package" cp "${z3_dir}/bin/libz3.a" /usr/local/lib diff --git a/.circleci/soltest.ps1 b/.circleci/soltest.ps1 index 6b67adb13..3c800903b 100755 --- a/.circleci/soltest.ps1 +++ b/.circleci/soltest.ps1 @@ -6,7 +6,7 @@ cd "$PSScriptRoot\.." if ( -not $? ) { throw "Cannot execute solc --version." } mkdir test_results -.\build\test\Release\soltest.exe --color_output=no --show_progress=yes --logger=JUNIT,error,test_results/result.xml -- --no-smt +.\build\test\Release\soltest.exe --color_output=no --show_progress=yes --logger=JUNIT,error,test_results/result.xml --logger=HRF,error,stdout -- --no-smt if ( -not $? ) { throw "Unoptimized soltest run failed." } -.\build\test\Release\soltest.exe --color_output=no --show_progress=yes --logger=JUNIT,error,test_results/result_opt.xml -- --optimize --no-smt -if ( -not $? ) { throw "Optimized soltest run failed." } \ No newline at end of file +.\build\test\Release\soltest.exe --color_output=no --show_progress=yes --logger=JUNIT,error,test_results/result_opt.xml --logger=HRF,error,stdout -- --optimize --no-smt +if ( -not $? ) { throw "Optimized soltest run failed." } diff --git a/.circleci/soltest.sh b/.circleci/soltest.sh index 91325f02e..7b5b88593 100755 --- a/.circleci/soltest.sh +++ b/.circleci/soltest.sh @@ -75,6 +75,7 @@ do "--color_output=no" "--show_progress=yes" "--logger=JUNIT,error,test_results/$(get_logfile_basename "$((CPUs * CIRCLE_NODE_INDEX + run))").xml" + "--logger=HRF,error,stdout" "${BOOST_TEST_ARGS[@]}" ) SOLTEST_ARGS=("--evm-version=$EVM" "${SOLTEST_FLAGS[@]}") diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index b4e9b3d50..c34dedb74 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,14 +1,17 @@ blank_issues_enabled: false contact_links: - name: Bug Report - url: https://github.com/ethereum/solidity/issues/new?template=bug_report.md&projects=ethereum/solidity/43&labels=bug+%3Abug%3A - about: Bug reports about the Solidity Compiler. + url: https://github.com/ethereum/solidity/issues/new?template=bug_report.md&projects=ethereum/solidity/43 + about: Bug reports for the Solidity Compiler. - name: Documentation Issue - url: https://github.com/ethereum/solidity/issues/new?template=documentation_issue.md&projects=ethereum/solidity/43&labels=documentation+%3Abook%3A + url: https://github.com/ethereum/solidity/issues/new?template=documentation_issue.md&projects=ethereum/solidity/43 about: Solidity documentation. - name: Feature Request - url: https://github.com/ethereum/solidity/issues/new?template=feature_request.md&projects=ethereum/solidity/43&labels=feature + url: https://github.com/ethereum/solidity/issues/new?template=feature_request.md&projects=ethereum/solidity/43 about: Solidity language or infrastructure feature requests. - name: Report a security vulnerability url: https://github.com/ethereum/solidity/security/policy about: Please review our security policy for more details. + - name: Initiate a language design or feedback discussion + url: https://forum.soliditylang.org + about: Open a thread on the Solidity forum. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 900e6977c..e5cc0f79c 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -10,6 +10,8 @@ name: Feature Request - [Solidity chat](https://gitter.im/ethereum/solidity) - [Stack Overflow](https://ethereum.stackexchange.com/) - Ensure the issue isn't already reported (check `feature` and `language design` labels). +- If you feel uncertain about your feature request, perhaps it's better to open a language design or feedback forum thread via the issue selector, or by going to the forum directly. + - [Solidity forum](https://forum.soliditylang.org/) *Delete the above section and the instructions in the sections below before submitting* --> diff --git a/.github/workflows/buildpack-deps.yml b/.github/workflows/buildpack-deps.yml index 535d15239..e2da2cdea 100644 --- a/.github/workflows/buildpack-deps.yml +++ b/.github/workflows/buildpack-deps.yml @@ -37,6 +37,9 @@ jobs: - name: comment PR if: "env.DOCKER_IMAGE" - uses: aarlt/comment-on-pr@v1.2.0 + # NOTE: Can't update to v1.3.1 due to an error: `/entrypoint.sh:5:in 'require_relative': cannot load such file -- /lib/github (LoadError)` + uses: unsplash/comment-on-pr@ffe8f97ccc63ce12c3c23c6885b169db67958d3b #v1.3.0 with: - msg: "`${{ env.DOCKER_IMAGE }} ${{ env.DOCKER_REPO_DIGEST }}`." \ No newline at end of file + msg: "`${{ env.DOCKER_IMAGE }} ${{ env.DOCKER_REPO_DIGEST }}`." + check_for_duplicate_msg: false + diff --git a/.gitignore b/.gitignore index 0ec3f7ace..4f1717181 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,16 @@ -commit_hash.txt -prerelease.txt +/commit_hash.txt +/prerelease.txt + +# Auth config for ppa release +/.release_ppa_auth # Compiled Object files *.slo *.lo *.o *.obj +*.pyc +__pycache__ # Precompiled Headers *.gch @@ -16,9 +21,6 @@ prerelease.txt *.dylib *.dll -# Fortran module files -*.mod - # Compiled Static libraries *.lai *.la @@ -33,14 +35,9 @@ prerelease.txt # Build directory /build* emscripten_build/ -docs/_build -docs/_static/robots.txt -__pycache__ -docs/utils/*.pyc -/deps/downloads/ -deps/install -deps/cache -cmake-build-*/ +/docs/_build +/docs/_static/robots.txt +/deps # vim stuff [._]*.sw[a-p] @@ -50,18 +47,15 @@ cmake-build-*/ *~ # IDE files -.idea -.vscode -browse.VC.db -CMakeLists.txt.user +/.idea/ +/.vscode/ +/browse.VC.db +/CMakeLists.txt.user /CMakeSettings.json /.vs /.cproject /.project -# place to put local temporary files -tmp - # OS specific local files .DS_Store Thumbs.db diff --git a/CMakeLists.txt b/CMakeLists.txt index 426520383..6680b75b2 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.15") +set(PROJECT_VERSION "0.8.17") # OSX target needed in order to support std::visit set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14") project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX) @@ -35,6 +35,7 @@ endif() option(SOLC_LINK_STATIC "Link solc executable statically on supported platforms" OFF) option(SOLC_STATIC_STDLIBS "Link solc against static versions of libgcc and libstdc++ on supported platforms" OFF) option(STRICT_Z3_VERSION "Use the latest version of Z3" ON) +option(PEDANTIC "Enable extra warnings and pedantic build flags. Treat all warnings as errors." ON) # Setup cccache. include(EthCcache) @@ -48,6 +49,9 @@ include_directories(SYSTEM ${JSONCPP_INCLUDE_DIR}) find_package(Threads) +if(NOT PEDANTIC) + message(WARNING "-- Pedantic build flags turned off. Warnings will not make compilation fail. This is NOT recommended in development builds.") +endif() # Figure out what compiler and system are we using include(EthCompilerSettings) @@ -65,7 +69,7 @@ configure_file("${CMAKE_SOURCE_DIR}/cmake/templates/license.h.in" include/licens include(EthOptions) configure_project(TESTS) -set(LATEST_Z3_VERSION "4.8.17") +set(LATEST_Z3_VERSION "4.11.0") set(MINIMUM_Z3_VERSION "4.8.0") find_package(Z3) if (${Z3_FOUND}) diff --git a/Changelog.md b/Changelog.md index 1f223a5d7..fe89981b4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -11,15 +11,69 @@ Breaking changes: * View Pure Checker: Mark ``returndatasize`` and ``returndatacopy`` as view to disallow them in inline assembly blocks in pure functions. -### 0.8.15 (unreleased) +### 0.8.17 (unreleased) + +Important Bugfixes: + Language Features: Compiler Features: + * Code Generator: More efficient overflow checks for multiplication. + * Yul Optimizer: Simplify the starting offset of zero-length operations to zero. + * Language Server: Analyze all files in a project by default (can be customized by setting ``'file-load-strategy'`` to ``'directly-opened-and-on-import'`` in LSP settings object). Bugfixes: + * Type Checker: Fix internal compiler error on tuple assignments with invalid left-hand side. + + +### 0.8.16 (2022-08-08) + +Important Bugfixes: + * Code Generation: Fix data corruption that affected ABI-encoding of calldata values represented by tuples: structs at any nesting level; argument lists of external functions, events and errors; return value lists of external functions. The 32 leading bytes of the first dynamically-encoded value in the tuple would get zeroed when the last component contained a statically-encoded array. + + +Compiler Features: + * Code Generator: More efficient code for checked addition and subtraction. + * TypeChecker: Support using library constants in initializers of other constants. + * Yul IR Code Generation: Improved copy routines for arrays with packed storage layout. + * Yul Optimizer: Add rule to convert ``mod(add(X, Y), A)`` into ``addmod(X, Y, A)``, if ``A`` is a power of two. + * Yul Optimizer: Add rule to convert ``mod(mul(X, Y), A)`` into ``mulmod(X, Y, A)``, if ``A`` is a power of two. + + +Bugfixes: + * Commandline Interface: Disallow the following options outside of the compiler mode: ``--via-ir``,``--metadata-literal``, ``--metadata-hash``, ``--model-checker-show-unproved``, ``--model-checker-div-mod-no-slacks``, ``--model-checker-engine``, ``--model-checker-invariants``, ``--model-checker-solvers``, ``--model-checker-timeout``, ``--model-checker-contracts``, ``--model-checker-targets``. + * Type Checker: Fix compiler crash on tuple assignments involving certain patterns with unary tuples on the left-hand side. + * Type Checker: Fix compiler crash when ``abi.encodeCall`` received a tuple expression instead of an inline tuple. + * Type Checker: Fix null dereference in ``abi.encodeCall`` type checking of free function. + + +### 0.8.15 (2022-06-15) + +Important Bugfixes: + * Code Generation: Avoid writing dirty bytes to storage when copying ``bytes`` arrays. + * Yul Optimizer: Keep all memory side-effects of inline assembly blocks. + + +Language Features: + * Add `E.selector` for a non-anonymous event `E` to access the 32-byte selector topic. + + +Compiler Features: + * Language Server: Add rudimentary support for semantic highlighting. + * Language Server: Adds support for configuring ``include-paths`` JSON settings object that can be passed during LSP configuration stage. + * Language Server: Always add ``{project_root}/node_modules`` to include search paths. + * Type Checker: Warn about assignments involving multiple pushes to storage ``bytes`` that may invalidate references. + * Yul Optimizer: Improve inlining heuristics for via IR code generation and pure Yul compilation. + +Bugfixes: + * ABI Encoder: When encoding an empty string coming from storage do not add a superfluous empty slot for data. + * Common Subexpression Eliminator: Process assembly items in chunks with maximum size of 2000. It helps to avoid extremely time-consuming searches during code optimization. + * DocString Parser: Fix ICE caused by an immutable struct with mapping. + * Yul IR Code Generation: More robust cleanup in corner cases during memory to storage copies. + * Yul Optimizer: Do not remove ``returndatacopy`` in cases in which it might perform out-of-bounds reads that unconditionally revert as out-of-gas. Previously, any ``returndatacopy`` that wrote to memory that was never read from was removed without accounting for the out-of-bounds condition. ### 0.8.14 (2022-05-17) @@ -61,9 +115,10 @@ Compiler Features: * Commandline Interface: Allow the use of ``--via-ir`` in place of ``--experimental-via-ir``. * Compilation via Yul IR is no longer marked as experimental. * JSON-AST: Added selector field for errors and events. - * LSP: Implements goto-definition. + * Language Server: Implements goto-definition. * Peephole Optimizer: Optimize comparisons in front of conditional jumps and conditional jumps across a single unconditional jump. * Yul EVM Code Transform: Avoid unnecessary ``pop``s on terminating control flow. + * Yul IR Code Generation: When the result of an external call is statically-sized, ignore any returndata past the size expected by the compiler. * Yul Optimizer: Remove ``sstore`` and ``mstore`` operations that are never read from. diff --git a/README.md b/README.md index ccd8dc634..1f0046532 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ For a good overview and starting point, please check out the official [Solidity Solidity is a statically-typed curly-braces programming language designed for developing smart contracts that run on the Ethereum Virtual Machine. Smart contracts are programs that are executed inside a peer-to-peer -network where nobody has special authority over the execution, and thus they allow to implement tokens of value, +network where nobody has special authority over the execution, and thus they allow anyone to implement tokens of value, ownership, voting, and other kinds of logic. When deploying contracts, you should use the latest released version of diff --git a/ReleaseChecklist.md b/ReleaseChecklist.md index 6d5008cb3..6d07ae011 100644 --- a/ReleaseChecklist.md +++ b/ReleaseChecklist.md @@ -26,29 +26,16 @@ - [ ] Click the `PUBLISH RELEASE` button on the release page, creating the tag. - [ ] Wait for the CI runs on the tag itself. -### Upload Release Artifacts +### Upload Release Artifacts and Publish Binaries - [ ] Switch to the tag that archives have to be created for. - [ ] Create the ``prerelease.txt`` file: (``echo -n > prerelease.txt``). - [ ] Run ``scripts/create_source_tarball.sh`` while being on the tag to create the source tarball. This will create the tarball in a directory called ``upload``. - [ ] Take the tarball from the upload directory (its name should be ``solidity_x.x.x.tar.gz``, otherwise ``prerelease.txt`` was missing in the step before) and upload the source tarball to the release page. - - [ ] Take the ``solc.exe`` binary from the ``b_win_release`` run of the released commit in circle-ci and add it to the release page as ``solc-windows.exe``. - - [ ] Take the ``solc`` binary from the ``b_osx`` run of the released commit in circle-ci and add it to the release page as ``solc-macos``. - - [ ] Take the ``solc`` binary from the ``b_ubu_static`` run of the released commit in circle-ci and add it to the release page as ``solc-static-linux``. - - [ ] Take the ``soljson.js`` binary from the ``b_ems`` run of the released commit in circle-ci and add it to the release page as ``soljson.js``. - -### Update [solc-bin](https://github.com/ethereum/solc-bin/) - - [ ] Copy files to solc-bin: - ```bash - VERSION=0.8.4 - COMMIT="c7e474f2" - SOLC_BIN="/home/me/solc-bin" - chmod +x solc-static-linux solc-macos - cp soljson.js $SOLC_BIN/bin/soljson-v$VERSION+commit.$COMMIT.js - cp solc-static-linux $SOLC_BIN/linux-amd64/solc-linux-amd64-v$VERSION+commit.$COMMIT - cp solc-macos $SOLC_BIN/macosx-amd64/solc-macosx-amd64-v$VERSION+commit.$COMMIT - cp solc-windows.exe $SOLC_BIN/windows-amd64/solc-windows-amd64-v$VERSION+commit.$COMMIT.exe + - [ ] Take the ``github-binaries.tar`` tarball from ``c_release_binaries`` run of the tagged commit in circle-ci and add all binaries from it to the release page. + Make sure it contains four binaries: ``solc-windows.exe``, ``solc-macos``, ``solc-static-linux`` and ``soljson.js``. + - [ ] Take the ``solc-bin-binaries.tar`` tarball from ``c_release_binaries`` run of the tagged commit in circle-ci and add all binaries from it to solc-bin. - [ ] Run ``./update --reuse-hashes`` in ``solc-bin`` and verify that the script has updated ``list.js``, ``list.txt`` and ``list.json`` files correctly and that symlinks to the new release have been added in ``solc-bin/wasm/`` and ``solc-bin/emscripten-wasm32/``. - - [ ] Create a pull request and merge. + - [ ] Create a pull request in solc-bin and merge. ### Homebrew and MacOS - [ ] Update the version and the hash (``sha256sum solidity_$VERSION.tar.gz``) in https://github.com/Homebrew/homebrew-core/blob/master/Formula/solidity.rb diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index 0ddeb452a..01eee4b98 100644 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -23,7 +23,9 @@ if(NOT EMSCRIPTEN) endif() endif() -eth_add_cxx_compiler_flag_if_supported(-Wimplicit-fallthrough) +if(PEDANTIC) + eth_add_cxx_compiler_flag_if_supported(-Wimplicit-fallthrough) +endif() # Prevent the path of the source directory from ending up in the binary via __FILE__ macros. eth_add_cxx_compiler_flag_if_supported("-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=/solidity") @@ -32,39 +34,45 @@ eth_add_cxx_compiler_flag_if_supported("-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=/ # if the argument was not wrapped in a call. This happens when moving a local # variable in a return statement when the variable is the same type as the # return type or using a move to create a new object from a temporary object. -eth_add_cxx_compiler_flag_if_supported(-Wpessimizing-move) +if(PEDANTIC) + eth_add_cxx_compiler_flag_if_supported(-Wpessimizing-move) +endif() # -Wredundant-move warns when an implicit move would already be made, so the # std::move call is not needed, such as when moving a local variable in a return # that is different from the return type. -eth_add_cxx_compiler_flag_if_supported(-Wredundant-move) +if(PEDANTIC) + eth_add_cxx_compiler_flag_if_supported(-Wredundant-move) +endif() if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")) # Enables all the warnings about constructions that some users consider questionable, # and that are easy to avoid. Also enable some extra warning flags that are not # enabled by -Wall. Finally, treat at warnings-as-errors, which forces developers # to fix warnings as they arise, so they don't accumulate "to be fixed later". - add_compile_options(-Wall) - add_compile_options(-Wextra) - add_compile_options(-Werror) - add_compile_options(-pedantic) - add_compile_options(-Wmissing-declarations) - add_compile_options(-Wno-unknown-pragmas) - add_compile_options(-Wimplicit-fallthrough) - add_compile_options(-Wsign-conversion) - add_compile_options(-Wconversion) + if(PEDANTIC) + add_compile_options(-Wall) + add_compile_options(-Wextra) + add_compile_options(-Werror) + add_compile_options(-pedantic) + add_compile_options(-Wmissing-declarations) + add_compile_options(-Wno-unknown-pragmas) + add_compile_options(-Wimplicit-fallthrough) + add_compile_options(-Wsign-conversion) + add_compile_options(-Wconversion) - check_cxx_compiler_flag(-Wextra-semi WEXTRA_SEMI) - if(WEXTRA_SEMI) - add_compile_options($<$:-Wextra-semi>) + check_cxx_compiler_flag(-Wextra-semi WEXTRA_SEMI) + if(WEXTRA_SEMI) + add_compile_options($<$:-Wextra-semi>) + endif() + eth_add_cxx_compiler_flag_if_supported(-Wfinal-dtor-non-final-class) + eth_add_cxx_compiler_flag_if_supported(-Wnewline-eof) + eth_add_cxx_compiler_flag_if_supported(-Wsuggest-destructor-override) + eth_add_cxx_compiler_flag_if_supported(-Wduplicated-cond) + eth_add_cxx_compiler_flag_if_supported(-Wduplicate-enum) + eth_add_cxx_compiler_flag_if_supported(-Wlogical-op) + eth_add_cxx_compiler_flag_if_supported(-Wno-unknown-attributes) endif() - eth_add_cxx_compiler_flag_if_supported(-Wfinal-dtor-non-final-class) - eth_add_cxx_compiler_flag_if_supported(-Wnewline-eof) - eth_add_cxx_compiler_flag_if_supported(-Wsuggest-destructor-override) - eth_add_cxx_compiler_flag_if_supported(-Wduplicated-cond) - eth_add_cxx_compiler_flag_if_supported(-Wduplicate-enum) - eth_add_cxx_compiler_flag_if_supported(-Wlogical-op) - eth_add_cxx_compiler_flag_if_supported(-Wno-unknown-attributes) # Configuration-specific compiler settings. set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -DETH_DEBUG") @@ -158,7 +166,9 @@ elseif (DEFINED MSVC) add_compile_options(/MP) # enable parallel compilation add_compile_options(/EHsc) # specify Exception Handling Model in msvc - add_compile_options(/WX) # enable warnings-as-errors + if(PEDANTIC) + add_compile_options(/WX) # enable warnings-as-errors + endif() add_compile_options(/wd4068) # disable unknown pragma warning (4068) add_compile_options(/wd4996) # disable unsafe function warning (4996) add_compile_options(/wd4503) # disable decorated name length exceeded, name was truncated (4503) diff --git a/cmake/EthPolicy.cmake b/cmake/EthPolicy.cmake index cc404e794..f571a09ce 100644 --- a/cmake/EthPolicy.cmake +++ b/cmake/EthPolicy.cmake @@ -20,4 +20,9 @@ macro (eth_policy) # Allow selecting MSVC runtime library using CMAKE_MSVC_RUNTIME_LIBRARY. cmake_policy(SET CMP0091 NEW) endif() + + # Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24: + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") + cmake_policy(SET CMP0135 NEW) + endif() endmacro() diff --git a/cmake/range-v3.cmake b/cmake/range-v3.cmake index d6d9cb773..75ed5a92e 100644 --- a/cmake/range-v3.cmake +++ b/cmake/range-v3.cmake @@ -12,9 +12,9 @@ set(RANGE_V3_INCLUDE_DIR "${prefix}/include") ExternalProject_Add(range-v3-project PREFIX "${prefix}" DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads" - DOWNLOAD_NAME range-v3-0.11.0.tar.gz - URL https://github.com/ericniebler/range-v3/archive/0.11.0.tar.gz - URL_HASH SHA256=376376615dbba43d3bef75aa590931431ecb49eb36d07bb726a19f680c75e20c + DOWNLOAD_NAME range-v3-0.12.0.tar.gz + URL https://github.com/ericniebler/range-v3/archive/0.12.0.tar.gz + URL_HASH SHA256=015adb2300a98edfceaf0725beec3337f542af4915cec4d0b89fa0886f4ba9cb CMAKE_COMMAND ${RANGE_V3_CMAKE_COMMAND} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} diff --git a/docs/_static/js/toggle.js b/docs/_static/js/toggle.js index f46a3a666..780ea9ee7 100644 --- a/docs/_static/js/toggle.js +++ b/docs/_static/js/toggle.js @@ -4,15 +4,16 @@ document.addEventListener('DOMContentLoaded', function() { var mode = (isDay ? "Day" : "Night"); localStorage.setItem("css-mode", mode); - var daysheet = $('link[href="_static/pygments.css"]')[0].sheet; + var url_root = DOCUMENTATION_OPTIONS.URL_ROOT == "./" ? "" : DOCUMENTATION_OPTIONS.URL_ROOT; + var daysheet = $(`link[href="${url_root}_static/pygments.css"]`)[0].sheet; daysheet.disabled = !isDay; - var nightsheet = $('link[href="_static/css/dark.css"]')[0]; + var nightsheet = $(`link[href="${url_root}_static/css/dark.css"]`)[0]; if (!isDay && nightsheet === undefined) { var element = document.createElement("link"); element.setAttribute("rel", "stylesheet"); element.setAttribute("type", "text/css"); - element.setAttribute("href", "_static/css/dark.css"); + element.setAttribute("href", `${url_root}_static/css/dark.css`); document.getElementsByTagName("head")[0].appendChild(element); return; } diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst index 02e5f8b2a..9164ae6a1 100644 --- a/docs/abi-spec.rst +++ b/docs/abi-spec.rst @@ -13,13 +13,13 @@ The Contract Application Binary Interface (ABI) is the standard way to interact from outside the blockchain and for contract-to-contract interaction. Data is encoded according to its type, as described in this specification. The encoding is not self describing and thus requires a schema in order to decode. -We assume the interface functions of a contract are strongly typed, known at compilation time and static. +We assume that the interface functions of a contract are strongly typed, known at compilation time and static. We assume that all contracts will have the interface definitions of any contracts they call available at compile-time. This specification does not address contracts whose interface is dynamic or otherwise known only at run-time. .. _abi_function_selector: -.. index:: selector +.. index:: ! selector; of a function Function Selector ================= @@ -29,7 +29,7 @@ first (left, high-order in big-endian) four bytes of the Keccak-256 hash of the the function. The signature is defined as the canonical expression of the basic prototype without data location specifier, i.e. the function name with the parenthesised list of parameter types. Parameter types are split by a single -comma - no spaces are used. +comma — no spaces are used. .. note:: The return type of a function is not part of this signature. In @@ -133,7 +133,7 @@ The encoding is designed to have the following properties, which are especially previous version of the ABI, the number of reads scaled linearly with the total number of dynamic parameters in the worst case. -2. The data of a variable or array element is not interleaved with other data and it is +2. The data of a variable or an array element is not interleaved with other data and it is relocatable, i.e. it only uses relative "addresses". @@ -252,7 +252,7 @@ Given the contract: } -Thus for our ``Foo`` example if we wanted to call ``baz`` with the parameters ``69`` and +Thus, for our ``Foo`` example if we wanted to call ``baz`` with the parameters ``69`` and ``true``, we would pass 68 bytes total, which can be broken down into: - ``0xcdcd77c0``: the Method ID. This is derived as the first 4 bytes of the Keccak hash of @@ -308,7 +308,7 @@ In total: Use of Dynamic Types ==================== -A call to a function with the signature ``f(uint,uint32[],bytes10,bytes)`` with values +A call to a function with the signature ``f(uint256,uint32[],bytes10,bytes)`` with values ``(0x123, [0x456, 0x789], "1234567890", "Hello, world!")`` is encoded in the following way: We take the first four bytes of ``sha3("f(uint256,uint32[],bytes10,bytes)")``, i.e. ``0x8be65246``. @@ -348,7 +348,7 @@ All together, the encoding is (newline after function selector and each 32-bytes 000000000000000000000000000000000000000000000000000000000000000d 48656c6c6f2c20776f726c642100000000000000000000000000000000000000 -Let us apply the same principle to encode the data for a function with a signature ``g(uint[][],string[])`` +Let us apply the same principle to encode the data for a function with a signature ``g(uint256[][],string[])`` with values ``([[1, 2], [3]], ["one", "two", "three"])`` but start from the most atomic parts of the encoding: First we encode the length and data of the first embedded dynamic array ``[1, 2]`` of the first root array ``[[1, 2], [3]]``: @@ -417,7 +417,7 @@ thus ``e = 0x00000000000000000000000000000000000000000000000000000000000000e0``. Note that the encodings of the embedded elements of the root arrays are not dependent on each other -and have the same encodings for a function with a signature ``g(string[],uint[][])``. +and have the same encodings for a function with a signature ``g(string[],uint256[][])``. Then we encode the length of the first root array: @@ -503,6 +503,7 @@ efficient search and arbitrary legibility by defining events with two arguments indexed, one not — intended to hold the same value. .. _abi_errors: +.. index:: error, selector; of an error Errors ====== @@ -596,7 +597,7 @@ Errors look as follows: .. note:: There can be multiple errors with the same name and even with identical signature - in the JSON array, for example if the errors originate from different + in the JSON array; for example, if the errors originate from different files in the smart contract or are referenced from another smart contract. For the ABI, only the name of the error itself is relevant and not where it is defined. @@ -645,7 +646,7 @@ would result in the JSON: Handling tuple types -------------------- -Despite that names are intentionally not part of the ABI encoding they do make a lot of sense to be included +Despite the fact that names are intentionally not part of the ABI encoding, they do make a lot of sense to be included in the JSON to enable displaying it to the end user. The structure is nested in the following way: An object with members ``name``, ``type`` and potentially ``components`` describes a typed variable. @@ -653,7 +654,7 @@ The canonical type is determined until a tuple type is reached and the string de to that point is stored in ``type`` prefix with the word ``tuple``, i.e. it will be ``tuple`` followed by a sequence of ``[]`` and ``[k]`` with integers ``k``. The components of the tuple are then stored in the member ``components``, -which is of array type and has the same structure as the top-level object except that +which is of an array type and has the same structure as the top-level object except that ``indexed`` is not allowed there. As an example, the code @@ -737,10 +738,10 @@ Strict Encoding Mode ==================== Strict encoding mode is the mode that leads to exactly the same encoding as defined in the formal specification above. -This means offsets have to be as small as possible while still not creating overlaps in the data areas and thus no gaps are +This means that offsets have to be as small as possible while still not creating overlaps in the data areas, and thus no gaps are allowed. -Usually, ABI decoders are written in a straightforward way just following offset pointers, but some decoders +Usually, ABI decoders are written in a straightforward way by just following offset pointers, but some decoders might enforce strict mode. The Solidity ABI decoder currently does not enforce strict mode, but the encoder always creates data in strict mode. @@ -776,7 +777,7 @@ More specifically: encoding of its elements **with** padding. - Dynamically-sized types like ``string``, ``bytes`` or ``uint[]`` are encoded without their length field. -- The encoding of ``string`` or ``bytes`` does not apply padding at the end +- The encoding of ``string`` or ``bytes`` does not apply padding at the end, unless it is part of an array or struct (then it is padded to a multiple of 32 bytes). @@ -804,7 +805,7 @@ Encoding of Indexed Event Parameters ==================================== Indexed event parameters that are not value types, i.e. arrays and structs are not -stored directly but instead a keccak256-hash of an encoding is stored. This encoding +stored directly but instead a Keccak-256 hash of an encoding is stored. This encoding is defined as follows: - the encoding of a ``bytes`` and ``string`` value is just the string contents diff --git a/docs/assembly.rst b/docs/assembly.rst index 70c4a458d..b527ffbaf 100644 --- a/docs/assembly.rst +++ b/docs/assembly.rst @@ -8,7 +8,7 @@ Inline Assembly You can interleave Solidity statements with inline assembly in a language close -to the one of the Ethereum virtual machine. This gives you more fine-grained control, +to the one of the Ethereum Virtual Machine. This gives you more fine-grained control, which is especially useful when you are enhancing the language by writing libraries. The language used for inline assembly in Solidity is called :ref:`Yul ` @@ -108,7 +108,7 @@ efficient code, for example: for { let end := add(dataElementLocation, mul(len, 0x20)) } lt(dataElementLocation, end) - { data := add(dataElementLocation, 0x20) } + { dataElementLocation := add(dataElementLocation, 0x20) } { sum := add(sum, mload(dataElementLocation)) } @@ -116,7 +116,7 @@ efficient code, for example: } } - +.. index:: selector; of a function Access to External Variables, Functions and Libraries ----------------------------------------------------- @@ -126,15 +126,15 @@ You can access Solidity variables and other identifiers by using their name. Local variables of value type are directly usable in inline assembly. They can both be read and assigned to. -Local variables that refer to memory evaluate to the address of the variable in memory not the value itself. +Local variables that refer to memory evaluate to the address of the variable in memory, not the value itself. Such variables can also be assigned to, but note that an assignment will only change the pointer and not the data and that it is your responsibility to respect Solidity's memory management. See :ref:`Conventions in Solidity `. Similarly, local variables that refer to statically-sized calldata arrays or calldata structs evaluate to the address of the variable in calldata, not the value itself. -The variable can also be assigned a new offset, but note that no validation to ensure that -the variable will not point beyond ``calldatasize()`` is performed. +The variable can also be assigned a new offset, but note that no validation is performed to ensure that +the variable will not point beyond ``calldatasize()``. For external function pointers the address and the function selector can be accessed using ``x.address`` and ``x.selector``. @@ -205,7 +205,7 @@ Local Solidity variables are available for assignments, for example: ``assembly { signextend(, x) }`` -Since Solidity 0.6.0 the name of a inline assembly variable may not +Since Solidity 0.6.0, the name of a inline assembly variable may not shadow any declaration visible in the scope of the inline assembly block (including variable, contract and function declarations). @@ -253,7 +253,7 @@ starting from where this pointer points at and update it. There is no guarantee that the memory has not been used before and thus you cannot assume that its contents are zero bytes. There is no built-in mechanism to release or free allocated memory. -Here is an assembly snippet you can use for allocating memory that follows the process outlined above +Here is an assembly snippet you can use for allocating memory that follows the process outlined above: .. code-block:: yul @@ -276,7 +276,7 @@ first slot of the array and followed by the array elements. .. warning:: Statically-sized memory arrays do not have a length field, but it might be added later - to allow better convertibility between statically- and dynamically-sized arrays, so + to allow better convertibility between statically and dynamically-sized arrays; so, do not rely on this. Memory Safety @@ -289,8 +289,8 @@ perform additional memory optimizations, if it can rely on certain assumptions a While we recommend to always respect Solidity's memory model, inline assembly allows you to use memory in an incompatible way. Therefore, moving stack variables to memory and additional memory optimizations are, -by default, disabled in the presence of any inline assembly block that contains a memory operation or assigns -to solidity variables in memory. +by default, globally disabled in the presence of any inline assembly block that contains a memory operation +or assigns to Solidity variables in memory. However, you can specifically annotate an assembly block to indicate that it in fact respects Solidity's memory model as follows: @@ -346,7 +346,7 @@ If the memory operations use a length of zero, it is also fine to just use any o } Note that not only memory operations in inline assembly itself can be memory-unsafe, but also assignments to -solidity variables of reference type in memory. For example the following is not memory-safe: +Solidity variables of reference type in memory. For example the following is not memory-safe: .. code-block:: solidity @@ -356,7 +356,7 @@ solidity variables of reference type in memory. For example the following is not } x[0x20] = 0x42; -Inline assembly that neither involves any operations that access memory nor assigns to any solidity variables +Inline assembly that neither involves any operations that access memory nor assigns to any Solidity variables in memory is automatically considered memory-safe and does not need to be annotated. .. warning:: @@ -365,7 +365,7 @@ in memory is automatically considered memory-safe and does not need to be annota undefined behaviour that cannot easily be discovered by testing. In case you are developing a library that is meant to be compatible across multiple versions -of solidity, you can use a special comment to annotate an assembly block as memory-safe: +of Solidity, you can use a special comment to annotate an assembly block as memory-safe: .. code-block:: solidity @@ -374,5 +374,5 @@ of solidity, you can use a special comment to annotate an assembly block as memo ... } -Note that we will disallow the annotation via comment in a future breaking release, so if you are not concerned with +Note that we will disallow the annotation via comment in a future breaking release; so, if you are not concerned with backwards-compatibility with older compiler versions, prefer using the dialect string. diff --git a/docs/bugs.json b/docs/bugs.json index 7bee4d10f..421bb007c 100644 --- a/docs/bugs.json +++ b/docs/bugs.json @@ -1,4 +1,40 @@ [ + { + "uid": "SOL-2022-6", + "name": "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "summary": "ABI-encoding a tuple with a statically-sized calldata array in the last component would corrupt 32 leading bytes of its first dynamically encoded component.", + "description": "When ABI-encoding a statically-sized calldata array, the compiler always pads the data area to a multiple of 32-bytes and ensures that the padding bytes are zeroed. In some cases, this cleanup used to be performed by always writing exactly 32 bytes, regardless of how many needed to be zeroed. This was done with the assumption that the data that would eventually occupy the area past the end of the array had not yet been written, because the encoder processes tuple components in the order they were given. While this assumption is mostly true, there is an important corner case: dynamically encoded tuple components are stored separately from the statically-sized ones in an area called the *tail* of the encoding and the tail immediately follows the *head*, which is where the statically-sized components are placed. The aforementioned cleanup, if performed for the last component of the head would cross into the tail and overwrite up to 32 bytes of the first component stored there with zeros. The only array type for which the cleanup could actually result in an overwrite were arrays with ``uint256`` or ``bytes32`` as the base element type and in this case the size of the corrupted area was always exactly 32 bytes. The problem affected tuples at any nesting level. This included also structs, which are encoded as tuples in the ABI. Note also that lists of parameters and return values of functions, events and errors are encoded as tuples.", + "link": "https://blog.soliditylang.org/2022/08/08/calldata-tuple-reencoding-head-overflow-bug/", + "introduced": "0.5.8", + "fixed": "0.8.16", + "severity": "medium", + "conditions": { + "ABIEncoderV2": true + } + }, + { + "uid": "SOL-2022-5", + "name": "DirtyBytesArrayToStorage", + "summary": "Copying ``bytes`` arrays from memory or calldata to storage may result in dirty storage values.", + "description": "Copying ``bytes`` arrays from memory or calldata to storage is done in chunks of 32 bytes even if the length is not a multiple of 32. Thereby, extra bytes past the end of the array may be copied from calldata or memory to storage. These dirty bytes may then become observable after a ``.push()`` without arguments to the bytes array in storage, i.e. such a push will not result in a zero value at the end of the array as expected. This bug only affects the legacy code generation pipeline, the new code generation pipeline via IR is not affected.", + "link": "https://blog.soliditylang.org/2022/06/15/dirty-bytes-array-to-storage-bug/", + "introduced": "0.0.1", + "fixed": "0.8.15", + "severity": "low" + }, + { + "uid": "SOL-2022-4", + "name": "InlineAssemblyMemorySideEffects", + "summary": "The Yul optimizer may incorrectly remove memory writes from inline assembly blocks, that do not access solidity variables.", + "description": "The Yul optimizer considers all memory writes in the outermost Yul block that are never read from as unused and removes them. This is valid when that Yul block is the entire Yul program, which is always the case for the Yul code generated by the new via-IR pipeline. Inline assembly blocks are never optimized in isolation when using that pipeline. Instead they are optimized as a part of the whole Yul input. However, the legacy code generation pipeline (which is still the default) runs the Yul optimizer individually on an inline assembly block if the block does not refer to any local variables defined in the surrounding Solidity code. Consequently, memory writes in such inline assembly blocks are removed as well, if the written memory is never read from in the same assembly block, even if the written memory is accessed later, for example by a subsequent inline assembly block.", + "link": "https://blog.soliditylang.org/2022/06/15/inline-assembly-memory-side-effects-bug/", + "introduced": "0.8.13", + "fixed": "0.8.15", + "severity": "medium", + "conditions": { + "yulOptimizer": true + } + }, { "uid": "SOL-2022-3", "name": "DataLocationChangeInInternalOverride", @@ -8,7 +44,6 @@ "introduced": "0.6.9", "fixed": "0.8.14", "severity": "very low" - }, { "uid": "SOL-2022-2", diff --git a/docs/bugs_by_version.json b/docs/bugs_by_version.json index 86203a72b..3e3847c9b 100644 --- a/docs/bugs_by_version.json +++ b/docs/bugs_by_version.json @@ -1,6 +1,7 @@ { "0.1.0": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -22,6 +23,7 @@ }, "0.1.1": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -43,6 +45,7 @@ }, "0.1.2": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -64,6 +67,7 @@ }, "0.1.3": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -85,6 +89,7 @@ }, "0.1.4": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -107,6 +112,7 @@ }, "0.1.5": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -129,6 +135,7 @@ }, "0.1.6": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -153,6 +160,7 @@ }, "0.1.7": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -177,6 +185,7 @@ }, "0.2.0": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -202,6 +211,7 @@ }, "0.2.1": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -227,6 +237,7 @@ }, "0.2.2": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -252,6 +263,7 @@ }, "0.3.0": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -279,6 +291,7 @@ }, "0.3.1": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -305,6 +318,7 @@ }, "0.3.2": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -331,6 +345,7 @@ }, "0.3.3": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -356,6 +371,7 @@ }, "0.3.4": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -381,6 +397,7 @@ }, "0.3.5": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -406,6 +423,7 @@ }, "0.3.6": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -429,6 +447,7 @@ }, "0.4.0": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -452,6 +471,7 @@ }, "0.4.1": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -475,6 +495,7 @@ }, "0.4.10": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -497,6 +518,7 @@ }, "0.4.11": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -518,6 +540,7 @@ }, "0.4.12": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -538,6 +561,7 @@ }, "0.4.13": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -558,6 +582,7 @@ }, "0.4.14": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -577,6 +602,7 @@ }, "0.4.15": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -595,6 +621,7 @@ }, "0.4.16": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -616,6 +643,7 @@ }, "0.4.17": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -638,6 +666,7 @@ }, "0.4.18": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -659,6 +688,7 @@ }, "0.4.19": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -681,6 +711,7 @@ }, "0.4.2": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -703,6 +734,7 @@ }, "0.4.20": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -725,6 +757,7 @@ }, "0.4.21": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -747,6 +780,7 @@ }, "0.4.22": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -769,6 +803,7 @@ }, "0.4.23": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -790,6 +825,7 @@ }, "0.4.24": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -811,6 +847,7 @@ }, "0.4.25": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -830,6 +867,7 @@ }, "0.4.26": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -846,6 +884,7 @@ }, "0.4.3": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -867,6 +906,7 @@ }, "0.4.4": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -887,6 +927,7 @@ }, "0.4.5": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -910,6 +951,7 @@ }, "0.4.6": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -932,6 +974,7 @@ }, "0.4.7": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -954,6 +997,7 @@ }, "0.4.8": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -976,6 +1020,7 @@ }, "0.4.9": { "bugs": [ + "DirtyBytesArrayToStorage", "KeccakCaching", "EmptyByteArrayCopy", "DynamicArrayCleanup", @@ -998,6 +1043,7 @@ }, "0.5.0": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -1017,6 +1063,7 @@ }, "0.5.1": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -1036,6 +1083,8 @@ }, "0.5.10": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", @@ -1052,6 +1101,8 @@ }, "0.5.11": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", @@ -1067,6 +1118,8 @@ }, "0.5.12": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", @@ -1082,6 +1135,8 @@ }, "0.5.13": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", @@ -1097,6 +1152,8 @@ }, "0.5.14": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", @@ -1114,6 +1171,8 @@ }, "0.5.15": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", @@ -1130,6 +1189,8 @@ }, "0.5.16": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", @@ -1145,6 +1206,8 @@ }, "0.5.17": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", @@ -1159,6 +1222,7 @@ }, "0.5.2": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -1178,6 +1242,7 @@ }, "0.5.3": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -1197,6 +1262,7 @@ }, "0.5.4": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -1216,6 +1282,7 @@ }, "0.5.5": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -1237,6 +1304,7 @@ }, "0.5.6": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -1258,6 +1326,7 @@ }, "0.5.7": { "bugs": [ + "DirtyBytesArrayToStorage", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", "EmptyByteArrayCopy", @@ -1277,6 +1346,8 @@ }, "0.5.8": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", @@ -1296,6 +1367,8 @@ }, "0.5.9": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", @@ -1314,6 +1387,8 @@ }, "0.6.0": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", @@ -1330,6 +1405,8 @@ }, "0.6.1": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", @@ -1345,6 +1422,8 @@ }, "0.6.10": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", @@ -1357,6 +1436,8 @@ }, "0.6.11": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", @@ -1369,6 +1450,8 @@ }, "0.6.12": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", @@ -1381,6 +1464,8 @@ }, "0.6.2": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", @@ -1396,6 +1481,8 @@ }, "0.6.3": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", @@ -1411,6 +1498,8 @@ }, "0.6.4": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "ABIDecodeTwoDimensionalArrayMemory", "KeccakCaching", @@ -1426,6 +1515,8 @@ }, "0.6.5": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", "ABIDecodeTwoDimensionalArrayMemory", @@ -1441,6 +1532,8 @@ }, "0.6.6": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", "ABIDecodeTwoDimensionalArrayMemory", @@ -1455,6 +1548,8 @@ }, "0.6.7": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", "ABIDecodeTwoDimensionalArrayMemory", @@ -1469,6 +1564,8 @@ }, "0.6.8": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", "ABIDecodeTwoDimensionalArrayMemory", @@ -1480,6 +1577,8 @@ }, "0.6.9": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", @@ -1493,6 +1592,8 @@ }, "0.7.0": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", @@ -1505,6 +1606,8 @@ }, "0.7.1": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", @@ -1518,6 +1621,8 @@ }, "0.7.2": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", @@ -1530,6 +1635,8 @@ }, "0.7.3": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", @@ -1541,6 +1648,8 @@ }, "0.7.4": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", @@ -1551,6 +1660,8 @@ }, "0.7.5": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", @@ -1561,6 +1672,8 @@ }, "0.7.6": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", @@ -1571,6 +1684,8 @@ }, "0.8.0": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", @@ -1581,6 +1696,8 @@ }, "0.8.1": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", @@ -1591,6 +1708,8 @@ }, "0.8.10": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation" ], @@ -1598,6 +1717,8 @@ }, "0.8.11": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "AbiEncodeCallLiteralAsFixedBytesBug" @@ -1606,6 +1727,8 @@ }, "0.8.12": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "AbiEncodeCallLiteralAsFixedBytesBug" @@ -1614,17 +1737,36 @@ }, "0.8.13": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", + "InlineAssemblyMemorySideEffects", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation" ], "released": "2022-03-16" }, "0.8.14": { - "bugs": [], + "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", + "InlineAssemblyMemorySideEffects" + ], "released": "2022-05-17" }, + "0.8.15": { + "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup" + ], + "released": "2022-06-15" + }, + "0.8.16": { + "bugs": [], + "released": "2022-08-08" + }, "0.8.2": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", @@ -1635,6 +1777,8 @@ }, "0.8.3": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables", @@ -1644,6 +1788,8 @@ }, "0.8.4": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables" @@ -1652,6 +1798,8 @@ }, "0.8.5": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables" @@ -1660,6 +1808,8 @@ }, "0.8.6": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables" @@ -1668,6 +1818,8 @@ }, "0.8.7": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "SignedImmutables" @@ -1676,6 +1828,8 @@ }, "0.8.8": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation", "UserDefinedValueTypesBug", @@ -1685,6 +1839,8 @@ }, "0.8.9": { "bugs": [ + "AbiReencodingHeadOverflowWithStaticArrayCleanup", + "DirtyBytesArrayToStorage", "DataLocationChangeInInternalOverride", "NestedCallataArrayAbiReencodingSizeValidation" ], diff --git a/docs/cheatsheet.rst b/docs/cheatsheet.rst index a7581aae5..3a7d478b1 100644 --- a/docs/cheatsheet.rst +++ b/docs/cheatsheet.rst @@ -2,70 +2,11 @@ Cheatsheet ********** -.. index:: precedence - -.. _order: +.. index:: operator; precedence Order of Precedence of Operators ================================ - -The following is the order of precedence for operators, listed in order of evaluation. - -+------------+-------------------------------------+--------------------------------------------+ -| Precedence | Description | Operator | -+============+=====================================+============================================+ -| *1* | Postfix increment and decrement | ``++``, ``--`` | -+ +-------------------------------------+--------------------------------------------+ -| | New expression | ``new `` | -+ +-------------------------------------+--------------------------------------------+ -| | Array subscripting | ``[]`` | -+ +-------------------------------------+--------------------------------------------+ -| | Member access | ``.`` | -+ +-------------------------------------+--------------------------------------------+ -| | Function-like call | ``()`` | -+ +-------------------------------------+--------------------------------------------+ -| | Parentheses | ``()`` | -+------------+-------------------------------------+--------------------------------------------+ -| *2* | Prefix increment and decrement | ``++``, ``--`` | -+ +-------------------------------------+--------------------------------------------+ -| | Unary minus | ``-`` | -+ +-------------------------------------+--------------------------------------------+ -| | Unary operations | ``delete`` | -+ +-------------------------------------+--------------------------------------------+ -| | Logical NOT | ``!`` | -+ +-------------------------------------+--------------------------------------------+ -| | Bitwise NOT | ``~`` | -+------------+-------------------------------------+--------------------------------------------+ -| *3* | Exponentiation | ``**`` | -+------------+-------------------------------------+--------------------------------------------+ -| *4* | Multiplication, division and modulo | ``*``, ``/``, ``%`` | -+------------+-------------------------------------+--------------------------------------------+ -| *5* | Addition and subtraction | ``+``, ``-`` | -+------------+-------------------------------------+--------------------------------------------+ -| *6* | Bitwise shift operators | ``<<``, ``>>`` | -+------------+-------------------------------------+--------------------------------------------+ -| *7* | Bitwise AND | ``&`` | -+------------+-------------------------------------+--------------------------------------------+ -| *8* | Bitwise XOR | ``^`` | -+------------+-------------------------------------+--------------------------------------------+ -| *9* | Bitwise OR | ``|`` | -+------------+-------------------------------------+--------------------------------------------+ -| *10* | Inequality operators | ``<``, ``>``, ``<=``, ``>=`` | -+------------+-------------------------------------+--------------------------------------------+ -| *11* | Equality operators | ``==``, ``!=`` | -+------------+-------------------------------------+--------------------------------------------+ -| *12* | Logical AND | ``&&`` | -+------------+-------------------------------------+--------------------------------------------+ -| *13* | Logical OR | ``||`` | -+------------+-------------------------------------+--------------------------------------------+ -| *14* | Ternary operator | `` ? : `` | -+ +-------------------------------------+--------------------------------------------+ -| | Assignment operators | ``=``, ``|=``, ``^=``, ``&=``, ``<<=``, | -| | | ``>>=``, ``+=``, ``-=``, ``*=``, ``/=``, | -| | | ``%=`` | -+------------+-------------------------------------+--------------------------------------------+ -| *15* | Comma operator | ``,`` | -+------------+-------------------------------------+--------------------------------------------+ +.. include:: types/operator-precedence-table.rst .. index:: assert, block, coinbase, difficulty, number, block;number, timestamp, block;timestamp, msg, data, gas, sender, value, gas price, origin, revert, require, keccak256, ripemd160, sha256, ecrecover, addmod, mulmod, cryptography, this, super, selfdestruct, balance, codehash, send @@ -135,35 +76,6 @@ Global Variables - ``type(T).min`` (``T``): the minimum value representable by the integer type ``T``, see :ref:`Type Information`. - ``type(T).max`` (``T``): the maximum value representable by the integer type ``T``, see :ref:`Type Information`. -.. note:: - When contracts are evaluated off-chain rather than in context of a transaction included in a - block, you should not assume that ``block.*`` and ``tx.*`` refer to values from any specific - block or transaction. These values are provided by the EVM implementation that executes the - contract and can be arbitrary. - -.. note:: - Do not rely on ``block.timestamp`` or ``blockhash`` as a source of randomness, - unless you know what you are doing. - - Both the timestamp and the block hash can be influenced by miners to some degree. - Bad actors in the mining community can for example run a casino payout function on a chosen hash - and just retry a different hash if they did not receive any money. - - The current block timestamp must be strictly larger than the timestamp of the last block, - but the only guarantee is that it will be somewhere between the timestamps of two - consecutive blocks in the canonical chain. - -.. note:: - The block hashes are not available for all blocks for scalability reasons. - You can only access the hashes of the most recent 256 blocks, all other - values will be zero. - -.. note:: - In version 0.5.0, the following aliases were removed: ``suicide`` as alias for ``selfdestruct``, - ``msg.gas`` as alias for ``gasleft``, ``block.blockhash`` as alias for ``blockhash`` and - ``sha3`` as alias for ``keccak256``. -.. note:: - In version 0.7.0, the alias ``now`` (for ``block.timestamp``) was removed. .. index:: visibility, public, private, external, internal @@ -200,13 +112,3 @@ Modifiers - ``override``: States that this function, modifier or public state variable changes the behaviour of a function or modifier in a base contract. -Reserved Keywords -================= - -These keywords are reserved in Solidity. They might become part of the syntax in the future: - -``after``, ``alias``, ``apply``, ``auto``, ``byte``, ``case``, ``copyof``, ``default``, -``define``, ``final``, ``implements``, ``in``, ``inline``, ``let``, ``macro``, ``match``, -``mutable``, ``null``, ``of``, ``partial``, ``promise``, ``reference``, ``relocatable``, -``sealed``, ``sizeof``, ``static``, ``supports``, ``switch``, ``typedef``, ``typeof``, -``var``. diff --git a/docs/contracts/constant-state-variables.rst b/docs/contracts/constant-state-variables.rst index e917cad7f..2e94397b1 100644 --- a/docs/contracts/constant-state-variables.rst +++ b/docs/contracts/constant-state-variables.rst @@ -81,7 +81,7 @@ construction time. The contract creation code generated by the compiler will modify the contract's runtime code before it is returned by replacing all references -to immutables by the values assigned to the them. This is important if +to immutables with the values assigned to them. This is important if you are comparing the runtime code generated by the compiler with the one actually stored in the blockchain. @@ -95,4 +95,4 @@ blockchain. This is a safeguard against different interpretations about the order of state variable initialization and constructor execution, especially - with regards to inheritance. \ No newline at end of file + with regards to inheritance. diff --git a/docs/contracts/errors.rst b/docs/contracts/errors.rst index 7800317a8..19577a387 100644 --- a/docs/contracts/errors.rst +++ b/docs/contracts/errors.rst @@ -1,5 +1,4 @@ -.. index:: ! error, revert - +.. index:: ! error, revert, ! selector; of an error .. _errors: ******************************* @@ -80,3 +79,8 @@ of the built-in type ``Panic(uint256)``. by default. This means that an inner call can "forge" revert data that looks like it could have come from the contract that called it. + +Members of Errors +================= + +- ``error.selector``: A ``bytes4`` value containing the error selector. diff --git a/docs/contracts/events.rst b/docs/contracts/events.rst index 27df4dde1..8618e7524 100644 --- a/docs/contracts/events.rst +++ b/docs/contracts/events.rst @@ -1,4 +1,4 @@ -.. index:: ! event +.. index:: ! event, ! event; anonymous, ! event; indexed, ! event; topic .. _events: @@ -73,6 +73,18 @@ four indexed arguments rather than three. In particular, it is possible to "fake" the signature of another event using an anonymous event. +.. index:: ! selector; of an event + +Members of Events +================= + +- ``event.selector``: For non-anonymous events, this is a ``bytes32`` value + containing the ``keccak256`` hash of the event signature, as used in the default topic. + + +Example +======= + .. code-block:: solidity // SPDX-License-Identifier: GPL-3.0 @@ -137,7 +149,7 @@ The output of the above looks like the following (trimmed): } Additional Resources for Understanding Events -============================================== +============================================= - `Javascript documentation `_ - `Example usage of events `_ diff --git a/docs/contracts/function-modifiers.rst b/docs/contracts/function-modifiers.rst index 2445895e4..f23119544 100644 --- a/docs/contracts/function-modifiers.rst +++ b/docs/contracts/function-modifiers.rst @@ -111,6 +111,12 @@ whitespace-separated list and are evaluated in the order presented. Modifiers cannot implicitly access or change the arguments and return values of functions they modify. Their values can only be passed to them explicitly at the point of invocation. +In function modifiers, it is necessary to specify when you want the function to which the modifier is +applied to be run. The placeholder statement (denoted by a single underscore character ``_``) is used to +denote where the body of the function being modified should be inserted. Note that the +placeholder operator is different from using underscores as leading or trailing characters in variable +names, which is a stylistic choice. + Explicit returns from a modifier or function body only leave the current modifier or function body. Return variables are assigned and control flow continues after the ``_`` in the preceding modifier. diff --git a/docs/contracts/functions.rst b/docs/contracts/functions.rst index 8dbb2e275..7765e95b4 100644 --- a/docs/contracts/functions.rst +++ b/docs/contracts/functions.rst @@ -35,10 +35,10 @@ that call them, similar to internal library functions. .. note:: Functions defined outside a contract are still always executed - in the context of a contract. They still have access to the variable ``this``, - can call other contracts, send them Ether and destroy the contract that called them, + in the context of a contract. + They still can call other contracts, send them Ether and destroy the contract that called them, among other things. The main difference to functions defined inside a contract - is that free functions do not have direct access to storage variables and functions + is that free functions do not have direct access to the variable ``this``, storage variables and functions not in their scope. .. _function-parameters-return-variables: @@ -72,16 +72,6 @@ with two integers, you would use something like the following: Function parameters can be used as any other local variable and they can also be assigned to. -.. note:: - - An :ref:`external function` cannot accept a - multi-dimensional array as an input - parameter. This functionality is possible if you enable the ABI coder v2 - by adding ``pragma abicoder v2;`` to your source file. - - An :ref:`internal function` can accept a - multi-dimensional array without enabling the feature. - .. index:: return array, return string, array, string, array of strings, dynamic array, variably sized array, return struct, struct Return Variables @@ -139,12 +129,16 @@ If you use an early ``return`` to leave a function that has return variables, you must provide return values together with the return statement. .. note:: - You cannot return some types from non-internal functions, notably - multi-dimensional dynamic arrays and structs. If you enable the - ABI coder v2 by adding ``pragma abicoder v2;`` - to your source file then more types are available, but - ``mapping`` types are still limited to inside a single contract and you - cannot transfer them. + You cannot return some types from non-internal functions. + This includes the types listed below and any composite types that recursively contain them: + + - mappings, + - internal function types, + - reference types with location set to ``storage``, + - multi-dimensional arrays (applies only to :ref:`ABI coder v1 `), + - structs (applies only to :ref:`ABI coder v1 `). + + This restriction does not apply to library functions because of their different :ref:`internal ABI `. .. _multi-return: diff --git a/docs/contracts/libraries.rst b/docs/contracts/libraries.rst index c40284b49..7256ebe03 100644 --- a/docs/contracts/libraries.rst +++ b/docs/contracts/libraries.rst @@ -215,7 +215,7 @@ In comparison to contracts, libraries are restricted in the following ways: (These might be lifted at a later point.) .. _library-selectors: -.. index:: selector +.. index:: ! selector; of a library function Function Signatures and Selectors in Libraries ============================================== diff --git a/docs/contracts/using-for.rst b/docs/contracts/using-for.rst index 2c2817f15..b4a60585a 100644 --- a/docs/contracts/using-for.rst +++ b/docs/contracts/using-for.rst @@ -87,7 +87,6 @@ instead of library functions. } function contains(Data storage self, uint value) - public view returns (bool) { diff --git a/docs/contributing.rst b/docs/contributing.rst index 0c2ee9124..9da7f02d0 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -2,7 +2,7 @@ Contributing ############ -Help is always welcome and there are plenty of options how you can contribute to Solidity. +Help is always welcome and there are plenty of options to contribute to Solidity. In particular, we appreciate support in the following areas: @@ -22,7 +22,7 @@ To get started, you can try :ref:`building-from-source` in order to familiarize yourself with the components of Solidity and the build process. Also, it may be useful to become well-versed at writing smart-contracts in Solidity. -Please note that this project is released with a `Contributor Code of Conduct `_. By participating in this project - in the issues, pull requests, or Gitter channels - you agree to abide by its terms. +Please note that this project is released with a `Contributor Code of Conduct `_. By participating in this project — in the issues, pull requests, or Gitter channels — you agree to abide by its terms. Team Calls ========== @@ -30,8 +30,7 @@ Team Calls If you have issues or pull requests to discuss, or are interested in hearing what the team and contributors are working on, you can join our public team calls: -- Mondays at 3pm CET/CEST. -- Wednesdays at 2pm CET/CEST. +- Mondays and Wednesdays at 3pm CET/CEST. Both calls take place on `Jitsi `_. @@ -49,7 +48,7 @@ reporting issues, please mention the following details: * Actual vs. expected behaviour. Reducing the source code that caused the issue to a bare minimum is always -very helpful and sometimes even clarifies a misunderstanding. +very helpful, and sometimes even clarifies a misunderstanding. Workflow for Pull Requests ========================== @@ -67,7 +66,7 @@ Additionally, if you are writing a new feature, please ensure you add appropriat test cases under ``test/`` (see below). However, if you are making a larger change, please consult with the `Solidity Development Gitter channel -`_ (different from the one mentioned above, this one is +`_ (different from the one mentioned above — this one is focused on compiler and language development instead of language usage) first. New features and bugfixes should be added to the ``Changelog.md`` file: please @@ -91,10 +90,10 @@ dependencies (`evmone `_, `libz3 `_, and `libhera `_). -On macOS some of the testing scripts expect GNU coreutils to be installed. +On macOS systems, some of the testing scripts expect GNU coreutils to be installed. This can be easiest accomplished using Homebrew: ``brew install coreutils``. -On Windows systems make sure that you have a privilege to create symlinks, +On Windows systems, make sure that you have a privilege to create symlinks, otherwise several tests may fail. Administrators should have that privilege, but you may also `grant it to other users `_ @@ -117,7 +116,7 @@ The test system automatically tries to discover the location of the `evmone `_ for running the semantic tests. The ``evmone`` library must be located in the ``deps`` or ``deps/lib`` directory relative to the -current working directory, to its parent or its parent's parent. Alternatively an explicit location +current working directory, to its parent or its parent's parent. Alternatively, an explicit location for the ``evmone`` shared object can be specified via the ``ETH_EVMONE`` environment variable. ``evmone`` is needed mainly for running semantic and gas tests. @@ -245,7 +244,7 @@ It offers several options for failing tests: - ``skip``: Skips the execution of this particular test. - ``quit``: Quits ``isoltest``. -All of these options apply to the current contract, expect ``quit`` which stops the entire testing process. +All of these options apply to the current contract, except ``quit`` which stops the entire testing process. Automatically updating the test above changes it to @@ -292,7 +291,7 @@ Next, build Solidity (or just the ``solfuzzer`` binary) with AFL as your compile cmake .. -DCMAKE_C_COMPILER=path/to/afl-gcc -DCMAKE_CXX_COMPILER=path/to/afl-g++ make solfuzzer -At this stage you should be able to see a message similar to the following: +At this stage, you should be able to see a message similar to the following: .. code-block:: text @@ -481,7 +480,7 @@ needed for documentation and checks for any problems such as broken links or syn Solidity Language Design ======================== -To actively get involved in the language design process and share your ideas concerning the future of Solidity, +To actively get involved in the language design process and to share your ideas concerning the future of Solidity, please join the `Solidity forum `_. The Solidity forum serves as the place to propose and discuss new language features and their implementation in @@ -500,7 +499,7 @@ If you want to know where the team is standing in terms or implementing new feat Issues in the design backlog need further specification and will either be discussed in a language design call or in a regular team call. You can see the upcoming changes for the next breaking release by changing from the default branch (`develop`) to the `breaking branch `_. -For ad-hoc cases and questions you can reach out to us via the `Solidity-dev Gitter channel `_, a +For ad-hoc cases and questions, you can reach out to us via the `Solidity-dev Gitter channel `_ — a dedicated chatroom for conversations around the Solidity compiler and language development. We are happy to hear your thoughts on how we can improve the language design process to be even more collaborative and transparent. diff --git a/docs/control-structures.rst b/docs/control-structures.rst index de3b58485..18a522217 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -150,8 +150,8 @@ throws an exception or goes out of gas. use ``f.value(x).gas(g)()``. This was deprecated in Solidity 0.6.2 and is no longer possible since Solidity 0.7.0. -Named Calls and Anonymous Function Parameters ---------------------------------------------- +Function Calls with Named Parameters +------------------------------------ Function call arguments can be given by name, in any order, if they are enclosed in ``{ }`` as can be seen in the following @@ -176,11 +176,13 @@ parameters from the function declaration, but can be in arbitrary order. } -Omitted Function Parameter Names --------------------------------- +Omitted Names in Function Definitions +------------------------------------- -The names of unused parameters (especially return parameters) can be omitted. -Those parameters will still be present on the stack, but they are inaccessible. +The names of parameters and return values in the function declaration can be omitted. +Those items with omitted names will still be present on the stack, but they are +inaccessible by name. An omitted return value name +can still return a value to the caller by use of the ``return`` statement. .. code-block:: solidity diff --git a/docs/examples/modular.rst b/docs/examples/modular.rst index 7903ae27f..697699ae6 100644 --- a/docs/examples/modular.rst +++ b/docs/examples/modular.rst @@ -7,7 +7,7 @@ Modular Contracts A modular approach to building your contracts helps you reduce the complexity and improve the readability which will help to identify bugs and vulnerabilities during development and code review. -If you specify and control the behaviour or each module in isolation, the +If you specify and control the behaviour of each module in isolation, the interactions you have to consider are only those between the module specifications and not every other moving part of the contract. In the example below, the contract uses the ``move`` method diff --git a/docs/examples/voting.rst b/docs/examples/voting.rst index 6e36f4e51..de899da7a 100644 --- a/docs/examples/voting.rst +++ b/docs/examples/voting.rst @@ -129,14 +129,16 @@ of votes. require(to != msg.sender, "Found loop in delegation."); } - // Since `sender` is a reference, this - // modifies `voters[msg.sender].voted` Voter storage delegate_ = voters[to]; // Voters cannot delegate to accounts that cannot vote. require(delegate_.weight >= 1); + + // Since `sender` is a reference, this + // modifies `voters[msg.sender]`. sender.voted = true; sender.delegate = to; + if (delegate_.voted) { // If the delegate already voted, // directly add to the number of votes @@ -191,5 +193,8 @@ of votes. Possible Improvements ===================== -Currently, many transactions are needed to assign the rights -to vote to all participants. Can you think of a better way? +Currently, many transactions are needed to +assign the rights to vote to all participants. +Moreover, if two or more proposals have the same +number of votes, ``winningProposal()`` is not able +to register a tie. Can you think of a way to fix these issues? \ No newline at end of file diff --git a/docs/grammar/SolidityLexer.g4 b/docs/grammar/SolidityLexer.g4 index 9250835dd..c47dc411c 100644 --- a/docs/grammar/SolidityLexer.g4 +++ b/docs/grammar/SolidityLexer.g4 @@ -9,10 +9,9 @@ ReservedKeywords: | 'partial' | 'promise' | 'reference' | 'relocatable' | 'sealed' | 'sizeof' | 'static' | 'supports' | 'switch' | 'typedef' | 'typeof' | 'var'; -Pragma: 'pragma' -> pushMode(PragmaMode); Abstract: 'abstract'; -Anonymous: 'anonymous'; Address: 'address'; +Anonymous: 'anonymous'; As: 'as'; Assembly: 'assembly' -> pushMode(AssemblyBlockMode); Bool: 'bool'; @@ -30,13 +29,11 @@ Else: 'else'; Emit: 'emit'; Enum: 'enum'; Error: 'error'; // not a real keyword -Revert: 'revert'; // not a real keyword Event: 'event'; External: 'external'; Fallback: 'fallback'; False: 'false'; Fixed: 'fixed' | ('fixed' [1-9][0-9]* 'x' [1-9][0-9]*); -From: 'from'; // not a real keyword /** * Bytes types of fixed length. */ @@ -46,6 +43,7 @@ FixedBytes: 'bytes17' | 'bytes18' | 'bytes19' | 'bytes20' | 'bytes21' | 'bytes22' | 'bytes23' | 'bytes24' | 'bytes25' | 'bytes26' | 'bytes27' | 'bytes28' | 'bytes29' | 'bytes30' | 'bytes31' | 'bytes32'; For: 'for'; +From: 'from'; // not a real keyword Function: 'function'; Global: 'global'; // not a real keyword Hex: 'hex'; @@ -67,12 +65,14 @@ New: 'new'; NumberUnit: 'wei' | 'gwei' | 'ether' | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'years'; Override: 'override'; Payable: 'payable'; +Pragma: 'pragma' -> pushMode(PragmaMode); Private: 'private'; Public: 'public'; Pure: 'pure'; Receive: 'receive'; Return: 'return'; Returns: 'returns'; +Revert: 'revert'; // not a real keyword /** * Sized signed integer types. * int is an alias of int256. diff --git a/docs/installing-solidity.rst b/docs/installing-solidity.rst index 9d6e666d2..9a613d75d 100644 --- a/docs/installing-solidity.rst +++ b/docs/installing-solidity.rst @@ -354,6 +354,17 @@ The following are dependencies for all builds of Solidity: If you do this, however, please remember to pass the ``--no-smt`` option to ``scripts/tests.sh`` to skip the SMT tests. +.. note:: + By default the build is performed in *pedantic mode*, which enables extra warnings and tells the + compiler to treat all warnings as errors. + This forces developers to fix warnings as they arise, so they do not accumulate "to be fixed later". + If you are only interested in creating a release build and do not intend to modify the source code + to deal with such warnings, you can pass ``-DPEDANTIC=OFF`` option to CMake to disable this mode. + Doing this is not recommended for general use but may be necessary when using a toolchain we are + not testing with or trying to build an older version with newer tools. + If you encounter such warnings, please consider + `reporting them `_. + Minimum Compiler Versions ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/internals/layout_in_storage.rst b/docs/internals/layout_in_storage.rst index 599cd03d3..53670eeb8 100644 --- a/docs/internals/layout_in_storage.rst +++ b/docs/internals/layout_in_storage.rst @@ -153,7 +153,7 @@ the :ref:`standard JSON interface `. The output is a JSON object element has the following form: -.. code:: +.. code-block:: json { @@ -181,7 +181,7 @@ The given ``type``, in this case ``t_uint256`` represents an element in ``types``, which has the form: -.. code:: +.. code-block:: json { "encoding": "inplace", @@ -238,7 +238,7 @@ value and reference types, types that are encoded packed, and nested types. bytes b1; } -.. code:: json +.. code-block:: json { "storage": [ diff --git a/docs/internals/optimizer.rst b/docs/internals/optimizer.rst index 1d6c214e5..5ad0f19e5 100644 --- a/docs/internals/optimizer.rst +++ b/docs/internals/optimizer.rst @@ -330,7 +330,7 @@ the ``--yul-optimizations`` option: The sequence inside ``[...]`` will be applied multiple times in a loop until the Yul code remains unchanged or until the maximum number of rounds (currently 12) has been reached. -Available abbreviations are listed in the `Yul optimizer docs `_. +Available abbreviations are listed in the :ref:`Yul optimizer docs `. Preprocessing ------------- @@ -683,7 +683,7 @@ Conflicting values are resolved in the following way: - "unused", "undecided" -> "undecided" - "unused", "used" -> "used" -- "undecided, "used" -> "used" +- "undecided", "used" -> "used" For for-loops, the condition, body and post-part are visited twice, taking the joining control-flow at the condition into account. diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index 9b2e5fceb..875e5ebc8 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -186,7 +186,9 @@ transactions. To listen for this event, you could use the following JavaScript code, which uses `web3.js `_ to create the ``Coin`` contract object, -and any user interface calls the automatically generated ``balances`` function from above:: +and any user interface calls the automatically generated ``balances`` function from above: + +.. code-block:: javascript Coin.Sent().watch({}, '', function(error, result) { if (!error) { @@ -504,10 +506,10 @@ operations, loops should be preferred over recursive calls. Furthermore, only 63/64th of the gas can be forwarded in a message call, which causes a depth limit of a little less than 1000 in practice. -.. index:: delegatecall, callcode, library +.. index:: delegatecall, library -Delegatecall / Callcode and Libraries -===================================== +Delegatecall and Libraries +========================== There exists a special variant of a message call, named **delegatecall** which is identical to a message call apart from the fact that @@ -548,7 +550,7 @@ these **create calls** and normal message calls is that the payload data is executed and the result stored as code and the caller / creator receives the address of the new contract on the stack. -.. index:: selfdestruct, self-destruct, deactivate +.. index:: ! selfdestruct, deactivate Deactivate and Self-destruct ============================ diff --git a/docs/ir-breaking-changes.rst b/docs/ir-breaking-changes.rst index 2b5905a96..7e4efce68 100644 --- a/docs/ir-breaking-changes.rst +++ b/docs/ir-breaking-changes.rst @@ -154,37 +154,6 @@ hiding new and different behavior in existing code. - New code generator: ``0`` as all parameters, including return parameters, will be re-initialized before each ``_;`` evaluation. -- Copying ``bytes`` arrays from memory to storage is implemented in a different way. - The old code generator always copies full words, while the new one cuts the byte - array after its end. The old behaviour can lead to dirty data being copied after - the end of the array (but still in the same storage slot). - This causes differences in some contracts, for example: - - .. code-block:: solidity - - // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.8.1; - - contract C { - bytes x; - function f() public returns (uint r) { - bytes memory m = "tmp"; - assembly { - mstore(m, 8) - mstore(add(m, 32), "deadbeef15dead") - } - x = m; - assembly { - r := sload(x.slot) - } - } - } - - Previously ``f()`` would return ``0x6465616462656566313564656164000000000000000000000000000000000010`` - (it has correct length, and correct first 8 elements, but then it contains dirty data which was set via assembly). - Now it is returning ``0x6465616462656566000000000000000000000000000000000000000000000010`` (it has - correct length, and correct elements, but does not contain superfluous data). - .. index:: ! evaluation order; expression - For the old code generator, the evaluation order of expressions is unspecified. diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index 729951142..9a5847858 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -56,7 +56,7 @@ you have to add the pragma to all your files if you want to enable it in your whole project. If you :ref:`import` another file, the pragma from that file does *not* automatically apply to the importing file. -.. index:: ! pragma, version +.. index:: ! pragma;version .. _version_pragma: @@ -91,6 +91,9 @@ these follow the same syntax used by `npm `. You have to publish the metadata file to IPFS, Swarm, or another service so that others can access it. You create the file by using the ``solc --metadata`` -command that generates a file called ``ContractName_meta.json``. It contains -IPFS and Swarm references to the source code, so you have to upload all source -files and the metadata file. +command together with the ``--output-dir`` parameter. Without the parameter, +the metadata will be written to standard output. +The metadata contains IPFS and Swarm references to the source code, so you have to +upload all source files in addition to the metadata file. For IPFS, the hash contained +in the CID returned by ``ipfs add`` (not the direct sha2-256 hash of the file) +shall match with the one contained in the bytecode. The metadata file has the following format. The example below is presented in a human-readable way. Properly formatted metadata should use quotes correctly, @@ -43,20 +46,20 @@ explanatory purposes. // to the language. "compiler": { // Required for Solidity: Version of the compiler - "version": "0.4.6+commit.2dabbdf0.Emscripten.clang", + "version": "0.8.2+commit.661d1103", // Optional: Hash of the compiler binary which produced this output "keccak256": "0x123..." }, - // Required: Compilation source files/source units, keys are file names + // Required: Compilation source files/source units, keys are file paths "sources": { - "myFile.sol": { + "myDirectory/myFile.sol": { // Required: keccak256 hash of the source file "keccak256": "0x123...", // Required (unless "content" is used, see below): Sorted URL(s) - // to the source file, protocol is more or less arbitrary, but a - // Swarm URL is recommended - "urls": [ "bzzr://56ab..." ], + // to the source file, protocol is more or less arbitrary, but an + // IPFS URL is recommended + "urls": [ "bzz-raw://7d7a...", "dweb:/ipfs/QmN..." ], // Optional: SPDX license identifier as given in the source file "license": "MIT" }, @@ -70,7 +73,7 @@ explanatory purposes. // Required: Compiler settings "settings": { - // Required for Solidity: Sorted list of remappings + // Required for Solidity: Sorted list of import remappings "remappings": [ ":g=/dir" ], // Optional: Optimizer settings. The fields "enabled" and "runs" are deprecated // and are only given for backwards-compatibility. @@ -97,15 +100,15 @@ explanatory purposes. } }, "metadata": { - // Reflects the setting used in the input json, defaults to false + // Reflects the setting used in the input json, defaults to "false" "useLiteralContent": true, // Reflects the setting used in the input json, defaults to "ipfs" "bytecodeHash": "ipfs" }, - // Required for Solidity: File and name of the contract or library this + // Required for Solidity: File path and the name of the contract or library this // metadata is created for. "compilationTarget": { - "myFile.sol": "MyContract" + "myDirectory/myFile.sol": "MyContract" }, // Required for Solidity: Addresses for libraries used "libraries": { @@ -115,12 +118,66 @@ explanatory purposes. // Required: Generated information about the contract. "output": { - // Required: ABI definition of the contract + // Required: ABI definition of the contract. See "Contract ABI Specification" "abi": [/* ... */], + // Required: NatSpec developer documentation of the contract. + "devdoc": { + "version": 1 // NatSpec version + "kind": "dev", + // Contents of the @author NatSpec field of the contract + "author": "John Doe", + // Contents of the @title NatSpec field of the contract + "title": "MyERC20: an example ERC20" + // Contents of the @dev NatSpec field of the contract + "details": "Interface of the ERC20 standard as defined in the EIP. See https://eips.ethereum.org/EIPS/eip-20 for details", + "methods": { + "transfer(address,uint256)": { + // Contents of the @dev NatSpec field of the method + "details": "Returns a boolean value indicating whether the operation succeeded. Must be called by the token holder address", + // Contents of the @param NatSpec fields of the method + "params": { + "_value": "The amount tokens to be transferred", + "_to": "The receiver address" + } + // Contents of the @return NatSpec field. + "returns": { + // Return var name (here "success") if exists. "_0" as key if return var is unnamed + "success": "a boolean value indicating whether the operation succeeded" + } + } + }, + "stateVariables": { + "owner": { + // Contents of the @dev NatSpec field of the state variable + "details": "Must be set during contract creation. Can then only be changed by the owner" + } + } + "events": { + "Transfer(address,address,uint256)": { + "details": "Emitted when `value` tokens are moved from one account (`from`) toanother (`to`)." + "params": { + "from": "The sender address" + "to": "The receiver address" + "value": "The token amount" + } + } + } + }, // Required: NatSpec user documentation of the contract - "userdoc": [/* ... */], - // Required: NatSpec developer documentation of the contract - "devdoc": [/* ... */] + "userdoc": { + "version": 1 // NatSpec version + "kind": "user", + "methods": { + "transfer(address,uint256)": { + "notice": "Transfers `_value` tokens to address `_to`" + } + }, + "events": { + "Transfer(address,address,uint256)": { + "notice": "`_value` tokens have been moved from `from` to `to`" + } + } + } } } @@ -157,7 +214,7 @@ to the end of the deployed bytecode 0x00 0x33 So in order to retrieve the data, the end of the deployed bytecode can be checked -to match that pattern and use the IPFS hash to retrieve the file. +to match that pattern and the IPFS hash can be used to retrieve the file (if pinned/published). Whereas release builds of solc use a 3 byte encoding of the version as shown above (one byte each for major, minor and patch version number), prerelease builds @@ -181,14 +238,15 @@ Usage for Automatic Interface Generation and NatSpec ==================================================== The metadata is used in the following way: A component that wants to interact -with a contract (e.g. Mist or any wallet) retrieves the code of the contract, -from that the IPFS/Swarm hash of a file which is then retrieved. That file +with a contract (e.g. a wallet) retrieves the code of the contract. +It decodes the CBOR encoded section containing the IPFS/Swarm hash of the +metadata file. With that hash, the metadata file is retrieved. That file is JSON-decoded into a structure like above. The component can then use the ABI to automatically generate a rudimentary user interface for the contract. -Furthermore, the wallet can use the NatSpec user documentation to display a confirmation message to the user +Furthermore, the wallet can use the NatSpec user documentation to display a human-readable confirmation message to the user whenever they interact with the contract, together with requesting authorization for the transaction signature. diff --git a/docs/natspec-format.rst b/docs/natspec-format.rst index a66c10462..28848dae4 100644 --- a/docs/natspec-format.rst +++ b/docs/natspec-format.rst @@ -183,7 +183,7 @@ other to be used by the developer. If the above contract is saved as ``ex1.sol`` then you can generate the documentation using: -.. code:: +.. code-block:: shell solc --userdoc --devdoc ex1.sol @@ -202,7 +202,7 @@ User Documentation The above documentation will produce the following user documentation JSON file as output: -.. code:: +.. code-block:: json { "version" : 1, @@ -230,7 +230,7 @@ Developer Documentation Apart from the user documentation file, a developer documentation JSON file should also be produced and should look like this: -.. code:: +.. code-block:: json { "version" : 1, diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst index 1a6568737..2b39bd76b 100644 --- a/docs/security-considerations.rst +++ b/docs/security-considerations.rst @@ -98,7 +98,7 @@ as it uses ``call`` which forwards all remaining gas by default: } To avoid re-entrancy, you can use the Checks-Effects-Interactions pattern as -outlined further below: +demonstrated below: .. code-block:: solidity @@ -116,6 +116,13 @@ outlined further below: } } +The Checks-Effects-Interactions pattern ensures that all code paths through a contract complete all required checks +of the supplied parameters before modifying the contract's state (Checks); only then it makes any changes to the state (Effects); +it may make calls to functions in other contracts *after* all planned state changes have been written to +storage (Interactions). This is a common foolproof way to prevent *re-entrancy attacks*, where an externally called +malicious contract is able to double-spend an allowance, double-withdraw a balance, among other things, by using logic that calls back into the +original contract before it has finalized its transaction. + Note that re-entrancy is not only an effect of Ether transfer but of any function call on another contract. Furthermore, you also have to take multi-contract situations into account. A called contract could modify the diff --git a/docs/style-guide.rst b/docs/style-guide.rst index 3b76273cc..75de18ac0 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -146,8 +146,7 @@ No: Maximum Line Length =================== -Keeping lines under the `PEP 8 recommendation `_ to a maximum of 79 (or 99) -characters helps readers easily parse the code. +Maximum suggested line length is 120 characters. Wrapped lines should conform to the following guidelines. @@ -1256,8 +1255,8 @@ Avoiding Naming Collisions * ``singleTrailingUnderscore_`` -This convention is suggested when the desired name collides with that of a -built-in or otherwise reserved name. +This convention is suggested when the desired name collides with that of +an existing state variable, function, built-in or otherwise reserved name. .. _style_guide_natspec: diff --git a/docs/types/conversion.rst b/docs/types/conversion.rst index 7e266d1bd..e6c68df41 100644 --- a/docs/types/conversion.rst +++ b/docs/types/conversion.rst @@ -188,6 +188,10 @@ Addresses As described in :ref:`address_literals`, hex literals of the correct size that pass the checksum test are of ``address`` type. No other literals can be implicitly converted to the ``address`` type. -Explicit conversions from ``bytes20`` or any integer type to ``address`` result in ``address payable``. +Explicit conversions to ``address`` are allowed only from ``bytes20`` and ``uint160``. -An ``address a`` can be converted to ``address payable`` via ``payable(a)``. +An ``address a`` can be converted explicitly to ``address payable`` via ``payable(a)``. + +.. note:: + Prior to version 0.8.0, it was possible to explicitly convert from any integer type (of any size, signed or unsigned) to ``address`` or ``address payable``. + Starting with in 0.8.0 only conversion from ``uint160`` is allowed. \ No newline at end of file diff --git a/docs/types/operator-precedence-table.rst b/docs/types/operator-precedence-table.rst new file mode 100644 index 000000000..65034045b --- /dev/null +++ b/docs/types/operator-precedence-table.rst @@ -0,0 +1,57 @@ +The following is the order of precedence for operators, listed in order of evaluation. + ++------------+-------------------------------------+--------------------------------------------+ +| Precedence | Description | Operator | ++============+=====================================+============================================+ +| *1* | Postfix increment and decrement | ``++``, ``--`` | ++ +-------------------------------------+--------------------------------------------+ +| | New expression | ``new `` | ++ +-------------------------------------+--------------------------------------------+ +| | Array subscripting | ``[]`` | ++ +-------------------------------------+--------------------------------------------+ +| | Member access | ``.`` | ++ +-------------------------------------+--------------------------------------------+ +| | Function-like call | ``()`` | ++ +-------------------------------------+--------------------------------------------+ +| | Parentheses | ``()`` | ++------------+-------------------------------------+--------------------------------------------+ +| *2* | Prefix increment and decrement | ``++``, ``--`` | ++ +-------------------------------------+--------------------------------------------+ +| | Unary minus | ``-`` | ++ +-------------------------------------+--------------------------------------------+ +| | Unary operations | ``delete`` | ++ +-------------------------------------+--------------------------------------------+ +| | Logical NOT | ``!`` | ++ +-------------------------------------+--------------------------------------------+ +| | Bitwise NOT | ``~`` | ++------------+-------------------------------------+--------------------------------------------+ +| *3* | Exponentiation | ``**`` | ++------------+-------------------------------------+--------------------------------------------+ +| *4* | Multiplication, division and modulo | ``*``, ``/``, ``%`` | ++------------+-------------------------------------+--------------------------------------------+ +| *5* | Addition and subtraction | ``+``, ``-`` | ++------------+-------------------------------------+--------------------------------------------+ +| *6* | Bitwise shift operators | ``<<``, ``>>`` | ++------------+-------------------------------------+--------------------------------------------+ +| *7* | Bitwise AND | ``&`` | ++------------+-------------------------------------+--------------------------------------------+ +| *8* | Bitwise XOR | ``^`` | ++------------+-------------------------------------+--------------------------------------------+ +| *9* | Bitwise OR | ``|`` | ++------------+-------------------------------------+--------------------------------------------+ +| *10* | Inequality operators | ``<``, ``>``, ``<=``, ``>=`` | ++------------+-------------------------------------+--------------------------------------------+ +| *11* | Equality operators | ``==``, ``!=`` | ++------------+-------------------------------------+--------------------------------------------+ +| *12* | Logical AND | ``&&`` | ++------------+-------------------------------------+--------------------------------------------+ +| *13* | Logical OR | ``||`` | ++------------+-------------------------------------+--------------------------------------------+ +| *14* | Ternary operator | `` ? : `` | ++ +-------------------------------------+--------------------------------------------+ +| | Assignment operators | ``=``, ``|=``, ``^=``, ``&=``, ``<<=``, | +| | | ``>>=``, ``+=``, ``-=``, ``*=``, ``/=``, | +| | | ``%=`` | ++------------+-------------------------------------+--------------------------------------------+ +| *15* | Comma operator | ``,`` | ++------------+-------------------------------------+--------------------------------------------+ diff --git a/docs/types/operators.rst b/docs/types/operators.rst index be5f0d456..1d71352d6 100644 --- a/docs/types/operators.rst +++ b/docs/types/operators.rst @@ -5,7 +5,7 @@ Operators Arithmetic and bit operators can be applied even if the two operands do not have the same type. For example, you can compute ``y = x + z``, where ``x`` is a ``uint8`` and ``z`` has -the type ``int32``. In these cases, the following mechanism will be used to determine +the type ``uint32``. In these cases, the following mechanism will be used to determine the type in which the operation is computed (this is important in case of overflow) and the type of the operator's result: @@ -18,7 +18,9 @@ and the type of the operator's result: In case one of the operands is a :ref:`literal number ` it is first converted to its "mobile type", which is the smallest type that can hold the value (unsigned types of the same bit-width are considered "smaller" than the signed types). -If both are literal numbers, the operation is computed with arbitrary precision. +If both are literal numbers, the operation is computed with effectively unlimited precision in +that the expression is evaluated to whatever precision is necessary so that none is lost +when the result is used with a non-literal type. The operator's result type is the same as the type the operation is performed in, except for comparison operators where the result is always ``bool``. @@ -108,3 +110,11 @@ value it referred to previously. assert(y.length == 0); } } + +.. index:: ! operator; precedence +.. _order: + +Order of Precedence of Operators +-------------------------------- + +.. include:: types/operator-precedence-table.rst diff --git a/docs/types/reference-types.rst b/docs/types/reference-types.rst index 5903ac3be..a6b5728c9 100644 --- a/docs/types/reference-types.rst +++ b/docs/types/reference-types.rst @@ -85,8 +85,10 @@ Data locations are not only relevant for persistency of data, but also for the s // The following does not work; it would need to create a new temporary / // unnamed array in storage, but storage is "statically" allocated: // y = memoryArray; - // This does not work either, since it would "reset" the pointer, but there - // is no sensible location it could point to. + // Similarly, "delete y" is not valid, as assignments to local variables + // referencing storage objects can only be made from existing storage objects. + // It would "reset" the pointer, but there is no sensible location it could point to. + // For more details see the documentation of the "delete" operator. // delete y; g(x); // calls g, handing over a reference to x h(x); // calls h and creates an independent, temporary copy in memory @@ -379,8 +381,10 @@ Array Members uint[2**20] aLotOfIntegers; // Note that the following is not a pair of dynamic arrays but a // dynamic array of pairs (i.e. of fixed size arrays of length two). - // Because of that, T[] is always a dynamic array of T, even if T - // itself is an array. + // In Solidity, T[k] and T[] are always arrays with elements of type T, + // even if T itself is an array. + // Because of that, bool[2][] is a dynamic array of elements + // that are bool[2]. This is different from other languages, like C. // Data location for all state variables is storage. bool[2][] pairsOfFlags; @@ -468,6 +472,120 @@ Array Members } } +.. index:: ! array;dangling storage references + +Dangling References to Storage Array Elements +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When working with storage arrays, you need to take care to avoid dangling references. +A dangling reference is a reference that points to something that no longer exists or has been +moved without updating the reference. A dangling reference can for example occur, if you store a +reference to an array element in a local variable and then ``.pop()`` from the containing array: + +.. code-block:: solidity + + // SPDX-License-Identifier: GPL-3.0 + pragma solidity >=0.8.0 <0.9.0; + + contract C { + uint[][] s; + + function f() public { + // Stores a pointer to the last array element of s. + uint[] storage ptr = s[s.length - 1]; + // Removes the last array element of s. + s.pop(); + // Writes to the array element that is no longer within the array. + ptr.push(0x42); + // Adding a new element to ``s`` now will not add an empty array, but + // will result in an array of length 1 with ``0x42`` as element. + s.push(); + assert(s[s.length - 1][0] == 0x42); + } + } + +The write in ``ptr.push(0x42)`` will **not** revert, despite the fact that ``ptr`` no +longer refers to a valid element of ``s``. Since the compiler assumes that unused storage +is always zeroed, a subsequent ``s.push()`` will not explicitly write zeroes to storage, +so the last element of ``s`` after that ``push()`` will have length ``1`` and contain +``0x42`` as its first element. + +Note that Solidity does not allow to declare references to value types in storage. These kinds +of explicit dangling references are restricted to nested reference types. However, dangling references +can also occur temporarily when using complex expressions in tuple assignments: + +.. code-block:: solidity + + // SPDX-License-Identifier: GPL-3.0 + pragma solidity >=0.8.0 <0.9.0; + + contract C { + uint[] s; + uint[] t; + constructor() { + // Push some initial values to the storage arrays. + s.push(0x07); + t.push(0x03); + } + + function g() internal returns (uint[] storage) { + s.pop(); + return t; + } + + function f() public returns (uint[] memory) { + // The following will first evaluate ``s.push()`` to a reference to a new element + // at index 1. Afterwards, the call to ``g`` pops this new element, resulting in + // the left-most tuple element to become a dangling reference. The assignment still + // takes place and will write outside the data area of ``s``. + (s.push(), g()[0]) = (0x42, 0x17); + // A subsequent push to ``s`` will reveal the value written by the previous + // statement, i.e. the last element of ``s`` at the end of this function will have + // the value ``0x42``. + s.push(); + return s; + } + } + +It is always safer to only assign to storage once per statement and to avoid +complex expressions on the left-hand-side of an assignment. + +You need to take particular care when dealing with references to elements of +``bytes`` arrays, since a ``.push()`` on a bytes array may switch :ref:`from short +to long layout in storage`. + +.. code-block:: solidity + + // SPDX-License-Identifier: GPL-3.0 + pragma solidity >=0.8.0 <0.9.0; + + // This will report a warning + contract C { + bytes x = "012345678901234567890123456789"; + + function test() external returns(uint) { + (x.push(), x.push()) = (0x01, 0x02); + return x.length; + } + } + +Here, when the first ``x.push()`` is evaluated, ``x`` is still stored in short +layout, thereby ``x.push()`` returns a reference to an element in the first storage slot of +``x``. However, the second ``x.push()`` switches the bytes array to large layout. +Now the element that ``x.push()`` referred to is in the data area of the array while +the reference still points at its original location, which is now a part of the length field +and the assignment will effectively garble the length of ``x``. +To be safe, only enlarge bytes arrays by at most one element during a single +assignment and do not simultaneously index-access the array in the same statement. + +While the above describes the behaviour of dangling storage references in the +current version of the compiler, any code with dangling references should be +considered to have *undefined behaviour*. In particular, this means that +any future version of the compiler may change the behaviour of code that +involves dangling references. + +Be sure to avoid dangling references in your code! + .. index:: ! array;slice .. _array-slices: diff --git a/docs/types/value-types.rst b/docs/types/value-types.rst index cc3f17dd3..5972ea818 100644 --- a/docs/types/value-types.rst +++ b/docs/types/value-types.rst @@ -210,6 +210,11 @@ an exception to this rule. declare its type as ``address payable`` to make this requirement visible. Also, try to make this distinction or conversion as early as possible. + The distinction between ``address`` and ``address payable`` was introduced with version 0.5.0. + Also starting from that version, contracts are not implicitly convertible to the ``address`` type, but can still be explicitly converted to + ``address`` or to ``address payable``, if they have a receive or payable fallback function. + + Operators: * ``<=``, ``<``, ``==``, ``!=``, ``>=`` and ``>`` @@ -223,9 +228,7 @@ Operators: or you can use ``address(uint160(uint256(b)))``, which results in ``0x777788889999AaAAbBbbCcccddDdeeeEfFFfCcCc``. .. note:: - The distinction between ``address`` and ``address payable`` was introduced with version 0.5.0. - Also starting from that version, contracts do not derive from the address type, but can still be explicitly converted to - ``address`` or to ``address payable``, if they have a receive or payable fallback function. + Mixed-case hexadecimal numbers conforming to `EIP-55 `_ are automatically treated as literals of the ``address`` type. See :ref:`Address Literals`. .. _members-of-addresses: @@ -448,8 +451,8 @@ Integer literals are formed from a sequence of digits in the range 0-9. They are interpreted as decimals. For example, ``69`` means sixty nine. Octal literals do not exist in Solidity and leading zeros are invalid. -Decimal fractional literals are formed by a ``.`` with at least one number on -one side. Examples include ``1.``, ``.1`` and ``1.3``. +Decimal fractional literals are formed by a ``.`` with at least one number after the decimal point. +Examples include ``.1`` and ``1.3`` (but not ``1.``). Scientific notation in the form of ``2e10`` is also supported, where the mantissa can be fractional but the exponent has to be an integer. diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst index 7d172eb07..b19396299 100644 --- a/docs/units-and-global-variables.rst +++ b/docs/units-and-global-variables.rst @@ -384,3 +384,14 @@ The following properties are available for an integer type ``T``: ``type(T).max`` The largest value representable by type ``T``. + +Reserved Keywords +================= + +These keywords are reserved in Solidity. They might become part of the syntax in the future: + +``after``, ``alias``, ``apply``, ``auto``, ``byte``, ``case``, ``copyof``, ``default``, +``define``, ``final``, ``implements``, ``in``, ``inline``, ``let``, ``macro``, ``match``, +``mutable``, ``null``, ``of``, ``partial``, ``promise``, ``reference``, ``relocatable``, +``sealed``, ``sizeof``, ``static``, ``supports``, ``switch``, ``typedef``, ``typeof``, +``var``. \ No newline at end of file diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index ffe1aa624..8db3522a4 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -613,8 +613,9 @@ Error Types 10. ``Exception``: Unknown failure during compilation - this should be reported as an issue. 11. ``CompilerError``: Invalid use of the compiler stack - this should be reported as an issue. 12. ``FatalError``: Fatal error not processed correctly - this should be reported as an issue. -13. ``Warning``: A warning, which didn't stop the compilation, but should be addressed if possible. -14. ``Info``: Information that the compiler thinks the user might find useful, but is not dangerous and does not necessarily need to be addressed. +13. ``YulException``: Error during Yul Code generation - this should be reported as an issue. +14. ``Warning``: A warning, which didn't stop the compilation, but should be addressed if possible. +15. ``Info``: Information that the compiler thinks the user might find useful, but is not dangerous and does not necessarily need to be addressed. .. _compiler-tools: diff --git a/docs/yul.rst b/docs/yul.rst index 8a584db1d..7ce010169 100644 --- a/docs/yul.rst +++ b/docs/yul.rst @@ -663,10 +663,10 @@ We will use a destructuring notation for the AST nodes. E(G, L, : Assignment) = let G1, L1, v1, ..., vn = E(G, L, rhs) let L2 be a copy of L1 where L2[$var_i] = vi for i = 1, ..., n - G, L2, regular + G1, L2, regular E(G, L, : ForLoop) = if n >= 1: - let G1, L, mode = E(G, L, i1, ..., in) + let G1, L1, mode = E(G, L, i1, ..., in) // mode has to be regular or leave due to the syntactic restrictions if mode is leave then G1, L1 restricted to variables of L, leave @@ -686,7 +686,7 @@ We will use a destructuring notation for the AST nodes. else: G3, L3, mode = E(G2, L2, post) if mode is leave: - G2, L3, leave + G3, L3, leave otherwise E(G3, L3, for {} condition post body) E(G, L, break: BreakContinue) = @@ -1162,6 +1162,7 @@ An example Yul Object is shown below: code { function allocate(size) -> ptr { ptr := mload(0x40) + // Note that Solidity generated IR code reserves memory offset ``0x60`` as well, but a pure Yul object is free to use memory as it chooses. if iszero(ptr) { ptr := 0x60 } mstore(0x40, add(ptr, size)) } @@ -1191,6 +1192,7 @@ An example Yul Object is shown below: code { function allocate(size) -> ptr { ptr := mload(0x40) + // Note that Solidity generated IR code reserves memory offset ``0x60`` as well, but a pure Yul object is free to use memory as it chooses. if iszero(ptr) { ptr := 0x60 } mstore(0x40, add(ptr, size)) } @@ -1238,6 +1240,8 @@ and optionally specify the :ref:`expected number of contract executions = 0, AssemblyException, "Stack underflow."); m_deposit += static_cast(_i.deposit()); - m_items.emplace_back(move(_i)); + m_items.emplace_back(std::move(_i)); if (!m_items.back().location().isValid() && m_currentSourceLocation.isValid()) m_items.back().setLocation(m_currentSourceLocation); m_items.back().m_modifierDepth = m_currentModifierDepth; @@ -254,7 +254,7 @@ Json::Value Assembly::assemblyJSON(map const& _sourceIndices, if (!data.empty()) jsonItem["value"] = data; jsonItem["source"] = sourceIndex; - code.append(move(jsonItem)); + code.append(std::move(jsonItem)); if (item.type() == AssemblyItemType::Tag) { @@ -265,7 +265,7 @@ Json::Value Assembly::assemblyJSON(map const& _sourceIndices, jumpdest["source"] = sourceIndex; if (item.m_modifierDepth != 0) jumpdest["modifierDepth"] = static_cast(item.m_modifierDepth); - code.append(move(jumpdest)); + code.append(std::move(jumpdest)); } } if (_includeSourceList) @@ -464,7 +464,7 @@ map const& Assembly::optimiseInternal( } if (optimisedItems.size() < m_items.size()) { - m_items = move(optimisedItems); + m_items = std::move(optimisedItems); count++; } } @@ -478,7 +478,7 @@ map const& Assembly::optimiseInternal( *this ); - m_tagReplacements = move(tagReplacements); + m_tagReplacements = std::move(tagReplacements); return *m_tagReplacements; } diff --git a/libevmasm/CommonSubexpressionEliminator.cpp b/libevmasm/CommonSubexpressionEliminator.cpp index 397d20f16..19b275cb6 100644 --- a/libevmasm/CommonSubexpressionEliminator.cpp +++ b/libevmasm/CommonSubexpressionEliminator.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -47,8 +48,8 @@ vector CommonSubexpressionEliminator::getOptimizedItems() { m_breakingItem = nullptr; m_storeOperations.clear(); - m_initialState = move(nextInitialState); - m_state = move(nextState); + m_initialState = std::move(nextInitialState); + m_state = std::move(nextState); }); map initialStackContents; @@ -163,7 +164,7 @@ AssemblyItems CSECodeGenerator::generateCode( // Invalid sequenced operation. // @todo quick fix for now. Proper fix needs to choose representative with higher // sequence number during dependency analysis. - assertThrow(seqNr >= _initialSequenceNumber, StackTooDeepException, ""); + assertThrow(seqNr >= _initialSequenceNumber, StackTooDeepException, util::stackTooDeepString); sequencedExpressions.insert(make_pair(seqNr, id)); } @@ -471,7 +472,7 @@ void CSECodeGenerator::appendDup(int _fromPosition, SourceLocation const& _locat { assertThrow(_fromPosition != c_invalidPosition, OptimizerException, ""); int instructionNum = 1 + m_stackHeight - _fromPosition; - assertThrow(instructionNum <= 16, StackTooDeepException, "Stack too deep, try removing local variables."); + assertThrow(instructionNum <= 16, StackTooDeepException, util::stackTooDeepString); assertThrow(1 <= instructionNum, OptimizerException, "Invalid stack access."); appendItem(AssemblyItem(dupInstruction(static_cast(instructionNum)), _location)); m_stack[m_stackHeight] = m_stack[_fromPosition]; @@ -484,7 +485,7 @@ void CSECodeGenerator::appendOrRemoveSwap(int _fromPosition, SourceLocation cons if (_fromPosition == m_stackHeight) return; int instructionNum = m_stackHeight - _fromPosition; - assertThrow(instructionNum <= 16, StackTooDeepException, "Stack too deep, try removing local variables."); + assertThrow(instructionNum <= 16, StackTooDeepException, util::stackTooDeepString); assertThrow(1 <= instructionNum, OptimizerException, "Invalid stack access."); appendItem(AssemblyItem(swapInstruction(static_cast(instructionNum)), _location)); diff --git a/libevmasm/CommonSubexpressionEliminator.h b/libevmasm/CommonSubexpressionEliminator.h index 51a5d74b2..b0810a9a1 100644 --- a/libevmasm/CommonSubexpressionEliminator.h +++ b/libevmasm/CommonSubexpressionEliminator.h @@ -179,9 +179,15 @@ AssemblyItemIterator CommonSubexpressionEliminator::feedItems( ) { assertThrow(!m_breakingItem, OptimizerException, "Invalid use of CommonSubexpressionEliminator."); - for (; _iterator != _end && !SemanticInformation::breaksCSEAnalysisBlock(*_iterator, _msizeImportant); ++_iterator) + unsigned const maxChunkSize = 2000; + unsigned chunkSize = 0; + for ( + ; + _iterator != _end && !SemanticInformation::breaksCSEAnalysisBlock(*_iterator, _msizeImportant) && chunkSize < maxChunkSize; + ++_iterator, ++chunkSize + ) feedItem(*_iterator); - if (_iterator != _end) + if (_iterator != _end && chunkSize < maxChunkSize) m_breakingItem = &(*_iterator++); return _iterator; } diff --git a/libevmasm/ConstantOptimiser.cpp b/libevmasm/ConstantOptimiser.cpp index a639bc6fc..37ac4c18b 100644 --- a/libevmasm/ConstantOptimiser.cpp +++ b/libevmasm/ConstantOptimiser.cpp @@ -244,8 +244,8 @@ AssemblyItems ComputeMethod::findRepresentation(u256 const& _value) bigint newGas = gasNeeded(newRoutine); if (newGas < bestGas) { - bestGas = move(newGas); - routine = move(newRoutine); + bestGas = std::move(newGas); + routine = std::move(newRoutine); } } return routine; diff --git a/libevmasm/ControlFlowGraph.cpp b/libevmasm/ControlFlowGraph.cpp index d6d8adf4a..cb648f90f 100644 --- a/libevmasm/ControlFlowGraph.cpp +++ b/libevmasm/ControlFlowGraph.cpp @@ -236,12 +236,12 @@ void ControlFlowGraph::gatherKnowledge() item.state = _state->copy(); item.blocksSeen = _currentItem.blocksSeen; item.blocksSeen.insert(_currentItem.blockId); - workQueue.push_back(move(item)); + workQueue.push_back(std::move(item)); }; while (!workQueue.empty()) { - WorkQueueItem item = move(workQueue.back()); + WorkQueueItem item = std::move(workQueue.back()); workQueue.pop_back(); //@todo we might have to do something like incrementing the sequence number for each JUMPDEST assertThrow(!!item.blockId, OptimizerException, ""); diff --git a/libevmasm/ExpressionClasses.cpp b/libevmasm/ExpressionClasses.cpp index c17ff9c29..8cd97b6a8 100644 --- a/libevmasm/ExpressionClasses.cpp +++ b/libevmasm/ExpressionClasses.cpp @@ -23,38 +23,59 @@ */ #include + #include #include #include +#include + #include -#include #include +#include using namespace std; using namespace solidity; using namespace solidity::evmasm; using namespace solidity::langutil; -bool ExpressionClasses::Expression::operator<(ExpressionClasses::Expression const& _other) const +bool ExpressionClasses::Expression::operator==(ExpressionClasses::Expression const& _other) const { assertThrow(!!item && !!_other.item, OptimizerException, ""); auto type = item->type(); auto otherType = _other.item->type(); if (type != otherType) - return type < otherType; + return false; else if (type == Operation) { auto instr = item->instruction(); auto otherInstr = _other.item->instruction(); - return std::tie(instr, arguments, sequenceNumber) < + return std::tie(instr, arguments, sequenceNumber) == std::tie(otherInstr, _other.arguments, _other.sequenceNumber); } else - return std::tie(item->data(), arguments, sequenceNumber) < + return std::tie(item->data(), arguments, sequenceNumber) == std::tie(_other.item->data(), _other.arguments, _other.sequenceNumber); } +std::size_t ExpressionClasses::Expression::ExpressionHash::operator()(Expression const& _expression) const +{ + assertThrow(!!_expression.item, OptimizerException, ""); + std::size_t seed = 0; + auto type = _expression.item->type(); + boost::hash_combine(seed, type); + + if (type == Operation) + boost::hash_combine(seed, _expression.item->instruction()); + else + boost::hash_combine(seed, _expression.item->data()); + + boost::hash_range(seed, _expression.arguments.begin(), _expression.arguments.end()); + boost::hash_combine(seed, _expression.sequenceNumber); + + return seed; +} + ExpressionClasses::Id ExpressionClasses::find( AssemblyItem const& _item, Ids const& _arguments, diff --git a/libevmasm/ExpressionClasses.h b/libevmasm/ExpressionClasses.h index 7df907517..8d4159fc7 100644 --- a/libevmasm/ExpressionClasses.h +++ b/libevmasm/ExpressionClasses.h @@ -24,13 +24,13 @@ #pragma once -#include #include -#include -#include +#include + #include -#include +#include +#include namespace solidity::langutil { @@ -61,9 +61,15 @@ public: /// Storage modification sequence, only used for storage and memory operations. unsigned sequenceNumber = 0; /// Behaves as if this was a tuple of (item->type(), item->data(), arguments, sequenceNumber). - bool operator<(Expression const& _other) const; + bool operator==(Expression const& _other) const; + + struct ExpressionHash + { + std::size_t operator()(Expression const& _expression) const; + }; }; + /// Retrieves the id of the expression equivalence class resulting from the given item applied to the /// given classes, might also create a new one. /// @param _copyItem if true, copies the assembly item to an internal storage instead of just @@ -122,7 +128,7 @@ private: /// Expression equivalence class representatives - we only store one item of an equivalence. std::vector m_representatives; /// All expression ever encountered. - std::set m_expressions; + std::unordered_set m_expressions; std::vector> m_spareAssemblyItems; }; diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp index 3ad9ba084..d49ee9891 100644 --- a/libevmasm/GasMeter.cpp +++ b/libevmasm/GasMeter.cpp @@ -184,7 +184,7 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _ if (*value) { // Note: msb() counts from 0 and throws on 0 as input. - unsigned const significantByteCount = (boost::multiprecision::msb(*value) + 1 + 7) / 8; + unsigned const significantByteCount = (static_cast(boost::multiprecision::msb(*value)) + 1u + 7u) / 8u; gas += GasCosts::expByteGas(m_evmVersion) * significantByteCount; } } diff --git a/libevmasm/Inliner.cpp b/libevmasm/Inliner.cpp index 527e6ae38..d365e312a 100644 --- a/libevmasm/Inliner.cpp +++ b/libevmasm/Inliner.cpp @@ -257,7 +257,7 @@ void Inliner::optimise() if (auto exitItem = shouldInline(*tag, nextItem, *inlinableBlock)) { newItems += inlinableBlock->items | ranges::views::drop_last(1); - newItems.emplace_back(move(*exitItem)); + newItems.emplace_back(std::move(*exitItem)); // We are removing one push tag to the block we inline. --inlinableBlock->pushTagCount; @@ -277,5 +277,5 @@ void Inliner::optimise() newItems.emplace_back(item); } - m_items = move(newItems); + m_items = std::move(newItems); } diff --git a/libevmasm/KnownState.cpp b/libevmasm/KnownState.cpp index 841affab0..1e886f7ab 100644 --- a/libevmasm/KnownState.cpp +++ b/libevmasm/KnownState.cpp @@ -252,7 +252,7 @@ void KnownState::reduceToCommonKnowledge(KnownState const& _other, bool _combine map shiftedStack; for (auto const& stackElement: m_stackElements) shiftedStack[stackElement.first - stackDiff] = stackElement.second; - m_stackElements = move(shiftedStack); + m_stackElements = std::move(shiftedStack); m_stackHeight = _other.m_stackHeight; } @@ -333,7 +333,7 @@ KnownState::StoreOperation KnownState::storeInStorage( for (auto const& storageItem: m_storageContent) if (m_expressionClasses->knownToBeDifferent(storageItem.first, _slot) || storageItem.second == _value) storageContents.insert(storageItem); - m_storageContent = move(storageContents); + m_storageContent = std::move(storageContents); AssemblyItem item(Instruction::SSTORE, _location); Id id = m_expressionClasses->find(item, {_slot, _value}, true, m_sequenceNumber); @@ -365,7 +365,7 @@ KnownState::StoreOperation KnownState::storeInMemory(Id _slot, Id _value, Source for (auto const& memoryItem: m_memoryContent) if (m_expressionClasses->knownToBeDifferentBy32(memoryItem.first, _slot)) memoryContents.insert(memoryItem); - m_memoryContent = move(memoryContents); + m_memoryContent = std::move(memoryContents); AssemblyItem item(Instruction::MSTORE, _location); Id id = m_expressionClasses->find(item, {_slot, _value}, true, m_sequenceNumber); diff --git a/libevmasm/KnownState.h b/libevmasm/KnownState.h index 723170610..8c28fbb62 100644 --- a/libevmasm/KnownState.h +++ b/libevmasm/KnownState.h @@ -132,7 +132,7 @@ public: /// @returns true if the knowledge about the state of both objects is (known to be) equal. bool operator==(KnownState const& _other) const; - /// Retrieves the current equivalence class fo the given stack element (or generates a new + /// Retrieves the current equivalence class for the given stack element (or generates a new /// one if it does not exist yet). Id stackElement(int _stackHeight, langutil::SourceLocation const& _location); /// @returns the stackElement relative to the current stack height. diff --git a/libevmasm/PathGasMeter.cpp b/libevmasm/PathGasMeter.cpp index b7c985f1b..c165985cf 100644 --- a/libevmasm/PathGasMeter.cpp +++ b/libevmasm/PathGasMeter.cpp @@ -44,7 +44,7 @@ GasMeter::GasConsumption PathGasMeter::estimateMax( auto path = make_unique(); path->index = _startIndex; path->state = _state->copy(); - queue(move(path)); + queue(std::move(path)); GasMeter::GasConsumption gas; while (!m_queue.empty() && !gas.isInfinite) @@ -60,14 +60,14 @@ void PathGasMeter::queue(std::unique_ptr&& _newPath) ) return; m_highestGasUsagePerJumpdest[_newPath->index] = _newPath->gas; - m_queue[_newPath->index] = move(_newPath); + m_queue[_newPath->index] = std::move(_newPath); } GasMeter::GasConsumption PathGasMeter::handleQueueItem() { assertThrow(!m_queue.empty(), OptimizerException, ""); - unique_ptr path = move(m_queue.rbegin()->second); + unique_ptr path = std::move(m_queue.rbegin()->second); m_queue.erase(--m_queue.end()); shared_ptr state = path->state; @@ -129,7 +129,7 @@ GasMeter::GasConsumption PathGasMeter::handleQueueItem() newPath->largestMemoryAccess = meter.largestMemoryAccess(); newPath->state = state->copy(); newPath->visitedJumpdests = path->visitedJumpdests; - queue(move(newPath)); + queue(std::move(newPath)); } if (branchStops) diff --git a/libevmasm/RuleList.h b/libevmasm/RuleList.h index ec0970e65..9b20d0f8b 100644 --- a/libevmasm/RuleList.h +++ b/libevmasm/RuleList.h @@ -275,11 +275,12 @@ std::vector> simplificationRuleListPart4_5( template std::vector> simplificationRuleListPart5( + bool _forYulOptimizer, Pattern A, Pattern B, Pattern, Pattern X, - Pattern + Pattern Y ) { using Word = typename Pattern::Word; @@ -287,6 +288,28 @@ std::vector> simplificationRuleListPart5( std::vector> rules; + // The libevmasm optimizer does not support rules resulting in opcodes with more than two arguments. + if (_forYulOptimizer) + { + // Replace MOD(MUL(X, Y), A) with MULMOD(X, Y, A) iff A=2**N + rules.push_back({ + Builtins::MOD(Builtins::MUL(X, Y), A), + [=]() -> Pattern { return Builtins::MULMOD(X, Y, A); }, + [=] { + return A.d() > 0 && ((A.d() & (A.d() - 1)) == 0); + } + }); + + // Replace MOD(ADD(X, Y), A) with ADDMOD(X, Y, A) iff A=2**N + rules.push_back({ + Builtins::MOD(Builtins::ADD(X, Y), A), + [=]() -> Pattern { return Builtins::ADDMOD(X, Y, A); }, + [=] { + return A.d() > 0 && ((A.d() & (A.d() - 1)) == 0); + } + }); + } + // Replace MOD X, with AND X, - 1 for (size_t i = 0; i < Pattern::WordSize; ++i) { @@ -798,7 +821,7 @@ std::vector> simplificationRuleList( rules += simplificationRuleListPart3(A, B, C, W, X); rules += simplificationRuleListPart4(A, B, C, W, X); rules += simplificationRuleListPart4_5(A, B, C, W, X); - rules += simplificationRuleListPart5(A, B, C, W, X); + rules += simplificationRuleListPart5(_evmVersion.has_value(), A, B, C, W, X); rules += simplificationRuleListPart6(A, B, C, W, X); rules += simplificationRuleListPart7(A, B, C, W, X); rules += simplificationRuleListPart8(A, B, C, W, X); diff --git a/liblangutil/CharStream.h b/liblangutil/CharStream.h index 08f86129b..59ddf22d9 100644 --- a/liblangutil/CharStream.h +++ b/liblangutil/CharStream.h @@ -73,9 +73,15 @@ public: CharStream() = default; CharStream(std::string _source, std::string _name): m_source(std::move(_source)), m_name(std::move(_name)) {} + CharStream(std::string _source, std::string _name, bool _importedFromAST): + m_source(std::move(_source)), + m_name(std::move(_name)), + m_importedFromAST(_importedFromAST) + { } size_t position() const { return m_position; } bool isPastEndOfInput(size_t _charsForward = 0) const { return (m_position + _charsForward) >= m_source.size(); } + bool isImportedFromAST() const { return m_importedFromAST; } char get(size_t _charsForward = 0) const { return m_source[m_position + _charsForward]; } char advanceAndGet(size_t _chars = 1); @@ -138,6 +144,7 @@ public: private: std::string m_source; std::string m_name; + bool m_importedFromAST{false}; size_t m_position{0}; }; diff --git a/liblangutil/EVMVersion.h b/liblangutil/EVMVersion.h index bb6971ae3..c68441f01 100644 --- a/liblangutil/EVMVersion.h +++ b/liblangutil/EVMVersion.h @@ -34,7 +34,7 @@ namespace solidity::langutil /** * A version specifier of the EVM we want to compile to. - * Defaults to the latest version deployed on Ethereum mainnet at the time of compiler release. + * Defaults to the latest version deployed on Ethereum Mainnet at the time of compiler release. */ class EVMVersion: boost::less_than_comparable, diff --git a/liblangutil/Scanner.cpp b/liblangutil/Scanner.cpp index fede6d3f8..d769a9363 100644 --- a/liblangutil/Scanner.cpp +++ b/liblangutil/Scanner.cpp @@ -76,6 +76,7 @@ string to_string(ScannerError _errorCode) case ScannerError::IllegalHexDigit: return "Hexadecimal digit missing or invalid."; case ScannerError::IllegalCommentTerminator: return "Expected multi-line comment-terminator."; case ScannerError::IllegalEscapeSequence: return "Invalid escape sequence."; + case ScannerError::UnicodeCharacterInNonUnicodeString: return "Invalid character in string. If you are trying to use Unicode characters, use a unicode\"...\" string literal."; case ScannerError::IllegalCharacterInString: return "Invalid character in string."; case ScannerError::IllegalStringEndQuote: return "Expected string end-quote."; case ScannerError::IllegalNumberSeparator: return "Invalid use of number separator '_'."; @@ -424,7 +425,7 @@ Token Scanner::scanMultiLineDocComment() while (!isSourcePastEndOfInput()) { - //handle newlines in multline comments + // handle newlines in multiline comments if (atEndOfLine()) { skipWhitespace(); @@ -844,7 +845,11 @@ Token Scanner::scanString(bool const _isUnicode) // We are using a manual range and not isprint() to avoid // any potential complications with locale. if (!_isUnicode && (static_cast(c) <= 0x1f || static_cast(c) >= 0x7f)) - return setError(ScannerError::IllegalCharacterInString); + { + if (m_kind == ScannerKind::Yul) + return setError(ScannerError::IllegalCharacterInString); + return setError(ScannerError::UnicodeCharacterInNonUnicodeString); + } addLiteralChar(c); } } diff --git a/liblangutil/Scanner.h b/liblangutil/Scanner.h index e9957850c..c45a2ec24 100644 --- a/liblangutil/Scanner.h +++ b/liblangutil/Scanner.h @@ -81,6 +81,7 @@ enum class ScannerError IllegalHexDigit, IllegalCommentTerminator, IllegalEscapeSequence, + UnicodeCharacterInNonUnicodeString, IllegalCharacterInString, IllegalStringEndQuote, IllegalNumberSeparator, @@ -160,6 +161,8 @@ public: /// Called by the parser during FunctionDefinition parsing to clear the current comment void clearCurrentCommentLiteral() { m_skippedComments[Current].literal.clear(); } + ScannerKind scannerKind() const { return m_kind; } + ///@} ///@{ diff --git a/liblangutil/SourceReferenceFormatter.cpp b/liblangutil/SourceReferenceFormatter.cpp index 0edd551b8..a38c5e617 100644 --- a/liblangutil/SourceReferenceFormatter.cpp +++ b/liblangutil/SourceReferenceFormatter.cpp @@ -124,6 +124,9 @@ void SourceReferenceFormatter::printSourceLocation(SourceReference const& _ref) string_view text = _ref.text; + if (m_charStreamProvider.charStream(_ref.sourceName).isImportedFromAST()) + return; + if (!_ref.multiline) { size_t const locationLength = static_cast(_ref.endColumn - _ref.startColumn); diff --git a/libsmtutil/CHCSmtLib2Interface.cpp b/libsmtutil/CHCSmtLib2Interface.cpp index 630eb0619..c9b5f6053 100644 --- a/libsmtutil/CHCSmtLib2Interface.cpp +++ b/libsmtutil/CHCSmtLib2Interface.cpp @@ -44,7 +44,7 @@ CHCSmtLib2Interface::CHCSmtLib2Interface( ): CHCSolverInterface(_queryTimeout), m_smtlib2(make_unique(_queryResponses, _smtCallback, m_queryTimeout)), - m_queryResponses(move(_queryResponses)), + m_queryResponses(std::move(_queryResponses)), m_smtCallback(_smtCallback) { reset(); @@ -195,7 +195,7 @@ void CHCSmtLib2Interface::declareFunction(string const& _name, SortPointer const void CHCSmtLib2Interface::write(string _data) { - m_accumulatedOutput += move(_data) + "\n"; + m_accumulatedOutput += std::move(_data) + "\n"; } string CHCSmtLib2Interface::querySolver(string const& _input) diff --git a/libsmtutil/CVC4Interface.cpp b/libsmtutil/CVC4Interface.cpp index 8387b24cb..ff356c025 100644 --- a/libsmtutil/CVC4Interface.cpp +++ b/libsmtutil/CVC4Interface.cpp @@ -19,6 +19,7 @@ #include #include +#include #include @@ -277,7 +278,7 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr) return m_context.mkExpr(CVC4::kind::APPLY_CONSTRUCTOR, c, arguments); } - smtAssert(false, ""); + smtAssert(false); } catch (CVC4::TypeCheckingException const& _e) { @@ -288,7 +289,10 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr) smtAssert(false, _e.what()); } - smtAssert(false, ""); + smtAssert(false); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + util::unreachable(); } CVC4::Type CVC4Interface::cvc4Sort(Sort const& _sort) diff --git a/libsmtutil/SMTLib2Interface.cpp b/libsmtutil/SMTLib2Interface.cpp index bd74cf2c9..3e117913a 100644 --- a/libsmtutil/SMTLib2Interface.cpp +++ b/libsmtutil/SMTLib2Interface.cpp @@ -45,8 +45,8 @@ SMTLib2Interface::SMTLib2Interface( optional _queryTimeout ): SolverInterface(_queryTimeout), - m_queryResponses(move(_queryResponses)), - m_smtCallback(move(_smtCallback)) + m_queryResponses(std::move(_queryResponses)), + m_smtCallback(std::move(_smtCallback)) { reset(); } @@ -264,7 +264,7 @@ string SMTLib2Interface::toSmtLibSort(vector const& _sorts) void SMTLib2Interface::write(string _data) { smtAssert(!m_accumulatedOutput.empty(), ""); - m_accumulatedOutput.back() += move(_data) + "\n"; + m_accumulatedOutput.back() += std::move(_data) + "\n"; } string SMTLib2Interface::checkSatAndGetValuesCommand(vector const& _expressionsToEvaluate) diff --git a/libsmtutil/SMTPortfolio.cpp b/libsmtutil/SMTPortfolio.cpp index aec9b0a1c..77a404a47 100644 --- a/libsmtutil/SMTPortfolio.cpp +++ b/libsmtutil/SMTPortfolio.cpp @@ -41,7 +41,7 @@ SMTPortfolio::SMTPortfolio( SolverInterface(_queryTimeout) { if (_enabledSolvers.smtlib2) - m_solvers.emplace_back(make_unique(move(_smtlib2Responses), move(_smtCallback), m_queryTimeout)); + m_solvers.emplace_back(make_unique(std::move(_smtlib2Responses), std::move(_smtCallback), m_queryTimeout)); #ifdef HAVE_Z3 if (_enabledSolvers.z3 && Z3Interface::available()) m_solvers.emplace_back(make_unique(m_queryTimeout)); diff --git a/libsmtutil/Z3CHCInterface.cpp b/libsmtutil/Z3CHCInterface.cpp index 82dca4878..bfbc9841b 100644 --- a/libsmtutil/Z3CHCInterface.cpp +++ b/libsmtutil/Z3CHCInterface.cpp @@ -101,7 +101,7 @@ tuple Z3CHCInterface::que { result = CheckResult::UNSATISFIABLE; auto invariants = m_z3Interface->fromZ3Expr(m_solver.get_answer()); - return {result, move(invariants), {}}; + return {result, std::move(invariants), {}}; } case z3::check_result::unknown: { diff --git a/libsmtutil/Z3Interface.cpp b/libsmtutil/Z3Interface.cpp index a0d50d225..4abeffa16 100644 --- a/libsmtutil/Z3Interface.cpp +++ b/libsmtutil/Z3Interface.cpp @@ -20,6 +20,7 @@ #include #include +#include #ifdef HAVE_Z3_DLOPEN #include @@ -263,14 +264,17 @@ z3::expr Z3Interface::toZ3Expr(Expression const& _expr) return constructor(args); } - smtAssert(false, ""); + smtAssert(false); } catch (z3::exception const& _e) { smtAssert(false, _e.msg()); } - smtAssert(false, ""); + smtAssert(false); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + util::unreachable(); } Expression Z3Interface::fromZ3Expr(z3::expr const& _expr) @@ -378,7 +382,10 @@ Expression Z3Interface::fromZ3Expr(z3::expr const& _expr) ) return Expression(_expr.decl().name().str(), arguments, fromZ3Sort(_expr.get_sort())); - smtAssert(false, ""); + smtAssert(false); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + util::unreachable(); } z3::sort Z3Interface::z3Sort(Sort const& _sort) diff --git a/libsolc/libsolc.cpp b/libsolc/libsolc.cpp index 48cf7e0f8..4ceeeac6f 100644 --- a/libsolc/libsolc.cpp +++ b/libsolc/libsolc.cpp @@ -56,7 +56,7 @@ string takeOverAllocation(char const* _data) for (auto iter = begin(solidityAllocations); iter != end(solidityAllocations); ++iter) if (iter->data() == _data) { - string chunk = move(*iter); + string chunk = std::move(*iter); solidityAllocations.erase(iter); return chunk; } @@ -109,7 +109,7 @@ ReadCallback::Callback wrapReadCallback(CStyleReadFileCallback _readCallback, vo string compile(string _input, CStyleReadFileCallback _readCallback, void* _readContext) { StandardCompiler compiler(wrapReadCallback(_readCallback, _readContext)); - return compiler.compile(move(_input)); + return compiler.compile(std::move(_input)); } } diff --git a/libsolidity/CMakeLists.txt b/libsolidity/CMakeLists.txt index 26c14976e..68e58e1c9 100644 --- a/libsolidity/CMakeLists.txt +++ b/libsolidity/CMakeLists.txt @@ -53,8 +53,8 @@ set(sources ast/ASTAnnotations.h ast/ASTEnums.h ast/ASTForward.h - ast/ASTJsonConverter.cpp - ast/ASTJsonConverter.h + ast/ASTJsonExporter.cpp + ast/ASTJsonExporter.h ast/ASTUtils.cpp ast/ASTUtils.h ast/ASTJsonImporter.cpp @@ -159,10 +159,14 @@ set(sources lsp/FileRepository.h lsp/GotoDefinition.cpp lsp/GotoDefinition.h + lsp/RenameSymbol.cpp + lsp/RenameSymbol.h lsp/HandlerBase.cpp lsp/HandlerBase.h lsp/LanguageServer.cpp lsp/LanguageServer.h + lsp/SemanticTokensBuilder.cpp + lsp/SemanticTokensBuilder.h lsp/Transport.cpp lsp/Transport.h lsp/Utils.cpp diff --git a/libsolidity/analysis/ConstantEvaluator.cpp b/libsolidity/analysis/ConstantEvaluator.cpp index 0fc6761f7..7fde36ec0 100644 --- a/libsolidity/analysis/ConstantEvaluator.cpp +++ b/libsolidity/analysis/ConstantEvaluator.cpp @@ -49,7 +49,7 @@ bool fitsPrecisionExp(bigint const& _base, bigint const& _exp) size_t const bitsMax = 4096; - unsigned mostSignificantBaseBit = boost::multiprecision::msb(_base); + size_t mostSignificantBaseBit = static_cast(boost::multiprecision::msb(_base)); if (mostSignificantBaseBit == 0) // _base == 1 return true; if (mostSignificantBaseBit > bitsMax) // _base >= 2 ^ 4096 diff --git a/libsolidity/analysis/ControlFlowBuilder.cpp b/libsolidity/analysis/ControlFlowBuilder.cpp index 7c568b18e..1d1e33f50 100644 --- a/libsolidity/analysis/ControlFlowBuilder.cpp +++ b/libsolidity/analysis/ControlFlowBuilder.cpp @@ -17,6 +17,7 @@ // SPDX-License-Identifier: GPL-3.0 #include +#include #include #include @@ -617,11 +618,7 @@ bool ControlFlowBuilder::visit(VariableDeclarationStatement const& _variableDecl solAssert(tupleExpression->components().size() > i, ""); expression = tupleExpression->components()[i].get(); } - while (auto tupleExpression = dynamic_cast(expression)) - if (tupleExpression->components().size() == 1) - expression = tupleExpression->components().front().get(); - else - break; + expression = resolveOuterUnaryTuples(expression); m_currentNode->variableOccurrences.emplace_back( *var, VariableOccurrence::Kind::Assignment, diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp index 7ca134c5d..b6cd3eef0 100644 --- a/libsolidity/analysis/DeclarationContainer.cpp +++ b/libsolidity/analysis/DeclarationContainer.cpp @@ -144,9 +144,7 @@ bool DeclarationContainer::registerDeclaration( vector DeclarationContainer::resolveName( ASTString const& _name, - bool _recursive, - bool _alsoInvisible, - bool _onlyVisibleAsUnqualifiedNames + ResolvingSettings _settings ) const { solAssert(!_name.empty(), "Attempt to resolve empty name."); @@ -154,22 +152,22 @@ vector DeclarationContainer::resolveName( if (m_declarations.count(_name)) { - if (_onlyVisibleAsUnqualifiedNames) + if (_settings.onlyVisibleAsUnqualifiedNames) result += m_declarations.at(_name) | ranges::views::filter(&Declaration::isVisibleAsUnqualifiedName) | ranges::to_vector; else result += m_declarations.at(_name); } - if (_alsoInvisible && m_invisibleDeclarations.count(_name)) + if (_settings.alsoInvisible && m_invisibleDeclarations.count(_name)) { - if (_onlyVisibleAsUnqualifiedNames) + if (_settings.onlyVisibleAsUnqualifiedNames) result += m_invisibleDeclarations.at(_name) | ranges::views::filter(&Declaration::isVisibleAsUnqualifiedName) | ranges::to_vector; else result += m_invisibleDeclarations.at(_name); } - if (result.empty() && _recursive && m_enclosingContainer) - result = m_enclosingContainer->resolveName(_name, true, _alsoInvisible, _onlyVisibleAsUnqualifiedNames); + if (result.empty() && _settings.recursive && m_enclosingContainer) + result = m_enclosingContainer->resolveName(_name, _settings); return result; } @@ -209,7 +207,10 @@ void DeclarationContainer::populateHomonyms(back_insert_iterator _it) for (auto [name, location]: m_homonymCandidates) { - vector const& declarations = m_enclosingContainer->resolveName(name, true, true); + ResolvingSettings settings; + settings.recursive = true; + settings.alsoInvisible = true; + vector const& declarations = m_enclosingContainer->resolveName(name, std::move(settings)); if (!declarations.empty()) _it = make_pair(location, declarations); } diff --git a/libsolidity/analysis/DeclarationContainer.h b/libsolidity/analysis/DeclarationContainer.h index 2dbed0098..279ee1806 100644 --- a/libsolidity/analysis/DeclarationContainer.h +++ b/libsolidity/analysis/DeclarationContainer.h @@ -27,9 +27,27 @@ #include #include +#include + namespace solidity::frontend { +/** + * Settings for how the function DeclarationContainer::resolveName operates. + */ +struct ResolvingSettings +{ + /// if true and there are no matching declarations in the current container, + /// recursively searches the enclosing containers as well. + bool recursive = false; + /// if true, include invisible declaration in the results. + bool alsoInvisible = false; + /// if true, do not include declarations which can never actually be referenced using their + /// name alone (without being qualified with the name of scope in which they are declared). + bool onlyVisibleAsUnqualifiedNames = false; +}; + + /** * Container that stores mappings between names and declarations. It also contains a link to the * enclosing scope. @@ -58,18 +76,8 @@ public: /// Finds all declarations that in the current scope can be referred to using specified name. /// @param _name the name to look for. - /// @param _recursive if true and there are no matching declarations in the current container, - /// recursively searches the enclosing containers as well. - /// @param _alsoInvisible if true, include invisible declaration in the results. - /// @param _onlyVisibleAsUnqualifiedNames if true, do not include declarations which can never - /// actually be referenced using their name alone (without being qualified with the name - /// of scope in which they are declared). - std::vector resolveName( - ASTString const& _name, - bool _recursive = false, - bool _alsoInvisible = false, - bool _onlyVisibleAsUnqualifiedNames = false - ) const; + /// @param _settings see ResolvingSettings + std::vector resolveName(ASTString const& _name, ResolvingSettings _settings = ResolvingSettings{}) const; ASTNode const* enclosingNode() const { return m_enclosingNode; } DeclarationContainer const* enclosingContainer() const { return m_enclosingContainer; } std::map> const& declarations() const { return m_declarations; } diff --git a/libsolidity/analysis/FunctionCallGraph.cpp b/libsolidity/analysis/FunctionCallGraph.cpp index 45da1b4f0..e941c99c5 100644 --- a/libsolidity/analysis/FunctionCallGraph.cpp +++ b/libsolidity/analysis/FunctionCallGraph.cpp @@ -61,7 +61,7 @@ CallGraph FunctionCallGraphBuilder::buildCreationGraph(ContractDefinition const& builder.m_currentNode = CallGraph::SpecialNode::Entry; builder.processQueue(); - return move(builder.m_graph); + return std::move(builder.m_graph); } CallGraph FunctionCallGraphBuilder::buildDeployedGraph( @@ -109,7 +109,7 @@ CallGraph FunctionCallGraphBuilder::buildDeployedGraph( builder.m_currentNode = CallGraph::SpecialNode::Entry; builder.processQueue(); - return move(builder.m_graph); + return std::move(builder.m_graph); } bool FunctionCallGraphBuilder::visit(FunctionCall const& _functionCall) diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index 968aa744c..1b58d3c9a 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -83,7 +83,7 @@ bool NameAndTypeResolver::performImports(SourceUnit& _sourceUnit, mapsymbolAliases().empty()) for (auto const& alias: imp->symbolAliases()) { - auto declarations = scope->second->resolveName(alias.symbol->name(), false); + auto declarations = scope->second->resolveName(alias.symbol->name()); if (declarations.empty()) { m_errorReporter.declarationError( @@ -176,34 +176,52 @@ vector NameAndTypeResolver::resolveName(ASTString const& _na auto iterator = m_scopes.find(_scope); if (iterator == end(m_scopes)) return vector({}); - return iterator->second->resolveName(_name, false); + return iterator->second->resolveName(_name); } vector NameAndTypeResolver::nameFromCurrentScope(ASTString const& _name, bool _includeInvisibles) const { - return m_currentScope->resolveName(_name, true, _includeInvisibles); + ResolvingSettings settings; + settings.recursive = true; + settings.alsoInvisible = _includeInvisibles; + return m_currentScope->resolveName(_name, std::move(settings)); } Declaration const* NameAndTypeResolver::pathFromCurrentScope(vector const& _path) const +{ + if (auto declarations = pathFromCurrentScopeWithAllDeclarations(_path); !declarations.empty()) + return declarations.back(); + + return nullptr; +} + +std::vector NameAndTypeResolver::pathFromCurrentScopeWithAllDeclarations(std::vector const& _path) const { solAssert(!_path.empty(), ""); - vector candidates = m_currentScope->resolveName( - _path.front(), - /* _recursive */ true, - /* _alsoInvisible */ false, - /* _onlyVisibleAsUnqualifiedNames */ true - ); + vector pathDeclarations; + + ResolvingSettings settings; + settings.recursive = true; + settings.alsoInvisible = false; + settings.onlyVisibleAsUnqualifiedNames = true; + vector candidates = m_currentScope->resolveName(_path.front(), std::move(settings)); for (size_t i = 1; i < _path.size() && candidates.size() == 1; i++) { if (!m_scopes.count(candidates.front())) - return nullptr; - candidates = m_scopes.at(candidates.front())->resolveName(_path[i], false); + return {}; + + pathDeclarations.push_back(candidates.front()); + + candidates = m_scopes.at(candidates.front())->resolveName(_path[i]); } if (candidates.size() == 1) - return candidates.front(); + { + pathDeclarations.push_back(candidates.front()); + return pathDeclarations; + } else - return nullptr; + return {}; } void NameAndTypeResolver::warnHomonymDeclarations() const diff --git a/libsolidity/analysis/NameAndTypeResolver.h b/libsolidity/analysis/NameAndTypeResolver.h index 36a22ed2e..2bf238a00 100644 --- a/libsolidity/analysis/NameAndTypeResolver.h +++ b/libsolidity/analysis/NameAndTypeResolver.h @@ -93,6 +93,10 @@ public: /// Should only be called during the initial resolving phase. /// @note Returns a null pointer if any component in the path was not unique or not found. Declaration const* pathFromCurrentScope(std::vector const& _path) const; + /// Resolves a path starting from the "current" scope, but also searches parent scopes. + /// Should only be called during the initial resolving phase. + /// @note Returns an empty vector if any component in the path was non-unique or not found. Otherwise, all declarations along the path are returned. + std::vector pathFromCurrentScopeWithAllDeclarations(std::vector const& _path) const; /// Generate and store warnings about declarations with the same name. void warnHomonymDeclarations() const; diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index 50c9cbd4f..5bab71e6e 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -173,14 +173,15 @@ void ReferencesResolver::endVisit(ModifierDefinition const&) void ReferencesResolver::endVisit(IdentifierPath const& _path) { - Declaration const* declaration = m_resolver.pathFromCurrentScope(_path.path()); - if (!declaration) + std::vector declarations = m_resolver.pathFromCurrentScopeWithAllDeclarations(_path.path()); + if (declarations.empty()) { m_errorReporter.fatalDeclarationError(7920_error, _path.location(), "Identifier not found or not unique."); return; } - _path.annotation().referencedDeclaration = declaration; + _path.annotation().referencedDeclaration = declarations.back(); + _path.annotation().pathDeclarations = std::move(declarations); } bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly) @@ -275,7 +276,7 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier) return; } - m_yulAnnotation->externalReferences[&_identifier].suffix = move(suffix); + m_yulAnnotation->externalReferences[&_identifier].suffix = std::move(suffix); m_yulAnnotation->externalReferences[&_identifier].declaration = declarations.front(); } diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index f0a13fbfa..e1dad5f0f 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -40,9 +40,10 @@ #include #include -#include -#include #include +#include +#include +#include #include #include @@ -105,26 +106,79 @@ bool TypeChecker::visit(ContractDefinition const& _contract) void TypeChecker::checkDoubleStorageAssignment(Assignment const& _assignment) { - TupleType const& lhs = dynamic_cast(*type(_assignment.leftHandSide())); - TupleType const& rhs = dynamic_cast(*type(_assignment.rightHandSide())); - - if (lhs.components().size() != rhs.components().size()) - { - solAssert(m_errorReporter.hasErrors(), ""); - return; - } - size_t storageToStorageCopies = 0; size_t toStorageCopies = 0; - for (size_t i = 0; i < lhs.components().size(); ++i) + size_t storageByteArrayPushes = 0; + size_t storageByteAccesses = 0; + auto count = [&](TupleExpression const& _lhs, TupleType const& _rhs, auto _recurse) -> void { + TupleType const& lhsType = dynamic_cast(*type(_lhs)); + TupleExpression const* lhsResolved = dynamic_cast(resolveOuterUnaryTuples(&_lhs)); + + if (lhsType.components().size() != _rhs.components().size() || lhsResolved->components().size() != _rhs.components().size()) + { + solAssert(m_errorReporter.hasErrors(), ""); + return; + } + + for (auto&& [index, componentType]: lhsType.components() | ranges::views::enumerate) + { + if (ReferenceType const* ref = dynamic_cast(componentType)) + { + if (ref && ref->dataStoredIn(DataLocation::Storage) && !ref->isPointer()) + { + toStorageCopies++; + if (_rhs.components()[index]->dataStoredIn(DataLocation::Storage)) + storageToStorageCopies++; + } + } + else if (FixedBytesType const* bytesType = dynamic_cast(componentType)) + { + if (bytesType && bytesType->numBytes() == 1) + { + if (FunctionCall const* lhsCall = dynamic_cast(resolveOuterUnaryTuples(lhsResolved->components().at(index).get()))) + { + FunctionType const& callType = dynamic_cast(*type(lhsCall->expression())); + if (callType.kind() == FunctionType::Kind::ArrayPush) + { + ArrayType const& arrayType = dynamic_cast(*callType.selfType()); + if (arrayType.isByteArray() && arrayType.dataStoredIn(DataLocation::Storage)) + { + ++storageByteAccesses; + ++storageByteArrayPushes; + } + } + } + else if (IndexAccess const* indexAccess = dynamic_cast(resolveOuterUnaryTuples(lhsResolved->components().at(index).get()))) + { + if (ArrayType const* arrayType = dynamic_cast(type(indexAccess->baseExpression()))) + if (arrayType->isByteArray() && arrayType->dataStoredIn(DataLocation::Storage)) + ++storageByteAccesses; + } + } + } + else if (TupleType const* tupleType = dynamic_cast(componentType)) + if (auto const* lhsNested = dynamic_cast(lhsResolved->components().at(index).get())) + if (auto const* rhsNestedType = dynamic_cast(_rhs.components().at(index))) + _recurse( + *lhsNested, + *rhsNestedType, + _recurse + ); + } + }; + + TupleExpression const* lhsTupleExpression = dynamic_cast(&_assignment.leftHandSide()); + if (!lhsTupleExpression) { - ReferenceType const* ref = dynamic_cast(lhs.components()[i]); - if (!ref || !ref->dataStoredIn(DataLocation::Storage) || ref->isPointer()) - continue; - toStorageCopies++; - if (rhs.components()[i]->dataStoredIn(DataLocation::Storage)) - storageToStorageCopies++; + solAssert(m_errorReporter.hasErrors()); + return; } + count( + *lhsTupleExpression, + dynamic_cast(*type(_assignment.rightHandSide())), + count + ); + if (storageToStorageCopies >= 1 && toStorageCopies >= 2) m_errorReporter.warning( 7238_error, @@ -134,6 +188,16 @@ void TypeChecker::checkDoubleStorageAssignment(Assignment const& _assignment) "is executed and thus may have unexpected effects. It is safer to perform the copies " "separately or assign to storage pointers first." ); + + if (storageByteArrayPushes >= 1 && storageByteAccesses >= 2) + m_errorReporter.warning( + 7239_error, + _assignment.location(), + "This assignment involves multiple accesses to a bytes array in storage while simultaneously enlarging it. " + "When a bytes array is enlarged, it may transition from short storage layout to long storage layout, " + "which invalidates all references to its elements. It is safer to only enlarge byte arrays in a single " + "operation, one element at a time." + ); } TypePointers TypeChecker::typeCheckABIDecodeAndRetrieveReturnType(FunctionCall const& _functionCall, bool _abiEncoderV2) @@ -158,7 +222,7 @@ TypePointers TypeChecker::typeCheckABIDecodeAndRetrieveReturnType(FunctionCall c arguments.front()->location(), "The first argument to \"abi.decode\" must be implicitly convertible to " "bytes memory or bytes calldata, but is of type " + - type(*arguments.front())->toString() + + type(*arguments.front())->humanReadableName() + "." ); @@ -202,7 +266,7 @@ TypePointers TypeChecker::typeCheckABIDecodeAndRetrieveReturnType(FunctionCall c m_errorReporter.typeError( 9611_error, typeArgument->location(), - "Decoding type " + actualType->toString(false) + " not supported." + "Decoding type " + actualType->humanReadableName() + " not supported." ); if (auto referenceType = dynamic_cast(actualType)) @@ -262,7 +326,7 @@ TypePointers TypeChecker::typeCheckMetaTypeFunctionAndRetrieveReturnType(Functio arguments.front()->location(), "Invalid type for argument in the function call. " "An enum type, contract type or an integer type is required, but " + - type(*arguments.front())->toString(true) + " provided." + type(*arguments.front())->humanReadableName() + " provided." ); return {TypeProvider::meta(dynamic_cast(*firstArgType).actualType())}; @@ -311,9 +375,9 @@ void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance) (*arguments)[i]->location(), "Invalid type for argument in constructor call. " "Invalid implicit conversion from " + - type(*(*arguments)[i])->toString() + + type(*(*arguments)[i])->humanReadableName() + " to " + - parameterTypes[i]->toString() + + parameterTypes[i]->humanReadableName() + " requested.", result.message() ); @@ -567,7 +631,7 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) m_errorReporter.fatalTypeError( 4061_error, _variable.location(), - "Type " + varType->toString(true) + " is only valid in storage because it contains a (nested) mapping." + "Type " + varType->humanReadableName() + " is only valid in storage because it contains a (nested) mapping." ); } else if (_variable.visibility() >= Visibility::Public) @@ -578,7 +642,7 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) vector unsupportedTypes; for (auto const& param: getter.parameterTypes() + getter.returnParameterTypes()) if (!typeSupportedByOldABIEncoder(*param, false /* isLibrary */)) - unsupportedTypes.emplace_back(param->toString()); + unsupportedTypes.emplace_back(param->humanReadableName()); if (!unsupportedTypes.empty()) m_errorReporter.typeError( 2763_error, @@ -720,9 +784,9 @@ void TypeChecker::visitManually( arguments[i]->location(), "Invalid type for argument in modifier invocation. " "Invalid implicit conversion from " + - type(*arguments[i])->toString() + + type(*arguments[i])->humanReadableName() + " to " + - type(*(*parameters)[i])->toString() + + type(*(*parameters)[i])->humanReadableName() + " requested.", result.message() ); @@ -1052,9 +1116,9 @@ void TypeChecker::endVisit(TryStatement const& _tryStatement) 6509_error, parameter->location(), "Invalid type, expected " + - returnType->toString(false) + + returnType->humanReadableName() + " but got " + - parameter->annotation().type->toString() + + parameter->annotation().type->humanReadableName() + "." ); } @@ -1195,9 +1259,9 @@ void TypeChecker::endVisit(Return const& _return) 5992_error, _return.expression()->location(), "Return argument type " + - type(*_return.expression())->toString() + + type(*_return.expression())->humanReadableName() + " is not implicitly convertible to expected type " + - TupleType(returnTypes).toString(false) + ".", + TupleType(returnTypes).humanReadableName() + ".", result.message() ); } @@ -1213,9 +1277,9 @@ void TypeChecker::endVisit(Return const& _return) 6359_error, _return.expression()->location(), "Return argument type " + - type(*_return.expression())->toString() + + type(*_return.expression())->humanReadableName() + " is not implicitly convertible to expected type (type of first return variable) " + - expected->toString() + ".", + expected->humanReadableName() + ".", result.message() ); } @@ -1319,9 +1383,9 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) if (!result) { auto errorMsg = "Type " + - valueComponentType->toString() + + valueComponentType->humanReadableName() + " is not implicitly convertible to expected type " + - var.annotation().type->toString(); + var.annotation().type->humanReadableName(); if ( valueComponentType->category() == Type::Category::RationalNumber && dynamic_cast(*valueComponentType).isFractional() && @@ -1340,7 +1404,7 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) _statement.location(), errorMsg + ". Try converting to type " + - valueComponentType->mobileType()->toString() + + valueComponentType->mobileType()->humanReadableName() + " or use an explicit conversion." ); } @@ -1423,9 +1487,9 @@ bool TypeChecker::visit(Conditional const& _conditional) 1080_error, _conditional.location(), "True expression's type " + - trueType->toString() + + trueType->humanReadableName() + " does not match false expression's type " + - falseType->toString() + + falseType->humanReadableName() + "." ); // even we can't find a common type, we have to set a type here, @@ -1535,9 +1599,10 @@ bool TypeChecker::visit(Assignment const& _assignment) "Operator " + string(TokenTraits::toString(_assignment.assignmentOperator())) + " not compatible with types " + - t->toString() + + t->humanReadableName() + " and " + - type(_assignment.rightHandSide())->toString() + type(_assignment.rightHandSide())->humanReadableName() + + "." ); } return false; @@ -1567,7 +1632,7 @@ bool TypeChecker::visit(TupleExpression const& _tuple) if (components.size() == 1) _tuple.annotation().type = type(*components[0]); else - _tuple.annotation().type = TypeProvider::tuple(move(types)); + _tuple.annotation().type = TypeProvider::tuple(std::move(types)); // If some of the components are not LValues, the error is reported above. _tuple.annotation().isLValue = true; _tuple.annotation().isPure = false; @@ -1628,7 +1693,7 @@ bool TypeChecker::visit(TupleExpression const& _tuple) m_errorReporter.fatalTypeError( 1545_error, _tuple.location(), - "Type " + inlineArrayType->toString(true) + " is only valid in storage." + "Type " + inlineArrayType->humanReadableName() + " is only valid in storage." ); _tuple.annotation().type = TypeProvider::array(DataLocation::Memory, inlineArrayType, types.size()); @@ -1638,7 +1703,7 @@ bool TypeChecker::visit(TupleExpression const& _tuple) if (components.size() == 1) _tuple.annotation().type = type(*components[0]); else - _tuple.annotation().type = TypeProvider::tuple(move(types)); + _tuple.annotation().type = TypeProvider::tuple(std::move(types)); } _tuple.annotation().isLValue = false; @@ -1660,9 +1725,7 @@ bool TypeChecker::visit(UnaryOperation const& _operation) TypeResult result = subExprType->unaryOperatorResult(op); if (!result) { - string description = "Unary operator " + string(TokenTraits::toString(op)) + " cannot be applied to type " + subExprType->toString(); - if (!result.message().empty()) - description += ". " + result.message(); + string description = "Unary operator " + string(TokenTraits::toString(op)) + " cannot be applied to type " + subExprType->humanReadableName() + "." + (!result.message().empty() ? " " + result.message() : ""); if (modifying) // Cannot just report the error, ignore the unary operator, and continue, // because the sub-expression was already processed with requireLValue() @@ -1694,10 +1757,10 @@ void TypeChecker::endVisit(BinaryOperation const& _operation) "Operator " + string(TokenTraits::toString(_operation.getOperator())) + " not compatible with types " + - leftType->toString() + + leftType->humanReadableName() + " and " + - rightType->toString() + - (!result.message().empty() ? ". " + result.message() : "") + rightType->humanReadableName() + "." + + (!result.message().empty() ? " " + result.message() : "") ); commonType = leftType; } @@ -1738,9 +1801,9 @@ void TypeChecker::endVisit(BinaryOperation const& _operation) "The result type of the " + operation + " operation is equal to the type of the first operand (" + - commonType->toString() + + commonType->humanReadableName() + ") ignoring the (larger) type of the second operand (" + - rightType->toString() + + rightType->humanReadableName() + ") which might be unexpected. Silence this warning by either converting " "the first or the second operand to the type of the other." ); @@ -1836,7 +1899,7 @@ Type const* TypeChecker::typeCheckTypeConversionAndRetrieveReturnType( _functionCall.location(), ssl, "Explicit type conversion not allowed from non-payable \"address\" to \"" + - resultType->toString() + + resultType->humanReadableName() + "\", which has a payable fallback function." ); } @@ -1850,9 +1913,9 @@ Type const* TypeChecker::typeCheckTypeConversionAndRetrieveReturnType( 5030_error, _functionCall.location(), "Explicit type conversion not allowed from \"" + - argType->toString() + + argType->humanReadableName() + "\" to \"" + - resultType->toString() + + resultType->humanReadableName() + "\". To obtain the address of the contract of the function, " + "you can use the .address member of the function." ); @@ -1861,9 +1924,9 @@ Type const* TypeChecker::typeCheckTypeConversionAndRetrieveReturnType( 9640_error, _functionCall.location(), "Explicit type conversion not allowed from \"" + - argType->toString() + + argType->humanReadableName() + "\" to \"" + - resultType->toString() + + resultType->humanReadableName() + "\".", result.message() ); @@ -2121,7 +2184,7 @@ void TypeChecker::typeCheckABIEncodeCallFunction(FunctionCall const& _functionCa 5511_error, arguments.front()->location(), "Expected first argument to be a function pointer, not \"" + - type(*arguments.front())->toString() + + type(*arguments.front())->humanReadableName() + "\"." ); return; @@ -2133,14 +2196,28 @@ void TypeChecker::typeCheckABIEncodeCallFunction(FunctionCall const& _functionCa ) { string msg = "Expected regular external function type, or external view on public function."; - if (externalFunctionType->kind() == FunctionType::Kind::Internal) - msg += " Provided internal function."; - else if (externalFunctionType->kind() == FunctionType::Kind::DelegateCall) - msg += " Cannot use library functions for abi.encodeCall."; - else if (externalFunctionType->kind() == FunctionType::Kind::Creation) - msg += " Provided creation function."; - else - msg += " Cannot use special function."; + + switch (externalFunctionType->kind()) + { + case FunctionType::Kind::Internal: + msg += " Provided internal function."; + break; + case FunctionType::Kind::DelegateCall: + msg += " Cannot use library functions for abi.encodeCall."; + break; + case FunctionType::Kind::Creation: + msg += " Provided creation function."; + break; + case FunctionType::Kind::Event: + msg += " Cannot use events for abi.encodeCall."; + break; + case FunctionType::Kind::Error: + msg += " Cannot use errors for abi.encodeCall."; + break; + default: + msg += " Cannot use special function."; + } + SecondarySourceLocation ssl{}; if (externalFunctionType->hasDeclaration()) @@ -2151,10 +2228,14 @@ void TypeChecker::typeCheckABIEncodeCallFunction(FunctionCall const& _functionCa externalFunctionType->declaration().scope() == m_currentContract ) msg += " Did you forget to prefix \"this.\"?"; - else if (util::contains( - m_currentContract->annotation().linearizedBaseContracts, - externalFunctionType->declaration().scope() - ) && externalFunctionType->declaration().scope() != m_currentContract) + else if ( + m_currentContract && + externalFunctionType->declaration().scope() != m_currentContract && + util::contains( + m_currentContract->annotation().linearizedBaseContracts, + externalFunctionType->declaration().scope() + ) + ) msg += " Functions from base contracts have to be external."; } @@ -2168,8 +2249,17 @@ void TypeChecker::typeCheckABIEncodeCallFunction(FunctionCall const& _functionCa auto const* tupleType = dynamic_cast(type(*arguments[1])); if (tupleType) { - auto const& argumentTuple = dynamic_cast(*arguments[1].get()); - callArguments = decltype(callArguments){argumentTuple.components().begin(), argumentTuple.components().end()}; + if (TupleExpression const* argumentTuple = dynamic_cast(arguments[1].get())) + callArguments = decltype(callArguments){argumentTuple->components().begin(), argumentTuple->components().end()}; + else + { + m_errorReporter.typeError( + 9062_error, + arguments[1]->location(), + "Expected an inline tuple, not an expression of a tuple type." + ); + return; + } } else callArguments.push_back(arguments[1]); @@ -2210,9 +2300,9 @@ void TypeChecker::typeCheckABIEncodeCallFunction(FunctionCall const& _functionCa "Cannot implicitly convert component at position " + to_string(i) + " from \"" + - argType.toString() + + argType.humanReadableName() + "\" to \"" + - externalFunctionType->parameterTypes()[i]->toString() + + externalFunctionType->parameterTypes()[i]->humanReadableName() + "\"" + (result.message().empty() ? "." : ": " + result.message()) ); @@ -2272,7 +2362,7 @@ void TypeChecker::typeCheckBytesConcatFunction( argument->location(), "Invalid type for argument in the bytes.concat function call. " "bytes or fixed bytes type is required, but " + - argumentType->toString(true) + " provided." + argumentType->humanReadableName() + " provided." ); } } @@ -2457,9 +2547,9 @@ void TypeChecker::typeCheckFunctionGeneralChecks( string msg = "Invalid type for argument in function call. " "Invalid implicit conversion from " + - type(*paramArgMap[i])->toString() + + type(*paramArgMap[i])->humanReadableName() + " to " + - parameterTypes[i]->toString() + + parameterTypes[i]->humanReadableName() + " requested."; if (!result.message().empty()) msg += " " + result.message(); @@ -2521,7 +2611,7 @@ void TypeChecker::typeCheckFunctionGeneralChecks( m_errorReporter.typeError( 2443_error, paramArgMap[i]->location(), - "The type of this parameter, " + parameterTypes[i]->toString(true) + ", " + "The type of this parameter, " + parameterTypes[i]->humanReadableName() + ", " "is only supported in ABI coder v2. " "Use \"pragma abicoder v2;\" to enable the feature." ); @@ -2535,7 +2625,7 @@ void TypeChecker::typeCheckFunctionGeneralChecks( m_errorReporter.typeError( 2428_error, _functionCall.location(), - "The type of return parameter " + toString(i + 1) + ", " + returnParameterTypes[i]->toString(true) + ", " + "The type of return parameter " + toString(i + 1) + ", " + returnParameterTypes[i]->humanReadableName() + ", " "is only supported in ABI coder v2. " "Use \"pragma abicoder v2;\" to enable the feature." ); @@ -2715,8 +2805,8 @@ bool TypeChecker::visit(FunctionCall const& _functionCall) } funcCallAnno.type = returnTypes.size() == 1 ? - move(returnTypes.front()) : - TypeProvider::tuple(move(returnTypes)); + std::move(returnTypes.front()) : + TypeProvider::tuple(std::move(returnTypes)); break; } @@ -2834,7 +2924,7 @@ bool TypeChecker::visit(FunctionCallOptions const& _functionCallOptions) _functionCallOptions.location(), kind == FunctionType::Kind::Creation ? "Cannot set option \"value\", since the constructor of " + - expressionFunctionType->returnParameterTypes().front()->toString() + + expressionFunctionType->returnParameterTypes().front()->humanReadableName() + " is not payable." : "Cannot set option \"value\" on a non-payable function type." ); @@ -2974,14 +3064,14 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) 4994_error, _memberAccess.location(), "Member \"" + memberName + "\" is not available in " + - exprType->toString() + + exprType->humanReadableName() + " outside of storage." ); } auto [errorId, description] = [&]() -> tuple { string errorMsg = "Member \"" + memberName + "\" not found or not visible " - "after argument-dependent lookup in " + exprType->toString() + "."; + "after argument-dependent lookup in " + exprType->humanReadableName() + "."; if (auto const* funType = dynamic_cast(exprType)) { @@ -2992,7 +3082,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) if (funType->kind() == FunctionType::Kind::Creation) return { 8827_error, - "Constructor for " + t.front()->toString() + " must be payable for member \"value\" to be available." + "Constructor for " + t.front()->humanReadableName() + " must be payable for member \"value\" to be available." }; else if ( funType->kind() == FunctionType::Kind::DelegateCall || @@ -3031,7 +3121,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) "Expected address not-payable as members were not found" ); - return { 9862_error, "\"send\" and \"transfer\" are only available for objects of type \"address payable\", not \"" + exprType->toString() + "\"." }; + return { 9862_error, "\"send\" and \"transfer\" are only available for objects of type \"address payable\", not \"" + exprType->humanReadableName() + "\"." }; } } @@ -3049,7 +3139,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) 6675_error, _memberAccess.location(), "Member \"" + memberName + "\" not unique " - "after argument-dependent lookup in " + exprType->toString() + + "after argument-dependent lookup in " + exprType->humanReadableName() + (memberName == "value" ? " - did you forget the \"payable\" modifier?" : ".") ); @@ -3063,7 +3153,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) solAssert( !funType->bound() || exprType->isImplicitlyConvertibleTo(*funType->selfType()), "Function \"" + memberName + "\" cannot be called on an object of type " + - exprType->toString() + " (expected " + funType->selfType()->toString() + ")." + exprType->humanReadableName() + " (expected " + funType->selfType()->humanReadableName() + ")." ); if ( @@ -3161,6 +3251,13 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) annotation.isPure = isPure; } + if ( + auto const* varDecl = dynamic_cast(annotation.referencedDeclaration); + !annotation.isPure.set() && + varDecl && + varDecl->isConstant() + ) + annotation.isPure = true; if (auto magicType = dynamic_cast(exprType)) { @@ -3328,7 +3425,7 @@ bool TypeChecker::visit(IndexAccess const& _access) m_errorReporter.fatalTypeError( 2614_error, _access.baseExpression().location(), - "Indexed expression has to be a type, mapping or array (is " + baseType->toString() + ")" + "Indexed expression has to be a type, mapping or array (is " + baseType->humanReadableName() + ")" ); } _access.annotation().type = resultType; @@ -3483,7 +3580,7 @@ bool TypeChecker::visit(Identifier const& _identifier) // Try to re-construct function definition string description; for (auto const& param: declaration->functionType(true)->parameterTypes()) - description += (description.empty() ? "" : ", ") + param->toString(false); + description += (description.empty() ? "" : ", ") + param->humanReadableName(); description = "function " + _identifier.name() + "(" + description + ")"; ssl.append("Candidate: " + description, declaration->location()); @@ -3704,7 +3801,7 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor) path->location(), "The function \"" + joinHumanReadable(path->path(), ".") + "\" " + "does not have any parameters, and therefore cannot be bound to the type \"" + - (normalizedType ? normalizedType->toString(true) : "*") + "\"." + (normalizedType ? normalizedType->humanReadableName() : "*") + "\"." ); FunctionType const* functionType = dynamic_cast(*functionDefinition.type()).asBoundFunction(); @@ -3717,9 +3814,9 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor) 3100_error, path->location(), "The function \"" + joinHumanReadable(path->path(), ".") + "\" "+ - "cannot be bound to the type \"" + _usingFor.typeName()->annotation().type->toString() + + "cannot be bound to the type \"" + _usingFor.typeName()->annotation().type->humanReadableName() + "\" because the type cannot be implicitly converted to the first argument" + - " of the function (\"" + functionType->selfType()->toString() + "\")" + + " of the function (\"" + functionType->selfType()->humanReadableName() + "\")" + ( result.message().empty() ? "." : @@ -3774,9 +3871,9 @@ bool TypeChecker::expectType(Expression const& _expression, Type const& _expecte if (!result) { auto errorMsg = "Type " + - type(_expression)->toString() + + type(_expression)->humanReadableName() + " is not implicitly convertible to expected type " + - _expectedType.toString(); + _expectedType.humanReadableName(); if ( type(_expression)->category() == Type::Category::RationalNumber && dynamic_cast(type(_expression))->isFractional() && @@ -3795,7 +3892,7 @@ bool TypeChecker::expectType(Expression const& _expression, Type const& _expecte _expression.location(), errorMsg + ". Try converting to type " + - type(_expression)->mobileType()->toString() + + type(_expression)->mobileType()->humanReadableName() + " or use an explicit conversion.", result.message() ); diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 04c47a155..97167818c 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -29,6 +29,8 @@ #include #include +#include + #include #include @@ -38,6 +40,17 @@ using namespace std; using namespace solidity; using namespace solidity::frontend; +namespace +{ +TryCatchClause const* findClause(vector> const& _clauses, optional _errorName = {}) +{ + for (auto const& clause: ranges::views::tail(_clauses)) + if (_errorName.has_value() ? clause->errorName() == _errorName : clause->errorName().empty()) + return clause.get(); + return nullptr; +} +} + ASTNode::ASTNode(int64_t _id, SourceLocation _location): m_id(static_cast(_id)), m_location(std::move(_location)) @@ -239,7 +252,7 @@ vector ContractDefinition::interfaceErrors(bool _require result += (*annotation().creationCallGraph)->usedErrors + (*annotation().deployedCallGraph)->usedErrors; - return util::convertContainer>(move(result)); + return util::convertContainer>(std::move(result)); } vector, FunctionTypePointer>> const& ContractDefinition::interfaceFunctionList(bool _includeInheritedFunctions) const @@ -981,26 +994,14 @@ TryCatchClause const* TryStatement::successClause() const return m_clauses[0].get(); } -TryCatchClause const* TryStatement::panicClause() const -{ - for (size_t i = 1; i < m_clauses.size(); ++i) - if (m_clauses[i]->errorName() == "Panic") - return m_clauses[i].get(); - return nullptr; +TryCatchClause const* TryStatement::panicClause() const { + return findClause(m_clauses, "Panic"); } -TryCatchClause const* TryStatement::errorClause() const -{ - for (size_t i = 1; i < m_clauses.size(); ++i) - if (m_clauses[i]->errorName() == "Error") - return m_clauses[i].get(); - return nullptr; +TryCatchClause const* TryStatement::errorClause() const { + return findClause(m_clauses, "Error"); } -TryCatchClause const* TryStatement::fallbackClause() const -{ - for (size_t i = 1; i < m_clauses.size(); ++i) - if (m_clauses[i]->errorName().empty()) - return m_clauses[i].get(); - return nullptr; +TryCatchClause const* TryStatement::fallbackClause() const { + return findClause(m_clauses); } diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 4eba73c5d..d6e41bb5f 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -358,7 +358,7 @@ public: ): Declaration(_id, _location, _unitAlias, std::move(_unitAliasLocation)), m_path(std::move(_path)), - m_symbolAliases(move(_symbolAliases)) + m_symbolAliases(std::move(_symbolAliases)) { } void accept(ASTVisitor& _visitor) override; @@ -587,10 +587,19 @@ private: class IdentifierPath: public ASTNode { public: - IdentifierPath(int64_t _id, SourceLocation const& _location, std::vector _path): - ASTNode(_id, _location), m_path(std::move(_path)) {} + IdentifierPath( + int64_t _id, + SourceLocation const& _location, + std::vector _path, + std::vector _pathLocations + ): + ASTNode(_id, _location), m_path(std::move(_path)), m_pathLocations(std::move(_pathLocations)) + { + solAssert(m_pathLocations.size() == m_path.size()); + } std::vector const& path() const { return m_path; } + std::vector const& pathLocations() const { return m_pathLocations; } IdentifierPathAnnotation& annotation() const override { return initAnnotation(); @@ -600,6 +609,8 @@ public: void accept(ASTConstVisitor& _visitor) const override; private: std::vector m_path; + // Corresponding locations for m_path. Array has same length and indices as m_path. + std::vector m_pathLocations; }; class InheritanceSpecifier: public ASTNode @@ -1492,7 +1503,7 @@ public: ): Statement(_id, _location, _docString), m_dialect(_dialect), - m_flags(move(_flags)), + m_flags(std::move(_flags)), m_operations(std::move(_operations)) {} void accept(ASTVisitor& _visitor) override; @@ -2094,9 +2105,14 @@ public: SourceLocation const& _location, ASTPointer _expression, std::vector> _arguments, - std::vector> _names + std::vector> _names, + std::vector _nameLocations ): - Expression(_id, _location), m_expression(std::move(_expression)), m_arguments(std::move(_arguments)), m_names(std::move(_names)) {} + Expression(_id, _location), m_expression(std::move(_expression)), m_arguments(std::move(_arguments)), m_names(std::move(_names)), m_nameLocations(std::move(_nameLocations)) + { + solAssert(m_nameLocations.size() == m_names.size()); + } + void accept(ASTVisitor& _visitor) override; void accept(ASTConstVisitor& _visitor) const override; @@ -2109,6 +2125,7 @@ public: /// in the order they were written. /// If this is not a named call, this is empty. std::vector> const& names() const { return m_names; } + std::vector const& nameLocations() const { return m_nameLocations; } FunctionCallAnnotation& annotation() const override; @@ -2116,6 +2133,7 @@ private: ASTPointer m_expression; std::vector> m_arguments; std::vector> m_names; + std::vector m_nameLocations; }; /** @@ -2179,19 +2197,27 @@ public: int64_t _id, SourceLocation const& _location, ASTPointer _expression, - ASTPointer _memberName + ASTPointer _memberName, + SourceLocation _memberLocation ): - Expression(_id, _location), m_expression(std::move(_expression)), m_memberName(std::move(_memberName)) {} + Expression(_id, _location), + m_expression(std::move(_expression)), + m_memberName(std::move(_memberName)), + m_memberLocation(std::move(_memberLocation)) + {} + void accept(ASTVisitor& _visitor) override; void accept(ASTConstVisitor& _visitor) const override; Expression const& expression() const { return *m_expression; } ASTString const& memberName() const { return *m_memberName; } + SourceLocation const& memberLocation() const { return m_memberLocation; } MemberAccessAnnotation& annotation() const override; private: ASTPointer m_expression; ASTPointer m_memberName; + SourceLocation m_memberLocation; }; /** diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index 3497a2ea8..2615e6af7 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -256,6 +256,9 @@ struct IdentifierPathAnnotation: ASTAnnotation Declaration const* referencedDeclaration = nullptr; /// What kind of lookup needs to be done (static, virtual, super) find the declaration. util::SetOnce requiredLookup; + + /// Declaration of each path element. + std::vector pathDeclarations; }; struct ExpressionAnnotation: ASTAnnotation diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonExporter.cpp similarity index 83% rename from libsolidity/ast/ASTJsonConverter.cpp rename to libsolidity/ast/ASTJsonExporter.cpp index f75f5bc15..d308cd90c 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonExporter.cpp @@ -20,7 +20,7 @@ * Converts the AST into json format */ -#include +#include #include #include @@ -37,8 +37,6 @@ #include -#include - #include #include #include @@ -74,27 +72,27 @@ void addIfSet(std::vector>& _attributes, string const& namespace solidity::frontend { -ASTJsonConverter::ASTJsonConverter(CompilerStack::State _stackState, map _sourceIndices): +ASTJsonExporter::ASTJsonExporter(CompilerStack::State _stackState, map _sourceIndices): m_stackState(_stackState), m_sourceIndices(std::move(_sourceIndices)) { } -void ASTJsonConverter::setJsonNode( +void ASTJsonExporter::setJsonNode( ASTNode const& _node, string const& _nodeName, initializer_list>&& _attributes ) { - ASTJsonConverter::setJsonNode( + ASTJsonExporter::setJsonNode( _node, _nodeName, std::vector>(std::move(_attributes)) ); } -void ASTJsonConverter::setJsonNode( +void ASTJsonExporter::setJsonNode( ASTNode const& _node, string const& _nodeType, std::vector>&& _attributes @@ -111,7 +109,7 @@ void ASTJsonConverter::setJsonNode( m_currentValue[e.first] = std::move(e.second); } -optional ASTJsonConverter::sourceIndexFromLocation(SourceLocation const& _location) const +optional ASTJsonExporter::sourceIndexFromLocation(SourceLocation const& _location) const { if (_location.sourceName && m_sourceIndices.count(*_location.sourceName)) return m_sourceIndices.at(*_location.sourceName); @@ -119,7 +117,7 @@ optional ASTJsonConverter::sourceIndexFromLocation(SourceLocation const& return nullopt; } -string ASTJsonConverter::sourceLocationToString(SourceLocation const& _location) const +string ASTJsonExporter::sourceLocationToString(SourceLocation const& _location) const { optional sourceIndexOpt = sourceIndexFromLocation(_location); int length = -1; @@ -128,20 +126,30 @@ string ASTJsonConverter::sourceLocationToString(SourceLocation const& _location) return to_string(_location.start) + ":" + to_string(length) + ":" + (sourceIndexOpt.has_value() ? to_string(sourceIndexOpt.value()) : "-1"); } -string ASTJsonConverter::namePathToString(std::vector const& _namePath) +Json::Value ASTJsonExporter::sourceLocationsToJson(vector const& _sourceLocations) const +{ + Json::Value locations = Json::arrayValue; + + for (SourceLocation const& location: _sourceLocations) + locations.append(sourceLocationToString(location)); + + return locations; +} + +string ASTJsonExporter::namePathToString(std::vector const& _namePath) { return boost::algorithm::join(_namePath, "."); } -Json::Value ASTJsonConverter::typePointerToJson(Type const* _tp, bool _short) +Json::Value ASTJsonExporter::typePointerToJson(Type const* _tp, bool _withoutDataLocation) { Json::Value typeDescriptions(Json::objectValue); - typeDescriptions["typeString"] = _tp ? Json::Value(_tp->toString(_short)) : Json::nullValue; + typeDescriptions["typeString"] = _tp ? Json::Value(_tp->toString(_withoutDataLocation)) : Json::nullValue; typeDescriptions["typeIdentifier"] = _tp ? Json::Value(_tp->identifier()) : Json::nullValue; return typeDescriptions; } -Json::Value ASTJsonConverter::typePointerToJson(std::optional const& _tps) +Json::Value ASTJsonExporter::typePointerToJson(std::optional const& _tps) { if (_tps) { @@ -154,7 +162,7 @@ Json::Value ASTJsonConverter::typePointerToJson(std::optional return Json::nullValue; } -void ASTJsonConverter::appendExpressionAttributes( +void ASTJsonExporter::appendExpressionAttributes( std::vector>& _attributes, ExpressionAnnotation const& _annotation ) @@ -174,7 +182,7 @@ void ASTJsonConverter::appendExpressionAttributes( _attributes += exprAttributes; } -Json::Value ASTJsonConverter::inlineAssemblyIdentifierToJson(pair _info) const +Json::Value ASTJsonExporter::inlineAssemblyIdentifierToJson(pair _info) const { Json::Value tuple(Json::objectValue); tuple["src"] = sourceLocationToString(nativeLocationOf(*_info.first)); @@ -190,18 +198,18 @@ Json::Value ASTJsonConverter::inlineAssemblyIdentifierToJson(pair> attributes = { make_pair("license", _node.licenseString() ? Json::Value(*_node.licenseString()) : Json::nullValue), @@ -228,7 +236,7 @@ bool ASTJsonConverter::visit(SourceUnit const& _node) return false; } -bool ASTJsonConverter::visit(PragmaDirective const& _node) +bool ASTJsonExporter::visit(PragmaDirective const& _node) { Json::Value literals(Json::arrayValue); for (auto const& literal: _node.literals()) @@ -239,7 +247,7 @@ bool ASTJsonConverter::visit(PragmaDirective const& _node) return false; } -bool ASTJsonConverter::visit(ImportDirective const& _node) +bool ASTJsonExporter::visit(ImportDirective const& _node) { std::vector> attributes = { make_pair("file", _node.path()), @@ -267,7 +275,7 @@ bool ASTJsonConverter::visit(ImportDirective const& _node) return false; } -bool ASTJsonConverter::visit(ContractDefinition const& _node) +bool ASTJsonExporter::visit(ContractDefinition const& _node) { std::vector> attributes = { make_pair("name", _node.name()), @@ -292,16 +300,22 @@ bool ASTJsonConverter::visit(ContractDefinition const& _node) return false; } -bool ASTJsonConverter::visit(IdentifierPath const& _node) +bool ASTJsonExporter::visit(IdentifierPath const& _node) { + Json::Value nameLocations = Json::arrayValue; + + for (SourceLocation location: _node.pathLocations()) + nameLocations.append(sourceLocationToString(location)); + setJsonNode(_node, "IdentifierPath", { make_pair("name", namePathToString(_node.path())), + make_pair("nameLocations", nameLocations), make_pair("referencedDeclaration", idOrNull(_node.annotation().referencedDeclaration)) }); return false; } -bool ASTJsonConverter::visit(InheritanceSpecifier const& _node) +bool ASTJsonExporter::visit(InheritanceSpecifier const& _node) { setJsonNode(_node, "InheritanceSpecifier", { make_pair("baseName", toJson(_node.name())), @@ -310,7 +324,7 @@ bool ASTJsonConverter::visit(InheritanceSpecifier const& _node) return false; } -bool ASTJsonConverter::visit(UsingForDirective const& _node) +bool ASTJsonExporter::visit(UsingForDirective const& _node) { vector> attributes = { make_pair("typeName", _node.typeName() ? toJson(*_node.typeName()) : Json::nullValue) @@ -322,20 +336,20 @@ bool ASTJsonConverter::visit(UsingForDirective const& _node) { Json::Value functionNode; functionNode["function"] = toJson(*function); - functionList.append(move(functionNode)); + functionList.append(std::move(functionNode)); } - attributes.emplace_back("functionList", move(functionList)); + attributes.emplace_back("functionList", std::move(functionList)); } else attributes.emplace_back("libraryName", toJson(*_node.functionsOrLibrary().front())); attributes.emplace_back("global", _node.global()); - setJsonNode(_node, "UsingForDirective", move(attributes)); + setJsonNode(_node, "UsingForDirective", std::move(attributes)); return false; } -bool ASTJsonConverter::visit(StructDefinition const& _node) +bool ASTJsonExporter::visit(StructDefinition const& _node) { std::vector> attributes = { make_pair("name", _node.name()), @@ -352,7 +366,7 @@ bool ASTJsonConverter::visit(StructDefinition const& _node) return false; } -bool ASTJsonConverter::visit(EnumDefinition const& _node) +bool ASTJsonExporter::visit(EnumDefinition const& _node) { std::vector> attributes = { make_pair("name", _node.name()), @@ -367,7 +381,7 @@ bool ASTJsonConverter::visit(EnumDefinition const& _node) return false; } -bool ASTJsonConverter::visit(EnumValue const& _node) +bool ASTJsonExporter::visit(EnumValue const& _node) { setJsonNode(_node, "EnumValue", { make_pair("name", _node.name()), @@ -376,7 +390,7 @@ bool ASTJsonConverter::visit(EnumValue const& _node) return false; } -bool ASTJsonConverter::visit(UserDefinedValueTypeDefinition const& _node) +bool ASTJsonExporter::visit(UserDefinedValueTypeDefinition const& _node) { solAssert(_node.underlyingType(), ""); std::vector> attributes = { @@ -391,7 +405,7 @@ bool ASTJsonConverter::visit(UserDefinedValueTypeDefinition const& _node) return false; } -bool ASTJsonConverter::visit(ParameterList const& _node) +bool ASTJsonExporter::visit(ParameterList const& _node) { setJsonNode(_node, "ParameterList", { make_pair("parameters", toJson(_node.parameters())) @@ -399,7 +413,7 @@ bool ASTJsonConverter::visit(ParameterList const& _node) return false; } -bool ASTJsonConverter::visit(OverrideSpecifier const& _node) +bool ASTJsonExporter::visit(OverrideSpecifier const& _node) { setJsonNode(_node, "OverrideSpecifier", { make_pair("overrides", toJson(_node.overrides())) @@ -407,7 +421,7 @@ bool ASTJsonConverter::visit(OverrideSpecifier const& _node) return false; } -bool ASTJsonConverter::visit(FunctionDefinition const& _node) +bool ASTJsonExporter::visit(FunctionDefinition const& _node) { std::vector> attributes = { make_pair("name", _node.name()), @@ -445,7 +459,7 @@ bool ASTJsonConverter::visit(FunctionDefinition const& _node) return false; } -bool ASTJsonConverter::visit(VariableDeclaration const& _node) +bool ASTJsonExporter::visit(VariableDeclaration const& _node) { std::vector> attributes = { make_pair("name", _node.name()), @@ -473,7 +487,7 @@ bool ASTJsonConverter::visit(VariableDeclaration const& _node) return false; } -bool ASTJsonConverter::visit(ModifierDefinition const& _node) +bool ASTJsonExporter::visit(ModifierDefinition const& _node) { std::vector> attributes = { make_pair("name", _node.name()), @@ -491,7 +505,7 @@ bool ASTJsonConverter::visit(ModifierDefinition const& _node) return false; } -bool ASTJsonConverter::visit(ModifierInvocation const& _node) +bool ASTJsonExporter::visit(ModifierInvocation const& _node) { std::vector> attributes{ make_pair("modifierName", toJson(_node.name())), @@ -504,11 +518,11 @@ bool ASTJsonConverter::visit(ModifierInvocation const& _node) else if (dynamic_cast(declaration)) attributes.emplace_back("kind", "baseConstructorSpecifier"); } - setJsonNode(_node, "ModifierInvocation", move(attributes)); + setJsonNode(_node, "ModifierInvocation", std::move(attributes)); return false; } -bool ASTJsonConverter::visit(EventDefinition const& _node) +bool ASTJsonExporter::visit(EventDefinition const& _node) { m_inEvent = true; std::vector> _attributes = { @@ -529,7 +543,7 @@ bool ASTJsonConverter::visit(EventDefinition const& _node) return false; } -bool ASTJsonConverter::visit(ErrorDefinition const& _node) +bool ASTJsonExporter::visit(ErrorDefinition const& _node) { std::vector> _attributes = { make_pair("name", _node.name()), @@ -544,7 +558,7 @@ bool ASTJsonConverter::visit(ErrorDefinition const& _node) return false; } -bool ASTJsonConverter::visit(ElementaryTypeName const& _node) +bool ASTJsonExporter::visit(ElementaryTypeName const& _node) { std::vector> attributes = { make_pair("name", _node.typeName().toString()), @@ -558,7 +572,7 @@ bool ASTJsonConverter::visit(ElementaryTypeName const& _node) return false; } -bool ASTJsonConverter::visit(UserDefinedTypeName const& _node) +bool ASTJsonExporter::visit(UserDefinedTypeName const& _node) { setJsonNode(_node, "UserDefinedTypeName", { make_pair("pathNode", toJson(_node.pathNode())), @@ -568,7 +582,7 @@ bool ASTJsonConverter::visit(UserDefinedTypeName const& _node) return false; } -bool ASTJsonConverter::visit(FunctionTypeName const& _node) +bool ASTJsonExporter::visit(FunctionTypeName const& _node) { setJsonNode(_node, "FunctionTypeName", { make_pair("visibility", Declaration::visibilityToString(_node.visibility())), @@ -580,7 +594,7 @@ bool ASTJsonConverter::visit(FunctionTypeName const& _node) return false; } -bool ASTJsonConverter::visit(Mapping const& _node) +bool ASTJsonExporter::visit(Mapping const& _node) { setJsonNode(_node, "Mapping", { make_pair("keyType", toJson(_node.keyType())), @@ -590,7 +604,7 @@ bool ASTJsonConverter::visit(Mapping const& _node) return false; } -bool ASTJsonConverter::visit(ArrayTypeName const& _node) +bool ASTJsonExporter::visit(ArrayTypeName const& _node) { setJsonNode(_node, "ArrayTypeName", { make_pair("baseType", toJson(_node.baseType())), @@ -600,7 +614,7 @@ bool ASTJsonConverter::visit(ArrayTypeName const& _node) return false; } -bool ASTJsonConverter::visit(InlineAssembly const& _node) +bool ASTJsonExporter::visit(InlineAssembly const& _node) { vector> externalReferences; @@ -613,7 +627,7 @@ bool ASTJsonConverter::visit(InlineAssembly const& _node) Json::Value externalReferencesJson = Json::arrayValue; - ranges::sort(externalReferences); + std::sort(externalReferences.begin(), externalReferences.end()); for (Json::Value& it: externalReferences | ranges::views::values) externalReferencesJson.append(std::move(it)); @@ -631,14 +645,14 @@ bool ASTJsonConverter::visit(InlineAssembly const& _node) flags.append(*flag); else flags.append(Json::nullValue); - attributes.emplace_back(make_pair("flags", move(flags))); + attributes.emplace_back(make_pair("flags", std::move(flags))); } - setJsonNode(_node, "InlineAssembly", move(attributes)); + setJsonNode(_node, "InlineAssembly", std::move(attributes)); return false; } -bool ASTJsonConverter::visit(Block const& _node) +bool ASTJsonExporter::visit(Block const& _node) { setJsonNode(_node, _node.unchecked() ? "UncheckedBlock" : "Block", { make_pair("statements", toJson(_node.statements())) @@ -646,13 +660,13 @@ bool ASTJsonConverter::visit(Block const& _node) return false; } -bool ASTJsonConverter::visit(PlaceholderStatement const& _node) +bool ASTJsonExporter::visit(PlaceholderStatement const& _node) { setJsonNode(_node, "PlaceholderStatement", {}); return false; } -bool ASTJsonConverter::visit(IfStatement const& _node) +bool ASTJsonExporter::visit(IfStatement const& _node) { setJsonNode(_node, "IfStatement", { make_pair("condition", toJson(_node.condition())), @@ -662,7 +676,7 @@ bool ASTJsonConverter::visit(IfStatement const& _node) return false; } -bool ASTJsonConverter::visit(TryCatchClause const& _node) +bool ASTJsonExporter::visit(TryCatchClause const& _node) { setJsonNode(_node, "TryCatchClause", { make_pair("errorName", _node.errorName()), @@ -672,7 +686,7 @@ bool ASTJsonConverter::visit(TryCatchClause const& _node) return false; } -bool ASTJsonConverter::visit(TryStatement const& _node) +bool ASTJsonExporter::visit(TryStatement const& _node) { setJsonNode(_node, "TryStatement", { make_pair("externalCall", toJson(_node.externalCall())), @@ -681,7 +695,7 @@ bool ASTJsonConverter::visit(TryStatement const& _node) return false; } -bool ASTJsonConverter::visit(WhileStatement const& _node) +bool ASTJsonExporter::visit(WhileStatement const& _node) { setJsonNode( _node, @@ -694,7 +708,7 @@ bool ASTJsonConverter::visit(WhileStatement const& _node) return false; } -bool ASTJsonConverter::visit(ForStatement const& _node) +bool ASTJsonExporter::visit(ForStatement const& _node) { setJsonNode(_node, "ForStatement", { make_pair("initializationExpression", toJsonOrNull(_node.initializationExpression())), @@ -705,19 +719,19 @@ bool ASTJsonConverter::visit(ForStatement const& _node) return false; } -bool ASTJsonConverter::visit(Continue const& _node) +bool ASTJsonExporter::visit(Continue const& _node) { setJsonNode(_node, "Continue", {}); return false; } -bool ASTJsonConverter::visit(Break const& _node) +bool ASTJsonExporter::visit(Break const& _node) { setJsonNode(_node, "Break", {}); return false; } -bool ASTJsonConverter::visit(Return const& _node) +bool ASTJsonExporter::visit(Return const& _node) { setJsonNode(_node, "Return", { make_pair("expression", toJsonOrNull(_node.expression())), @@ -726,13 +740,13 @@ bool ASTJsonConverter::visit(Return const& _node) return false; } -bool ASTJsonConverter::visit(Throw const& _node) +bool ASTJsonExporter::visit(Throw const& _node) { setJsonNode(_node, "Throw", {}); return false; } -bool ASTJsonConverter::visit(EmitStatement const& _node) +bool ASTJsonExporter::visit(EmitStatement const& _node) { setJsonNode(_node, "EmitStatement", { make_pair("eventCall", toJson(_node.eventCall())) @@ -740,7 +754,7 @@ bool ASTJsonConverter::visit(EmitStatement const& _node) return false; } -bool ASTJsonConverter::visit(RevertStatement const& _node) +bool ASTJsonExporter::visit(RevertStatement const& _node) { setJsonNode(_node, "RevertStatement", { make_pair("errorCall", toJson(_node.errorCall())) @@ -748,7 +762,7 @@ bool ASTJsonConverter::visit(RevertStatement const& _node) return false; } -bool ASTJsonConverter::visit(VariableDeclarationStatement const& _node) +bool ASTJsonExporter::visit(VariableDeclarationStatement const& _node) { Json::Value varDecs(Json::arrayValue); for (auto const& v: _node.declarations()) @@ -761,7 +775,7 @@ bool ASTJsonConverter::visit(VariableDeclarationStatement const& _node) return false; } -bool ASTJsonConverter::visit(ExpressionStatement const& _node) +bool ASTJsonExporter::visit(ExpressionStatement const& _node) { setJsonNode(_node, "ExpressionStatement", { make_pair("expression", toJson(_node.expression())) @@ -769,7 +783,7 @@ bool ASTJsonConverter::visit(ExpressionStatement const& _node) return false; } -bool ASTJsonConverter::visit(Conditional const& _node) +bool ASTJsonExporter::visit(Conditional const& _node) { std::vector> attributes = { make_pair("condition", toJson(_node.condition())), @@ -781,7 +795,7 @@ bool ASTJsonConverter::visit(Conditional const& _node) return false; } -bool ASTJsonConverter::visit(Assignment const& _node) +bool ASTJsonExporter::visit(Assignment const& _node) { std::vector> attributes = { make_pair("operator", TokenTraits::toString(_node.assignmentOperator())), @@ -793,7 +807,7 @@ bool ASTJsonConverter::visit(Assignment const& _node) return false; } -bool ASTJsonConverter::visit(TupleExpression const& _node) +bool ASTJsonExporter::visit(TupleExpression const& _node) { std::vector> attributes = { make_pair("isInlineArray", Json::Value(_node.isInlineArray())), @@ -804,7 +818,7 @@ bool ASTJsonConverter::visit(TupleExpression const& _node) return false; } -bool ASTJsonConverter::visit(UnaryOperation const& _node) +bool ASTJsonExporter::visit(UnaryOperation const& _node) { std::vector> attributes = { make_pair("prefix", _node.isPrefixOperation()), @@ -816,7 +830,7 @@ bool ASTJsonConverter::visit(UnaryOperation const& _node) return false; } -bool ASTJsonConverter::visit(BinaryOperation const& _node) +bool ASTJsonExporter::visit(BinaryOperation const& _node) { std::vector> attributes = { make_pair("operator", TokenTraits::toString(_node.getOperator())), @@ -829,7 +843,7 @@ bool ASTJsonConverter::visit(BinaryOperation const& _node) return false; } -bool ASTJsonConverter::visit(FunctionCall const& _node) +bool ASTJsonExporter::visit(FunctionCall const& _node) { Json::Value names(Json::arrayValue); for (auto const& name: _node.names()) @@ -837,6 +851,7 @@ bool ASTJsonConverter::visit(FunctionCall const& _node) std::vector> attributes = { make_pair("expression", toJson(_node.expression())), make_pair("names", std::move(names)), + make_pair("nameLocations", sourceLocationsToJson(_node.nameLocations())), make_pair("arguments", toJson(_node.arguments())), make_pair("tryCall", _node.annotation().tryCall) }; @@ -852,7 +867,7 @@ bool ASTJsonConverter::visit(FunctionCall const& _node) return false; } -bool ASTJsonConverter::visit(FunctionCallOptions const& _node) +bool ASTJsonExporter::visit(FunctionCallOptions const& _node) { Json::Value names(Json::arrayValue); for (auto const& name: _node.names()) @@ -869,7 +884,7 @@ bool ASTJsonConverter::visit(FunctionCallOptions const& _node) return false; } -bool ASTJsonConverter::visit(NewExpression const& _node) +bool ASTJsonExporter::visit(NewExpression const& _node) { std::vector> attributes = { make_pair("typeName", toJson(_node.typeName())) @@ -879,10 +894,11 @@ bool ASTJsonConverter::visit(NewExpression const& _node) return false; } -bool ASTJsonConverter::visit(MemberAccess const& _node) +bool ASTJsonExporter::visit(MemberAccess const& _node) { std::vector> attributes = { make_pair("memberName", _node.memberName()), + make_pair("memberLocation", Json::Value(sourceLocationToString(_node.memberLocation()))), make_pair("expression", toJson(_node.expression())), make_pair("referencedDeclaration", idOrNull(_node.annotation().referencedDeclaration)), }; @@ -891,7 +907,7 @@ bool ASTJsonConverter::visit(MemberAccess const& _node) return false; } -bool ASTJsonConverter::visit(IndexAccess const& _node) +bool ASTJsonExporter::visit(IndexAccess const& _node) { std::vector> attributes = { make_pair("baseExpression", toJson(_node.baseExpression())), @@ -902,7 +918,7 @@ bool ASTJsonConverter::visit(IndexAccess const& _node) return false; } -bool ASTJsonConverter::visit(IndexRangeAccess const& _node) +bool ASTJsonExporter::visit(IndexRangeAccess const& _node) { std::vector> attributes = { make_pair("baseExpression", toJson(_node.baseExpression())), @@ -914,7 +930,7 @@ bool ASTJsonConverter::visit(IndexRangeAccess const& _node) return false; } -bool ASTJsonConverter::visit(Identifier const& _node) +bool ASTJsonExporter::visit(Identifier const& _node) { Json::Value overloads(Json::arrayValue); for (auto const& dec: _node.annotation().overloadedDeclarations) @@ -929,7 +945,7 @@ bool ASTJsonConverter::visit(Identifier const& _node) return false; } -bool ASTJsonConverter::visit(ElementaryTypeNameExpression const& _node) +bool ASTJsonExporter::visit(ElementaryTypeNameExpression const& _node) { std::vector> attributes = { make_pair("typeName", toJson(_node.type())) @@ -939,7 +955,7 @@ bool ASTJsonConverter::visit(ElementaryTypeNameExpression const& _node) return false; } -bool ASTJsonConverter::visit(Literal const& _node) +bool ASTJsonExporter::visit(Literal const& _node) { Json::Value value{_node.value()}; if (!util::validateUTF8(_node.value())) @@ -961,7 +977,7 @@ bool ASTJsonConverter::visit(Literal const& _node) return false; } -bool ASTJsonConverter::visit(StructuredDocumentation const& _node) +bool ASTJsonExporter::visit(StructuredDocumentation const& _node) { Json::Value text{*_node.text()}; std::vector> attributes = { @@ -973,12 +989,12 @@ bool ASTJsonConverter::visit(StructuredDocumentation const& _node) -void ASTJsonConverter::endVisit(EventDefinition const&) +void ASTJsonExporter::endVisit(EventDefinition const&) { m_inEvent = false; } -string ASTJsonConverter::location(VariableDeclaration::Location _location) +string ASTJsonExporter::location(VariableDeclaration::Location _location) { switch (_location) { @@ -995,7 +1011,7 @@ string ASTJsonConverter::location(VariableDeclaration::Location _location) return {}; } -string ASTJsonConverter::contractKind(ContractKind _kind) +string ASTJsonExporter::contractKind(ContractKind _kind) { switch (_kind) { @@ -1011,7 +1027,7 @@ string ASTJsonConverter::contractKind(ContractKind _kind) return {}; } -string ASTJsonConverter::functionCallKind(FunctionCallKind _kind) +string ASTJsonExporter::functionCallKind(FunctionCallKind _kind) { switch (_kind) { @@ -1026,7 +1042,7 @@ string ASTJsonConverter::functionCallKind(FunctionCallKind _kind) } } -string ASTJsonConverter::literalTokenKind(Token _token) +string ASTJsonExporter::literalTokenKind(Token _token) { switch (_token) { @@ -1046,12 +1062,12 @@ string ASTJsonConverter::literalTokenKind(Token _token) } } -string ASTJsonConverter::type(Expression const& _expression) +string ASTJsonExporter::type(Expression const& _expression) { return _expression.annotation().type ? _expression.annotation().type->toString() : "Unknown"; } -string ASTJsonConverter::type(VariableDeclaration const& _varDecl) +string ASTJsonExporter::type(VariableDeclaration const& _varDecl) { return _varDecl.annotation().type ? _varDecl.annotation().type->toString() : "Unknown"; } diff --git a/libsolidity/ast/ASTJsonConverter.h b/libsolidity/ast/ASTJsonExporter.h similarity index 96% rename from libsolidity/ast/ASTJsonConverter.h rename to libsolidity/ast/ASTJsonExporter.h index 88725299f..71d15ce0a 100644 --- a/libsolidity/ast/ASTJsonConverter.h +++ b/libsolidity/ast/ASTJsonExporter.h @@ -48,13 +48,13 @@ namespace solidity::frontend /** * Converter of the AST into JSON format */ -class ASTJsonConverter: public ASTConstVisitor +class ASTJsonExporter: public ASTConstVisitor { public: /// Create a converter to JSON for the given abstract syntax tree. /// @a _stackState state of the compiler stack to avoid outputting incomplete data /// @a _sourceIndices is used to abbreviate source names in source locations. - explicit ASTJsonConverter( + explicit ASTJsonExporter( CompilerStack::State _stackState, std::map _sourceIndices = std::map() ); @@ -144,6 +144,7 @@ private: /// Maps source location to an index, if source is valid and a mapping does exist, otherwise returns std::nullopt. std::optional sourceIndexFromLocation(langutil::SourceLocation const& _location) const; std::string sourceLocationToString(langutil::SourceLocation const& _location) const; + Json::Value sourceLocationsToJson(std::vector const& _sourceLocations) const; static std::string namePathToString(std::vector const& _namePath); static Json::Value idOrNull(ASTNode const* _pt) { @@ -183,7 +184,7 @@ private: return json; } - static Json::Value typePointerToJson(Type const* _tp, bool _short = false); + static Json::Value typePointerToJson(Type const* _tp, bool _withoutDataLocation = false); static Json::Value typePointerToJson(std::optional const& _tps); void appendExpressionAttributes( std::vector> &_attributes, diff --git a/libsolidity/ast/ASTJsonImporter.cpp b/libsolidity/ast/ASTJsonImporter.cpp index 2f36cdead..96c37003e 100644 --- a/libsolidity/ast/ASTJsonImporter.cpp +++ b/libsolidity/ast/ASTJsonImporter.cpp @@ -95,6 +95,20 @@ SourceLocation const ASTJsonImporter::createSourceLocation(Json::Value const& _n return solidity::langutil::parseSourceLocation(_node["src"].asString(), m_sourceNames); } +optional> ASTJsonImporter::createSourceLocations(Json::Value const& _node) const +{ + vector locations; + + if (_node.isMember("nameLocations") && _node["nameLocations"].isArray()) + { + for (auto const& val: _node["nameLocations"]) + locations.emplace_back(langutil::parseSourceLocation(val.asString(), m_sourceNames)); + return locations; + } + + return nullopt; +} + SourceLocation ASTJsonImporter::createNameSourceLocation(Json::Value const& _node) { astAssert(member(_node, "nameLocation").isString(), "'nameLocation' must be a string"); @@ -229,6 +243,9 @@ ASTPointer ASTJsonImporter::convertJsonToASTNode(Json::Value const& _js return createDocumentation(_json); else astAssert(false, "Unknown type of ASTNode: " + nodeType); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + util::unreachable(); } // ============ functions to instantiate the AST-Nodes from Json-Nodes ============== @@ -282,7 +299,7 @@ ASTPointer ASTJsonImporter::createImportDirective(Json::Value c path, unitAlias, createNameSourceLocation(_node), - move(symbolAliases) + std::move(symbolAliases) ); astAssert(_node["absolutePath"].isString(), "Expected 'absolutePath' to be a string!"); @@ -322,6 +339,7 @@ ASTPointer ASTJsonImporter::createIdentifierPath(Json::Value con astAssert(_node["name"].isString(), "Expected 'name' to be a string!"); vector namePath; + vector namePathLocations; vector strs; string nameString = member(_node, "name").asString(); boost::algorithm::split(strs, nameString, boost::is_any_of(".")); @@ -331,7 +349,23 @@ ASTPointer ASTJsonImporter::createIdentifierPath(Json::Value con astAssert(!s.empty(), "Expected non-empty string for IdentifierPath element."); namePath.emplace_back(s); } - return createASTNode(_node, namePath); + + if (_node.isMember("nameLocations") && _node["nameLocations"].isArray()) + for (auto const& val: _node["nameLocations"]) + namePathLocations.emplace_back(langutil::parseSourceLocation(val.asString(), m_sourceNames)); + else + namePathLocations.resize(namePath.size()); + + astAssert( + namePath.size() == namePathLocations.size(), + "SourceLocations don't match name paths." + ); + + return createASTNode( + _node, + namePath, + namePathLocations + ); } ASTPointer ASTJsonImporter::createInheritanceSpecifier(Json::Value const& _node) @@ -357,7 +391,7 @@ ASTPointer ASTJsonImporter::createUsingForDirective(Json::Val return createASTNode( _node, - move(functions), + std::move(functions), !_node.isMember("libraryName"), _node["typeName"].isNull() ? nullptr : convertJsonToASTNode(_node["typeName"]), memberAsBool(_node, "global") @@ -652,7 +686,7 @@ ASTPointer ASTJsonImporter::createInlineAssembly(Json::Value con _node, nullOrASTString(_node, "documentation"), dialect, - move(flags), + std::move(flags), operations ); } @@ -873,11 +907,17 @@ ASTPointer ASTJsonImporter::createFunctionCall(Json::Value const& astAssert(name.isString(), "Expected 'names' members to be strings!"); names.push_back(make_shared(name.asString())); } + + optional> sourceLocations = createSourceLocations(_node); + return createASTNode( _node, convertJsonToASTNode(member(_node, "expression")), arguments, - names + names, + sourceLocations ? + *sourceLocations : + vector(names.size()) ); } @@ -911,10 +951,15 @@ ASTPointer ASTJsonImporter::createNewExpression(Json::Value const ASTPointer ASTJsonImporter::createMemberAccess(Json::Value const& _node) { + SourceLocation memberLocation; + if (member(_node, "memberLocation").isString()) + memberLocation = solidity::langutil::parseSourceLocation(_node["memberLocation"].asString(), m_sourceNames); + return createASTNode( _node, convertJsonToASTNode(member(_node, "expression")), - memberAsASTString(_node, "memberName") + memberAsASTString(_node, "memberName"), + std::move(memberLocation) ); } @@ -1073,6 +1118,9 @@ Visibility ASTJsonImporter::visibility(Json::Value const& _node) return Visibility::External; else astAssert(false, "Unknown visibility declaration"); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + util::unreachable(); } VariableDeclaration::Location ASTJsonImporter::location(Json::Value const& _node) @@ -1092,6 +1140,9 @@ VariableDeclaration::Location ASTJsonImporter::location(Json::Value const& _node return VariableDeclaration::Location::CallData; else astAssert(false, "Unknown location declaration"); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + util::unreachable(); } Literal::SubDenomination ASTJsonImporter::subdenomination(Json::Value const& _node) @@ -1125,6 +1176,9 @@ Literal::SubDenomination ASTJsonImporter::subdenomination(Json::Value const& _no return Literal::SubDenomination::Year; else astAssert(false, "Unknown subdenomination"); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + util::unreachable(); } StateMutability ASTJsonImporter::stateMutability(Json::Value const& _node) @@ -1142,6 +1196,9 @@ StateMutability ASTJsonImporter::stateMutability(Json::Value const& _node) return StateMutability::Payable; else astAssert(false, "Unknown stateMutability"); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + util::unreachable(); } } diff --git a/libsolidity/ast/ASTJsonImporter.h b/libsolidity/ast/ASTJsonImporter.h index 4566a58a4..1216d29b1 100644 --- a/libsolidity/ast/ASTJsonImporter.h +++ b/libsolidity/ast/ASTJsonImporter.h @@ -59,6 +59,7 @@ private: ASTPointer createASTNode(Json::Value const& _node, Args&&... _args); /// @returns the sourceLocation-object created from the string in the JSON node langutil::SourceLocation const createSourceLocation(Json::Value const& _node); + std::optional> createSourceLocations(Json::Value const& _node) const; /// Creates an ASTNode for a given JSON-ast of unknown type /// @returns Pointer to a new created ASTNode ASTPointer convertJsonToASTNode(Json::Value const& _ast); diff --git a/libsolidity/ast/ASTUtils.cpp b/libsolidity/ast/ASTUtils.cpp index 2b7ea7427..27c0833d2 100644 --- a/libsolidity/ast/ASTUtils.cpp +++ b/libsolidity/ast/ASTUtils.cpp @@ -85,4 +85,14 @@ VariableDeclaration const* rootConstVariableDeclaration(VariableDeclaration cons return rootDecl; } +Expression const* resolveOuterUnaryTuples(Expression const* _expr) +{ + while (auto const* tupleExpression = dynamic_cast(_expr)) + if (tupleExpression->components().size() == 1) + _expr = tupleExpression->components().front().get(); + else + break; + return _expr; +} + } diff --git a/libsolidity/ast/ASTUtils.h b/libsolidity/ast/ASTUtils.h index 2bfbb8fe9..f6e3f0641 100644 --- a/libsolidity/ast/ASTUtils.h +++ b/libsolidity/ast/ASTUtils.h @@ -38,4 +38,8 @@ bool isConstantVariableRecursive(VariableDeclaration const& _varDecl); /// Returns the innermost AST node that covers the given location or nullptr if not found. ASTNode const* locateInnermostASTNode(int _offsetInFile, SourceUnit const& _sourceUnit); +/// @returns @a _expr itself, in case it is not a unary tuple expression. Otherwise it descends recursively +/// into unary tuples and returns the contained expression. +Expression const* resolveOuterUnaryTuples(Expression const* _expr); + } diff --git a/libsolidity/ast/TypeProvider.cpp b/libsolidity/ast/TypeProvider.cpp index 97d230d2e..91d1da4be 100644 --- a/libsolidity/ast/TypeProvider.cpp +++ b/libsolidity/ast/TypeProvider.cpp @@ -404,7 +404,7 @@ TupleType const* TypeProvider::tuple(vector members) if (members.empty()) return &m_emptyTuple; - return createAndGet(move(members)); + return createAndGet(std::move(members)); } ReferenceType const* TypeProvider::withLocation(ReferenceType const* _type, DataLocation _location, bool _isPointer) diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 32ef5f4ea..a1e447ca8 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -110,6 +110,14 @@ util::Result transformParametersToExternal(TypePointers const& _pa return transformed; } +string toStringInParentheses(TypePointers const& _types, bool _withoutDataLocation) +{ + return '(' + util::joinHumanReadable( + _types | ranges::views::transform([&](auto const* _type) { return _type->toString(_withoutDataLocation); }), + "," + ) + ')'; +} + } MemberList::Member::Member(Declaration const* _declaration, Type const* _type): @@ -117,7 +125,7 @@ MemberList::Member::Member(Declaration const* _declaration, Type const* _type): {} MemberList::Member::Member(Declaration const* _declaration, Type const* _type, string _name): - name(move(_name)), + name(std::move(_name)), type(_type), declaration(_declaration) { @@ -297,7 +305,7 @@ MemberList const& Type::members(ASTNode const* _currentScope) const MemberList::MemberMap members = nativeMembers(_currentScope); if (_currentScope) members += boundFunctions(*this, *_currentScope); - m_members[_currentScope] = make_unique(move(members)); + m_members[_currentScope] = make_unique(std::move(members)); } return *m_members[_currentScope]; } @@ -1785,7 +1793,7 @@ vector> ArrayType::makeStackItems() const solAssert(false, ""); } -string ArrayType::toString(bool _short) const +string ArrayType::toString(bool _withoutDataLocation) const { string ret; if (isString()) @@ -1794,16 +1802,34 @@ string ArrayType::toString(bool _short) const ret = "bytes"; else { - ret = baseType()->toString(_short) + "["; + ret = baseType()->toString(_withoutDataLocation) + "["; if (!isDynamicallySized()) ret += length().str(); ret += "]"; } - if (!_short) + if (!_withoutDataLocation) ret += " " + stringForReferencePart(); return ret; } +string ArrayType::humanReadableName() const +{ + string ret; + if (isString()) + ret = "string"; + else if (isByteArrayOrString()) + ret = "bytes"; + else + { + ret = baseType()->toString(true) + "["; + if (!isDynamicallySized()) + ret += length().str(); + ret += "]"; + } + ret += " " + stringForReferencePart(); + return ret; +} + string ArrayType::canonicalName() const { string ret; @@ -1986,9 +2012,14 @@ bool ArraySliceType::operator==(Type const& _other) const return false; } -string ArraySliceType::toString(bool _short) const +string ArraySliceType::toString(bool _withoutDataLocation) const { - return m_arrayType.toString(_short) + " slice"; + return m_arrayType.toString(_withoutDataLocation) + " slice"; +} + +string ArraySliceType::humanReadableName() const +{ + return m_arrayType.humanReadableName() + " slice"; } Type const* ArraySliceType::mobileType() const @@ -2252,10 +2283,10 @@ bool StructType::containsNestedMapping() const return m_struct.annotation().containsNestedMapping.value(); } -string StructType::toString(bool _short) const +string StructType::toString(bool _withoutDataLocation) const { string ret = "struct " + *m_struct.annotation().canonicalName; - if (!_short) + if (!_withoutDataLocation) ret += " " + stringForReferencePart(); return ret; } @@ -2607,7 +2638,7 @@ bool UserDefinedValueType::operator==(Type const& _other) const return other.definition() == definition(); } -string UserDefinedValueType::toString(bool /* _short */) const +string UserDefinedValueType::toString(bool /* _withoutDataLocation */) const { return *definition().annotation().canonicalName; } @@ -2655,13 +2686,24 @@ bool TupleType::operator==(Type const& _other) const return false; } -string TupleType::toString(bool _short) const +string TupleType::toString(bool _withoutDataLocation) const { if (components().empty()) return "tuple()"; string str = "tuple("; for (auto const& t: components()) - str += (t ? t->toString(_short) : "") + ","; + str += (t ? t->toString(_withoutDataLocation) : "") + ","; + str.pop_back(); + return str + ")"; +} + +string TupleType::humanReadableName() const +{ + if (components().empty()) + return "tuple()"; + string str = "tuple("; + for (auto const& t: components()) + str += (t ? t->humanReadableName() : "") + ","; str.pop_back(); return str + ")"; } @@ -2699,7 +2741,7 @@ Type const* TupleType::mobileType() const else mobiles.push_back(nullptr); } - return TypeProvider::tuple(move(mobiles)); + return TypeProvider::tuple(std::move(mobiles)); } FunctionType::FunctionType(FunctionDefinition const& _function, Kind _kind): @@ -3094,7 +3136,20 @@ string FunctionType::canonicalName() const return "function"; } -string FunctionType::toString(bool _short) const +string FunctionType::humanReadableName() const +{ + switch (m_kind) + { + case Kind::Error: + return "error " + m_declaration->name() + toStringInParentheses(m_parameterTypes, /* _withoutDataLocation */ true); + case Kind::Event: + return "event " + m_declaration->name() + toStringInParentheses(m_parameterTypes, /* _withoutDataLocation */ true); + default: + return toString(/* _withoutDataLocation */ false); + } +} + +string FunctionType::toString(bool _withoutDataLocation) const { string name = "function "; if (m_kind == Kind::Declaration) @@ -3105,20 +3160,15 @@ string FunctionType::toString(bool _short) const name += *contract->annotation().canonicalName + "."; name += functionDefinition->name(); } - name += '('; - for (auto it = m_parameterTypes.begin(); it != m_parameterTypes.end(); ++it) - name += (*it)->toString(_short) + (it + 1 == m_parameterTypes.end() ? "" : ","); - name += ")"; + name += toStringInParentheses(m_parameterTypes, _withoutDataLocation); if (m_stateMutability != StateMutability::NonPayable) name += " " + stateMutabilityToString(m_stateMutability); if (m_kind == Kind::External) name += " external"; if (!m_returnParameterTypes.empty()) { - name += " returns ("; - for (auto it = m_returnParameterTypes.begin(); it != m_returnParameterTypes.end(); ++it) - name += (*it)->toString(_short) + (it + 1 == m_returnParameterTypes.end() ? "" : ","); - name += ")"; + name += " returns "; + name += toStringInParentheses(m_returnParameterTypes, _withoutDataLocation); } return name; } @@ -3339,6 +3389,12 @@ MemberList::MemberMap FunctionType::nativeMembers(ASTNode const* _scope) const } case Kind::Error: return {{"selector", TypeProvider::fixedBytes(4)}}; + case Kind::Event: + { + if (!(dynamic_cast(declaration()).isAnonymous())) + return {{"selector", TypeProvider::fixedBytes(32)}}; + return MemberList::MemberMap(); + } default: return MemberList::MemberMap(); } @@ -3704,9 +3760,9 @@ bool MappingType::operator==(Type const& _other) const return *other.m_keyType == *m_keyType && *other.m_valueType == *m_valueType; } -string MappingType::toString(bool _short) const +string MappingType::toString(bool _withoutDataLocation) const { - return "mapping(" + keyType()->toString(_short) + " => " + valueType()->toString(_short) + ")"; + return "mapping(" + keyType()->toString(_withoutDataLocation) + " => " + valueType()->toString(_withoutDataLocation) + ")"; } string MappingType::canonicalName() const @@ -3931,11 +3987,11 @@ bool ModifierType::operator==(Type const& _other) const return true; } -string ModifierType::toString(bool _short) const +string ModifierType::toString(bool _withoutDataLocation) const { string name = "modifier ("; for (auto it = m_parameterTypes.begin(); it != m_parameterTypes.end(); ++it) - name += (*it)->toString(_short) + (it + 1 == m_parameterTypes.end() ? "" : ","); + name += (*it)->toString(_withoutDataLocation) + (it + 1 == m_parameterTypes.end() ? "" : ","); return name + ")"; } @@ -4131,7 +4187,7 @@ MemberList::MemberMap MagicType::nativeMembers(ASTNode const*) const return {}; } -string MagicType::toString(bool _short) const +string MagicType::toString(bool _withoutDataLocation) const { switch (m_kind) { @@ -4145,7 +4201,7 @@ string MagicType::toString(bool _short) const return "abi"; case Kind::MetaType: solAssert(m_typeArgument, ""); - return "type(" + m_typeArgument->toString(_short) + ")"; + return "type(" + m_typeArgument->toString(_withoutDataLocation) + ")"; } solAssert(false, "Unknown kind of magic."); return {}; diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 9b3080769..553af6c7d 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -335,10 +335,11 @@ public: return members(_currentScope).memberType(_name); } - virtual std::string toString(bool _short) const = 0; + virtual std::string toString(bool _withoutDataLocation) const = 0; std::string toString() const { return toString(false); } /// @returns the canonical name of this type for use in library function signatures. virtual std::string canonicalName() const { return toString(true); } + virtual std::string humanReadableName() const { return toString(); } /// @returns the signature of this type in external functions, i.e. `uint256` for integers /// or `(uint256,bytes8)[2]` for an array of structs. If @a _structsByName, /// structs are given by canonical name like `ContractName.StructName[2]`. @@ -427,7 +428,7 @@ public: MemberList::MemberMap nativeMembers(ASTNode const*) const override; - std::string toString(bool _short) const override; + std::string toString(bool _withoutDataLocation) const override; std::string canonicalName() const override; u256 literalValue(Literal const* _literal) const override; @@ -470,7 +471,7 @@ public: bool isValueType() const override { return true; } bool nameable() const override { return true; } - std::string toString(bool _short) const override; + std::string toString(bool _withoutDataLocation) const override; Type const* encodingType() const override { return this; } TypeResult interfaceType(bool) const override { return this; } @@ -517,7 +518,7 @@ public: bool isValueType() const override { return true; } bool nameable() const override { return true; } - std::string toString(bool _short) const override; + std::string toString(bool _withoutDataLocation) const override; Type const* encodingType() const override { return this; } TypeResult interfaceType(bool) const override { return this; } @@ -567,7 +568,7 @@ public: bool canBeStored() const override { return false; } - std::string toString(bool _short) const override; + std::string toString(bool _withoutDataLocation) const override; u256 literalValue(Literal const* _literal) const override; Type const* mobileType() const override; @@ -831,7 +832,8 @@ public: bool containsNestedMapping() const override { return m_baseType->containsNestedMapping(); } bool nameable() const override { return true; } - std::string toString(bool _short) const override; + std::string toString(bool _withoutDataLocation) const override; + std::string humanReadableName() const override; std::string canonicalName() const override; std::string signatureInExternalFunction(bool _structsByName) const override; MemberList::MemberMap nativeMembers(ASTNode const* _currentScope) const override; @@ -895,7 +897,8 @@ public: unsigned calldataEncodedTailSize() const override { return 32; } bool isDynamicallySized() const override { return true; } bool isDynamicallyEncoded() const override { return true; } - std::string toString(bool _short) const override; + std::string toString(bool _withoutDataLocation) const override; + std::string humanReadableName() const override; Type const* mobileType() const override; BoolResult validForLocation(DataLocation _loc) const override { return m_arrayType.validForLocation(_loc); } @@ -939,7 +942,7 @@ public: bool leftAligned() const override { solAssert(!isSuper(), ""); return false; } bool isValueType() const override { return !isSuper(); } bool nameable() const override { return !isSuper(); } - std::string toString(bool _short) const override; + std::string toString(bool _withoutDataLocation) const override; std::string canonicalName() const override; MemberList::MemberMap nativeMembers(ASTNode const* _currentScope) const override; @@ -1001,7 +1004,7 @@ public: u256 storageSize() const override; bool containsNestedMapping() const override; bool nameable() const override { return true; } - std::string toString(bool _short) const override; + std::string toString(bool _withoutDataLocation) const override; MemberList::MemberMap nativeMembers(ASTNode const* _currentScope) const override; @@ -1063,7 +1066,7 @@ public: } unsigned storageBytes() const override; bool leftAligned() const override { return false; } - std::string toString(bool _short) const override; + std::string toString(bool _withoutDataLocation) const override; std::string canonicalName() const override; bool isValueType() const override { return true; } bool nameable() const override { return true; } @@ -1150,7 +1153,7 @@ public: return false; } - std::string toString(bool _short) const override; + std::string toString(bool _withoutDataLocation) const override; std::string canonicalName() const override; std::string signatureInExternalFunction(bool) const override { solAssert(false, ""); } @@ -1176,7 +1179,8 @@ public: std::string richIdentifier() const override; bool operator==(Type const& _other) const override; TypeResult binaryOperatorResult(Token, Type const*) const override { return nullptr; } - std::string toString(bool) const override; + std::string toString(bool _withoutDataLocation) const override; + std::string humanReadableName() const override; bool canBeStored() const override { return false; } u256 storageSize() const override; bool hasSimpleZeroValueInMemory() const override { return false; } @@ -1378,7 +1382,8 @@ public: TypeResult unaryOperatorResult(Token _operator) const override; TypeResult binaryOperatorResult(Token, Type const*) const override; std::string canonicalName() const override; - std::string toString(bool _short) const override; + std::string humanReadableName() const override; + std::string toString(bool _withoutDataLocation) const override; unsigned calldataEncodedSize(bool _padded) const override; bool canBeStored() const override { return m_kind == Kind::Internal || m_kind == Kind::External; } u256 storageSize() const override; @@ -1512,7 +1517,7 @@ public: std::string richIdentifier() const override; bool operator==(Type const& _other) const override; - std::string toString(bool _short) const override; + std::string toString(bool _withoutDataLocation) const override; std::string canonicalName() const override; bool containsNestedMapping() const override { return true; } TypeResult binaryOperatorResult(Token, Type const*) const override { return nullptr; } @@ -1553,7 +1558,7 @@ public: bool canBeStored() const override { return false; } u256 storageSize() const override; bool hasSimpleZeroValueInMemory() const override { solAssert(false, ""); } - std::string toString(bool _short) const override { return "type(" + m_actualType->toString(_short) + ")"; } + std::string toString(bool _withoutDataLocation) const override { return "type(" + m_actualType->toString(_withoutDataLocation) + ")"; } MemberList::MemberMap nativeMembers(ASTNode const* _currentScope) const override; BoolResult isExplicitlyConvertibleTo(Type const& _convertTo) const override; @@ -1580,7 +1585,7 @@ public: bool hasSimpleZeroValueInMemory() const override { solAssert(false, ""); } std::string richIdentifier() const override; bool operator==(Type const& _other) const override; - std::string toString(bool _short) const override; + std::string toString(bool _withoutDataLocation) const override; protected: std::vector> makeStackItems() const override { return {}; } private: @@ -1606,7 +1611,7 @@ public: bool hasSimpleZeroValueInMemory() const override { solAssert(false, ""); } MemberList::MemberMap nativeMembers(ASTNode const*) const override; - std::string toString(bool _short) const override; + std::string toString(bool _withoutDataLocation) const override; protected: std::vector> makeStackItems() const override { return {}; } @@ -1645,7 +1650,7 @@ public: bool hasSimpleZeroValueInMemory() const override { solAssert(false, ""); } MemberList::MemberMap nativeMembers(ASTNode const*) const override; - std::string toString(bool _short) const override; + std::string toString(bool _withoutDataLocation) const override; Kind kind() const { return m_kind; } diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp index d24dfc078..c92525f21 100644 --- a/libsolidity/codegen/ABIFunctions.cpp +++ b/libsolidity/codegen/ABIFunctions.cpp @@ -468,7 +468,8 @@ string ABIFunctions::abiEncodingFunctionCalldataArrayWithoutCleanup( _to.identifier() + _options.toFunctionNameSuffix(); return createFunction(functionName, [&]() { - bool needsPadding = _options.padded && fromArrayType.isByteArrayOrString(); + bool bytesOrString = fromArrayType.isByteArrayOrString(); + bool needsPadding = _options.padded && bytesOrString; if (fromArrayType.isDynamicallySized()) { Whiskers templ(R"( @@ -498,7 +499,7 @@ string ABIFunctions::abiEncodingFunctionCalldataArrayWithoutCleanup( ); templ("readableTypeNameFrom", _from.toString(true)); templ("readableTypeNameTo", _to.toString(true)); - templ("copyFun", m_utils.copyToMemoryFunction(true)); + templ("copyFun", m_utils.copyToMemoryFunction(true, /*cleanup*/bytesOrString)); templ("lengthPadded", needsPadding ? m_utils.roundUpFunction() + "(length)" : "length"); return templ.render(); } @@ -514,7 +515,7 @@ string ABIFunctions::abiEncodingFunctionCalldataArrayWithoutCleanup( templ("functionName", functionName); templ("readableTypeNameFrom", _from.toString(true)); templ("readableTypeNameTo", _to.toString(true)); - templ("copyFun", m_utils.copyToMemoryFunction(true)); + templ("copyFun", m_utils.copyToMemoryFunction(true, /*cleanup*/bytesOrString)); templ("byteLength", toCompactHexWithPrefix(fromArrayType.length() * fromArrayType.calldataStride())); return templ.render(); } @@ -662,7 +663,7 @@ string ABIFunctions::abiEncodingFunctionMemoryByteArray( templ("functionName", functionName); templ("lengthFun", m_utils.arrayLengthFunction(_from)); templ("storeLength", arrayStoreLengthForEncodingFunction(_to, _options)); - templ("copyFun", m_utils.copyToMemoryFunction(false)); + templ("copyFun", m_utils.copyToMemoryFunction(false, /*cleanup*/true)); templ("lengthPadded", _options.padded ? m_utils.roundUpFunction() + "(length)" : "length"); return templ.render(); }); @@ -699,7 +700,7 @@ string ABIFunctions::abiEncodingFunctionCompactStorageArray( case 0 { // short byte array mstore(pos, and(slotValue, not(0xff))) - ret := add(pos, ) + ret := add(pos, mul(, iszero(iszero(length)))) } case 1 { // long byte array @@ -1296,7 +1297,7 @@ string ABIFunctions::abiDecodingFunctionByteArrayAvailableLength(ArrayType const templ("functionName", functionName); templ("allocate", m_utils.allocationFunction()); templ("allocationSize", m_utils.arrayAllocationSizeFunction(_type)); - templ("copyToMemFun", m_utils.copyToMemoryFunction(!_fromMemory)); + templ("copyToMemFun", m_utils.copyToMemoryFunction(!_fromMemory, /*cleanup*/true)); return templ.render(); }); } diff --git a/libsolidity/codegen/ABIFunctions.h b/libsolidity/codegen/ABIFunctions.h index 07088aa3b..b7f7f8ae5 100644 --- a/libsolidity/codegen/ABIFunctions.h +++ b/libsolidity/codegen/ABIFunctions.h @@ -243,7 +243,7 @@ private: std::string abiDecodingFunctionArray(ArrayType const& _type, bool _fromMemory); /// Part of @a abiDecodingFunction for calldata array types. std::string abiDecodingFunctionCalldataArray(ArrayType const& _type); - /// Part of @a abiDecodingFunctionArrayWithAvailableLength + /// Part of @a abiDecodingFunctionArrayAvailableLength std::string abiDecodingFunctionByteArrayAvailableLength(ArrayType const& _type, bool _fromMemory); /// Part of @a abiDecodingFunction for calldata struct types. std::string abiDecodingFunctionCalldataStruct(StructType const& _type); diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp index d2691c877..9b95463ba 100644 --- a/libsolidity/codegen/ArrayUtils.cpp +++ b/libsolidity/codegen/ArrayUtils.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -49,9 +50,8 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons // stack layout: [source_ref] [source length] target_ref (top) solAssert(_targetType.location() == DataLocation::Storage, ""); - Type const* uint256 = TypeProvider::uint256(); - Type const* targetBaseType = _targetType.isByteArrayOrString() ? uint256 : _targetType.baseType(); - Type const* sourceBaseType = _sourceType.isByteArrayOrString() ? uint256 : _sourceType.baseType(); + Type const* targetBaseType = _targetType.baseType(); + Type const* sourceBaseType = _sourceType.baseType(); // TODO unroll loop for small sizes @@ -67,7 +67,38 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons for (unsigned i = _sourceType.sizeOnStack(); i > 0; --i) m_context << swapInstruction(i); // stack: target_ref source_ref [source_length] - // stack: target_ref source_ref [source_length] + + if (_targetType.isByteArrayOrString()) + { + // stack: target_ref source_ref [source_length] + if (fromCalldata && _sourceType.isDynamicallySized()) + { + // stack: target_ref source_ref source_length + m_context << Instruction::SWAP1; + // stack: target_ref source_length source_ref + m_context << Instruction::DUP3; + // stack: target_ref source_length source_ref target_ref + m_context.callYulFunction( + m_context.utilFunctions().copyByteArrayToStorageFunction(_sourceType, _targetType), + 3, + 0 + ); + } + else + { + // stack: target_ref source_ref + m_context << Instruction::DUP2; + // stack: target_ref source_ref target_ref + m_context.callYulFunction( + m_context.utilFunctions().copyByteArrayToStorageFunction(_sourceType, _targetType), + 2, + 0 + ); + } + // stack: target_ref + return; + } + // retrieve source length if (_sourceType.location() != DataLocation::CallData || !_sourceType.isDynamicallySized()) retrieveLength(_sourceType); // otherwise, length is already there @@ -96,10 +127,11 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons utils.retrieveLength(_targetType); // stack: target_ref source_ref source_length target_ref target_length if (_targetType.isDynamicallySized()) + { // store new target length - if (!_targetType.isByteArrayOrString()) - // Otherwise, length will be stored below. - _context << Instruction::DUP3 << Instruction::DUP3 << Instruction::SSTORE; + solAssert(!_targetType.isByteArrayOrString()); + _context << Instruction::DUP3 << Instruction::DUP3 << Instruction::SSTORE; + } if (sourceBaseType->category() == Type::Category::Mapping) { solAssert(targetBaseType->category() == Type::Category::Mapping, ""); @@ -124,51 +156,7 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons // stack: target_ref target_data_end source_length target_data_pos source_ref evmasm::AssemblyItem copyLoopEndWithoutByteOffset = _context.newTag(); - - // special case for short byte arrays: Store them together with their length. - if (_targetType.isByteArrayOrString()) - { - // stack: target_ref target_data_end source_length target_data_pos source_ref - _context << Instruction::DUP3; - evmasm::AssemblyItem nonEmptyByteArray = _context.appendConditionalJump(); - // Empty source, just zero out the main slot. - _context << u256(0) << Instruction::DUP6 << Instruction::SSTORE; - _context.appendJumpTo(copyLoopEndWithoutByteOffset); - - _context << nonEmptyByteArray; - // Non-empty source. - // stack: target_ref target_data_end source_length target_data_pos source_ref - _context << Instruction::DUP3 << u256(31) << Instruction::LT; - evmasm::AssemblyItem longByteArray = _context.appendConditionalJump(); - // store the short byte array - solAssert(_sourceType.isByteArrayOrString(), ""); - if (_sourceType.location() == DataLocation::Storage) - { - // just copy the slot, it contains length and data - _context << Instruction::DUP1 << Instruction::SLOAD; - _context << Instruction::DUP6 << Instruction::SSTORE; - } - else - { - _context << Instruction::DUP1; - CompilerUtils(_context).loadFromMemoryDynamic(*sourceBaseType, fromCalldata, true, false); - // stack: target_ref target_data_end source_length target_data_pos source_ref value - // clear the lower-order byte - which will hold the length - _context << u256(0xff) << Instruction::NOT << Instruction::AND; - // fetch the length and shift it left by one - _context << Instruction::DUP4 << Instruction::DUP1 << Instruction::ADD; - // combine value and length and store them - _context << Instruction::OR << Instruction::DUP6 << Instruction::SSTORE; - } - // end of special case, jump right into cleaning target data area - _context.appendJumpTo(copyLoopEndWithoutByteOffset); - _context << longByteArray; - // Store length (2*length+1) - _context << Instruction::DUP3 << Instruction::DUP1 << Instruction::ADD; - _context << u256(1) << Instruction::ADD; - _context << Instruction::DUP6 << Instruction::SSTORE; - } - + solAssert(!_targetType.isByteArrayOrString()); // skip copying if source length is zero _context << Instruction::DUP3 << Instruction::ISZERO; _context.appendConditionalJumpTo(copyLoopEndWithoutByteOffset); @@ -242,7 +230,7 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons assertThrow( 2 + byteOffsetSize + sourceBaseType->sizeOnStack() <= 16, StackTooDeepError, - "Stack too deep, try removing local variables." + util::stackTooDeepString ); // fetch target storage reference _context << dupInstruction(2 + byteOffsetSize + sourceBaseType->sizeOnStack()); diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index 99b87e5a7..f1cc5b6dd 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -43,6 +43,7 @@ #include #include +#include #include #include @@ -198,7 +199,7 @@ void CompilerContext::appendYulUtilityFunctions(OptimiserSettings const& _optimi if (!code.empty()) { appendInlineAssembly( - yul::reindent("{\n" + move(code) + "\n}"), + yul::reindent("{\n" + std::move(code) + "\n}"), {}, m_externallyUsedYulFunctions, true, @@ -422,7 +423,7 @@ void CompilerContext::appendInlineAssembly( BOOST_THROW_EXCEPTION( StackTooDeepError() << errinfo_sourceLocation(nativeLocationOf(_identifier)) << - util::errinfo_comment("Stack too deep (" + to_string(stackDiff) + "), try removing local variables.") + util::errinfo_comment(util::stackTooDeepString) ); if (_context == yul::IdentifierContext::RValue) _assembly.appendInstruction(dupInstruction(static_cast(stackDiff))); @@ -484,6 +485,7 @@ void CompilerContext::appendInlineAssembly( obj.code = parserResult; obj.analysisInfo = make_shared(analysisInfo); + solAssert(!dialect.providesObjectAccess()); optimizeYul(obj, dialect, _optimiserSettings, externallyUsedIdentifiers); if (_system) diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index 0ad37241b..32b1f1bba 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -31,6 +31,7 @@ #include #include #include +#include using namespace std; using namespace solidity; @@ -476,7 +477,7 @@ void CompilerUtils::encodeToMemory( assertThrow( (argSize + dynPointers) < 16, StackTooDeepError, - "Stack too deep, try using fewer variables." + util::stackTooDeepString ); } else @@ -537,7 +538,7 @@ void CompilerUtils::encodeToMemory( assertThrow( (2 + dynPointers) <= 16, StackTooDeepError, - "Stack too deep(" + to_string(2 + dynPointers) + "), try using fewer variables." + util::stackTooDeepString ); m_context << dupInstruction(2 + dynPointers) << Instruction::DUP2; m_context << Instruction::SUB; @@ -1418,7 +1419,7 @@ void CompilerUtils::moveToStackVariable(VariableDeclaration const& _variable) BOOST_THROW_EXCEPTION( StackTooDeepError() << errinfo_sourceLocation(_variable.location()) << - util::errinfo_comment("Stack too deep, try removing local variables.") + util::errinfo_comment(util::stackTooDeepString) ); for (unsigned i = 0; i < size; ++i) m_context << swapInstruction(stackPosition - size + 1) << Instruction::POP; @@ -1429,7 +1430,7 @@ void CompilerUtils::copyToStackTop(unsigned _stackDepth, unsigned _itemSize) assertThrow( _stackDepth <= 16, StackTooDeepError, - "Stack too deep, try removing local variables." + util::stackTooDeepString ); for (unsigned i = 0; i < _itemSize; ++i) m_context << dupInstruction(_stackDepth); @@ -1455,7 +1456,7 @@ void CompilerUtils::rotateStackUp(unsigned _items) assertThrow( _items - 1 <= 16, StackTooDeepError, - "Stack too deep, try removing local variables." + util::stackTooDeepString ); for (unsigned i = 1; i < _items; ++i) m_context << swapInstruction(_items - i); @@ -1466,7 +1467,7 @@ void CompilerUtils::rotateStackDown(unsigned _items) assertThrow( _items - 1 <= 16, StackTooDeepError, - "Stack too deep, try removing local variables." + util::stackTooDeepString ); for (unsigned i = 1; i < _items; ++i) m_context << swapInstruction(i); diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index d2c71e2af..a89dbb21b 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -48,6 +48,7 @@ #include #include +#include #include @@ -672,7 +673,7 @@ bool ContractCompiler::visit(FunctionDefinition const& _function) BOOST_THROW_EXCEPTION( StackTooDeepError() << errinfo_sourceLocation(_function.location()) << - util::errinfo_comment("Stack too deep, try removing local variables.") + util::errinfo_comment(util::stackTooDeepString) ); while (!stackLayout.empty() && stackLayout.back() != static_cast(stackLayout.size() - 1)) if (stackLayout.back() < 0) @@ -842,7 +843,7 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly) BOOST_THROW_EXCEPTION( StackTooDeepError() << errinfo_sourceLocation(_inlineAssembly.location()) << - util::errinfo_comment("Stack too deep, try removing local variables.") + util::errinfo_comment(util::stackTooDeepString) ); _assembly.appendInstruction(dupInstruction(stackDiff)); } @@ -916,7 +917,7 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly) BOOST_THROW_EXCEPTION( StackTooDeepError() << errinfo_sourceLocation(_inlineAssembly.location()) << - util::errinfo_comment("Stack too deep(" + to_string(stackDiff) + "), try removing local variables.") + util::errinfo_comment(util::stackTooDeepString) ); _assembly.appendInstruction(swapInstruction(stackDiff)); _assembly.appendInstruction(Instruction::POP); @@ -1292,7 +1293,7 @@ bool ContractCompiler::visit(Return const& _return) Type const* expectedType; if (expression->annotation().type->category() == Type::Category::Tuple || types.size() != 1) - expectedType = TypeProvider::tuple(move(types)); + expectedType = TypeProvider::tuple(std::move(types)); else expectedType = types.front(); compileExpression(*expression, expectedType); diff --git a/libsolidity/codegen/ContractCompiler.h b/libsolidity/codegen/ContractCompiler.h index 74a2e3b5f..592b67039 100644 --- a/libsolidity/codegen/ContractCompiler.h +++ b/libsolidity/codegen/ContractCompiler.h @@ -36,7 +36,7 @@ namespace solidity::frontend /** * Code generator at the contract level. Can be used to generate code for exactly one contract - * either either in "runtime mode" or "creation mode". + * either in "runtime mode" or "creation mode". */ class ContractCompiler: private ASTConstVisitor { diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 21cb45e77..3ee824447 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -70,7 +71,7 @@ Type const* closestType(Type const* _type, Type const* _targetType, bool _isShif solAssert(tempComponents[i], ""); } } - return TypeProvider::tuple(move(tempComponents)); + return TypeProvider::tuple(std::move(tempComponents)); } else return _targetType->dataStoredIn(DataLocation::Storage) ? _type->mobileType() : _targetType; @@ -268,7 +269,7 @@ void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const& BOOST_THROW_EXCEPTION( StackTooDeepError() << errinfo_sourceLocation(_varDecl.location()) << - util::errinfo_comment("Stack too deep.") + util::errinfo_comment(util::stackTooDeepString) ); m_context << dupInstruction(retSizeOnStack + 1); m_context.appendJump(evmasm::AssemblyItem::JumpType::OutOfFunction); @@ -350,7 +351,7 @@ bool ExpressionCompiler::visit(Assignment const& _assignment) BOOST_THROW_EXCEPTION( StackTooDeepError() << errinfo_sourceLocation(_assignment.location()) << - util::errinfo_comment("Stack too deep, try removing local variables.") + util::errinfo_comment(util::stackTooDeepString) ); // value [lvalue_ref] updated_value for (unsigned i = 0; i < itemSize; ++i) @@ -390,7 +391,7 @@ bool ExpressionCompiler::visit(TupleExpression const& _tuple) if (_tuple.annotation().willBeWrittenTo) { solAssert(!!m_currentLValue, ""); - lvalues.push_back(move(m_currentLValue)); + lvalues.push_back(std::move(m_currentLValue)); } } else if (_tuple.annotation().willBeWrittenTo) @@ -398,9 +399,9 @@ bool ExpressionCompiler::visit(TupleExpression const& _tuple) if (_tuple.annotation().willBeWrittenTo) { if (_tuple.components().size() == 1) - m_currentLValue = move(lvalues[0]); + m_currentLValue = std::move(lvalues[0]); else - m_currentLValue = make_unique(m_context, move(lvalues)); + m_currentLValue = make_unique(m_context, std::move(lvalues)); } } return false; @@ -1601,9 +1602,14 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) { if (functionType->hasDeclaration()) { - m_context << functionType->externalIdentifier(); - /// need to store it as bytes4 - utils().leftShiftNumberOnStack(224); + if (functionType->kind() == FunctionType::Kind::Event) + m_context << u256(h256::Arith(util::keccak256(functionType->externalSignature()))); + else + { + m_context << functionType->externalIdentifier(); + /// need to store it as bytes4 + utils().leftShiftNumberOnStack(224); + } return false; } else if (auto const* expr = dynamic_cast(&_memberAccess.expression())) @@ -1774,9 +1780,13 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) if (member == "selector") { auto const& functionType = dynamic_cast(*_memberAccess.expression().annotation().type); + // all events should have already been caught by this stage + solAssert(!(functionType.kind() == FunctionType::Kind::Event)); + if (functionType.kind() == FunctionType::Kind::External) CompilerUtils(m_context).popStackSlots(functionType.sizeOnStack() - 2); m_context << Instruction::SWAP1 << Instruction::POP; + /// need to store it as bytes4 utils().leftShiftNumberOnStack(224); } diff --git a/libsolidity/codegen/ExpressionCompiler.h b/libsolidity/codegen/ExpressionCompiler.h index b583b8327..13e1e3106 100644 --- a/libsolidity/codegen/ExpressionCompiler.h +++ b/libsolidity/codegen/ExpressionCompiler.h @@ -151,7 +151,7 @@ void ExpressionCompiler::setLValue(Expression const& _expression, Arguments cons solAssert(!m_currentLValue, "Current LValue not reset before trying to set new one."); std::unique_ptr lvalue = std::make_unique(m_context, _arguments...); if (_expression.annotation().willBeWrittenTo) - m_currentLValue = move(lvalue); + m_currentLValue = std::move(lvalue); else lvalue->retrieveValue(_expression.location(), true); } diff --git a/libsolidity/codegen/LValue.cpp b/libsolidity/codegen/LValue.cpp index 379e9818b..2708d319d 100644 --- a/libsolidity/codegen/LValue.cpp +++ b/libsolidity/codegen/LValue.cpp @@ -28,6 +28,8 @@ #include #include +#include + using namespace std; using namespace solidity; using namespace solidity::evmasm; @@ -50,7 +52,7 @@ void StackVariable::retrieveValue(SourceLocation const& _location, bool) const BOOST_THROW_EXCEPTION( StackTooDeepError() << errinfo_sourceLocation(_location) << - util::errinfo_comment("Stack too deep, try removing local variables.") + util::errinfo_comment(util::stackTooDeepString) ); solAssert(stackPos + 1 >= m_size, "Size and stack pos mismatch."); for (unsigned i = 0; i < m_size; ++i) @@ -64,7 +66,7 @@ void StackVariable::storeValue(Type const&, SourceLocation const& _location, boo BOOST_THROW_EXCEPTION( StackTooDeepError() << errinfo_sourceLocation(_location) << - util::errinfo_comment("Stack too deep, try removing local variables.") + util::errinfo_comment(util::stackTooDeepString) ); else if (stackDiff > 0) for (unsigned i = 0; i < m_size; ++i) @@ -555,7 +557,7 @@ TupleObject::TupleObject( CompilerContext& _compilerContext, std::vector>&& _lvalues ): - LValue(_compilerContext), m_lvalues(move(_lvalues)) + LValue(_compilerContext), m_lvalues(std::move(_lvalues)) { } diff --git a/libsolidity/codegen/MultiUseYulFunctionCollector.cpp b/libsolidity/codegen/MultiUseYulFunctionCollector.cpp index 69d30c6c8..39df88449 100644 --- a/libsolidity/codegen/MultiUseYulFunctionCollector.cpp +++ b/libsolidity/codegen/MultiUseYulFunctionCollector.cpp @@ -33,7 +33,7 @@ using namespace solidity::util; string MultiUseYulFunctionCollector::requestedFunctions() { - string result = move(m_code); + string result = std::move(m_code); m_code.clear(); m_requestedFunctions.clear(); return result; @@ -47,7 +47,7 @@ string MultiUseYulFunctionCollector::createFunction(string const& _name, functio string fun = _creator(); solAssert(!fun.empty(), ""); solAssert(fun.find("function " + _name + "(") != string::npos, "Function not properly named."); - m_code += move(fun); + m_code += std::move(fun); } return _name; } diff --git a/libsolidity/codegen/YulUtilFunctions.cpp b/libsolidity/codegen/YulUtilFunctions.cpp index 23f41efd2..b66189f05 100644 --- a/libsolidity/codegen/YulUtilFunctions.cpp +++ b/libsolidity/codegen/YulUtilFunctions.cpp @@ -80,20 +80,25 @@ string YulUtilFunctions::splitExternalFunctionIdFunction() }); } -string YulUtilFunctions::copyToMemoryFunction(bool _fromCalldata) +string YulUtilFunctions::copyToMemoryFunction(bool _fromCalldata, bool _cleanup) { - string functionName = "copy_" + string(_fromCalldata ? "calldata" : "memory") + "_to_memory"; + string functionName = + "copy_"s + + (_fromCalldata ? "calldata"s : "memory"s) + + "_to_memory"s + + (_cleanup ? "_with_cleanup"s : ""s); + return m_functionCollector.createFunction(functionName, [&]() { if (_fromCalldata) { return Whiskers(R"( function (src, dst, length) { calldatacopy(dst, src, length) - // clear end - mstore(add(dst, length), 0) + mstore(add(dst, length), 0) } )") ("functionName", functionName) + ("cleanup", _cleanup) .render(); } else @@ -105,14 +110,11 @@ string YulUtilFunctions::copyToMemoryFunction(bool _fromCalldata) { mstore(add(dst, i), mload(add(src, i))) } - if gt(i, length) - { - // clear end - mstore(add(dst, length), 0) - } + mstore(add(dst, length), 0) } )") ("functionName", functionName) + ("cleanup", _cleanup) .render(); } }); @@ -615,25 +617,34 @@ string YulUtilFunctions::divide32CeilFunction() string YulUtilFunctions::overflowCheckedIntAddFunction(IntegerType const& _type) { string functionName = "checked_add_" + _type.identifier(); - // TODO: Consider to add a special case for unsigned 256-bit integers - // and use the following instead: - // sum := add(x, y) if lt(sum, x) { () } return m_functionCollector.createFunction(functionName, [&]() { return Whiskers(R"( function (x, y) -> sum { x := (x) y := (y) - - // overflow, if x >= 0 and y > (maxValue - x) - if and(iszero(slt(x, 0)), sgt(y, sub(, x))) { () } - // underflow, if x < 0 and y < (minValue - x) - if and(slt(x, 0), slt(y, sub(, x))) { () } - - // overflow, if x > (maxValue - y) - if gt(x, sub(, y)) { () } - sum := add(x, y) + + + // overflow, if x >= 0 and sum < y + // underflow, if x < 0 and sum >= y + if or( + and(iszero(slt(x, 0)), slt(sum, y)), + and(slt(x, 0), iszero(slt(sum, y))) + ) { () } + + if or( + sgt(sum, ), + slt(sum, ) + ) { () } + + + + if gt(x, sum) { () } + + if gt(sum, ) { () } + + } )") ("functionName", functionName) @@ -642,6 +653,7 @@ string YulUtilFunctions::overflowCheckedIntAddFunction(IntegerType const& _type) ("minValue", toCompactHexWithPrefix(u256(_type.minValue()))) ("cleanupFunction", cleanupFunction(_type)) ("panic", panicFunction(PanicCode::UnderOverflow)) + ("256bit", _type.numBits() == 256) .render(); }); } @@ -672,28 +684,46 @@ string YulUtilFunctions::overflowCheckedIntMulFunction(IntegerType const& _type) function (x, y) -> product { x := (x) y := (y) + let product_raw := mul(x, y) + product := (product_raw) - // overflow, if x > 0, y > 0 and x > (maxValue / y) - if and(and(sgt(x, 0), sgt(y, 0)), gt(x, div(, y))) { () } - // underflow, if x > 0, y < 0 and y < (minValue / x) - if and(and(sgt(x, 0), slt(y, 0)), slt(y, sdiv(, x))) { () } - // underflow, if x < 0, y > 0 and x < (minValue / y) - if and(and(slt(x, 0), sgt(y, 0)), slt(x, sdiv(, y))) { () } - // overflow, if x < 0, y < 0 and x < (maxValue / y) - if and(and(slt(x, 0), slt(y, 0)), slt(x, sdiv(, y))) { () } + + + // special case + if and(slt(x, 0), eq(y, )) { () } + + // overflow, if x != 0 and y != product/x + if iszero( + or( + iszero(x), + eq(y, sdiv(product, x)) + ) + ) { () } + + if iszero(eq(product, product_raw)) { () } + - // overflow, if x != 0 and y > (maxValue / x) - if and(iszero(iszero(x)), gt(y, div(, x))) { () } + + // overflow, if x != 0 and y != product/x + if iszero( + or( + iszero(x), + eq(y, div(product, x)) + ) + ) { () } + + if iszero(eq(product, product_raw)) { () } + - product := mul(x, y) } )") ("functionName", functionName) ("signed", _type.isSigned()) - ("maxValue", toCompactHexWithPrefix(u256(_type.maxValue()))) - ("minValue", toCompactHexWithPrefix(u256(_type.minValue()))) ("cleanupFunction", cleanupFunction(_type)) ("panic", panicFunction(PanicCode::UnderOverflow)) + ("minValue", toCompactHexWithPrefix(u256(_type.minValue()))) + ("256bit", _type.numBits() == 256) + ("gt128bit", _type.numBits() > 128) .render(); }); } @@ -795,15 +825,28 @@ string YulUtilFunctions::overflowCheckedIntSubFunction(IntegerType const& _type) function (x, y) -> diff { x := (x) y := (y) - - // underflow, if y >= 0 and x < (minValue + y) - if and(iszero(slt(y, 0)), slt(x, add(, y))) { () } - // overflow, if y < 0 and x > (maxValue + y) - if and(slt(y, 0), sgt(x, add(, y))) { () } - - if lt(x, y) { () } - diff := sub(x, y) + + + // underflow, if y >= 0 and diff > x + // overflow, if y < 0 and diff < x + if or( + and(iszero(slt(y, 0)), sgt(diff, x)), + and(slt(y, 0), slt(diff, x)) + ) { () } + + if or( + slt(diff, ), + sgt(diff, ) + ) { () } + + + + if gt(diff, x) { () } + + if gt(diff, ) { () } + + } )") ("functionName", functionName) @@ -812,6 +855,7 @@ string YulUtilFunctions::overflowCheckedIntSubFunction(IntegerType const& _type) ("minValue", toCompactHexWithPrefix(u256(_type.minValue()))) ("cleanupFunction", cleanupFunction(_type)) ("panic", panicFunction(PanicCode::UnderOverflow)) + ("256bit", _type.numBits() == 256) .render(); }); } @@ -1797,8 +1841,11 @@ string YulUtilFunctions::copyArrayToStorageFunction(ArrayType const& _fromType, if (_fromType.isByteArrayOrString()) return copyByteArrayToStorageFunction(_fromType, _toType); - if (_fromType.dataStoredIn(DataLocation::Storage) && _toType.baseType()->isValueType()) - return copyValueArrayStorageToStorageFunction(_fromType, _toType); + if (_toType.baseType()->isValueType()) + return copyValueArrayToStorageFunction(_fromType, _toType); + + solAssert(_toType.storageStride() == 32); + solAssert(!_fromType.baseType()->isValueType()); string functionName = "copy_array_to_storage_from_" + _fromType.identifier() + "_to_" + _toType.identifier(); return m_functionCollector.createFunction(functionName, [&](){ @@ -1812,43 +1859,30 @@ string YulUtilFunctions::copyArrayToStorageFunction(ArrayType const& _fromType, let srcPtr := (value) let elementSlot := (slot) - let elementOffset := 0 for { let i := 0 } lt(i, length) {i := add(i, 1)} { - let := + let := (value, srcPtr) srcPtr - - - := () - - let := (srcPtr) + let := (srcPtr) - let := srcPtr + let := srcPtr - (elementSlot, elementOffset, ) + (elementSlot, ) srcPtr := add(srcPtr, ) - - elementOffset := add(elementOffset, ) - if gt(elementOffset, sub(32, )) { - elementOffset := 0 - elementSlot := add(elementSlot, 1) - } - - elementSlot := add(elementSlot, ) - + elementSlot := add(elementSlot, ) } } )"); @@ -1870,16 +1904,15 @@ string YulUtilFunctions::copyArrayToStorageFunction(ArrayType const& _fromType, } templ("resizeArray", resizeArrayFunction(_toType)); templ("arrayLength",arrayLengthFunction(_fromType)); - templ("isValueType", _fromType.baseType()->isValueType()); templ("dstDataLocation", arrayDataAreaFunction(_toType)); if (fromMemory || (fromCalldata && _fromType.baseType()->isValueType())) - templ("readFromCalldataOrMemory", readFromMemoryOrCalldata(*_fromType.baseType(), fromCalldata)); - templ("elementValues", suffixedVariableNameList( - "elementValue_", + templ("readFromMemoryOrCalldata", readFromMemoryOrCalldata(*_fromType.baseType(), fromCalldata)); + templ("stackItems", suffixedVariableNameList( + "stackItem_", 0, _fromType.baseType()->stackItems().size() )); - templ("updateStorageValue", updateStorageValueFunction(*_fromType.baseType(), *_toType.baseType())); + templ("updateStorageValue", updateStorageValueFunction(*_fromType.baseType(), *_toType.baseType(), 0)); templ("srcStride", fromCalldata ? to_string(_fromType.calldataStride()) : @@ -1887,8 +1920,6 @@ string YulUtilFunctions::copyArrayToStorageFunction(ArrayType const& _fromType, to_string(_fromType.memoryStride()) : formatNumber(_fromType.baseType()->storageSize()) ); - templ("multipleItemsPerSlot", _toType.storageStride() <= 16); - templ("storageStride", to_string(_toType.storageStride())); templ("storageSize", _toType.baseType()->storageSize().str()); return templ.render(); @@ -1973,8 +2004,7 @@ string YulUtilFunctions::copyByteArrayToStorageFunction(ArrayType const& _fromTy }); } - -string YulUtilFunctions::copyValueArrayStorageToStorageFunction(ArrayType const& _fromType, ArrayType const& _toType) +string YulUtilFunctions::copyValueArrayToStorageFunction(ArrayType const& _fromType, ArrayType const& _toType) { solAssert(_fromType.baseType()->isValueType(), ""); solAssert(_toType.baseType()->isValueType(), ""); @@ -1982,7 +2012,6 @@ string YulUtilFunctions::copyValueArrayStorageToStorageFunction(ArrayType const& solAssert(!_fromType.isByteArrayOrString(), ""); solAssert(!_toType.isByteArrayOrString(), ""); - solAssert(_fromType.dataStoredIn(DataLocation::Storage), ""); solAssert(_toType.dataStoredIn(DataLocation::Storage), ""); solAssert(_fromType.storageStride() <= _toType.storageStride(), ""); @@ -1991,32 +2020,41 @@ string YulUtilFunctions::copyValueArrayStorageToStorageFunction(ArrayType const& string functionName = "copy_array_to_storage_from_" + _fromType.identifier() + "_to_" + _toType.identifier(); return m_functionCollector.createFunction(functionName, [&](){ Whiskers templ(R"( - function (dst, src) { + function (dst, src, len) { + if eq(dst, src) { leave } - let length := (src) + + let length := (src, len) // Make sure array length is sane if gt(length, 0xffffffffffffffff) { () } (dst, length) - let srcSlot := (src) + let srcPtr := (src) let dstSlot := (dst) let fullSlots := div(length, ) - let srcSlotValue := sload(srcSlot) + + let srcSlotValue := sload(srcPtr) let srcItemIndexInSlot := 0 + + for { let i := 0 } lt(i, fullSlots) { i := add(i, 1) } { let dstSlotValue := 0 - + dstSlotValue := (srcSlotValue) - - + + for { let j := 0 } lt(j, ) { j := add(j, 1) } { - let itemValue := ( + + let := ( (srcSlotValue, mul(, srcItemIndexInSlot)) ) - itemValue := (itemValue) + + let := (srcPtr) + + let itemValue := () dstSlotValue := (dstSlotValue, mul(, j), itemValue) @@ -2024,9 +2062,9 @@ string YulUtilFunctions::copyValueArrayStorageToStorageFunction(ArrayType const& itemValue - + } - + sstore(add(dstSlot, i), dstSlotValue) } @@ -2035,20 +2073,24 @@ string YulUtilFunctions::copyValueArrayStorageToStorageFunction(ArrayType const& let spill := sub(length, mul(fullSlots, )) if gt(spill, 0) { let dstSlotValue := 0 - + dstSlotValue := (srcSlotValue, mul(spill, )) - - + + for { let j := 0 } lt(j, spill) { j := add(j, 1) } { - let itemValue := ( + + let := ( (srcSlotValue, mul(, srcItemIndexInSlot)) ) - itemValue := (itemValue) + + let := (srcPtr) + + let itemValue := () dstSlotValue := (dstSlotValue, mul(, j), itemValue) - + } - + sstore(add(dstSlot, fullSlots), dstSlotValue) } @@ -2056,26 +2098,37 @@ string YulUtilFunctions::copyValueArrayStorageToStorageFunction(ArrayType const& )"); if (_fromType.dataStoredIn(DataLocation::Storage)) solAssert(!_fromType.isValueType(), ""); + + bool fromCalldata = _fromType.dataStoredIn(DataLocation::CallData); + bool fromStorage = _fromType.dataStoredIn(DataLocation::Storage); templ("functionName", functionName); templ("resizeArray", resizeArrayFunction(_toType)); templ("arrayLength", arrayLengthFunction(_fromType)); templ("panic", panicFunction(PanicCode::ResourceError)); + templ("isFromDynamicCalldata", _fromType.isDynamicallySized() && fromCalldata); + templ("isFromStorage", fromStorage); + templ("readFromMemoryOrCalldata", readFromMemoryOrCalldata(*_fromType.baseType(), fromCalldata)); templ("srcDataLocation", arrayDataAreaFunction(_fromType)); templ("dstDataLocation", arrayDataAreaFunction(_toType)); templ("srcStride", to_string(_fromType.storageStride())); + templ("stackItems", suffixedVariableNameList( + "stackItem_", + 0, + _fromType.baseType()->stackItems().size() + )); unsigned itemsPerSlot = 32 / _toType.storageStride(); templ("itemsPerSlot", to_string(itemsPerSlot)); templ("multipleItemsPerSlotDst", itemsPerSlot > 1); - bool sameType = *_fromType.baseType() == *_toType.baseType(); + bool sameTypeFromStorage = fromStorage && (*_fromType.baseType() == *_toType.baseType()); if (auto functionType = dynamic_cast(_fromType.baseType())) { solAssert(functionType->equalExcludingStateMutability( dynamic_cast(*_toType.baseType()) )); - sameType = true; + sameTypeFromStorage = fromStorage; } - templ("sameType", sameType); - if (sameType) + templ("sameTypeFromStorage", sameTypeFromStorage); + if (sameTypeFromStorage) { templ("maskFull", maskLowerOrderBytesFunction(itemsPerSlot * _toType.storageStride())); templ("maskBytes", maskLowerOrderBytesFunctionDynamic()); @@ -2088,24 +2141,32 @@ string YulUtilFunctions::copyValueArrayStorageToStorageFunction(ArrayType const& templ("convert", conversionFunction(*_fromType.baseType(), *_toType.baseType())); templ("prepareStore", prepareStoreFunction(*_toType.baseType())); } - templ("updateSrcSlotValue", Whiskers(R"( - - srcItemIndexInSlot := add(srcItemIndexInSlot, 1) - if eq(srcItemIndexInSlot, ) { - // here we are done with this slot, we need to read next one - srcSlot := add(srcSlot, 1) - srcSlotValue := sload(srcSlot) - srcItemIndexInSlot := 0 - } - - srcSlot := add(srcSlot, 1) - srcSlotValue := sload(srcSlot) - - )") - ("srcReadMultiPerSlot", !sameType && _fromType.storageStride() <= 16) - ("srcItemsPerSlot", to_string(32 / _fromType.storageStride())) - .render() - ); + if (fromStorage) + templ("updateSrcPtr", Whiskers(R"( + + srcItemIndexInSlot := add(srcItemIndexInSlot, 1) + if eq(srcItemIndexInSlot, ) { + // here we are done with this slot, we need to read next one + srcPtr := add(srcPtr, 1) + srcSlotValue := sload(srcPtr) + srcItemIndexInSlot := 0 + } + + srcPtr := add(srcPtr, 1) + srcSlotValue := sload(srcPtr) + + )") + ("srcReadMultiPerSlot", !sameTypeFromStorage && _fromType.storageStride() <= 16) + ("srcItemsPerSlot", to_string(32 / _fromType.storageStride())) + .render() + ); + else + templ("updateSrcPtr", Whiskers(R"( + srcPtr := add(srcPtr, ) + )") + ("srcStride", fromCalldata ? to_string(_fromType.calldataStride()) : to_string(_fromType.memoryStride())) + .render() + ); return templ.render(); }); diff --git a/libsolidity/codegen/YulUtilFunctions.h b/libsolidity/codegen/YulUtilFunctions.h index 4d6e7efda..7d736df5b 100644 --- a/libsolidity/codegen/YulUtilFunctions.h +++ b/libsolidity/codegen/YulUtilFunctions.h @@ -73,8 +73,9 @@ public: /// @returns a function that copies raw bytes of dynamic length from calldata /// or memory to memory. - /// Pads with zeros and might write more than exactly length. - std::string copyToMemoryFunction(bool _fromCalldata); + /// @params _cleanup If true, pads with zeros up to the 32 byte boundary after the specified length + /// signature: (src, dst, length) -> + std::string copyToMemoryFunction(bool _fromCalldata, bool _cleanup); /// @returns the name of a function that copies a string literal to memory /// and returns a pointer to the memory area containing the string literal. @@ -232,8 +233,8 @@ public: std::string storageArrayPopFunction(ArrayType const& _type); /// @returns the name of a function that pushes an element to a storage array -/// @param _fromType represents the type of the element being pushed. -/// If _fromType is ReferenceType the function will perform deep copy. + /// @param _fromType represents the type of the element being pushed. + /// If _fromType is ReferenceType the function will perform deep copy. /// signature: (array, value) std::string storageArrayPushFunction(ArrayType const& _type, Type const* _fromType = nullptr); @@ -258,9 +259,9 @@ public: /// signature (to_slot, from_ptr) -> std::string copyByteArrayToStorageFunction(ArrayType const& _fromType, ArrayType const& _toType); - /// @returns the name of a function that will copy an array of value types from storage to storage. - /// signature (to_slot, from_slot) -> - std::string copyValueArrayStorageToStorageFunction(ArrayType const& _fromType, ArrayType const& _toType); + /// @returns the name of a function that will copy an array of value types to storage. + /// signature (to_slot, from_ptr[, from_length]) -> + std::string copyValueArrayToStorageFunction(ArrayType const& _fromType, ArrayType const& _toType); /// Returns the name of a function that will convert a given length to the /// size in memory (number of storage slots or calldata/memory bytes) it @@ -530,7 +531,7 @@ public: std::string externalFunctionPointersEqualFunction(); private: -/// @returns the name of a function that copies a struct from calldata or memory to storage + /// @returns the name of a function that copies a struct from calldata or memory to storage /// signature: (slot, value) -> std::string copyStructToStorageFunction(StructType const& _from, StructType const& _to); diff --git a/libsolidity/codegen/ir/IRGenerationContext.cpp b/libsolidity/codegen/ir/IRGenerationContext.cpp index 5d39bf4b5..cb1c371dc 100644 --- a/libsolidity/codegen/ir/IRGenerationContext.cpp +++ b/libsolidity/codegen/ir/IRGenerationContext.cpp @@ -121,7 +121,7 @@ void IRGenerationContext::addStateVariable( unsigned _byteOffset ) { - m_stateVariables[&_declaration] = make_pair(move(_storageOffset), _byteOffset); + m_stateVariables[&_declaration] = make_pair(std::move(_storageOffset), _byteOffset); } string IRGenerationContext::newYulVariable() @@ -137,12 +137,12 @@ void IRGenerationContext::initializeInternalDispatch(InternalDispatchMap _intern for (auto function: functions) enqueueFunctionForCodeGeneration(*function); - m_internalDispatchMap = move(_internalDispatch); + m_internalDispatchMap = std::move(_internalDispatch); } InternalDispatchMap IRGenerationContext::consumeInternalDispatchMap() { - InternalDispatchMap internalDispatch = move(m_internalDispatchMap); + InternalDispatchMap internalDispatch = std::move(m_internalDispatchMap); m_internalDispatchMap.clear(); return internalDispatch; } diff --git a/libsolidity/codegen/ir/IRGenerator.cpp b/libsolidity/codegen/ir/IRGenerator.cpp index 7c76f8344..a13a35301 100644 --- a/libsolidity/codegen/ir/IRGenerator.cpp +++ b/libsolidity/codegen/ir/IRGenerator.cpp @@ -113,7 +113,7 @@ pair IRGenerator::run( } asmStack.optimize(); - return {move(ir), asmStack.print(m_context.soliditySourceProvider())}; + return {std::move(ir), asmStack.print(m_context.soliditySourceProvider())}; } string IRGenerator::generate( @@ -214,7 +214,7 @@ string IRGenerator::generate( // NOTE: Function pointers can be passed from creation code via storage variables. We need to // get all the functions they could point to into the dispatch functions even if they're never // referenced by name in the deployed code. - m_context.initializeInternalDispatch(move(internalDispatchMap)); + m_context.initializeInternalDispatch(std::move(internalDispatchMap)); // Do not register immutables to avoid assignment. t("DeployedObject", IRNames::deployedObject(_contract)); @@ -236,8 +236,8 @@ string IRGenerator::generate( solAssert(_contract.annotation().creationCallGraph->get() != nullptr, ""); solAssert(_contract.annotation().deployedCallGraph->get() != nullptr, ""); - verifyCallGraph(collectReachableCallables(**_contract.annotation().creationCallGraph), move(creationFunctionList)); - verifyCallGraph(collectReachableCallables(**_contract.annotation().deployedCallGraph), move(deployedFunctionList)); + verifyCallGraph(collectReachableCallables(**_contract.annotation().creationCallGraph), std::move(creationFunctionList)); + verifyCallGraph(collectReachableCallables(**_contract.annotation().deployedCallGraph), std::move(deployedFunctionList)); return t.render(); } @@ -317,7 +317,7 @@ InternalDispatchMap IRGenerator::generateInternalDispatchFunctions(ContractDefin }); } - templ("cases", move(cases)); + templ("cases", std::move(cases)); return templ.render(); }); } @@ -944,7 +944,7 @@ void IRGenerator::generateConstructors(ContractDefinition const& _contract) generateFunctionWithModifierInner(*constructor); } } - t("userDefinedConstructorBody", move(body)); + t("userDefinedConstructorBody", std::move(body)); return t.render(); }); @@ -1117,7 +1117,7 @@ void IRGenerator::resetContext(ContractDefinition const& _contract, ExecutionCon m_context.soliditySourceProvider() ); newContext.copyFunctionIDsFrom(m_context); - m_context = move(newContext); + m_context = std::move(newContext); m_context.setMostDerivedContract(_contract); for (auto const& var: ContractType(_contract).stateVariables()) diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 9e48c811c..679510cd6 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -827,17 +827,17 @@ bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp) expr = "iszero(" + expr + ")"; } else if (op == Token::Equal) - expr = "eq(" + move(args) + ")"; + expr = "eq(" + std::move(args) + ")"; else if (op == Token::NotEqual) - expr = "iszero(eq(" + move(args) + "))"; + expr = "iszero(eq(" + std::move(args) + "))"; else if (op == Token::GreaterThanOrEqual) - expr = "iszero(" + string(isSigned ? "slt(" : "lt(") + move(args) + "))"; + expr = "iszero(" + string(isSigned ? "slt(" : "lt(") + std::move(args) + "))"; else if (op == Token::LessThanOrEqual) - expr = "iszero(" + string(isSigned ? "sgt(" : "gt(") + move(args) + "))"; + expr = "iszero(" + string(isSigned ? "sgt(" : "gt(") + std::move(args) + "))"; else if (op == Token::GreaterThan) - expr = (isSigned ? "sgt(" : "gt(") + move(args) + ")"; + expr = (isSigned ? "sgt(" : "gt(") + std::move(args) + ")"; else if (op == Token::LessThan) - expr = (isSigned ? "slt(" : "lt(") + move(args) + ")"; + expr = (isSigned ? "slt(" : "lt(") + std::move(args) + ")"; else solAssert(false, "Unknown comparison operator."); define(_binOp) << expr << "\n"; @@ -1109,7 +1109,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) messageArgumentType ); - appendCode() << move(requireOrAssertFunction) << "(" << IRVariable(*arguments[0]).name(); + appendCode() << std::move(requireOrAssertFunction) << "(" << IRVariable(*arguments[0]).name(); if (messageArgumentType && messageArgumentType->sizeOnStack() > 0) appendCode() << ", " << IRVariable(*arguments[1]).commaSeparatedList(); appendCode() << ")\n"; @@ -1785,7 +1785,20 @@ void IRGeneratorForStatements::endVisit(MemberAccess const& _memberAccess) functionType.declaration().isPartOfExternalInterface(), "" ); - define(IRVariable{_memberAccess}) << formatNumber(functionType.externalIdentifier() << 224) << "\n"; + define(IRVariable{_memberAccess}) << formatNumber( + util::selectorFromSignature(functionType.externalSignature()) + ) << "\n"; + } + else if (functionType.kind() == FunctionType::Kind::Event) + { + solAssert(functionType.hasDeclaration()); + solAssert(functionType.kind() == FunctionType::Kind::Event); + solAssert( + !(dynamic_cast(functionType.declaration()).isAnonymous()) + ); + define(IRVariable{_memberAccess}) << formatNumber( + u256(h256::Arith(util::keccak256(functionType.externalSignature()))) + ) << "\n"; } else solAssert(false, "Invalid use of .selector: " + functionType.toString(false)); diff --git a/libsolidity/formal/ArraySlicePredicate.cpp b/libsolidity/formal/ArraySlicePredicate.cpp index 85fced906..f73985f18 100644 --- a/libsolidity/formal/ArraySlicePredicate.cpp +++ b/libsolidity/formal/ArraySlicePredicate.cpp @@ -86,6 +86,6 @@ pair ArraySlicePredicate::create(So return {false, m_slicePredicates[tupleName] = { {&slice, &header, &loop}, - {move(rule1), move(rule2), move(rule3), move(rule4)} + {std::move(rule1), std::move(rule2), std::move(rule3), std::move(rule4)} }}; } diff --git a/libsolidity/formal/BMC.cpp b/libsolidity/formal/BMC.cpp index bf3618791..0466bfbac 100644 --- a/libsolidity/formal/BMC.cpp +++ b/libsolidity/formal/BMC.cpp @@ -76,7 +76,7 @@ void BMC::analyze(SourceUnit const& _source, map, vector> BMC::modelExpressions() expressionName = m_charStreamProvider.charStream(*uf->location().sourceName).text( uf->location() ); - expressionNames.push_back(move(expressionName)); + expressionNames.push_back(std::move(expressionName)); } return {expressionsToEvaluate, expressionNames}; @@ -888,7 +888,7 @@ void BMC::addVerificationTarget( if (_type == VerificationTargetType::ConstantCondition) checkVerificationTarget(target); else - m_verificationTargets.emplace_back(move(target)); + m_verificationTargets.emplace_back(std::move(target)); } /// Solving. @@ -964,7 +964,7 @@ void BMC::checkCondition( message.str(), SecondarySourceLocation().append(modelMessage.str(), SourceLocation{}) .append(SMTEncoder::callStackMessage(_callStack)) - .append(move(secondaryLocation)) + .append(std::move(secondaryLocation)) ); break; } diff --git a/libsolidity/formal/CHC.cpp b/libsolidity/formal/CHC.cpp index 267ea9269..3d5c3e6c3 100644 --- a/libsolidity/formal/CHC.cpp +++ b/libsolidity/formal/CHC.cpp @@ -1422,7 +1422,7 @@ vector CHC::currentStateVariables(ContractDefinition const& smtutil::Expression CHC::currentEqualInitialVarsConstraints(vector const& _vars) const { return fold(_vars, smtutil::Expression(true), [this](auto&& _conj, auto _var) { - return move(_conj) && currentValue(*_var) == m_context.variable(*_var)->valueAtIndex(0); + return std::move(_conj) && currentValue(*_var) == m_context.variable(*_var)->valueAtIndex(0); }); } @@ -1566,7 +1566,7 @@ tuple CHC::query tie(resultNoOpt, invariantNoOpt, cexNoOpt) = m_interface->query(_query); if (resultNoOpt == CheckResult::SATISFIABLE) - cex = move(cexNoOpt); + cex = std::move(cexNoOpt); spacer->setSpacerOptions(true); } @@ -1817,7 +1817,7 @@ void CHC::checkAndReportTarget( predicates.insert(pred); map> invariants = collectInvariants(invariant, predicates, m_settings.invariants); for (auto pred: invariants | ranges::views::keys) - m_invariants[pred] += move(invariants.at(pred)); + m_invariants[pred] += std::move(invariants.at(pred)); } else if (result == CheckResult::SATISFIABLE) { diff --git a/libsolidity/formal/EncodingContext.cpp b/libsolidity/formal/EncodingContext.cpp index f9edd7db3..2000efd07 100644 --- a/libsolidity/formal/EncodingContext.cpp +++ b/libsolidity/formal/EncodingContext.cpp @@ -211,5 +211,5 @@ void EncodingContext::addAssertion(smtutil::Expression const& _expr) if (m_assertions.empty()) m_assertions.push_back(_expr); else - m_assertions.back() = _expr && move(m_assertions.back()); + m_assertions.back() = _expr && std::move(m_assertions.back()); } diff --git a/libsolidity/formal/EncodingContext.h b/libsolidity/formal/EncodingContext.h index 7c001f452..35e54ed76 100644 --- a/libsolidity/formal/EncodingContext.h +++ b/libsolidity/formal/EncodingContext.h @@ -63,7 +63,7 @@ public: smtutil::Expression newVariable(std::string _name, smtutil::SortPointer _sort) { solAssert(m_solver, ""); - return m_solver->newVariable(move(_name), move(_sort)); + return m_solver->newVariable(std::move(_name), std::move(_sort)); } struct IdCompare diff --git a/libsolidity/formal/Invariants.cpp b/libsolidity/formal/Invariants.cpp index 10d342ed4..9177a4d43 100644 --- a/libsolidity/formal/Invariants.cpp +++ b/libsolidity/formal/Invariants.cpp @@ -55,9 +55,9 @@ map> collectInvariants( auto arg0 = _expr->arguments.at(0); auto arg1 = _expr->arguments.at(1); if (starts_with(arg0.name, t)) - equalities.insert({arg0.name, {arg0, move(arg1)}}); + equalities.insert({arg0.name, {arg0, std::move(arg1)}}); else if (starts_with(arg1.name, t)) - equalities.insert({arg1.name, {arg1, move(arg0)}}); + equalities.insert({arg1.name, {arg1, std::move(arg0)}}); } for (auto const& arg: _expr->arguments) _addChild(&arg); diff --git a/libsolidity/formal/ModelChecker.cpp b/libsolidity/formal/ModelChecker.cpp index cf7a398ec..0d624f9e0 100644 --- a/libsolidity/formal/ModelChecker.cpp +++ b/libsolidity/formal/ModelChecker.cpp @@ -38,7 +38,7 @@ ModelChecker::ModelChecker( ReadCallback::Callback const& _smtCallback ): m_errorReporter(_errorReporter), - m_settings(move(_settings)), + m_settings(std::move(_settings)), m_context(), m_bmc(m_context, m_uniqueErrorReporter, _smtlib2Responses, _smtCallback, m_settings, _charStreamProvider), m_chc(m_context, m_uniqueErrorReporter, _smtlib2Responses, _smtCallback, m_settings, _charStreamProvider) diff --git a/libsolidity/formal/Predicate.cpp b/libsolidity/formal/Predicate.cpp index 91513a00c..d4b6994cf 100644 --- a/libsolidity/formal/Predicate.cpp +++ b/libsolidity/formal/Predicate.cpp @@ -50,13 +50,13 @@ Predicate const* Predicate::create( vector _scopeStack ) { - smt::SymbolicFunctionVariable predicate{_sort, move(_name), _context}; + smt::SymbolicFunctionVariable predicate{_sort, std::move(_name), _context}; string functorName = predicate.currentName(); solAssert(!m_predicates.count(functorName), ""); return &m_predicates.emplace( std::piecewise_construct, std::forward_as_tuple(functorName), - std::forward_as_tuple(move(predicate), _type, _node, _contractContext, move(_scopeStack)) + std::forward_as_tuple(std::move(predicate), _type, _node, _contractContext, std::move(_scopeStack)) ).first->second; } @@ -67,7 +67,7 @@ Predicate::Predicate( ContractDefinition const* _contractContext, vector _scopeStack ): - m_predicate(move(_predicate)), + m_predicate(std::move(_predicate)), m_type(_type), m_node(_node), m_contractContext(_contractContext), diff --git a/libsolidity/formal/SMTEncoder.cpp b/libsolidity/formal/SMTEncoder.cpp index 8c5dd647e..e779fbeb8 100644 --- a/libsolidity/formal/SMTEncoder.cpp +++ b/libsolidity/formal/SMTEncoder.cpp @@ -2977,7 +2977,7 @@ set const& SMTEncoder::contract resolvedFunctions.insert(baseFunction); } } - m_contractFunctions.emplace(&_contract, move(resolvedFunctions)); + m_contractFunctions.emplace(&_contract, std::move(resolvedFunctions)); } return m_contractFunctions.at(&_contract); } @@ -2991,7 +2991,7 @@ set const& SMTEncoder::contract for (auto const* baseFun: base->definedFunctions()) allFunctions.insert(baseFun); - m_contractFunctionsWithoutVirtual.emplace(&_contract, move(allFunctions)); + m_contractFunctionsWithoutVirtual.emplace(&_contract, std::move(allFunctions)); } return m_contractFunctionsWithoutVirtual.at(&_contract); diff --git a/libsolidity/formal/SymbolicState.cpp b/libsolidity/formal/SymbolicState.cpp index b1fd7978f..0679cee8a 100644 --- a/libsolidity/formal/SymbolicState.cpp +++ b/libsolidity/formal/SymbolicState.cpp @@ -32,8 +32,8 @@ BlockchainVariable::BlockchainVariable( map _members, EncodingContext& _context ): - m_name(move(_name)), - m_members(move(_members)), + m_name(std::move(_name)), + m_members(std::move(_members)), m_context(_context) { vector members; @@ -94,12 +94,12 @@ smtutil::Expression SymbolicState::balance() const smtutil::Expression SymbolicState::balance(smtutil::Expression _address) const { - return smtutil::Expression::select(balances(), move(_address)); + return smtutil::Expression::select(balances(), std::move(_address)); } smtutil::Expression SymbolicState::blockhash(smtutil::Expression _blockNumber) const { - return smtutil::Expression::select(m_tx.member("blockhash"), move(_blockNumber)); + return smtutil::Expression::select(m_tx.member("blockhash"), std::move(_blockNumber)); } void SymbolicState::newBalances() @@ -114,13 +114,13 @@ void SymbolicState::transfer(smtutil::Expression _from, smtutil::Expression _to, { unsigned indexBefore = m_state.index(); addBalance(_from, 0 - _value); - addBalance(_to, move(_value)); + addBalance(_to, std::move(_value)); unsigned indexAfter = m_state.index(); solAssert(indexAfter > indexBefore, ""); m_state.newVar(); /// Do not apply the transfer operation if _from == _to. auto newState = smtutil::Expression::ite( - move(_from) == move(_to), + std::move(_from) == std::move(_to), m_state.value(indexBefore), m_state.value(indexAfter) ); @@ -132,7 +132,7 @@ void SymbolicState::addBalance(smtutil::Expression _address, smtutil::Expression auto newBalances = smtutil::Expression::store( balances(), _address, - balance(_address) + move(_value) + balance(_address) + std::move(_value) ); m_state.assignMember("balances", newBalances); } @@ -322,7 +322,7 @@ void SymbolicState::buildABIFunctions(set const& _abiFuncti functions[name] = functionSort; } - m_abi = make_unique("abi", move(functions), m_context); + m_abi = make_unique("abi", std::move(functions), m_context); } smtutil::Expression SymbolicState::abiFunction(frontend::FunctionCall const* _funCall) diff --git a/libsolidity/formal/SymbolicVariables.cpp b/libsolidity/formal/SymbolicVariables.cpp index f0fa7df86..799ac4adb 100644 --- a/libsolidity/formal/SymbolicVariables.cpp +++ b/libsolidity/formal/SymbolicVariables.cpp @@ -38,7 +38,7 @@ SymbolicVariable::SymbolicVariable( ): m_type(_type), m_originalType(_originalType), - m_uniqueName(move(_uniqueName)), + m_uniqueName(std::move(_uniqueName)), m_context(_context), m_ssa(make_unique()) { @@ -52,8 +52,8 @@ SymbolicVariable::SymbolicVariable( string _uniqueName, EncodingContext& _context ): - m_sort(move(_sort)), - m_uniqueName(move(_uniqueName)), + m_sort(std::move(_sort)), + m_uniqueName(std::move(_uniqueName)), m_context(_context), m_ssa(make_unique()) { @@ -108,7 +108,7 @@ SymbolicBoolVariable::SymbolicBoolVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(_type, _type, move(_uniqueName), _context) + SymbolicVariable(_type, _type, std::move(_uniqueName), _context) { solAssert(m_type->category() == frontend::Type::Category::Bool, ""); } @@ -119,7 +119,7 @@ SymbolicIntVariable::SymbolicIntVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(_type, _originalType, move(_uniqueName), _context) + SymbolicVariable(_type, _originalType, std::move(_uniqueName), _context) { solAssert(isNumber(*m_type), ""); } @@ -128,7 +128,7 @@ SymbolicAddressVariable::SymbolicAddressVariable( string _uniqueName, EncodingContext& _context ): - SymbolicIntVariable(TypeProvider::uint(160), TypeProvider::uint(160), move(_uniqueName), _context) + SymbolicIntVariable(TypeProvider::uint(160), TypeProvider::uint(160), std::move(_uniqueName), _context) { } @@ -138,7 +138,7 @@ SymbolicFixedBytesVariable::SymbolicFixedBytesVariable( string _uniqueName, EncodingContext& _context ): - SymbolicIntVariable(TypeProvider::uint(_numBytes * 8), _originalType, move(_uniqueName), _context) + SymbolicIntVariable(TypeProvider::uint(_numBytes * 8), _originalType, std::move(_uniqueName), _context) { } @@ -147,7 +147,7 @@ SymbolicFunctionVariable::SymbolicFunctionVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(_type, _type, move(_uniqueName), _context), + SymbolicVariable(_type, _type, std::move(_uniqueName), _context), m_declaration(m_context.newVariable(currentName(), m_sort)) { solAssert(m_type->category() == frontend::Type::Category::Function, ""); @@ -158,7 +158,7 @@ SymbolicFunctionVariable::SymbolicFunctionVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(move(_sort), move(_uniqueName), _context), + SymbolicVariable(std::move(_sort), std::move(_uniqueName), _context), m_declaration(m_context.newVariable(currentName(), m_sort)) { solAssert(m_sort->kind == Kind::Function, ""); @@ -219,7 +219,7 @@ SymbolicEnumVariable::SymbolicEnumVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(_type, _type, move(_uniqueName), _context) + SymbolicVariable(_type, _type, std::move(_uniqueName), _context) { solAssert(isEnum(*m_type), ""); } @@ -229,7 +229,7 @@ SymbolicTupleVariable::SymbolicTupleVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(_type, _type, move(_uniqueName), _context) + SymbolicVariable(_type, _type, std::move(_uniqueName), _context) { solAssert(isTuple(*m_type), ""); } @@ -239,7 +239,7 @@ SymbolicTupleVariable::SymbolicTupleVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(move(_sort), move(_uniqueName), _context) + SymbolicVariable(std::move(_sort), std::move(_uniqueName), _context) { solAssert(m_sort->kind == Kind::Tuple, ""); } @@ -288,7 +288,7 @@ SymbolicArrayVariable::SymbolicArrayVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(_type, _originalType, move(_uniqueName), _context), + SymbolicVariable(_type, _originalType, std::move(_uniqueName), _context), m_pair( smtSort(*_type), m_uniqueName + "_length_pair", @@ -303,7 +303,7 @@ SymbolicArrayVariable::SymbolicArrayVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(move(_sort), move(_uniqueName), _context), + SymbolicVariable(std::move(_sort), std::move(_uniqueName), _context), m_pair( std::make_shared( "array_length_pair", @@ -346,7 +346,7 @@ SymbolicStructVariable::SymbolicStructVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(_type, _type, move(_uniqueName), _context) + SymbolicVariable(_type, _type, std::move(_uniqueName), _context) { solAssert(isNonRecursiveStruct(*m_type), ""); auto const* structType = dynamic_cast(_type); diff --git a/libsolidity/interface/ABI.cpp b/libsolidity/interface/ABI.cpp index eab1801c6..cbfa36122 100644 --- a/libsolidity/interface/ABI.cpp +++ b/libsolidity/interface/ABI.cpp @@ -134,7 +134,7 @@ Json::Value ABI::generate(ContractDefinition const& _contractDef) formatType(p->name(), *type, *p->annotation().type, false) ); } - abi.emplace(move(errorJson)); + abi.emplace(std::move(errorJson)); } Json::Value abiJson{Json::arrayValue}; diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 6560b0be5..702d5a0d2 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -208,7 +208,7 @@ void CompilerStack::setRemappings(vector _remappings) solThrow(CompilerError, "Must set remappings before parsing."); for (auto const& remapping: _remappings) solAssert(!remapping.prefix.empty(), ""); - m_importRemapper.setRemappings(move(_remappings)); + m_importRemapper.setRemappings(std::move(_remappings)); } void CompilerStack::setViaIR(bool _viaIR) @@ -404,9 +404,10 @@ void CompilerStack::importASTs(map const& _sources) source.ast = src.second; source.charStream = make_shared( util::jsonCompactPrint(m_sourceJsons[src.first]), - src.first + src.first, + true // imported from AST ); - m_sources[path] = move(source); + m_sources[path] = std::move(source); } m_stackState = ParsedAndImported; m_importedSources = true; @@ -479,12 +480,6 @@ bool CompilerStack::analyze() if (auto sourceAst = source->ast) noErrors = contractLevelChecker.check(*sourceAst); - // Requires ContractLevelChecker - DocStringAnalyser docStringAnalyser(m_errorReporter); - for (Source const* source: m_sourceOrder) - if (source->ast && !docStringAnalyser.analyseDocStrings(*source->ast)) - noErrors = false; - // Now we run full type checks that go down to the expression level. This // cannot be done earlier, because we need cross-contract types and information // about whether a contract is abstract for the `new` expression. @@ -497,6 +492,15 @@ bool CompilerStack::analyze() if (source->ast && !typeChecker.checkTypeRequirements(*source->ast)) noErrors = false; + if (noErrors) + { + // Requires ContractLevelChecker and TypeChecker + DocStringAnalyser docStringAnalyser(m_errorReporter); + for (Source const* source: m_sourceOrder) + if (source->ast && !docStringAnalyser.analyseDocStrings(*source->ast)) + noErrors = false; + } + if (noErrors) { // Checks that can only be done when all types of all AST nodes are known. @@ -789,7 +793,7 @@ Json::Value CompilerStack::generatedSources(string const& _contractName, bool _r sources[0]["name"] = sourceName; sources[0]["id"] = sourceIndex; sources[0]["language"] = "Yul"; - sources[0]["contents"] = move(source); + sources[0]["contents"] = std::move(source); } } @@ -1282,7 +1286,7 @@ void CompilerStack::assemble( "Contract code size is "s + to_string(compiledContract.runtimeObject.bytecode.size()) + " bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). " - "This contract may not be deployable on mainnet. " + "This contract may not be deployable on Mainnet. " "Consider enabling the optimizer (with a low \"runs\" value!), " "turning off revert strings, or using libraries." ); diff --git a/libsolidity/interface/ImportRemapper.cpp b/libsolidity/interface/ImportRemapper.cpp index 9d5561013..4d4fa42d4 100644 --- a/libsolidity/interface/ImportRemapper.cpp +++ b/libsolidity/interface/ImportRemapper.cpp @@ -35,7 +35,7 @@ void ImportRemapper::setRemappings(vector _remappings) { for (auto const& remapping: _remappings) solAssert(!remapping.prefix.empty(), ""); - m_remappings = move(_remappings); + m_remappings = std::move(_remappings); } SourceUnitName ImportRemapper::apply(ImportPath const& _path, string const& _context) const diff --git a/libsolidity/interface/Natspec.cpp b/libsolidity/interface/Natspec.cpp index 449690493..566b67607 100644 --- a/libsolidity/interface/Natspec.cpp +++ b/libsolidity/interface/Natspec.cpp @@ -92,7 +92,7 @@ Json::Value Natspec::userDocumentation(ContractDefinition const& _contractDef) { Json::Value errorDoc{Json::objectValue}; errorDoc["notice"] = value; - doc["errors"][error->functionType(true)->externalSignature()].append(move(errorDoc)); + doc["errors"][error->functionType(true)->externalSignature()].append(std::move(errorDoc)); } } @@ -140,10 +140,10 @@ Json::Value Natspec::devDocumentation(ContractDefinition const& _contractDef) ); if (!jsonReturn.empty()) - method["returns"] = move(jsonReturn); + method["returns"] = std::move(jsonReturn); if (!method.empty()) - doc["methods"][it.second->externalSignature()] = move(method); + doc["methods"][it.second->externalSignature()] = std::move(method); } } @@ -230,7 +230,7 @@ Json::Value Natspec::extractCustomDoc(multimap const& _tags) return Json::nullValue; Json::Value result{Json::objectValue}; for (auto& [tag, value]: concatenated) - result[tag] = move(value); + result[tag] = std::move(value); return result; } diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 9ca8de3ea..c6cd741c1 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include @@ -403,7 +403,7 @@ Json::Value collectEVMObject( if (_runtimeObject && _artifactRequested("immutableReferences")) output["immutableReferences"] = formatImmutableReferences(_object.immutableReferences); if (_artifactRequested("generatedSources")) - output["generatedSources"] = move(_generatedSources); + output["generatedSources"] = std::move(_generatedSources); return output; } @@ -966,7 +966,7 @@ std::variant StandardCompiler: if (sourceContracts[source].empty()) return formatFatalError("JSONError", "Source contracts must be a non-empty array."); } - ret.modelCheckerSettings.contracts = {move(sourceContracts)}; + ret.modelCheckerSettings.contracts = {std::move(sourceContracts)}; } if (modelCheckerSettings.isMember("divModNoSlacks")) @@ -1076,7 +1076,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting compilerStack.setViaIR(_inputsAndSettings.viaIR); compilerStack.setEVMVersion(_inputsAndSettings.evmVersion); compilerStack.setParserErrorRecovery(_inputsAndSettings.parserErrorRecovery); - compilerStack.setRemappings(move(_inputsAndSettings.remappings)); + compilerStack.setRemappings(std::move(_inputsAndSettings.remappings)); compilerStack.setOptimiserSettings(std::move(_inputsAndSettings.optimiserSettings)); compilerStack.setRevertStringBehaviour(_inputsAndSettings.revertStrings); if (_inputsAndSettings.debugInfoSelection.has_value()) @@ -1254,7 +1254,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting Json::Value sourceResult = Json::objectValue; sourceResult["id"] = sourceIndex++; if (isArtifactRequested(_inputsAndSettings.outputSelection, sourceName, "", "ast", wildcardMatchesExperimental)) - sourceResult["ast"] = ASTJsonConverter(compilerStack.state(), compilerStack.sourceIndices()).toJson(compilerStack.ast(sourceName)); + sourceResult["ast"] = ASTJsonExporter(compilerStack.state(), compilerStack.sourceIndices()).toJson(compilerStack.ast(sourceName)); output["sources"][sourceName] = sourceResult; } @@ -1582,7 +1582,7 @@ Json::Value StandardCompiler::formatFunctionDebugData( fun["entryPoint"] = Json::nullValue; fun["parameterSlots"] = Json::UInt64(info.params); fun["returnSlots"] = Json::UInt64(info.returns); - ret[name] = move(fun); + ret[name] = std::move(fun); } return ret; diff --git a/libsolidity/interface/StorageLayout.cpp b/libsolidity/interface/StorageLayout.cpp index 74d7ccf4b..76c840db5 100644 --- a/libsolidity/interface/StorageLayout.cpp +++ b/libsolidity/interface/StorageLayout.cpp @@ -40,8 +40,8 @@ Json::Value StorageLayout::generate(ContractDefinition const& _contractDef) variables.append(generate(*var, slot, offset)); Json::Value layout; - layout["storage"] = move(variables); - layout["types"] = move(m_types); + layout["storage"] = std::move(variables); + layout["types"] = std::move(m_types); return layout; } @@ -81,7 +81,7 @@ void StorageLayout::generate(Type const* _type) auto const& offsets = structType->storageOffsetsOfMember(member->name()); members.append(generate(*member, offsets.first, offsets.second)); } - typeInfo["members"] = move(members); + typeInfo["members"] = std::move(members); typeInfo["encoding"] = "inplace"; } else if (auto mappingType = dynamic_cast(_type)) diff --git a/libsolidity/lsp/FileRepository.cpp b/libsolidity/lsp/FileRepository.cpp index e82343973..4e8ebbb12 100644 --- a/libsolidity/lsp/FileRepository.cpp +++ b/libsolidity/lsp/FileRepository.cpp @@ -17,16 +17,23 @@ // SPDX-License-Identifier: GPL-3.0 #include +#include #include #include #include +#include #include #include +#include #include +#include + +#include + using namespace std; using namespace solidity; using namespace solidity::lsp; @@ -34,29 +41,54 @@ using namespace solidity::frontend; using solidity::util::readFileAsString; using solidity::util::joinHumanReadable; +using solidity::util::Result; -FileRepository::FileRepository(boost::filesystem::path _basePath): m_basePath(std::move(_basePath)) +FileRepository::FileRepository(boost::filesystem::path _basePath, std::vector _includePaths): + m_basePath(std::move(_basePath)), + m_includePaths(std::move(_includePaths)) { } +void FileRepository::setIncludePaths(std::vector _paths) +{ + m_includePaths = std::move(_paths); +} + string FileRepository::sourceUnitNameToUri(string const& _sourceUnitName) const { regex const windowsDriveLetterPath("^[a-zA-Z]:/"); + auto const ensurePathIsUnixLike = [&](string inputPath) -> string { + if (!regex_search(inputPath, windowsDriveLetterPath)) + return inputPath; + else + return "/" + std::move(inputPath); + }; + if (m_sourceUnitNamesToUri.count(_sourceUnitName)) + { + solAssert(boost::starts_with(m_sourceUnitNamesToUri.at(_sourceUnitName), "file://"), ""); return m_sourceUnitNamesToUri.at(_sourceUnitName); + } else if (_sourceUnitName.find("file://") == 0) return _sourceUnitName; else if (regex_search(_sourceUnitName, windowsDriveLetterPath)) return "file:///" + _sourceUnitName; - else if (_sourceUnitName.find("/") == 0) - return "file://" + _sourceUnitName; - else + else if ( + auto const resolvedPath = tryResolvePath(_sourceUnitName); + resolvedPath.message().empty() + ) + return "file://" + ensurePathIsUnixLike(resolvedPath.get().generic_string()); + else if (m_basePath.generic_string() != "/") return "file://" + m_basePath.generic_string() + "/" + _sourceUnitName; + else + // Avoid double-/ in case base-path itself is simply a UNIX root filesystem root. + return "file:///" + _sourceUnitName; } string FileRepository::uriToSourceUnitName(string const& _path) const { + lspAssert(boost::algorithm::starts_with(_path, "file://"), ErrorCode::InternalError, "URI must start with file://"); return stripFileUriSchemePrefix(_path); } @@ -65,10 +97,57 @@ void FileRepository::setSourceByUri(string const& _uri, string _source) // This is needed for uris outside the base path. It can lead to collisions, // but we need to mostly rewrite this in a future version anyway. auto sourceUnitName = uriToSourceUnitName(_uri); + lspDebug(fmt::format("FileRepository.setSourceByUri({}): {}", _uri, _source)); m_sourceUnitNamesToUri.emplace(sourceUnitName, _uri); m_sourceCodes[sourceUnitName] = std::move(_source); } +Result FileRepository::tryResolvePath(std::string const& _strippedSourceUnitName) const +{ + if ( + boost::filesystem::path(_strippedSourceUnitName).has_root_path() && + boost::filesystem::exists(_strippedSourceUnitName) + ) + return boost::filesystem::path(_strippedSourceUnitName); + + vector candidates; + vector> prefixes = {m_basePath}; + prefixes += (m_includePaths | ranges::to>>); + auto const defaultInclude = m_basePath / "node_modules"; + if (m_includePaths.empty()) + prefixes.emplace_back(defaultInclude); + + auto const pathToQuotedString = [](boost::filesystem::path const& _path) { return "\"" + _path.string() + "\""; }; + + for (auto const& prefix: prefixes) + { + boost::filesystem::path canonicalPath = boost::filesystem::path(prefix) / boost::filesystem::path(_strippedSourceUnitName); + + if (boost::filesystem::exists(canonicalPath)) + candidates.push_back(std::move(canonicalPath)); + } + + if (candidates.empty()) + return Result::err( + "File not found. Searched the following locations: " + + joinHumanReadable(prefixes | ranges::views::transform(pathToQuotedString), ", ") + + "." + ); + + if (candidates.size() >= 2) + return Result::err( + "Ambiguous import. " + "Multiple matching files found inside base path and/or include paths: " + + joinHumanReadable(candidates | ranges::views::transform(pathToQuotedString), ", ") + + "." + ); + + if (!boost::filesystem::is_regular_file(candidates[0])) + return Result::err("Not a valid file."); + + return candidates[0]; +} + frontend::ReadCallback::Result FileRepository::readFile(string const& _kind, string const& _sourceUnitName) { solAssert( @@ -83,56 +162,14 @@ frontend::ReadCallback::Result FileRepository::readFile(string const& _kind, str return ReadCallback::Result{true, m_sourceCodes.at(_sourceUnitName)}; string const strippedSourceUnitName = stripFileUriSchemePrefix(_sourceUnitName); + Result const resolvedPath = tryResolvePath(strippedSourceUnitName); + if (!resolvedPath.message().empty()) + return ReadCallback::Result{false, resolvedPath.message()}; - if ( - boost::filesystem::path(strippedSourceUnitName).has_root_path() && - boost::filesystem::exists(strippedSourceUnitName) - ) - { - auto contents = readFileAsString(strippedSourceUnitName); - solAssert(m_sourceCodes.count(_sourceUnitName) == 0, ""); - m_sourceCodes[_sourceUnitName] = contents; - return ReadCallback::Result{true, move(contents)}; - } - - vector candidates; - vector> prefixes = {m_basePath}; - prefixes += (m_includePaths | ranges::to>>); - - auto const pathToQuotedString = [](boost::filesystem::path const& _path) { return "\"" + _path.string() + "\""; }; - - for (auto const& prefix: prefixes) - { - boost::filesystem::path canonicalPath = boost::filesystem::path(prefix) / boost::filesystem::path(strippedSourceUnitName); - - if (boost::filesystem::exists(canonicalPath)) - candidates.push_back(move(canonicalPath)); - } - - if (candidates.empty()) - return ReadCallback::Result{ - false, - "File not found. Searched the following locations: " + - joinHumanReadable(prefixes | ranges::views::transform(pathToQuotedString), ", ") + - "." - }; - - if (candidates.size() >= 2) - return ReadCallback::Result{ - false, - "Ambiguous import. " - "Multiple matching files found inside base path and/or include paths: " + - joinHumanReadable(candidates | ranges::views::transform(pathToQuotedString), ", ") + - "." - }; - - if (!boost::filesystem::is_regular_file(candidates[0])) - return ReadCallback::Result{false, "Not a valid file."}; - - auto contents = readFileAsString(candidates[0]); + auto contents = readFileAsString(resolvedPath.get()); solAssert(m_sourceCodes.count(_sourceUnitName) == 0, ""); m_sourceCodes[_sourceUnitName] = contents; - return ReadCallback::Result{true, move(contents)}; + return ReadCallback::Result{true, std::move(contents)}; } catch (std::exception const& _exception) { diff --git a/libsolidity/lsp/FileRepository.h b/libsolidity/lsp/FileRepository.h index 152c1d4be..dfd931938 100644 --- a/libsolidity/lsp/FileRepository.h +++ b/libsolidity/lsp/FileRepository.h @@ -18,6 +18,7 @@ #pragma once #include +#include #include #include @@ -28,7 +29,10 @@ namespace solidity::lsp class FileRepository { public: - explicit FileRepository(boost::filesystem::path _basePath); + FileRepository(boost::filesystem::path _basePath, std::vector _includePaths); + + std::vector const& includePaths() const noexcept { return m_includePaths; } + void setIncludePaths(std::vector _paths); boost::filesystem::path const& basePath() const { return m_basePath; } @@ -44,7 +48,6 @@ public: /// Changes the source identified by the LSP client path _uri to _text. void setSourceByUri(std::string const& _uri, std::string _text); - void addOrUpdateFile(boost::filesystem::path const& _path, frontend::SourceCode _source); void setSourceUnits(StringMap _sources); frontend::ReadCallback::Result readFile(std::string const& _kind, std::string const& _sourceUnitName); frontend::ReadCallback::Callback reader() @@ -52,6 +55,8 @@ public: return [this](std::string const& _kind, std::string const& _path) { return readFile(_kind, _path); }; } + util::Result tryResolvePath(std::string const& _sourceUnitName) const; + private: /// Base path without URI scheme. boost::filesystem::path m_basePath; diff --git a/libsolidity/lsp/GotoDefinition.cpp b/libsolidity/lsp/GotoDefinition.cpp index 26fb686db..532792c17 100644 --- a/libsolidity/lsp/GotoDefinition.cpp +++ b/libsolidity/lsp/GotoDefinition.cpp @@ -44,13 +44,13 @@ void GotoDefinition::operator()(MessageID _id, Json::Value const& _args) // Handles all expressions that can have one or more declaration annotation. if (auto const* declaration = referencedDeclaration(expression)) if (auto location = declarationLocation(declaration)) - locations.emplace_back(move(location.value())); + locations.emplace_back(std::move(location.value())); } else if (auto const* identifierPath = dynamic_cast(sourceNode)) { if (auto const* declaration = identifierPath->annotation().referencedDeclaration) if (auto location = declarationLocation(declaration)) - locations.emplace_back(move(location.value())); + locations.emplace_back(std::move(location.value())); } else if (auto const* importDirective = dynamic_cast(sourceNode)) { diff --git a/libsolidity/lsp/HandlerBase.h b/libsolidity/lsp/HandlerBase.h index 3ca1679be..e2ccb88d8 100644 --- a/libsolidity/lsp/HandlerBase.h +++ b/libsolidity/lsp/HandlerBase.h @@ -45,8 +45,8 @@ public: /// from the JSON-RPC parameters. std::pair extractSourceUnitNameAndLineColumn(Json::Value const& _params) const; - langutil::CharStreamProvider const& charStreamProvider() const noexcept { return m_server.charStreamProvider(); } - FileRepository const& fileRepository() const noexcept { return m_server.fileRepository(); } + langutil::CharStreamProvider const& charStreamProvider() const noexcept { return m_server.compilerStack(); } + FileRepository& fileRepository() const noexcept { return m_server.fileRepository(); } Transport& client() const noexcept { return m_server.client(); } protected: diff --git a/libsolidity/lsp/LanguageServer.cpp b/libsolidity/lsp/LanguageServer.cpp index 44b0cf041..ce68dbef3 100644 --- a/libsolidity/lsp/LanguageServer.cpp +++ b/libsolidity/lsp/LanguageServer.cpp @@ -26,10 +26,13 @@ // LSP feature implementations #include +#include +#include #include #include +#include #include #include @@ -40,6 +43,8 @@ #include #include +#include + using namespace std; using namespace std::string_literals; using namespace std::placeholders; @@ -48,9 +53,25 @@ using namespace solidity::lsp; using namespace solidity::langutil; using namespace solidity::frontend; +namespace fs = boost::filesystem; + namespace { +bool resolvesToRegularFile(boost::filesystem::path _path, int maxRecursionDepth = 10) +{ + fs::file_status fileStatus = fs::status(_path); + + while (fileStatus.type() == fs::file_type::symlink_file && maxRecursionDepth > 0) + { + _path = boost::filesystem::read_symlink(_path); + fileStatus = fs::status(_path); + maxRecursionDepth--; + } + + return fileStatus.type() == fs::file_type::regular_file; +} + int toDiagnosticSeverity(Error::Type _errorType) { // 1=Error, 2=Warning, 3=Info, 4=Hint @@ -64,6 +85,49 @@ int toDiagnosticSeverity(Error::Type _errorType) return -1; } +Json::Value semanticTokensLegend() +{ + Json::Value legend = Json::objectValue; + + // NOTE! The (alphabetical) order and items must match exactly the items of + // their respective enum class members. + + Json::Value tokenTypes = Json::arrayValue; + tokenTypes.append("class"); + tokenTypes.append("comment"); + tokenTypes.append("enum"); + tokenTypes.append("enumMember"); + tokenTypes.append("event"); + tokenTypes.append("function"); + tokenTypes.append("interface"); + tokenTypes.append("keyword"); + tokenTypes.append("macro"); + tokenTypes.append("method"); + tokenTypes.append("modifier"); + tokenTypes.append("number"); + tokenTypes.append("operator"); + tokenTypes.append("parameter"); + tokenTypes.append("property"); + tokenTypes.append("string"); + tokenTypes.append("struct"); + tokenTypes.append("type"); + tokenTypes.append("typeParameter"); + tokenTypes.append("variable"); + legend["tokenTypes"] = tokenTypes; + + Json::Value tokenModifiers = Json::arrayValue; + tokenModifiers.append("abstract"); + tokenModifiers.append("declaration"); + tokenModifiers.append("definition"); + tokenModifiers.append("deprecated"); + tokenModifiers.append("documentation"); + tokenModifiers.append("modification"); + tokenModifiers.append("readonly"); + legend["tokenModifiers"] = tokenModifiers; + + return legend; +} + } LanguageServer::LanguageServer(Transport& _transport): @@ -73,17 +137,19 @@ LanguageServer::LanguageServer(Transport& _transport): {"cancelRequest", [](auto, auto) {/*nothing for now as we are synchronous */}}, {"exit", [this](auto, auto) { m_state = (m_state == State::ShutdownRequested ? State::ExitRequested : State::ExitWithoutShutdown); }}, {"initialize", bind(&LanguageServer::handleInitialize, this, _1, _2)}, - {"initialized", [](auto, auto) {}}, - {"$/setTrace", bind(&LanguageServer::setTrace, this, _2)}, + {"initialized", bind(&LanguageServer::handleInitialized, this, _1, _2)}, + {"$/setTrace", [this](auto, Json::Value const& args) { setTrace(args["value"]); }}, {"shutdown", [this](auto, auto) { m_state = State::ShutdownRequested; }}, {"textDocument/definition", GotoDefinition(*this) }, {"textDocument/didOpen", bind(&LanguageServer::handleTextDocumentDidOpen, this, _2)}, {"textDocument/didChange", bind(&LanguageServer::handleTextDocumentDidChange, this, _2)}, {"textDocument/didClose", bind(&LanguageServer::handleTextDocumentDidClose, this, _2)}, + {"textDocument/rename", RenameSymbol(*this) }, {"textDocument/implementation", GotoDefinition(*this) }, + {"textDocument/semanticTokens/full", bind(&LanguageServer::semanticTokensFull, this, _1, _2)}, {"workspace/didChangeConfiguration", bind(&LanguageServer::handleWorkspaceDidChangeConfiguration, this, _2)}, }, - m_fileRepository("/" /* basePath */), + m_fileRepository("/" /* basePath */, {} /* no search paths */), m_compilerStack{m_fileRepository.reader()} { } @@ -100,7 +166,68 @@ Json::Value LanguageServer::toJson(SourceLocation const& _location) void LanguageServer::changeConfiguration(Json::Value const& _settings) { + // The settings item: "file-load-strategy" (enum) defaults to "project-directory" if not (or not correctly) set. + // It can be overridden during client's handshake or at runtime, as usual. + // + // If this value is set to "project-directory" (default), all .sol files located inside the project directory or reachable through symbolic links will be subject to operations. + // + // Operations include compiler analysis, but also finding all symbolic references or symbolic renaming. + // + // If this value is set to "directly-opened-and-on-import", then only currently directly opened files and + // those files being imported directly or indirectly will be included in operations. + if (_settings["file-load-strategy"]) + { + auto const text = _settings["file-load-strategy"].asString(); + if (text == "project-directory") + m_fileLoadStrategy = FileLoadStrategy::ProjectDirectory; + else if (text == "directly-opened-and-on-import") + m_fileLoadStrategy = FileLoadStrategy::DirectlyOpenedAndOnImported; + else + lspAssert(false, ErrorCode::InvalidParams, "Invalid file load strategy: " + text); + } + m_settingsObject = _settings; + Json::Value jsonIncludePaths = _settings["include-paths"]; + + if (jsonIncludePaths) + { + int typeFailureCount = 0; + if (jsonIncludePaths.isArray()) + { + vector includePaths; + for (Json::Value const& jsonPath: jsonIncludePaths) + { + if (jsonPath.isString()) + includePaths.emplace_back(boost::filesystem::path(jsonPath.asString())); + else + typeFailureCount++; + } + m_fileRepository.setIncludePaths(std::move(includePaths)); + } + else + ++typeFailureCount; + + if (typeFailureCount) + m_client.trace("Invalid JSON configuration passed. \"include-paths\" must be an array of strings."); + } +} + +vector LanguageServer::allSolidityFilesFromProject() const +{ + vector collectedPaths{}; + + // We explicitly decided against including all files from include paths but leave the possibility + // open for a future PR to enable such a feature to be optionally enabled (default disabled). + + auto directoryIterator = fs::recursive_directory_iterator(m_fileRepository.basePath(), fs::symlink_option::recurse); + for (fs::directory_entry const& dirEntry: directoryIterator) + if ( + dirEntry.path().extension() == ".sol" && + (dirEntry.status().type() == fs::file_type::regular_file || resolvesToRegularFile(dirEntry.path())) + ) + collectedPaths.push_back(dirEntry.path()); + + return collectedPaths; } void LanguageServer::compile() @@ -108,9 +235,21 @@ void LanguageServer::compile() // For files that are not open, we have to take changes on disk into account, // so we just remove all non-open files. - FileRepository oldRepository(m_fileRepository.basePath()); + FileRepository oldRepository(m_fileRepository.basePath(), m_fileRepository.includePaths()); swap(oldRepository, m_fileRepository); + // Load all solidity files from project. + if (m_fileLoadStrategy == FileLoadStrategy::ProjectDirectory) + for (auto const& projectFile: allSolidityFilesFromProject()) + { + lspDebug(fmt::format("adding project file: {}", projectFile.generic_string())); + m_fileRepository.setSourceByUri( + m_fileRepository.sourceUnitNameToUri(projectFile.generic_string()), + util::readFileAsString(projectFile) + ); + } + + // Overwrite all files as opened by the client, including the ones which might potentially have changes. for (string const& fileName: m_openFiles) m_fileRepository.setSourceByUri( fileName, @@ -150,7 +289,7 @@ void LanguageServer::compileAndUpdateDiagnostics() string message = error->typeName() + ":"; if (string const* comment = error->comment()) message += " " + *comment; - jsonDiag["message"] = move(message); + jsonDiag["message"] = std::move(message); jsonDiag["range"] = toRange(*location); if (auto const* secondary = error->secondarySourceLocation()) @@ -179,8 +318,8 @@ void LanguageServer::compileAndUpdateDiagnostics() params["uri"] = m_fileRepository.sourceUnitNameToUri(sourceUnitName); if (!diagnostics.empty()) m_nonemptyDiagnostics.insert(sourceUnitName); - params["diagnostics"] = move(diagnostics); - m_client.notify("textDocument/publishDiagnostics", move(params)); + params["diagnostics"] = std::move(diagnostics); + m_client.notify("textDocument/publishDiagnostics", std::move(params)); } } @@ -199,6 +338,7 @@ bool LanguageServer::run() { string const methodName = (*jsonMessage)["method"].asString(); id = (*jsonMessage)["id"]; + lspDebug(fmt::format("received method call: {}", methodName)); if (auto handler = util::valueOrDefault(m_handlers, methodName)) handler(id, (*jsonMessage)["params"]); @@ -208,6 +348,10 @@ bool LanguageServer::run() else m_client.error({}, ErrorCode::ParseError, "\"method\" has to be a string."); } + catch (Json::Exception const&) + { + m_client.error(id, ErrorCode::InvalidParams, "JSON object access error. Most likely due to a badly formatted JSON request message."s); + } catch (RequestError const& error) { m_client.error(id, error.code(), error.comment() ? *error.comment() : ""s); @@ -255,7 +399,10 @@ void LanguageServer::handleInitialize(MessageID _id, Json::Value const& _args) else if (Json::Value rootPath = _args["rootPath"]) rootPath = rootPath.asString(); - m_fileRepository = FileRepository(rootPath); + if (_args["trace"]) + setTrace(_args["trace"]); + + m_fileRepository = FileRepository(rootPath, {}); if (_args["initializationOptions"].isObject()) changeConfiguration(_args["initializationOptions"]); @@ -266,8 +413,35 @@ void LanguageServer::handleInitialize(MessageID _id, Json::Value const& _args) replyArgs["capabilities"]["implementationProvider"] = true; replyArgs["capabilities"]["textDocumentSync"]["change"] = 2; // 0=none, 1=full, 2=incremental replyArgs["capabilities"]["textDocumentSync"]["openClose"] = true; + replyArgs["capabilities"]["semanticTokensProvider"]["legend"] = semanticTokensLegend(); + replyArgs["capabilities"]["semanticTokensProvider"]["range"] = false; + replyArgs["capabilities"]["semanticTokensProvider"]["full"] = true; // XOR requests.full.delta = true + replyArgs["capabilities"]["renameProvider"] = true; - m_client.reply(_id, move(replyArgs)); + m_client.reply(_id, std::move(replyArgs)); +} + +void LanguageServer::handleInitialized(MessageID, Json::Value const&) +{ + if (m_fileLoadStrategy == FileLoadStrategy::ProjectDirectory) + compileAndUpdateDiagnostics(); +} + +void LanguageServer::semanticTokensFull(MessageID _id, Json::Value const& _args) +{ + auto uri = _args["textDocument"]["uri"]; + + compile(); + + auto const sourceName = m_fileRepository.uriToSourceUnitName(uri.as()); + SourceUnit const& ast = m_compilerStack.ast(sourceName); + m_compilerStack.charStream(sourceName); + Json::Value data = SemanticTokensBuilder().build(ast, m_compilerStack.charStream(sourceName)); + + Json::Value reply = Json::objectValue; + reply["data"] = data; + + m_client.reply(_id, std::move(reply)); } void LanguageServer::handleWorkspaceDidChangeConfiguration(Json::Value const& _args) @@ -280,11 +454,11 @@ void LanguageServer::handleWorkspaceDidChangeConfiguration(Json::Value const& _a void LanguageServer::setTrace(Json::Value const& _args) { - if (!_args["value"].isString()) + if (!_args.isString()) // Simply ignore invalid parameter. return; - string const stringValue = _args["value"].asString(); + string const stringValue = _args.asString(); if (stringValue == "off") m_client.setTrace(TraceValue::Off); else if (stringValue == "messages") @@ -306,7 +480,7 @@ void LanguageServer::handleTextDocumentDidOpen(Json::Value const& _args) string text = _args["textDocument"]["text"].asString(); string uri = _args["textDocument"]["uri"].asString(); m_openFiles.insert(uri); - m_fileRepository.setSourceByUri(uri, move(text)); + m_fileRepository.setSourceByUri(uri, std::move(text)); compileAndUpdateDiagnostics(); } @@ -342,10 +516,10 @@ void LanguageServer::handleTextDocumentDidChange(Json::Value const& _args) ); string buffer = m_fileRepository.sourceUnits().at(sourceUnitName); - buffer.replace(static_cast(change->start), static_cast(change->end - change->start), move(text)); - text = move(buffer); + buffer.replace(static_cast(change->start), static_cast(change->end - change->start), std::move(text)); + text = std::move(buffer); } - m_fileRepository.setSourceByUri(uri, move(text)); + m_fileRepository.setSourceByUri(uri, std::move(text)); } compileAndUpdateDiagnostics(); @@ -367,6 +541,7 @@ void LanguageServer::handleTextDocumentDidClose(Json::Value const& _args) compileAndUpdateDiagnostics(); } + ASTNode const* LanguageServer::astNodeAtSourceLocation(std::string const& _sourceUnitName, LineColumn const& _filePos) { if (m_compilerStack.state() < CompilerStack::AnalysisPerformed) diff --git a/libsolidity/lsp/LanguageServer.h b/libsolidity/lsp/LanguageServer.h index 2a7951fb0..a05bec497 100644 --- a/libsolidity/lsp/LanguageServer.h +++ b/libsolidity/lsp/LanguageServer.h @@ -33,8 +33,26 @@ namespace solidity::lsp { +class RenameSymbol; enum class ErrorCode; +/** + * Enum to mandate what files to take into consideration for source code analysis. + */ +enum class FileLoadStrategy +{ + /// Takes only those files into consideration that are explicitly opened and those + /// that have been directly or indirectly imported. + DirectlyOpenedAndOnImported = 0, + + /// Takes all Solidity (.sol) files within the project root into account. + /// Symbolic links will be followed, even if they lead outside of the project directory + /// (`--allowed-paths` is currently ignored by the LSP). + /// + /// This resembles the closest what other LSPs should be doing already. + ProjectDirectory = 1, +}; + /** * Solidity Language Server, managing one LSP client. * This implements a subset of LSP version 3.16 that can be found at: @@ -60,25 +78,31 @@ public: FileRepository& fileRepository() noexcept { return m_fileRepository; } Transport& client() noexcept { return m_client; } frontend::ASTNode const* astNodeAtSourceLocation(std::string const& _sourceUnitName, langutil::LineColumn const& _filePos); - langutil::CharStreamProvider const& charStreamProvider() const noexcept { return m_compilerStack; } + frontend::CompilerStack const& compilerStack() const noexcept { return m_compilerStack; } private: /// Checks if the server is initialized (to be used by messages that need it to be initialized). /// Reports an error and returns false if not. void requireServerInitialized(); void handleInitialize(MessageID _id, Json::Value const& _args); + void handleInitialized(MessageID _id, Json::Value const& _args); void handleWorkspaceDidChangeConfiguration(Json::Value const& _args); void setTrace(Json::Value const& _args); void handleTextDocumentDidOpen(Json::Value const& _args); void handleTextDocumentDidChange(Json::Value const& _args); void handleTextDocumentDidClose(Json::Value const& _args); + void handleRename(Json::Value const& _args); void handleGotoDefinition(MessageID _id, Json::Value const& _args); + void semanticTokensFull(MessageID _id, Json::Value const& _args); /// Invoked when the server user-supplied configuration changes (initiated by the client). void changeConfiguration(Json::Value const&); /// Compile everything until after analysis phase. void compile(); + + std::vector allSolidityFilesFromProject() const; + using MessageHandler = std::function; Json::Value toRange(langutil::SourceLocation const& _location); @@ -97,6 +121,7 @@ private: /// Set of source unit names for which we sent diagnostics to the client in the last iteration. std::set m_nonemptyDiagnostics; FileRepository m_fileRepository; + FileLoadStrategy m_fileLoadStrategy = FileLoadStrategy::ProjectDirectory; frontend::CompilerStack m_compilerStack; diff --git a/libsolidity/lsp/RenameSymbol.cpp b/libsolidity/lsp/RenameSymbol.cpp new file mode 100644 index 000000000..e205beb73 --- /dev/null +++ b/libsolidity/lsp/RenameSymbol.cpp @@ -0,0 +1,316 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 +#include +#include + +#include + +#include + +#include +#include +#include + +using namespace solidity::frontend; +using namespace solidity::langutil; +using namespace solidity::lsp; +using namespace std; + +namespace +{ + +CallableDeclaration const* extractCallableDeclaration(FunctionCall const& _functionCall) +{ + if ( + auto const* functionType = dynamic_cast(_functionCall.expression().annotation().type); + functionType && functionType->hasDeclaration() + ) + if (auto const* functionDefinition = dynamic_cast(&functionType->declaration())) + return functionDefinition; + + return nullptr; +} + +} + +void RenameSymbol::operator()(MessageID _id, Json::Value const& _args) +{ + auto const&& [sourceUnitName, lineColumn] = extractSourceUnitNameAndLineColumn(_args); + string const newName = _args["newName"].asString(); + string const uri = _args["textDocument"]["uri"].asString(); + + ASTNode const* sourceNode = m_server.astNodeAtSourceLocation(sourceUnitName, lineColumn); + + m_symbolName = {}; + m_declarationToRename = nullptr; + m_sourceUnits = { &m_server.compilerStack().ast(sourceUnitName) }; + m_locations.clear(); + + optional cursorBytePosition = charStreamProvider() + .charStream(sourceUnitName) + .translateLineColumnToPosition(lineColumn); + solAssert(cursorBytePosition.has_value(), "Expected source pos"); + + extractNameAndDeclaration(*sourceNode, *cursorBytePosition); + + // Find all source units using this symbol + for (auto const& [name, content]: fileRepository().sourceUnits()) + { + auto const& sourceUnit = m_server.compilerStack().ast(name); + for (auto const* referencedSourceUnit: sourceUnit.referencedSourceUnits(true, util::convertContainer>(m_sourceUnits))) + if (*referencedSourceUnit->location().sourceName == sourceUnitName) + { + m_sourceUnits.insert(&sourceUnit); + break; + } + } + + // Origin source unit should always be checked + m_sourceUnits.insert(&m_declarationToRename->sourceUnit()); + + Visitor visitor(*this); + + for (auto const* sourceUnit: m_sourceUnits) + sourceUnit->accept(visitor); + + // Apply changes in reverse order (will iterate in reverse) + sort(m_locations.begin(), m_locations.end()); + + Json::Value reply = Json::objectValue; + reply["changes"] = Json::objectValue; + + Json::Value edits = Json::arrayValue; + + for (auto i = m_locations.rbegin(); i != m_locations.rend(); i++) + { + solAssert(i->isValid()); + + // Replace in our file repository + string const uri = fileRepository().sourceUnitNameToUri(*i->sourceName); + string buffer = fileRepository().sourceUnits().at(*i->sourceName); + buffer.replace((size_t)i->start, (size_t)(i->end - i->start), newName); + fileRepository().setSourceByUri(uri, std::move(buffer)); + + Json::Value edit = Json::objectValue; + edit["range"] = toRange(*i); + edit["newText"] = newName; + + // Record changes for the client + edits.append(edit); + if (i + 1 == m_locations.rend() || (i + 1)->sourceName != i->sourceName) + { + reply["changes"][uri] = edits; + edits = Json::arrayValue; + } + } + + client().reply(_id, reply); +} + +void RenameSymbol::extractNameAndDeclaration(ASTNode const& _node, int _cursorBytePosition) +{ + // Identify symbol name and node + if (auto const* declaration = dynamic_cast(&_node)) + { + if (declaration->nameLocation().containsOffset(_cursorBytePosition)) + { + m_symbolName = declaration->name(); + m_declarationToRename = declaration; + } + else if (auto const* importDirective = dynamic_cast(declaration)) + extractNameAndDeclaration(*importDirective, _cursorBytePosition); + } + else if (auto const* identifier = dynamic_cast(&_node)) + { + if (auto const* declReference = dynamic_cast(identifier->annotation().referencedDeclaration)) + { + m_symbolName = identifier->name(); + m_declarationToRename = declReference; + } + } + else if (auto const* identifierPath = dynamic_cast(&_node)) + extractNameAndDeclaration(*identifierPath, _cursorBytePosition); + else if (auto const* memberAccess = dynamic_cast(&_node)) + { + m_symbolName = memberAccess->memberName(); + m_declarationToRename = memberAccess->annotation().referencedDeclaration; + } + else if (auto const* functionCall = dynamic_cast(&_node)) + extractNameAndDeclaration(*functionCall, _cursorBytePosition); + else if (auto const* inlineAssembly = dynamic_cast(&_node)) + extractNameAndDeclaration(*inlineAssembly, _cursorBytePosition); + else + solAssert(false, "Unexpected ASTNODE id: " + to_string(_node.id())); + + lspDebug(fmt::format("Goal: rename '{}', loc: {}-{}", m_symbolName, m_declarationToRename->nameLocation().start, m_declarationToRename->nameLocation().end)); +} + +void RenameSymbol::extractNameAndDeclaration(ImportDirective const& _importDirective, int _cursorBytePosition) +{ + for (ImportDirective::SymbolAlias const& symbolAlias: _importDirective.symbolAliases()) + if (symbolAlias.location.containsOffset(_cursorBytePosition)) + { + solAssert(symbolAlias.alias); + m_symbolName = *symbolAlias.alias; + m_declarationToRename = symbolAlias.symbol->annotation().referencedDeclaration; + break; + } +} + +void RenameSymbol::Visitor::endVisit(ImportDirective const& _node) +{ + // Handles SourceUnit aliases + if (handleGenericDeclaration(_node)) + return; + + for (ImportDirective::SymbolAlias const& symbolAlias: _node.symbolAliases()) + if ( + symbolAlias.alias != nullptr && + *symbolAlias.alias == m_outer.m_symbolName && + symbolAlias.symbol->annotation().referencedDeclaration == m_outer.m_declarationToRename + ) + m_outer.m_locations.emplace_back(symbolAlias.location); +} + +void RenameSymbol::extractNameAndDeclaration(FunctionCall const& _functionCall, int _cursorBytePosition) +{ + if (auto const* functionDefinition = extractCallableDeclaration(_functionCall)) + for (size_t i = 0; i < _functionCall.names().size(); i++) + if (_functionCall.nameLocations()[i].containsOffset(_cursorBytePosition)) + { + m_symbolName = *_functionCall.names()[i]; + for (size_t j = 0; j < functionDefinition->parameters().size(); j++) + if ( + functionDefinition->parameters()[j] && + functionDefinition->parameters()[j]->name() == m_symbolName + ) + m_declarationToRename = functionDefinition->parameters()[j].get(); + return; + } +} + +void RenameSymbol::Visitor::endVisit(FunctionCall const& _node) +{ + SourceLocation nameLocationInFunctionCall; + + for (size_t i = 0; i < _node.names().size(); i++) + if (_node.names()[i] && *_node.names()[i] == m_outer.m_symbolName) + nameLocationInFunctionCall = _node.nameLocations()[i]; + + if (!nameLocationInFunctionCall.isValid()) + return; + + if (auto const* functionDefinition = extractCallableDeclaration(_node)) + for (size_t j = 0; j < functionDefinition->parameters().size(); j++) + if ( + functionDefinition->parameters()[j] && + *functionDefinition->parameters()[j] == *m_outer.m_declarationToRename + ) + m_outer.m_locations.emplace_back(nameLocationInFunctionCall); +} + +void RenameSymbol::Visitor::endVisit(MemberAccess const& _node) +{ + if ( + m_outer.m_symbolName == _node.memberName() && + *m_outer.m_declarationToRename == *_node.annotation().referencedDeclaration + ) + m_outer.m_locations.emplace_back(_node.memberLocation()); +} + +void RenameSymbol::Visitor::endVisit(Identifier const& _node) +{ + if ( + m_outer.m_symbolName == _node.name() && + *m_outer.m_declarationToRename == *_node.annotation().referencedDeclaration + ) + m_outer.m_locations.emplace_back(_node.location()); +} + +void RenameSymbol::extractNameAndDeclaration(IdentifierPath const& _identifierPath, int _cursorBytePosition) +{ + // iterate through the elements of the path to find the one the cursor is on + size_t numIdentifiers = _identifierPath.pathLocations().size(); + for (size_t i = 0; i < numIdentifiers; i++) + { + auto& location = _identifierPath.pathLocations()[i]; + + if (location.containsOffset(_cursorBytePosition)) + { + solAssert(_identifierPath.annotation().pathDeclarations.size() == numIdentifiers); + solAssert(_identifierPath.path().size() == numIdentifiers); + + m_declarationToRename = _identifierPath.annotation().pathDeclarations[i]; + m_symbolName = _identifierPath.path()[i]; + } + } +} + +void RenameSymbol::Visitor::endVisit(IdentifierPath const& _node) +{ + std::vector& declarations = _node.annotation().pathDeclarations; + solAssert(declarations.size() == _node.path().size()); + + for (size_t i = 0; i < _node.path().size(); i++) + if ( + _node.path()[i] == m_outer.m_symbolName && + declarations[i] == m_outer.m_declarationToRename + ) + m_outer.m_locations.emplace_back(_node.pathLocations()[i]); +} + +void RenameSymbol::extractNameAndDeclaration(InlineAssembly const& _inlineAssembly, int _cursorBytePosition) +{ + for (auto&& [identifier, externalReference]: _inlineAssembly.annotation().externalReferences) + { + SourceLocation location = yul::nativeLocationOf(*identifier); + location.end -= static_cast(externalReference.suffix.size() + 1); + + if (location.containsOffset(_cursorBytePosition)) + { + m_declarationToRename = externalReference.declaration; + m_symbolName = identifier->name.str(); + + if (!externalReference.suffix.empty()) + m_symbolName = m_symbolName.substr(0, m_symbolName.length() - externalReference.suffix.size() - 1); + break; + } + } +} + +void RenameSymbol::Visitor::endVisit(InlineAssembly const& _node) +{ + for (auto&& [identifier, externalReference]: _node.annotation().externalReferences) + { + string identifierName = identifier->name.str(); + if (!externalReference.suffix.empty()) + identifierName = identifierName.substr(0, identifierName.length() - externalReference.suffix.size() - 1); + + if ( + externalReference.declaration == m_outer.m_declarationToRename && + identifierName == m_outer.m_symbolName + ) + { + SourceLocation location = yul::nativeLocationOf(*identifier); + location.end -= static_cast(externalReference.suffix.size() + 1); + + m_outer.m_locations.emplace_back(location); + } + } + +} diff --git a/libsolidity/lsp/RenameSymbol.h b/libsolidity/lsp/RenameSymbol.h new file mode 100644 index 000000000..cafa8c067 --- /dev/null +++ b/libsolidity/lsp/RenameSymbol.h @@ -0,0 +1,119 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 +#include +#include +#include + +namespace solidity::lsp +{ + +class RenameSymbol: public HandlerBase +{ +public: + explicit RenameSymbol(LanguageServer& _server): HandlerBase(_server) {} + + void operator()(MessageID, Json::Value const&); +protected: + // Nested class because otherwise `RenameSymbol` couldn't be easily used + // with LanguageServer::m_handlers as `ASTConstVisitor` deletes required + // c'tors + struct Visitor: public frontend::ASTConstVisitor + { + explicit Visitor(RenameSymbol& _outer): m_outer(_outer) {} + void endVisit(frontend::ImportDirective const& _node) override; + void endVisit(frontend::MemberAccess const& _node) override; + void endVisit(frontend::Identifier const& _node) override; + void endVisit(frontend::IdentifierPath const& _node) override; + void endVisit(frontend::FunctionCall const& _node) override; + void endVisit(frontend::InlineAssembly const& _node) override; + + void endVisit(frontend::ContractDefinition const& _node) override + { + handleGenericDeclaration(_node); + } + void endVisit(frontend::StructDefinition const& _node) override + { + handleGenericDeclaration(_node); + } + void endVisit(frontend::EnumDefinition const& _node) override + { + handleGenericDeclaration(_node); + } + void endVisit(frontend::EnumValue const& _node) override + { + handleGenericDeclaration(_node); + } + void endVisit(frontend::UserDefinedValueTypeDefinition const& _node) override + { + handleGenericDeclaration(_node); + } + void endVisit(frontend::VariableDeclaration const& _node) override + { + handleGenericDeclaration(_node); + } + void endVisit(frontend::FunctionDefinition const& _node) override + { + handleGenericDeclaration(_node); + } + void endVisit(frontend::ModifierDefinition const& _node) override + { + handleGenericDeclaration(_node); + } + void endVisit(frontend::EventDefinition const& _node) override + { + handleGenericDeclaration(_node); + } + void endVisit(frontend::ErrorDefinition const& _node) override + { + handleGenericDeclaration(_node); + } + + bool handleGenericDeclaration(frontend::Declaration const& _declaration) + { + if ( + m_outer.m_symbolName == _declaration.name() && + *m_outer.m_declarationToRename == _declaration + ) + { + m_outer.m_locations.emplace_back(_declaration.nameLocation()); + return true; + } + return false; + } + + private: + RenameSymbol& m_outer; + }; + + void extractNameAndDeclaration(frontend::ASTNode const& _node, int _cursorBytePosition); + void extractNameAndDeclaration(frontend::IdentifierPath const& _identifierPath, int _cursorBytePosition); + void extractNameAndDeclaration(frontend::ImportDirective const& _importDirective, int _cursorBytePosition); + void extractNameAndDeclaration(frontend::FunctionCall const& _functionCall, int _cursorBytePosition); + void extractNameAndDeclaration(frontend::InlineAssembly const& _inlineAssembly, int _cursorBytePosition); + + // Node to rename + frontend::Declaration const* m_declarationToRename = nullptr; + // Original name + frontend::ASTString m_symbolName = {}; + // SourceUnits to search & replace symbol in + std::set m_sourceUnits = {}; + // Source locations that need to be replaced + std::vector m_locations = {}; +}; + +} diff --git a/libsolidity/lsp/SemanticTokensBuilder.cpp b/libsolidity/lsp/SemanticTokensBuilder.cpp new file mode 100644 index 000000000..dae48c1b5 --- /dev/null +++ b/libsolidity/lsp/SemanticTokensBuilder.cpp @@ -0,0 +1,283 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 +#include +#include + +#include +#include + +#include + +using namespace std; +using namespace solidity::langutil; +using namespace solidity::frontend; + +namespace solidity::lsp +{ + +namespace +{ + +optional semanticTokenTypeForType(frontend::Type const* _type) +{ + if (!_type) + return nullopt; + + switch (_type->category()) + { + case frontend::Type::Category::Address: return SemanticTokenType::Class; + case frontend::Type::Category::Bool: return SemanticTokenType::Number; + case frontend::Type::Category::Enum: return SemanticTokenType::Enum; + case frontend::Type::Category::Function: return SemanticTokenType::Function; + case frontend::Type::Category::Integer: return SemanticTokenType::Number; + case frontend::Type::Category::RationalNumber: return SemanticTokenType::Number; + case frontend::Type::Category::StringLiteral: return SemanticTokenType::String; + case frontend::Type::Category::Struct: return SemanticTokenType::Struct; + case frontend::Type::Category::Contract: return SemanticTokenType::Class; + default: + lspDebug(fmt::format("semanticTokenTypeForType: unknown category: {}", static_cast(_type->category()))); + return SemanticTokenType::Type; + } +} + +SemanticTokenType semanticTokenTypeForExpression(frontend::Type const* _type) +{ + if (!_type) + return SemanticTokenType::Variable; + + switch (_type->category()) + { + case frontend::Type::Category::Enum: + return SemanticTokenType::Enum; + default: + return SemanticTokenType::Variable; + } +} + +} // end namespace + +Json::Value SemanticTokensBuilder::build(SourceUnit const& _sourceUnit, CharStream const& _charStream) +{ + reset(&_charStream); + _sourceUnit.accept(*this); + return m_encodedTokens; +} + +void SemanticTokensBuilder::reset(CharStream const* _charStream) +{ + m_encodedTokens = Json::arrayValue; + m_charStream = _charStream; + m_lastLine = 0; + m_lastStartChar = 0; +} + +void SemanticTokensBuilder::encode( + SourceLocation const& _sourceLocation, + SemanticTokenType _tokenType, + SemanticTokenModifiers _modifiers +) +{ + /* + https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#textDocument_semanticTokens + + // Step-1: Absolute positions + { line: 2, startChar: 5, length: 3, tokenType: 0, tokenModifiers: 3 }, + { line: 2, startChar: 10, length: 4, tokenType: 1, tokenModifiers: 0 }, + { line: 5, startChar: 2, length: 7, tokenType: 2, tokenModifiers: 0 } + + // Step-2: Relative positions as intermediate step + { deltaLine: 2, deltaStartChar: 5, length: 3, tokenType: 0, tokenModifiers: 3 }, + { deltaLine: 0, deltaStartChar: 5, length: 4, tokenType: 1, tokenModifiers: 0 }, + { deltaLine: 3, deltaStartChar: 2, length: 7, tokenType: 2, tokenModifiers: 0 } + + // Step-3: final array result + // 1st token, 2nd token, 3rd token + [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ] + + So traverse through the AST and assign each leaf a token 5-tuple. + */ + + // solAssert(_sourceLocation.isValid()); + if (!_sourceLocation.isValid()) + return; + + auto const [line, startChar] = m_charStream->translatePositionToLineColumn(_sourceLocation.start); + auto const length = _sourceLocation.end - _sourceLocation.start; + + lspDebug(fmt::format("encode [{}:{}..{}] {}", line, startChar, length, _tokenType)); + + m_encodedTokens.append(line - m_lastLine); + if (line == m_lastLine) + m_encodedTokens.append(startChar - m_lastStartChar); + else + m_encodedTokens.append(startChar); + m_encodedTokens.append(length); + m_encodedTokens.append(static_cast(_tokenType)); + m_encodedTokens.append(static_cast(_modifiers)); + + m_lastLine = line; + m_lastStartChar = startChar; +} + +bool SemanticTokensBuilder::visit(frontend::ContractDefinition const& _node) +{ + encode(_node.nameLocation(), SemanticTokenType::Class); + return true; +} + +bool SemanticTokensBuilder::visit(frontend::ElementaryTypeName const& _node) +{ + encode(_node.location(), SemanticTokenType::Type); + return true; +} + +bool SemanticTokensBuilder::visit(frontend::ElementaryTypeNameExpression const& _node) +{ + if (auto const tokenType = semanticTokenTypeForType(_node.annotation().type); tokenType.has_value()) + encode(_node.location(), tokenType.value()); + return true; +} + +bool SemanticTokensBuilder::visit(frontend::EnumDefinition const& _node) +{ + encode(_node.nameLocation(), SemanticTokenType::Enum); + return true; +} + +bool SemanticTokensBuilder::visit(frontend::EnumValue const& _node) +{ + encode(_node.nameLocation(), SemanticTokenType::EnumMember); + return true; +} + +bool SemanticTokensBuilder::visit(frontend::ErrorDefinition const& _node) +{ + encode(_node.nameLocation(), SemanticTokenType::Event); + return true; +} + +bool SemanticTokensBuilder::visit(frontend::FunctionDefinition const& _node) +{ + encode(_node.nameLocation(), SemanticTokenType::Function); + return true; +} + +bool SemanticTokensBuilder::visit(frontend::ModifierDefinition const& _node) +{ + encode(_node.nameLocation(), SemanticTokenType::Modifier); + return true; +} + +void SemanticTokensBuilder::endVisit(frontend::Literal const& _literal) +{ + encode(_literal.location(), SemanticTokenType::Number); +} + +void SemanticTokensBuilder::endVisit(frontend::StructuredDocumentation const& _documentation) +{ + encode(_documentation.location(), SemanticTokenType::Comment); +} + +void SemanticTokensBuilder::endVisit(frontend::Identifier const& _identifier) +{ + //lspDebug(fmt::format("Identifier: {}, {}..{} cat={}", _identifier.name(), _identifier.location().start, _identifier.location().end, _identifier.annotation().type->category())); + + SemanticTokenModifiers modifiers = SemanticTokenModifiers::None; + if (_identifier.annotation().isConstant.set() && *_identifier.annotation().isConstant) + { + lspDebug("OMG We've found a const!"); + modifiers = modifiers | SemanticTokenModifiers::Readonly; + } + + encode(_identifier.location(), semanticTokenTypeForExpression(_identifier.annotation().type), modifiers); +} + +void SemanticTokensBuilder::endVisit(frontend::IdentifierPath const& _node) +{ + lspDebug(fmt::format("IdentifierPath: identifier path [{}..{}]", _node.location().start, _node.location().end)); + for (size_t i = 0; i < _node.path().size(); ++i) + lspDebug(fmt::format(" [{}]: {}", i, _node.path().at(i))); + if (dynamic_cast(_node.annotation().referencedDeclaration)) + encode(_node.location(), SemanticTokenType::EnumMember); + else + encode(_node.location(), SemanticTokenType::Variable); +} + +bool SemanticTokensBuilder::visit(frontend::MemberAccess const& _node) +{ + lspDebug(fmt::format("[{}..{}] MemberAccess({}): {}", _node.location().start, _node.location().end, _node.annotation().referencedDeclaration ? _node.annotation().referencedDeclaration->name() : "?", _node.memberName())); + + auto const memberNameLength = static_cast(_node.memberName().size()); + auto const memberTokenType = semanticTokenTypeForExpression(_node.annotation().type); + + auto lhsLocation = _node.location(); + lhsLocation.end -= (memberNameLength + 1 /*exclude the dot*/); + + auto rhsLocation = _node.location(); + rhsLocation.start = rhsLocation.end - static_cast(memberNameLength); + + if (memberTokenType == SemanticTokenType::Enum) + { + // Special handling for enumeration symbols. + encode(lhsLocation, SemanticTokenType::Enum); + encode(rhsLocation, SemanticTokenType::EnumMember); + } + else if (memberTokenType == SemanticTokenType::Function) + { + // Special handling for function symbols. + encode(lhsLocation, SemanticTokenType::Variable); + encode(rhsLocation, memberTokenType); + } + else + { + encode(rhsLocation, memberTokenType); + } + + return false; // we handle LHS and RHS explicitly above. +} + +void SemanticTokensBuilder::endVisit(PragmaDirective const& _pragma) +{ + encode(_pragma.location(), SemanticTokenType::Macro); + // NOTE: It would be nice if we could highlight based on the symbols, + // such as (version) numerics be different than identifiers. +} + +bool SemanticTokensBuilder::visit(frontend::UserDefinedTypeName const& _node) +{ + if (auto const token = semanticTokenTypeForType(_node.annotation().type); token.has_value()) + encode(_node.location(), *token); + return false; +} + +bool SemanticTokensBuilder::visit(frontend::VariableDeclaration const& _node) +{ + lspDebug(fmt::format("VariableDeclaration: {}", _node.name())); + + if (auto const token = semanticTokenTypeForType(_node.typeName().annotation().type); token.has_value()) + encode(_node.typeName().location(), *token); + + encode(_node.nameLocation(), SemanticTokenType::Variable); + if (_node.overrides()) + _node.overrides()->accept(*this); + if (_node.value()) + _node.value()->accept(*this); + return false; +} + +} // end namespace diff --git a/libsolidity/lsp/SemanticTokensBuilder.h b/libsolidity/lsp/SemanticTokensBuilder.h new file mode 100644 index 000000000..ca3c48d1c --- /dev/null +++ b/libsolidity/lsp/SemanticTokensBuilder.h @@ -0,0 +1,123 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 +#include +#include +#include + +#include + +namespace solidity::langutil +{ +class CharStream; +struct SourceLocation; +} + +namespace solidity::lsp +{ + +// See: https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#semanticTokenTypes +enum class SemanticTokenType +{ + Class, + Comment, + Enum, + EnumMember, + Event, + Function, + Interface, + Keyword, + Macro, + Method, + Modifier, + Number, + Operator, + Parameter, + Property, + String, + Struct, + Type, + TypeParameter, + Variable, + + // Unused below: + // Namespace, + // Regexp, +}; + +enum class SemanticTokenModifiers +{ + None = 0, + + // Member integer values must be bit-values as + // they can be OR'd together. + Abstract = 0x0001, + Declaration = 0x0002, + Definition = 0x0004, + Deprecated = 0x0008, + Documentation = 0x0010, + Modification = 0x0020, + Readonly = 0x0040, + + // Unused below: + // Static, + // Async, + // DefaultLibrary, +}; + +constexpr SemanticTokenModifiers operator|(SemanticTokenModifiers a, SemanticTokenModifiers b) noexcept +{ + return static_cast(static_cast(a) | static_cast(b)); +} + +class SemanticTokensBuilder: public frontend::ASTConstVisitor +{ +public: + Json::Value build(frontend::SourceUnit const& _sourceUnit, langutil::CharStream const& _charStream); + + void reset(langutil::CharStream const* _charStream); + void encode( + langutil::SourceLocation const& _sourceLocation, + SemanticTokenType _tokenType, + SemanticTokenModifiers _modifiers = SemanticTokenModifiers::None + ); + + bool visit(frontend::ContractDefinition const&) override; + bool visit(frontend::ElementaryTypeName const&) override; + bool visit(frontend::ElementaryTypeNameExpression const&) override; + bool visit(frontend::EnumDefinition const&) override; + bool visit(frontend::EnumValue const&) override; + bool visit(frontend::ErrorDefinition const&) override; + bool visit(frontend::FunctionDefinition const&) override; + bool visit(frontend::ModifierDefinition const&) override; + void endVisit(frontend::Literal const&) override; + void endVisit(frontend::StructuredDocumentation const&) override; + void endVisit(frontend::Identifier const&) override; + void endVisit(frontend::IdentifierPath const&) override; + bool visit(frontend::MemberAccess const&) override; + void endVisit(frontend::PragmaDirective const&) override; + bool visit(frontend::UserDefinedTypeName const&) override; + bool visit(frontend::VariableDeclaration const&) override; + +private: + Json::Value m_encodedTokens; + langutil::CharStream const* m_charStream; + int m_lastLine; + int m_lastStartChar; +}; + +} // end namespace diff --git a/libsolidity/lsp/Transport.cpp b/libsolidity/lsp/Transport.cpp index aa85fd6b1..5af723128 100644 --- a/libsolidity/lsp/Transport.cpp +++ b/libsolidity/lsp/Transport.cpp @@ -16,6 +16,7 @@ */ // SPDX-License-Identifier: GPL-3.0 #include +#include #include #include @@ -66,7 +67,7 @@ optional Transport::receive() return nullopt; } - return {move(jsonMessage)}; + return {std::move(jsonMessage)}; } void Transport::trace(std::string _message, Json::Value _extra) @@ -75,9 +76,9 @@ void Transport::trace(std::string _message, Json::Value _extra) { Json::Value params; if (_extra.isObject()) - params = move(_extra); - params["message"] = move(_message); - notify("$/logTrace", move(params)); + params = std::move(_extra); + params["message"] = std::move(_message); + notify("$/logTrace", std::move(params)); } } @@ -100,30 +101,30 @@ optional> Transport::parseHeaders() if (!headers.emplace(boost::trim_copy(name), boost::trim_copy(value)).second) return nullopt; } - return {move(headers)}; + return {std::move(headers)}; } void Transport::notify(string _method, Json::Value _message) { Json::Value json; - json["method"] = move(_method); - json["params"] = move(_message); - send(move(json)); + json["method"] = std::move(_method); + json["params"] = std::move(_message); + send(std::move(json)); } void Transport::reply(MessageID _id, Json::Value _message) { Json::Value json; - json["result"] = move(_message); - send(move(json), _id); + json["result"] = std::move(_message); + send(std::move(json), _id); } void Transport::error(MessageID _id, ErrorCode _code, string _message) { Json::Value json; json["error"]["code"] = static_cast(_code); - json["error"]["message"] = move(_message); - send(move(json), _id); + json["error"]["message"] = std::move(_message); + send(std::move(json), _id); } void Transport::send(Json::Value _json, MessageID _id) @@ -205,11 +206,13 @@ std::string StdioTransport::getline() { std::string line; std::getline(std::cin, line); + lspDebug(fmt::format("Received: {}", line)); return line; } void StdioTransport::writeBytes(std::string_view _data) { + lspDebug(fmt::format("Sending: {}", _data)); auto const bytesWritten = fwrite(_data.data(), 1, _data.size(), stdout); solAssert(bytesWritten == _data.size()); } diff --git a/libsolidity/parsing/DocStringParser.cpp b/libsolidity/parsing/DocStringParser.cpp index 5c07950ed..7e6e158b7 100644 --- a/libsolidity/parsing/DocStringParser.cpp +++ b/libsolidity/parsing/DocStringParser.cpp @@ -116,7 +116,7 @@ multimap DocStringParser::parse() currPos = nlPos + 1; } } - return move(m_docTags); + return std::move(m_docTags); } DocStringParser::iter DocStringParser::parseDocTagLine(iter _pos, iter _end, bool _appending) diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 7bf0de045..afa70609d 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -38,6 +38,7 @@ #include #include #include +#include using namespace std; using namespace solidity::langutil; @@ -273,7 +274,7 @@ ASTPointer Parser::parseImportDirective() expectToken(Token::As); tie(alias, aliasLocation) = expectIdentifierWithLocation(); } - symbolAliases.emplace_back(ImportDirective::SymbolAlias{move(id), move(alias), aliasLocation}); + symbolAliases.emplace_back(ImportDirective::SymbolAlias{std::move(id), std::move(alias), aliasLocation}); if (m_scanner->currentToken() != Token::Comma) break; advance(); @@ -301,7 +302,7 @@ ASTPointer Parser::parseImportDirective() fatalParserError(6326_error, "Import path cannot be empty."); nodeFactory.markEndPosition(); expectToken(Token::Semicolon); - return nodeFactory.createNode(path, unitAlias, unitAliasLocation, move(symbolAliases)); + return nodeFactory.createNode(path, unitAlias, unitAliasLocation, std::move(symbolAliases)); } std::pair Parser::parseContractKind() @@ -495,7 +496,7 @@ ASTPointer Parser::parseOverrideSpecifier() expectToken(Token::RParen); } - return nodeFactory.createNode(move(overrides)); + return nodeFactory.createNode(std::move(overrides)); } StateMutability Parser::parseStateMutability() @@ -685,7 +686,7 @@ ASTPointer Parser::parseStructDefinition() } nodeFactory.markEndPosition(); expectToken(Token::RBrace); - return nodeFactory.createNode(move(name), move(nameLocation), move(members)); + return nodeFactory.createNode(std::move(name), std::move(nameLocation), std::move(members)); } ASTPointer Parser::parseEnumValue() @@ -917,7 +918,7 @@ pair, SourceLocation> Parser::expectIdentifierWithLocation SourceLocation nameLocation = currentLocation(); ASTPointer name = expectIdentifierToken(); - return {move(name), move(nameLocation)}; + return {std::move(name), std::move(nameLocation)}; } ASTPointer Parser::parseEventDefinition() @@ -956,7 +957,7 @@ ASTPointer Parser::parseErrorDefinition() ASTPointer parameters = parseParameterList({}); nodeFactory.markEndPosition(); expectToken(Token::Semicolon); - return nodeFactory.createNode(name, move(nameLocation), documentation, parameters); + return nodeFactory.createNode(name, std::move(nameLocation), documentation, parameters); } ASTPointer Parser::parseUsingDirective() @@ -995,7 +996,7 @@ ASTPointer Parser::parseUsingDirective() } nodeFactory.markEndPosition(); expectToken(Token::Semicolon); - return nodeFactory.createNode(move(functions), usesBraces, typeName, global); + return nodeFactory.createNode(std::move(functions), usesBraces, typeName, global); } ASTPointer Parser::parseModifierInvocation() @@ -1013,7 +1014,7 @@ ASTPointer Parser::parseModifierInvocation() } else nodeFactory.setEndPositionFromNode(name); - return nodeFactory.createNode(name, move(arguments)); + return nodeFactory.createNode(name, std::move(arguments)); } ASTPointer Parser::parseIdentifier() @@ -1051,7 +1052,7 @@ ASTPointer Parser::parseUserDefinedValueTypeDefi expectToken(Token::Semicolon); return nodeFactory.createNode( name, - move(nameLocation), + std::move(nameLocation), typeName ); } @@ -1061,14 +1062,24 @@ ASTPointer Parser::parseIdentifierPath() RecursionGuard recursionGuard(*this); ASTNodeFactory nodeFactory(*this); nodeFactory.markEndPosition(); - vector identifierPath{*expectIdentifierToken()}; + + auto [name, nameLocation] = expectIdentifierWithLocation(); + + vector identifierPath{*name}; + vector identifierPathLocations{nameLocation}; + while (m_scanner->currentToken() == Token::Period) { advance(); + nodeFactory.markEndPosition(); - identifierPath.push_back(*expectIdentifierTokenOrAddress()); + + tie(name, nameLocation) = expectIdentifierWithLocation(); + + identifierPath.push_back(*name); + identifierPathLocations.push_back(nameLocation); } - return nodeFactory.createNode(identifierPath); + return nodeFactory.createNode(identifierPath, identifierPathLocations); } ASTPointer Parser::parseTypeNameSuffix(ASTPointer type, ASTNodeFactory& nodeFactory) @@ -1366,7 +1377,7 @@ ASTPointer Parser::parseInlineAssembly(ASTPointer con BOOST_THROW_EXCEPTION(FatalError()); location.end = nativeLocationOf(*block).end; - return make_shared(nextID(), location, _docString, dialect, move(flags), block); + return make_shared(nextID(), location, _docString, dialect, std::move(flags), block); } ASTPointer Parser::parseIfStatement(ASTPointer const& _docString) @@ -1532,13 +1543,16 @@ ASTPointer Parser::parseEmitStatement(ASTPointer const auto eventName = expressionFromIndexAccessStructure(iap); expectToken(Token::LParen); - vector> arguments; - vector> names; - std::tie(arguments, names) = parseFunctionCallArguments(); + auto functionCallArguments = parseFunctionCallArguments(); eventCallNodeFactory.markEndPosition(); nodeFactory.markEndPosition(); expectToken(Token::RParen); - auto eventCall = eventCallNodeFactory.createNode(eventName, arguments, names); + auto eventCall = eventCallNodeFactory.createNode( + eventName, + functionCallArguments.arguments, + functionCallArguments.parameterNames, + functionCallArguments.parameterNameLocations + ); return nodeFactory.createNode(_docString, eventCall); } @@ -1563,13 +1577,16 @@ ASTPointer Parser::parseRevertStatement(ASTPointer c auto errorName = expressionFromIndexAccessStructure(iap); expectToken(Token::LParen); - vector> arguments; - vector> names; - std::tie(arguments, names) = parseFunctionCallArguments(); + auto functionCallArguments = parseFunctionCallArguments(); errorCallNodeFactory.markEndPosition(); nodeFactory.markEndPosition(); expectToken(Token::RParen); - auto errorCall = errorCallNodeFactory.createNode(errorName, arguments, names); + auto errorCall = errorCallNodeFactory.createNode( + errorName, + functionCallArguments.arguments, + functionCallArguments.parameterNames, + functionCallArguments.parameterNameLocations + ); return nodeFactory.createNode(_docString, errorCall); } @@ -1637,7 +1654,7 @@ ASTPointer Parser::parseSimpleStatement(ASTPointer const& return parseExpressionStatement(_docString, nodeFactory.createNode(components, false)); } default: - solAssert(false, ""); + solAssert(false); } } else @@ -1650,17 +1667,19 @@ ASTPointer Parser::parseSimpleStatement(ASTPointer const& case LookAheadInfo::Expression: return parseExpressionStatement(_docString, expressionFromIndexAccessStructure(iap)); default: - solAssert(false, ""); + solAssert(false); } } + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + util::unreachable(); } bool Parser::IndexAccessedPath::empty() const { if (!indices.empty()) - { - solAssert(!path.empty(), ""); - } + solAssert(!path.empty()); + return path.empty() && indices.empty(); } @@ -1691,9 +1710,9 @@ pair Parser::tryParseIndexAcce IndexAccessedPath iap = parseIndexAccessedPath(); if (m_scanner->currentToken() == Token::Identifier || TokenTraits::isLocationSpecifier(m_scanner->currentToken())) - return make_pair(LookAheadInfo::VariableDeclaration, move(iap)); + return make_pair(LookAheadInfo::VariableDeclaration, std::move(iap)); else - return make_pair(LookAheadInfo::Expression, move(iap)); + return make_pair(LookAheadInfo::Expression, std::move(iap)); } ASTPointer Parser::parseVariableDeclarationStatement( @@ -1885,18 +1904,22 @@ ASTPointer Parser::parseLeftHandSideExpression( { advance(); nodeFactory.markEndPosition(); - expression = nodeFactory.createNode(expression, expectIdentifierTokenOrAddress()); + SourceLocation memberLocation = currentLocation(); + ASTPointer memberName = expectIdentifierTokenOrAddress(); + expression = nodeFactory.createNode(expression, std::move(memberName), std::move(memberLocation)); break; } case Token::LParen: { advance(); - vector> arguments; - vector> names; - std::tie(arguments, names) = parseFunctionCallArguments(); + auto functionCallArguments = parseFunctionCallArguments(); nodeFactory.markEndPosition(); expectToken(Token::RParen); - expression = nodeFactory.createNode(expression, arguments, names); + expression = nodeFactory.createNode( + expression, + functionCallArguments.arguments, + functionCallArguments.parameterNames, + functionCallArguments.parameterNameLocations); break; } case Token::LBrace: @@ -1915,7 +1938,7 @@ ASTPointer Parser::parseLeftHandSideExpression( nodeFactory.markEndPosition(); expectToken(Token::RBrace); - expression = nodeFactory.createNode(expression, optionList.first, optionList.second); + expression = nodeFactory.createNode(expression, optionList.arguments, optionList.parameterNames); break; } default: @@ -2059,10 +2082,11 @@ vector> Parser::parseFunctionCallListArguments() return arguments; } -pair>, vector>> Parser::parseFunctionCallArguments() +Parser::FunctionCallArguments Parser::parseFunctionCallArguments() { RecursionGuard recursionGuard(*this); - pair>, vector>> ret; + FunctionCallArguments ret; + Token token = m_scanner->currentToken(); if (token == Token::LBrace) { @@ -2072,13 +2096,13 @@ pair>, vector>> Parser::pars expectToken(Token::RBrace); } else - ret.first = parseFunctionCallListArguments(); + ret.arguments = parseFunctionCallListArguments(); return ret; } -pair>, vector>> Parser::parseNamedArguments() +Parser::FunctionCallArguments Parser::parseNamedArguments() { - pair>, vector>> ret; + FunctionCallArguments ret; bool first = true; while (m_scanner->currentToken() != Token::RBrace) @@ -2086,9 +2110,15 @@ pair>, vector>> Parser::pars if (!first) expectToken(Token::Comma); - ret.second.push_back(expectIdentifierToken()); + auto identifierWithLocation = expectIdentifierWithLocation(); + + // Add name + ret.parameterNames.emplace_back(std::move(identifierWithLocation.first)); + // Add location + ret.parameterNameLocations.emplace_back(std::move(identifierWithLocation.second)); + expectToken(Token::Colon); - ret.first.push_back(parseExpression()); + ret.arguments.emplace_back(parseExpression()); if ( m_scanner->currentToken() == Token::Comma && @@ -2284,9 +2314,16 @@ ASTPointer Parser::typeNameFromIndexAccessStructure(Parser::IndexAcces else { vector path; + vector pathLocations; + for (auto const& el: _iap.path) - path.push_back(dynamic_cast(*el).name()); - type = nodeFactory.createNode(nodeFactory.createNode(path)); + { + auto& identifier = dynamic_cast(*el); + path.push_back(identifier.name()); + pathLocations.push_back(identifier.location()); + } + + type = nodeFactory.createNode(nodeFactory.createNode(path, pathLocations)); } for (auto const& lengthExpression: _iap.indices) { @@ -2316,7 +2353,8 @@ ASTPointer Parser::expressionFromIndexAccessStructure( Identifier const& identifier = dynamic_cast(*_iap.path[i]); expression = nodeFactory.createNode( expression, - make_shared(identifier.name()) + make_shared(identifier.name()), + identifier.location() ); } for (auto const& index: _iap.indices) diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h index e656c936d..7a9b41318 100644 --- a/libsolidity/parsing/Parser.h +++ b/libsolidity/parsing/Parser.h @@ -77,6 +77,14 @@ private: std::vector> modifiers; }; + /// Struct to share parsed function call arguments. + struct FunctionCallArguments + { + std::vector> arguments; + std::vector> parameterNames; + std::vector parameterNameLocations; + }; + ///@{ ///@name Parsing functions for the AST nodes void parsePragmaVersion(langutil::SourceLocation const& _location, std::vector const& _tokens, std::vector const& _literals); @@ -153,8 +161,9 @@ private: ); ASTPointer parsePrimaryExpression(); std::vector> parseFunctionCallListArguments(); - std::pair>, std::vector>> parseFunctionCallArguments(); - std::pair>, std::vector>> parseNamedArguments(); + + FunctionCallArguments parseFunctionCallArguments(); + FunctionCallArguments parseNamedArguments(); std::pair, langutil::SourceLocation> expectIdentifierWithLocation(); ///@} diff --git a/libsolutil/Assertions.h b/libsolutil/Assertions.h index 4924522d6..6735cda16 100644 --- a/libsolutil/Assertions.h +++ b/libsolutil/Assertions.h @@ -40,6 +40,28 @@ namespace solidity::util #define ETH_FUNC __func__ #endif +#if defined(__GNUC__) +// GCC 4.8+, Clang, Intel and other compilers compatible with GCC (-std=c++0x or above) +[[noreturn]] inline __attribute__((always_inline)) void unreachable() +{ + __builtin_unreachable(); +} + +#elif defined(_MSC_VER) // MSVC + +[[noreturn]] __forceinline void unreachable() +{ + __assume(false); +} + +#else + +[[noreturn]] inline void unreachable() +{ + solThrow(Exception, "Unreachable"); +} +#endif + namespace assertions { diff --git a/libsolutil/CMakeLists.txt b/libsolutil/CMakeLists.txt index e055317be..363baba19 100644 --- a/libsolutil/CMakeLists.txt +++ b/libsolutil/CMakeLists.txt @@ -28,6 +28,7 @@ set(sources picosha2.h Result.h SetOnce.h + StackTooDeepString.h StringUtils.cpp StringUtils.h SwarmHash.cpp diff --git a/libsolutil/Numeric.cpp b/libsolutil/Numeric.cpp index f1d4057e0..97a7b0420 100644 --- a/libsolutil/Numeric.cpp +++ b/libsolutil/Numeric.cpp @@ -31,7 +31,7 @@ bool solidity::fitsPrecisionBaseX(bigint const& _mantissa, double _log2OfBase, u size_t const bitsMax = 4096; - unsigned mostSignificantMantissaBit = boost::multiprecision::msb(_mantissa); + size_t mostSignificantMantissaBit = static_cast(boost::multiprecision::msb(_mantissa)); if (mostSignificantMantissaBit > bitsMax) // _mantissa >= 2 ^ 4096 return false; diff --git a/libsolutil/Numeric.h b/libsolutil/Numeric.h index 384589764..c0f33e490 100644 --- a/libsolutil/Numeric.h +++ b/libsolutil/Numeric.h @@ -33,6 +33,9 @@ #if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ >= 12) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wstringop-overread" +#pragma GCC diagnostic ignored "-Waggressive-loop-optimizations" #endif #include #if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ >= 12) diff --git a/libsolutil/StackTooDeepString.h b/libsolutil/StackTooDeepString.h new file mode 100644 index 000000000..75fe557e2 --- /dev/null +++ b/libsolutil/StackTooDeepString.h @@ -0,0 +1,28 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 +#pragma once + +#include + +namespace solidity::util +{ + static std::string stackTooDeepString = + "Stack too deep. " + "Try compiling with `--via-ir` (cli) or the equivalent `viaIR: true` (standard JSON) " + "while enabling the optimizer. Otherwise, try removing local variables."; +} diff --git a/libsolutil/StringUtils.h b/libsolutil/StringUtils.h index 7a48c296f..d7e123850 100644 --- a/libsolutil/StringUtils.h +++ b/libsolutil/StringUtils.h @@ -101,17 +101,9 @@ std::string joinHumanReadablePrefixed return _separator + joinHumanReadable(_list, _separator, _lastSeparator); } -/// Formats large numbers to be easily readable by humans. -/// Returns decimal representation for smaller numbers; hex for large numbers. -/// "Special" numbers, powers-of-two and powers-of-two minus 1, are returned in -/// formulaic form like 0x01 * 2**24 - 1. -/// @a T will typically by unsigned, u160, u256 or bigint. -/// @param _value to be formatted -/// @param _useTruncation if true, internal truncation is also applied, -/// like 0x5555...{+56 more}...5555 -/// @example formatNumber((u256)0x7ffffff) +/// Same as @ref formatNumberReadable but only for unsigned numbers template -inline std::string formatNumberReadable( +inline std::string formatUnsignedNumberReadable ( T const& _value, bool _useTruncation = false ) @@ -181,7 +173,40 @@ inline std::string formatNumberReadable( return str; } -/// Safely converts an usigned integer as string into an unsigned int type. +/// Formats large numbers to be easily readable by humans. +/// Returns decimal representation for smaller numbers; hex for large numbers. +/// "Special" numbers, powers-of-two and powers-of-two minus 1, are returned in +/// formulaic form like 0x01 * 2**24 - 1. +/// @a T can be any integer variable, will typically be u160, u256 or bigint. +/// @param _value to be formatted +/// @param _useTruncation if true, internal truncation is also applied, +/// like 0x5555...{+56 more}...5555 +/// @example formatNumberReadable((u256)0x7ffffff) = "0x08 * 2**24" +/// @example formatNumberReadable(-57896044618658097711785492504343953926634992332820282019728792003956564819968) = -0x80 * 2**248 +template +inline std::string formatNumberReadable( + T const& _value, + bool _useTruncation = false +) +{ + static_assert( + std::numeric_limits::is_integer, + "only integer numbers are supported" + ); + + if (_value >= 0) + { + bigint const _v = bigint(_value); + return formatUnsignedNumberReadable(_v, _useTruncation); + } + else + { + bigint const _abs_value = bigint(-1) * _value; + return "-" + formatUnsignedNumberReadable(_abs_value, _useTruncation); + } +} + +/// Safely converts an unsigned integer as string into an unsigned int type. /// /// @return the converted number or nullopt in case of an failure (including if it would not fit). inline std::optional toUnsignedInt(std::string const& _value) diff --git a/libsolutil/Whiskers.cpp b/libsolutil/Whiskers.cpp index 340527bdd..043f2dd76 100644 --- a/libsolutil/Whiskers.cpp +++ b/libsolutil/Whiskers.cpp @@ -32,7 +32,7 @@ using namespace std; using namespace solidity::util; Whiskers::Whiskers(string _template): - m_template(move(_template)) + m_template(std::move(_template)) { } @@ -41,7 +41,7 @@ Whiskers& Whiskers::operator()(string _parameter, string _value) checkParameterValid(_parameter); checkParameterUnknown(_parameter); checkTemplateContainsTags(_parameter, {""}); - m_parameters[move(_parameter)] = move(_value); + m_parameters[std::move(_parameter)] = std::move(_value); return *this; } @@ -50,7 +50,7 @@ Whiskers& Whiskers::operator()(string _parameter, bool _value) checkParameterValid(_parameter); checkParameterUnknown(_parameter); checkTemplateContainsTags(_parameter, {"?", "/"}); - m_conditions[move(_parameter)] = _value; + m_conditions[std::move(_parameter)] = _value; return *this; } @@ -65,7 +65,7 @@ Whiskers& Whiskers::operator()( for (auto const& element: _values) for (auto const& val: element) checkParameterValid(val.first); - m_listParameters[move(_listParameter)] = move(_values); + m_listParameters[std::move(_listParameter)] = std::move(_values); return *this; } diff --git a/libyul/AsmJsonImporter.cpp b/libyul/AsmJsonImporter.cpp index 8fb4eaeb3..0a88cacf8 100644 --- a/libyul/AsmJsonImporter.cpp +++ b/libyul/AsmJsonImporter.cpp @@ -110,6 +110,9 @@ Statement AsmJsonImporter::createStatement(Json::Value const& _node) return createBlock(_node); else yulAssert(false, "Invalid nodeType as statement"); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + util::unreachable(); } Expression AsmJsonImporter::createExpression(Json::Value const& _node) @@ -129,6 +132,9 @@ Expression AsmJsonImporter::createExpression(Json::Value const& _node) return createLiteral(_node); else yulAssert(false, "Invalid nodeType as expression"); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + util::unreachable(); } vector AsmJsonImporter::createExpressionVector(Json::Value const& _array) diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index ba4bf1115..8043c758a 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -88,7 +88,7 @@ void Parser::updateLocationEndFrom( DebugData updatedDebugData = *_debugData; updatedDebugData.nativeLocation.end = _location.end; updatedDebugData.originLocation.end = _location.end; - _debugData = make_shared(move(updatedDebugData)); + _debugData = make_shared(std::move(updatedDebugData)); break; } case UseSourceLocationFrom::LocationOverride: @@ -98,7 +98,7 @@ void Parser::updateLocationEndFrom( { DebugData updatedDebugData = *_debugData; updatedDebugData.nativeLocation.end = _location.end; - _debugData = make_shared(move(updatedDebugData)); + _debugData = make_shared(std::move(updatedDebugData)); break; } } @@ -246,7 +246,7 @@ optional> Parser::parseSrcComment( { shared_ptr sourceName = m_sourceNames->at(static_cast(sourceIndex.value())); solAssert(sourceName, ""); - return {{tail, SourceLocation{start.value(), end.value(), move(sourceName)}}}; + return {{tail, SourceLocation{start.value(), end.value(), std::move(sourceName)}}}; } return {{tail, SourceLocation{}}}; } @@ -313,7 +313,7 @@ Statement Parser::parseStatement() _if.condition = make_unique(parseExpression()); _if.body = parseBlock(); updateLocationEndFrom(_if.debugData, nativeLocationOf(_if.body)); - return Statement{move(_if)}; + return Statement{std::move(_if)}; } case Token::Switch: { @@ -331,7 +331,7 @@ Statement Parser::parseStatement() if (_switch.cases.empty()) fatalParserError(2418_error, "Switch statement without any cases."); updateLocationEndFrom(_switch.debugData, nativeLocationOf(_switch.cases.back().body)); - return Statement{move(_switch)}; + return Statement{std::move(_switch)}; } case Token::For: return parseForLoop(); @@ -371,7 +371,7 @@ Statement Parser::parseStatement() case Token::LParen: { Expression expr = parseCall(std::move(elementary)); - return ExpressionStatement{debugDataOf(expr), move(expr)}; + return ExpressionStatement{debugDataOf(expr), std::move(expr)}; } case Token::Comma: case Token::AssemblyAssign: @@ -414,7 +414,7 @@ Statement Parser::parseStatement() assignment.value = make_unique(parseExpression()); updateLocationEndFrom(assignment.debugData, nativeLocationOf(*assignment.value)); - return Statement{move(assignment)}; + return Statement{std::move(assignment)}; } default: fatalParserError(6913_error, "Call or assignment expected."); @@ -485,11 +485,11 @@ Expression Parser::parseExpression() nativeLocationOf(_identifier), "Builtin function \"" + _identifier.name.str() + "\" must be called." ); - return move(_identifier); + return std::move(_identifier); }, [&](Literal& _literal) -> Expression { - return move(_literal); + return std::move(_literal); } }, operation); } diff --git a/libyul/AsmPrinter.cpp b/libyul/AsmPrinter.cpp index 46000bc10..54733cc43 100644 --- a/libyul/AsmPrinter.cpp +++ b/libyul/AsmPrinter.cpp @@ -197,7 +197,7 @@ string AsmPrinter::operator()(ForLoop const& _forLoop) delim = ' '; return locationComment + - ("for " + move(pre) + delim + move(condition) + delim + move(post) + "\n") + + ("for " + std::move(pre) + delim + std::move(condition) + delim + std::move(post) + "\n") + (*this)(_forLoop.body); } @@ -278,7 +278,11 @@ string AsmPrinter::formatSourceLocation( { sourceIndex = to_string(_nameToSourceIndex.at(*_location.sourceName)); - if (_debugInfoSelection.snippet && _soliditySourceProvider) + if ( + _debugInfoSelection.snippet && + _soliditySourceProvider && + !_soliditySourceProvider->charStream(*_location.sourceName).isImportedFromAST() + ) { solidityCodeSnippet = escapeAndQuoteString( _soliditySourceProvider->charStream(*_location.sourceName).singleLineSnippet(_location) diff --git a/libyul/ControlFlowSideEffectsCollector.cpp b/libyul/ControlFlowSideEffectsCollector.cpp index 6e96712a0..19eb8275d 100644 --- a/libyul/ControlFlowSideEffectsCollector.cpp +++ b/libyul/ControlFlowSideEffectsCollector.cpp @@ -92,7 +92,7 @@ void ControlFlowBuilder::operator()(FunctionDefinition const& _function) m_currentNode->successors.emplace_back(flow.exit); - m_functionFlows[&_function] = move(flow); + m_functionFlows[&_function] = std::move(flow); m_leave = nullptr; } diff --git a/libyul/ObjectParser.cpp b/libyul/ObjectParser.cpp index afd4b7d94..1a2d8b33a 100644 --- a/libyul/ObjectParser.cpp +++ b/libyul/ObjectParser.cpp @@ -88,7 +88,7 @@ shared_ptr ObjectParser::parseObject(Object* _containingObject) expectToken(Token::LBrace); - ret->code = parseCode(move(sourceNameMapping)); + ret->code = parseCode(std::move(sourceNameMapping)); while (currentToken() != Token::RBrace) { @@ -113,7 +113,7 @@ shared_ptr ObjectParser::parseCode(optional _sourceNames) fatalParserError(4846_error, "Expected keyword \"code\"."); advance(); - return parseBlock(move(_sourceNames)); + return parseBlock(std::move(_sourceNames)); } optional ObjectParser::tryParseSourceNameMapping() const @@ -156,7 +156,7 @@ optional ObjectParser::tryParseSourceNameMapping() const Token const next = scanner.next(); if (next == Token::EOS) - return {move(sourceNames)}; + return {std::move(sourceNames)}; if (next != Token::Comma) break; scanner.next(); @@ -172,7 +172,7 @@ optional ObjectParser::tryParseSourceNameMapping() const shared_ptr ObjectParser::parseBlock(optional _sourceNames) { - Parser parser(m_errorReporter, m_dialect, move(_sourceNames)); + Parser parser(m_errorReporter, m_dialect, std::move(_sourceNames)); shared_ptr block = parser.parseInline(m_scanner); yulAssert(block || m_errorReporter.hasErrors(), "Invalid block but no error!"); return block; diff --git a/libyul/backends/evm/AsmCodeGen.cpp b/libyul/backends/evm/AsmCodeGen.cpp index 6ef142906..c4d276fa1 100644 --- a/libyul/backends/evm/AsmCodeGen.cpp +++ b/libyul/backends/evm/AsmCodeGen.cpp @@ -26,6 +26,8 @@ #include #include +#include + using namespace std; using namespace solidity; using namespace solidity::yul; @@ -61,7 +63,7 @@ void CodeGenerator::assemble( assertThrow( false, langutil::StackTooDeepError, - "Stack too deep when compiling inline assembly" + + util::stackTooDeepString + " When compiling inline assembly" + (transform.stackErrors().front().comment() ? ": " + *transform.stackErrors().front().comment() : ".") ); } diff --git a/libyul/backends/evm/ConstantOptimiser.cpp b/libyul/backends/evm/ConstantOptimiser.cpp index aecd00bf4..59e987b69 100644 --- a/libyul/backends/evm/ConstantOptimiser.cpp +++ b/libyul/backends/evm/ConstantOptimiser.cpp @@ -130,7 +130,7 @@ Representation const& RepresentationFinder::findRepresentation(u256 const& _valu if (numberEncodingSize(~_value) < numberEncodingSize(_value)) // Negated is shorter to represent - routine = min(move(routine), represent("not"_yulstring, findRepresentation(~_value))); + routine = min(std::move(routine), represent("not"_yulstring, findRepresentation(~_value))); // Decompose value into a * 2**k + b where abs(b) << 2**k for (unsigned bits = 255; bits > 8 && m_maxSteps > 0; --bits) @@ -171,10 +171,10 @@ Representation const& RepresentationFinder::findRepresentation(u256 const& _valu if (m_maxSteps > 0) m_maxSteps--; - routine = min(move(routine), move(newRoutine)); + routine = min(std::move(routine), std::move(newRoutine)); } yulAssert(MiniEVMInterpreter{m_dialect}.eval(*routine.expression) == _value, "Invalid expression generated."); - return m_cache[_value] = move(routine); + return m_cache[_value] = std::move(routine); } Representation RepresentationFinder::represent(u256 const& _value) const diff --git a/libyul/backends/evm/ControlFlowGraph.h b/libyul/backends/evm/ControlFlowGraph.h index 8ca2076a0..b267b8461 100644 --- a/libyul/backends/evm/ControlFlowGraph.h +++ b/libyul/backends/evm/ControlFlowGraph.h @@ -236,7 +236,7 @@ struct CFG BasicBlock& makeBlock(std::shared_ptr _debugData) { - return blocks.emplace_back(BasicBlock{move(_debugData), {}, {}}); + return blocks.emplace_back(BasicBlock{std::move(_debugData), {}, {}}); } }; diff --git a/libyul/backends/evm/ControlFlowGraphBuilder.cpp b/libyul/backends/evm/ControlFlowGraphBuilder.cpp index 855d96fbd..1980fb442 100644 --- a/libyul/backends/evm/ControlFlowGraphBuilder.cpp +++ b/libyul/backends/evm/ControlFlowGraphBuilder.cpp @@ -532,7 +532,7 @@ Stack const& ControlFlowGraphBuilder::visitFunctionCall(FunctionCall const& _cal return TemporarySlot{_call, _i}; }) | ranges::to, // operation - move(builtinCall) + std::move(builtinCall) }).output; } else @@ -607,8 +607,8 @@ void ControlFlowGraphBuilder::makeConditionalJump( { yulAssert(m_currentBlock, ""); m_currentBlock->exit = CFG::BasicBlock::ConditionalJump{ - move(_debugData), - move(_condition), + std::move(_debugData), + std::move(_condition), &_nonZero, &_zero }; @@ -624,7 +624,7 @@ void ControlFlowGraphBuilder::jump( ) { yulAssert(m_currentBlock, ""); - m_currentBlock->exit = CFG::BasicBlock::Jump{move(_debugData), &_target, backwards}; + m_currentBlock->exit = CFG::BasicBlock::Jump{std::move(_debugData), &_target, backwards}; _target.entries.emplace_back(m_currentBlock); m_currentBlock = &_target; } diff --git a/libyul/backends/evm/EVMCodeTransform.cpp b/libyul/backends/evm/EVMCodeTransform.cpp index 531fd1b92..7c9bf05cf 100644 --- a/libyul/backends/evm/EVMCodeTransform.cpp +++ b/libyul/backends/evm/EVMCodeTransform.cpp @@ -26,6 +26,7 @@ #include #include +#include #include @@ -63,9 +64,9 @@ CodeTransform::CodeTransform( m_builtinContext(_builtinContext), m_allowStackOpt(_allowStackOpt), m_useNamedLabelsForFunctions(_useNamedLabelsForFunctions), - m_identifierAccessCodeGen(move(_identifierAccessCodeGen)), - m_context(move(_context)), - m_delayedReturnVariables(move(_delayedReturnVariables)), + m_identifierAccessCodeGen(std::move(_identifierAccessCodeGen)), + m_context(std::move(_context)), + m_delayedReturnVariables(std::move(_delayedReturnVariables)), m_functionExitLabel(_functionExitLabel) { if (!m_context) @@ -405,11 +406,11 @@ void CodeTransform::operator()(FunctionDefinition const& _function) if (!m_allowStackOpt) subTransform.setupReturnVariablesAndFunctionExit(); - subTransform.m_assignedNamedLabels = move(m_assignedNamedLabels); + subTransform.m_assignedNamedLabels = std::move(m_assignedNamedLabels); subTransform(_function.body); - m_assignedNamedLabels = move(subTransform.m_assignedNamedLabels); + m_assignedNamedLabels = std::move(subTransform.m_assignedNamedLabels); m_assembly.setSourceLocation(originLocationOf(_function)); if (!subTransform.m_stackErrors.empty()) @@ -785,7 +786,8 @@ size_t CodeTransform::variableHeightDiff(Scope::Variable const& _var, YulString _varName.str() + " is " + to_string(heightDiff - limit) + - " slot(s) too deep inside the stack." + " slot(s) too deep inside the stack. " + + stackTooDeepString ); m_assembly.markAsInvalid(); return _forSwap ? 2 : 1; diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp index 0b6855e3a..350f260c5 100644 --- a/libyul/backends/evm/EVMDialect.cpp +++ b/libyul/backends/evm/EVMDialect.cpp @@ -82,7 +82,8 @@ pair createEVMFunction( _assembly.appendInstruction(_instruction); }; - return {f.name, move(f)}; + YulString name = f.name; + return {name, move(f)}; } pair createFunction( @@ -374,7 +375,7 @@ BuiltinFunctionForEVM const* EVMDialect::verbatimFunction(size_t _arguments, siz } ).second; builtinFunction.isMSize = true; - function = make_shared(move(builtinFunction)); + function = make_shared(std::move(builtinFunction)); } return function.get(); } diff --git a/libyul/backends/evm/EthAssemblyAdapter.cpp b/libyul/backends/evm/EthAssemblyAdapter.cpp index 5d7b4cbf4..685f56cbc 100644 --- a/libyul/backends/evm/EthAssemblyAdapter.cpp +++ b/libyul/backends/evm/EthAssemblyAdapter.cpp @@ -96,7 +96,7 @@ void EthAssemblyAdapter::appendLinkerSymbol(std::string const& _linkerSymbol) void EthAssemblyAdapter::appendVerbatim(bytes _data, size_t _arguments, size_t _returnVariables) { - m_assembly.appendVerbatim(move(_data), _arguments, _returnVariables); + m_assembly.appendVerbatim(std::move(_data), _arguments, _returnVariables); } void EthAssemblyAdapter::appendJump(int _stackDiffAfter, JumpType _jumpType) diff --git a/libyul/backends/evm/OptimizedEVMCodeTransform.cpp b/libyul/backends/evm/OptimizedEVMCodeTransform.cpp index 08987b565..db73ba2a7 100644 --- a/libyul/backends/evm/OptimizedEVMCodeTransform.cpp +++ b/libyul/backends/evm/OptimizedEVMCodeTransform.cpp @@ -61,7 +61,7 @@ vector OptimizedEVMCodeTransform::run( optimizedCodeTransform(*dfg->entry); for (Scope::Function const* function: dfg->functions) optimizedCodeTransform(dfg->functionInfo.at(function)); - return move(optimizedCodeTransform.m_stackErrors); + return std::move(optimizedCodeTransform.m_stackErrors); } void OptimizedEVMCodeTransform::operator()(CFG::FunctionCall const& _call) @@ -459,7 +459,7 @@ void OptimizedEVMCodeTransform::operator()(CFG::BasicBlock const& _block) { // Restore the stack afterwards for the non-zero case below. ScopeGuard stackRestore([storedStack = m_stack, this]() { - m_stack = move(storedStack); + m_stack = std::move(storedStack); m_assembly.setStackHeight(static_cast(m_stack.size())); }); diff --git a/libyul/backends/evm/StackHelpers.h b/libyul/backends/evm/StackHelpers.h index a0a942860..ff8887b24 100644 --- a/libyul/backends/evm/StackHelpers.h +++ b/libyul/backends/evm/StackHelpers.h @@ -371,6 +371,9 @@ private: return true; } yulAssert(false, ""); + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + throw std::exception(); } }; diff --git a/libyul/backends/evm/StackLayoutGenerator.cpp b/libyul/backends/evm/StackLayoutGenerator.cpp index 4f9a1e2a1..8b39b364f 100644 --- a/libyul/backends/evm/StackLayoutGenerator.cpp +++ b/libyul/backends/evm/StackLayoutGenerator.cpp @@ -65,7 +65,7 @@ map> StackLayoutGenerator: stackTooDeepErrors[YulString{}] = reportStackTooDeep(_cfg, YulString{}); for (auto const& function: _cfg.functions) if (auto errors = reportStackTooDeep(_cfg, function->name); !errors.empty()) - stackTooDeepErrors[function->name] = move(errors); + stackTooDeepErrors[function->name] = std::move(errors); return stackTooDeepErrors; } @@ -324,8 +324,8 @@ Stack StackLayoutGenerator::propagateStackThroughBlock(Stack _exitStack, CFG::Ba Stack newStack = propagateStackThroughOperation(stack, operation, _aggressiveStackCompression); if (!_aggressiveStackCompression && !findStackTooDeep(newStack, stack).empty()) // If we had stack errors, run again with aggressive stack compression. - return propagateStackThroughBlock(move(_exitStack), _block, true); - stack = move(newStack); + return propagateStackThroughBlock(std::move(_exitStack), _block, true); + stack = std::move(newStack); } return stack; @@ -715,13 +715,13 @@ void StackLayoutGenerator::fillInJunk(CFG::BasicBlock const& _block) util::BreadthFirstSearch breadthFirstSearch{{_entry}}; breadthFirstSearch.run([&](CFG::BasicBlock const* _block, auto _addChild) { auto& blockInfo = m_layout.blockInfos.at(_block); - blockInfo.entryLayout = Stack{_numJunk, JunkSlot{}} + move(blockInfo.entryLayout); + blockInfo.entryLayout = Stack{_numJunk, JunkSlot{}} + std::move(blockInfo.entryLayout); for (auto const& operation: _block->operations) { auto& operationEntryLayout = m_layout.operationEntryLayout.at(&operation); - operationEntryLayout = Stack{_numJunk, JunkSlot{}} + move(operationEntryLayout); + operationEntryLayout = Stack{_numJunk, JunkSlot{}} + std::move(operationEntryLayout); } - blockInfo.exitLayout = Stack{_numJunk, JunkSlot{}} + move(blockInfo.exitLayout); + blockInfo.exitLayout = Stack{_numJunk, JunkSlot{}} + std::move(blockInfo.exitLayout); std::visit(util::GenericVisitor{ [&](CFG::BasicBlock::MainExit const&) {}, diff --git a/libyul/backends/wasm/BinaryTransform.cpp b/libyul/backends/wasm/BinaryTransform.cpp index 321792b08..03f385d80 100644 --- a/libyul/backends/wasm/BinaryTransform.cpp +++ b/libyul/backends/wasm/BinaryTransform.cpp @@ -239,12 +239,12 @@ static map const builtins = { bytes prefixSize(bytes _data) { size_t size = _data.size(); - return lebEncode(size) + move(_data); + return lebEncode(size) + std::move(_data); } bytes makeSection(Section _section, bytes _data) { - return toBytes(_section) + prefixSize(move(_data)); + return toBytes(_section) + prefixSize(std::move(_data)); } /// This is a kind of run-length-encoding of local types. @@ -306,7 +306,7 @@ bytes BinaryTransform::run(Module const& _module) // TODO should we prefix and / or shorten the name? bytes data = BinaryTransform::run(module); size_t const length = data.size(); - ret += customSection(name, move(data)); + ret += customSection(name, std::move(data)); // Skip all the previous sections and the size field of this current custom section. size_t const offset = ret.size() - length; subModulePosAndSize[name] = {offset, length}; @@ -321,10 +321,10 @@ bytes BinaryTransform::run(Module const& _module) } BinaryTransform bt( - move(globalIDs), - move(functionIDs), - move(functionTypes), - move(subModulePosAndSize) + std::move(globalIDs), + std::move(functionIDs), + std::move(functionTypes), + std::move(subModulePosAndSize) ); ret += bt.codeSection(_module.functions); @@ -378,7 +378,7 @@ bytes BinaryTransform::operator()(BuiltinCall const& _call) yulAssert(builtins.count(_call.functionName), "Builtin " + _call.functionName + " not found"); // NOTE: the dialect ensures we have the right amount of arguments bytes args = visit(_call.arguments); - bytes ret = move(args) + toBytes(builtins.at(_call.functionName)); + bytes ret = std::move(args) + toBytes(builtins.at(_call.functionName)); if ( _call.functionName.find(".load") != string::npos || _call.functionName.find(".store") != string::npos @@ -500,7 +500,7 @@ bytes BinaryTransform::operator()(FunctionDefinition const& _function) yulAssert(m_labels.empty(), "Stray labels."); - return prefixSize(move(ret)); + return prefixSize(std::move(ret)); } BinaryTransform::Type BinaryTransform::typeOf(FunctionImport const& _import) @@ -602,7 +602,7 @@ bytes BinaryTransform::typeSection(map> co index++; } - return makeSection(Section::TYPE, lebEncode(index) + move(result)); + return makeSection(Section::TYPE, lebEncode(index) + std::move(result)); } bytes BinaryTransform::importSection( @@ -620,7 +620,7 @@ bytes BinaryTransform::importSection( toBytes(importKind) + lebEncode(_functionTypes.at(import.internalName)); } - return makeSection(Section::IMPORT, move(result)); + return makeSection(Section::IMPORT, std::move(result)); } bytes BinaryTransform::functionSection( @@ -631,7 +631,7 @@ bytes BinaryTransform::functionSection( bytes result = lebEncode(_functions.size()); for (auto const& fun: _functions) result += lebEncode(_functionTypes.at(fun.name)); - return makeSection(Section::FUNCTION, move(result)); + return makeSection(Section::FUNCTION, std::move(result)); } bytes BinaryTransform::memorySection() @@ -639,7 +639,7 @@ bytes BinaryTransform::memorySection() bytes result = lebEncode(1); result.push_back(static_cast(LimitsKind::Min)); result.push_back(1); // initial length - return makeSection(Section::MEMORY, move(result)); + return makeSection(Section::MEMORY, std::move(result)); } bytes BinaryTransform::globalSection(vector const& _globals) @@ -656,7 +656,7 @@ bytes BinaryTransform::globalSection(vector con toBytes(Opcode::End); } - return makeSection(Section::GLOBAL, move(result)); + return makeSection(Section::GLOBAL, std::move(result)); } bytes BinaryTransform::exportSection(map const& _functionIDs) @@ -666,13 +666,13 @@ bytes BinaryTransform::exportSection(map const& _functionIDs) result += encodeName("memory") + toBytes(Export::Memory) + lebEncode(0); if (hasMain) result += encodeName("main") + toBytes(Export::Function) + lebEncode(_functionIDs.at("main")); - return makeSection(Section::EXPORT, move(result)); + return makeSection(Section::EXPORT, std::move(result)); } bytes BinaryTransform::customSection(string const& _name, bytes _data) { - bytes result = encodeName(_name) + move(_data); - return makeSection(Section::CUSTOM, move(result)); + bytes result = encodeName(_name) + std::move(_data); + return makeSection(Section::CUSTOM, std::move(result)); } bytes BinaryTransform::codeSection(vector const& _functions) @@ -680,7 +680,7 @@ bytes BinaryTransform::codeSection(vector const& _func bytes result = lebEncode(_functions.size()); for (FunctionDefinition const& fun: _functions) result += (*this)(fun); - return makeSection(Section::CODE, move(result)); + return makeSection(Section::CODE, std::move(result)); } bytes BinaryTransform::visit(vector const& _expressions) diff --git a/libyul/backends/wasm/EVMToEwasmTranslator.cpp b/libyul/backends/wasm/EVMToEwasmTranslator.cpp index 359cc023b..d36b1cda3 100644 --- a/libyul/backends/wasm/EVMToEwasmTranslator.cpp +++ b/libyul/backends/wasm/EVMToEwasmTranslator.cpp @@ -92,7 +92,7 @@ Object EVMToEwasmTranslator::run(Object const& _object) Object ret; ret.name = _object.name; - ret.code = make_shared(move(ast)); + ret.code = make_shared(std::move(ast)); ret.debugData = _object.debugData; ret.analysisInfo = make_shared(); diff --git a/libyul/backends/wasm/TextTransform.cpp b/libyul/backends/wasm/TextTransform.cpp index 9880f5ee5..62596ba6e 100644 --- a/libyul/backends/wasm/TextTransform.cpp +++ b/libyul/backends/wasm/TextTransform.cpp @@ -90,7 +90,7 @@ string TextTransform::run(wasm::Module const& _module) ret += "\n"; for (auto const& f: _module.functions) ret += transform(f) + "\n"; - return move(ret) + ")\n"; + return std::move(ret) + ")\n"; } string TextTransform::operator()(wasm::Literal const& _literal) @@ -159,7 +159,7 @@ string TextTransform::operator()(wasm::If const& _if) string TextTransform::operator()(wasm::Loop const& _loop) { string label = _loop.labelName.empty() ? "" : " $" + _loop.labelName; - return "(loop" + move(label) + "\n" + indented(joinTransformed(_loop.statements, '\n')) + ")\n"; + return "(loop" + std::move(label) + "\n" + indented(joinTransformed(_loop.statements, '\n')) + ")\n"; } string TextTransform::operator()(wasm::Branch const& _branch) @@ -180,7 +180,7 @@ string TextTransform::operator()(wasm::Return const&) string TextTransform::operator()(wasm::Block const& _block) { string label = _block.labelName.empty() ? "" : " $" + _block.labelName; - return "(block" + move(label) + "\n" + indented(joinTransformed(_block.statements, '\n')) + "\n)\n"; + return "(block" + std::move(label) + "\n" + indented(joinTransformed(_block.statements, '\n')) + "\n)\n"; } string TextTransform::indented(string const& _in) @@ -230,7 +230,7 @@ string TextTransform::joinTransformed(vector const& _expressio string t = visit(e); if (!t.empty() && !ret.empty() && ret.back() != '\n') ret += _separator; - ret += move(t); + ret += std::move(t); } return ret; } diff --git a/libyul/backends/wasm/WasmCodeTransform.cpp b/libyul/backends/wasm/WasmCodeTransform.cpp index 32c774533..2d895d3fe 100644 --- a/libyul/backends/wasm/WasmCodeTransform.cpp +++ b/libyul/backends/wasm/WasmCodeTransform.cpp @@ -68,7 +68,7 @@ wasm::Expression WasmCodeTransform::generateMultiAssignment( ) { yulAssert(!_variableNames.empty(), ""); - wasm::LocalAssignment assignment{move(_variableNames.front()), std::move(_firstValue)}; + wasm::LocalAssignment assignment{std::move(_variableNames.front()), std::move(_firstValue)}; if (_variableNames.size() == 1) return { std::move(assignment) }; @@ -80,10 +80,10 @@ wasm::Expression WasmCodeTransform::generateMultiAssignment( yulAssert(allocatedIndices.size() == _variableNames.size() - 1, ""); wasm::Block block; - block.statements.emplace_back(move(assignment)); + block.statements.emplace_back(std::move(assignment)); for (size_t i = 1; i < _variableNames.size(); ++i) block.statements.emplace_back(wasm::LocalAssignment{ - move(_variableNames.at(i)), + std::move(_variableNames.at(i)), make_unique(wasm::GlobalVariable{m_globalVariables.at(allocatedIndices[i - 1]).variableName}) }); return { std::move(block) }; @@ -99,7 +99,7 @@ wasm::Expression WasmCodeTransform::operator()(yul::VariableDeclaration const& _ } if (_varDecl.value) - return generateMultiAssignment(move(variableNames), visit(*_varDecl.value)); + return generateMultiAssignment(std::move(variableNames), visit(*_varDecl.value)); else return wasm::BuiltinCall{"nop", {}}; } @@ -109,7 +109,7 @@ wasm::Expression WasmCodeTransform::operator()(yul::Assignment const& _assignmen vector variableNames; for (auto const& var: _assignment.variableNames) variableNames.emplace_back(var.name.str()); - return generateMultiAssignment(move(variableNames), visit(*_assignment.value)); + return generateMultiAssignment(std::move(variableNames), visit(*_assignment.value)); } wasm::Expression WasmCodeTransform::operator()(yul::ExpressionStatement const& _statement) @@ -134,7 +134,7 @@ void WasmCodeTransform::importBuiltinFunction(BuiltinFunction const* _builtin, s }; for (auto const& param: _builtin->parameters) imp.paramTypes.emplace_back(translatedType(param)); - m_functionsToImport[internalName] = move(imp); + m_functionsToImport[internalName] = std::move(imp); } } @@ -199,7 +199,7 @@ wasm::Expression WasmCodeTransform::operator()(yul::If const& _if) else yulAssert(false, "Invalid condition type"); - return wasm::If{make_unique(move(condition)), visit(_if.body.statements), {}}; + return wasm::If{make_unique(std::move(condition)), visit(_if.body.statements), {}}; } wasm::Expression WasmCodeTransform::operator()(yul::Switch const& _switch) @@ -224,7 +224,7 @@ wasm::Expression WasmCodeTransform::operator()(yul::Switch const& _switch) visitReturnByValue(*c.value) )}; wasm::If ifStmnt{ - make_unique(move(comparison)), + make_unique(std::move(comparison)), visit(c.body.statements), {} }; @@ -234,7 +234,7 @@ wasm::Expression WasmCodeTransform::operator()(yul::Switch const& _switch) ifStmnt.elseStatements = make_unique>(); nextBlock = ifStmnt.elseStatements.get(); } - currentBlock->emplace_back(move(ifStmnt)); + currentBlock->emplace_back(std::move(ifStmnt)); currentBlock = nextBlock; } else @@ -275,8 +275,8 @@ wasm::Expression WasmCodeTransform::operator()(yul::ForLoop const& _for) loop.statements += visit(_for.post.statements); loop.statements.emplace_back(wasm::Branch{wasm::Label{loop.labelName}}); - statements += make_vector(move(loop)); - return wasm::Block{breakLabel, move(statements)}; + statements += make_vector(std::move(loop)); + return wasm::Block{breakLabel, std::move(statements)}; } wasm::Expression WasmCodeTransform::operator()(yul::Break const&) diff --git a/libyul/backends/wasm/WasmDialect.cpp b/libyul/backends/wasm/WasmDialect.cpp index 817d53467..b724ba69e 100644 --- a/libyul/backends/wasm/WasmDialect.cpp +++ b/libyul/backends/wasm/WasmDialect.cpp @@ -269,7 +269,7 @@ void WasmDialect::addFunction( vector> _literalArguments ) { - YulString name{move(_name)}; + YulString name{std::move(_name)}; BuiltinFunction& f = m_functions[name]; f.name = name; f.parameters = std::move(_params); diff --git a/libyul/optimiser/CommonSubexpressionEliminator.cpp b/libyul/optimiser/CommonSubexpressionEliminator.cpp index d25beb6bd..d1d482877 100644 --- a/libyul/optimiser/CommonSubexpressionEliminator.cpp +++ b/libyul/optimiser/CommonSubexpressionEliminator.cpp @@ -48,7 +48,7 @@ CommonSubexpressionEliminator::CommonSubexpressionEliminator( Dialect const& _dialect, map _functionSideEffects ): - DataFlowAnalyzer(_dialect, std::move(_functionSideEffects)) + DataFlowAnalyzer(_dialect, MemoryAndStorage::Ignore, std::move(_functionSideEffects)) { } diff --git a/libyul/optimiser/ConditionalSimplifier.h b/libyul/optimiser/ConditionalSimplifier.h index 5df56476a..e558a1c6c 100644 --- a/libyul/optimiser/ConditionalSimplifier.h +++ b/libyul/optimiser/ConditionalSimplifier.h @@ -64,7 +64,7 @@ private: Dialect const& _dialect, std::map _sideEffects ): - m_dialect(_dialect), m_functionSideEffects(move(_sideEffects)) + m_dialect(_dialect), m_functionSideEffects(std::move(_sideEffects)) {} Dialect const& m_dialect; std::map m_functionSideEffects; diff --git a/libyul/optimiser/DataFlowAnalyzer.cpp b/libyul/optimiser/DataFlowAnalyzer.cpp index 65cdf31c3..ba8e6fb88 100644 --- a/libyul/optimiser/DataFlowAnalyzer.cpp +++ b/libyul/optimiser/DataFlowAnalyzer.cpp @@ -44,47 +44,54 @@ using namespace solidity::yul; DataFlowAnalyzer::DataFlowAnalyzer( Dialect const& _dialect, + MemoryAndStorage _analyzeStores, map _functionSideEffects ): m_dialect(_dialect), m_functionSideEffects(std::move(_functionSideEffects)), - m_knowledgeBase(_dialect, [this](YulString _var) { return variableValue(_var); }) + m_knowledgeBase(_dialect, [this](YulString _var) { return variableValue(_var); }), + m_analyzeStores(_analyzeStores == MemoryAndStorage::Analyze) { - if (auto const* builtin = _dialect.memoryStoreFunction(YulString{})) - m_storeFunctionName[static_cast(StoreLoadLocation::Memory)] = builtin->name; - if (auto const* builtin = _dialect.memoryLoadFunction(YulString{})) - m_loadFunctionName[static_cast(StoreLoadLocation::Memory)] = builtin->name; - if (auto const* builtin = _dialect.storageStoreFunction(YulString{})) - m_storeFunctionName[static_cast(StoreLoadLocation::Storage)] = builtin->name; - if (auto const* builtin = _dialect.storageLoadFunction(YulString{})) - m_loadFunctionName[static_cast(StoreLoadLocation::Storage)] = builtin->name; + if (m_analyzeStores) + { + if (auto const* builtin = _dialect.memoryStoreFunction(YulString{})) + m_storeFunctionName[static_cast(StoreLoadLocation::Memory)] = builtin->name; + if (auto const* builtin = _dialect.memoryLoadFunction(YulString{})) + m_loadFunctionName[static_cast(StoreLoadLocation::Memory)] = builtin->name; + if (auto const* builtin = _dialect.storageStoreFunction(YulString{})) + m_storeFunctionName[static_cast(StoreLoadLocation::Storage)] = builtin->name; + if (auto const* builtin = _dialect.storageLoadFunction(YulString{})) + m_loadFunctionName[static_cast(StoreLoadLocation::Storage)] = builtin->name; + } } void DataFlowAnalyzer::operator()(ExpressionStatement& _statement) { - if (auto vars = isSimpleStore(StoreLoadLocation::Storage, _statement)) + if (m_analyzeStores) { - ASTModifier::operator()(_statement); - cxx20::erase_if(m_state.storage, mapTuple([&](auto&& key, auto&& value) { - return - !m_knowledgeBase.knownToBeDifferent(vars->first, key) && - !m_knowledgeBase.knownToBeEqual(vars->second, value); - })); - m_state.storage[vars->first] = vars->second; - } - else if (auto vars = isSimpleStore(StoreLoadLocation::Memory, _statement)) - { - ASTModifier::operator()(_statement); - cxx20::erase_if(m_state.memory, mapTuple([&](auto&& key, auto&& /* value */) { - return !m_knowledgeBase.knownToBeDifferentByAtLeast32(vars->first, key); - })); - m_state.memory[vars->first] = vars->second; - } - else - { - clearKnowledgeIfInvalidated(_statement.expression); - ASTModifier::operator()(_statement); + if (auto vars = isSimpleStore(StoreLoadLocation::Storage, _statement)) + { + ASTModifier::operator()(_statement); + cxx20::erase_if(m_state.storage, mapTuple([&](auto&& key, auto&& value) { + return + !m_knowledgeBase.knownToBeDifferent(vars->first, key) && + !m_knowledgeBase.knownToBeEqual(vars->second, value); + })); + m_state.storage[vars->first] = vars->second; + return; + } + else if (auto vars = isSimpleStore(StoreLoadLocation::Memory, _statement)) + { + ASTModifier::operator()(_statement); + cxx20::erase_if(m_state.memory, mapTuple([&](auto&& key, auto&& /* value */) { + return !m_knowledgeBase.knownToBeDifferentByAtLeast32(vars->first, key); + })); + m_state.memory[vars->first] = vars->second; + return; + } } + clearKnowledgeIfInvalidated(_statement.expression); + ASTModifier::operator()(_statement); } void DataFlowAnalyzer::operator()(Assignment& _assignment) @@ -346,6 +353,8 @@ void DataFlowAnalyzer::assignValue(YulString _variable, Expression const* _value void DataFlowAnalyzer::clearKnowledgeIfInvalidated(Block const& _block) { + if (!m_analyzeStores) + return; SideEffectsCollector sideEffects(m_dialect, _block, &m_functionSideEffects); if (sideEffects.invalidatesStorage()) m_state.storage.clear(); @@ -355,6 +364,8 @@ void DataFlowAnalyzer::clearKnowledgeIfInvalidated(Block const& _block) void DataFlowAnalyzer::clearKnowledgeIfInvalidated(Expression const& _expr) { + if (!m_analyzeStores) + return; SideEffectsCollector sideEffects(m_dialect, _expr, &m_functionSideEffects); if (sideEffects.invalidatesStorage()) m_state.storage.clear(); @@ -367,6 +378,8 @@ void DataFlowAnalyzer::joinKnowledge( unordered_map const& _olderMemory ) { + if (!m_analyzeStores) + return; joinKnowledgeHelper(m_state.storage, _olderStorage); joinKnowledgeHelper(m_state.memory, _olderMemory); } @@ -398,7 +411,7 @@ bool DataFlowAnalyzer::inScope(YulString _variableName) const return false; } -optional DataFlowAnalyzer::valueOfIdentifier(YulString const& _name) +optional DataFlowAnalyzer::valueOfIdentifier(YulString const& _name) const { if (AssignedValue const* value = variableValue(_name)) if (Literal const* literal = get_if(value->value)) diff --git a/libyul/optimiser/DataFlowAnalyzer.h b/libyul/optimiser/DataFlowAnalyzer.h index a8463360b..b82f43753 100644 --- a/libyul/optimiser/DataFlowAnalyzer.h +++ b/libyul/optimiser/DataFlowAnalyzer.h @@ -81,12 +81,14 @@ struct AssignedValue class DataFlowAnalyzer: public ASTModifier { public: + enum class MemoryAndStorage { Analyze, Ignore }; /// @param _functionSideEffects /// Side-effects of user-defined functions. Worst-case side-effects are assumed /// if this is not provided or the function is not found. /// The parameter is mostly used to determine movability of expressions. explicit DataFlowAnalyzer( Dialect const& _dialect, + MemoryAndStorage _analyzeStores, std::map _functionSideEffects = {} ); @@ -146,7 +148,7 @@ protected: bool inScope(YulString _variableName) const; /// Returns the literal value of the identifier, if it exists. - std::optional valueOfIdentifier(YulString const& _name); + std::optional valueOfIdentifier(YulString const& _name) const; enum class StoreLoadLocation { Memory = 0, @@ -189,6 +191,8 @@ private: protected: KnowledgeBase m_knowledgeBase; + /// If true, analyzes memory and storage content via mload/mstore and sload/sstore. + bool m_analyzeStores = true; YulString m_storeFunctionName[static_cast(StoreLoadLocation::Last) + 1]; YulString m_loadFunctionName[static_cast(StoreLoadLocation::Last) + 1]; diff --git a/libyul/optimiser/DeadCodeEliminator.h b/libyul/optimiser/DeadCodeEliminator.h index 2c166a836..ae8c1b2a6 100644 --- a/libyul/optimiser/DeadCodeEliminator.h +++ b/libyul/optimiser/DeadCodeEliminator.h @@ -63,7 +63,7 @@ private: DeadCodeEliminator( Dialect const& _dialect, std::map _sideEffects - ): m_dialect(_dialect), m_functionSideEffects(move(_sideEffects)) {} + ): m_dialect(_dialect), m_functionSideEffects(std::move(_sideEffects)) {} Dialect const& m_dialect; std::map m_functionSideEffects; diff --git a/libyul/optimiser/EqualStoreEliminator.h b/libyul/optimiser/EqualStoreEliminator.h index 796fcc538..b8572f466 100644 --- a/libyul/optimiser/EqualStoreEliminator.h +++ b/libyul/optimiser/EqualStoreEliminator.h @@ -47,7 +47,7 @@ private: Dialect const& _dialect, std::map _functionSideEffects ): - DataFlowAnalyzer(_dialect, std::move(_functionSideEffects)) + DataFlowAnalyzer(_dialect, MemoryAndStorage::Analyze, std::move(_functionSideEffects)) {} protected: diff --git a/libyul/optimiser/ExpressionSimplifier.cpp b/libyul/optimiser/ExpressionSimplifier.cpp index 8c3a038f1..caf74cfb7 100644 --- a/libyul/optimiser/ExpressionSimplifier.cpp +++ b/libyul/optimiser/ExpressionSimplifier.cpp @@ -23,7 +23,11 @@ #include #include +#include #include +#include + +#include using namespace std; using namespace solidity; @@ -44,4 +48,29 @@ void ExpressionSimplifier::visit(Expression& _expression) [this](YulString _var) { return variableValue(_var); } )) _expression = match->action().toExpression(debugDataOf(_expression)); + + if (auto* functionCall = get_if(&_expression)) + if (optional instruction = toEVMInstruction(m_dialect, functionCall->functionName.name)) + for (auto op: evmasm::SemanticInformation::readWriteOperations(*instruction)) + if (op.startParameter && op.lengthParameter) + { + Expression& startArgument = functionCall->arguments.at(*op.startParameter); + Expression const& lengthArgument = functionCall->arguments.at(*op.lengthParameter); + if ( + knownToBeZero(lengthArgument) && + !knownToBeZero(startArgument) && + !holds_alternative(startArgument) + ) + startArgument = Literal{debugDataOf(startArgument), LiteralKind::Number, "0"_yulstring, {}}; + } +} + +bool ExpressionSimplifier::knownToBeZero(Expression const& _expression) const +{ + if (auto const* literal = get_if(&_expression)) + return valueOfLiteral(*literal) == 0; + else if (auto const* identifier = get_if(&_expression)) + return valueOfIdentifier(identifier->name) == 0; + else + return false; } diff --git a/libyul/optimiser/ExpressionSimplifier.h b/libyul/optimiser/ExpressionSimplifier.h index f9d4e8da5..662c8c389 100644 --- a/libyul/optimiser/ExpressionSimplifier.h +++ b/libyul/optimiser/ExpressionSimplifier.h @@ -51,7 +51,10 @@ public: void visit(Expression& _expression) override; private: - explicit ExpressionSimplifier(Dialect const& _dialect): DataFlowAnalyzer(_dialect) {} + explicit ExpressionSimplifier(Dialect const& _dialect): + DataFlowAnalyzer(_dialect, MemoryAndStorage::Ignore) + {} + bool knownToBeZero(Expression const& _expression) const; }; } diff --git a/libyul/optimiser/ForLoopInitRewriter.cpp b/libyul/optimiser/ForLoopInitRewriter.cpp index 345dd1266..7cfa16b4f 100644 --- a/libyul/optimiser/ForLoopInitRewriter.cpp +++ b/libyul/optimiser/ForLoopInitRewriter.cpp @@ -40,7 +40,7 @@ void ForLoopInitRewriter::operator()(Block& _block) (*this)(forLoop.post); vector rewrite; swap(rewrite, forLoop.pre.statements); - rewrite.emplace_back(move(forLoop)); + rewrite.emplace_back(std::move(forLoop)); return { std::move(rewrite) }; } else diff --git a/libyul/optimiser/FullInliner.cpp b/libyul/optimiser/FullInliner.cpp index 61e2800b8..9ffe871fa 100644 --- a/libyul/optimiser/FullInliner.cpp +++ b/libyul/optimiser/FullInliner.cpp @@ -22,11 +22,14 @@ #include #include +#include +#include #include #include #include #include #include +#include #include #include #include @@ -46,8 +49,12 @@ void FullInliner::run(OptimiserStepContext& _context, Block& _ast) } FullInliner::FullInliner(Block& _ast, NameDispenser& _dispenser, Dialect const& _dialect): - m_ast(_ast), m_nameDispenser(_dispenser), m_dialect(_dialect) + m_ast(_ast), + m_recursiveFunctions(CallGraphGenerator::callGraph(_ast).recursiveFunctions()), + m_nameDispenser(_dispenser), + m_dialect(_dialect) { + // Determine constants SSAValueTracker tracker; tracker(m_ast); @@ -71,6 +78,15 @@ FullInliner::FullInliner(Block& _ast, NameDispenser& _dispenser, Dialect const& m_singleUse.emplace(fun.name); updateCodeSize(fun); } + + // Check for memory guard. + vector memoryGuardCalls = FunctionCallFinder::run( + _ast, + "memoryguard"_yulstring + ); + // We will perform less aggressive inlining, if no ``memoryguard`` call is found. + if (!memoryGuardCalls.empty()) + m_hasMemoryGuard = true; } void FullInliner::run(Pass _pass) @@ -177,8 +193,20 @@ bool FullInliner::shallInline(FunctionCall const& _funCall, YulString _callSite) if (m_pass == Pass::InlineTiny) return false; - // Do not inline into already big functions. - if (m_functionSizes.at(_callSite) > 45) + bool aggressiveInlining = true; + + if ( + EVMDialect const* evmDialect = dynamic_cast(&m_dialect); + !evmDialect || !evmDialect->providesObjectAccess() || evmDialect->evmVersion() <= langutil::EVMVersion::homestead() + ) + // No aggressive inlining with the old code transform. + aggressiveInlining = false; + + // No aggressive inlining, if we cannot perform stack-to-memory. + if (!m_hasMemoryGuard || m_recursiveFunctions.count(_callSite)) + aggressiveInlining = false; + + if (!aggressiveInlining && m_functionSizes.at(_callSite) > 45) return false; if (m_singleUse.count(calledFunction->name)) @@ -196,7 +224,7 @@ bool FullInliner::shallInline(FunctionCall const& _funCall, YulString _callSite) break; } - return (size < 6 || (constantArg && size < 12)); + return (size < (aggressiveInlining ? 8u : 6u) || (constantArg && size < (aggressiveInlining ? 16u : 12u))); } void FullInliner::tentativelyUpdateCodeSize(YulString _function, YulString _callSite) diff --git a/libyul/optimiser/FullInliner.h b/libyul/optimiser/FullInliner.h index a743bf323..5029abf39 100644 --- a/libyul/optimiser/FullInliner.h +++ b/libyul/optimiser/FullInliner.h @@ -111,6 +111,10 @@ private: std::map m_functions; /// Functions not to be inlined (because they contain the ``leave`` statement). std::set m_noInlineFunctions; + /// True, if the code contains a ``memoryguard`` and we can expect to be able to move variables to memory later. + bool m_hasMemoryGuard = false; + /// Set of recursive functions. + std::set m_recursiveFunctions; /// Names of functions to always inline. std::set m_singleUse; /// Variables that are constants (used for inlining heuristic) diff --git a/libyul/optimiser/FunctionSpecializer.cpp b/libyul/optimiser/FunctionSpecializer.cpp index 1d14db18b..4555e2f8f 100644 --- a/libyul/optimiser/FunctionSpecializer.cpp +++ b/libyul/optimiser/FunctionSpecializer.cpp @@ -65,7 +65,7 @@ void FunctionSpecializer::operator()(FunctionCall& _f) if (ranges::any_of(arguments, [](auto& _a) { return _a.has_value(); })) { - YulString oldName = move(_f.functionName.name); + YulString oldName = std::move(_f.functionName.name); auto newName = m_nameDispenser.newName(oldName); m_oldToNewMap[oldName].emplace_back(make_pair(newName, arguments)); @@ -106,12 +106,12 @@ FunctionDefinition FunctionSpecializer::specialize( VariableDeclaration{ _f.debugData, vector{newFunction.parameters[index]}, - make_unique(move(*argument)) + make_unique(std::move(*argument)) } ); newFunction.body.statements = - move(missingVariableDeclarations) + move(newFunction.body.statements); + std::move(missingVariableDeclarations) + std::move(newFunction.body.statements); // Only take those indices that cannot be specialized, i.e., whose value is `nullopt`. newFunction.parameters = @@ -120,7 +120,7 @@ FunctionDefinition FunctionSpecializer::specialize( applyMap(_arguments, [&](auto const& _v) { return !_v; }) ); - newFunction.name = move(_newName); + newFunction.name = std::move(_newName); return newFunction; } @@ -146,10 +146,10 @@ void FunctionSpecializer::run(OptimiserStepContext& _context, Block& _ast) f.m_oldToNewMap.at(functionDefinition.name), [&](auto& _p) -> Statement { - return f.specialize(functionDefinition, move(_p.first), move(_p.second)); + return f.specialize(functionDefinition, std::move(_p.first), std::move(_p.second)); } ); - return move(out) + make_vector(move(functionDefinition)); + return std::move(out) + make_vector(std::move(functionDefinition)); } } diff --git a/libyul/optimiser/KnowledgeBase.cpp b/libyul/optimiser/KnowledgeBase.cpp index 460f6707f..77848cce0 100644 --- a/libyul/optimiser/KnowledgeBase.cpp +++ b/libyul/optimiser/KnowledgeBase.cpp @@ -89,7 +89,7 @@ optional KnowledgeBase::valueIfKnownConstant(YulString _a) Expression KnowledgeBase::simplify(Expression _expression) { m_counter = 0; - return simplifyRecursively(move(_expression)); + return simplifyRecursively(std::move(_expression)); } Expression KnowledgeBase::simplifyRecursively(Expression _expression) diff --git a/libyul/optimiser/LoadResolver.h b/libyul/optimiser/LoadResolver.h index 93d37d779..e56bc6c4a 100644 --- a/libyul/optimiser/LoadResolver.h +++ b/libyul/optimiser/LoadResolver.h @@ -53,7 +53,7 @@ private: bool _containsMSize, std::optional _expectedExecutionsPerDeployment ): - DataFlowAnalyzer(_dialect, std::move(_functionSideEffects)), + DataFlowAnalyzer(_dialect, MemoryAndStorage::Analyze, std::move(_functionSideEffects)), m_containsMSize(_containsMSize), m_expectedExecutionsPerDeployment(std::move(_expectedExecutionsPerDeployment)) {} diff --git a/libyul/optimiser/NameDispenser.cpp b/libyul/optimiser/NameDispenser.cpp index 01d33919f..d43b6802f 100644 --- a/libyul/optimiser/NameDispenser.cpp +++ b/libyul/optimiser/NameDispenser.cpp @@ -37,7 +37,7 @@ using namespace solidity::util; NameDispenser::NameDispenser(Dialect const& _dialect, Block const& _ast, set _reservedNames): NameDispenser(_dialect, NameCollector(_ast).names() + _reservedNames) { - m_reservedNames = move(_reservedNames); + m_reservedNames = std::move(_reservedNames); } NameDispenser::NameDispenser(Dialect const& _dialect, set _usedNames): diff --git a/libyul/optimiser/NameSimplifier.cpp b/libyul/optimiser/NameSimplifier.cpp index dfe1df9f4..0eb568beb 100644 --- a/libyul/optimiser/NameSimplifier.cpp +++ b/libyul/optimiser/NameSimplifier.cpp @@ -111,7 +111,7 @@ void NameSimplifier::findSimplification(YulString const& _name) { YulString newName{name}; m_context.dispenser.markUsed(newName); - m_translations[_name] = move(newName); + m_translations[_name] = std::move(newName); } } diff --git a/libyul/optimiser/ReasoningBasedSimplifier.cpp b/libyul/optimiser/ReasoningBasedSimplifier.cpp index 94c7102bd..af39978ed 100644 --- a/libyul/optimiser/ReasoningBasedSimplifier.cpp +++ b/libyul/optimiser/ReasoningBasedSimplifier.cpp @@ -71,7 +71,7 @@ void ReasoningBasedSimplifier::operator()(If& _if) { Literal trueCondition = m_dialect.trueLiteral(); trueCondition.debugData = debugDataOf(*_if.condition); - _if.condition = make_unique(move(trueCondition)); + _if.condition = make_unique(std::move(trueCondition)); } else { @@ -83,7 +83,7 @@ void ReasoningBasedSimplifier::operator()(If& _if) { Literal falseCondition = m_dialect.zeroLiteralForType(m_dialect.boolType); falseCondition.debugData = debugDataOf(*_if.condition); - _if.condition = make_unique(move(falseCondition)); + _if.condition = make_unique(std::move(falseCondition)); _if.body = yul::Block{}; // Nothing left to be done. return; diff --git a/libyul/optimiser/Rematerialiser.cpp b/libyul/optimiser/Rematerialiser.cpp index 7dff1df80..fb42e6593 100644 --- a/libyul/optimiser/Rematerialiser.cpp +++ b/libyul/optimiser/Rematerialiser.cpp @@ -43,7 +43,7 @@ Rematerialiser::Rematerialiser( set _varsToAlwaysRematerialize, bool _onlySelectedVariables ): - DataFlowAnalyzer(_dialect), + DataFlowAnalyzer(_dialect, MemoryAndStorage::Ignore), m_referenceCounts(ReferencesCounter::countReferences(_ast)), m_varsToAlwaysRematerialize(std::move(_varsToAlwaysRematerialize)), m_onlySelectedVariables(_onlySelectedVariables) diff --git a/libyul/optimiser/Rematerialiser.h b/libyul/optimiser/Rematerialiser.h index 592f79d1b..9ee5209fd 100644 --- a/libyul/optimiser/Rematerialiser.h +++ b/libyul/optimiser/Rematerialiser.h @@ -95,7 +95,7 @@ public: private: LiteralRematerialiser(Dialect const& _dialect): - DataFlowAnalyzer(_dialect) + DataFlowAnalyzer(_dialect, MemoryAndStorage::Ignore) {} }; diff --git a/libyul/optimiser/StackCompressor.cpp b/libyul/optimiser/StackCompressor.cpp index b3402e4d7..a6173996f 100644 --- a/libyul/optimiser/StackCompressor.cpp +++ b/libyul/optimiser/StackCompressor.cpp @@ -56,7 +56,7 @@ namespace class RematCandidateSelector: public DataFlowAnalyzer { public: - explicit RematCandidateSelector(Dialect const& _dialect): DataFlowAnalyzer(_dialect) {} + explicit RematCandidateSelector(Dialect const& _dialect): DataFlowAnalyzer(_dialect, MemoryAndStorage::Ignore) {} /// @returns a map from function name to rematerialisation costs to a vector of variables to rematerialise /// and variables that occur in their expression. @@ -176,7 +176,7 @@ void eliminateVariables( varsToEliminate += chooseVarsToEliminate(candidates[functionName], static_cast(numVariables)); } - Rematerialiser::run(_dialect, _ast, move(varsToEliminate)); + Rematerialiser::run(_dialect, _ast, std::move(varsToEliminate)); // Do not remove functions. set allFunctions = NameCollector{_ast, NameCollector::OnlyFunctions}.names(); UnusedPruner::runUntilStabilised(_dialect, _ast, _allowMSizeOptimization, nullptr, allFunctions); diff --git a/libyul/optimiser/StackToMemoryMover.cpp b/libyul/optimiser/StackToMemoryMover.cpp index 425680923..74d05635e 100644 --- a/libyul/optimiser/StackToMemoryMover.cpp +++ b/libyul/optimiser/StackToMemoryMover.cpp @@ -50,7 +50,7 @@ vector generateMemoryStore( Identifier{_debugData, memoryStoreFunction->name}, { Literal{_debugData, LiteralKind::Number, _mpos, {}}, - move(_value) + std::move(_value) } }}); return result; @@ -95,7 +95,7 @@ void StackToMemoryMover::run( ) ); stackToMemoryMover(_block); - _block.statements += move(stackToMemoryMover.m_newFunctionDefinitions); + _block.statements += std::move(stackToMemoryMover.m_newFunctionDefinitions); } StackToMemoryMover::StackToMemoryMover( @@ -106,7 +106,7 @@ StackToMemoryMover::StackToMemoryMover( m_context(_context), m_memoryOffsetTracker(_memoryOffsetTracker), m_nameDispenser(_context.dispenser), -m_functionReturnVariables(move(_functionReturnVariables)) +m_functionReturnVariables(std::move(_functionReturnVariables)) { auto const* evmDialect = dynamic_cast(&_context.dialect); yulAssert( @@ -156,7 +156,7 @@ void StackToMemoryMover::operator()(FunctionDefinition& _functionDefinition) newFunctionName, stackParameters, {}, - move(_functionDefinition.body) + std::move(_functionDefinition.body) }); // Generate new names for the arguments to maintain disambiguation. std::map newArgumentNames; @@ -165,7 +165,7 @@ void StackToMemoryMover::operator()(FunctionDefinition& _functionDefinition) for (auto& parameter: _functionDefinition.parameters) parameter.name = util::valueOrDefault(newArgumentNames, parameter.name, parameter.name); // Replace original function by a call to the new function and an assignment to the return variable from memory. - _functionDefinition.body = Block{_functionDefinition.debugData, move(memoryVariableInits)}; + _functionDefinition.body = Block{_functionDefinition.debugData, std::move(memoryVariableInits)}; _functionDefinition.body.statements.emplace_back(ExpressionStatement{ _functionDefinition.debugData, FunctionCall{ @@ -189,7 +189,7 @@ void StackToMemoryMover::operator()(FunctionDefinition& _functionDefinition) } if (!memoryVariableInits.empty()) - _functionDefinition.body.statements = move(memoryVariableInits) + move(_functionDefinition.body.statements); + _functionDefinition.body.statements = std::move(memoryVariableInits) + std::move(_functionDefinition.body.statements); _functionDefinition.returnVariables = _functionDefinition.returnVariables | ranges::views::filter( not_fn(m_memoryOffsetTracker) @@ -214,7 +214,7 @@ void StackToMemoryMover::operator()(Block& _block) m_context.dialect, debugData, *offset, - _stmt.value ? *move(_stmt.value) : Literal{debugData, LiteralKind::Number, "0"_yulstring, {}} + _stmt.value ? *std::move(_stmt.value) : Literal{debugData, LiteralKind::Number, "0"_yulstring, {}} ); else return {}; @@ -245,7 +245,7 @@ void StackToMemoryMover::operator()(Block& _block) vector memoryAssignments; vector variableAssignments; - VariableDeclaration tempDecl{debugData, {}, move(_stmt.value)}; + VariableDeclaration tempDecl{debugData, {}, std::move(_stmt.value)}; yulAssert(rhsMemorySlots.size() == _lhsVars.size(), ""); for (auto&& [lhsVar, rhsSlot]: ranges::views::zip(_lhsVars, rhsMemorySlots)) @@ -265,26 +265,26 @@ void StackToMemoryMover::operator()(Block& _block) m_context.dialect, _stmt.debugData, *offset, - move(*rhs) + std::move(*rhs) ); else variableAssignments.emplace_back(StatementType{ debugData, - { move(lhsVar) }, - move(rhs) + { std::move(lhsVar) }, + std::move(rhs) }); } vector result; if (tempDecl.variables.empty()) - result.emplace_back(ExpressionStatement{debugData, *move(tempDecl.value)}); + result.emplace_back(ExpressionStatement{debugData, *std::move(tempDecl.value)}); else - result.emplace_back(move(tempDecl)); + result.emplace_back(std::move(tempDecl)); reverse(memoryAssignments.begin(), memoryAssignments.end()); - result += move(memoryAssignments); + result += std::move(memoryAssignments); reverse(variableAssignments.begin(), variableAssignments.end()); - result += move(variableAssignments); - return OptionalStatements{move(result)}; + result += std::move(variableAssignments); + return OptionalStatements{std::move(result)}; }; util::iterateReplacing( diff --git a/libyul/optimiser/UnusedFunctionParameterPruner.cpp b/libyul/optimiser/UnusedFunctionParameterPruner.cpp index 75e8325a3..6ce097f42 100644 --- a/libyul/optimiser/UnusedFunctionParameterPruner.cpp +++ b/libyul/optimiser/UnusedFunctionParameterPruner.cpp @@ -118,7 +118,7 @@ void UnusedFunctionParameterPruner::run(OptimiserStepContext& _context, Block& _ originalFunction.returnVariables = filter(originalFunction.returnVariables, used.second); - return make_vector(move(originalFunction), move(linkingFunction)); + return make_vector(std::move(originalFunction), std::move(linkingFunction)); } } diff --git a/libyul/optimiser/UnusedStoreBase.cpp b/libyul/optimiser/UnusedStoreBase.cpp index de13a23cc..49f550842 100644 --- a/libyul/optimiser/UnusedStoreBase.cpp +++ b/libyul/optimiser/UnusedStoreBase.cpp @@ -40,7 +40,7 @@ void UnusedStoreBase::operator()(If const& _if) TrackedStores skipBranch{m_stores}; (*this)(_if.body); - merge(m_stores, move(skipBranch)); + merge(m_stores, std::move(skipBranch)); } void UnusedStoreBase::operator()(Switch const& _switch) @@ -56,17 +56,17 @@ void UnusedStoreBase::operator()(Switch const& _switch) if (!c.value) hasDefault = true; (*this)(c.body); - branches.emplace_back(move(m_stores)); + branches.emplace_back(std::move(m_stores)); m_stores = preState; } if (hasDefault) { - m_stores = move(branches.back()); + m_stores = std::move(branches.back()); branches.pop_back(); } for (auto& branch: branches) - merge(m_stores, move(branch)); + merge(m_stores, std::move(branch)); } void UnusedStoreBase::operator()(FunctionDefinition const& _functionDefinition) @@ -97,7 +97,7 @@ void UnusedStoreBase::operator()(ForLoop const& _forLoop) TrackedStores zeroRuns{m_stores}; (*this)(_forLoop.body); - merge(m_stores, move(m_forLoopInfo.pendingContinueStmts)); + merge(m_stores, std::move(m_forLoopInfo.pendingContinueStmts)); m_forLoopInfo.pendingContinueStmts = {}; (*this)(_forLoop.post); @@ -110,50 +110,50 @@ void UnusedStoreBase::operator()(ForLoop const& _forLoop) (*this)(_forLoop.body); - merge(m_stores, move(m_forLoopInfo.pendingContinueStmts)); + merge(m_stores, std::move(m_forLoopInfo.pendingContinueStmts)); m_forLoopInfo.pendingContinueStmts.clear(); (*this)(_forLoop.post); visit(*_forLoop.condition); // Order of merging does not matter because "max" is commutative and associative. - merge(m_stores, move(oneRun)); + merge(m_stores, std::move(oneRun)); } else // Shortcut to avoid horrible runtime. shortcutNestedLoop(zeroRuns); // Order of merging does not matter because "max" is commutative and associative. - merge(m_stores, move(zeroRuns)); - merge(m_stores, move(m_forLoopInfo.pendingBreakStmts)); + merge(m_stores, std::move(zeroRuns)); + merge(m_stores, std::move(m_forLoopInfo.pendingBreakStmts)); m_forLoopInfo.pendingBreakStmts.clear(); } void UnusedStoreBase::operator()(Break const&) { - m_forLoopInfo.pendingBreakStmts.emplace_back(move(m_stores)); + m_forLoopInfo.pendingBreakStmts.emplace_back(std::move(m_stores)); m_stores.clear(); } void UnusedStoreBase::operator()(Continue const&) { - m_forLoopInfo.pendingContinueStmts.emplace_back(move(m_stores)); + m_forLoopInfo.pendingContinueStmts.emplace_back(std::move(m_stores)); m_stores.clear(); } void UnusedStoreBase::merge(TrackedStores& _target, TrackedStores&& _other) { - util::joinMap(_target, move(_other), []( + util::joinMap(_target, std::move(_other), []( map& _assignmentHere, map&& _assignmentThere ) { - return util::joinMap(_assignmentHere, move(_assignmentThere), State::join); + return util::joinMap(_assignmentHere, std::move(_assignmentThere), State::join); }); } void UnusedStoreBase::merge(TrackedStores& _target, vector&& _source) { for (TrackedStores& ts: _source) - merge(_target, move(ts)); + merge(_target, std::move(ts)); _source.clear(); } diff --git a/libyul/optimiser/UnusedStoreEliminator.cpp b/libyul/optimiser/UnusedStoreEliminator.cpp index 343bd720a..754c02ac5 100644 --- a/libyul/optimiser/UnusedStoreEliminator.cpp +++ b/libyul/optimiser/UnusedStoreEliminator.cpp @@ -31,6 +31,8 @@ #include #include +#include + #include #include @@ -76,7 +78,13 @@ void UnusedStoreEliminator::run(OptimiserStepContext& _context, Block& _ast) ignoreMemory }; rse(_ast); - rse.changeUndecidedTo(State::Unused, Location::Memory); + if ( + auto evmDialect = dynamic_cast(&_context.dialect); + evmDialect && evmDialect->providesObjectAccess() + ) + rse.changeUndecidedTo(State::Unused, Location::Memory); + else + rse.changeUndecidedTo(State::Used, Location::Memory); rse.changeUndecidedTo(State::Used, Location::Storage); rse.scheduleUnusedForDeletion(); @@ -157,10 +165,28 @@ void UnusedStoreEliminator::visit(Statement const& _statement) yulAssert(isCandidateForRemoval == (isStorageWrite || (!m_ignoreMemory && isMemoryWrite))); if (isCandidateForRemoval) { - m_stores[YulString{}].insert({&_statement, State::Undecided}); + State initialState = State::Undecided; + if (*instruction == Instruction::RETURNDATACOPY) + { + initialState = State::Used; + auto startOffset = identifierNameIfSSA(funCall->arguments.at(1)); + auto length = identifierNameIfSSA(funCall->arguments.at(2)); + KnowledgeBase knowledge(m_dialect, [this](YulString _var) { return util::valueOrNullptr(m_ssaValues, _var); }); + if (length && startOffset) + { + FunctionCall const* lengthCall = get_if(m_ssaValues.at(*length).value); + if ( + knowledge.knownToBeZero(*startOffset) && + lengthCall && + toEVMInstruction(m_dialect, lengthCall->functionName.name) == Instruction::RETURNDATASIZE + ) + initialState = State::Undecided; + } + } + m_stores[YulString{}].insert({&_statement, initialState}); vector operations = operationsFromFunctionCall(*funCall); yulAssert(operations.size() == 1, ""); - m_storeOperations[&_statement] = move(operations.front()); + m_storeOperations[&_statement] = std::move(operations.front()); } } diff --git a/scripts/build_emscripten.sh b/scripts/build_emscripten.sh index 841cc26b3..43a402fd6 100755 --- a/scripts/build_emscripten.sh +++ b/scripts/build_emscripten.sh @@ -34,7 +34,7 @@ else BUILD_DIR="$1" fi -# solbuildpackpusher/solidity-buildpack-deps:emscripten-11 +# solbuildpackpusher/solidity-buildpack-deps:emscripten-13 docker run -v "$(pwd):/root/project" -w /root/project \ - solbuildpackpusher/solidity-buildpack-deps@sha256:0ad7c65e8c54d926ba9cb80d56246e4fc49f9284ad5188aaaa4834f46ab0c315 \ + solbuildpackpusher/solidity-buildpack-deps@sha256:f1c13f3450d1f2e53ea18ac1ac1a17e932573cb9a5ccd0fd9ef6dd44f6402fa9 \ ./scripts/ci/build_emscripten.sh "$BUILD_DIR" diff --git a/scripts/ci/build_emscripten.sh b/scripts/ci/build_emscripten.sh index 55d2288c3..f2e475c2a 100755 --- a/scripts/ci/build_emscripten.sh +++ b/scripts/ci/build_emscripten.sh @@ -40,7 +40,8 @@ else BUILD_DIR="$1" fi -apt-get update && apt-get install lz4 +apt-get update +apt-get install lz4 --no-install-recommends WORKSPACE=/root/project @@ -61,12 +62,21 @@ then echo -n "$CIRCLE_SHA1" >commit_hash.txt fi +# Disable warnings for unqualified `move()` calls, introduced and enabled by +# default in clang-16 which is what the emscripten docker image uses. +# Additionally, disable the warning for unknown warnings here, as this script is +# also used with earlier clang versions. +# TODO: This can be removed if and when all usages of `move()` in our codebase use the `std::` qualifier. +CMAKE_CXX_FLAGS="-Wno-unqualified-std-cast-call" + + mkdir -p "$BUILD_DIR" cd "$BUILD_DIR" emcmake cmake \ -DCMAKE_BUILD_TYPE=Release \ -DBoost_USE_STATIC_LIBS=1 \ -DBoost_USE_STATIC_RUNTIME=1 \ + -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" \ -DTESTS=0 \ .. make soljson diff --git a/scripts/codespell_ignored_lines.txt b/scripts/codespell_ignored_lines.txt new file mode 100644 index 000000000..b7987cc00 --- /dev/null +++ b/scripts/codespell_ignored_lines.txt @@ -0,0 +1,20 @@ + A constant BT = BU; + A constant BU = BV; + A constant FN = FO; + A constant FO = FP; + struct BT { BU m; } + struct BU { BV m; } + struct FN { FO m; } + struct FO { FP m; } +// encode_inline_asm(bytes): 0x20, 2, "fo" -> 0x20, 4, "Zm8=" +// encode_no_asm(bytes): 0x20, 2, "fo" -> 0x20, 4, "Zm8=" + BOOST_TEST(mutation(chromosome) == Chromosome("fo")); +docker run --rm -v "${OUTPUTDIR}":/tmp/output -v "${SCRIPTDIR}":/tmp/scripts:ro -it trzeci/emscripten:sdk-tag-1.39.3-64bit /tmp/scripts/docker-scripts/rebuild_tags.sh "${TAGS}" /tmp/output "$@" + + + + templ("assignEnd", dynamic ? "end := pos" : ""); + templ("assignEnd", dynamic ? "end := pos" : ""); + templ("assignEnd", "end := pos"); + templ("assignEnd", "end := tail"); + templ("assignEnd", ""); diff --git a/scripts/codespell_whitelist.txt b/scripts/codespell_whitelist.txt index 035060866..7de8a42fe 100644 --- a/scripts/codespell_whitelist.txt +++ b/scripts/codespell_whitelist.txt @@ -1,16 +1,3 @@ -iff nd -assignend -uint -mut -BA -FO -ba -fo compilability -errorstring -hist -otion keypair -ether -sur diff --git a/scripts/common.sh b/scripts/common.sh index 1ea0e1fc1..98f63ecb8 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -40,6 +40,28 @@ else function printLog { echo "$(tput setaf 3)$1$(tput sgr0)"; } fi +function checkDputEntries +{ + local pattern="$1" + grep "${pattern}" /etc/dput.cf --quiet || \ + fail "Error: Missing ${pattern//\\/} section in /etc/dput.cf (check top comment in release_ppa.sh for more information)." +} + +function sourcePPAConfig +{ + [[ "$LAUNCHPAD_KEYID" == "" && "$LAUNCHPAD_EMAIL" == "" ]] || fail + + # source keyid and email from .release_ppa_auth + if [[ -e .release_ppa_auth ]] + then + # shellcheck source=/dev/null + source "${REPO_ROOT}/.release_ppa_auth" + fi + + [[ "$LAUNCHPAD_KEYID" != "" && "$LAUNCHPAD_EMAIL" != "" ]] || \ + fail "Error: Couldn't find variables \$LAUNCHPAD_KEYID or \$LAUNCHPAD_EMAIL in sourced file .release_ppa_auth (check top comment in $0 for more information)." +} + function printStackTrace { printWarning "" diff --git a/scripts/common/git_helpers.py b/scripts/common/git_helpers.py new file mode 100644 index 000000000..bb5b1f613 --- /dev/null +++ b/scripts/common/git_helpers.py @@ -0,0 +1,19 @@ +import subprocess + + +def run_git_command(command): + process = subprocess.run( + command, + encoding='utf8', + capture_output=True, + check=True, + ) + return process.stdout.strip() + + +def git_current_branch(): + return run_git_command(['git', 'symbolic-ref', 'HEAD', '--short']) + + +def git_commit_hash(ref: str = 'HEAD'): + return run_git_command(['git', 'rev-parse', '--verify', ref]) diff --git a/scripts/common/rest_api_helpers.py b/scripts/common/rest_api_helpers.py new file mode 100644 index 000000000..31f973e81 --- /dev/null +++ b/scripts/common/rest_api_helpers.py @@ -0,0 +1,189 @@ +from pathlib import Path +from typing import List, Mapping, Optional +import functools +import json +import operator +import shutil + +import requests + + +class APIHelperError(Exception): + pass + +class JobNotSuccessful(APIHelperError): + def __init__(self, name: str, status: str): + assert status != 'success' + + self.name = name + self.status = status + self.job_finished = (status in ['failed', 'blocked']) + + if status == 'not_running': + message = f"Job {name} has not started yet." + elif status == 'blocked': + message = f"Job {name} will not run because one of its dependencies failed." + elif status == 'running': + message = f"Job {name} is still running." + elif status == 'failed': + message = f"Job {name} failed." + else: + message = f"Job {name} did not finish successfully. Current status: {status}." + + super().__init__(message) + +class JobMissing(APIHelperError): + pass + +class InvalidResponse(APIHelperError): + pass + +class FileAlreadyExists(APIHelperError): + pass + + +def query_api(url: str, params: Mapping[str, str], debug_requests=False) -> dict: + if debug_requests: + print(f'REQUEST URL: {url}') + if len(params) > 0: + print(f'QUERY: {params}') + + response = requests.get(url, params=params, timeout=60) + response.raise_for_status() + + if debug_requests: + json_response = response.json() + print('========== RESPONSE ==========') + if json_response is not None: + print(json.dumps(json_response, indent=4)) + else: + print(response.content) + print('==============================') + + return response.json() + + +def download_file(url: str, target_path: Path, overwrite=False): + if not overwrite and target_path.exists(): + raise FileAlreadyExists(f"Refusing to overwrite existing file: '{target_path}'.") + + with requests.get(url, stream=True, timeout=60) as request: + with open(target_path, 'wb') as target_file: + shutil.copyfileobj(request.raw, target_file) + + +class Github: + BASE_URL = 'https://api.github.com' + + project_slug: str + debug_requests: bool + + def __init__(self, project_slug: str, debug_requests: bool): + self.project_slug = project_slug + self.debug_requests = debug_requests + + def pull_request(self, pr_id: int) -> dict: + return query_api( + f'{self.BASE_URL}/repos/{self.project_slug}/pulls/{pr_id}', + {}, + self.debug_requests + ) + + +class CircleCI: + # None might be a more logical default for max_pages but in most cases we'll actually + # want some limit to prevent flooding the API with requests in case of a bug. + DEFAULT_MAX_PAGES = 10 + BASE_URL = 'https://circleci.com/api/v2' + + project_slug: str + debug_requests: bool + + def __init__(self, project_slug: str, debug_requests: bool): + self.project_slug = project_slug + self.debug_requests = debug_requests + + def paginated_query_api_iterator(self, url: str, params: Mapping[str, str], max_pages: int = DEFAULT_MAX_PAGES): + assert 'page-token' not in params + + page_count = 0 + next_page_token = None + while max_pages is None or page_count < max_pages: + if next_page_token is not None: + params = {**params, 'page-token': next_page_token} + + json_response = query_api(url, params, self.debug_requests) + + yield json_response['items'] + next_page_token = json_response['next_page_token'] + page_count += 1 + if next_page_token is None: + break + + def paginated_query_api(self, url: str, params: Mapping[str, str], max_pages: int = DEFAULT_MAX_PAGES): + return functools.reduce(operator.add, self.paginated_query_api_iterator(url, params, max_pages), []) + + def pipelines( + self, + branch: Optional[str] = None, + commit_hash: Optional[str] = None, + excluded_trigger_types: List[str] = None, + ) -> List[dict]: + if excluded_trigger_types is None: + excluded_trigger_types = [] + + for items in self.paginated_query_api_iterator( + f'{self.BASE_URL}/project/gh/{self.project_slug}/pipeline', + {'branch': branch} if branch is not None else {}, + max_pages=10, + ): + matching_items = [ + item + for item in items + if ( + (commit_hash is None or item['vcs']['revision'] == commit_hash) and + item['trigger']['type'] not in excluded_trigger_types + ) + ] + if len(matching_items) > 0: + return matching_items + + return [] + + def workflows(self, pipeline_id: str) -> dict: + return self.paginated_query_api(f'{self.BASE_URL}/pipeline/{pipeline_id}/workflow', {}) + + def jobs(self, workflow_id: str) -> Mapping[str, dict]: + items = self.paginated_query_api(f'{self.BASE_URL}/workflow/{workflow_id}/job', {}) + jobs_by_name = {job['name']: job for job in items} + + assert len(jobs_by_name) <= len(items) + if len(jobs_by_name) < len(items): + raise InvalidResponse("Job names in the workflow are not unique.") + + return jobs_by_name + + def job(self, workflow_id: str, name: str, require_success: bool = False) -> dict: + jobs = self.jobs(workflow_id) + if name not in jobs: + raise JobMissing(f"Job {name} is not present in the workflow.") + + if require_success and jobs[name]['status'] != 'success': + raise JobNotSuccessful(name, jobs[name]['status']) + + return jobs[name] + + def artifacts(self, job_number: int) -> Mapping[str, dict]: + items = self.paginated_query_api(f'{self.BASE_URL}/project/gh/{self.project_slug}/{job_number}/artifacts', {}) + artifacts_by_name = {artifact['path']: artifact for artifact in items} + + assert len(artifacts_by_name) <= len(items) + if len(artifacts_by_name) < len(items): + raise InvalidResponse("Names of artifacts attached to the job are not unique.") + + return artifacts_by_name + + @staticmethod + def latest_item(items: dict) -> dict: + sorted_items = sorted(items, key=lambda item: item['created_at'], reverse=True) + return sorted_items[0] if len(sorted_items) > 0 else None diff --git a/scripts/deps-ppa/static_z3.sh b/scripts/deps-ppa/static_z3.sh index 6fd353ad8..fa237ba08 100755 --- a/scripts/deps-ppa/static_z3.sh +++ b/scripts/deps-ppa/static_z3.sh @@ -3,9 +3,6 @@ ## This is used to package .deb packages and upload them to the launchpad ## ppa servers for building. ## -## The gnupg key for "builds@ethereum.org" has to be present in order to sign -## the package. -## ## It will clone the Z3 git from github on the specified version tag, ## create a source archive and push it to the ubuntu ppa servers. ## @@ -16,18 +13,35 @@ ## method = ftp ## incoming = ~ethereum/cpp-build-deps ## login = anonymous - +## +## To interact with launchpad, you need to set the variables $LAUNCHPAD_EMAIL +## and $LAUNCHPAD_KEYID in the file .release_ppa_auth in the root directory of +## the project to your launchpad email and pgp keyid. +## This could for example look like this: +## +## LAUNCHPAD_EMAIL=your-launchpad-email@ethereum.org +## LAUNCHPAD_KEYID=123ABCFFFFFFFF ## ############################################################################## -set -ev +set -e -keyid=70D110489D66E2F6 -email=builds@ethereum.org packagename=z3-static -version=4.8.17 +version="$1" -DISTRIBUTIONS="focal impish jammy" +REPO_ROOT="$(dirname "$0")/../.." + +# shellcheck source=/dev/null +source "${REPO_ROOT}/scripts/common.sh" + +[[ $version != "" ]] || fail "Usage: $0 " + +sourcePPAConfig + +# Sanity check +checkDputEntries "\[cpp-build-deps\]" + +DISTRIBUTIONS="focal jammy kinetic" for distribution in $DISTRIBUTIONS do @@ -40,7 +54,7 @@ pparepo=cpp-build-deps ppafilesurl=https://launchpad.net/~ethereum/+archive/ubuntu/${pparepo}/+files # Fetch source -git clone --branch z3-${version} https://github.com/Z3Prover/z3.git +git clone --branch "z3-${version}" https://github.com/Z3Prover/z3.git cd z3 debversion="${version}" @@ -50,11 +64,11 @@ CMAKE_OPTIONS="-DZ3_BUILD_LIBZ3_SHARED=OFF -DCMAKE_BUILD_TYPE=Release" # gzip will create different tars all the time and we are not allowed # to upload the same file twice with different contents, so we only # create it once. -if [ ! -e /tmp/${packagename}_${debversion}.orig.tar.gz ] +if [ ! -e "/tmp/${packagename}_${debversion}.orig.tar.gz" ] then - tar --exclude .git -czf /tmp/${packagename}_${debversion}.orig.tar.gz . + tar --exclude .git -czf "/tmp/${packagename}_${debversion}.orig.tar.gz" . fi -cp /tmp/${packagename}_${debversion}.orig.tar.gz ../ +cp "/tmp/${packagename}_${debversion}.orig.tar.gz" ../ # Create debian package information @@ -209,7 +223,7 @@ echo "3.0 (quilt)" > debian/source/format chmod +x debian/rules versionsuffix=1ubuntu0~${distribution} -EMAIL="$email" dch -v "1:${debversion}-${versionsuffix}" "build of ${version}" +EMAIL="$LAUNCHPAD_EMAIL" dch -v "1:${debversion}-${versionsuffix}" "build of ${version}" # build source package # If packages is rejected because original source is already present, add @@ -226,26 +240,26 @@ cd .. orig="${packagename}_${debversion}.orig.tar.gz" # shellcheck disable=SC2012 orig_size=$(ls -l "$orig" | cut -d ' ' -f 5) -orig_sha1=$(sha1sum $orig | cut -d ' ' -f 1) -orig_sha256=$(sha256sum $orig | cut -d ' ' -f 1) -orig_md5=$(md5sum $orig | cut -d ' ' -f 1) +orig_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1) +orig_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1) +orig_md5=$(md5sum "$orig" | cut -d ' ' -f 1) -if wget --quiet -O $orig-tmp "$ppafilesurl/$orig" +if wget --quiet -O "$orig-tmp" "$ppafilesurl/$orig" then echo "[WARN] Original tarball found in Ubuntu archive, using it instead" - mv $orig-tmp $orig + mv "${orig}-tmp" "$orig" # shellcheck disable=SC2012 new_size=$(ls -l ./*.orig.tar.gz | cut -d ' ' -f 5) - new_sha1=$(sha1sum $orig | cut -d ' ' -f 1) - new_sha256=$(sha256sum $orig | cut -d ' ' -f 1) - new_md5=$(md5sum $orig | cut -d ' ' -f 1) + new_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1) + new_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1) + new_md5=$(md5sum "$orig" | cut -d ' ' -f 1) sed -i -e "s,$orig_sha1,$new_sha1,g" -e "s,$orig_sha256,$new_sha256,g" -e "s,$orig_size,$new_size,g" -e "s,$orig_md5,$new_md5,g" ./*.dsc sed -i -e "s,$orig_sha1,$new_sha1,g" -e "s,$orig_sha256,$new_sha256,g" -e "s,$orig_size,$new_size,g" -e "s,$orig_md5,$new_md5,g" ./*.changes fi ) # sign the package -debsign --re-sign -k "${keyid}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" +debsign --re-sign -k "${LAUNCHPAD_KEYID}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" # upload dput "${pparepo}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" diff --git a/scripts/docker/buildpack-deps/Dockerfile.emscripten b/scripts/docker/buildpack-deps/Dockerfile.emscripten index 777d8b2ec..ba36541e5 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.emscripten +++ b/scripts/docker/buildpack-deps/Dockerfile.emscripten @@ -32,16 +32,20 @@ # apparently this currently breaks due to conflicting compatibility headers. # Using $(em-config CACHE)/sysroot/usr seems to work, though, and still has cmake find the # dependencies automatically. -FROM emscripten/emsdk:2.0.33 AS base -LABEL version="11" +FROM emscripten/emsdk:3.1.19 AS base +LABEL version="13" ADD emscripten.jam /usr/src -RUN set -ex; \ - cd /usr/src; \ - git clone https://github.com/Z3Prover/z3.git -b z3-4.8.17 --depth 1 ; \ - cd z3; \ - mkdir build; \ - cd build; \ +RUN set -ex && \ + \ + apt-get update && \ + apt-get install lz4 --no-install-recommends && \ + \ + cd /usr/src && \ + git clone https://github.com/Z3Prover/z3.git -b z3-4.11.0 --depth 1 && \ + cd z3 && \ + mkdir build && \ + cd build && \ emcmake cmake \ -DCMAKE_INSTALL_PREFIX=$(em-config CACHE)/sysroot/usr \ -DCMAKE_BUILD_TYPE=MinSizeRel \ @@ -51,21 +55,22 @@ RUN set -ex; \ -DZ3_BUILD_EXECUTABLE=OFF \ -DZ3_SINGLE_THREADED=ON \ -DCMAKE_CXX_FLAGS="-s DISABLE_EXCEPTION_CATCHING=0" \ - ..; \ - make ; make install; \ - rm -r /usr/src/z3; \ - cd /usr/src; \ - - wget -q 'https://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.tar.bz2' -O boost.tar.bz2; \ - test "$(sha256sum boost.tar.bz2)" = "953db31e016db7bb207f11432bef7df100516eeb746843fa0486a222e3fd49cb boost.tar.bz2"; \ - tar -xf boost.tar.bz2; \ - rm boost.tar.bz2; \ - cd boost_1_75_0; \ - mv ../emscripten.jam .; \ - ./bootstrap.sh; \ - echo "using emscripten : : em++ ;" >> project-config.jam ; \ + .. && \ + make && \ + make install && \ + rm -r /usr/src/z3 && \ + cd /usr/src && \ + \ + wget -q 'https://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.tar.bz2' -O boost.tar.bz2 && \ + test "$(sha256sum boost.tar.bz2)" = "953db31e016db7bb207f11432bef7df100516eeb746843fa0486a222e3fd49cb boost.tar.bz2" && \ + tar -xf boost.tar.bz2 && \ + rm boost.tar.bz2 && \ + cd boost_1_75_0 && \ + mv ../emscripten.jam . && \ + ./bootstrap.sh && \ + echo "using emscripten : : em++ ;" >> project-config.jam && \ ./b2 toolset=emscripten link=static variant=release threading=single runtime-link=static \ --with-system --with-filesystem --with-test --with-program_options \ cxxflags="-s DISABLE_EXCEPTION_CATCHING=0 -Wno-unused-local-typedef -Wno-variadic-macros -Wno-c99-extensions -Wno-all" \ - --prefix=$(em-config CACHE)/sysroot/usr install; \ + --prefix=$(em-config CACHE)/sysroot/usr install && \ rm -r /usr/src/boost_1_75_0 diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz b/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz index 2fe04622b..d5481604a 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz @@ -22,7 +22,7 @@ # (c) 2016-2021 solidity contributors. #------------------------------------------------------------------------------ FROM gcr.io/oss-fuzz-base/base-clang:latest as base -LABEL version="18" +LABEL version="19" ARG DEBIAN_FRONTEND=noninteractive @@ -61,7 +61,7 @@ RUN set -ex; \ # Z3 RUN set -ex; \ - git clone --depth 1 -b z3-4.8.17 https://github.com/Z3Prover/z3.git \ + git clone --depth 1 -b z3-4.11.0 https://github.com/Z3Prover/z3.git \ /usr/src/z3; \ cd /usr/src/z3; \ mkdir build; \ diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 index 2f3304c1e..6cac5cc86 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 @@ -22,7 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:focal AS base -LABEL version="13" +LABEL version="14" ARG DEBIAN_FRONTEND=noninteractive diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang index 0a11680b8..dc5acbcdc 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang @@ -22,7 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:focal AS base -LABEL version="13" +LABEL version="14" ARG DEBIAN_FRONTEND=noninteractive @@ -38,7 +38,7 @@ RUN set -ex; \ libboost-filesystem-dev libboost-test-dev libboost-system-dev \ libboost-program-options-dev \ clang \ - libz3-static-dev jq \ + libz3-static-dev z3-static jq \ ; \ rm -rf /var/lib/apt/lists/* diff --git a/scripts/docker/buildpack-deps/README.md b/scripts/docker/buildpack-deps/README.md index 004a89e91..7f6352581 100644 --- a/scripts/docker/buildpack-deps/README.md +++ b/scripts/docker/buildpack-deps/README.md @@ -18,18 +18,22 @@ located in `develop`. ### Build, Test & Push Note that the whole workflow - including all defined strategies (image variants) - will be triggered, -even if only a single Dockerfile was change. The full workflow will only gets executed, if the corresponding +even if only a single Dockerfile was changed. The full workflow will only get executed, if the corresponding Dockerfile was changed. The execution of workflows of unchanged Dockerfiles will not continue and just return success. See `scripts/ci/docker_upgrade.sh`. If the version check was successful, the docker image will be built using the Dockerfile located in `scripts/docker/buildpack-deps/Dockerfile.*`. -The resulting docker image will be tested by executing -the corresponding `scripts/ci/buildpack-deps_test_*` scripts. These scripts are normally symlinked to `scripts/ci/build.sh`, -except for the `buildpack-deps-ubuntu1604.clang.ossfuzz` docker image, that is symlinked to `scripts/ci/build_ossfuzz.sh`. +The resulting docker image will be tested by executing the corresponding `scripts/ci/buildpack-deps_test_*` scripts. +Some of these scripts are symlinked to `scripts/ci/build.sh`, except the following two: + * `buildpack-deps-ubuntu1604.clang.ossfuzz` => `scripts/ci/build_ossfuzz.sh` + * `buildpack-deps_test_emscripten.sh` => `scripts/ci/build_emscripten.sh` + These scripts `scripts/ci/build.sh` and `scripts/ci/build_ossfuzz.sh` are also used by CircleCI, see `.circleci/config.yml`. If the tests passed successfully, the docker image will get tagged by the version defined within the corresponding `Dockerfile`. Finally, a comment will be added to the PR that contains the full repository, version and repository digest -of the freshly created docker image. \ No newline at end of file +of the freshly created docker image. + +The files `.circleci/config.yml` and `scripts/build_emscripten.sh` need to be updated with the new hash posted in the comment. diff --git a/scripts/externalTests/download_benchmarks.py b/scripts/externalTests/download_benchmarks.py new file mode 100755 index 000000000..29f5fe4bc --- /dev/null +++ b/scripts/externalTests/download_benchmarks.py @@ -0,0 +1,194 @@ +#!/usr/bin/env python3 + +from argparse import ArgumentParser, Namespace +from enum import Enum, unique +from pathlib import Path +from typing import Mapping, Optional +import sys + +import requests + +# Our scripts/ is not a proper Python package so we need to modify PYTHONPATH to import from it +# pragma pylint: disable=import-error,wrong-import-position +SCRIPTS_DIR = Path(__file__).parent.parent +sys.path.insert(0, str(SCRIPTS_DIR)) + +from common.git_helpers import git_current_branch, git_commit_hash +from common.rest_api_helpers import APIHelperError, JobNotSuccessful, CircleCI, Github, download_file +# pragma pylint: enable=import-error,wrong-import-position + + +@unique +class Status(Enum): + OK = 0 # Benchmarks downloaded successfully + ERROR = 1 # Error in the script, bad API response, unexpected data, etc. + NO_BENCHMARK = 2 # Benchmark collector job did not finish successfully and/or benchmark artifacts are missing. + PENDING = 3 # Benchmark collector job has not finished yet. + + +def process_commandline() -> Namespace: + script_description = ( + "Downloads benchmark results attached as artifacts to the c_ext_benchmarks job on CircleCI. " + "If no options are specified, downloads results for the currently checked out git branch." + ) + + parser = ArgumentParser(description=script_description) + + target_definition = parser.add_mutually_exclusive_group() + target_definition.add_argument( + '--branch', + dest='branch', + help="Git branch that the job ran on.", + ) + target_definition.add_argument( + '--pr', + dest='pull_request_id', + type=int, + help="Github PR ID that the job ran on.", + ) + target_definition.add_argument( + '--base-of-pr', + dest='base_of_pr', + type=int, + help="ID of a Github PR that's based on top of the branch we're interested in." + ) + + parser.add_argument( + '--any-commit', + dest='ignore_commit_hash', + default=False, + action='store_true', + help="Include pipelines that ran on a different commit as long as branch/PR matches." + ) + parser.add_argument( + '--overwrite', + dest='overwrite', + default=False, + action='store_true', + help="If artifacts already exist on disk, overwrite them.", + ) + parser.add_argument( + '--debug-requests', + dest='debug_requests', + default=False, + action='store_true', + help="Print detailed info about performed API requests and received responses.", + ) + + return parser.parse_args() + + +def download_benchmark_artifact( + artifacts: Mapping[str, dict], + benchmark_name: str, + branch: str, + commit_hash: str, + overwrite: bool, + silent: bool = False +) -> bool: + if not silent: + print(f"Downloading artifact: {benchmark_name}-{branch}-{commit_hash[:8]}.json.") + + artifact_path = f'reports/externalTests/{benchmark_name}.json' + + if artifact_path not in artifacts: + if not silent: + print(f"Missing artifact: {artifact_path}.") + return False + + download_file( + artifacts[artifact_path]['url'], + Path(f'{benchmark_name}-{branch}-{commit_hash[:8]}.json'), + overwrite, + ) + + return True + + +def download_benchmarks( + branch: Optional[str], + pull_request_id: Optional[int], + base_of_pr: Optional[int], + ignore_commit_hash: bool = False, + overwrite: bool = False, + debug_requests: bool = False, + silent: bool = False, +) -> Status: + github = Github('ethereum/solidity', debug_requests) + circleci = CircleCI('ethereum/solidity', debug_requests) + + expected_commit_hash = None + if branch is None and pull_request_id is None and base_of_pr is None: + branch = git_current_branch() + expected_commit_hash = git_commit_hash() + elif branch is not None: + expected_commit_hash = git_commit_hash(branch) + elif pull_request_id is not None: + pr_info = github.pull_request(pull_request_id) + branch = pr_info['head']['ref'] + expected_commit_hash = pr_info['head']['sha'] + elif base_of_pr is not None: + pr_info = github.pull_request(base_of_pr) + branch = pr_info['base']['ref'] + expected_commit_hash = pr_info['base']['sha'] + + if not silent: + print( + f"Looking for pipelines that ran on branch {branch}" + + (f", commit {expected_commit_hash}." if not ignore_commit_hash else " (any commit).") + ) + + pipeline = circleci.latest_item(circleci.pipelines( + branch, + expected_commit_hash if not ignore_commit_hash else None, + # Skip nightly workflows. They don't have the c_ext_benchmarks job and even if they did, + # they would likely be running a different set of external tests. + excluded_trigger_types=['schedule'], + )) + if pipeline is None: + raise RuntimeError("No matching pipelines found.") + + actual_commit_hash = pipeline['vcs']['revision'] + workflow_id = circleci.latest_item(circleci.workflows(pipeline['id']))['id'] + benchmark_collector_job = circleci.job(workflow_id, 'c_ext_benchmarks', require_success=True) + + artifacts = circleci.artifacts(int(benchmark_collector_job['job_number'])) + + got_summary = download_benchmark_artifact(artifacts, 'summarized-benchmarks', branch, actual_commit_hash, overwrite, silent) + got_full = download_benchmark_artifact(artifacts, 'all-benchmarks', branch, actual_commit_hash, overwrite, silent) + + return Status.OK if got_summary and got_full else Status.NO_BENCHMARK + + +def main(): + try: + options = process_commandline() + return download_benchmarks( + options.branch, + options.pull_request_id, + options.base_of_pr, + options.ignore_commit_hash, + options.overwrite, + options.debug_requests, + ).value + except JobNotSuccessful as exception: + print(f"[ERROR] {exception}", file=sys.stderr) + if not exception.job_finished: + print("Please wait for the workflow to finish and try again.", file=sys.stderr) + return Status.PENDING.value + else: + print("Benchmarks from this run of the pipeline are not available.", file=sys.stderr) + return Status.NO_BENCHMARK.value + except APIHelperError as exception: + print(f"[ERROR] {exception}", file=sys.stderr) + return Status.ERROR.value + except requests.exceptions.HTTPError as exception: + print(f"[ERROR] {exception}", file=sys.stderr) + return Status.ERROR.value + except RuntimeError as exception: + print(f"[ERROR] {exception}", file=sys.stderr) + return Status.ERROR.value + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/scripts/externalTests/update_external_repos.sh b/scripts/externalTests/update_external_repos.sh new file mode 100755 index 000000000..2270691ec --- /dev/null +++ b/scripts/externalTests/update_external_repos.sh @@ -0,0 +1,122 @@ +#!/usr/bin/env bash + +#------------------------------------------------------------------------------ +# Clones external test repositories from solidity-external-tests organization +# and for each of them pulls latest upstream changes from the main branch and +# pushes them to our fork. +# +# The script assumes that the current user has write access to +# solidity-external-tests and that git is configured to be able to push there +# without specifying the password (e.g. with the key already unlocked and loaded +# into ssh-agent). Otherwise git will keep asking for password for each repository. +# +# Usage: +# +# ./update_external_repos.sh [] +# +# : directory where the clones of the repositories are stored. +# If omitted, a temporary directory will be created. +# +# ------------------------------------------------------------------------------ +# This file is part of solidity. +# +# solidity is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# solidity is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with solidity. If not, see +# +# (c) 2022 solidity contributors. +#------------------------------------------------------------------------------ + +set -euo pipefail + +target_dir="${1:-$(mktemp -d -t update_external_repos_XXXXXX)}" + +function clone_repo +{ + local upstream_user="$1" + local upstream_repo="$2" + local fork_name="${3:-$upstream_repo}" + + if [[ ! -d $fork_name ]]; then + git clone "git@github.com:solidity-external-tests/${fork_name}.git" --no-checkout + else + echo "Reusing existing repo: ${fork_name}." + fi + + pushd "$fork_name" > /dev/null + git remote rm upstream 2> /dev/null || true + git remote add upstream "https://github.com/${upstream_user}/${upstream_repo}" + popd > /dev/null +} + +function sync_branch +{ + local fork_name="$1" + local branch="$2" + + echo "${fork_name}: syncing branch ${branch}..." + pushd "$fork_name" > /dev/null + git fetch upstream "$branch" --quiet + git checkout -B "$branch" --track "upstream/$branch" --quiet + git merge "upstream/${branch}" --ff-only --quiet + git push origin "$branch" + popd > /dev/null +} + +mkdir -p "$target_dir" + +echo "Entering ${target_dir}" +cd "$target_dir" + +clone_repo brinktrade brink-core +clone_repo dapphub dappsys-monolithic +clone_repo element-fi elf-contracts +clone_repo ensdomains ens +clone_repo ensdomains ens-contracts +clone_repo euler-xyz euler-contracts +clone_repo gnosis gp-v2-contracts +clone_repo gnosis mock-contract +clone_repo gnosis util-contracts +clone_repo JoinColony colonyNetwork +clone_repo mycelium-ethereum perpetual-pools-contracts +clone_repo OpenZeppelin openzeppelin-contracts +clone_repo paulrberg prb-math +clone_repo pooltogether v4-core pooltogether-v4-core +clone_repo safe-global safe-contracts +clone_repo smartcontractkit chainlink +clone_repo sushiswap trident +clone_repo Uniswap v2-core uniswap-v2-core +clone_repo Uniswap v3-core uniswap-v3-core +clone_repo wighawag bleeps +clone_repo yieldprotocol yield-liquidator-v2 + +sync_branch brink-core master +sync_branch dappsys-monolithic master +sync_branch elf-contracts main +sync_branch ens master +sync_branch ens-contracts master +sync_branch euler-contracts master +sync_branch gp-v2-contracts main +sync_branch mock-contract master +sync_branch util-contracts main +sync_branch colonyNetwork develop +sync_branch perpetual-pools-contracts develop +sync_branch openzeppelin-contracts master +sync_branch prb-math main +sync_branch pooltogether-v4-core master +sync_branch safe-contracts main +sync_branch chainlink develop +sync_branch trident master +sync_branch uniswap-v2-core master +sync_branch uniswap-v3-core main +sync_branch bleeps main +sync_branch yield-liquidator-v2 master diff --git a/scripts/gas_diff_stats.py b/scripts/gas_diff_stats.py old mode 100644 new mode 100755 index 5c7aa5338..56cd0cd43 --- a/scripts/gas_diff_stats.py +++ b/scripts/gas_diff_stats.py @@ -88,11 +88,11 @@ def collect_statistics(lines) -> (int, int, int, int, int, int): diff_kinds = [Diff.Minus, Diff.Plus] codegen_kinds = [Kind.IrOptimized, Kind.LegacyOptimized, Kind.Legacy] return tuple( - sum([ + sum( val for (diff_kind, codegen_kind, val) in out if diff_kind == _diff_kind and codegen_kind == _codegen_kind - ]) + ) for _diff_kind in diff_kinds for _codegen_kind in codegen_kinds ) diff --git a/scripts/pylintrc b/scripts/pylintrc index 02d529567..3a2b85293 100644 --- a/scripts/pylintrc +++ b/scripts/pylintrc @@ -17,7 +17,6 @@ # TODO: What could be eliminated in future PRs: invalid-name, pointless-string-statement, redefined-outer-name. disable= bad-indentation, - bad-whitespace, duplicate-code, invalid-name, missing-docstring, diff --git a/scripts/release_ppa.sh b/scripts/release_ppa.sh index fe1efda27..ac0a68988 100755 --- a/scripts/release_ppa.sh +++ b/scripts/release_ppa.sh @@ -9,13 +9,18 @@ ## If the given branch is "release", the resulting package will be uploaded to ## ethereum/ethereum PPA, or ethereum/ethereum-dev PPA otherwise. ## -## The gnupg key for "builds@ethereum.org" has to be present in order to sign -## the package. -## ## It will clone the Solidity git from github, determine the version, ## create a source archive and push it to the ubuntu ppa servers. ## -## This requires the following entries in /etc/dput.cf: +## To interact with launchpad, you need to set the variables $LAUNCHPAD_EMAIL +## and $LAUNCHPAD_KEYID in the file .release_ppa_auth in the root directory of +## the project to your launchpad email and pgp keyid. +## This could for example look like this: +## +## LAUNCHPAD_EMAIL=your-launchpad-email@ethereum.org +## LAUNCHPAD_KEYID=123ABCFFFFFFFF +## +## Additionally the following entries in /etc/dput.cf are required: ## ## [ethereum-dev] ## fqdn = ppa.launchpad.net @@ -34,11 +39,16 @@ ## method = ftp ## incoming = ~ethereum/ethereum-static ## login = anonymous - ## ############################################################################## -set -ev +set -e + + +REPO_ROOT="$(dirname "$0")/.." + +# shellcheck source=scripts/common.sh +source "${REPO_ROOT}/scripts/common.sh" if [ -z "$1" ] then @@ -48,20 +58,28 @@ else fi is_release() { - [[ "${branch}" = "release" ]] || [[ "${branch}" =~ ^v[0-9]+(\.[0-9])*$ ]] + [[ "${branch}" =~ ^v[0-9]+(\.[0-9]+)*$ ]] } -keyid=379F4801D622CDCF -email=builds@ethereum.org +sourcePPAConfig + packagename=solc -static_build_distribution=impish +# This needs to be a still active release +static_build_distribution=focal -DISTRIBUTIONS="focal impish jammy" +DISTRIBUTIONS="focal jammy kinetic" if is_release then DISTRIBUTIONS="$DISTRIBUTIONS STATIC" + + # Sanity checks + checkDputEntries "\[ethereum\]" + checkDputEntries "\[ethereum-static\]" +else + # Sanity check + checkDputEntries "\[ethereum-dev\]" fi for distribution in $DISTRIBUTIONS @@ -108,7 +126,7 @@ mv solidity solc # Fetch dependencies mkdir -p ./solc/deps/downloads/ 2>/dev/null || true wget -O ./solc/deps/downloads/jsoncpp-1.9.3.tar.gz https://github.com/open-source-parsers/jsoncpp/archive/1.9.3.tar.gz -wget -O ./solc/deps/downloads/range-v3-0.11.0.tar.gz https://github.com/ericniebler/range-v3/archive/0.11.0.tar.gz +wget -O ./solc/deps/downloads/range-v3-0.12.0.tar.gz https://github.com/ericniebler/range-v3/archive/0.12.0.tar.gz wget -O ./solc/deps/downloads/fmt-8.0.1.tar.gz https://github.com/fmtlib/fmt/archive/8.0.1.tar.gz # Determine version @@ -245,7 +263,7 @@ chmod +x debian/rules versionsuffix=0ubuntu1~${distribution} # bump version / add entry to changelog -EMAIL="$email" dch -v "1:${debversion}-${versionsuffix}" "git build of ${commithash}" +EMAIL="$LAUNCHPAD_EMAIL" dch -v "1:${debversion}-${versionsuffix}" "git build of ${commithash}" # build source package @@ -287,7 +305,7 @@ fi ) # sign the package -debsign --re-sign -k "${keyid}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" +debsign --re-sign -k "${LAUNCHPAD_KEYID}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" # upload dput "${pparepo}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" diff --git a/scripts/update_bugs_by_version.py b/scripts/update_bugs_by_version.py index d1577bfc1..442cd0fdc 100755 --- a/scripts/update_bugs_by_version.py +++ b/scripts/update_bugs_by_version.py @@ -6,20 +6,19 @@ # This makes it possible to use this script as part of CI to check # that the list is up to date. -import os import json import re -import sys +from pathlib import Path def comp(version_string): return [int(c) for c in version_string.split('.')] -path = os.path.dirname(os.path.realpath(__file__)) -with open(path + '/../docs/bugs.json', encoding='utf8') as bugsFile: - bugs = json.load(bugsFile) +root_path = Path(__file__).resolve().parent.parent + +bugs = json.loads((root_path / 'docs/bugs.json').read_text(encoding='utf8')) versions = {} -with open(path + '/../Changelog.md', encoding='utf8') as changelog: +with (root_path / 'Changelog.md').open(encoding='utf8') as changelog: for line in changelog: m = re.search(r'^### (\S+) \((\d+-\d+-\d+)\)$', line) if m: @@ -35,9 +34,9 @@ for key, value in versions.items(): continue value['bugs'] += [bug['name']] -new_contents = json.dumps(versions, sort_keys=True, indent=4, separators=(',', ': ')) -with open(path + '/../docs/bugs_by_version.json', 'r', encoding='utf8') as bugs_by_version: - old_contents = bugs_by_version.read() -with open(path + '/../docs/bugs_by_version.json', 'w', encoding='utf8') as bugs_by_version: - bugs_by_version.write(new_contents) -sys.exit(old_contents != new_contents) +(root_path / 'docs/bugs_by_version.json').write_text(json.dumps( + versions, + sort_keys=True, + indent=4, + separators=(',', ': ') +), encoding='utf8') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 273e47a43..a0fef0950 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -29,7 +29,7 @@ #include "solidity/BuildInfo.h" #include -#include +#include #include #include #include @@ -863,7 +863,7 @@ void CommandLineInterface::handleCombinedJSON() output[g_strSources] = Json::Value(Json::objectValue); for (auto const& sourceCode: m_fileReader.sourceUnits()) { - ASTJsonConverter converter(m_compiler->state(), m_compiler->sourceIndices()); + ASTJsonExporter converter(m_compiler->state(), m_compiler->sourceIndices()); output[g_strSources][sourceCode.first] = Json::Value(Json::objectValue); output[g_strSources][sourceCode.first]["AST"] = converter.toJson(m_compiler->ast(sourceCode.first)); } @@ -893,7 +893,7 @@ void CommandLineInterface::handleAst() { stringstream data; string postfix = ""; - ASTJsonConverter(m_compiler->state(), m_compiler->sourceIndices()).print(data, m_compiler->ast(sourceCode.first), m_options.formatting.json); + ASTJsonExporter(m_compiler->state(), m_compiler->sourceIndices()).print(data, m_compiler->ast(sourceCode.first), m_options.formatting.json); postfix += "_json"; boost::filesystem::path path(sourceCode.first); createFile(path.filename().string() + postfix + ".ast", data.str()); @@ -905,7 +905,7 @@ void CommandLineInterface::handleAst() for (auto const& sourceCode: m_fileReader.sourceUnits()) { sout() << endl << "======= " << sourceCode.first << " =======" << endl; - ASTJsonConverter(m_compiler->state(), m_compiler->sourceIndices()).print(sout(), m_compiler->ast(sourceCode.first), m_options.formatting.json); + ASTJsonExporter(m_compiler->state(), m_compiler->sourceIndices()).print(sout(), m_compiler->ast(sourceCode.first), m_options.formatting.json); } } } diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index 1cab3358e..a6698f1b9 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -542,7 +542,7 @@ General Information)").c_str(), ( (g_strOutputDir + ",o").c_str(), po::value()->value_name("path"), - "If given, creates one file per component and contract/file at the specified directory." + "If given, creates one file per output component and contract/file at the specified directory." ) ( g_strOverwrite.c_str(), @@ -695,7 +695,7 @@ General Information)").c_str(), (CompilerOutputs::componentName(&CompilerOutputs::signatureHashes).c_str(), "Function signature hashes of the contracts.") (CompilerOutputs::componentName(&CompilerOutputs::natspecUser).c_str(), "Natspec user documentation of all contracts.") (CompilerOutputs::componentName(&CompilerOutputs::natspecDev).c_str(), "Natspec developer documentation of all contracts.") - (CompilerOutputs::componentName(&CompilerOutputs::metadata).c_str(), "Combined Metadata JSON whose Swarm hash is stored on-chain.") + (CompilerOutputs::componentName(&CompilerOutputs::metadata).c_str(), "Combined Metadata JSON whose IPFS hash is stored on-chain.") (CompilerOutputs::componentName(&CompilerOutputs::storageLayout).c_str(), "Slots, offsets and types of the contract's state variables.") ; desc.add(outputComponents); @@ -888,12 +888,26 @@ void CommandLineParser::processArgs() // TODO: This should eventually contain all options. {g_strErrorRecovery, {InputMode::Compiler, InputMode::CompilerWithASTImport}}, {g_strExperimentalViaIR, {InputMode::Compiler, InputMode::CompilerWithASTImport}}, - {g_strViaIR, {InputMode::Compiler, InputMode::CompilerWithASTImport}} + {g_strViaIR, {InputMode::Compiler, InputMode::CompilerWithASTImport}}, + {g_strMetadataLiteral, {InputMode::Compiler, InputMode::CompilerWithASTImport}}, + {g_strMetadataHash, {InputMode::Compiler, InputMode::CompilerWithASTImport}}, + {g_strModelCheckerShowUnproved, {InputMode::Compiler, InputMode::CompilerWithASTImport}}, + {g_strModelCheckerDivModNoSlacks, {InputMode::Compiler, InputMode::CompilerWithASTImport}}, + {g_strModelCheckerEngine, {InputMode::Compiler, InputMode::CompilerWithASTImport}}, + {g_strModelCheckerInvariants, {InputMode::Compiler, InputMode::CompilerWithASTImport}}, + {g_strModelCheckerSolvers, {InputMode::Compiler, InputMode::CompilerWithASTImport}}, + {g_strModelCheckerTimeout, {InputMode::Compiler, InputMode::CompilerWithASTImport}}, + {g_strModelCheckerContracts, {InputMode::Compiler, InputMode::CompilerWithASTImport}}, + {g_strModelCheckerTargets, {InputMode::Compiler, InputMode::CompilerWithASTImport}} }; vector invalidOptionsForCurrentInputMode; for (auto const& [optionName, inputModes]: validOptionInputModeCombinations) { - if (m_args.count(optionName) > 0 && inputModes.count(m_options.input.mode) == 0) + if ( + m_args.count(optionName) > 0 && + inputModes.count(m_options.input.mode) == 0 && + !m_args[optionName].defaulted() + ) invalidOptionsForCurrentInputMode.push_back(optionName); } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 255218c15..cc7a61bae 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,5 @@ set(sources - boostTest.cpp + soltest.cpp Common.cpp Common.h CommonSyntaxTest.cpp diff --git a/test/Common.cpp b/test/Common.cpp index 8cdf0fed1..7cd869934 100644 --- a/test/Common.cpp +++ b/test/Common.cpp @@ -20,15 +20,20 @@ #include #include #include +#include #include +#include #include #include #include +#include namespace fs = boost::filesystem; namespace po = boost::program_options; +using namespace std; + namespace solidity::test { @@ -107,7 +112,6 @@ void CommonOptions::addOptions() ("no-semantic-tests", po::bool_switch(&disableSemanticTests)->default_value(disableSemanticTests), "disable semantic tests") ("no-smt", po::bool_switch(&disableSMT)->default_value(disableSMT), "disable SMT checker") ("optimize", po::bool_switch(&optimize)->default_value(optimize), "enables optimization") - ("enforce-via-yul", po::value(&enforceViaYul)->default_value(enforceViaYul)->implicit_value(true), "Enforce compiling all tests via yul to see if additional tests can be activated.") ("enforce-compile-to-ewasm", po::bool_switch(&enforceCompileToEwasm)->default_value(enforceCompileToEwasm), "Enforce compiling all tests to Ewasm to see if additional tests can be activated.") ("enforce-gas-cost", po::value(&enforceGasTest)->default_value(enforceGasTest)->implicit_value(true), "Enforce checking gas cost in semantic tests.") ("enforce-gas-cost-min-value", po::value(&enforceGasTestMinValue)->default_value(enforceGasTestMinValue), "Threshold value to enforce adding gas checks to a test.") @@ -208,6 +212,41 @@ bool CommonOptions::parse(int argc, char const* const* argv) return true; } +string CommonOptions::toString(vector const& _selectedOptions) const +{ + if (_selectedOptions.empty()) + return ""; + + auto boolToString = [](bool _value) -> string { return _value ? "true" : "false"; }; + // Using std::map to avoid if-else/switch-case block + map optionValueMap = { + {"evmVersion", evmVersion().name()}, + {"optimize", boolToString(optimize)}, + {"useABIEncoderV1", boolToString(useABIEncoderV1)}, + {"batch", to_string(selectedBatch + 1) + "/" + to_string(batches)}, + {"ewasm", boolToString(ewasm)}, + {"enforceCompileToEwasm", boolToString(enforceCompileToEwasm)}, + {"enforceGasTest", boolToString(enforceGasTest)}, + {"enforceGasTestMinValue", enforceGasTestMinValue.str()}, + {"disableSemanticTests", boolToString(disableSemanticTests)}, + {"disableSMT", boolToString(disableSMT)}, + {"showMessages", boolToString(showMessages)}, + {"showMetadata", boolToString(showMetadata)} + }; + + soltestAssert(ranges::all_of(_selectedOptions, [&optionValueMap](string const& _option) { return optionValueMap.count(_option) > 0; })); + + vector optionsWithValues = _selectedOptions | + ranges::views::transform([&optionValueMap](string const& _option) { return _option + "=" + optionValueMap.at(_option); }) | + ranges::to(); + + return solidity::util::joinHumanReadable(optionsWithValues); +} + +void CommonOptions::printSelectedOptions(ostream& _stream, string const& _linePrefix, vector const& _selectedOptions) const +{ + _stream << _linePrefix << "Run Settings: " << toString(_selectedOptions) << endl; +} langutil::EVMVersion CommonOptions::evmVersion() const { diff --git a/test/Common.h b/test/Common.h index 28862348f..bd76cd0df 100644 --- a/test/Common.h +++ b/test/Common.h @@ -60,7 +60,6 @@ struct CommonOptions boost::filesystem::path testPath; bool ewasm = false; bool optimize = false; - bool enforceViaYul = false; bool enforceCompileToEwasm = false; bool enforceGasTest = false; u256 enforceGasTestMinValue = 100000; @@ -82,6 +81,12 @@ struct CommonOptions // Throws a ConfigException on error virtual void validate() const; + /// @returns string with a key=value list of the options separated by comma + /// Ex.: "evmVersion=london, optimize=true, useABIEncoderV1=false" + virtual std::string toString(std::vector const& _selectedOptions) const; + /// Helper to print the value of settings used + virtual void printSelectedOptions(std::ostream& _stream, std::string const& _linePrefix, std::vector const& _selectedOptions) const; + static CommonOptions const& get(); static void setSingleton(std::unique_ptr&& _instance); diff --git a/test/CommonSyntaxTest.cpp b/test/CommonSyntaxTest.cpp index 5b66aea30..f794439de 100644 --- a/test/CommonSyntaxTest.cpp +++ b/test/CommonSyntaxTest.cpp @@ -245,10 +245,10 @@ vector CommonSyntaxTest::parseExpectations(istream& _stream) string errorMessage(it, line.end()); expectations.emplace_back(SyntaxTestError{ - move(errorType), - move(errorId), - move(errorMessage), - move(sourceName), + std::move(errorType), + std::move(errorId), + std::move(errorMessage), + std::move(sourceName), locationStart, locationEnd }); diff --git a/test/EVMHost.cpp b/test/EVMHost.cpp index 6c5cb6912..118a517fb 100644 --- a/test/EVMHost.cpp +++ b/test/EVMHost.cpp @@ -50,7 +50,7 @@ evmc::VM& EVMHost::getVM(string const& _path) if (vm && errorCode == EVMC_LOADER_SUCCESS) { if (vm.get_capabilities() & (EVMC_CAPABILITY_EVM1 | EVMC_CAPABILITY_EWASM)) - vms[_path] = make_unique(evmc::VM(move(vm))); + vms[_path] = make_unique(evmc::VM(std::move(vm))); else cerr << "VM loaded neither supports EVM1 nor EWASM" << endl; } diff --git a/test/FilesystemUtils.cpp b/test/FilesystemUtils.cpp index 0d1de3af9..7506d677e 100644 --- a/test/FilesystemUtils.cpp +++ b/test/FilesystemUtils.cpp @@ -20,6 +20,8 @@ #include +#include + using namespace std; using namespace solidity; using namespace solidity::test; diff --git a/test/Metadata.cpp b/test/Metadata.cpp index 3b27e3101..88a1f7b42 100644 --- a/test/Metadata.cpp +++ b/test/Metadata.cpp @@ -136,7 +136,7 @@ private: } bytes readBytes(unsigned length) { - bytes ret{m_metadata.begin() + m_pos, m_metadata.begin() + m_pos + length}; + bytes ret{m_metadata.begin() + static_cast(m_pos), m_metadata.begin() + static_cast(m_pos + length)}; m_pos += length; return ret; } @@ -162,7 +162,7 @@ std::optional> parseCBORMetadata(bytes const& _metadata) { string key = parser.readKey(); string value = parser.readValue(); - ret[move(key)] = move(value); + ret[std::move(key)] = std::move(value); } return ret; } diff --git a/test/TestCase.h b/test/TestCase.h index d63c88b48..181fb0120 100644 --- a/test/TestCase.h +++ b/test/TestCase.h @@ -40,7 +40,6 @@ public: std::string filename; langutil::EVMVersion evmVersion; std::vector vmPaths; - bool enforceCompileViaYul = false; bool enforceCompileToEwasm = false; bool enforceGasCost = false; u256 enforceGasCostMinValue; diff --git a/test/TestCaseReader.cpp b/test/TestCaseReader.cpp index d9015b55f..43e4a6fc3 100644 --- a/test/TestCaseReader.cpp +++ b/test/TestCaseReader.cpp @@ -194,7 +194,7 @@ pair TestCaseReader::parseSourcesAndSettingsWithLineNumber(is } // Register the last source as the main one sources[currentSourceName] = currentSource; - return {{move(sources), move(externalSources), move(currentSourceName)}, lineNumber}; + return {{std::move(sources), std::move(externalSources), std::move(currentSourceName)}, lineNumber}; } string TestCaseReader::parseSimpleExpectations(istream& _file) diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index 86900b56e..b50b3128e 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -311,7 +311,7 @@ function test_solc_assembly_output function test_via_ir_equivalence() { SOLTMPDIR=$(mktemp -d) - pushd "$SOLTMPDIR" + pushd "$SOLTMPDIR" > /dev/null (( $# <= 2 )) || fail "This function accepts at most two arguments." @@ -355,7 +355,7 @@ function test_via_ir_equivalence() for yul_file in $(find . -name "${output_file_prefix}*.yul" | sort -V); do bin_output_two_stage+=$( - msg_on_error --no-stderr "$SOLC" --strict-assembly --bin "${optimizer_flags[@]}" "$yul_file" | + msg_on_error --no-stderr "$SOLC" --strict-assembly --bin "${optimizer_flags[@]}" "$yul_file" | sed '/^Binary representation:$/d' | sed '/^=======/d' ) @@ -369,14 +369,19 @@ function test_via_ir_equivalence() diff_values "$bin_output_two_stage" "$bin_output_via_ir" --ignore-space-change --ignore-blank-lines - popd + popd > /dev/null rm -r "$SOLTMPDIR" } ## RUN -echo "Checking that the bug list is up to date..." -"$REPO_ROOT"/scripts/update_bugs_by_version.py +SOLTMPDIR=$(mktemp -d) +printTask "Checking that the bug list is up to date..." +cp "${REPO_ROOT}/docs/bugs_by_version.json" "${SOLTMPDIR}/original_bugs_by_version.json" +"${REPO_ROOT}/scripts/update_bugs_by_version.py" +diff --unified "${SOLTMPDIR}/original_bugs_by_version.json" "${REPO_ROOT}/docs/bugs_by_version.json" || \ + fail "The bug list in bugs_by_version.json was out of date and has been updated. Please investigate and submit a bugfix if necessary." +rm -r "$SOLTMPDIR" printTask "Testing unknown options..." ( @@ -517,15 +522,16 @@ SOLTMPDIR=$(mktemp -d) opts=() # We expect errors if explicitly stated, or if imports # are used (in the style guide) - if grep -E "This will not compile|import \"" "$f" >/dev/null + if grep -E "// This will not compile" "$f" >/dev/null || + sed -e 's|//.*||g' "$f" | grep -E "import \"" >/dev/null then opts=(--expect-errors) fi - if grep "This will report a warning" "$f" >/dev/null + if grep "// This will report a warning" "$f" >/dev/null then opts+=(--expect-warnings) fi - if grep "This may report a warning" "$f" >/dev/null + if grep "// This may report a warning" "$f" >/dev/null then opts+=(--ignore-warnings) fi diff --git a/test/cmdlineTests/asm_json/output b/test/cmdlineTests/asm_json/output index 000ad1b75..f6a0a4b19 100644 --- a/test/cmdlineTests/asm_json/output +++ b/test/cmdlineTests/asm_json/output @@ -1300,14 +1300,14 @@ EVM assembly: }, { "begin": 1211, - "end": 1516, + "end": 1402, "name": "tag", "source": 1, "value": "10" }, { "begin": 1211, - "end": 1516, + "end": 1402, "name": "JUMPDEST", "source": 1 }, @@ -1423,159 +1423,146 @@ EVM assembly: "source": 1 }, { - "begin": 1458, - "end": 1459, + "begin": 1347, + "end": 1348, "name": "DUP3", "source": 1 }, { - "begin": 1390, - "end": 1456, - "name": "PUSH", - "source": 1, - "value": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - }, - { - "begin": 1386, - "end": 1460, - "name": "SUB", - "source": 1 - }, - { - "begin": 1383, - "end": 1384, + "begin": 1344, + "end": 1345, "name": "DUP3", "source": 1 }, { - "begin": 1380, - "end": 1461, + "begin": 1340, + "end": 1349, + "name": "ADD", + "source": 1 + }, + { + "begin": 1333, + "end": 1349, + "name": "SWAP1", + "source": 1 + }, + { + "begin": 1333, + "end": 1349, + "name": "POP", + "source": 1 + }, + { + "begin": 1368, + "end": 1371, + "name": "DUP1", + "source": 1 + }, + { + "begin": 1365, + "end": 1366, + "name": "DUP3", + "source": 1 + }, + { + "begin": 1362, + "end": 1372, "name": "GT", "source": 1 }, { - "begin": 1377, - "end": 1484, + "begin": 1359, + "end": 1395, "name": "ISZERO", "source": 1 }, { - "begin": 1377, - "end": 1484, + "begin": 1359, + "end": 1395, "name": "PUSH [tag]", "source": 1, "value": "37" }, { - "begin": 1377, - "end": 1484, + "begin": 1359, + "end": 1395, "name": "JUMPI", "source": 1 }, { - "begin": 1464, - "end": 1482, + "begin": 1375, + "end": 1393, "name": "PUSH [tag]", "source": 1, "value": "38" }, { - "begin": 1464, - "end": 1482, + "begin": 1375, + "end": 1393, "name": "PUSH [tag]", "source": 1, "value": "18" }, { - "begin": 1464, - "end": 1482, + "begin": 1375, + "end": 1393, "jumpType": "[in]", "name": "JUMP", "source": 1 }, { - "begin": 1464, - "end": 1482, + "begin": 1375, + "end": 1393, "name": "tag", "source": 1, "value": "38" }, { - "begin": 1464, - "end": 1482, + "begin": 1375, + "end": 1393, "name": "JUMPDEST", "source": 1 }, { - "begin": 1377, - "end": 1484, + "begin": 1359, + "end": 1395, "name": "tag", "source": 1, "value": "37" }, { - "begin": 1377, - "end": 1484, + "begin": 1359, + "end": 1395, "name": "JUMPDEST", "source": 1 }, - { - "begin": 1508, - "end": 1509, - "name": "DUP3", - "source": 1 - }, - { - "begin": 1505, - "end": 1506, - "name": "DUP3", - "source": 1 - }, - { - "begin": 1501, - "end": 1510, - "name": "ADD", - "source": 1 - }, - { - "begin": 1494, - "end": 1510, - "name": "SWAP1", - "source": 1 - }, - { - "begin": 1494, - "end": 1510, - "name": "POP", - "source": 1 - }, { "begin": 1211, - "end": 1516, + "end": 1402, "name": "SWAP3", "source": 1 }, { "begin": 1211, - "end": 1516, + "end": 1402, "name": "SWAP2", "source": 1 }, { "begin": 1211, - "end": 1516, + "end": 1402, "name": "POP", "source": 1 }, { "begin": 1211, - "end": 1516, + "end": 1402, "name": "POP", "source": 1 }, { "begin": 1211, - "end": 1516, + "end": 1402, "jumpType": "[out]", "name": "JUMP", "source": 1 diff --git a/test/cmdlineTests/asm_json_no_pretty_print/output b/test/cmdlineTests/asm_json_no_pretty_print/output index 232d0bdea..b713097bb 100644 --- a/test/cmdlineTests/asm_json_no_pretty_print/output +++ b/test/cmdlineTests/asm_json_no_pretty_print/output @@ -1,4 +1,4 @@ ======= asm_json_no_pretty_print/input.sol:C ======= EVM assembly: -{".code":[{"begin":60,"end":160,"name":"PUSH","source":0,"value":"80"},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"40"},{"begin":60,"end":160,"name":"MSTORE","source":0},{"begin":60,"end":160,"name":"CALLVALUE","source":0},{"begin":60,"end":160,"name":"DUP1","source":0},{"begin":60,"end":160,"name":"ISZERO","source":0},{"begin":60,"end":160,"name":"PUSH [tag]","source":0,"value":"1"},{"begin":60,"end":160,"name":"JUMPI","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"0"},{"begin":60,"end":160,"name":"DUP1","source":0},{"begin":60,"end":160,"name":"REVERT","source":0},{"begin":60,"end":160,"name":"tag","source":0,"value":"1"},{"begin":60,"end":160,"name":"JUMPDEST","source":0},{"begin":60,"end":160,"name":"POP","source":0},{"begin":60,"end":160,"name":"PUSH #[$]","source":0,"value":"0000000000000000000000000000000000000000000000000000000000000000"},{"begin":60,"end":160,"name":"DUP1","source":0},{"begin":60,"end":160,"name":"PUSH [$]","source":0,"value":"0000000000000000000000000000000000000000000000000000000000000000"},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"0"},{"begin":60,"end":160,"name":"CODECOPY","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"0"},{"begin":60,"end":160,"name":"RETURN","source":0}],".data":{"0":{".auxdata":"",".code":[{"begin":60,"end":160,"name":"PUSH","source":0,"value":"80"},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"40"},{"begin":60,"end":160,"name":"MSTORE","source":0},{"begin":60,"end":160,"name":"CALLVALUE","source":0},{"begin":60,"end":160,"name":"DUP1","source":0},{"begin":60,"end":160,"name":"ISZERO","source":0},{"begin":60,"end":160,"name":"PUSH [tag]","source":0,"value":"1"},{"begin":60,"end":160,"name":"JUMPI","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"0"},{"begin":60,"end":160,"name":"DUP1","source":0},{"begin":60,"end":160,"name":"REVERT","source":0},{"begin":60,"end":160,"name":"tag","source":0,"value":"1"},{"begin":60,"end":160,"name":"JUMPDEST","source":0},{"begin":60,"end":160,"name":"POP","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"4"},{"begin":60,"end":160,"name":"CALLDATASIZE","source":0},{"begin":60,"end":160,"name":"LT","source":0},{"begin":60,"end":160,"name":"PUSH [tag]","source":0,"value":"2"},{"begin":60,"end":160,"name":"JUMPI","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"0"},{"begin":60,"end":160,"name":"CALLDATALOAD","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"E0"},{"begin":60,"end":160,"name":"SHR","source":0},{"begin":60,"end":160,"name":"DUP1","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"B3DE648B"},{"begin":60,"end":160,"name":"EQ","source":0},{"begin":60,"end":160,"name":"PUSH [tag]","source":0,"value":"3"},{"begin":60,"end":160,"name":"JUMPI","source":0},{"begin":60,"end":160,"name":"tag","source":0,"value":"2"},{"begin":60,"end":160,"name":"JUMPDEST","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"0"},{"begin":60,"end":160,"name":"DUP1","source":0},{"begin":60,"end":160,"name":"REVERT","source":0},{"begin":77,"end":158,"name":"tag","source":0,"value":"3"},{"begin":77,"end":158,"name":"JUMPDEST","source":0},{"begin":77,"end":158,"name":"PUSH [tag]","source":0,"value":"4"},{"begin":77,"end":158,"name":"PUSH","source":0,"value":"4"},{"begin":77,"end":158,"name":"DUP1","source":0},{"begin":77,"end":158,"name":"CALLDATASIZE","source":0},{"begin":77,"end":158,"name":"SUB","source":0},{"begin":77,"end":158,"name":"DUP2","source":0},{"begin":77,"end":158,"name":"ADD","source":0},{"begin":77,"end":158,"name":"SWAP1","source":0},{"begin":77,"end":158,"name":"PUSH [tag]","source":0,"value":"5"},{"begin":77,"end":158,"name":"SWAP2","source":0},{"begin":77,"end":158,"name":"SWAP1","source":0},{"begin":77,"end":158,"name":"PUSH [tag]","source":0,"value":"6"},{"begin":77,"end":158,"jumpType":"[in]","name":"JUMP","source":0},{"begin":77,"end":158,"name":"tag","source":0,"value":"5"},{"begin":77,"end":158,"name":"JUMPDEST","source":0},{"begin":77,"end":158,"name":"PUSH [tag]","source":0,"value":"7"},{"begin":77,"end":158,"jumpType":"[in]","name":"JUMP","source":0},{"begin":77,"end":158,"name":"tag","source":0,"value":"4"},{"begin":77,"end":158,"name":"JUMPDEST","source":0},{"begin":77,"end":158,"name":"STOP","source":0},{"begin":77,"end":158,"name":"tag","source":0,"value":"7"},{"begin":77,"end":158,"name":"JUMPDEST","source":0},{"begin":123,"end":125,"name":"PUSH","source":0,"value":"2A"},{"begin":118,"end":125,"name":"DUP2","source":0},{"begin":118,"end":125,"name":"PUSH [tag]","source":0,"value":"9"},{"begin":118,"end":125,"name":"SWAP2","source":0},{"begin":118,"end":125,"name":"SWAP1","source":0},{"begin":118,"end":125,"name":"PUSH [tag]","source":0,"value":"10"},{"begin":118,"end":125,"jumpType":"[in]","name":"JUMP","source":0},{"begin":118,"end":125,"name":"tag","source":0,"value":"9"},{"begin":118,"end":125,"name":"JUMPDEST","source":0},{"begin":118,"end":125,"name":"SWAP1","source":0},{"begin":118,"end":125,"name":"POP","source":0},{"begin":147,"end":150,"name":"PUSH","source":0,"value":"64"},{"begin":143,"end":144,"name":"DUP2","source":0},{"begin":143,"end":150,"name":"GT","source":0},{"begin":135,"end":151,"name":"PUSH [tag]","source":0,"value":"11"},{"begin":135,"end":151,"name":"JUMPI","source":0},{"begin":135,"end":151,"name":"PUSH","source":0,"value":"0"},{"begin":135,"end":151,"name":"DUP1","source":0},{"begin":135,"end":151,"name":"REVERT","source":0},{"begin":135,"end":151,"name":"tag","source":0,"value":"11"},{"begin":135,"end":151,"name":"JUMPDEST","source":0},{"begin":77,"end":158,"name":"POP","source":0},{"begin":77,"end":158,"jumpType":"[out]","name":"JUMP","source":0},{"begin":88,"end":205,"name":"tag","source":1,"value":"13"},{"begin":88,"end":205,"name":"JUMPDEST","source":1},{"begin":197,"end":198,"name":"PUSH","source":1,"value":"0"},{"begin":194,"end":195,"name":"DUP1","source":1},{"begin":187,"end":199,"name":"REVERT","source":1},{"begin":334,"end":411,"name":"tag","source":1,"value":"15"},{"begin":334,"end":411,"name":"JUMPDEST","source":1},{"begin":371,"end":378,"name":"PUSH","source":1,"value":"0"},{"begin":400,"end":405,"name":"DUP2","source":1},{"begin":389,"end":405,"name":"SWAP1","source":1},{"begin":389,"end":405,"name":"POP","source":1},{"begin":334,"end":411,"name":"SWAP2","source":1},{"begin":334,"end":411,"name":"SWAP1","source":1},{"begin":334,"end":411,"name":"POP","source":1},{"begin":334,"end":411,"jumpType":"[out]","name":"JUMP","source":1},{"begin":417,"end":539,"name":"tag","source":1,"value":"16"},{"begin":417,"end":539,"name":"JUMPDEST","source":1},{"begin":490,"end":514,"name":"PUSH [tag]","source":1,"value":"25"},{"begin":508,"end":513,"name":"DUP2","source":1},{"begin":490,"end":514,"name":"PUSH [tag]","source":1,"value":"15"},{"begin":490,"end":514,"jumpType":"[in]","name":"JUMP","source":1},{"begin":490,"end":514,"name":"tag","source":1,"value":"25"},{"begin":490,"end":514,"name":"JUMPDEST","source":1},{"begin":483,"end":488,"name":"DUP2","source":1},{"begin":480,"end":515,"name":"EQ","source":1},{"begin":470,"end":533,"name":"PUSH [tag]","source":1,"value":"26"},{"begin":470,"end":533,"name":"JUMPI","source":1},{"begin":529,"end":530,"name":"PUSH","source":1,"value":"0"},{"begin":526,"end":527,"name":"DUP1","source":1},{"begin":519,"end":531,"name":"REVERT","source":1},{"begin":470,"end":533,"name":"tag","source":1,"value":"26"},{"begin":470,"end":533,"name":"JUMPDEST","source":1},{"begin":417,"end":539,"name":"POP","source":1},{"begin":417,"end":539,"jumpType":"[out]","name":"JUMP","source":1},{"begin":545,"end":684,"name":"tag","source":1,"value":"17"},{"begin":545,"end":684,"name":"JUMPDEST","source":1},{"begin":591,"end":596,"name":"PUSH","source":1,"value":"0"},{"begin":629,"end":635,"name":"DUP2","source":1},{"begin":616,"end":636,"name":"CALLDATALOAD","source":1},{"begin":607,"end":636,"name":"SWAP1","source":1},{"begin":607,"end":636,"name":"POP","source":1},{"begin":645,"end":678,"name":"PUSH [tag]","source":1,"value":"28"},{"begin":672,"end":677,"name":"DUP2","source":1},{"begin":645,"end":678,"name":"PUSH [tag]","source":1,"value":"16"},{"begin":645,"end":678,"jumpType":"[in]","name":"JUMP","source":1},{"begin":645,"end":678,"name":"tag","source":1,"value":"28"},{"begin":645,"end":678,"name":"JUMPDEST","source":1},{"begin":545,"end":684,"name":"SWAP3","source":1},{"begin":545,"end":684,"name":"SWAP2","source":1},{"begin":545,"end":684,"name":"POP","source":1},{"begin":545,"end":684,"name":"POP","source":1},{"begin":545,"end":684,"jumpType":"[out]","name":"JUMP","source":1},{"begin":690,"end":1019,"name":"tag","source":1,"value":"6"},{"begin":690,"end":1019,"name":"JUMPDEST","source":1},{"begin":749,"end":755,"name":"PUSH","source":1,"value":"0"},{"begin":798,"end":800,"name":"PUSH","source":1,"value":"20"},{"begin":786,"end":795,"name":"DUP3","source":1},{"begin":777,"end":784,"name":"DUP5","source":1},{"begin":773,"end":796,"name":"SUB","source":1},{"begin":769,"end":801,"name":"SLT","source":1},{"begin":766,"end":885,"name":"ISZERO","source":1},{"begin":766,"end":885,"name":"PUSH [tag]","source":1,"value":"30"},{"begin":766,"end":885,"name":"JUMPI","source":1},{"begin":804,"end":883,"name":"PUSH [tag]","source":1,"value":"31"},{"begin":804,"end":883,"name":"PUSH [tag]","source":1,"value":"13"},{"begin":804,"end":883,"jumpType":"[in]","name":"JUMP","source":1},{"begin":804,"end":883,"name":"tag","source":1,"value":"31"},{"begin":804,"end":883,"name":"JUMPDEST","source":1},{"begin":766,"end":885,"name":"tag","source":1,"value":"30"},{"begin":766,"end":885,"name":"JUMPDEST","source":1},{"begin":924,"end":925,"name":"PUSH","source":1,"value":"0"},{"begin":949,"end":1002,"name":"PUSH [tag]","source":1,"value":"32"},{"begin":994,"end":1001,"name":"DUP5","source":1},{"begin":985,"end":991,"name":"DUP3","source":1},{"begin":974,"end":983,"name":"DUP6","source":1},{"begin":970,"end":992,"name":"ADD","source":1},{"begin":949,"end":1002,"name":"PUSH [tag]","source":1,"value":"17"},{"begin":949,"end":1002,"jumpType":"[in]","name":"JUMP","source":1},{"begin":949,"end":1002,"name":"tag","source":1,"value":"32"},{"begin":949,"end":1002,"name":"JUMPDEST","source":1},{"begin":939,"end":1002,"name":"SWAP2","source":1},{"begin":939,"end":1002,"name":"POP","source":1},{"begin":895,"end":1012,"name":"POP","source":1},{"begin":690,"end":1019,"name":"SWAP3","source":1},{"begin":690,"end":1019,"name":"SWAP2","source":1},{"begin":690,"end":1019,"name":"POP","source":1},{"begin":690,"end":1019,"name":"POP","source":1},{"begin":690,"end":1019,"jumpType":"[out]","name":"JUMP","source":1},{"begin":1025,"end":1205,"name":"tag","source":1,"value":"18"},{"begin":1025,"end":1205,"name":"JUMPDEST","source":1},{"begin":1073,"end":1150,"name":"PUSH","source":1,"value":"4E487B7100000000000000000000000000000000000000000000000000000000"},{"begin":1070,"end":1071,"name":"PUSH","source":1,"value":"0"},{"begin":1063,"end":1151,"name":"MSTORE","source":1},{"begin":1170,"end":1174,"name":"PUSH","source":1,"value":"11"},{"begin":1167,"end":1168,"name":"PUSH","source":1,"value":"4"},{"begin":1160,"end":1175,"name":"MSTORE","source":1},{"begin":1194,"end":1198,"name":"PUSH","source":1,"value":"24"},{"begin":1191,"end":1192,"name":"PUSH","source":1,"value":"0"},{"begin":1184,"end":1199,"name":"REVERT","source":1},{"begin":1211,"end":1516,"name":"tag","source":1,"value":"10"},{"begin":1211,"end":1516,"name":"JUMPDEST","source":1},{"begin":1251,"end":1254,"name":"PUSH","source":1,"value":"0"},{"begin":1270,"end":1290,"name":"PUSH [tag]","source":1,"value":"35"},{"begin":1288,"end":1289,"name":"DUP3","source":1},{"begin":1270,"end":1290,"name":"PUSH [tag]","source":1,"value":"15"},{"begin":1270,"end":1290,"jumpType":"[in]","name":"JUMP","source":1},{"begin":1270,"end":1290,"name":"tag","source":1,"value":"35"},{"begin":1270,"end":1290,"name":"JUMPDEST","source":1},{"begin":1265,"end":1290,"name":"SWAP2","source":1},{"begin":1265,"end":1290,"name":"POP","source":1},{"begin":1304,"end":1324,"name":"PUSH [tag]","source":1,"value":"36"},{"begin":1322,"end":1323,"name":"DUP4","source":1},{"begin":1304,"end":1324,"name":"PUSH [tag]","source":1,"value":"15"},{"begin":1304,"end":1324,"jumpType":"[in]","name":"JUMP","source":1},{"begin":1304,"end":1324,"name":"tag","source":1,"value":"36"},{"begin":1304,"end":1324,"name":"JUMPDEST","source":1},{"begin":1299,"end":1324,"name":"SWAP3","source":1},{"begin":1299,"end":1324,"name":"POP","source":1},{"begin":1458,"end":1459,"name":"DUP3","source":1},{"begin":1390,"end":1456,"name":"PUSH","source":1,"value":"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"},{"begin":1386,"end":1460,"name":"SUB","source":1},{"begin":1383,"end":1384,"name":"DUP3","source":1},{"begin":1380,"end":1461,"name":"GT","source":1},{"begin":1377,"end":1484,"name":"ISZERO","source":1},{"begin":1377,"end":1484,"name":"PUSH [tag]","source":1,"value":"37"},{"begin":1377,"end":1484,"name":"JUMPI","source":1},{"begin":1464,"end":1482,"name":"PUSH [tag]","source":1,"value":"38"},{"begin":1464,"end":1482,"name":"PUSH [tag]","source":1,"value":"18"},{"begin":1464,"end":1482,"jumpType":"[in]","name":"JUMP","source":1},{"begin":1464,"end":1482,"name":"tag","source":1,"value":"38"},{"begin":1464,"end":1482,"name":"JUMPDEST","source":1},{"begin":1377,"end":1484,"name":"tag","source":1,"value":"37"},{"begin":1377,"end":1484,"name":"JUMPDEST","source":1},{"begin":1508,"end":1509,"name":"DUP3","source":1},{"begin":1505,"end":1506,"name":"DUP3","source":1},{"begin":1501,"end":1510,"name":"ADD","source":1},{"begin":1494,"end":1510,"name":"SWAP1","source":1},{"begin":1494,"end":1510,"name":"POP","source":1},{"begin":1211,"end":1516,"name":"SWAP3","source":1},{"begin":1211,"end":1516,"name":"SWAP2","source":1},{"begin":1211,"end":1516,"name":"POP","source":1},{"begin":1211,"end":1516,"name":"POP","source":1},{"begin":1211,"end":1516,"jumpType":"[out]","name":"JUMP","source":1}]}},"sourceList":["asm_json_no_pretty_print/input.sol","#utility.yul"]} +{".code":[{"begin":60,"end":160,"name":"PUSH","source":0,"value":"80"},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"40"},{"begin":60,"end":160,"name":"MSTORE","source":0},{"begin":60,"end":160,"name":"CALLVALUE","source":0},{"begin":60,"end":160,"name":"DUP1","source":0},{"begin":60,"end":160,"name":"ISZERO","source":0},{"begin":60,"end":160,"name":"PUSH [tag]","source":0,"value":"1"},{"begin":60,"end":160,"name":"JUMPI","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"0"},{"begin":60,"end":160,"name":"DUP1","source":0},{"begin":60,"end":160,"name":"REVERT","source":0},{"begin":60,"end":160,"name":"tag","source":0,"value":"1"},{"begin":60,"end":160,"name":"JUMPDEST","source":0},{"begin":60,"end":160,"name":"POP","source":0},{"begin":60,"end":160,"name":"PUSH #[$]","source":0,"value":"0000000000000000000000000000000000000000000000000000000000000000"},{"begin":60,"end":160,"name":"DUP1","source":0},{"begin":60,"end":160,"name":"PUSH [$]","source":0,"value":"0000000000000000000000000000000000000000000000000000000000000000"},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"0"},{"begin":60,"end":160,"name":"CODECOPY","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"0"},{"begin":60,"end":160,"name":"RETURN","source":0}],".data":{"0":{".auxdata":"",".code":[{"begin":60,"end":160,"name":"PUSH","source":0,"value":"80"},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"40"},{"begin":60,"end":160,"name":"MSTORE","source":0},{"begin":60,"end":160,"name":"CALLVALUE","source":0},{"begin":60,"end":160,"name":"DUP1","source":0},{"begin":60,"end":160,"name":"ISZERO","source":0},{"begin":60,"end":160,"name":"PUSH [tag]","source":0,"value":"1"},{"begin":60,"end":160,"name":"JUMPI","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"0"},{"begin":60,"end":160,"name":"DUP1","source":0},{"begin":60,"end":160,"name":"REVERT","source":0},{"begin":60,"end":160,"name":"tag","source":0,"value":"1"},{"begin":60,"end":160,"name":"JUMPDEST","source":0},{"begin":60,"end":160,"name":"POP","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"4"},{"begin":60,"end":160,"name":"CALLDATASIZE","source":0},{"begin":60,"end":160,"name":"LT","source":0},{"begin":60,"end":160,"name":"PUSH [tag]","source":0,"value":"2"},{"begin":60,"end":160,"name":"JUMPI","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"0"},{"begin":60,"end":160,"name":"CALLDATALOAD","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"E0"},{"begin":60,"end":160,"name":"SHR","source":0},{"begin":60,"end":160,"name":"DUP1","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"B3DE648B"},{"begin":60,"end":160,"name":"EQ","source":0},{"begin":60,"end":160,"name":"PUSH [tag]","source":0,"value":"3"},{"begin":60,"end":160,"name":"JUMPI","source":0},{"begin":60,"end":160,"name":"tag","source":0,"value":"2"},{"begin":60,"end":160,"name":"JUMPDEST","source":0},{"begin":60,"end":160,"name":"PUSH","source":0,"value":"0"},{"begin":60,"end":160,"name":"DUP1","source":0},{"begin":60,"end":160,"name":"REVERT","source":0},{"begin":77,"end":158,"name":"tag","source":0,"value":"3"},{"begin":77,"end":158,"name":"JUMPDEST","source":0},{"begin":77,"end":158,"name":"PUSH [tag]","source":0,"value":"4"},{"begin":77,"end":158,"name":"PUSH","source":0,"value":"4"},{"begin":77,"end":158,"name":"DUP1","source":0},{"begin":77,"end":158,"name":"CALLDATASIZE","source":0},{"begin":77,"end":158,"name":"SUB","source":0},{"begin":77,"end":158,"name":"DUP2","source":0},{"begin":77,"end":158,"name":"ADD","source":0},{"begin":77,"end":158,"name":"SWAP1","source":0},{"begin":77,"end":158,"name":"PUSH [tag]","source":0,"value":"5"},{"begin":77,"end":158,"name":"SWAP2","source":0},{"begin":77,"end":158,"name":"SWAP1","source":0},{"begin":77,"end":158,"name":"PUSH [tag]","source":0,"value":"6"},{"begin":77,"end":158,"jumpType":"[in]","name":"JUMP","source":0},{"begin":77,"end":158,"name":"tag","source":0,"value":"5"},{"begin":77,"end":158,"name":"JUMPDEST","source":0},{"begin":77,"end":158,"name":"PUSH [tag]","source":0,"value":"7"},{"begin":77,"end":158,"jumpType":"[in]","name":"JUMP","source":0},{"begin":77,"end":158,"name":"tag","source":0,"value":"4"},{"begin":77,"end":158,"name":"JUMPDEST","source":0},{"begin":77,"end":158,"name":"STOP","source":0},{"begin":77,"end":158,"name":"tag","source":0,"value":"7"},{"begin":77,"end":158,"name":"JUMPDEST","source":0},{"begin":123,"end":125,"name":"PUSH","source":0,"value":"2A"},{"begin":118,"end":125,"name":"DUP2","source":0},{"begin":118,"end":125,"name":"PUSH [tag]","source":0,"value":"9"},{"begin":118,"end":125,"name":"SWAP2","source":0},{"begin":118,"end":125,"name":"SWAP1","source":0},{"begin":118,"end":125,"name":"PUSH [tag]","source":0,"value":"10"},{"begin":118,"end":125,"jumpType":"[in]","name":"JUMP","source":0},{"begin":118,"end":125,"name":"tag","source":0,"value":"9"},{"begin":118,"end":125,"name":"JUMPDEST","source":0},{"begin":118,"end":125,"name":"SWAP1","source":0},{"begin":118,"end":125,"name":"POP","source":0},{"begin":147,"end":150,"name":"PUSH","source":0,"value":"64"},{"begin":143,"end":144,"name":"DUP2","source":0},{"begin":143,"end":150,"name":"GT","source":0},{"begin":135,"end":151,"name":"PUSH [tag]","source":0,"value":"11"},{"begin":135,"end":151,"name":"JUMPI","source":0},{"begin":135,"end":151,"name":"PUSH","source":0,"value":"0"},{"begin":135,"end":151,"name":"DUP1","source":0},{"begin":135,"end":151,"name":"REVERT","source":0},{"begin":135,"end":151,"name":"tag","source":0,"value":"11"},{"begin":135,"end":151,"name":"JUMPDEST","source":0},{"begin":77,"end":158,"name":"POP","source":0},{"begin":77,"end":158,"jumpType":"[out]","name":"JUMP","source":0},{"begin":88,"end":205,"name":"tag","source":1,"value":"13"},{"begin":88,"end":205,"name":"JUMPDEST","source":1},{"begin":197,"end":198,"name":"PUSH","source":1,"value":"0"},{"begin":194,"end":195,"name":"DUP1","source":1},{"begin":187,"end":199,"name":"REVERT","source":1},{"begin":334,"end":411,"name":"tag","source":1,"value":"15"},{"begin":334,"end":411,"name":"JUMPDEST","source":1},{"begin":371,"end":378,"name":"PUSH","source":1,"value":"0"},{"begin":400,"end":405,"name":"DUP2","source":1},{"begin":389,"end":405,"name":"SWAP1","source":1},{"begin":389,"end":405,"name":"POP","source":1},{"begin":334,"end":411,"name":"SWAP2","source":1},{"begin":334,"end":411,"name":"SWAP1","source":1},{"begin":334,"end":411,"name":"POP","source":1},{"begin":334,"end":411,"jumpType":"[out]","name":"JUMP","source":1},{"begin":417,"end":539,"name":"tag","source":1,"value":"16"},{"begin":417,"end":539,"name":"JUMPDEST","source":1},{"begin":490,"end":514,"name":"PUSH [tag]","source":1,"value":"25"},{"begin":508,"end":513,"name":"DUP2","source":1},{"begin":490,"end":514,"name":"PUSH [tag]","source":1,"value":"15"},{"begin":490,"end":514,"jumpType":"[in]","name":"JUMP","source":1},{"begin":490,"end":514,"name":"tag","source":1,"value":"25"},{"begin":490,"end":514,"name":"JUMPDEST","source":1},{"begin":483,"end":488,"name":"DUP2","source":1},{"begin":480,"end":515,"name":"EQ","source":1},{"begin":470,"end":533,"name":"PUSH [tag]","source":1,"value":"26"},{"begin":470,"end":533,"name":"JUMPI","source":1},{"begin":529,"end":530,"name":"PUSH","source":1,"value":"0"},{"begin":526,"end":527,"name":"DUP1","source":1},{"begin":519,"end":531,"name":"REVERT","source":1},{"begin":470,"end":533,"name":"tag","source":1,"value":"26"},{"begin":470,"end":533,"name":"JUMPDEST","source":1},{"begin":417,"end":539,"name":"POP","source":1},{"begin":417,"end":539,"jumpType":"[out]","name":"JUMP","source":1},{"begin":545,"end":684,"name":"tag","source":1,"value":"17"},{"begin":545,"end":684,"name":"JUMPDEST","source":1},{"begin":591,"end":596,"name":"PUSH","source":1,"value":"0"},{"begin":629,"end":635,"name":"DUP2","source":1},{"begin":616,"end":636,"name":"CALLDATALOAD","source":1},{"begin":607,"end":636,"name":"SWAP1","source":1},{"begin":607,"end":636,"name":"POP","source":1},{"begin":645,"end":678,"name":"PUSH [tag]","source":1,"value":"28"},{"begin":672,"end":677,"name":"DUP2","source":1},{"begin":645,"end":678,"name":"PUSH [tag]","source":1,"value":"16"},{"begin":645,"end":678,"jumpType":"[in]","name":"JUMP","source":1},{"begin":645,"end":678,"name":"tag","source":1,"value":"28"},{"begin":645,"end":678,"name":"JUMPDEST","source":1},{"begin":545,"end":684,"name":"SWAP3","source":1},{"begin":545,"end":684,"name":"SWAP2","source":1},{"begin":545,"end":684,"name":"POP","source":1},{"begin":545,"end":684,"name":"POP","source":1},{"begin":545,"end":684,"jumpType":"[out]","name":"JUMP","source":1},{"begin":690,"end":1019,"name":"tag","source":1,"value":"6"},{"begin":690,"end":1019,"name":"JUMPDEST","source":1},{"begin":749,"end":755,"name":"PUSH","source":1,"value":"0"},{"begin":798,"end":800,"name":"PUSH","source":1,"value":"20"},{"begin":786,"end":795,"name":"DUP3","source":1},{"begin":777,"end":784,"name":"DUP5","source":1},{"begin":773,"end":796,"name":"SUB","source":1},{"begin":769,"end":801,"name":"SLT","source":1},{"begin":766,"end":885,"name":"ISZERO","source":1},{"begin":766,"end":885,"name":"PUSH [tag]","source":1,"value":"30"},{"begin":766,"end":885,"name":"JUMPI","source":1},{"begin":804,"end":883,"name":"PUSH [tag]","source":1,"value":"31"},{"begin":804,"end":883,"name":"PUSH [tag]","source":1,"value":"13"},{"begin":804,"end":883,"jumpType":"[in]","name":"JUMP","source":1},{"begin":804,"end":883,"name":"tag","source":1,"value":"31"},{"begin":804,"end":883,"name":"JUMPDEST","source":1},{"begin":766,"end":885,"name":"tag","source":1,"value":"30"},{"begin":766,"end":885,"name":"JUMPDEST","source":1},{"begin":924,"end":925,"name":"PUSH","source":1,"value":"0"},{"begin":949,"end":1002,"name":"PUSH [tag]","source":1,"value":"32"},{"begin":994,"end":1001,"name":"DUP5","source":1},{"begin":985,"end":991,"name":"DUP3","source":1},{"begin":974,"end":983,"name":"DUP6","source":1},{"begin":970,"end":992,"name":"ADD","source":1},{"begin":949,"end":1002,"name":"PUSH [tag]","source":1,"value":"17"},{"begin":949,"end":1002,"jumpType":"[in]","name":"JUMP","source":1},{"begin":949,"end":1002,"name":"tag","source":1,"value":"32"},{"begin":949,"end":1002,"name":"JUMPDEST","source":1},{"begin":939,"end":1002,"name":"SWAP2","source":1},{"begin":939,"end":1002,"name":"POP","source":1},{"begin":895,"end":1012,"name":"POP","source":1},{"begin":690,"end":1019,"name":"SWAP3","source":1},{"begin":690,"end":1019,"name":"SWAP2","source":1},{"begin":690,"end":1019,"name":"POP","source":1},{"begin":690,"end":1019,"name":"POP","source":1},{"begin":690,"end":1019,"jumpType":"[out]","name":"JUMP","source":1},{"begin":1025,"end":1205,"name":"tag","source":1,"value":"18"},{"begin":1025,"end":1205,"name":"JUMPDEST","source":1},{"begin":1073,"end":1150,"name":"PUSH","source":1,"value":"4E487B7100000000000000000000000000000000000000000000000000000000"},{"begin":1070,"end":1071,"name":"PUSH","source":1,"value":"0"},{"begin":1063,"end":1151,"name":"MSTORE","source":1},{"begin":1170,"end":1174,"name":"PUSH","source":1,"value":"11"},{"begin":1167,"end":1168,"name":"PUSH","source":1,"value":"4"},{"begin":1160,"end":1175,"name":"MSTORE","source":1},{"begin":1194,"end":1198,"name":"PUSH","source":1,"value":"24"},{"begin":1191,"end":1192,"name":"PUSH","source":1,"value":"0"},{"begin":1184,"end":1199,"name":"REVERT","source":1},{"begin":1211,"end":1402,"name":"tag","source":1,"value":"10"},{"begin":1211,"end":1402,"name":"JUMPDEST","source":1},{"begin":1251,"end":1254,"name":"PUSH","source":1,"value":"0"},{"begin":1270,"end":1290,"name":"PUSH [tag]","source":1,"value":"35"},{"begin":1288,"end":1289,"name":"DUP3","source":1},{"begin":1270,"end":1290,"name":"PUSH [tag]","source":1,"value":"15"},{"begin":1270,"end":1290,"jumpType":"[in]","name":"JUMP","source":1},{"begin":1270,"end":1290,"name":"tag","source":1,"value":"35"},{"begin":1270,"end":1290,"name":"JUMPDEST","source":1},{"begin":1265,"end":1290,"name":"SWAP2","source":1},{"begin":1265,"end":1290,"name":"POP","source":1},{"begin":1304,"end":1324,"name":"PUSH [tag]","source":1,"value":"36"},{"begin":1322,"end":1323,"name":"DUP4","source":1},{"begin":1304,"end":1324,"name":"PUSH [tag]","source":1,"value":"15"},{"begin":1304,"end":1324,"jumpType":"[in]","name":"JUMP","source":1},{"begin":1304,"end":1324,"name":"tag","source":1,"value":"36"},{"begin":1304,"end":1324,"name":"JUMPDEST","source":1},{"begin":1299,"end":1324,"name":"SWAP3","source":1},{"begin":1299,"end":1324,"name":"POP","source":1},{"begin":1347,"end":1348,"name":"DUP3","source":1},{"begin":1344,"end":1345,"name":"DUP3","source":1},{"begin":1340,"end":1349,"name":"ADD","source":1},{"begin":1333,"end":1349,"name":"SWAP1","source":1},{"begin":1333,"end":1349,"name":"POP","source":1},{"begin":1368,"end":1371,"name":"DUP1","source":1},{"begin":1365,"end":1366,"name":"DUP3","source":1},{"begin":1362,"end":1372,"name":"GT","source":1},{"begin":1359,"end":1395,"name":"ISZERO","source":1},{"begin":1359,"end":1395,"name":"PUSH [tag]","source":1,"value":"37"},{"begin":1359,"end":1395,"name":"JUMPI","source":1},{"begin":1375,"end":1393,"name":"PUSH [tag]","source":1,"value":"38"},{"begin":1375,"end":1393,"name":"PUSH [tag]","source":1,"value":"18"},{"begin":1375,"end":1393,"jumpType":"[in]","name":"JUMP","source":1},{"begin":1375,"end":1393,"name":"tag","source":1,"value":"38"},{"begin":1375,"end":1393,"name":"JUMPDEST","source":1},{"begin":1359,"end":1395,"name":"tag","source":1,"value":"37"},{"begin":1359,"end":1395,"name":"JUMPDEST","source":1},{"begin":1211,"end":1402,"name":"SWAP3","source":1},{"begin":1211,"end":1402,"name":"SWAP2","source":1},{"begin":1211,"end":1402,"name":"POP","source":1},{"begin":1211,"end":1402,"name":"POP","source":1},{"begin":1211,"end":1402,"jumpType":"[out]","name":"JUMP","source":1}]}},"sourceList":["asm_json_no_pretty_print/input.sol","#utility.yul"]} diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/output b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/output index af83c9f36..115bf34cc 100644 --- a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/output +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/output @@ -194,7 +194,7 @@ object "C_6" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(memoryguard(0x80), _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/output b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/output index dc4ea45fd..33faf3cf1 100644 --- a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/output +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/output @@ -193,7 +193,7 @@ object "C_6" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(memoryguard(0x80), _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/output b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/output index b2ad57c30..330715023 100644 --- a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/output +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/output @@ -182,7 +182,7 @@ object "C_6" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(memoryguard(0x80), _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/debug_info_in_yul_snippet_escaping/output b/test/cmdlineTests/debug_info_in_yul_snippet_escaping/output index 04a354e2e..9fb9a2dbc 100644 --- a/test/cmdlineTests/debug_info_in_yul_snippet_escaping/output +++ b/test/cmdlineTests/debug_info_in_yul_snippet_escaping/output @@ -179,17 +179,13 @@ object "D_27" { updated_pos := add(pos, 0x20) } - function copy_memory_to_memory(src, dst, length) { + function copy_memory_to_memory_with_cleanup(src, dst, length) { let i := 0 for { } lt(i, length) { i := add(i, 32) } { mstore(add(dst, i), mload(add(src, i))) } - if gt(i, length) - { - // clear end - mstore(add(dst, length), 0) - } + mstore(add(dst, length), 0) } function round_up_to_mul_of_32(value) -> result { @@ -199,7 +195,7 @@ object "D_27" { function abi_encode_t_string_memory_ptr_to_t_string_memory_ptr_fromStack(value, pos) -> end { let length := array_length_t_string_memory_ptr(value) pos := array_storeLengthForEncoding_t_string_memory_ptr_fromStack(pos, length) - copy_memory_to_memory(add(value, 0x20), pos, length) + copy_memory_to_memory_with_cleanup(add(value, 0x20), pos, length) end := add(pos, round_up_to_mul_of_32(length)) } @@ -434,77 +430,74 @@ object "D_27" { { /// @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." let _1 := memoryguard(0x80) - mstore(64, _1) + let _2 := 64 + mstore(_2, _1) if iszero(lt(calldatasize(), 4)) { - let _2 := 0 - if eq(0x26121ff0, shr(224, calldataload(_2))) + let _3 := 0 + if eq(0x26121ff0, shr(224, calldataload(_3))) { - if callvalue() { revert(_2, _2) } - if slt(add(calldatasize(), not(3)), _2) { revert(_2, _2) } + if callvalue() { revert(_3, _3) } + if slt(add(calldatasize(), not(3)), _3) { revert(_3, _3) } /// @src 0:446:491 "new /// @src 0:149:156 \"new C()\"..." - let _3 := datasize("C_2") - let _4 := add(_1, _3) - if or(gt(_4, 0xffffffffffffffff), lt(_4, _1)) { panic_error_0x41() } - datacopy(_1, dataoffset("C_2"), _3) - if iszero(create(/** @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." */ _2, /** @src 0:446:491 "new /// @src 0:149:156 \"new C()\"..." */ _1, sub(_4, _1))) + let _4 := datasize("C_2") + let _5 := add(_1, _4) + let _6 := 0xffffffffffffffff + if or(gt(_5, _6), lt(_5, _1)) { /// @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." - let pos := mload(64) - returndatacopy(pos, _2, returndatasize()) + mstore(_3, shl(224, 0x4e487b71)) + mstore(4, 0x41) + revert(_3, 0x24) + } + /// @src 0:446:491 "new /// @src 0:149:156 \"new C()\"..." + datacopy(_1, dataoffset("C_2"), _4) + if iszero(create(/** @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." */ _3, /** @src 0:446:491 "new /// @src 0:149:156 \"new C()\"..." */ _1, sub(_5, _1))) + { + /// @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." + let pos := mload(_2) + returndatacopy(pos, _3, returndatasize()) revert(pos, returndatasize()) } - mstore(add(allocate_memory_array_string(), 32), "/*") - let memPtr := allocate_memory_array_string_546() - mstore(add(memPtr, 32), 0x2f2a2a204073726320303a39363a313635202022636f6e74726163742044207b) - mstore(add(memPtr, 64), shl(200, 0x2e2e2e22202a2f)) - let memPos := mload(64) - return(memPos, sub(abi_encode_string(memPos, memPtr), memPos)) + let memPtr := mload(_2) + let newFreePtr := add(memPtr, _2) + if or(gt(newFreePtr, /** @src 0:446:491 "new /// @src 0:149:156 \"new C()\"..." */ _6), /** @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." */ lt(newFreePtr, memPtr)) + { + mstore(_3, shl(224, 0x4e487b71)) + mstore(4, 0x41) + revert(_3, 0x24) + } + mstore(_2, newFreePtr) + mstore(memPtr, 2) + let _7 := 32 + mstore(add(memPtr, _7), "/*") + let memPtr_1 := mload(_2) + let newFreePtr_1 := add(memPtr_1, 96) + if or(gt(newFreePtr_1, /** @src 0:446:491 "new /// @src 0:149:156 \"new C()\"..." */ _6), /** @src 0:279:599 "contract D /** @src 0:96:165 \"contract D {...\" *\/ {..." */ lt(newFreePtr_1, memPtr_1)) + { + mstore(_3, shl(224, 0x4e487b71)) + mstore(4, 0x41) + revert(_3, 0x24) + } + mstore(_2, newFreePtr_1) + mstore(memPtr_1, 39) + mstore(add(memPtr_1, _7), 0x2f2a2a204073726320303a39363a313635202022636f6e74726163742044207b) + mstore(add(memPtr_1, _2), shl(200, 0x2e2e2e22202a2f)) + let memPos := mload(_2) + mstore(memPos, _7) + let length := mload(memPtr_1) + mstore(add(memPos, _7), length) + let i := _3 + for { } lt(i, length) { i := add(i, _7) } + { + mstore(add(add(memPos, i), _2), mload(add(add(memPtr_1, i), _7))) + } + mstore(add(add(memPos, length), _2), _3) + return(memPos, add(sub(add(memPos, and(add(length, 31), not(31))), memPos), _2)) } } revert(0, 0) } - function abi_encode_string(headStart, value0) -> tail - { - let _1 := 32 - mstore(headStart, _1) - let length := mload(value0) - mstore(add(headStart, _1), length) - let i := 0 - for { } lt(i, length) { i := add(i, _1) } - { - mstore(add(add(headStart, i), 64), mload(add(add(value0, i), _1))) - } - if gt(i, length) - { - mstore(add(add(headStart, length), 64), 0) - } - tail := add(add(headStart, and(add(length, 31), not(31))), 64) - } - function panic_error_0x41() - { - mstore(0, shl(224, 0x4e487b71)) - mstore(4, 0x41) - revert(0, 0x24) - } - function allocate_memory_array_string() -> memPtr - { - let memPtr_1 := mload(64) - let newFreePtr := add(memPtr_1, 64) - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr_1)) { panic_error_0x41() } - mstore(64, newFreePtr) - memPtr := memPtr_1 - mstore(memPtr_1, 2) - } - function allocate_memory_array_string_546() -> memPtr - { - let memPtr_1 := mload(64) - let newFreePtr := add(memPtr_1, 96) - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr_1)) { panic_error_0x41() } - mstore(64, newFreePtr) - memPtr := memPtr_1 - mstore(memPtr_1, 39) - } } /// @use-src 0:"debug_info_in_yul_snippet_escaping/input.sol" object "C_2" { diff --git a/test/cmdlineTests/function_debug_info_via_yul/output b/test/cmdlineTests/function_debug_info_via_yul/output index 97125e4b9..5af245ce4 100644 --- a/test/cmdlineTests/function_debug_info_via_yul/output +++ b/test/cmdlineTests/function_debug_info_via_yul/output @@ -4,20 +4,7 @@ "function_debug_info_via_yul/input.sol:C": { "function-debug": {}, - "function-debug-runtime": - { - "abi_encode_uint256": - { - "parameterSlots": 2, - "returnSlots": 1 - }, - "calldata_array_index_access_uint256_dyn_calldata": - { - "entryPoint": 144, - "parameterSlots": 2, - "returnSlots": 1 - } - } + "function-debug-runtime": {} } }, "version": "" diff --git a/test/cmdlineTests/ir_compiler_subobjects/output b/test/cmdlineTests/ir_compiler_subobjects/output index 5cacb6c16..0a505a4ac 100644 --- a/test/cmdlineTests/ir_compiler_subobjects/output +++ b/test/cmdlineTests/ir_compiler_subobjects/output @@ -71,7 +71,7 @@ object "D_16" { returndatacopy(pos, _2, returndatasize()) revert(pos, returndatasize()) } - return(mload(64), _2) + return(_2, _2) } } revert(0, 0) diff --git a/test/cmdlineTests/ir_with_assembly_no_memoryguard_creation/output b/test/cmdlineTests/ir_with_assembly_no_memoryguard_creation/output index 41f353269..50915c8dc 100644 --- a/test/cmdlineTests/ir_with_assembly_no_memoryguard_creation/output +++ b/test/cmdlineTests/ir_with_assembly_no_memoryguard_creation/output @@ -22,7 +22,7 @@ object "D_12" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(memoryguard(0x80), _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output b/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output index c406d4f7e..b81febf73 100644 --- a/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output +++ b/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output @@ -24,7 +24,7 @@ object "D_8" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(128, _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/name_simplifier/output b/test/cmdlineTests/name_simplifier/output index 219d76769..170e58ffb 100644 --- a/test/cmdlineTests/name_simplifier/output +++ b/test/cmdlineTests/name_simplifier/output @@ -17,112 +17,109 @@ object "C_59" { code { { /// @src 0:346:625 "contract C {..." - mstore(64, memoryguard(0x80)) - if iszero(lt(calldatasize(), 4)) + let _1 := memoryguard(0x80) + let _2 := 4 + if iszero(lt(calldatasize(), _2)) { - let _1 := 0 - if eq(0xf8eddcc6, shr(224, calldataload(_1))) + let _3 := 0 + if eq(0xf8eddcc6, shr(224, calldataload(_3))) { - if callvalue() { revert(_1, _1) } - let _2 := 32 - if slt(add(calldatasize(), not(3)), _2) { revert(_1, _1) } - let offset := calldataload(4) - let _3 := 0xffffffffffffffff - if gt(offset, _3) { revert(_1, _1) } - if iszero(slt(add(offset, 35), calldatasize())) { revert(_1, _1) } - let _4 := calldataload(add(4, offset)) - if gt(_4, _3) { panic_error_0x41() } - let _5 := shl(5, _4) - let dst := allocate_memory(add(_5, _2)) - let dst_1 := dst - mstore(dst, _4) - dst := add(dst, _2) - let srcEnd := add(add(offset, _5), 36) - if gt(srcEnd, calldatasize()) { revert(_1, _1) } - let src := add(offset, 36) - for { } lt(src, srcEnd) { src := add(src, _2) } + if callvalue() { revert(_3, _3) } + let _4 := 32 + if slt(add(calldatasize(), not(3)), _4) { revert(_3, _3) } + let offset := calldataload(_2) + let _5 := 0xffffffffffffffff + if gt(offset, _5) { revert(_3, _3) } + if iszero(slt(add(offset, 35), calldatasize())) { revert(_3, _3) } + let _6 := calldataload(add(_2, offset)) + let _7 := 36 + if gt(_6, _5) { - if slt(sub(calldatasize(), src), _2) { revert(_1, _1) } - let value := allocate_memory_1307() - mstore(value, calldataload(src)) - mstore(dst, value) - dst := add(dst, _2) + mstore(_3, shl(224, 0x4e487b71)) + mstore(_2, 0x41) + revert(_3, _7) } - let ret, ret_1 := fun_sumArray(dst_1) - let memPos := mload(64) - return(memPos, sub(abi_encode_uint256_string(memPos, ret, ret_1), memPos)) + let _8 := shl(5, _6) + let _9 := not(31) + let newFreePtr := add(_1, and(add(_8, 63), _9)) + if or(gt(newFreePtr, _5), lt(newFreePtr, _1)) + { + mstore(_3, shl(224, 0x4e487b71)) + mstore(_2, 0x41) + revert(_3, _7) + } + let _10 := 64 + mstore(_10, newFreePtr) + let dst := _1 + mstore(_1, _6) + dst := add(_1, _4) + let dst_1 := dst + let srcEnd := add(add(offset, _8), _7) + if gt(srcEnd, calldatasize()) { revert(_3, _3) } + let src := add(offset, _7) + for { } lt(src, srcEnd) { src := add(src, _4) } + { + if slt(sub(calldatasize(), src), _4) { revert(_3, _3) } + let memPtr := mload(_10) + let newFreePtr_1 := add(memPtr, _4) + if or(gt(newFreePtr_1, _5), lt(newFreePtr_1, memPtr)) + { + mstore(_3, shl(224, 0x4e487b71)) + mstore(_2, 0x41) + revert(_3, _7) + } + mstore(_10, newFreePtr_1) + mstore(memPtr, calldataload(src)) + mstore(dst, memPtr) + dst := add(dst, _4) + } + if iszero(mload(_1)) + { + mstore(_3, shl(224, 0x4e487b71)) + mstore(_2, 0x32) + revert(_3, _7) + } + sstore(_3, mload(/** @src 0:469:474 "_s[0]" */ mload(dst_1))) + /// @src 0:346:625 "contract C {..." + if iszero(lt(/** @src 0:492:493 "1" */ 0x01, /** @src 0:346:625 "contract C {..." */ mload(_1))) + { + mstore(_3, shl(224, 0x4e487b71)) + mstore(_2, 0x32) + revert(_3, _7) + } + let _11 := mload(/** @src 0:489:494 "_s[1]" */ mload(/** @src 0:346:625 "contract C {..." */ add(_1, _10))) + sstore(0x02, _11) + let memPtr_1 := mload(_10) + let newFreePtr_2 := add(memPtr_1, 160) + if or(gt(newFreePtr_2, _5), lt(newFreePtr_2, memPtr_1)) + { + mstore(_3, shl(224, 0x4e487b71)) + mstore(_2, 0x41) + revert(_3, _7) + } + mstore(_10, newFreePtr_2) + mstore(memPtr_1, 100) + mstore(add(memPtr_1, _4), "longstringlongstringlongstringlo") + mstore(add(memPtr_1, _10), "ngstringlongstringlongstringlong") + let _12 := 96 + mstore(add(memPtr_1, _12), "stringlongstringlongstringlongst") + mstore(add(memPtr_1, 128), "ring") + let memPos := mload(_10) + mstore(memPos, _11) + mstore(add(memPos, _4), _10) + let length := mload(memPtr_1) + mstore(add(memPos, _10), length) + let i := _3 + for { } lt(i, length) { i := add(i, _4) } + { + mstore(add(add(memPos, i), _12), mload(add(add(memPtr_1, i), _4))) + } + mstore(add(add(memPos, length), _12), _3) + return(memPos, add(sub(add(memPos, and(add(length, 31), _9)), memPos), _12)) } } revert(0, 0) } - function panic_error_0x41() - { - mstore(0, shl(224, 0x4e487b71)) - mstore(4, 0x41) - revert(0, 0x24) - } - function allocate_memory_1307() -> memPtr - { - memPtr := mload(64) - let newFreePtr := add(memPtr, 32) - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } - mstore(64, newFreePtr) - } - function allocate_memory(size) -> memPtr - { - memPtr := mload(64) - let newFreePtr := add(memPtr, and(add(size, 31), not(31))) - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } - mstore(64, newFreePtr) - } - function abi_encode_uint256_string(headStart, value0, value1) -> tail - { - mstore(headStart, value0) - let _1 := 32 - mstore(add(headStart, _1), 64) - let length := mload(value1) - mstore(add(headStart, 64), length) - let i := 0 - for { } lt(i, length) { i := add(i, _1) } - { - mstore(add(add(headStart, i), 96), mload(add(add(value1, i), _1))) - } - if gt(i, length) - { - mstore(add(add(headStart, length), 96), 0) - } - tail := add(add(headStart, and(add(length, 31), not(31))), 96) - } - function panic_error_0x32() - { - mstore(0, shl(224, 0x4e487b71)) - mstore(4, 0x32) - revert(0, 0x24) - } - /// @ast-id 58 @src 0:381:623 "function sumArray(S[] memory _s) public returns (uint, string memory) {..." - function fun_sumArray(var_s_mpos) -> var, var_mpos - { - /// @src 0:346:625 "contract C {..." - if iszero(mload(var_s_mpos)) { panic_error_0x32() } - sstore(/** @src 0:472:473 "0" */ 0x00, /** @src 0:346:625 "contract C {..." */ mload(/** @src 0:469:474 "_s[0]" */ mload(/** @src 0:346:625 "contract C {..." */ add(var_s_mpos, 32)))) - if iszero(lt(1, mload(var_s_mpos))) { panic_error_0x32() } - let _1 := mload(/** @src 0:489:494 "_s[1]" */ mload(/** @src 0:346:625 "contract C {..." */ add(var_s_mpos, 64))) - sstore(0x02, _1) - /// @src 0:500:619 "return (t.y[0], \"longstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstring\")" - var := _1 - /// @src 0:346:625 "contract C {..." - let memPtr := mload(64) - let newFreePtr := add(memPtr, 160) - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } - mstore(64, newFreePtr) - mstore(memPtr, 100) - mstore(add(memPtr, 32), "longstringlongstringlongstringlo") - mstore(add(memPtr, 64), "ngstringlongstringlongstringlong") - mstore(add(memPtr, 96), "stringlongstringlongstringlongst") - mstore(add(memPtr, 128), "ring") - /// @src 0:500:619 "return (t.y[0], \"longstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstring\")" - var_mpos := memPtr - } } data ".metadata" hex"" } diff --git a/test/cmdlineTests/optimizer_array_sload/output b/test/cmdlineTests/optimizer_array_sload/output index bb0d0bf40..98b23306a 100644 --- a/test/cmdlineTests/optimizer_array_sload/output +++ b/test/cmdlineTests/optimizer_array_sload/output @@ -18,53 +18,55 @@ object "Arraysum_34" { { /// @src 0:80:429 "contract Arraysum {..." mstore(64, memoryguard(0x80)) - if iszero(lt(calldatasize(), 4)) + let _1 := 4 + if iszero(lt(calldatasize(), _1)) { - let _1 := 0 - if eq(0x81d73423, shr(224, calldataload(_1))) + let _2 := 0 + if eq(0x81d73423, shr(224, calldataload(_2))) { - if callvalue() { revert(_1, _1) } - if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - let var_sum := _1 + if callvalue() { revert(_2, _2) } + if slt(add(calldatasize(), not(3)), _2) { revert(_2, _2) } + let var_sum := _2 /// @src 0:368:378 "uint i = 0" - let var_i := /** @src 0:80:429 "contract Arraysum {..." */ _1 - let _2 := sload(_1) + let var_i := /** @src 0:80:429 "contract Arraysum {..." */ _2 + let _3 := sload(_2) /// @src 0:364:423 "for(uint i = 0; i < values.length; i++)..." for { } - /** @src 0:380:397 "i < values.length" */ lt(var_i, _2) + /** @src 0:380:397 "i < values.length" */ lt(var_i, _3) /// @src 0:368:378 "uint i = 0" { /// @src 0:80:429 "contract Arraysum {..." - if eq(var_i, not(0)) { panic_error_0x11() } + if eq(var_i, not(0)) + { + mstore(_2, shl(224, 0x4e487b71)) + mstore(_1, 0x11) + revert(_2, 0x24) + } /// @src 0:399:402 "i++" var_i := /** @src 0:80:429 "contract Arraysum {..." */ add(var_i, 1) } /// @src 0:399:402 "i++" { /// @src 0:80:429 "contract Arraysum {..." - mstore(_1, _1) - let _3 := sload(add(18569430475105882587588266137607568536673111973893317399460219858819262702947, var_i)) - if gt(var_sum, not(_3)) { panic_error_0x11() } + mstore(_2, _2) + let sum := add(var_sum, sload(add(18569430475105882587588266137607568536673111973893317399460219858819262702947, var_i))) + if gt(var_sum, sum) + { + mstore(_2, shl(224, 0x4e487b71)) + mstore(_1, 0x11) + revert(_2, 0x24) + } /// @src 0:407:423 "sum += values[i]" - var_sum := /** @src 0:80:429 "contract Arraysum {..." */ add(var_sum, _3) + var_sum := sum } + /// @src 0:80:429 "contract Arraysum {..." let memPos := mload(64) - return(memPos, sub(abi_encode_uint256(memPos, var_sum), memPos)) + mstore(memPos, var_sum) + return(memPos, 32) } } revert(0, 0) } - function abi_encode_uint256(headStart, value0) -> tail - { - tail := add(headStart, 32) - mstore(headStart, value0) - } - function panic_error_0x11() - { - mstore(0, shl(224, 0x4e487b71)) - mstore(4, 0x11) - revert(0, 0x24) - } } data ".metadata" hex"" } diff --git a/test/cmdlineTests/optimizer_inliner_dynamic_reference/output b/test/cmdlineTests/optimizer_inliner_dynamic_reference/output index ba32c364b..2ddef4d76 100644 --- a/test/cmdlineTests/optimizer_inliner_dynamic_reference/output +++ b/test/cmdlineTests/optimizer_inliner_dynamic_reference/output @@ -150,75 +150,73 @@ sub_0: assembly { jump // in tag_25: jump // out - /* "#utility.yul":196:421 */ + /* "#utility.yul":196:418 */ tag_22: - /* "#utility.yul":236:239 */ - 0x00 - /* "#utility.yul":267:268 */ + /* "#utility.yul":261:270 */ + dup1 dup3 - /* "#utility.yul":263:269 */ - not - /* "#utility.yul":260:261 */ + add + /* "#utility.yul":282:292 */ + dup1 dup3 - /* "#utility.yul":257:270 */ gt - /* "#utility.yul":254:390 */ + /* "#utility.yul":279:412 */ iszero tag_30 jumpi - /* "#utility.yul":312:322 */ + /* "#utility.yul":334:344 */ 0x4e487b71 - /* "#utility.yul":307:310 */ + /* "#utility.yul":329:332 */ 0xe0 - /* "#utility.yul":303:323 */ + /* "#utility.yul":325:345 */ shl - /* "#utility.yul":300:301 */ + /* "#utility.yul":322:323 */ 0x00 - /* "#utility.yul":293:324 */ + /* "#utility.yul":315:346 */ mstore - /* "#utility.yul":347:351 */ + /* "#utility.yul":369:373 */ 0x11 - /* "#utility.yul":344:345 */ + /* "#utility.yul":366:367 */ 0x04 - /* "#utility.yul":337:352 */ + /* "#utility.yul":359:374 */ mstore - /* "#utility.yul":375:379 */ + /* "#utility.yul":397:401 */ 0x24 - /* "#utility.yul":372:373 */ + /* "#utility.yul":394:395 */ 0x00 - /* "#utility.yul":365:380 */ + /* "#utility.yul":387:402 */ revert - /* "#utility.yul":254:390 */ + /* "#utility.yul":279:412 */ tag_30: + /* "#utility.yul":196:418 */ + swap3 + swap2 + pop pop - /* "#utility.yul":406:415 */ - add - swap1 - /* "#utility.yul":196:421 */ jump // out - /* "#utility.yul":426:553 */ + /* "#utility.yul":423:550 */ tag_26: - /* "#utility.yul":487:497 */ + /* "#utility.yul":484:494 */ 0x4e487b71 - /* "#utility.yul":482:485 */ + /* "#utility.yul":479:482 */ 0xe0 - /* "#utility.yul":478:498 */ + /* "#utility.yul":475:495 */ shl - /* "#utility.yul":475:476 */ + /* "#utility.yul":472:473 */ 0x00 - /* "#utility.yul":468:499 */ + /* "#utility.yul":465:496 */ mstore - /* "#utility.yul":518:522 */ + /* "#utility.yul":515:519 */ 0x51 - /* "#utility.yul":515:516 */ + /* "#utility.yul":512:513 */ 0x04 - /* "#utility.yul":508:523 */ + /* "#utility.yul":505:520 */ mstore - /* "#utility.yul":542:546 */ + /* "#utility.yul":539:543 */ 0x24 - /* "#utility.yul":539:540 */ + /* "#utility.yul":536:537 */ 0x00 - /* "#utility.yul":532:547 */ + /* "#utility.yul":529:544 */ revert auxdata: diff --git a/test/cmdlineTests/optimizer_inliner_dynamic_reference_constructor/output b/test/cmdlineTests/optimizer_inliner_dynamic_reference_constructor/output index 83f06edad..edc93c0be 100644 --- a/test/cmdlineTests/optimizer_inliner_dynamic_reference_constructor/output +++ b/test/cmdlineTests/optimizer_inliner_dynamic_reference_constructor/output @@ -155,75 +155,73 @@ sub_0: assembly { jump // in tag_21: jump // out - /* "#utility.yul":196:421 */ + /* "#utility.yul":196:418 */ tag_19: - /* "#utility.yul":236:239 */ - 0x00 - /* "#utility.yul":267:268 */ + /* "#utility.yul":261:270 */ + dup1 dup3 - /* "#utility.yul":263:269 */ - not - /* "#utility.yul":260:261 */ + add + /* "#utility.yul":282:292 */ + dup1 dup3 - /* "#utility.yul":257:270 */ gt - /* "#utility.yul":254:390 */ + /* "#utility.yul":279:412 */ iszero tag_26 jumpi - /* "#utility.yul":312:322 */ + /* "#utility.yul":334:344 */ 0x4e487b71 - /* "#utility.yul":307:310 */ + /* "#utility.yul":329:332 */ 0xe0 - /* "#utility.yul":303:323 */ + /* "#utility.yul":325:345 */ shl - /* "#utility.yul":300:301 */ + /* "#utility.yul":322:323 */ 0x00 - /* "#utility.yul":293:324 */ + /* "#utility.yul":315:346 */ mstore - /* "#utility.yul":347:351 */ + /* "#utility.yul":369:373 */ 0x11 - /* "#utility.yul":344:345 */ + /* "#utility.yul":366:367 */ 0x04 - /* "#utility.yul":337:352 */ + /* "#utility.yul":359:374 */ mstore - /* "#utility.yul":375:379 */ + /* "#utility.yul":397:401 */ 0x24 - /* "#utility.yul":372:373 */ + /* "#utility.yul":394:395 */ 0x00 - /* "#utility.yul":365:380 */ + /* "#utility.yul":387:402 */ revert - /* "#utility.yul":254:390 */ + /* "#utility.yul":279:412 */ tag_26: + /* "#utility.yul":196:418 */ + swap3 + swap2 + pop pop - /* "#utility.yul":406:415 */ - add - swap1 - /* "#utility.yul":196:421 */ jump // out - /* "#utility.yul":426:553 */ + /* "#utility.yul":423:550 */ tag_22: - /* "#utility.yul":487:497 */ + /* "#utility.yul":484:494 */ 0x4e487b71 - /* "#utility.yul":482:485 */ + /* "#utility.yul":479:482 */ 0xe0 - /* "#utility.yul":478:498 */ + /* "#utility.yul":475:495 */ shl - /* "#utility.yul":475:476 */ + /* "#utility.yul":472:473 */ 0x00 - /* "#utility.yul":468:499 */ + /* "#utility.yul":465:496 */ mstore - /* "#utility.yul":518:522 */ + /* "#utility.yul":515:519 */ 0x51 - /* "#utility.yul":515:516 */ + /* "#utility.yul":512:513 */ 0x04 - /* "#utility.yul":508:523 */ + /* "#utility.yul":505:520 */ mstore - /* "#utility.yul":542:546 */ + /* "#utility.yul":539:543 */ 0x24 - /* "#utility.yul":539:540 */ + /* "#utility.yul":536:537 */ 0x00 - /* "#utility.yul":532:547 */ + /* "#utility.yul":529:544 */ revert auxdata: diff --git a/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json b/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json index 3490a7342..586099182 100644 --- a/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json +++ b/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json @@ -1,6 +1,6 @@ {"contracts":{"C":{"C":{"evm":{"assembly":" /* \"C\":79:428 contract C... */ 0xa0 - jumpi(tag_6, callvalue) + jumpi(tag_5, callvalue) 0x1f bytecodeSize codesize @@ -22,7 +22,7 @@ dup5 lt or - tag_4 + tag_3 jumpi dup1 dup5 @@ -37,12 +37,11 @@ add sub slt - tag_6 + tag_5 jumpi mload /* \"C\":147:149 42 */ mstore(0x80, 0x2a) - /* \"C\":203:219 stateVar = _init */ 0x00 /* \"C\":79:428 contract C... */ sstore @@ -53,15 +52,18 @@ dataOffset(sub_0) dup3 codecopy - mload(0x80) + /* \"C\":147:149 42 */ + 0x80 + /* \"C\":79:428 contract C... */ + mload dup2 assignImmutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") return -tag_6: +tag_5: 0x00 dup1 revert -tag_4: +tag_3: mstore(0x00, shl(0xe0, 0x4e487b71)) mstore(0x04, 0x41) revert(0x00, 0x24) @@ -69,15 +71,19 @@ stop sub_0: assembly { /* \"C\":79:428 contract C... */ - mstore(0x40, 0x80) - jumpi(tag_7, iszero(lt(calldatasize, 0x04))) - tag_8: + 0x80 + 0x40 + dup2 + dup2 + mstore + jumpi(tag_2, iszero(lt(calldatasize, 0x04))) 0x00 dup1 revert - tag_7: + tag_2: 0x00 - dup1 + swap2 + dup3 calldataload 0xe0 shr @@ -85,108 +91,43 @@ sub_0: assembly { dup2 0x26121ff0 eq - tag_9 + tag_4 jumpi pop dup1 0x793816ec eq - tag_11 + tag_6 jumpi 0x9942ec6f eq - tag_13 + tag_8 jumpi 0x00 dup1 revert - tag_13: - tag_8 - tag_3 - jump\t// in - tag_11: - pop - tag_8 - tag_2 - jump\t// in - tag_9: - jumpi(tag_19, callvalue) - dup1 + tag_8: + jumpi(tag_12, callvalue) + dup2 add(calldatasize, not(0x03)) slt - tag_19 + tag_12 jumpi - 0x20 - /* \"C\":290:298 immutVar */ - immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") - sub(shl(0xff, 0x01), 0x2a) - /* \"C\":117:119 41 */ dup2 - sgt - 0x01 - and - tag_21 - jumpi - /* \"C\":79:428 contract C... */ - tag_22: - mload(0x40) - /* \"C\":117:119 41 */ - swap1 - 0x29 - add - /* \"C\":79:428 contract C... */ - dup2 - mstore - return - /* \"C\":117:119 41 */ - tag_21: - tag_23 - tag_4 - jump\t// in - tag_23: - jump(tag_22) - /* \"C\":79:428 contract C... */ - tag_19: - dup1 - revert - tag_2: - pop - jumpi(tag_8, callvalue) - jumpi(tag_8, slt(add(not(0x03), calldatasize), 0x00)) - 0x20 - sload(0x00) - mload(0x40) - swap1 - dup2 - mstore - return - tag_3: - pop - jumpi(tag_8, callvalue) - 0x00 - dup1 - add(calldatasize, not(0x03)) - slt - tag_19 - jumpi - dup1 sload - /* \"C\":117:119 41 */ - 0x01 - swap1 sub(shl(0xff, 0x01), 0x01) - /* \"C\":79:428 contract C... */ dup2 eq - tag_32 + tag_14 jumpi - tag_33: + 0x01 add - swap1 - dup2 + swap2 + dup3 dup2 sstore - mload(0x40) + dup2 + mload shl(0xe4, 0x026121ff) /* \"C\":403:411 this.f() */ dup2 @@ -205,124 +146,116 @@ sub_0: assembly { swap2 dup3 iszero - tag_34 + tag_16 jumpi dup1 swap3 - tag_36 + tag_18 jumpi /* \"C\":79:428 contract C... */ - tag_37: - tag_38 - /* \"C\":392:422 stateVar + this.f() + immutVar */ - tag_39 + tag_19: + /* \"C\":403:411 this.f() */ + 0x20 /* \"C\":392:411 stateVar + this.f() */ - tag_40 - dup6 - dup8 - tag_5 + dup5 + /* \"C\":392:422 stateVar + this.f() + immutVar */ + tag_20 + /* \"C\":392:411 stateVar + this.f() */ + tag_21 + dup7 + dup10 + tag_1 jump\t// in - tag_40: + tag_21: /* \"C\":414:422 immutVar */ immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") /* \"C\":392:422 stateVar + this.f() + immutVar */ swap1 - tag_5 + tag_1 jump\t// in - tag_39: + tag_20: /* \"C\":79:428 contract C... */ - mload(0x40) + swap1 + mload swap1 dup2 mstore - swap1 - dup2 - swap1 - 0x20 - dup3 - add - swap1 - jump - tag_38: - sub - swap1 return /* \"C\":403:411 this.f() */ - tag_36: + tag_18: swap1 swap2 pop 0x20 - swap1 returndatasize - dup3 + dup2 gt - tag_41 + tag_22 jumpi - tag_42: + tag_23: /* \"C\":79:428 contract C... */ 0x1f - dup3 + dup2 add not(0x1f) and dup4 add - swap1 0xffffffffffffffff - dup3 + dup2 gt dup5 - dup4 + dup3 lt or - tag_43 + tag_24 jumpi - pop - swap3 /* \"C\":403:411 this.f() */ - tag_45 - /* \"C\":392:422 stateVar + this.f() + immutVar */ - tag_39 + 0x20 /* \"C\":79:428 contract C... */ - swap4 - /* \"C\":392:411 stateVar + this.f() */ - tag_40 - /* \"C\":79:428 contract C... */ - swap4 - tag_38 - swap7 - 0x40 + swap2 + dup5 + swap2 + dup7 mstore /* \"C\":403:411 this.f() */ dup2 add - swap1 - tag_6 - jump\t// in - tag_45: - swap3 - pop - swap3 - jump(tag_37) /* \"C\":79:428 contract C... */ - tag_43: + sub + slt + tag_26 + jumpi + pop + mload + /* \"C\":392:411 stateVar + this.f() */ + tag_21 + /* \"C\":403:411 this.f() */ + 0x20 + jump(tag_19) + /* \"C\":79:428 contract C... */ + tag_26: + dup1 + revert + tag_24: shl(0xe0, 0x4e487b71) - dup2 + dup4 mstore mstore(0x04, 0x41) 0x24 - swap1 + /* \"C\":117:119 41 */ + dup4 + /* \"C\":79:428 contract C... */ revert /* \"C\":403:411 this.f() */ - tag_41: - returndatasize - swap2 + tag_22: pop - jump(tag_42) - tag_34: + returndatasize + jump(tag_23) + tag_16: /* \"C\":79:428 contract C... */ - mload(0x40) + dup4 + mload swap1 returndatasize swap1 @@ -331,83 +264,106 @@ sub_0: assembly { returndatasize swap1 revert - tag_32: - tag_46 - tag_4 - jump\t// in - tag_46: - jump(tag_33) - /* \"C\":117:119 41 */ - tag_4: - pop - /* \"C\":79:428 contract C... */ + tag_14: shl(0xe0, 0x4e487b71) /* \"C\":117:119 41 */ - 0x00 + dup4 mstore - mstore(0x04, 0x11) - revert(0x00, 0x24) - tag_5: - 0x00 - dup2 - slt - dup1 - iszero - sub(shl(0xff, 0x01), 0x01) - dup4 - swap1 - sub - dup5 - sgt - and - tag_47 - jumpi - tag_48: - shl(0xff, 0x01) - dup3 - swap1 - sub - dup4 - slt - and - tag_49 - jumpi - add - swap1 - jump\t// out - tag_49: - tag_51 - tag_4 - jump\t// in - tag_51: - add - swap1 - jump\t// out - tag_47: - tag_52 - tag_4 - jump\t// in - tag_52: - jump(tag_48) + 0x11 /* \"C\":79:428 contract C... */ + 0x04 + /* \"C\":117:119 41 */ + mstore + 0x24 + dup4 + revert + /* \"C\":79:428 contract C... */ + tag_12: + pop + dup1 + revert tag_6: - swap1 + pop + jumpi(tag_12, callvalue) dup2 + add(calldatasize, not(0x03)) + slt + tag_12 + jumpi 0x20 swap2 - sub - slt - tag_8 - jumpi + sload + swap1 mload swap1 + dup2 + mstore + return + tag_4: + dup4 + swap1 + jumpi(tag_12, callvalue) + dup2 + add(calldatasize, not(0x03)) + slt + tag_12 + jumpi + /* \"C\":290:298 immutVar */ + immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") + /* \"C\":117:119 41 */ + dup1 + 0x29 + add + swap1 + dup2 + slt + 0x01 + and + tag_14 + jumpi + /* \"C\":79:428 contract C... */ + 0x20 + swap3 + pop + dup2 + mstore + return + /* \"C\":117:119 41 */ + tag_1: + swap2 + swap1 + swap2 + 0x00 + dup4 + dup3 + add + swap4 + dup5 + slt + swap2 + slt + swap1 + dup1 + iszero + dup3 + and + swap2 + iszero + and + or + tag_38 + jumpi jump\t// out + tag_38: + mstore(0x00, shl(0xe0, 0x4e487b71)) + mstore(0x04, 0x11) + revert(0x00, 0x24) auxdata: } "}}},"D":{"D":{"evm":{"assembly":" /* \"D\":91:166 contract D is C(3)... */ 0xa0 - jumpi(tag_6, callvalue) + jumpi(tag_5, callvalue) 0x1f bytecodeSize codesize @@ -429,7 +385,7 @@ sub_0: assembly { dup5 lt or - tag_4 + tag_3 jumpi dup1 dup5 @@ -444,14 +400,26 @@ sub_0: assembly { add sub slt - tag_6 + tag_5 jumpi - tag_8 - swap1 mload - tag_1 - jump\t// in -tag_8: + /* \"C\":147:149 42 */ + mstore(0x80, 0x2a) + /* \"D\":91:166 contract D is C(3)... */ + dup1 + /* \"D\":107:108 3 */ + 0x03 + /* \"D\":91:166 contract D is C(3)... */ + add + swap1 + dup2 + slt + 0x01 + and + tag_7 + jumpi + 0x00 + sstore mload(0x40) dataSize(sub_0) swap1 @@ -459,56 +427,42 @@ tag_8: dataOffset(sub_0) dup3 codecopy - mload(0x80) + /* \"C\":147:149 42 */ + 0x80 + /* \"D\":91:166 contract D is C(3)... */ + mload dup2 assignImmutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") return -tag_6: +tag_7: + mstore(0x00, shl(0xe0, 0x4e487b71)) + mstore(0x04, 0x11) + revert(0x00, 0x24) +tag_5: 0x00 dup1 revert -tag_4: +tag_3: mstore(0x00, shl(0xe0, 0x4e487b71)) mstore(0x04, 0x41) - revert(0x00, 0x24) - /* \"D\":113:164 constructor(int _init2)... */ -tag_1: - /* \"C\":147:149 42 */ - mstore(0x80, 0x2a) - sub(shl(0xff, 0x01), 0x04) - /* \"D\":91:166 contract D is C(3)... */ - dup2 - sgt - 0x01 - and - tag_9 - jumpi - /* \"D\":107:108 3 */ - 0x03 - /* \"D\":91:166 contract D is C(3)... */ - add - 0x00 - sstore - /* \"D\":113:164 constructor(int _init2)... */ - jump\t// out - /* \"D\":91:166 contract D is C(3)... */ -tag_9: - mstore(0x00, shl(0xe0, 0x4e487b71)) - mstore(0x04, 0x11) revert(0x00, 0x24) stop sub_0: assembly { /* \"D\":91:166 contract D is C(3)... */ - mstore(0x40, 0x80) - jumpi(tag_7, iszero(lt(calldatasize, 0x04))) - tag_8: + 0x80 + 0x40 + dup2 + dup2 + mstore + jumpi(tag_2, iszero(lt(calldatasize, 0x04))) 0x00 dup1 revert - tag_7: + tag_2: 0x00 - dup1 + swap2 + dup3 calldataload 0xe0 shr @@ -516,108 +470,43 @@ sub_0: assembly { dup2 0x26121ff0 eq - tag_9 + tag_4 jumpi pop dup1 0x793816ec eq - tag_11 + tag_6 jumpi 0x9942ec6f eq - tag_13 + tag_8 jumpi 0x00 dup1 revert - tag_13: - tag_8 - tag_3 - jump\t// in - tag_11: - pop - tag_8 - tag_2 - jump\t// in - tag_9: - jumpi(tag_19, callvalue) - dup1 + tag_8: + jumpi(tag_12, callvalue) + dup2 add(calldatasize, not(0x03)) slt - tag_19 + tag_12 jumpi - 0x20 - /* \"C\":290:298 immutVar */ - immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") - sub(shl(0xff, 0x01), 0x2a) - /* \"C\":117:119 41 */ dup2 - sgt - 0x01 - and - tag_21 - jumpi - /* \"D\":91:166 contract D is C(3)... */ - tag_22: - mload(0x40) - /* \"C\":117:119 41 */ - swap1 - 0x29 - add - /* \"D\":91:166 contract D is C(3)... */ - dup2 - mstore - return - /* \"C\":117:119 41 */ - tag_21: - tag_23 - tag_4 - jump\t// in - tag_23: - jump(tag_22) - /* \"D\":91:166 contract D is C(3)... */ - tag_19: - dup1 - revert - tag_2: - pop - jumpi(tag_8, callvalue) - jumpi(tag_8, slt(add(not(0x03), calldatasize), 0x00)) - 0x20 - sload(0x00) - mload(0x40) - swap1 - dup2 - mstore - return - tag_3: - pop - jumpi(tag_8, callvalue) - 0x00 - dup1 - add(calldatasize, not(0x03)) - slt - tag_19 - jumpi - dup1 sload - /* \"C\":117:119 41 */ - 0x01 - swap1 sub(shl(0xff, 0x01), 0x01) - /* \"D\":91:166 contract D is C(3)... */ dup2 eq - tag_32 + tag_14 jumpi - tag_33: + 0x01 add - swap1 - dup2 + swap2 + dup3 dup2 sstore - mload(0x40) + dup2 + mload shl(0xe4, 0x026121ff) /* \"C\":403:411 this.f() */ dup2 @@ -636,124 +525,116 @@ sub_0: assembly { swap2 dup3 iszero - tag_34 + tag_16 jumpi dup1 swap3 - tag_36 + tag_18 jumpi /* \"D\":91:166 contract D is C(3)... */ - tag_37: - tag_38 - /* \"C\":392:422 stateVar + this.f() + immutVar */ - tag_39 + tag_19: + /* \"C\":403:411 this.f() */ + 0x20 /* \"C\":392:411 stateVar + this.f() */ - tag_40 - dup6 - dup8 - tag_5 + dup5 + /* \"C\":392:422 stateVar + this.f() + immutVar */ + tag_20 + /* \"C\":392:411 stateVar + this.f() */ + tag_21 + dup7 + dup10 + tag_1 jump\t// in - tag_40: + tag_21: /* \"C\":414:422 immutVar */ immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") /* \"C\":392:422 stateVar + this.f() + immutVar */ swap1 - tag_5 + tag_1 jump\t// in - tag_39: + tag_20: /* \"D\":91:166 contract D is C(3)... */ - mload(0x40) + swap1 + mload swap1 dup2 mstore - swap1 - dup2 - swap1 - 0x20 - dup3 - add - swap1 - jump - tag_38: - sub - swap1 return /* \"C\":403:411 this.f() */ - tag_36: + tag_18: swap1 swap2 pop 0x20 - swap1 returndatasize - dup3 + dup2 gt - tag_41 + tag_22 jumpi - tag_42: + tag_23: /* \"D\":91:166 contract D is C(3)... */ 0x1f - dup3 + dup2 add not(0x1f) and dup4 add - swap1 0xffffffffffffffff - dup3 + dup2 gt dup5 - dup4 + dup3 lt or - tag_43 + tag_24 jumpi - pop - swap3 /* \"C\":403:411 this.f() */ - tag_45 - /* \"C\":392:422 stateVar + this.f() + immutVar */ - tag_39 + 0x20 /* \"D\":91:166 contract D is C(3)... */ - swap4 - /* \"C\":392:411 stateVar + this.f() */ - tag_40 - /* \"D\":91:166 contract D is C(3)... */ - swap4 - tag_38 - swap7 - 0x40 + swap2 + dup5 + swap2 + dup7 mstore /* \"C\":403:411 this.f() */ dup2 add - swap1 - tag_6 - jump\t// in - tag_45: - swap3 - pop - swap3 - jump(tag_37) /* \"D\":91:166 contract D is C(3)... */ - tag_43: + sub + slt + tag_26 + jumpi + pop + mload + /* \"C\":392:411 stateVar + this.f() */ + tag_21 + /* \"C\":403:411 this.f() */ + 0x20 + jump(tag_19) + /* \"D\":91:166 contract D is C(3)... */ + tag_26: + dup1 + revert + tag_24: shl(0xe0, 0x4e487b71) - dup2 + dup4 mstore mstore(0x04, 0x41) 0x24 - swap1 + /* \"C\":117:119 41 */ + dup4 + /* \"D\":91:166 contract D is C(3)... */ revert /* \"C\":403:411 this.f() */ - tag_41: - returndatasize - swap2 + tag_22: pop - jump(tag_42) - tag_34: + returndatasize + jump(tag_23) + tag_16: /* \"D\":91:166 contract D is C(3)... */ - mload(0x40) + dup4 + mload swap1 returndatasize swap1 @@ -762,77 +643,100 @@ sub_0: assembly { returndatasize swap1 revert - tag_32: - tag_46 - tag_4 - jump\t// in - tag_46: - jump(tag_33) - /* \"C\":117:119 41 */ - tag_4: - pop - /* \"D\":91:166 contract D is C(3)... */ + tag_14: shl(0xe0, 0x4e487b71) /* \"C\":117:119 41 */ - 0x00 + dup4 mstore - mstore(0x04, 0x11) - revert(0x00, 0x24) - tag_5: - 0x00 - dup2 - slt - dup1 - iszero - sub(shl(0xff, 0x01), 0x01) - dup4 - swap1 - sub - dup5 - sgt - and - tag_47 - jumpi - tag_48: - shl(0xff, 0x01) - dup3 - swap1 - sub - dup4 - slt - and - tag_49 - jumpi - add - swap1 - jump\t// out - tag_49: - tag_51 - tag_4 - jump\t// in - tag_51: - add - swap1 - jump\t// out - tag_47: - tag_52 - tag_4 - jump\t// in - tag_52: - jump(tag_48) + 0x11 /* \"D\":91:166 contract D is C(3)... */ + 0x04 + /* \"C\":117:119 41 */ + mstore + 0x24 + dup4 + revert + /* \"D\":91:166 contract D is C(3)... */ + tag_12: + pop + dup1 + revert tag_6: - swap1 + pop + jumpi(tag_12, callvalue) dup2 + add(calldatasize, not(0x03)) + slt + tag_12 + jumpi 0x20 swap2 - sub - slt - tag_8 - jumpi + sload + swap1 mload swap1 + dup2 + mstore + return + tag_4: + dup4 + swap1 + jumpi(tag_12, callvalue) + dup2 + add(calldatasize, not(0x03)) + slt + tag_12 + jumpi + /* \"C\":290:298 immutVar */ + immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") + /* \"C\":117:119 41 */ + dup1 + 0x29 + add + swap1 + dup2 + slt + 0x01 + and + tag_14 + jumpi + /* \"D\":91:166 contract D is C(3)... */ + 0x20 + swap3 + pop + dup2 + mstore + return + /* \"C\":117:119 41 */ + tag_1: + swap2 + swap1 + swap2 + 0x00 + dup4 + dup3 + add + swap4 + dup5 + slt + swap2 + slt + swap1 + dup1 + iszero + dup3 + and + swap2 + iszero + and + or + tag_38 + jumpi jump\t// out + tag_38: + mstore(0x00, shl(0xe0, 0x4e487b71)) + mstore(0x04, 0x11) + revert(0x00, 0x24) auxdata: } diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json index 30895c160..2fe90b70e 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json @@ -199,7 +199,7 @@ object \"C_6\" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(memoryguard(0x80), _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json index 6ee9874d3..3600f633c 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json @@ -198,7 +198,7 @@ object \"C_6\" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(memoryguard(0x80), _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json index a32ee0580..7393f8b44 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json @@ -187,7 +187,7 @@ object \"C_6\" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(memoryguard(0x80), _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/standard_debug_info_in_yul_location/output.json b/test/cmdlineTests/standard_debug_info_in_yul_location/output.json index a57dbdc35..aff1f17aa 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_location/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_location/output.json @@ -354,13 +354,15 @@ object \"C_54\" { function checked_add_t_int256(x, y) -> sum { x := cleanup_t_int256(x) y := cleanup_t_int256(y) - - // overflow, if x >= 0 and y > (maxValue - x) - if and(iszero(slt(x, 0)), sgt(y, sub(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, x))) { panic_error_0x11() } - // underflow, if x < 0 and y < (minValue - x) - if and(slt(x, 0), slt(y, sub(0x8000000000000000000000000000000000000000000000000000000000000000, x))) { panic_error_0x11() } - sum := add(x, y) + + // overflow, if x >= 0 and sum < y + // underflow, if x < 0 and sum >= y + if or( + and(iszero(slt(x, 0)), slt(sum, y)), + and(slt(x, 0), iszero(slt(sum, y))) + ) { panic_error_0x11() } + } /// @ast-id 30 @@ -625,20 +627,17 @@ object \"C_54\" { revert(/** @src -1:-1:-1 */ 0, 0) } /// @src 0:79:435 \"contract C...\" - constructor_C(mload(_1)) - let _2 := mload(64) - let _3 := datasize(\"C_54_deployed\") - codecopy(_2, dataoffset(\"C_54_deployed\"), _3) - setimmutable(_2, \"8\", mload(128)) - return(_2, _3) - } - /// @ast-id 20 @src 0:182:230 \"constructor(int _init)...\" - function constructor_C(var_init) - { + let value := mload(_1) /// @src 0:154:156 \"42\" mstore(128, 0x2a) /// @src 0:79:435 \"contract C...\" - sstore(/** @src 0:210:226 \"stateVar = _init\" */ 0x00, /** @src 0:79:435 \"contract C...\" */ var_init) + sstore(/** @src -1:-1:-1 */ 0, /** @src 0:79:435 \"contract C...\" */ value) + let _2 := mload(64) + let _3 := datasize(\"C_54_deployed\") + codecopy(_2, dataoffset(\"C_54_deployed\"), _3) + setimmutable(_2, \"8\", mload(/** @src 0:154:156 \"42\" */ 128)) + /// @src 0:79:435 \"contract C...\" + return(_2, _3) } } /// @use-src 0:\"C\" @@ -646,117 +645,115 @@ object \"C_54\" { code { { /// @src 0:79:435 \"contract C...\" - mstore(64, memoryguard(0x80)) + let _1 := memoryguard(0x80) + let _2 := 64 + mstore(_2, _1) if iszero(lt(calldatasize(), 4)) { - let _1 := 0 - switch shr(224, calldataload(_1)) + let _3 := 0 + switch shr(224, calldataload(_3)) case 0x26121ff0 { - if callvalue() { revert(_1, _1) } - if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } + if callvalue() { revert(_3, _3) } + if slt(add(calldatasize(), not(3)), _3) { revert(_3, _3) } /// @src 0:297:305 \"immutVar\" - let _2 := loadimmutable(\"8\") + let _4 := loadimmutable(\"8\") /// @src 0:79:435 \"contract C...\" - if and(1, sgt(_2, sub(shl(255, 1), 42))) { panic_error_0x11() } - let memPos := mload(64) - mstore(memPos, add(/** @src 0:124:126 \"41\" */ 0x29, /** @src 0:79:435 \"contract C...\" */ _2)) + let sum := add(/** @src 0:124:126 \"41\" */ 0x29, /** @src 0:79:435 \"contract C...\" */ _4) + if and(1, slt(sum, _4)) + { + mstore(_3, shl(224, 0x4e487b71)) + mstore(4, 0x11) + revert(_3, 0x24) + } + mstore(_1, sum) + return(_1, 32) + } + case 0x793816ec { + if callvalue() { revert(_3, _3) } + if slt(add(calldatasize(), not(3)), _3) { revert(_3, _3) } + let _5 := sload(_3) + let memPos := mload(_2) + mstore(memPos, _5) return(memPos, 32) } - case 0x793816ec { external_fun_stateVar() } - case 0x9942ec6f { external_fun_f2() } - case 0xa00b982b { external_fun_constVar() } + case 0x9942ec6f { + if callvalue() { revert(_3, _3) } + if slt(add(calldatasize(), not(3)), _3) { revert(_3, _3) } + let _6 := sload(_3) + if eq(_6, sub(shl(255, 1), 1)) + { + mstore(_3, shl(224, 0x4e487b71)) + mstore(4, 0x11) + revert(_3, 0x24) + } + let ret := add(_6, 1) + sstore(_3, ret) + /// @src 0:410:418 \"this.f()\" + let _7 := /** @src 0:79:435 \"contract C...\" */ mload(_2) + /// @src 0:410:418 \"this.f()\" + mstore(_7, /** @src 0:79:435 \"contract C...\" */ shl(228, 0x026121ff)) + /// @src 0:410:418 \"this.f()\" + let _8 := staticcall(gas(), /** @src 0:410:414 \"this\" */ address(), /** @src 0:410:418 \"this.f()\" */ _7, /** @src 0:79:435 \"contract C...\" */ 4, /** @src 0:410:418 \"this.f()\" */ _7, 32) + if iszero(_8) + { + /// @src 0:79:435 \"contract C...\" + let pos := mload(_2) + returndatacopy(pos, _3, returndatasize()) + revert(pos, returndatasize()) + } + /// @src 0:410:418 \"this.f()\" + let expr := /** @src 0:79:435 \"contract C...\" */ _3 + /// @src 0:410:418 \"this.f()\" + if _8 + { + let _9 := 32 + if gt(_9, returndatasize()) { _9 := returndatasize() } + /// @src 0:79:435 \"contract C...\" + let newFreePtr := add(_7, and(add(_9, 31), not(31))) + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _7)) + { + mstore(_3, shl(224, 0x4e487b71)) + mstore(4, 0x41) + revert(_3, 0x24) + } + mstore(_2, newFreePtr) + if slt(sub(/** @src 0:410:418 \"this.f()\" */ add(_7, _9), /** @src 0:79:435 \"contract C...\" */ _7), /** @src 0:410:418 \"this.f()\" */ 32) + /// @src 0:79:435 \"contract C...\" + { revert(_3, _3) } + /// @src 0:410:418 \"this.f()\" + expr := /** @src 0:79:435 \"contract C...\" */ mload(_7) + } + /// @src 0:399:418 \"stateVar + this.f()\" + let expr_1 := checked_add_int256(ret, expr) + /// @src 0:392:429 \"return stateVar + this.f() + immutVar\" + let var := /** @src 0:399:429 \"stateVar + this.f() + immutVar\" */ checked_add_int256(expr_1, /** @src 0:421:429 \"immutVar\" */ loadimmutable(\"8\")) + /// @src 0:79:435 \"contract C...\" + let memPos_1 := mload(_2) + mstore(memPos_1, var) + return(memPos_1, /** @src 0:410:418 \"this.f()\" */ 32) + } + case /** @src 0:79:435 \"contract C...\" */ 0xa00b982b { + if callvalue() { revert(_3, _3) } + if slt(add(calldatasize(), not(3)), _3) { revert(_3, _3) } + let memPos_2 := mload(_2) + mstore(memPos_2, /** @src 0:124:126 \"41\" */ 0x29) + /// @src 0:79:435 \"contract C...\" + return(memPos_2, 32) + } } revert(0, 0) } - function abi_encode_int256(headStart, value0) -> tail - { - tail := add(headStart, 32) - mstore(headStart, value0) - } - function external_fun_stateVar() - { - if callvalue() { revert(0, 0) } - if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let _1 := sload(0) - let memPos := mload(64) - mstore(memPos, _1) - return(memPos, 32) - } - function external_fun_f2() - { - if callvalue() { revert(0, 0) } - let _1 := 0 - if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - let _2 := sload(_1) - if eq(_2, sub(shl(255, 1), 1)) { panic_error_0x11() } - let ret := add(_2, 1) - sstore(_1, ret) - /// @src 0:410:418 \"this.f()\" - let _3 := /** @src 0:79:435 \"contract C...\" */ mload(64) - /// @src 0:410:418 \"this.f()\" - mstore(_3, /** @src 0:79:435 \"contract C...\" */ shl(228, 0x026121ff)) - /// @src 0:410:418 \"this.f()\" - let _4 := staticcall(gas(), /** @src 0:410:414 \"this\" */ address(), /** @src 0:410:418 \"this.f()\" */ _3, /** @src 0:79:435 \"contract C...\" */ 4, /** @src 0:410:418 \"this.f()\" */ _3, 32) - if iszero(_4) - { - /// @src 0:79:435 \"contract C...\" - let pos := mload(64) - returndatacopy(pos, _1, returndatasize()) - revert(pos, returndatasize()) - } - /// @src 0:410:418 \"this.f()\" - let expr := /** @src 0:79:435 \"contract C...\" */ _1 - /// @src 0:410:418 \"this.f()\" - if _4 - { - let _5 := 32 - if gt(_5, returndatasize()) { _5 := returndatasize() } - /// @src 0:79:435 \"contract C...\" - let newFreePtr := add(_3, and(add(_5, 31), not(31))) - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _3)) - { - mstore(_1, shl(224, 0x4e487b71)) - mstore(4, 0x41) - revert(_1, 0x24) - } - mstore(64, newFreePtr) - /// @src 0:410:418 \"this.f()\" - expr := abi_decode_int256_fromMemory(_3, add(_3, _5)) - } - /// @src 0:399:418 \"stateVar + this.f()\" - let expr_1 := checked_add_int256(ret, expr) - /// @src 0:392:429 \"return stateVar + this.f() + immutVar\" - let var := /** @src 0:399:429 \"stateVar + this.f() + immutVar\" */ checked_add_int256(expr_1, /** @src 0:421:429 \"immutVar\" */ loadimmutable(\"8\")) - /// @src 0:79:435 \"contract C...\" - let memPos := mload(64) - return(memPos, sub(abi_encode_int256(memPos, var), memPos)) - } - function external_fun_constVar() - { - if callvalue() { revert(0, 0) } - if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let memPos := mload(64) - mstore(memPos, /** @src 0:124:126 \"41\" */ 0x29) - /// @src 0:79:435 \"contract C...\" - return(memPos, 32) - } - function panic_error_0x11() - { - mstore(0, shl(224, 0x4e487b71)) - mstore(4, 0x11) - revert(0, 0x24) - } function checked_add_int256(x, y) -> sum { - let _1 := slt(x, 0) - if and(iszero(_1), sgt(y, sub(sub(shl(255, 1), 1), x))) { panic_error_0x11() } - if and(_1, slt(y, sub(shl(255, 1), x))) { panic_error_0x11() } sum := add(x, y) - } - function abi_decode_int256_fromMemory(headStart, dataEnd) -> value0 - { - if slt(sub(dataEnd, headStart), 32) { revert(0, 0) } - value0 := mload(headStart) + let _1 := slt(sum, y) + let _2 := slt(x, 0) + if or(and(iszero(_2), _1), and(_2, iszero(_1))) + { + mstore(0, shl(224, 0x4e487b71)) + mstore(4, 0x11) + revert(0, 0x24) + } } } data \".metadata\" hex\"\" @@ -894,13 +891,15 @@ object \"D_72\" { function checked_add_t_int256(x, y) -> sum { x := cleanup_t_int256(x) y := cleanup_t_int256(y) - - // overflow, if x >= 0 and y > (maxValue - x) - if and(iszero(slt(x, 0)), sgt(y, sub(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, x))) { panic_error_0x11() } - // underflow, if x < 0 and y < (minValue - x) - if and(slt(x, 0), slt(y, sub(0x8000000000000000000000000000000000000000000000000000000000000000, x))) { panic_error_0x11() } - sum := add(x, y) + + // overflow, if x >= 0 and sum < y + // underflow, if x < 0 and sum >= y + if or( + and(iszero(slt(x, 0)), slt(sum, y)), + and(slt(x, 0), iszero(slt(sum, y))) + ) { panic_error_0x11() } + } function shift_left_0(value) -> newValue { @@ -1186,13 +1185,15 @@ object \"D_72\" { function checked_add_t_int256(x, y) -> sum { x := cleanup_t_int256(x) y := cleanup_t_int256(y) - - // overflow, if x >= 0 and y > (maxValue - x) - if and(iszero(slt(x, 0)), sgt(y, sub(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, x))) { panic_error_0x11() } - // underflow, if x < 0 and y < (minValue - x) - if and(slt(x, 0), slt(y, sub(0x8000000000000000000000000000000000000000000000000000000000000000, x))) { panic_error_0x11() } - sum := add(x, y) + + // overflow, if x >= 0 and sum < y + // underflow, if x < 0 and sum >= y + if or( + and(iszero(slt(x, 0)), slt(sum, y)), + and(slt(x, 0), iszero(slt(sum, y))) + ) { panic_error_0x11() } + } /// @ast-id 30 @@ -1457,26 +1458,24 @@ object \"D_72\" { revert(/** @src -1:-1:-1 */ 0, 0) } /// @src 1:91:166 \"contract D is C(3)...\" - constructor_D(mload(_1)) - let _2 := mload(64) - let _3 := datasize(\"D_72_deployed\") - codecopy(_2, dataoffset(\"D_72_deployed\"), _3) - setimmutable(_2, \"8\", mload(128)) - return(_2, _3) - } - /// @ast-id 71 @src 1:113:164 \"constructor(int _init2)...\" - function constructor_D(var_init2) - { + let value := mload(_1) /// @src 0:154:156 \"42\" mstore(128, 0x2a) /// @src 1:91:166 \"contract D is C(3)...\" - if and(1, sgt(var_init2, sub(shl(255, 1), 4))) + let sum := add(/** @src 1:107:108 \"3\" */ 0x03, /** @src 1:91:166 \"contract D is C(3)...\" */ value) + if and(1, slt(sum, value)) { - mstore(0, shl(224, 0x4e487b71)) + mstore(/** @src -1:-1:-1 */ 0, /** @src 1:91:166 \"contract D is C(3)...\" */ shl(224, 0x4e487b71)) mstore(4, 0x11) - revert(0, 0x24) + revert(/** @src -1:-1:-1 */ 0, /** @src 1:91:166 \"contract D is C(3)...\" */ 0x24) } - sstore(/** @src -1:-1:-1 */ 0, /** @src 1:91:166 \"contract D is C(3)...\" */ add(/** @src 1:107:108 \"3\" */ 0x03, /** @src 1:91:166 \"contract D is C(3)...\" */ var_init2)) + sstore(/** @src -1:-1:-1 */ 0, /** @src 1:91:166 \"contract D is C(3)...\" */ sum) + let _2 := mload(64) + let _3 := datasize(\"D_72_deployed\") + codecopy(_2, dataoffset(\"D_72_deployed\"), _3) + setimmutable(_2, \"8\", mload(/** @src 0:154:156 \"42\" */ 128)) + /// @src 1:91:166 \"contract D is C(3)...\" + return(_2, _3) } } /// @use-src 0:\"C\", 1:\"D\" @@ -1484,117 +1483,115 @@ object \"D_72\" { code { { /// @src 1:91:166 \"contract D is C(3)...\" - mstore(64, memoryguard(0x80)) + let _1 := memoryguard(0x80) + let _2 := 64 + mstore(_2, _1) if iszero(lt(calldatasize(), 4)) { - let _1 := 0 - switch shr(224, calldataload(_1)) + let _3 := 0 + switch shr(224, calldataload(_3)) case 0x26121ff0 { - if callvalue() { revert(_1, _1) } - if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } + if callvalue() { revert(_3, _3) } + if slt(add(calldatasize(), not(3)), _3) { revert(_3, _3) } /// @src 0:297:305 \"immutVar\" - let _2 := loadimmutable(\"8\") + let _4 := loadimmutable(\"8\") /// @src 1:91:166 \"contract D is C(3)...\" - if and(1, sgt(_2, sub(shl(255, 1), 42))) { panic_error_0x11() } - let memPos := mload(64) - mstore(memPos, add(/** @src 0:124:126 \"41\" */ 0x29, /** @src 1:91:166 \"contract D is C(3)...\" */ _2)) + let sum := add(/** @src 0:124:126 \"41\" */ 0x29, /** @src 1:91:166 \"contract D is C(3)...\" */ _4) + if and(1, slt(sum, _4)) + { + mstore(_3, shl(224, 0x4e487b71)) + mstore(4, 0x11) + revert(_3, 0x24) + } + mstore(_1, sum) + return(_1, 32) + } + case 0x793816ec { + if callvalue() { revert(_3, _3) } + if slt(add(calldatasize(), not(3)), _3) { revert(_3, _3) } + let _5 := sload(_3) + let memPos := mload(_2) + mstore(memPos, _5) return(memPos, 32) } - case 0x793816ec { external_fun_stateVar() } - case 0x9942ec6f { external_fun_f2() } - case 0xa00b982b { external_fun_constVar() } + case 0x9942ec6f { + if callvalue() { revert(_3, _3) } + if slt(add(calldatasize(), not(3)), _3) { revert(_3, _3) } + let _6 := sload(_3) + if eq(_6, sub(shl(255, 1), 1)) + { + mstore(_3, shl(224, 0x4e487b71)) + mstore(4, 0x11) + revert(_3, 0x24) + } + let ret := add(_6, 1) + sstore(_3, ret) + /// @src 0:410:418 \"this.f()\" + let _7 := /** @src 1:91:166 \"contract D is C(3)...\" */ mload(_2) + /// @src 0:410:418 \"this.f()\" + mstore(_7, /** @src 1:91:166 \"contract D is C(3)...\" */ shl(228, 0x026121ff)) + /// @src 0:410:418 \"this.f()\" + let _8 := staticcall(gas(), /** @src 0:410:414 \"this\" */ address(), /** @src 0:410:418 \"this.f()\" */ _7, /** @src 1:91:166 \"contract D is C(3)...\" */ 4, /** @src 0:410:418 \"this.f()\" */ _7, 32) + if iszero(_8) + { + /// @src 1:91:166 \"contract D is C(3)...\" + let pos := mload(_2) + returndatacopy(pos, _3, returndatasize()) + revert(pos, returndatasize()) + } + /// @src 0:410:418 \"this.f()\" + let expr := /** @src 1:91:166 \"contract D is C(3)...\" */ _3 + /// @src 0:410:418 \"this.f()\" + if _8 + { + let _9 := 32 + if gt(_9, returndatasize()) { _9 := returndatasize() } + /// @src 1:91:166 \"contract D is C(3)...\" + let newFreePtr := add(_7, and(add(_9, 31), not(31))) + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _7)) + { + mstore(_3, shl(224, 0x4e487b71)) + mstore(4, 0x41) + revert(_3, 0x24) + } + mstore(_2, newFreePtr) + if slt(sub(/** @src 0:410:418 \"this.f()\" */ add(_7, _9), /** @src 1:91:166 \"contract D is C(3)...\" */ _7), /** @src 0:410:418 \"this.f()\" */ 32) + /// @src 1:91:166 \"contract D is C(3)...\" + { revert(_3, _3) } + /// @src 0:410:418 \"this.f()\" + expr := /** @src 1:91:166 \"contract D is C(3)...\" */ mload(_7) + } + /// @src 0:399:418 \"stateVar + this.f()\" + let expr_1 := checked_add_int256(ret, expr) + /// @src 0:392:429 \"return stateVar + this.f() + immutVar\" + let var := /** @src 0:399:429 \"stateVar + this.f() + immutVar\" */ checked_add_int256(expr_1, /** @src 0:421:429 \"immutVar\" */ loadimmutable(\"8\")) + /// @src 1:91:166 \"contract D is C(3)...\" + let memPos_1 := mload(_2) + mstore(memPos_1, var) + return(memPos_1, /** @src 0:410:418 \"this.f()\" */ 32) + } + case /** @src 1:91:166 \"contract D is C(3)...\" */ 0xa00b982b { + if callvalue() { revert(_3, _3) } + if slt(add(calldatasize(), not(3)), _3) { revert(_3, _3) } + let memPos_2 := mload(_2) + mstore(memPos_2, /** @src 0:124:126 \"41\" */ 0x29) + /// @src 1:91:166 \"contract D is C(3)...\" + return(memPos_2, 32) + } } revert(0, 0) } - function abi_encode_int256(headStart, value0) -> tail - { - tail := add(headStart, 32) - mstore(headStart, value0) - } - function external_fun_stateVar() - { - if callvalue() { revert(0, 0) } - if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let _1 := sload(0) - let memPos := mload(64) - mstore(memPos, _1) - return(memPos, 32) - } - function external_fun_f2() - { - if callvalue() { revert(0, 0) } - let _1 := 0 - if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - let _2 := sload(_1) - if eq(_2, sub(shl(255, 1), 1)) { panic_error_0x11() } - let ret := add(_2, 1) - sstore(_1, ret) - /// @src 0:410:418 \"this.f()\" - let _3 := /** @src 1:91:166 \"contract D is C(3)...\" */ mload(64) - /// @src 0:410:418 \"this.f()\" - mstore(_3, /** @src 1:91:166 \"contract D is C(3)...\" */ shl(228, 0x026121ff)) - /// @src 0:410:418 \"this.f()\" - let _4 := staticcall(gas(), /** @src 0:410:414 \"this\" */ address(), /** @src 0:410:418 \"this.f()\" */ _3, /** @src 1:91:166 \"contract D is C(3)...\" */ 4, /** @src 0:410:418 \"this.f()\" */ _3, 32) - if iszero(_4) - { - /// @src 1:91:166 \"contract D is C(3)...\" - let pos := mload(64) - returndatacopy(pos, _1, returndatasize()) - revert(pos, returndatasize()) - } - /// @src 0:410:418 \"this.f()\" - let expr := /** @src 1:91:166 \"contract D is C(3)...\" */ _1 - /// @src 0:410:418 \"this.f()\" - if _4 - { - let _5 := 32 - if gt(_5, returndatasize()) { _5 := returndatasize() } - /// @src 1:91:166 \"contract D is C(3)...\" - let newFreePtr := add(_3, and(add(_5, 31), not(31))) - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _3)) - { - mstore(_1, shl(224, 0x4e487b71)) - mstore(4, 0x41) - revert(_1, 0x24) - } - mstore(64, newFreePtr) - /// @src 0:410:418 \"this.f()\" - expr := abi_decode_int256_fromMemory(_3, add(_3, _5)) - } - /// @src 0:399:418 \"stateVar + this.f()\" - let expr_1 := checked_add_int256(ret, expr) - /// @src 0:392:429 \"return stateVar + this.f() + immutVar\" - let var := /** @src 0:399:429 \"stateVar + this.f() + immutVar\" */ checked_add_int256(expr_1, /** @src 0:421:429 \"immutVar\" */ loadimmutable(\"8\")) - /// @src 1:91:166 \"contract D is C(3)...\" - let memPos := mload(64) - return(memPos, sub(abi_encode_int256(memPos, var), memPos)) - } - function external_fun_constVar() - { - if callvalue() { revert(0, 0) } - if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } - let memPos := mload(64) - mstore(memPos, /** @src 0:124:126 \"41\" */ 0x29) - /// @src 1:91:166 \"contract D is C(3)...\" - return(memPos, 32) - } - function panic_error_0x11() - { - mstore(0, shl(224, 0x4e487b71)) - mstore(4, 0x11) - revert(0, 0x24) - } function checked_add_int256(x, y) -> sum { - let _1 := slt(x, 0) - if and(iszero(_1), sgt(y, sub(sub(shl(255, 1), 1), x))) { panic_error_0x11() } - if and(_1, slt(y, sub(shl(255, 1), x))) { panic_error_0x11() } sum := add(x, y) - } - function abi_decode_int256_fromMemory(headStart, dataEnd) -> value0 - { - if slt(sub(dataEnd, headStart), 32) { revert(0, 0) } - value0 := mload(headStart) + let _1 := slt(sum, y) + let _2 := slt(x, 0) + if or(and(iszero(_2), _1), and(_2, iszero(_1))) + { + mstore(0, shl(224, 0x4e487b71)) + mstore(4, 0x11) + revert(0, 0x24) + } } } data \".metadata\" hex\"\" diff --git a/test/cmdlineTests/viair_subobject_optimization/output b/test/cmdlineTests/viair_subobject_optimization/output index 5d4e89480..4d5aa7f70 100644 --- a/test/cmdlineTests/viair_subobject_optimization/output +++ b/test/cmdlineTests/viair_subobject_optimization/output @@ -3,7 +3,7 @@ EVM assembly: /* "viair_subobject_optimization/input.sol":61:668 contract C {... */ 0x80 - jumpi(tag_6, callvalue) + jumpi(tag_7, callvalue) 0x1f bytecodeSize codesize @@ -25,7 +25,7 @@ EVM assembly: dup5 lt or - tag_4 + tag_3 jumpi dup1 dup5 @@ -40,14 +40,16 @@ EVM assembly: add sub slt - tag_6 + tag_7 jumpi - tag_8 - swap1 mload - tag_1 - jump // in -tag_8: + sub(shl(0x48, 0x01), 0xbe) + /* "viair_subobject_optimization/input.sol":620:645 x == 0xFFFFFFFFFFFFFFFF42 */ + eq + /* "viair_subobject_optimization/input.sol":616:661 if (x == 0xFFFFFFFFFFFFFFFF42)... */ + tag_7 + jumpi + /* "viair_subobject_optimization/input.sol":61:668 contract C {... */ mload(0x40) dataSize(sub_0) swap1 @@ -56,24 +58,17 @@ tag_8: dup3 codecopy return -tag_6: + /* "viair_subobject_optimization/input.sol":616:661 if (x == 0xFFFFFFFFFFFFFFFF42)... */ +tag_7: 0x00 + /* "viair_subobject_optimization/input.sol":653:661 revert() */ dup1 revert -tag_4: + /* "viair_subobject_optimization/input.sol":61:668 contract C {... */ +tag_3: mstore(0x00, shl(0xe0, 0x4e487b71)) mstore(0x04, 0x41) revert(0x00, 0x24) - /* "viair_subobject_optimization/input.sol":76:666 constructor(uint x) {... */ -tag_1: - sub(shl(0x48, 0x01), 0xbe) - /* "viair_subobject_optimization/input.sol":620:645 x == 0xFFFFFFFFFFFFFFFF42 */ - eq - /* "viair_subobject_optimization/input.sol":616:661 if (x == 0xFFFFFFFFFFFFFFFF42)... */ - tag_6 - jumpi - /* "viair_subobject_optimization/input.sol":76:666 constructor(uint x) {... */ - jump // out stop sub_0: assembly { @@ -110,163 +105,154 @@ stop sub_0: assembly { /* "viair_subobject_optimization/input.sol":669:772 contract D {... */ 0x80 - jumpi(tag_2, iszero(lt(calldatasize, 0x04))) + jumpi(tag_1, iszero(lt(calldatasize, 0x04))) 0x00 dup1 revert - tag_2: + tag_1: 0x00 - swap1 - dup2 + dup1 calldataload 0xe0 shr 0x26121ff0 eq - tag_4 + tag_3 jumpi 0x00 dup1 revert - tag_4: - jumpi(tag_8, callvalue) - dup2 + tag_3: + jumpi(tag_7, callvalue) + dup1 add(calldatasize, not(0x03)) slt - tag_8 + tag_7 jumpi /* "viair_subobject_optimization/input.sol":745:765 type(C).creationCode */ dataSize(sub_0) /* "viair_subobject_optimization/input.sol":669:772 contract D {... */ - 0x3f - dup2 - add + swap2 not(0x1f) - and - dup3 - add - 0xffffffffffffffff + swap1 dup2 - gt - dup4 - dup3 + 0x3f + dup6 + add + and + dup2 + add + swap3 + dup2 + dup5 lt + 0xffffffffffffffff + dup6 + gt or - tag_10 + tag_9 jumpi - tag_12 - swap4 - pop + swap1 + swap2 0x40 + swap4 + dup5 mstore /* "viair_subobject_optimization/input.sol":745:765 type(C).creationCode */ - dup1 - dup3 - mstore - dataOffset(sub_0) - 0x20 + dup5 dup4 + mstore + 0x20 + swap5 + dataOffset(sub_0) + dup7 + dup6 add codecopy /* "viair_subobject_optimization/input.sol":669:772 contract D {... */ - mload(0x40) + dup4 + mload + swap5 + dup6 + swap3 + dup2 + dup5 + mstore + dup5 + mload swap2 dup3 - swap2 + dup2 + dup7 + add + mstore + dup2 + swap6 + tag_11: + dup4 + dup8 + lt + tag_12 + jumpi + pop + pop + dup4 + swap5 + pop + dup6 dup3 - tag_1 - jump // in - tag_12: + 0x1f + swap5 + swap6 + add + add + mstore + add + and + dup2 + add sub + add swap1 return - tag_10: + tag_12: + dup7 + dup2 + add + dup3 + add + mload + dup10 + dup9 + add + dup10 + add + mstore + swap6 + dup2 + add + swap6 + dup9 + swap6 + pop + jump(tag_11) + tag_9: shl(0xe0, 0x4e487b71) - dup5 + dup2 mstore mstore(0x04, 0x41) 0x24 - dup5 + swap1 revert - tag_8: - pop + tag_7: dup1 revert - tag_1: - swap2 - swap1 - swap2 - 0x20 - dup1 - dup3 - mstore - dup4 - mload - swap1 - dup2 - dup2 - dup5 - add - mstore - 0x00 - swap5 - tag_13: - dup3 - dup7 - lt - tag_14 - jumpi - pop - pop - dup1 - 0x40 - swap4 - swap5 - gt - tag_16 - jumpi - tag_17: - 0x1f - add - not(0x1f) - and - add - add - swap1 - jump // out - tag_16: - 0x00 - dup4 - dup3 - dup5 - add - add - mstore - jump(tag_17) - tag_14: - dup6 - dup2 - add - dup3 - add - mload - dup5 - dup8 - add - 0x40 - add - mstore - swap5 - dup2 - add - swap5 - jump(tag_13) stop sub_0: assembly { /* "viair_subobject_optimization/input.sol":61:668 contract C {... */ 0x80 - jumpi(tag_6, callvalue) + jumpi(tag_7, callvalue) 0x1f bytecodeSize codesize @@ -288,7 +274,7 @@ sub_0: assembly { dup5 lt or - tag_4 + tag_3 jumpi dup1 dup5 @@ -303,14 +289,16 @@ sub_0: assembly { add sub slt - tag_6 + tag_7 jumpi - tag_8 - swap1 mload - tag_1 - jump // in - tag_8: + sub(shl(0x48, 0x01), 0xbe) + /* "viair_subobject_optimization/input.sol":620:645 x == 0xFFFFFFFFFFFFFFFF42 */ + eq + /* "viair_subobject_optimization/input.sol":616:661 if (x == 0xFFFFFFFFFFFFFFFF42)... */ + tag_7 + jumpi + /* "viair_subobject_optimization/input.sol":61:668 contract C {... */ mload(0x40) dataSize(sub_0) swap1 @@ -319,24 +307,17 @@ sub_0: assembly { dup3 codecopy return - tag_6: + /* "viair_subobject_optimization/input.sol":616:661 if (x == 0xFFFFFFFFFFFFFFFF42)... */ + tag_7: 0x00 + /* "viair_subobject_optimization/input.sol":653:661 revert() */ dup1 revert - tag_4: + /* "viair_subobject_optimization/input.sol":61:668 contract C {... */ + tag_3: mstore(0x00, shl(0xe0, 0x4e487b71)) mstore(0x04, 0x41) revert(0x00, 0x24) - /* "viair_subobject_optimization/input.sol":76:666 constructor(uint x) {... */ - tag_1: - sub(shl(0x48, 0x01), 0xbe) - /* "viair_subobject_optimization/input.sol":620:645 x == 0xFFFFFFFFFFFFFFFF42 */ - eq - /* "viair_subobject_optimization/input.sol":616:661 if (x == 0xFFFFFFFFFFFFFFFF42)... */ - tag_6 - jumpi - /* "viair_subobject_optimization/input.sol":76:666 constructor(uint x) {... */ - jump // out stop sub_0: assembly { diff --git a/test/cmdlineTests/viair_subobjects/output b/test/cmdlineTests/viair_subobjects/output index 51fdae924..500472f8a 100644 --- a/test/cmdlineTests/viair_subobjects/output +++ b/test/cmdlineTests/viair_subobjects/output @@ -83,7 +83,7 @@ object "D_16" { returndatacopy(pos, _2, returndatasize()) revert(pos, returndatasize()) } - return(mload(64), _2) + return(_2, _2) } } revert(0, 0) diff --git a/test/cmdlineTests/yul_string_format_ascii/output.json b/test/cmdlineTests/yul_string_format_ascii/output.json index 3ff8779ff..4bc66584c 100644 --- a/test/cmdlineTests/yul_string_format_ascii/output.json +++ b/test/cmdlineTests/yul_string_format_ascii/output.json @@ -88,17 +88,13 @@ object \"C_11\" { updated_pos := add(pos, 0x20) } - function copy_memory_to_memory(src, dst, length) { + function copy_memory_to_memory_with_cleanup(src, dst, length) { let i := 0 for { } lt(i, length) { i := add(i, 32) } { mstore(add(dst, i), mload(add(src, i))) } - if gt(i, length) - { - // clear end - mstore(add(dst, length), 0) - } + mstore(add(dst, length), 0) } function round_up_to_mul_of_32(value) -> result { @@ -108,7 +104,7 @@ object \"C_11\" { function abi_encode_t_string_memory_ptr_to_t_string_memory_ptr_fromStack(value, pos) -> end { let length := array_length_t_string_memory_ptr(value) pos := array_storeLengthForEncoding_t_string_memory_ptr_fromStack(pos, length) - copy_memory_to_memory(add(value, 0x20), pos, length) + copy_memory_to_memory_with_cleanup(add(value, 0x20), pos, length) end := add(pos, round_up_to_mul_of_32(length)) } diff --git a/test/cmdlineTests/yul_string_format_ascii_long/output.json b/test/cmdlineTests/yul_string_format_ascii_long/output.json index e019e5c2f..68f033773 100644 --- a/test/cmdlineTests/yul_string_format_ascii_long/output.json +++ b/test/cmdlineTests/yul_string_format_ascii_long/output.json @@ -88,17 +88,13 @@ object \"C_11\" { updated_pos := add(pos, 0x20) } - function copy_memory_to_memory(src, dst, length) { + function copy_memory_to_memory_with_cleanup(src, dst, length) { let i := 0 for { } lt(i, length) { i := add(i, 32) } { mstore(add(dst, i), mload(add(src, i))) } - if gt(i, length) - { - // clear end - mstore(add(dst, length), 0) - } + mstore(add(dst, length), 0) } function round_up_to_mul_of_32(value) -> result { @@ -108,7 +104,7 @@ object \"C_11\" { function abi_encode_t_string_memory_ptr_to_t_string_memory_ptr_fromStack(value, pos) -> end { let length := array_length_t_string_memory_ptr(value) pos := array_storeLengthForEncoding_t_string_memory_ptr_fromStack(pos, length) - copy_memory_to_memory(add(value, 0x20), pos, length) + copy_memory_to_memory_with_cleanup(add(value, 0x20), pos, length) end := add(pos, round_up_to_mul_of_32(length)) } diff --git a/test/externalTests.sh b/test/externalTests.sh index 8c581a165..4746e2a58 100755 --- a/test/externalTests.sh +++ b/test/externalTests.sh @@ -51,3 +51,5 @@ printTask "Running external tests..." "${REPO_ROOT}/test/externalTests/prb-math.sh" "$@" "${REPO_ROOT}/test/externalTests/elementfi.sh" "$@" "${REPO_ROOT}/test/externalTests/brink.sh" "$@" +"${REPO_ROOT}/test/externalTests/chainlink.sh" "$@" +"${REPO_ROOT}/test/externalTests/gp2.sh" "$@" diff --git a/test/externalTests/README.md b/test/externalTests/README.md index 76e39a79b..8df5b4dfe 100644 --- a/test/externalTests/README.md +++ b/test/externalTests/README.md @@ -79,7 +79,7 @@ The above is the workflow to use when the update is straightforward and looks sa fine to just modify the branches directly. If this is not the case, it is recommended to first perform the operation on copies of these version-specific branches and test them by creating PRs on `develop` and `breaking` to see if tests pass. The PRs should just modify project scripts in `test/externalScripts/` -to use the updated copies of the branches and can be discarded aferwards without being merged. +to use the updated copies of the branches and can be discarded afterwards without being merged. #### Changes needed after a breaking release of the compiler When a non-backwards-compatible version becomes the most recent release, `breaking` branch diff --git a/test/externalTests/bleeps.sh b/test/externalTests/bleeps.sh index a9d2b58a0..5ad80642e 100755 --- a/test/externalTests/bleeps.sh +++ b/test/externalTests/bleeps.sh @@ -28,7 +28,7 @@ REPO_ROOT=$(realpath "$(dirname "$0")/../..") verify_input "$@" BINARY_TYPE="$1" -BINARY_PATH="$2" +BINARY_PATH="$(realpath "$2")" SELECTED_PRESETS="$3" function compile_fn { npm run compile; } diff --git a/test/externalTests/brink.sh b/test/externalTests/brink.sh index bfbd993f2..901a0cfc0 100755 --- a/test/externalTests/brink.sh +++ b/test/externalTests/brink.sh @@ -28,7 +28,7 @@ REPO_ROOT=$(realpath "$(dirname "$0")/../..") verify_input "$@" BINARY_TYPE="$1" -BINARY_PATH="$2" +BINARY_PATH="$(realpath "$2")" SELECTED_PRESETS="$3" function compile_fn { yarn compile; } diff --git a/test/externalTests/chainlink.sh b/test/externalTests/chainlink.sh new file mode 100755 index 000000000..9f50e1486 --- /dev/null +++ b/test/externalTests/chainlink.sh @@ -0,0 +1,124 @@ +#!/usr/bin/env bash + +# ------------------------------------------------------------------------------ +# This file is part of solidity. +# +# solidity is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# solidity is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with solidity. If not, see +# +# (c) 2022 solidity contributors. +#------------------------------------------------------------------------------ + +set -e + +source scripts/common.sh +source test/externalTests/common.sh + +REPO_ROOT=$(realpath "$(dirname "$0")/../..") + +verify_input "$@" +BINARY_TYPE="$1" +BINARY_PATH="$(realpath "$2")" +SELECTED_PRESETS="$3" + +function compile_fn { yarn compile; } +function test_fn { yarn test; } + +function chainlink_test +{ + local repo="https://github.com/solidity-external-tests/chainlink" + local ref_type=branch + local ref=develop_080 + local config_file="hardhat.config.ts" + local config_var=config + + local compile_only_presets=( + legacy-no-optimize # Tests crash on a machine with 8 GB of RAM in CI "FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory" + ) + local settings_presets=( + "${compile_only_presets[@]}" + #ir-no-optimize # Compilation fails with "YulException: Variable var__value_775 is 1 slot(s) too deep inside the stack." + #ir-optimize-evm-only # Compilation fails with "YulException: Variable var__value_10 is 1 slot(s) too deep inside the stack" + ir-optimize-evm+yul + legacy-optimize-evm-only # NOTE: This requires >= 4 GB RAM in CI not to crash + legacy-optimize-evm+yul # NOTE: This requires >= 4 GB RAM in CI not to crash + ) + + [[ $SELECTED_PRESETS != "" ]] || SELECTED_PRESETS=$(circleci_select_steps_multiarg "${settings_presets[@]}") + print_presets_or_exit "$SELECTED_PRESETS" + + setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH" + download_project "$repo" "$ref_type" "$ref" "$DIR" + + cd "contracts/" + + # Disable tests that won't pass on the ir presets due to Hardhat heuristics. Note that this also disables + # them for other presets but that's fine - we want same code run for benchmarks to be comparable. + # TODO: Remove this when Hardhat adjusts heuristics for IR (https://github.com/nomiclabs/hardhat/issues/2115). + sed -i "s|\(it\)\(('reverts'\)|\1.skip\2|g" test/v0.6/BasicConsumer.test.ts + sed -i "s|\(it\)\(('has a reasonable gas cost \[ @skip-coverage \]'\)|\1.skip\2|g" test/v0.6/BasicConsumer.test.ts + sed -i "s|\(describe\)\(('#add[^']*'\)|\1.skip\2|g" test/v0.6/Chainlink.test.ts + sed -i "s|\(it\)\(('throws'\)|\1.skip\2|g" test/v0.6/SignedSafeMath.test.ts + sed -i "s|\(it\)\(('reverts when not enough LINK in the contract'\)|\1.skip\2|g" test/v0.*/VRFD20.test.ts + sed -i "s|\(it\)\(('errors while parsing invalid cron strings'\)|\1.skip\2|g" test/v0.8/Cron.test.ts + sed -i "s|\(it\)\(('reverts if the amount passed in data mismatches actual amount sent'\)|\1.skip\2|g" test/v0.8/KeeperRegistrar.test.ts + sed -i "s|\(it\)\(('reverts if the sender passed in data mismatches actual sender'\)|\1.skip\2|g" test/v0.8/KeeperRegistrar.test.ts + sed -i "s|\(it\)\(('reverts if the admin address is 0x0000...'\)|\1.skip\2|g" test/v0.8/KeeperRegistrar.test.ts + sed -i "s|\(it\)\(('reverts if not called with more or less than 32 bytes'\)|\1.skip\2|g" test/v0.8/KeeperRegistry.test.ts + sed -i "s|\(context\)\(('when permissions are not set'\)|\1.skip\2|g" test/v0.8/KeeperRegistry.test.ts + + # In some cases Hardhat does not detect revert reasons properly via IR. + # TODO: Remove this when https://github.com/NomicFoundation/hardhat/issues/2453 gets fixed. + sed -i "s|\(it\)\(('does not allow the specified address to start new rounds'\)|\1.skip\2|g" test/v0.6/FluxAggregator.test.ts + sed -i "s|\(describe\)\(('when called by a stranger'\)|\1.skip\2|g" test/v0.6/FluxAggregator.test.ts + sed -i "s|\(describe\)\(('if the access control is turned on'\)|\1.skip\2|g" test/v0.*/Flags.test.ts + sed -i "s|\(it\)\(('respects the access controls of #getFlag'\)|\1.skip\2|g" test/v0.*/Flags.test.ts + sed -i "s|\(describe\)\(('setting 0 authorized senders'\)|\1.skip\2|g" test/v0.7/AuthorizedForwarder.test.ts + sed -i "s|\(it\)\(('cannot add an authorized node'\)|\1.skip\2|g" test/v0.7/AuthorizedForwarder.test.ts + sed -i "s|\(it\)\(('should disallow reads on AggregatorV2V3Interface functions when consuming contract is not whitelisted'\)|\1.skip\2|g" test/v0.8/dev/ArbitrumSequencerUptimeFeed.test.ts + sed -i "s|\(it\)\(('should not be callable by non-owners'\)|\1.skip\2|g" test/v0.8/dev/CrossDomainOwnable.test.ts + sed -i "s|\(it\)\(('should not be callable by non pending-owners'\)|\1.skip\2|g" test/v0.8/dev/CrossDomainOwnable.test.ts + sed -i "s|\(it\)\(('cannot add a consumer to a nonexistent subscription'\)|\1.skip\2|g" test/v0.8/dev/VRFCoordinatorV2Mock.test.ts + sed -i "s|\(it\)\(('cannot remove a consumer from a nonexistent subscription'\)|\1.skip\2|g" test/v0.8/dev/VRFCoordinatorV2Mock.test.ts + sed -i "s|\(it\)\(('cannot remove a consumer after it is already removed'\)|\1.skip\2|g" test/v0.8/dev/VRFCoordinatorV2Mock.test.ts + sed -i "s|\(it\)\(('fails to fulfill without being a valid consumer'\)|\1.skip\2|g" test/v0.8/dev/VRFCoordinatorV2Mock.test.ts + # TODO: check why these two are needed due to this PR. + sed -i "s|\(it\)\(('cannot fund a nonexistent subscription'\)|\1.skip\2|g" test/v0.8/dev/VRFCoordinatorV2Mock.test.ts + sed -i "s|\(it\)\(('can cancel a subscription'\)|\1.skip\2|g" test/v0.8/dev/VRFCoordinatorV2Mock.test.ts + + + # Disable tests with hard-coded gas expectations. + sed -i "s|\(it\)\(('not use too much gas \[ @skip-coverage \]'\)|\1.skip\2|g" test/v0.6/FluxAggregator.test.ts + sed -i "s|\(it\)\(('has a large enough gas overhead to cover upkeeps that use all their gas \[ @skip-coverage \]'\)|\1.skip\2|g" test/v0.*/KeeperRegistry*.test.ts + sed -i "s|\(it\)\(('only pays .\+'\)|\1.skip\2|g" test/v0.*/KeeperRegistry*.test.ts + sed -i "s|\(it\)\(('uses a specific amount of gas \[ @skip-coverage \]'\)|\1.skip\2|g" test/v0.8/ValidatorProxy.test.ts + sed -i "s|\(describe\)\(('Gas costs'\)|\1.skip\2|g" test/v0.8/dev/ArbitrumSequencerUptimeFeed.test.ts + + neutralize_package_lock + neutralize_package_json_hooks + name_hardhat_default_export "$config_file" "$config_var" + force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH" + force_hardhat_compiler_settings "$config_file" "$(first_word "$SELECTED_PRESETS")" "$config_var" + force_hardhat_unlimited_contract_size "$config_file" "$config_var" + yarn install + yarn add hardhat-gas-reporter + + replace_version_pragmas + + for preset in $SELECTED_PRESETS; do + hardhat_run_test "$config_file" "$preset" "${compile_only_presets[*]}" compile_fn test_fn "$config_var" + store_benchmark_report hardhat chainlink "$repo" "$preset" + done +} + +external_test Chainlink chainlink_test diff --git a/test/externalTests/colony.sh b/test/externalTests/colony.sh index e23ce1135..8582411b9 100755 --- a/test/externalTests/colony.sh +++ b/test/externalTests/colony.sh @@ -28,7 +28,7 @@ REPO_ROOT=$(realpath "$(dirname "$0")/../..") verify_input "$@" BINARY_TYPE="$1" -BINARY_PATH="$2" +BINARY_PATH="$(realpath "$2")" SELECTED_PRESETS="$3" function compile_fn { yarn run provision:token:contracts; } diff --git a/test/externalTests/elementfi.sh b/test/externalTests/elementfi.sh index 5cb1e8088..94877f2f4 100755 --- a/test/externalTests/elementfi.sh +++ b/test/externalTests/elementfi.sh @@ -28,7 +28,7 @@ REPO_ROOT=$(realpath "$(dirname "$0")/../..") verify_input "$@" BINARY_TYPE="$1" -BINARY_PATH="$2" +BINARY_PATH="$(realpath "$2")" SELECTED_PRESETS="$3" function compile_fn { npm run build; } @@ -43,7 +43,7 @@ function elementfi_test local config_var=config local compile_only_presets=( - # ElementFi's test suite is hard-coded for mainnet forked via alchemy.io. + # ElementFi's test suite is hard-coded for Mainnet forked via alchemy.io. # Locally we can only compile. #ir-no-optimize # Compilation fails with "YulException: Variable var_amount_9311 is 10 slot(s) too deep inside the stack." #ir-optimize-evm-only # Compilation fails with "YulException: Variable var_amount_9311 is 10 slot(s) too deep inside the stack." @@ -88,7 +88,7 @@ function elementfi_test sed -i 's|delete _twoTokenPoolTokens\[poolId\];|delete _twoTokenPoolTokens[poolId].tokenA;delete _twoTokenPoolTokens[poolId].tokenB;|g' vault/balances/TwoTokenPoolsBalance.sol popd - # The test suite uses forked mainnet and an expiration period that's too short. + # The test suite uses forked Mainnet and an expiration period that's too short. # TODO: Remove when https://github.com/element-fi/elf-contracts/issues/243 is fixed. sed -i 's|^\s*require(_expiration - block\.timestamp < _unitSeconds);\s*$||g' contracts/ConvergentCurvePool.sol diff --git a/test/externalTests/ens.sh b/test/externalTests/ens.sh index 8d17920b2..fa5429ba7 100755 --- a/test/externalTests/ens.sh +++ b/test/externalTests/ens.sh @@ -28,7 +28,7 @@ REPO_ROOT=$(realpath "$(dirname "$0")/../..") verify_input "$@" BINARY_TYPE="$1" -BINARY_PATH="$2" +BINARY_PATH="$(realpath "$2")" SELECTED_PRESETS="$3" function compile_fn { yarn build; } @@ -37,8 +37,8 @@ function test_fn { yarn test; } function ens_test { local repo="https://github.com/ensdomains/ens-contracts.git" - local ref_type=branch - local ref="master" + local ref_type=commit + local ref="083d29a2c50cd0a8307386abf8fadc217b256256" local config_file="hardhat.config.js" local compile_only_presets=( @@ -65,10 +65,6 @@ function ens_test force_hardhat_compiler_settings "$config_file" "$(first_word "$SELECTED_PRESETS")" yarn install - # With ethers.js 5.6.2 many tests for revert messages fail. - # TODO: Remove when https://github.com/ethers-io/ethers.js/discussions/2849 is resolved. - yarn add ethers@5.6.1 - replace_version_pragmas neutralize_packaged_contracts @@ -78,6 +74,16 @@ function ens_test # Related to disallow returndatasize and returndatacopy in inline assembly blocks in pure functions https://github.com/ethereum/solidity/pull/13028 # TODO: Remove this after release 0.9 and ENS updated to support it. sed -i 's/pure/view/' contracts/utils/LowLevelCallUtils.sol + # TODO: Remove this when https://github.com/NomicFoundation/hardhat/issues/2453 gets fixed. + sed -i "s|it\(('can set fuses and then burn ability to burn fuses',\)|it.skip\1|g" test/wrapper/NameWrapper.js + sed -i "s|it\(('can set fuses and burn canSetResolver and canSetTTL',\)|it.skip\1|g" test/wrapper/NameWrapper.js + sed -i "s|it\(('Cannot be called if CANNOT_TRANSFER is burned\.',\)|it.skip\1|g" test/wrapper/NameWrapper.js + sed -i "s|it\(('Cannot be called if CANNOT_SET_RESOLVER is burned\.\?',\)|it.skip\1|g" test/wrapper/NameWrapper.js + sed -i "s|it\(('Cannot be called if CANNOT_SET_TTL is burned\.\?',\)|it.skip\1|g" test/wrapper/NameWrapper.js + sed -i "s|it\(('Cannot be called if CREATE_SUBDOMAIN is burned and is a new subdomain',\)|it.skip\1|g" test/wrapper/NameWrapper.js + sed -i "s|it\(('Cannot be called if REPLACE_SUBDOMAIN is burned and is an existing subdomain',\)|it.skip\1|g" test/wrapper/NameWrapper.js + sed -i "s|it\(('Cannot be called if CANNOT_CREATE_SUBDOMAIN is burned and is a new subdomain',\)|it.skip\1|g" test/wrapper/NameWrapper.js + sed -i "s|it\(('Cannot be called if PARENT_CANNOT_CONTROL is burned and is an existing subdomain',\)|it.skip\1|g" test/wrapper/NameWrapper.js find . -name "*.sol" -exec sed -i -e 's/^\(\s*\)\(assembly\)/\1\/\/\/ @solidity memory-safe-assembly\n\1\2/' '{}' \; diff --git a/test/externalTests/euler.sh b/test/externalTests/euler.sh index 0d63ecd43..6ecba6c59 100755 --- a/test/externalTests/euler.sh +++ b/test/externalTests/euler.sh @@ -28,7 +28,7 @@ REPO_ROOT=$(realpath "$(dirname "$0")/../..") verify_input "$@" BINARY_TYPE="$1" -BINARY_PATH="$2" +BINARY_PATH="$(realpath "$2")" SELECTED_PRESETS="$3" function compile_fn { npm run compile; } @@ -49,7 +49,7 @@ function euler_test "${compile_only_presets[@]}" #ir-no-optimize # Compilation fails with "YulException: Variable var_utilisation_307 is 6 slot(s) too deep inside the stack." #ir-optimize-evm-only # Compilation fails with "YulException: Variable var_utilisation_307 is 6 slot(s) too deep inside the stack." - #ir-optimize-evm+yul # Compilation fails with "YulException: Variable var_status_mpos is 3 too deep in the stack" + ir-optimize-evm+yul legacy-optimize-evm-only legacy-optimize-evm+yul legacy-no-optimize @@ -61,6 +61,12 @@ function euler_test setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH" download_project "$repo" "$ref_type" "$ref" "$DIR" + # Disable tests that won't pass on the ir presets due to Hardhat heuristics. Note that this also disables + # them for other presets but that's fine - we want same code run for benchmarks to be comparable. + # TODO: Remove this when https://github.com/NomicFoundation/hardhat/issues/2453 gets fixed. + sed -i "/expectError: 'JUNK_UPGRADE_TEST_FAILURE'/d" test/moduleUpgrade.js + sed -i "/et\.expect(errMsg)\.to\.contain('e\/collateral-violation');/d" test/flashLoanNative.js + neutralize_package_lock neutralize_package_json_hooks force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH" @@ -68,10 +74,6 @@ function euler_test force_hardhat_unlimited_contract_size "$config_file" npm install - # With ethers.js 5.6.2 many tests for revert messages fail. - # TODO: Remove when https://github.com/ethers-io/ethers.js/discussions/2849 is resolved. - npm install ethers@5.6.1 - replace_version_pragmas neutralize_packaged_contracts diff --git a/test/externalTests/gnosis.sh b/test/externalTests/gnosis.sh index 8995231e1..81e5180c6 100755 --- a/test/externalTests/gnosis.sh +++ b/test/externalTests/gnosis.sh @@ -28,11 +28,11 @@ REPO_ROOT=$(realpath "$(dirname "$0")/../..") verify_input "$@" BINARY_TYPE="$1" -BINARY_PATH="$2" +BINARY_PATH="$(realpath "$2")" SELECTED_PRESETS="$3" -function compile_fn { npm run build; } -function test_fn { npm test; } +function compile_fn { npx npm run build; } +function test_fn { npx npm test; } function gnosis_safe_test { @@ -82,24 +82,49 @@ function gnosis_safe_test # TODO: Remove this when Gnosis merges https://github.com/gnosis/safe-contracts/pull/394 sed -i "s|\(function isValidSignature(bytes \)calldata\( _data, bytes \)calldata\( _signature)\)|\1memory\2memory\3|g" contracts/handler/CompatibilityFallbackHandler.sol + # TODO: Remove this when https://github.com/NomicFoundation/hardhat/issues/2453 gets fixed. + sed -i "s|it\(('should enforce delegatecall'\)|it.skip\1|g" test/accessors/SimulateTxAccessor.spec.ts + sed -i "s|it\(('can only be called from Safe itself'\)|it.skip\1|g" test/libraries/Migration.spec.ts + sed -i "s|it\(('should enforce delegatecall to MultiSend'\)|it.skip\1|g" test/libraries/MultiSend.spec.ts + + # Force nested abstract-provider dependencies to be at version 5.6.0. Version 5.7.0 of @ethersproject/abstract-provider + # introduced a new field in FeeData, which causes clashes unless all dependency packages of abstract-provider are pegged + # to the same version. As we've already had to peg @ethersproject/contracts to 5.6.0 earlier, we are doing so now with + # @ethersproject/abstract-provider as well. + jq '.overrides."@ethersproject/abstract-provider"="5.6.0" | + .overrides."@ethersproject/abstract-signer@5.6.0" + ."@ethersproject/abstract-provider"="5.6.0"' package.json > package.json.tmp + mv package.json.tmp package.json + neutralize_package_lock neutralize_package_json_hooks force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH" force_hardhat_compiler_settings "$config_file" "$(first_word "$SELECTED_PRESETS")" "$config_var" - npm install - npm install hardhat-gas-reporter + # npm@8.3.0+ is required for `overrides` support + npm install npm@>8.3.0 + npx npm install + npx npm install hardhat-gas-reporter + + # Typescript compilation fails with typescript >= 4.7: + # Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective` + npx npm install "typescript@<4.7.0" # With ethers.js 5.6.2 many tests for revert messages fail. # TODO: Remove when https://github.com/ethers-io/ethers.js/discussions/2849 is resolved. - npm install ethers@5.6.1 + npx npm install ethers@5.6.1 # Note that ethers@5.6.1 depends on @ethersproject/contracts@5.6.0 while the dependency on hardhat-deploy # pulls @ethersproject/contracts@5.6.1 (latest). Force 5.6.0 to avoid errors due to having two copies. - npm install @ethersproject/contracts@5.6.0 + npx npm install @ethersproject/contracts@5.6.0 + + # 2.1.1 started causing failures in safe-contracts external tests after a contract address check was introduced + # in https://github.com/NomicFoundation/hardhat/pull/2916, and so to avoid errors, the package is now pegged. + # TODO: Remove when https://github.com/safe-global/safe-contracts/issues/436 is resolved. + npx npm install @nomiclabs/hardhat-ethers@2.1.0 # Hardhat 2.9.5 introduced a bug with handling padded arguments to getStorageAt(). # TODO: Remove when https://github.com/NomicFoundation/hardhat/issues/2709 is fixed. - npm install hardhat@2.9.4 + npx npm install hardhat@2.9.4 replace_version_pragmas [[ $BINARY_TYPE == solcjs ]] && force_solc_modules "${DIR}/solc/dist" diff --git a/test/externalTests/gp2.sh b/test/externalTests/gp2.sh new file mode 100755 index 000000000..c59d67e08 --- /dev/null +++ b/test/externalTests/gp2.sh @@ -0,0 +1,106 @@ +#!/usr/bin/env bash + +# ------------------------------------------------------------------------------ +# This file is part of solidity. +# +# solidity is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# solidity is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with solidity. If not, see +# +# (c) 2019 solidity contributors. +#------------------------------------------------------------------------------ + +set -e + +source scripts/common.sh +source test/externalTests/common.sh + +REPO_ROOT=$(realpath "$(dirname "$0")/../..") + +verify_input "$@" +BINARY_TYPE="$1" +BINARY_PATH="$(realpath "$2")" +SELECTED_PRESETS="$3" + +function compile_fn { npm run build; } +function test_fn { npm test; } + +function gp2_test +{ + local repo="https://github.com/gnosis/gp-v2-contracts.git" + local ref_type=branch + local ref=main + local config_file="hardhat.config.ts" + local config_var="config" + + local compile_only_presets=( + legacy-no-optimize # Tests doing `new GPv2VaultRelayer` fail with "Error: Transaction reverted: trying to deploy a contract whose code is too large" + ) + local settings_presets=( + "${compile_only_presets[@]}" + #ir-no-optimize # Compilation fails with "YulException: Variable var_amount_1468 is 10 slot(s) too deep inside the stack." + #ir-no-optimize # Compilation fails with "YulException: Variable var_offset_3451 is 1 slot(s) too deep inside the stack." + ir-optimize-evm+yul + legacy-optimize-evm-only + legacy-optimize-evm+yul + ) + + [[ $SELECTED_PRESETS != "" ]] || SELECTED_PRESETS=$(circleci_select_steps_multiarg "${settings_presets[@]}") + print_presets_or_exit "$SELECTED_PRESETS" + + setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH" + download_project "$repo" "$ref_type" "$ref" "$DIR" + [[ $BINARY_TYPE == native ]] && replace_global_solc "$BINARY_PATH" + + neutralize_package_lock + neutralize_package_json_hooks + name_hardhat_default_export "$config_file" "$config_var" + force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH" + force_hardhat_compiler_settings "$config_file" "$(first_word "$SELECTED_PRESETS")" "$config_var" + force_hardhat_unlimited_contract_size "$config_file" "$config_var" + npm install + + # Some dependencies come with pre-built artifacts. We want to build from scratch. + rm -r node_modules/@gnosis.pm/safe-contracts/build/ + + # FIXME: One of the E2E tests tries to import artifacts from Gnosis Safe. We should rebuild them + # but it's not that easy because @gnosis.pm/safe-contracts does not come with Hardhat config. + rm test/e2e/contractOrdersWithGnosisSafe.test.ts + + # Patch contracts for 0.8.x compatibility. + # NOTE: I'm patching OpenZeppelin as well instead of installing OZ 4.0 because it requires less + # work. The project imports files that were moved to different locations in 4.0. + sed -i 's|uint256(-1)|type(uint256).max|g' src/contracts/GPv2Settlement.sol + sed -i 's|return msg\.sender;|return payable(msg.sender);|g' node_modules/@openzeppelin/contracts/utils/Context.sol + perl -i -0pe \ + "s/uint256 (executedBuyAmount = \(-tokenDeltas\[trade.buyTokenIndex\]\)\n\s+.toUint256\(\);)/uint256 executedBuyAmount; unchecked \{\1\}/g" \ + src/contracts/GPv2Settlement.sol + + # This test is not supposed to work. The compiler is supposed to enforce zero padding since + # at least 0.5.8 (see https://github.com/ethereum/solidity/pull/5815). For some reason the + # test worked on 0.7.6 but no longer works on 0.8.x. + sed -i 's|it\(("invalid EVM transaction encoding does not change order hash"\)|it.skip\1|g' test/GPv2Signing.test.ts + + # Disable tests that won't pass on the ir presets due to Hardhat heuristics. Note that this also disables + # them for other presets but that's fine - we want same code run for benchmarks to be comparable. + # TODO: Remove this when Hardhat adjusts heuristics for IR (https://github.com/nomiclabs/hardhat/issues/2115). + sed -i 's|it\(("should revert when encoding invalid flags"\)|it.skip\1|g' test/GPv2Trade.test.ts + + replace_version_pragmas + + for preset in $SELECTED_PRESETS; do + hardhat_run_test "$config_file" "$preset" "${compile_only_presets[*]}" compile_fn test_fn "$config_var" + store_benchmark_report hardhat gp2 "$repo" "$preset" + done +} + +external_test Gnosis-Protocol-V2 gp2_test diff --git a/test/externalTests/perpetual-pools.sh b/test/externalTests/perpetual-pools.sh index 8f90ed0b4..a389e833f 100755 --- a/test/externalTests/perpetual-pools.sh +++ b/test/externalTests/perpetual-pools.sh @@ -28,7 +28,7 @@ REPO_ROOT=$(realpath "$(dirname "$0")/../..") verify_input "$@" BINARY_TYPE="$1" -BINARY_PATH="$2" +BINARY_PATH="$(realpath "$2")" SELECTED_PRESETS="$3" function compile_fn { yarn build; } @@ -47,7 +47,7 @@ function perpetual_pools_test "${compile_only_presets[@]}" #ir-no-optimize # Compilation fails with "YulException: Variable var_amount_527 is 9 slot(s) too deep inside the stack." #ir-optimize-evm-only # Compilation fails with "YulException: Variable var_amount_527 is 9 slot(s) too deep inside the stack." - #ir-optimize-evm+yul # Compilation fails with "YulException: Variable expr_mpos is 1 too deep in the stack" + ir-optimize-evm+yul legacy-no-optimize legacy-optimize-evm-only legacy-optimize-evm+yul @@ -59,6 +59,12 @@ function perpetual_pools_test setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH" download_project "$repo" "$ref_type" "$ref" "$DIR" + # Disable tests that won't pass on the ir presets due to Hardhat heuristics. Note that this also disables + # them for other presets but that's fine - we want same code run for benchmarks to be comparable. + # TODO: Remove this when Hardhat adjusts heuristics for IR (https://github.com/nomiclabs/hardhat/issues/2115). + sed -i 's|\(it\)\(("Should not allow commits that are too large"\)|\1.skip\2|g' test/PoolCommitter/commit.spec.ts + sed -i 's|\(it\)\(("Should not allow for too many commitments (that bring amount over a user'\''s balance)"\)|\1.skip\2|g' test/PoolCommitter/commit.spec.ts + neutralize_package_lock neutralize_package_json_hooks force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH" diff --git a/test/externalTests/pool-together.sh b/test/externalTests/pool-together.sh index b24cd6f4b..a3461a6b0 100755 --- a/test/externalTests/pool-together.sh +++ b/test/externalTests/pool-together.sh @@ -28,7 +28,7 @@ REPO_ROOT=$(realpath "$(dirname "$0")/../..") verify_input "$@" BINARY_TYPE="$1" -BINARY_PATH="$2" +BINARY_PATH="$(realpath "$2")" SELECTED_PRESETS="$3" function compile_fn { yarn compile; } @@ -59,6 +59,10 @@ function pool_together_test setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH" download_project "$repo" "$ref_type" "$ref" "$DIR" + # TODO: Remove this when https://github.com/NomicFoundation/hardhat/issues/2453 gets fixed. + sed -i "s|it\(('should fail to return value if value passed does not fit in [0-9]\+ bits'\)|it.skip\1|g" test/libraries/ExtendedSafeCast.test.ts + sed -i "s|it\(('should require an rng to be requested'\)|it.skip\1|g" test/DrawBeacon.test.ts + neutralize_package_lock neutralize_package_json_hooks force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH" diff --git a/test/externalTests/prb-math.sh b/test/externalTests/prb-math.sh index 1d0a0dd86..ffa2b7c01 100755 --- a/test/externalTests/prb-math.sh +++ b/test/externalTests/prb-math.sh @@ -28,7 +28,7 @@ REPO_ROOT=$(realpath "$(dirname "$0")/../..") verify_input "$@" BINARY_TYPE="$1" -BINARY_PATH="$2" +BINARY_PATH="$(realpath "$2")" SELECTED_PRESETS="$3" function compile_fn { yarn compile; } diff --git a/test/externalTests/trident.sh b/test/externalTests/trident.sh index 6c1f56fbb..401446f99 100755 --- a/test/externalTests/trident.sh +++ b/test/externalTests/trident.sh @@ -28,7 +28,7 @@ REPO_ROOT=$(realpath "$(dirname "$0")/../..") verify_input "$@" BINARY_TYPE="$1" -BINARY_PATH="$2" +BINARY_PATH="$(realpath "$2")" SELECTED_PRESETS="$3" function compile_fn { yarn build; } @@ -89,6 +89,9 @@ function trident_test sed -i 's|IStrategy(0)|IStrategy(address(0))|g' contracts/flat/BentoBoxV1Flat.sol find contracts -name "*.sol" -exec sed -i -e 's/^\(\s*\)\(assembly\)/\1\/\/\/ @solidity memory-safe-assembly\n\1\2/' '{}' \; + # TODO: Remove this when https://github.com/NomicFoundation/hardhat/issues/2453 gets fixed. + sed -i 's|it\(("Reverts on direct deployment via factory"\)|it.skip\1|g' test/MasterDeployer.test.ts + # @sushiswap/core package contains contracts that get built with 0.6.12 and fail our compiler # version check. It's not used by tests so we can remove it. rm -r node_modules/@sushiswap/core/ diff --git a/test/externalTests/uniswap.sh b/test/externalTests/uniswap.sh index efea480b6..5da068df8 100755 --- a/test/externalTests/uniswap.sh +++ b/test/externalTests/uniswap.sh @@ -28,7 +28,7 @@ REPO_ROOT=$(realpath "$(dirname "$0")/../..") verify_input "$@" BINARY_TYPE="$1" -BINARY_PATH="$2" +BINARY_PATH="$(realpath "$2")" SELECTED_PRESETS="$3" function compile_fn { yarn compile; } @@ -47,7 +47,7 @@ function uniswap_test "${compile_only_presets[@]}" #ir-no-optimize # Compilation fails with: "YulException: Variable ret_0 is 1 slot(s) too deep inside the stack." #ir-optimize-evm-only # Compilation fails with: "YulException: Variable ret_0 is 1 slot(s) too deep inside the stack." - #ir-optimize-evm+yul # Compilation fails with: "YulException: Variable var_slot0Start_mpos is 1 too deep in the stack" + ir-optimize-evm+yul legacy-no-optimize legacy-optimize-evm-only legacy-optimize-evm+yul @@ -59,6 +59,18 @@ function uniswap_test setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH" download_project "$repo" "$ref_type" "$ref" "$DIR" + # Disable tests that won't pass on the ir presets due to Hardhat heuristics. Note that this also disables + # them for other presets but that's fine - we want same code run for benchmarks to be comparable. + # TODO: Remove this when https://github.com/NomicFoundation/hardhat/issues/2115 gets fixed. + sed -i "s|it\(('underpay zero for one and exact in',\)|it.skip\1|g" test/UniswapV3Pool.spec.ts + sed -i "s|it\(('pay in the wrong token zero for one and exact in',\)|it.skip\1|g" test/UniswapV3Pool.spec.ts + sed -i "s|it\(('underpay zero for one and exact out',\)|it.skip\1|g" test/UniswapV3Pool.spec.ts + sed -i "s|it\(('pay in the wrong token zero for one and exact out',\)|it.skip\1|g" test/UniswapV3Pool.spec.ts + sed -i "s|it\(('underpay one for zero and exact in',\)|it.skip\1|g" test/UniswapV3Pool.spec.ts + sed -i "s|it\(('pay in the wrong token one for zero and exact in',\)|it.skip\1|g" test/UniswapV3Pool.spec.ts + sed -i "s|it\(('underpay one for zero and exact out',\)|it.skip\1|g" test/UniswapV3Pool.spec.ts + sed -i "s|it\(('pay in the wrong token one for zero and exact out',\)|it.skip\1|g" test/UniswapV3Pool.spec.ts + neutralize_package_json_hooks name_hardhat_default_export "$config_file" "$config_var" force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH" diff --git a/test/externalTests/yield-liquidator.sh b/test/externalTests/yield-liquidator.sh index bf2ea93e2..d2afe2560 100755 --- a/test/externalTests/yield-liquidator.sh +++ b/test/externalTests/yield-liquidator.sh @@ -28,7 +28,7 @@ REPO_ROOT=$(realpath "$(dirname "$0")/../..") verify_input "$@" BINARY_TYPE="$1" -BINARY_PATH="$2" +BINARY_PATH="$(realpath "$2")" SELECTED_PRESETS="$3" function compile_fn { npm run build; } diff --git a/test/externalTests/zeppelin.sh b/test/externalTests/zeppelin.sh index ccbf7595a..8d73ad1d2 100755 --- a/test/externalTests/zeppelin.sh +++ b/test/externalTests/zeppelin.sh @@ -19,6 +19,9 @@ # (c) 2019 solidity contributors. #------------------------------------------------------------------------------ +# Disable shellcheck errors on quoted special chars like backticks. Too many false-positives. +# shellcheck disable=SC2016 + set -e source scripts/common.sh @@ -28,7 +31,7 @@ REPO_ROOT=$(realpath "$(dirname "$0")/../..") verify_input "$@" BINARY_TYPE="$1" -BINARY_PATH="$2" +BINARY_PATH="$(realpath "$2")" SELECTED_PRESETS="$3" function compile_fn { npm run compile; } @@ -67,11 +70,66 @@ function zeppelin_test sed -i "s|it(\('reverts \)|it.skip(\1|g" structs/EnumerableSet.behavior.js popd + # In some cases Hardhat does not detect revert reasons properly via IR. # TODO: Remove this when https://github.com/NomicFoundation/hardhat/issues/2453 gets fixed. sed -i "s|it(\('reverts if the current value is 0'\)|it.skip(\1|g" test/utils/Counters.test.js + sed -i "s|it(\('prevent unauthorized maintenance'\)|it.skip(\1|g" test/governance/TimelockController.test.js + sed -i "s|it(\('cannot cancel invalid operation'\)|it.skip(\1|g" test/governance/TimelockController.test.js + sed -i "s|it(\('reverts if block number >= current block'\)|it.skip(\1|g" test/governance/utils/Votes.test.js + sed -i "s|it(\('reverts if block number >= current block'\)|it.skip(\1|g" test/governance/utils/Votes.behavior.js + sed -i "s|it(\('cannot call onlyInitializable function outside the scope of an initializable function'\)|it.skip(\1|g" test/proxy/utils/Initializable.test.js + sed -i "s|it(\('other accounts cannot unpause'\)|it.skip(\1|g" test/token/ERC20/presets/ERC20PresetMinterPauser.test.js + sed -i "s|it(\('other accounts cannot unpause'\)|it.skip(\1|g" test/token/ERC1155/presets/ERC1155PresetMinterPauser.test.js + sed -i "s|it(\('other accounts cannot pause'\)|it.skip(\1|g" test/token/ERC20/presets/ERC20PresetMinterPauser.test.js + sed -i "s|it(\('other accounts cannot pause'\)|it.skip(\1|g" test/token/ERC1155/presets/ERC1155PresetMinterPauser.test.js + sed -i "s|it(\('reverts when decreasing the allowance'\)|it.skip(\1|g" test/token/ERC20/utils/SafeERC20.test.js + sed -i "s|it(\('reverts when decreasing the allowance to a negative value'\)|it.skip(\1|g" test/token/ERC20/utils/SafeERC20.test.js + sed -i "s|it(\('cannot be released before time limit'\)|it.skip(\1|g" test/token/ERC20/utils/TokenTimelock.test.js + sed -i "s|it(\('cannot be released just before time limit'\)|it.skip(\1|g" test/token/ERC20/utils/TokenTimelock.test.js + sed -i "s|it(\('reverts when sending non-zero amounts'\)|it.skip(\1|g" test/utils/Address.test.js + sed -i "s|it(\('reverts when sending more than the balance'\)|it.skip(\1|g" test/utils/Address.test.js + sed -i "s|it(\('reverts if block number >= current block'\)|it.skip(\1|g" test/utils/Checkpoints.test.js + sed -i "s|it(\('fails deploying a contract if the bytecode length is zero'\)|it.skip(\1|g" test/utils/Create2.test.js + sed -i "s|it(\('fails deploying a contract if factory contract does not have sufficient balance'\)|it.skip(\1|g" test/utils/Create2.test.js + sed -i "s|it(\('reverts on withdrawals'\)|it.skip(\1|g" test/utils/escrow/ConditionalEscrow.test.js + sed -i "s|it(\('does not allow beneficiary withdrawal'\)|it.skip(\1|g" test/utils/escrow/RefundEscrow.test.js + sed -i "s|it(\('rejects deposits'\)|it.skip(\1|g" test/utils/escrow/RefundEscrow.test.js + sed -i "s|it(\('does not allow 0xffffffff'\)|it.skip(\1|g" test/utils/introspection/ERC165Storage.test.js + sed -i "s|it(\('reverts when casting -1'\)|it.skip(\1|g" test/utils/math/SafeCast.test.js + sed -i 's|it(\(`reverts when downcasting 2^\${bits} (\${maxValue.addn(1)})`\)|it.skip(\1|g' test/utils/math/SafeCast.test.js + sed -i 's|it(\(`reverts when downcasting 2^\${bits} + 1 (\${maxValue.addn(2)})`\)|it.skip(\1|g' test/utils/math/SafeCast.test.js + sed -i 's|it(\(`reverts when casting [^`]\+`\)|it.skip(\1|g' test/utils/math/SafeCast.test.js + sed -i "s|it(\('missing value'\)|it.skip(\1|g" test/utils/structs/EnumerableMap.behavior.js + sed -i "s|it(\('reverts when queried for non existent token id'\)|it.skip(\1|g" test/token/ERC721/ERC721.behavior.js + sed -i "s|it(\('reverts if index is greater than supply'\)|it.skip(\1|g" test/token/ERC721/ERC721.behavior.js + sed -i "s|it(\('burns all tokens'\)|it.skip(\1|g" test/token/ERC721/ERC721.behavior.js + sed -i "s|it(\('other accounts cannot pause'\)|it.skip(\1|g" test/token/ERC721/presets/ERC721PresetMinterPauserAutoId.test.js + sed -i "s|it(\('other accounts cannot unpause'\)|it.skip(\1|g" test/token/ERC721/presets/ERC721PresetMinterPauserAutoId.test.js + sed -i "s|it(\('prevents initialization'\)|it.skip(\1|g" test/proxy/utils/Initializable.test.js + sed -i "s|it(\('divide by 0'\)|it.skip(\1|g" test/utils/math/Math.test.js + # CAUTION:: The following two sed commands depend on the order of occurrence of the relevant patterns in the mentioned files. + # Could result in an error in the future. + sed -zi "s|it(\('deposit'\)|it.skip(\1|3" test/token/ERC20/extensions/ERC4626.test.js + sed -zi "s|it(\('withdraw'\)|it.skip(\1|3" test/token/ERC20/extensions/ERC4626.test.js + + # Here only the testToInt(248) and testToInt(256) cases fail so change the loop range to skip them + sed -i "s|range(8, 256, 8)\(.forEach(bits => testToInt(bits));\)|range(8, 240, 8)\1|" test/utils/math/SafeCast.test.js + + + # TODO: Remove this when https://github.com/NomicFoundation/hardhat/issues/2115 gets fixed. sed -i "s|describe\(('Polygon-Child'\)|describe.skip\1|g" test/crosschain/CrossChainEnabled.test.js + sed -i "s|it(\('revert with invalid multi proof #2'\)|it.skip(\1|g" test/utils/cryptography/MerkleProof.test.js + sed -i "s|describe(\('to a receiver contract that panics'\)|describe.skip(\1|g" test/token/ERC721/ERC721.behavior.js + sed -i "s|context(\('to a receiver contract that panics'\)|context.skip(\1|g" test/token/ERC721/ERC721.behavior.js + sed -i "s|describe(\('to a contract that does not implement the required function'\)|describe.skip(\1|g" test/token/ERC721/ERC721.behavior.js + sed -i "s|context(\('to a contract that does not implement the required function'\)|context.skip(\1|g" test/token/ERC721/ERC721.behavior.js + sed -i "s|it(\('reverts when the called function throws'\)|it.skip(\1|g" test/utils/Address.test.js + sed -i "s|it(\('reverts when function does not exist'\)|it.skip(\1|g" test/utils/Address.test.js + sed -i "s|it(\('reverting initialization'\)|it.skip(\1|g" test/proxy/beacon/BeaconProxy.test.js + sed -i "s|describe(\('reverting initialization'\)|describe.skip(\1|g" test/proxy/Proxy.behaviour.js + sed -i "s|it(\('does not allow remote callback'\)|it.skip(\1|g" test/security/ReentrancyGuard.test.js neutralize_package_json_hooks force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH" diff --git a/test/formal/checked_int_add.py b/test/formal/checked_int_add.py index 43368a98d..c83ff6056 100644 --- a/test/formal/checked_int_add.py +++ b/test/formal/checked_int_add.py @@ -1,4 +1,4 @@ -from opcodes import AND, ISZERO, SGT, SLT, SUB +from opcodes import AND, ISZERO, SGT, SLT, ADD from rule import Rule from util import BVSignedMax, BVSignedMin, BVSignedUpCast from z3 import BitVec, BVAddNoOverflow, BVAddNoUnderflow, Not @@ -25,16 +25,21 @@ while type_bits <= n_bits: # cast to full n_bits values X = BVSignedUpCast(X_short, n_bits) Y = BVSignedUpCast(Y_short, n_bits) + sum_ = ADD(X, Y) # Constants maxValue = BVSignedMax(type_bits, n_bits) minValue = BVSignedMin(type_bits, n_bits) # Overflow and underflow checks in YulUtilFunction::overflowCheckedIntAddFunction - overflow_check = AND(ISZERO(SLT(X, 0)), SGT(Y, SUB(maxValue, X))) - underflow_check = AND(SLT(X, 0), SLT(Y, SUB(minValue, X))) + if type_bits == 256: + overflow_check = AND(ISZERO(SLT(X, 0)), SLT(sum_, Y)) + underflow_check = AND(SLT(X, 0), ISZERO(SLT(sum_, Y))) + else: + overflow_check = SGT(sum_, maxValue) + underflow_check = SLT(sum_, minValue) + + type_bits += 8 rule.check(actual_overflow, overflow_check != 0) rule.check(actual_underflow, underflow_check != 0) - - type_bits *= 2 diff --git a/test/formal/checked_int_mul_12.py b/test/formal/checked_int_mul_12.py new file mode 100644 index 000000000..ea13f0194 --- /dev/null +++ b/test/formal/checked_int_mul_12.py @@ -0,0 +1,46 @@ +from opcodes import AND, SDIV, MUL, EQ, ISZERO, OR, SLT +from rule import Rule +from util import BVSignedUpCast, BVSignedMin, BVSignedCleanupFunction +from z3 import BVMulNoOverflow, BVMulNoUnderflow, BitVec, Not, Or + +""" +Overflow checked signed integer multiplication. +""" + +# Approximation with 16-bit base types. +n_bits = 12 + +for type_bits in [4, 6, 8, 12]: + + rule = Rule() + + # Input vars + X_short = BitVec('X', type_bits) + Y_short = BitVec('Y', type_bits) + + # Z3's overflow and underflow conditions + actual_overflow = Not(BVMulNoOverflow(X_short, Y_short, True)) + actual_underflow = Not(BVMulNoUnderflow(X_short, Y_short)) + + # cast to full n_bits values + X = BVSignedUpCast(X_short, n_bits) + Y = BVSignedUpCast(Y_short, n_bits) + product_raw = MUL(X, Y) + #remove any overflown bits + product = BVSignedCleanupFunction(product_raw, type_bits) + + # Constants + min_value = BVSignedMin(type_bits, n_bits) + + # Overflow and underflow checks in YulUtilFunction::overflowCheckedIntMulFunction + if type_bits > n_bits / 2: + sol_overflow_check_1 = ISZERO(OR(ISZERO(X), EQ(Y, SDIV(product, X)))) + if type_bits == n_bits: + sol_overflow_check_2 = AND(SLT(X, 0), EQ(Y, min_value)) + sol_overflow_check = Or(sol_overflow_check_1 != 0, sol_overflow_check_2 != 0) + else: + sol_overflow_check = (sol_overflow_check_1 != 0) + else: + sol_overflow_check = (ISZERO(EQ(product, product_raw)) != 0) + + rule.check(Or(actual_overflow, actual_underflow), sol_overflow_check) diff --git a/test/formal/checked_int_mul_16.py b/test/formal/checked_int_mul_16.py deleted file mode 100644 index b2f9eb852..000000000 --- a/test/formal/checked_int_mul_16.py +++ /dev/null @@ -1,43 +0,0 @@ -from opcodes import AND, DIV, GT, SDIV, SGT, SLT -from rule import Rule -from util import BVSignedMax, BVSignedMin, BVSignedUpCast -from z3 import BVMulNoOverflow, BVMulNoUnderflow, BitVec, Not, Or - -""" -Overflow checked signed integer multiplication. -""" - -# Approximation with 16-bit base types. -n_bits = 16 -type_bits = 8 - -while type_bits <= n_bits: - - rule = Rule() - - # Input vars - X_short = BitVec('X', type_bits) - Y_short = BitVec('Y', type_bits) - - # Z3's overflow and underflow conditions - actual_overflow = Not(BVMulNoOverflow(X_short, Y_short, True)) - actual_underflow = Not(BVMulNoUnderflow(X_short, Y_short)) - - # cast to full n_bits values - X = BVSignedUpCast(X_short, n_bits) - Y = BVSignedUpCast(Y_short, n_bits) - - # Constants - maxValue = BVSignedMax(type_bits, n_bits) - minValue = BVSignedMin(type_bits, n_bits) - - # Overflow and underflow checks in YulUtilFunction::overflowCheckedIntMulFunction - overflow_check_1 = AND(AND(SGT(X, 0), SGT(Y, 0)), GT(X, DIV(maxValue, Y))) - underflow_check_1 = AND(AND(SGT(X, 0), SLT(Y, 0)), SLT(Y, SDIV(minValue, X))) - underflow_check_2 = AND(AND(SLT(X, 0), SGT(Y, 0)), SLT(X, SDIV(minValue, Y))) - overflow_check_2 = AND(AND(SLT(X, 0), SLT(Y, 0)), SLT(X, SDIV(maxValue, Y))) - - rule.check(actual_overflow, Or(overflow_check_1 != 0, overflow_check_2 != 0)) - rule.check(actual_underflow, Or(underflow_check_1 != 0, underflow_check_2 != 0)) - - type_bits *= 2 diff --git a/test/formal/checked_int_sub.py b/test/formal/checked_int_sub.py index ed292bbe0..aafd46d53 100644 --- a/test/formal/checked_int_sub.py +++ b/test/formal/checked_int_sub.py @@ -1,4 +1,4 @@ -from opcodes import AND, ADD, ISZERO, SLT, SGT +from opcodes import AND, ISZERO, SLT, SGT, SUB from rule import Rule from util import BVSignedMax, BVSignedMin, BVSignedUpCast from z3 import BitVec, BVSubNoOverflow, BVSubNoUnderflow, Not @@ -25,16 +25,21 @@ while type_bits <= n_bits: # cast to full n_bits values X = BVSignedUpCast(X_short, n_bits) Y = BVSignedUpCast(Y_short, n_bits) + diff = SUB(X, Y) # Constants maxValue = BVSignedMax(type_bits, n_bits) minValue = BVSignedMin(type_bits, n_bits) # Overflow and underflow checks in YulUtilFunction::overflowCheckedIntSubFunction - underflow_check = AND(ISZERO(SLT(Y, 0)), SLT(X, ADD(minValue, Y))) - overflow_check = AND(SLT(Y, 0), SGT(X, ADD(maxValue, Y))) + if type_bits == 256: + underflow_check = AND(ISZERO(SLT(Y, 0)), SGT(diff, X)) + overflow_check = AND(SLT(Y, 0), SLT(diff, X)) + else: + underflow_check = SLT(diff, minValue) + overflow_check = SGT(diff, maxValue) + + type_bits += 8 rule.check(actual_underflow, underflow_check != 0) rule.check(actual_overflow, overflow_check != 0) - - type_bits *= 2 diff --git a/test/formal/checked_uint_add.py b/test/formal/checked_uint_add.py index e38b4dcdb..45b242833 100644 --- a/test/formal/checked_uint_add.py +++ b/test/formal/checked_uint_add.py @@ -1,4 +1,4 @@ -from opcodes import GT, SUB +from opcodes import GT, ADD from rule import Rule from util import BVUnsignedMax, BVUnsignedUpCast from z3 import BitVec, BVAddNoOverflow, Not @@ -24,13 +24,17 @@ while type_bits <= n_bits: # cast to full n_bits values X = BVUnsignedUpCast(X_short, n_bits) Y = BVUnsignedUpCast(Y_short, n_bits) + sum_ = ADD(X, Y) # Constants maxValue = BVUnsignedMax(type_bits, n_bits) # Overflow check in YulUtilFunction::overflowCheckedIntAddFunction - overflow_check = GT(X, SUB(maxValue, Y)) + if type_bits == 256: + overflow_check = GT(X, sum_) + else: + overflow_check = GT(sum_, maxValue) + + type_bits += 8 rule.check(overflow_check != 0, actual_overflow) - - type_bits *= 2 diff --git a/test/formal/checked_uint_mul_16.py b/test/formal/checked_uint_mul_12.py similarity index 58% rename from test/formal/checked_uint_mul_16.py rename to test/formal/checked_uint_mul_12.py index 1c60de47b..a386fcfa4 100644 --- a/test/formal/checked_uint_mul_16.py +++ b/test/formal/checked_uint_mul_12.py @@ -1,6 +1,6 @@ -from opcodes import AND, ISZERO, GT, DIV +from opcodes import ISZERO, DIV, MUL, EQ, OR from rule import Rule -from util import BVUnsignedUpCast, BVUnsignedMax +from util import BVUnsignedUpCast, BVUnsignedCleanupFunction from z3 import BitVec, Not, BVMulNoOverflow """ @@ -8,10 +8,9 @@ Overflow checked unsigned integer multiplication. """ # Approximation with 16-bit base types. -n_bits = 16 -type_bits = 8 +n_bits = 12 -while type_bits <= n_bits: +for type_bits in [4, 6, 8, 12]: rule = Rule() @@ -25,13 +24,14 @@ while type_bits <= n_bits: # cast to full n_bits values X = BVUnsignedUpCast(X_short, n_bits) Y = BVUnsignedUpCast(Y_short, n_bits) + product_raw = MUL(X, Y) + #remove any overflown bits + product = BVUnsignedCleanupFunction(product_raw, type_bits) - # Constants - maxValue = BVUnsignedMax(type_bits, n_bits) - - # Overflow check in YulUtilFunction::overflowCheckedIntMulFunction - overflow_check = AND(ISZERO(ISZERO(X)), GT(Y, DIV(maxValue, X))) + # Overflow check in YulUtilFunction::overflowCheckedIntMulFunctions + if type_bits > n_bits / 2: + overflow_check = ISZERO(OR(ISZERO(X), EQ(Y, DIV(product, X)))) + else: + overflow_check = ISZERO(EQ(product, product_raw)) rule.check(overflow_check != 0, actual_overflow) - - type_bits *= 2 diff --git a/test/formal/checked_uint_sub.py b/test/formal/checked_uint_sub.py index 65bcf74a4..40a72686e 100644 --- a/test/formal/checked_uint_sub.py +++ b/test/formal/checked_uint_sub.py @@ -1,4 +1,4 @@ -from opcodes import LT +from opcodes import SUB, GT from rule import Rule from util import BVUnsignedMax, BVUnsignedUpCast from z3 import BVSubNoUnderflow, BitVec, Not @@ -24,13 +24,17 @@ while type_bits <= n_bits: # cast to full n_bits values X = BVUnsignedUpCast(X_short, n_bits) Y = BVUnsignedUpCast(Y_short, n_bits) + diff = SUB(X, Y) # Constants maxValue = BVUnsignedMax(type_bits, n_bits) # Overflow check in YulUtilFunction::overflowCheckedIntSubFunction - overflow_check = LT(X, Y) + if type_bits == 256: + overflow_check = GT(diff, X) + else: + overflow_check = GT(diff, maxValue) + + type_bits += 8 rule.check(overflow_check != 0, actual_overflow) - - type_bits *= 2 diff --git a/test/formal/mod_add_to_addmod.py b/test/formal/mod_add_to_addmod.py new file mode 100644 index 000000000..60093b7fe --- /dev/null +++ b/test/formal/mod_add_to_addmod.py @@ -0,0 +1,31 @@ +from opcodes import MOD, ADD, ADDMOD +from rule import Rule +from z3 import BitVec + +""" +Rule: +MOD(ADD(X, Y), A) -> ADDMOD(X, Y, A) +given + A > 0 + A & (A - 1) == 0 +""" + +rule = Rule() + +n_bits = 32 + +# Input vars +X = BitVec('X', n_bits) +Y = BitVec('Y', n_bits) +A = BitVec('A', n_bits) + +# Non optimized result +nonopt = MOD(ADD(X, Y), A) + +# Optimized result +opt = ADDMOD(X, Y, A) + +rule.require(A > 0) +rule.require(((A & (A - 1)) == 0)) + +rule.check(nonopt, opt) diff --git a/test/formal/mod_mul_to_mulmod.py b/test/formal/mod_mul_to_mulmod.py new file mode 100644 index 000000000..812f341ea --- /dev/null +++ b/test/formal/mod_mul_to_mulmod.py @@ -0,0 +1,31 @@ +from opcodes import MOD, MUL, MULMOD +from rule import Rule +from z3 import BitVec + +""" +Rule: +MOD(MUL(X, Y), A) -> MULMOD(X, Y, A) +given + A > 0 + A & (A - 1) == 0 +""" + +rule = Rule() + +n_bits = 8 + +# Input vars +X = BitVec('X', n_bits) +Y = BitVec('Y', n_bits) +A = BitVec('A', n_bits) + +# Non optimized result +nonopt = MOD(MUL(X, Y), A) + +# Optimized result +opt = MULMOD(X, Y, A) + +rule.require(A > 0) +rule.require(((A & (A - 1)) == 0)) + +rule.check(nonopt, opt) diff --git a/test/formal/opcodes.py b/test/formal/opcodes.py index 103e57a14..e091e7847 100644 --- a/test/formal/opcodes.py +++ b/test/formal/opcodes.py @@ -1,4 +1,4 @@ -from z3 import BitVecVal, BV2Int, If, LShR, UDiv, ULT, UGT, URem +from z3 import BitVecVal, BV2Int, If, LShR, UDiv, ULT, UGT, URem, ZeroExt, Extract def ADD(x, y): return x + y @@ -18,6 +18,12 @@ def SDIV(x, y): def MOD(x, y): return If(y == 0, 0, URem(x, y)) +def MULMOD(x, y, m): + return If(m == 0, 0, Extract(x.size() - 1, 0, URem(ZeroExt(x.size(), x) * ZeroExt(x.size(), y), ZeroExt(m.size(), m)))) + +def ADDMOD(x, y, m): + return If(m == 0, 0, Extract(x.size() - 1, 0, URem(ZeroExt(1, x) + ZeroExt(1, y), ZeroExt(1, m)))) + def SMOD(x, y): return If(y == 0, 0, x % y) diff --git a/test/formal/signed_integer_cleanup_function.py b/test/formal/signed_integer_cleanup_function.py new file mode 100644 index 000000000..2b7b0e440 --- /dev/null +++ b/test/formal/signed_integer_cleanup_function.py @@ -0,0 +1,41 @@ +from opcodes import SIGNEXTEND +from rule import Rule +from util import BVSignedCleanupFunction, BVSignedUpCast +from z3 import BitVec, BitVecVal, Concat + +""" +Overflow checked signed integer multiplication. +""" + +n_bits = 256 + +# Check that YulUtilFunction::cleanupFunction cleanup matches BVSignedCleanupFunction +for type_bits in range(8,256,8): + + rule = Rule() + + # Input vars + X = BitVec('X', n_bits) + arg = BitVecVal(type_bits / 8 - 1, n_bits) + + cleaned_reference = BVSignedCleanupFunction(X, type_bits) + cleaned = SIGNEXTEND(arg, X) + + rule.check(cleaned, cleaned_reference) + + +# Check that BVSignedCleanupFunction properly cleans up values. +for type_bits in range(8,256,8): + + rule = Rule() + + # Input vars + X_short = BitVec('X', type_bits) + dirt = BitVec('dirt', n_bits - type_bits) + + X = BVSignedUpCast(X_short, n_bits) + X_dirty = Concat(dirt, X_short) + X_cleaned = BVSignedCleanupFunction(X_dirty, type_bits) + + + rule.check(X, X_cleaned) diff --git a/test/formal/unsigned_integer_cleanup_function.py b/test/formal/unsigned_integer_cleanup_function.py new file mode 100644 index 000000000..42296f89b --- /dev/null +++ b/test/formal/unsigned_integer_cleanup_function.py @@ -0,0 +1,40 @@ +from opcodes import AND +from rule import Rule +from util import BVUnsignedCleanupFunction, BVUnsignedUpCast +from z3 import BitVec, BitVecVal, Concat + +""" +Overflow checked unsigned integer multiplication. +""" + +n_bits = 256 + +# Check that YulUtilFunction::cleanupFunction cleanup matches BVUnsignedCleanupFunction +for type_bits in range(8,256,8): + + rule = Rule() + + # Input vars + X = BitVec('X', n_bits) + mask = BitVecVal((1 << type_bits) - 1, n_bits) + + cleaned_reference = BVUnsignedCleanupFunction(X, type_bits) + cleaned = AND(X, mask) + + rule.check(cleaned, cleaned_reference) + +# Check that BVUnsignedCleanupFunction properly cleans up values. +for type_bits in range(8,256,8): + + rule = Rule() + + # Input vars + X_short = BitVec('X', type_bits) + dirt = BitVec('dirt', n_bits - type_bits) + + X = BVUnsignedUpCast(X_short, n_bits) + X_dirty = Concat(dirt, X_short) + X_cleaned = BVUnsignedCleanupFunction(X_dirty, type_bits) + + + rule.check(X, X_cleaned) diff --git a/test/formal/util.py b/test/formal/util.py index 8d0debbef..8fc261fdc 100644 --- a/test/formal/util.py +++ b/test/formal/util.py @@ -25,3 +25,18 @@ def BVSignedMax(type_bits, n_bits): def BVSignedMin(type_bits, n_bits): assert type_bits <= n_bits return BitVecVal(-(1 << (type_bits - 1)), n_bits) + +def BVSignedCleanupFunction(x, type_bits): + assert x.size() >= type_bits + sign_mask = BitVecVal(1, x.size()) << (type_bits - 1) + bit_mask = (BitVecVal(1, x.size()) << type_bits) - 1 + return If( + x & sign_mask == 0, + x & bit_mask, + x | ~bit_mask + ) + +def BVUnsignedCleanupFunction(x, type_bits): + assert x.size() >= type_bits + bit_mask = (BitVecVal(1, x.size()) << type_bits) - 1 + return x & bit_mask diff --git a/test/libevmasm/Optimiser.cpp b/test/libevmasm/Optimiser.cpp index 44fbde927..6fc3c5a74 100644 --- a/test/libevmasm/Optimiser.cpp +++ b/test/libevmasm/Optimiser.cpp @@ -141,9 +141,9 @@ namespace ControlFlowGraph cfg(output); AssemblyItems optItems; for (BasicBlock const& block: cfg.optimisedBlocks()) - copy(output.begin() + block.begin, output.begin() + block.end, + copy(output.begin() + static_cast(block.begin), output.begin() + static_cast(block.end), back_inserter(optItems)); - output = move(optItems); + output = std::move(optItems); } return output; } @@ -714,10 +714,10 @@ BOOST_AUTO_TEST_CASE(cse_keccak256_twice_same_content_noninterfering_store_in_be Instruction::MSTORE, // m[12] = DUP1 Instruction::DUP12, u256(12 + 32), - Instruction::MSTORE, // does not destoy memory knowledge + Instruction::MSTORE, // does not destroy memory knowledge Instruction::DUP13, u256(128 - 32), - Instruction::MSTORE, // does not destoy memory knowledge + Instruction::MSTORE, // does not destroy memory knowledge u256(0x20), u256(12), Instruction::KECCAK256 // keccak256(m[12..(12+32)]) diff --git a/test/liblangutil/Scanner.cpp b/test/liblangutil/Scanner.cpp index 51d051236..9e196b0f5 100644 --- a/test/liblangutil/Scanner.cpp +++ b/test/liblangutil/Scanner.cpp @@ -123,7 +123,7 @@ BOOST_AUTO_TEST_CASE(string_nonprintable) if (v == '\n' || v == '\v' || v == '\f' || v == '\r') BOOST_CHECK_EQUAL(scanner.currentError(), ScannerError::IllegalStringEndQuote); else - BOOST_CHECK_EQUAL(scanner.currentError(), ScannerError::IllegalCharacterInString); + BOOST_CHECK_EQUAL(scanner.currentError(),ScannerError::UnicodeCharacterInNonUnicodeString); BOOST_CHECK_EQUAL(scanner.currentLiteral(), ""); } } @@ -150,11 +150,11 @@ struct TestScanner { unique_ptr stream; unique_ptr scanner; - explicit TestScanner(string _text) { reset(move(_text)); } + explicit TestScanner(string _text) { reset(std::move(_text)); } void reset(std::string _text) { - stream = make_unique(move(_text), ""); + stream = make_unique(std::move(_text), ""); scanner = make_unique(*stream); } @@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE(trailing_dot_in_numbers) BOOST_AUTO_TEST_CASE(leading_underscore_decimal_is_identifier) { - // Actual error is cought by SyntaxChecker. + // Actual error is caught by SyntaxChecker. CharStream stream("_1.2", ""); Scanner scanner(stream); BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Identifier); @@ -339,7 +339,7 @@ BOOST_AUTO_TEST_CASE(leading_underscore_decimal_is_identifier) BOOST_AUTO_TEST_CASE(leading_underscore_decimal_after_dot_illegal) { - // Actual error is cought by SyntaxChecker. + // Actual error is caught by SyntaxChecker. TestScanner scanner("1._2"); BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); @@ -351,7 +351,7 @@ BOOST_AUTO_TEST_CASE(leading_underscore_decimal_after_dot_illegal) BOOST_AUTO_TEST_CASE(leading_underscore_exp_are_identifier) { - // Actual error is cought by SyntaxChecker. + // Actual error is caught by SyntaxChecker. CharStream stream("_1e2", ""); Scanner scanner(stream); BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Identifier); @@ -360,7 +360,7 @@ BOOST_AUTO_TEST_CASE(leading_underscore_exp_are_identifier) BOOST_AUTO_TEST_CASE(leading_underscore_exp_after_e_illegal) { - // Actual error is cought by SyntaxChecker. + // Actual error is caught by SyntaxChecker. CharStream stream("1e_2", ""); Scanner scanner(stream); BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); @@ -379,7 +379,7 @@ BOOST_AUTO_TEST_CASE(leading_underscore_hex_illegal) BOOST_AUTO_TEST_CASE(fixed_number_invalid_underscore_front) { - // Actual error is cought by SyntaxChecker. + // Actual error is caught by SyntaxChecker. CharStream stream("12._1234_1234", ""); Scanner scanner(stream); BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); @@ -388,7 +388,7 @@ BOOST_AUTO_TEST_CASE(fixed_number_invalid_underscore_front) BOOST_AUTO_TEST_CASE(number_literals_with_trailing_underscore_at_eos) { - // Actual error is cought by SyntaxChecker. + // Actual error is caught by SyntaxChecker. TestScanner scanner("0x123_"); BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); diff --git a/test/libsolidity/ASTJSON/address_payable.json b/test/libsolidity/ASTJSON/address_payable.json index 9aec1e510..cc87fc3b9 100644 --- a/test/libsolidity/ASTJSON/address_payable.json +++ b/test/libsolidity/ASTJSON/address_payable.json @@ -320,6 +320,7 @@ "isPure": false, "kind": "typeConversion", "lValueRequested": false, + "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "209:13:1", @@ -445,6 +446,7 @@ "isPure": true, "kind": "typeConversion", "lValueRequested": false, + "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "239:10:1", diff --git a/test/libsolidity/ASTJSON/address_payable_parseOnly.json b/test/libsolidity/ASTJSON/address_payable_parseOnly.json index 39e91de1c..fd7f772f6 100644 --- a/test/libsolidity/ASTJSON/address_payable_parseOnly.json +++ b/test/libsolidity/ASTJSON/address_payable_parseOnly.json @@ -210,6 +210,7 @@ } }, "id": 26, + "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "209:13:1", @@ -281,6 +282,7 @@ } }, "id": 34, + "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "239:10:1", diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset.json b/test/libsolidity/ASTJSON/assembly/slot_offset.json index cc22c76e8..1e6fe1447 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset.json +++ b/test/libsolidity/ASTJSON/assembly/slot_offset.json @@ -95,6 +95,10 @@ { "id": 4, "name": "S", + "nameLocations": + [ + "42:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 3, "src": "42:1:1" diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset_parseOnly.json b/test/libsolidity/ASTJSON/assembly/slot_offset_parseOnly.json index 6407e4519..4135bb343 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/slot_offset_parseOnly.json @@ -66,6 +66,10 @@ { "id": 4, "name": "S", + "nameLocations": + [ + "42:1:1" + ], "nodeType": "IdentifierPath", "src": "42:1:1" }, diff --git a/test/libsolidity/ASTJSON/base_constructor_call.json b/test/libsolidity/ASTJSON/base_constructor_call.json index bfbd716da..774981fa9 100644 --- a/test/libsolidity/ASTJSON/base_constructor_call.json +++ b/test/libsolidity/ASTJSON/base_constructor_call.json @@ -113,6 +113,10 @@ { "id": 8, "name": "A", + "nameLocations": + [ + "50:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 7, "src": "50:1:1" @@ -177,6 +181,10 @@ { "id": 11, "name": "A", + "nameLocations": + [ + "68:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 7, "src": "68:1:1" diff --git a/test/libsolidity/ASTJSON/base_constructor_call_parseOnly.json b/test/libsolidity/ASTJSON/base_constructor_call_parseOnly.json index bd101b9b8..8af0c0b2c 100644 --- a/test/libsolidity/ASTJSON/base_constructor_call_parseOnly.json +++ b/test/libsolidity/ASTJSON/base_constructor_call_parseOnly.json @@ -84,6 +84,10 @@ { "id": 8, "name": "A", + "nameLocations": + [ + "50:1:1" + ], "nodeType": "IdentifierPath", "src": "50:1:1" }, @@ -131,6 +135,10 @@ { "id": 11, "name": "A", + "nameLocations": + [ + "68:1:1" + ], "nodeType": "IdentifierPath", "src": "68:1:1" }, diff --git a/test/libsolidity/ASTJSON/contract_dep_order.json b/test/libsolidity/ASTJSON/contract_dep_order.json index 754e14f4d..83865d7d4 100644 --- a/test/libsolidity/ASTJSON/contract_dep_order.json +++ b/test/libsolidity/ASTJSON/contract_dep_order.json @@ -56,6 +56,10 @@ { "id": 2, "name": "A", + "nameLocations": + [ + "29:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 1, "src": "29:1:1" @@ -92,6 +96,10 @@ { "id": 5, "name": "B", + "nameLocations": + [ + "49:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 4, "src": "49:1:1" @@ -129,6 +137,10 @@ { "id": 8, "name": "C", + "nameLocations": + [ + "69:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 7, "src": "69:1:1" @@ -167,6 +179,10 @@ { "id": 11, "name": "D", + "nameLocations": + [ + "89:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 10, "src": "89:1:1" diff --git a/test/libsolidity/ASTJSON/contract_dep_order_parseOnly.json b/test/libsolidity/ASTJSON/contract_dep_order_parseOnly.json index 5fe9bb195..2c8bdc745 100644 --- a/test/libsolidity/ASTJSON/contract_dep_order_parseOnly.json +++ b/test/libsolidity/ASTJSON/contract_dep_order_parseOnly.json @@ -26,6 +26,10 @@ { "id": 2, "name": "A", + "nameLocations": + [ + "29:1:1" + ], "nodeType": "IdentifierPath", "src": "29:1:1" }, @@ -53,6 +57,10 @@ { "id": 5, "name": "B", + "nameLocations": + [ + "49:1:1" + ], "nodeType": "IdentifierPath", "src": "49:1:1" }, @@ -80,6 +88,10 @@ { "id": 8, "name": "C", + "nameLocations": + [ + "69:1:1" + ], "nodeType": "IdentifierPath", "src": "69:1:1" }, @@ -107,6 +119,10 @@ { "id": 11, "name": "D", + "nameLocations": + [ + "89:1:1" + ], "nodeType": "IdentifierPath", "src": "89:1:1" }, diff --git a/test/libsolidity/ASTJSON/enum_value_declaration.json b/test/libsolidity/ASTJSON/enum_value_declaration.json index fc8506c2a..acdcc736e 100644 --- a/test/libsolidity/ASTJSON/enum_value_declaration.json +++ b/test/libsolidity/ASTJSON/enum_value_declaration.json @@ -70,6 +70,7 @@ "isLValue": false, "isPure": true, "lValueRequested": false, + "memberLocation": "57:1:1", "memberName": "X", "nodeType": "MemberAccess", "referencedDeclaration": 1, @@ -131,6 +132,10 @@ { "id": 5, "name": "A", + "nameLocations": + [ + "43:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 3, "src": "43:1:1" diff --git a/test/libsolidity/ASTJSON/enum_value_declaration_parseOnly.json b/test/libsolidity/ASTJSON/enum_value_declaration_parseOnly.json index f99b7cb87..8fa574fa7 100644 --- a/test/libsolidity/ASTJSON/enum_value_declaration_parseOnly.json +++ b/test/libsolidity/ASTJSON/enum_value_declaration_parseOnly.json @@ -49,6 +49,7 @@ "typeDescriptions": {} }, "id": 10, + "memberLocation": "57:1:1", "memberName": "X", "nodeType": "MemberAccess", "src": "55:3:1", @@ -99,6 +100,10 @@ { "id": 5, "name": "A", + "nameLocations": + [ + "43:1:1" + ], "nodeType": "IdentifierPath", "src": "43:1:1" }, diff --git a/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json b/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json index a5c7669ef..5368d5862 100644 --- a/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json +++ b/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json @@ -65,6 +65,10 @@ { "id": 4, "name": "S", + "nameLocations": + [ + "50:1:1" + ], "nodeType": "IdentifierPath", "src": "50:1:1" }, @@ -114,6 +118,10 @@ { "id": 13, "name": "error", + "nameLocations": + [ + "95:5:1" + ], "nodeType": "IdentifierPath", "src": "95:5:1" }, @@ -141,6 +149,7 @@ "typeDescriptions": {} }, "id": 18, + "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "117:3:1", @@ -251,6 +260,10 @@ { "id": 8, "name": "E", + "nameLocations": + [ + "72:1:1" + ], "nodeType": "IdentifierPath", "src": "72:1:1" }, diff --git a/test/libsolidity/ASTJSON/inheritance_specifier.json b/test/libsolidity/ASTJSON/inheritance_specifier.json index b74604265..8959d5b5d 100644 --- a/test/libsolidity/ASTJSON/inheritance_specifier.json +++ b/test/libsolidity/ASTJSON/inheritance_specifier.json @@ -44,6 +44,10 @@ { "id": 2, "name": "C1", + "nameLocations": + [ + "30:2:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 1, "src": "30:2:1" diff --git a/test/libsolidity/ASTJSON/inheritance_specifier_parseOnly.json b/test/libsolidity/ASTJSON/inheritance_specifier_parseOnly.json index deddb5224..72da9ad2c 100644 --- a/test/libsolidity/ASTJSON/inheritance_specifier_parseOnly.json +++ b/test/libsolidity/ASTJSON/inheritance_specifier_parseOnly.json @@ -26,6 +26,10 @@ { "id": 2, "name": "C1", + "nameLocations": + [ + "30:2:1" + ], "nodeType": "IdentifierPath", "src": "30:2:1" }, diff --git a/test/libsolidity/ASTJSON/mappings.json b/test/libsolidity/ASTJSON/mappings.json index 16904ec8a..e414b56fa 100644 --- a/test/libsolidity/ASTJSON/mappings.json +++ b/test/libsolidity/ASTJSON/mappings.json @@ -87,6 +87,10 @@ { "id": 5, "name": "C", + "nameLocations": + [ + "48:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 19, "src": "48:1:1" @@ -201,6 +205,10 @@ { "id": 14, "name": "E", + "nameLocations": + [ + "106:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 4, "src": "106:1:1" diff --git a/test/libsolidity/ASTJSON/mappings_parseOnly.json b/test/libsolidity/ASTJSON/mappings_parseOnly.json index 977ee776c..e4f7ee21a 100644 --- a/test/libsolidity/ASTJSON/mappings_parseOnly.json +++ b/test/libsolidity/ASTJSON/mappings_parseOnly.json @@ -68,6 +68,10 @@ { "id": 5, "name": "C", + "nameLocations": + [ + "48:1:1" + ], "nodeType": "IdentifierPath", "src": "48:1:1" }, @@ -146,6 +150,10 @@ { "id": 14, "name": "E", + "nameLocations": + [ + "106:1:1" + ], "nodeType": "IdentifierPath", "src": "106:1:1" }, diff --git a/test/libsolidity/ASTJSON/modifier_definition.json b/test/libsolidity/ASTJSON/modifier_definition.json index 67aa3e1ea..aa448568c 100644 --- a/test/libsolidity/ASTJSON/modifier_definition.json +++ b/test/libsolidity/ASTJSON/modifier_definition.json @@ -131,6 +131,10 @@ { "id": 8, "name": "M", + "nameLocations": + [ + "52:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 6, "src": "52:1:1" diff --git a/test/libsolidity/ASTJSON/modifier_definition_parseOnly.json b/test/libsolidity/ASTJSON/modifier_definition_parseOnly.json index a31b1f240..9344e419a 100644 --- a/test/libsolidity/ASTJSON/modifier_definition_parseOnly.json +++ b/test/libsolidity/ASTJSON/modifier_definition_parseOnly.json @@ -99,6 +99,10 @@ { "id": 8, "name": "M", + "nameLocations": + [ + "52:1:1" + ], "nodeType": "IdentifierPath", "src": "52:1:1" }, diff --git a/test/libsolidity/ASTJSON/modifier_invocation.json b/test/libsolidity/ASTJSON/modifier_invocation.json index 67aa3e1ea..aa448568c 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation.json +++ b/test/libsolidity/ASTJSON/modifier_invocation.json @@ -131,6 +131,10 @@ { "id": 8, "name": "M", + "nameLocations": + [ + "52:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 6, "src": "52:1:1" diff --git a/test/libsolidity/ASTJSON/modifier_invocation_parseOnly.json b/test/libsolidity/ASTJSON/modifier_invocation_parseOnly.json index a31b1f240..9344e419a 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation_parseOnly.json +++ b/test/libsolidity/ASTJSON/modifier_invocation_parseOnly.json @@ -99,6 +99,10 @@ { "id": 8, "name": "M", + "nameLocations": + [ + "52:1:1" + ], "nodeType": "IdentifierPath", "src": "52:1:1" }, diff --git a/test/libsolidity/ASTJSON/non_utf8.json b/test/libsolidity/ASTJSON/non_utf8.json index 0e2a56f84..926f858b5 100644 --- a/test/libsolidity/ASTJSON/non_utf8.json +++ b/test/libsolidity/ASTJSON/non_utf8.json @@ -135,6 +135,7 @@ "isPure": true, "kind": "typeConversion", "lValueRequested": false, + "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "60:14:1", @@ -182,6 +183,7 @@ "isPure": true, "kind": "typeConversion", "lValueRequested": false, + "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "53:22:1", diff --git a/test/libsolidity/ASTJSON/non_utf8_parseOnly.json b/test/libsolidity/ASTJSON/non_utf8_parseOnly.json index df358ae36..ef265cbe4 100644 --- a/test/libsolidity/ASTJSON/non_utf8_parseOnly.json +++ b/test/libsolidity/ASTJSON/non_utf8_parseOnly.json @@ -85,6 +85,7 @@ } }, "id": 10, + "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "60:14:1", @@ -108,6 +109,7 @@ } }, "id": 11, + "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "53:22:1", diff --git a/test/libsolidity/ASTJSON/not_existing_import_parseOnly.json b/test/libsolidity/ASTJSON/not_existing_import_parseOnly.json index a36c59fff..de14043f3 100644 --- a/test/libsolidity/ASTJSON/not_existing_import_parseOnly.json +++ b/test/libsolidity/ASTJSON/not_existing_import_parseOnly.json @@ -23,6 +23,11 @@ { "id": 2, "name": "NotExisting.X", + "nameLocations": + [ + "55:11:1", + "67:1:1" + ], "nodeType": "IdentifierPath", "src": "55:13:1" }, @@ -58,6 +63,11 @@ { "id": 4, "name": "NotExisting.SomeStruct", + "nameLocations": + [ + "72:11:1", + "84:10:1" + ], "nodeType": "IdentifierPath", "src": "72:22:1" }, diff --git a/test/libsolidity/ASTJSON/override.json b/test/libsolidity/ASTJSON/override.json index 639572c54..a7c43767f 100644 --- a/test/libsolidity/ASTJSON/override.json +++ b/test/libsolidity/ASTJSON/override.json @@ -86,6 +86,10 @@ { "id": 6, "name": "A", + "nameLocations": + [ + "72:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 5, "src": "72:1:1" @@ -200,6 +204,10 @@ { "id": 17, "name": "B", + "nameLocations": + [ + "167:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 16, "src": "167:1:1" diff --git a/test/libsolidity/ASTJSON/override_parseOnly.json b/test/libsolidity/ASTJSON/override_parseOnly.json index b092df459..fe9d8a7c6 100644 --- a/test/libsolidity/ASTJSON/override_parseOnly.json +++ b/test/libsolidity/ASTJSON/override_parseOnly.json @@ -62,6 +62,10 @@ { "id": 6, "name": "A", + "nameLocations": + [ + "72:1:1" + ], "nodeType": "IdentifierPath", "src": "72:1:1" }, @@ -159,6 +163,10 @@ { "id": 17, "name": "B", + "nameLocations": + [ + "167:1:1" + ], "nodeType": "IdentifierPath", "src": "167:1:1" }, diff --git a/test/libsolidity/ASTJSON/two_base_functions.json b/test/libsolidity/ASTJSON/two_base_functions.json index 2098b3cd5..23bdf6efe 100644 --- a/test/libsolidity/ASTJSON/two_base_functions.json +++ b/test/libsolidity/ASTJSON/two_base_functions.json @@ -144,6 +144,10 @@ { "id": 11, "name": "A", + "nameLocations": + [ + "114:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 5, "src": "114:1:1" @@ -157,6 +161,10 @@ { "id": 13, "name": "B", + "nameLocations": + [ + "117:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 10, "src": "117:1:1" @@ -212,6 +220,10 @@ { "id": 16, "name": "A", + "nameLocations": + [ + "154:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 5, "src": "154:1:1" @@ -219,6 +231,10 @@ { "id": 17, "name": "B", + "nameLocations": + [ + "157:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 10, "src": "157:1:1" diff --git a/test/libsolidity/ASTJSON/two_base_functions_parseOnly.json b/test/libsolidity/ASTJSON/two_base_functions_parseOnly.json index 7a077e705..078dc5daa 100644 --- a/test/libsolidity/ASTJSON/two_base_functions_parseOnly.json +++ b/test/libsolidity/ASTJSON/two_base_functions_parseOnly.json @@ -111,6 +111,10 @@ { "id": 11, "name": "A", + "nameLocations": + [ + "114:1:1" + ], "nodeType": "IdentifierPath", "src": "114:1:1" }, @@ -123,6 +127,10 @@ { "id": 13, "name": "B", + "nameLocations": + [ + "117:1:1" + ], "nodeType": "IdentifierPath", "src": "117:1:1" }, @@ -163,12 +171,20 @@ { "id": 16, "name": "A", + "nameLocations": + [ + "154:1:1" + ], "nodeType": "IdentifierPath", "src": "154:1:1" }, { "id": 17, "name": "B", + "nameLocations": + [ + "157:1:1" + ], "nodeType": "IdentifierPath", "src": "157:1:1" } diff --git a/test/libsolidity/ASTJSON/used_errors.json b/test/libsolidity/ASTJSON/used_errors.json index f00336d20..c59b4f530 100644 --- a/test/libsolidity/ASTJSON/used_errors.json +++ b/test/libsolidity/ASTJSON/used_errors.json @@ -67,6 +67,7 @@ "isPure": false, "kind": "functionCall", "lValueRequested": false, + "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "38:3:1", @@ -175,6 +176,7 @@ "isPure": false, "kind": "functionCall", "lValueRequested": false, + "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "99:3:1", diff --git a/test/libsolidity/ASTJSON/used_errors_parseOnly.json b/test/libsolidity/ASTJSON/used_errors_parseOnly.json index b7500b445..7a4b24b3c 100644 --- a/test/libsolidity/ASTJSON/used_errors_parseOnly.json +++ b/test/libsolidity/ASTJSON/used_errors_parseOnly.json @@ -40,6 +40,7 @@ "typeDescriptions": {} }, "id": 6, + "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "38:3:1", @@ -125,6 +126,7 @@ "typeDescriptions": {} }, "id": 15, + "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "99:3:1", diff --git a/test/libsolidity/ASTJSON/userDefinedValueType.json b/test/libsolidity/ASTJSON/userDefinedValueType.json index df7aa69c8..17bb19efa 100644 --- a/test/libsolidity/ASTJSON/userDefinedValueType.json +++ b/test/libsolidity/ASTJSON/userDefinedValueType.json @@ -103,6 +103,10 @@ { "id": 7, "name": "MyAddress", + "nameLocations": + [ + "67:9:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 2, "src": "67:9:1" @@ -153,6 +157,10 @@ { "id": 11, "name": "MyUInt", + "nameLocations": + [ + "84:6:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 4, "src": "84:6:1" @@ -287,6 +295,10 @@ { "id": 21, "name": "MyAddress", + "nameLocations": + [ + "177:9:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 18, "src": "177:9:1" @@ -314,6 +326,10 @@ { "id": 23, "name": "MyUInt", + "nameLocations": + [ + "190:6:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 20, "src": "190:6:1" diff --git a/test/libsolidity/ASTJSON/userDefinedValueType_parseOnly.json b/test/libsolidity/ASTJSON/userDefinedValueType_parseOnly.json index 36315b443..3cef5ea47 100644 --- a/test/libsolidity/ASTJSON/userDefinedValueType_parseOnly.json +++ b/test/libsolidity/ASTJSON/userDefinedValueType_parseOnly.json @@ -69,6 +69,10 @@ { "id": 7, "name": "MyAddress", + "nameLocations": + [ + "67:9:1" + ], "nodeType": "IdentifierPath", "src": "67:9:1" }, @@ -108,6 +112,10 @@ { "id": 11, "name": "MyUInt", + "nameLocations": + [ + "84:6:1" + ], "nodeType": "IdentifierPath", "src": "84:6:1" }, @@ -213,6 +221,10 @@ { "id": 21, "name": "MyAddress", + "nameLocations": + [ + "177:9:1" + ], "nodeType": "IdentifierPath", "src": "177:9:1" }, @@ -230,6 +242,10 @@ { "id": 23, "name": "MyUInt", + "nameLocations": + [ + "190:6:1" + ], "nodeType": "IdentifierPath", "src": "190:6:1" }, diff --git a/test/libsolidity/ASTJSON/using_for_directive.json b/test/libsolidity/ASTJSON/using_for_directive.json index c9052b0d7..57658134d 100644 --- a/test/libsolidity/ASTJSON/using_for_directive.json +++ b/test/libsolidity/ASTJSON/using_for_directive.json @@ -27,6 +27,10 @@ { "id": 1, "name": "f", + "nameLocations": + [ + "7:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 10, "src": "7:1:1" @@ -161,6 +165,10 @@ { "id": 11, "name": "L", + "nameLocations": + [ + "72:1:1" + ], "nodeType": "IdentifierPath", "referencedDeclaration": 4, "src": "72:1:1" diff --git a/test/libsolidity/ASTJSON/using_for_directive_parseOnly.json b/test/libsolidity/ASTJSON/using_for_directive_parseOnly.json index d704b4e81..84de310c0 100644 --- a/test/libsolidity/ASTJSON/using_for_directive_parseOnly.json +++ b/test/libsolidity/ASTJSON/using_for_directive_parseOnly.json @@ -12,6 +12,10 @@ { "id": 1, "name": "f", + "nameLocations": + [ + "7:1:1" + ], "nodeType": "IdentifierPath", "src": "7:1:1" } @@ -118,6 +122,10 @@ { "id": 11, "name": "L", + "nameLocations": + [ + "72:1:1" + ], "nodeType": "IdentifierPath", "src": "72:1:1" }, diff --git a/test/libsolidity/ASTJSONTest.cpp b/test/libsolidity/ASTJSONTest.cpp index a509adde6..3602e1485 100644 --- a/test/libsolidity/ASTJSONTest.cpp +++ b/test/libsolidity/ASTJSONTest.cpp @@ -17,7 +17,7 @@ // SPDX-License-Identifier: GPL-3.0 #include -#include +#include #include #include #include @@ -249,7 +249,7 @@ bool ASTJSONTest::runTest( for (size_t i = 0; i < m_sources.size(); i++) { ostringstream result; - ASTJsonConverter(_compiler.state(), _sourceIndices).print(result, _compiler.ast(m_sources[i].first), JsonFormat{ JsonFormat::Pretty }); + ASTJsonExporter(_compiler.state(), _sourceIndices).print(result, _compiler.ast(m_sources[i].first), JsonFormat{ JsonFormat::Pretty }); _variant.result += result.str(); if (i != m_sources.size() - 1) _variant.result += ","; diff --git a/test/libsolidity/GasTest.cpp b/test/libsolidity/GasTest.cpp index fd215cb94..030472e8a 100644 --- a/test/libsolidity/GasTest.cpp +++ b/test/libsolidity/GasTest.cpp @@ -58,7 +58,7 @@ void GasTest::parseExpectations(std::istream& _stream) { string kind = line.substr(3, line.length() - 4); boost::trim(kind); - currentKind = &m_expectations[move(kind)]; + currentKind = &m_expectations[std::move(kind)]; } else if (!currentKind) BOOST_THROW_EXCEPTION(runtime_error("No function kind specified. Expected \"creation:\", \"external:\" or \"internal:\".")); diff --git a/test/libsolidity/SMTCheckerTest.cpp b/test/libsolidity/SMTCheckerTest.cpp index 10084b014..eed911b1a 100644 --- a/test/libsolidity/SMTCheckerTest.cpp +++ b/test/libsolidity/SMTCheckerTest.cpp @@ -77,7 +77,7 @@ SMTCheckerTest::SMTCheckerTest(string const& _filename): SyntaxTest(_filename, E return filtered; }; if (m_modelCheckerSettings.invariants.invariants.empty()) - m_expectations = removeInv(move(m_expectations)); + m_expectations = removeInv(std::move(m_expectations)); auto const& ignoreInv = m_reader.stringSetting("SMTIgnoreInv", "yes"); if (ignoreInv == "no") diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index 3c26f5a97..9cf2b8d52 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -49,7 +49,6 @@ SemanticTest::SemanticTest( string const& _filename, langutil::EVMVersion _evmVersion, vector const& _vmPaths, - bool _enforceViaYul, bool _enforceCompileToEwasm, bool _enforceGasCost, u256 _enforceGasCostMinValue @@ -60,27 +59,32 @@ SemanticTest::SemanticTest( m_lineOffset(m_reader.lineNumber()), m_builtins(makeBuiltins()), m_sideEffectHooks(makeSideEffectHooks()), - m_enforceViaYul(_enforceViaYul), m_enforceCompileToEwasm(_enforceCompileToEwasm), m_enforceGasCost(_enforceGasCost), - m_enforceGasCostMinValue(move(_enforceGasCostMinValue)) + m_enforceGasCostMinValue(std::move(_enforceGasCostMinValue)) { - static set const compileViaYulAllowedValues{"also", "true", "false", "default"}; + static set const compileViaYulAllowedValues{"also", "true", "false"}; static set const yulRunTriggers{"also", "true"}; static set const legacyRunTriggers{"also", "false", "default"}; - string compileViaYul = m_reader.stringSetting("compileViaYul", "default"); + m_runWithABIEncoderV1Only = m_reader.boolSetting("ABIEncoderV1Only", false); + if (m_runWithABIEncoderV1Only && !solidity::test::CommonOptions::get().useABIEncoderV1) + m_shouldRun = false; + + string compileViaYul = m_reader.stringSetting("compileViaYul", "also"); + if (m_runWithABIEncoderV1Only && compileViaYul != "false") + BOOST_THROW_EXCEPTION(runtime_error( + "ABIEncoderV1Only tests cannot be run via yul, " + "so they need to also specify ``compileViaYul: false``" + )); if (!util::contains(compileViaYulAllowedValues, compileViaYul)) BOOST_THROW_EXCEPTION(runtime_error("Invalid compileViaYul value: " + compileViaYul + ".")); m_testCaseWantsYulRun = util::contains(yulRunTriggers, compileViaYul); m_testCaseWantsLegacyRun = util::contains(legacyRunTriggers, compileViaYul); - // Do not enforce via yul and ewasm, if via yul was explicitly denied. + // Do not enforce ewasm, if via yul was explicitly denied. if (compileViaYul == "false") - { - m_enforceViaYul = false; m_enforceCompileToEwasm = false; - } string compileToEwasm = m_reader.stringSetting("compileToEwasm", "false"); if (compileToEwasm == "also") @@ -97,18 +101,6 @@ SemanticTest::SemanticTest( if (m_testCaseWantsEwasmRun && !m_supportsEwasm) m_testCaseWantsEwasmRun = false; - m_runWithABIEncoderV1Only = m_reader.boolSetting("ABIEncoderV1Only", false); - if (m_runWithABIEncoderV1Only && !solidity::test::CommonOptions::get().useABIEncoderV1) - m_shouldRun = false; - - // Sanity check - if (m_runWithABIEncoderV1Only && (compileViaYul == "true" || compileViaYul == "also")) - BOOST_THROW_EXCEPTION(runtime_error( - "ABIEncoderV1Only can not be used with compileViaYul=" + compileViaYul + - ", set it to false or omit the flag. The compileViaYul setting ignores the abicoder pragma" - " and runs everything with ABICoder V2." - )); - auto revertStrings = revertStringsFromString(m_reader.stringSetting("revertStrings", "default")); soltestAssert(revertStrings, "Invalid revertStrings setting."); m_revertStrings = revertStrings.value(); @@ -307,7 +299,7 @@ TestCase::TestResult SemanticTest::run(ostream& _stream, string const& _linePref if (m_testCaseWantsLegacyRun) result = runTest(_stream, _linePrefix, _formatted, false, false); - if ((m_testCaseWantsYulRun || m_enforceViaYul) && result == TestResult::Success) + if (m_testCaseWantsYulRun && result == TestResult::Success) result = runTest(_stream, _linePrefix, _formatted, true, false); if ((m_testCaseWantsEwasmRun || m_enforceCompileToEwasm) && result == TestResult::Success) @@ -323,6 +315,14 @@ TestCase::TestResult SemanticTest::run(ostream& _stream, string const& _linePref throw; } } + + if (result != TestResult::Success) + solidity::test::CommonOptions::get().printSelectedOptions( + _stream, + _linePrefix, + {"evmVersion", "optimize", "useABIEncoderV1", "batch"} + ); + return result; } @@ -353,7 +353,6 @@ TestCase::TestResult SemanticTest::runTest( m_compileToEwasm = _isEwasmRun; } - m_canEnableYulRun = false; m_canEnableEwasmRun = false; if (_isYulRun) @@ -387,10 +386,7 @@ TestCase::TestResult SemanticTest::runTest( // For convenience, in semantic tests we assume that an unqualified name like `L` is equivalent to one // with an empty source unit name (`:L`). This is fine because the compiler never uses unqualified // names in the Yul code it produces and does not allow `linkersymbol()` at all in inline assembly. - if (test.call().signature.find(':') == string::npos) - libraries[":" + test.call().signature] = m_contractAddress; - else - libraries[test.call().signature] = m_contractAddress; + libraries[test.call().libraryFile + ":" + test.call().signature] = m_contractAddress; continue; } else @@ -461,30 +457,18 @@ TestCase::TestResult SemanticTest::runTest( success = false; test.setFailure(!m_transactionSuccessful); - test.setRawBytes(move(output)); + test.setRawBytes(std::move(output)); test.setContractABI(m_compiler.contractABI(m_compiler.lastContractName(m_sources.mainSourceFile))); } vector effects; for (SideEffectHook const& hook: m_sideEffectHooks) effects += hook(test.call()); - test.setSideEffects(move(effects)); + test.setSideEffects(std::move(effects)); success &= test.call().expectedSideEffects == test.call().actualSideEffects; } - if (!m_testCaseWantsYulRun && _isYulRun) - { - m_canEnableYulRun = success; - string message = success ? - "Test can pass via Yul, but marked with \"compileViaYul: false.\"" : - "Test compiles via Yul, but it gives different test results."; - AnsiColorized(_stream, _formatted, {BOLD, success ? YELLOW : MAGENTA}) << - _linePrefix << endl << - _linePrefix << message << endl; - return TestResult::Failure; - } - // Right now we have sometimes different test results in Yul vs. Ewasm. // The main reason is that Ewasm just returns a failure in some cases. // TODO: If Ewasm support got fully implemented, we could implement this in the same way as above. @@ -662,25 +646,19 @@ void SemanticTest::printUpdatedExpectations(ostream& _stream, string const&) con void SemanticTest::printUpdatedSettings(ostream& _stream, string const& _linePrefix) { auto& settings = m_reader.settings(); - if (settings.empty() && !m_canEnableYulRun) + if (settings.empty() && !m_canEnableEwasmRun) return; _stream << _linePrefix << "// ====" << endl; if (m_canEnableEwasmRun) { - soltestAssert(m_canEnableYulRun || m_testCaseWantsYulRun, ""); - string compileViaYul = m_reader.stringSetting("compileViaYul", ""); - if (!compileViaYul.empty()) - _stream << _linePrefix << "// compileViaYul: " << compileViaYul << "\n"; + soltestAssert(m_testCaseWantsYulRun, ""); _stream << _linePrefix << "// compileToEwasm: also\n"; } - else if (m_canEnableYulRun) - _stream << _linePrefix << "// compileViaYul: also\n"; for (auto const& [settingName, settingValue]: settings) if ( - !(settingName == "compileToEwasm" && m_canEnableEwasmRun) && - !(settingName == "compileViaYul" && (m_canEnableYulRun || m_canEnableEwasmRun)) + !(settingName == "compileToEwasm" && m_canEnableEwasmRun) ) _stream << _linePrefix << "// " << settingName << ": " << settingValue<< endl; } diff --git a/test/libsolidity/SemanticTest.h b/test/libsolidity/SemanticTest.h index b8093db22..dd189f1b5 100644 --- a/test/libsolidity/SemanticTest.h +++ b/test/libsolidity/SemanticTest.h @@ -52,7 +52,6 @@ public: _options.filename, _options.evmVersion, _options.vmPaths, - _options.enforceCompileViaYul, _options.enforceCompileToEwasm, _options.enforceGasCost, _options.enforceGasCostMinValue @@ -63,7 +62,6 @@ public: std::string const& _filename, langutil::EVMVersion _evmVersion, std::vector const& _vmPaths, - bool _enforceViaYul = false, bool _enforceCompileToEwasm = false, bool _enforceGasCost = false, u256 _enforceGasCostMinValue = 100000 @@ -97,14 +95,12 @@ private: std::vector m_tests; std::map const m_builtins; std::vector const m_sideEffectHooks; - bool m_testCaseWantsYulRun = false; + bool m_testCaseWantsYulRun = true; bool m_testCaseWantsEwasmRun = false; bool m_testCaseWantsLegacyRun = true; - bool m_enforceViaYul = false; bool m_enforceCompileToEwasm = false; bool m_runWithABIEncoderV1Only = false; bool m_allowNonExistingFunctions = false; - bool m_canEnableYulRun = false; bool m_canEnableEwasmRun = false; bool m_gasCostFailure = false; bool m_enforceGasCost = false; diff --git a/test/libsolidity/SolidityExecutionFramework.cpp b/test/libsolidity/SolidityExecutionFramework.cpp index 70d0b2a6e..cb47cf45e 100644 --- a/test/libsolidity/SolidityExecutionFramework.cpp +++ b/test/libsolidity/SolidityExecutionFramework.cpp @@ -109,7 +109,7 @@ bytes SolidityExecutionFramework::multiSourceCompileContract( try { asmStack.optimize(); - obj = move(*asmStack.assemble(yul::YulStack::Machine::EVM).bytecode); + obj = std::move(*asmStack.assemble(yul::YulStack::Machine::EVM).bytecode); obj.link(_libraryAddresses); break; } diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 4fef140e8..2741290fc 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -168,7 +168,7 @@ bytes compileFirstExpression( )); context.appendMissingLowLevelFunctions(); - // NOTE: We intentionally disable optimisations for utility functions to simplfy the tests + // NOTE: We intentionally disable optimisations for utility functions to simplify the tests context.appendYulUtilityFunctions({}); BOOST_REQUIRE(context.appendYulUtilityFunctionsRan()); diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index 8497fc0c0..319a60885 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -1428,7 +1428,7 @@ BOOST_AUTO_TEST_CASE(use_stack_optimization) BOOST_REQUIRE(result["errors"].isArray()); BOOST_CHECK(result["errors"][0]["severity"] == "error"); BOOST_REQUIRE(result["errors"][0]["message"].isString()); - BOOST_CHECK(result["errors"][0]["message"].asString().find("Stack too deep when compiling inline assembly") != std::string::npos); + BOOST_CHECK(result["errors"][0]["message"].asString().find("When compiling inline assembly") != std::string::npos); BOOST_CHECK(result["errors"][0]["type"] == "CompilerError"); } diff --git a/test/libsolidity/gasTests/abiv2.sol b/test/libsolidity/gasTests/abiv2.sol index 2dbe334b3..da433a9e5 100644 --- a/test/libsolidity/gasTests/abiv2.sol +++ b/test/libsolidity/gasTests/abiv2.sol @@ -14,9 +14,9 @@ contract C { } // ---- // creation: -// codeDepositCost: 1243000 -// executionCost: 1295 -// totalCost: 1244295 +// codeDepositCost: 1241200 +// executionCost: 1288 +// totalCost: 1242488 // external: // a(): 2430 // b(uint256): infinite diff --git a/test/libsolidity/gasTests/abiv2_optimised.sol b/test/libsolidity/gasTests/abiv2_optimised.sol index ca344afd0..26e2104f2 100644 --- a/test/libsolidity/gasTests/abiv2_optimised.sol +++ b/test/libsolidity/gasTests/abiv2_optimised.sol @@ -17,9 +17,9 @@ contract C { // optimize-yul: true // ---- // creation: -// codeDepositCost: 660800 -// executionCost: 696 -// totalCost: 661496 +// codeDepositCost: 659000 +// executionCost: 689 +// totalCost: 659689 // external: // a(): 2285 // b(uint256): 4652 diff --git a/test/libsolidity/lsp/analyze-full-project/C.sol b/test/libsolidity/lsp/analyze-full-project/C.sol new file mode 100644 index 000000000..d08ba140e --- /dev/null +++ b/test/libsolidity/lsp/analyze-full-project/C.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract C +{ +} diff --git a/test/libsolidity/lsp/analyze-full-project/D.sol b/test/libsolidity/lsp/analyze-full-project/D.sol new file mode 100644 index 000000000..93c8e92fc --- /dev/null +++ b/test/libsolidity/lsp/analyze-full-project/D.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract D +{ +} diff --git a/test/libsolidity/lsp/analyze-full-project/E.sol b/test/libsolidity/lsp/analyze-full-project/E.sol new file mode 100644 index 000000000..e0e5d1988 --- /dev/null +++ b/test/libsolidity/lsp/analyze-full-project/E.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract E +{ +} diff --git a/test/libsolidity/lsp/include-paths-nested-2/A/B/C/foo.sol b/test/libsolidity/lsp/include-paths-nested-2/A/B/C/foo.sol new file mode 100644 index 000000000..d53d359b1 --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested-2/A/B/C/foo.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +import "otherlib/second.sol"; + +contract C +{ +} diff --git a/test/libsolidity/lsp/include-paths-nested-2/A/B/foo.sol b/test/libsolidity/lsp/include-paths-nested-2/A/B/foo.sol new file mode 100644 index 000000000..0ab2f9c09 --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested-2/A/B/foo.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract B +{ +} diff --git a/test/libsolidity/lsp/include-paths-nested-2/A/foo.sol b/test/libsolidity/lsp/include-paths-nested-2/A/foo.sol new file mode 100644 index 000000000..1e31dbd99 --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested-2/A/foo.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract A +{ +} diff --git a/test/libsolidity/lsp/include-paths-nested-2/foo.sol b/test/libsolidity/lsp/include-paths-nested-2/foo.sol new file mode 100644 index 000000000..c589b6ae2 --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested-2/foo.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract RootContract +{ +} diff --git a/test/libsolidity/lsp/include-paths-nested/A/B/C/foo.sol b/test/libsolidity/lsp/include-paths-nested/A/B/C/foo.sol new file mode 100644 index 000000000..d08ba140e --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested/A/B/C/foo.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract C +{ +} diff --git a/test/libsolidity/lsp/include-paths-nested/A/B/foo.sol b/test/libsolidity/lsp/include-paths-nested/A/B/foo.sol new file mode 100644 index 000000000..0ab2f9c09 --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested/A/B/foo.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract B +{ +} diff --git a/test/libsolidity/lsp/include-paths-nested/A/foo.sol b/test/libsolidity/lsp/include-paths-nested/A/foo.sol new file mode 100644 index 000000000..1e31dbd99 --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested/A/foo.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract A +{ +} diff --git a/test/libsolidity/lsp/include-paths-nested/foo.sol b/test/libsolidity/lsp/include-paths-nested/foo.sol new file mode 100644 index 000000000..c589b6ae2 --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested/foo.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract RootContract +{ +} diff --git a/test/libsolidity/lsp/include-paths/default_include.sol b/test/libsolidity/lsp/include-paths/default_include.sol new file mode 100644 index 000000000..54bc859e0 --- /dev/null +++ b/test/libsolidity/lsp/include-paths/default_include.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +import "my-module/test.sol"; + +contract MyContract +{ + function f(uint a, uint b) public pure returns (uint) + { + return MyModule.add(a, b); + } +} +// ---- +// test: diff --git a/test/libsolidity/lsp/include-paths/file_at_include_path.sol b/test/libsolidity/lsp/include-paths/file_at_include_path.sol new file mode 100644 index 000000000..ec15e1533 --- /dev/null +++ b/test/libsolidity/lsp/include-paths/file_at_include_path.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +import "rootlib.sol"; + +contract MyContract +{ +} +// ---- +// rootlib: diff --git a/test/libsolidity/lsp/include-paths/file_not_found_in_searchpath.sol b/test/libsolidity/lsp/include-paths/file_not_found_in_searchpath.sol new file mode 100644 index 000000000..8dcefeca2 --- /dev/null +++ b/test/libsolidity/lsp/include-paths/file_not_found_in_searchpath.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + + import "test.sol"; +// ^^^^^^^^^^^^^^^^^^ @IncludeLocation + +contract SomeContract +{ +} +// ---- +// file_not_found_in_searchpath: @IncludeLocation 6275 diff --git a/test/libsolidity/lsp/include-paths/using-custom-includes.sol b/test/libsolidity/lsp/include-paths/using-custom-includes.sol new file mode 100644 index 000000000..2e2560d0d --- /dev/null +++ b/test/libsolidity/lsp/include-paths/using-custom-includes.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + + import "otherlib/otherlib.sol"; +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @NotFound + +contract MyContract +{ +} +// ---- +// using-custom-includes: @NotFound 6275 diff --git a/test/libsolidity/lsp/node_modules/my-module/test.sol b/test/libsolidity/lsp/node_modules/my-module/test.sol new file mode 100644 index 000000000..dffcb719f --- /dev/null +++ b/test/libsolidity/lsp/node_modules/my-module/test.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +library MyModule +{ + function add(uint a, uint b) public pure returns (uint) + { + return a + b; + } +} diff --git a/test/libsolidity/lsp/node_modules/rootlib.sol b/test/libsolidity/lsp/node_modules/rootlib.sol new file mode 100644 index 000000000..cbcf206a0 --- /dev/null +++ b/test/libsolidity/lsp/node_modules/rootlib.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +library MyRootLib +{ +} diff --git a/test/libsolidity/lsp/other-include-dir/otherlib/otherlib.sol b/test/libsolidity/lsp/other-include-dir/otherlib/otherlib.sol new file mode 100644 index 000000000..20a981ff9 --- /dev/null +++ b/test/libsolidity/lsp/other-include-dir/otherlib/otherlib.sol @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +library OtherLib +{ + function f(uint n) public returns (uint) { return n + 1; } +} diff --git a/test/libsolidity/lsp/other-include-dir/otherlib/second.sol b/test/libsolidity/lsp/other-include-dir/otherlib/second.sol new file mode 100644 index 000000000..2f32daac2 --- /dev/null +++ b/test/libsolidity/lsp/other-include-dir/otherlib/second.sol @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +library Second +{ + function f(uint n) public pure returns (uint) { return n + 1; } +} diff --git a/test/libsolidity/lsp/rename/contract.sol b/test/libsolidity/lsp/rename/contract.sol new file mode 100644 index 000000000..5bdc14fe6 --- /dev/null +++ b/test/libsolidity/lsp/rename/contract.sol @@ -0,0 +1,307 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract ToRename +// ^ @CursorOnContractDefinition +// ^^^^^^^^ @ContractInDefinition +{ +} + +contract User +// ^^^^ @UserContractInContractTest +{ + ToRename public publicVariable; +// ^^^^^^^^ @ContractInPublicVariable +// ^ @CursorOnPublicVariableType + + ToRename[10] previousContracts; +// ^^^^^^^^ @ContractInArrayType +// ^ @CursorOnArrayType + + mapping(int => ToRename) contractMapping; + // ^^^^^^^^ @ContractInMapping + // ^ @CursorOnMapping + + function getContract() public returns (ToRename) + // ^^^^^^^^ @ContractInReturnParameter +// ^ @CursorOnReturnParameter + { + return new ToRename(); + // ^^^^^^^^ @ContractInReturnExpression +// ^ @CursorOnReturnExpression + } + + function setContract(ToRename _contract) public + // ^^^^^^^^ @ContractInParameter + // ^ @CursorOnParameter + { + publicVariable = _contract; + } +} +// ---- +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnContractDefinition +// } +// <- { +// "changes": { +// "rename/contract.sol": [ +// { +// "newText": "Renamed", +// "range": @ContractInParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnExpression +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInMapping +// }, +// { +// "newText": "Renamed", +// "range": @ContractInArrayType +// }, +// { +// "newText": "Renamed", +// "range": @ContractInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @ContractInDefinition +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnReturnParameter +// } +// <- { +// "changes": { +// "rename/contract.sol": [ +// { +// "newText": "Renamed", +// "range": @ContractInParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnExpression +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInMapping +// }, +// { +// "newText": "Renamed", +// "range": @ContractInArrayType +// }, +// { +// "newText": "Renamed", +// "range": @ContractInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @ContractInDefinition +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnReturnExpression +// } +// <- { +// "changes": { +// "rename/contract.sol": [ +// { +// "newText": "Renamed", +// "range": @ContractInParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnExpression +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInMapping +// }, +// { +// "newText": "Renamed", +// "range": @ContractInArrayType +// }, +// { +// "newText": "Renamed", +// "range": @ContractInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @ContractInDefinition +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnPublicVariableType +// } +// <- { +// "changes": { +// "rename/contract.sol": [ +// { +// "newText": "Renamed", +// "range": @ContractInParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnExpression +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInMapping +// }, +// { +// "newText": "Renamed", +// "range": @ContractInArrayType +// }, +// { +// "newText": "Renamed", +// "range": @ContractInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @ContractInDefinition +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnArrayType +// } +// <- { +// "changes": { +// "rename/contract.sol": [ +// { +// "newText": "Renamed", +// "range": @ContractInParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnExpression +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInMapping +// }, +// { +// "newText": "Renamed", +// "range": @ContractInArrayType +// }, +// { +// "newText": "Renamed", +// "range": @ContractInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @ContractInDefinition +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnMapping +// } +// <- { +// "changes": { +// "rename/contract.sol": [ +// { +// "newText": "Renamed", +// "range": @ContractInParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnExpression +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInMapping +// }, +// { +// "newText": "Renamed", +// "range": @ContractInArrayType +// }, +// { +// "newText": "Renamed", +// "range": @ContractInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @ContractInDefinition +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnParameter +// } +// <- { +// "changes": { +// "rename/contract.sol": [ +// { +// "newText": "Renamed", +// "range": @ContractInParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnExpression +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInMapping +// }, +// { +// "newText": "Renamed", +// "range": @ContractInArrayType +// }, +// { +// "newText": "Renamed", +// "range": @ContractInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @ContractInDefinition +// } +// ] +// } +// } diff --git a/test/libsolidity/lsp/rename/function.sol b/test/libsolidity/lsp/rename/function.sol new file mode 100644 index 000000000..ffd8f6b58 --- /dev/null +++ b/test/libsolidity/lsp/rename/function.sol @@ -0,0 +1,194 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract C +{ + function renameMe() public pure returns (int) + // ^^^^^^^^ @FunctionInDefinition + // ^ @CursorInDefinition + { + return 1; + } + + function other() public view + { + renameMe(); +// ^^^^^^^^ @FunctionInFunctionSameContract +// ^ @CursorInFunctionSameContract + this.renameMe(); + // ^^^^^^^^ @FunctionInFunctionSameContractExternal + // ^ @CursorInFunctionSameContractExternal + } +} + +contract Other +{ + C m_contract; + + function other() public view + { + m_contract.renameMe(); + // ^^^^^^^^ @FunctionInFunctionOtherContract + // ^ @CursorInFunctionOtherContract + } +} + +function free() pure +{ + C local_contract; + local_contract.renameMe(); + // ^^^^^^^^ @FunctionInFreeFunction + // ^ @CursorInFreeFunction +} + +// ---- +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorInDefinition +// } +// <- { +// "changes": { +// "rename/function.sol": [ +// { +// "newText": "Renamed", +// "range": @FunctionInFreeFunction +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInFunctionOtherContract +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInFunctionSameContractExternal +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInFunctionSameContract +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInDefinition +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorInFunctionOtherContract +// } +// <- { +// "changes": { +// "rename/function.sol": [ +// { +// "newText": "Renamed", +// "range": @FunctionInFreeFunction +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInFunctionOtherContract +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInFunctionSameContractExternal +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInFunctionSameContract +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInDefinition +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorInFunctionSameContractExternal +// } +// <- { +// "changes": { +// "rename/function.sol": [ +// { +// "newText": "Renamed", +// "range": @FunctionInFreeFunction +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInFunctionOtherContract +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInFunctionSameContractExternal +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInFunctionSameContract +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInDefinition +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorInFunctionSameContract +// } +// <- { +// "changes": { +// "rename/function.sol": [ +// { +// "newText": "Renamed", +// "range": @FunctionInFreeFunction +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInFunctionOtherContract +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInFunctionSameContractExternal +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInFunctionSameContract +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInDefinition +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorInFreeFunction +// } +// <- { +// "changes": { +// "rename/function.sol": [ +// { +// "newText": "Renamed", +// "range": @FunctionInFreeFunction +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInFunctionOtherContract +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInFunctionSameContractExternal +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInFunctionSameContract +// }, +// { +// "newText": "Renamed", +// "range": @FunctionInDefinition +// } +// ] +// } +// } diff --git a/test/libsolidity/lsp/rename/functionCall.sol b/test/libsolidity/lsp/rename/functionCall.sol new file mode 100644 index 000000000..f8417fab9 --- /dev/null +++ b/test/libsolidity/lsp/rename/functionCall.sol @@ -0,0 +1,202 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract C +{ + function foo(int a, int b, int c) pure public returns(int) + // ^ @ParameterB + // ^ @ParameterA + // ^ @ParameterC + { + return a + b + c; + // ^ @ParameterBInFoo + // ^ @ParameterAInFoo + // ^ @ParameterCInFoo + + } + + function bar() public view + { + this.foo({c:1, b:2, a:3}); + // ^ @ParameterBInCall + // ^ @ParameterCInCall + // ^ @ParameterAInCall + } +} +// ---- +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @ParameterA +// } +// <- { +// "changes": { +// "rename/functionCall.sol": [ +// { +// "newText": "Renamed", +// "range": @ParameterAInCall +// }, +// { +// "newText": "Renamed", +// "range": @ParameterAInFoo +// }, +// { +// "newText": "Renamed", +// "range": @ParameterA +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @ParameterAInCall +// } +// <- { +// "changes": { +// "rename/functionCall.sol": [ +// { +// "newText": "Renamed", +// "range": @ParameterAInCall +// }, +// { +// "newText": "Renamed", +// "range": @ParameterAInFoo +// }, +// { +// "newText": "Renamed", +// "range": @ParameterA +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @ParameterAInFoo +// } +// <- { +// "changes": { +// "rename/functionCall.sol": [ +// { +// "newText": "Renamed", +// "range": @ParameterAInCall +// }, +// { +// "newText": "Renamed", +// "range": @ParameterAInFoo +// }, +// { +// "newText": "Renamed", +// "range": @ParameterA +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @ParameterC +// } +// <- { +// "changes": { +// "rename/functionCall.sol": [ +// { +// "newText": "Renamed", +// "range": @ParameterCInCall +// }, +// { +// "newText": "Renamed", +// "range": @ParameterCInFoo +// }, +// { +// "newText": "Renamed", +// "range": @ParameterC +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @ParameterCInCall +// } +// <- { +// "changes": { +// "rename/functionCall.sol": [ +// { +// "newText": "Renamed", +// "range": @ParameterCInCall +// }, +// { +// "newText": "Renamed", +// "range": @ParameterCInFoo +// }, +// { +// "newText": "Renamed", +// "range": @ParameterC +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @ParameterCInFoo +// } +// <- { +// "changes": { +// "rename/functionCall.sol": [ +// { +// "newText": "Renamed", +// "range": @ParameterCInCall +// }, +// { +// "newText": "Renamed", +// "range": @ParameterCInFoo +// }, +// { +// "newText": "Renamed", +// "range": @ParameterC +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @ParameterBInCall +// } +// <- { +// "changes": { +// "rename/functionCall.sol": [ +// { +// "newText": "Renamed", +// "range": @ParameterBInCall +// }, +// { +// "newText": "Renamed", +// "range": @ParameterBInFoo +// }, +// { +// "newText": "Renamed", +// "range": @ParameterB +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @ParameterBInFoo +// } +// <- { +// "changes": { +// "rename/functionCall.sol": [ +// { +// "newText": "Renamed", +// "range": @ParameterBInCall +// }, +// { +// "newText": "Renamed", +// "range": @ParameterBInFoo +// }, +// { +// "newText": "Renamed", +// "range": @ParameterB +// } +// ] +// } +// } diff --git a/test/libsolidity/lsp/rename/import_directive.sol b/test/libsolidity/lsp/rename/import_directive.sol new file mode 100644 index 000000000..a6b596866 --- /dev/null +++ b/test/libsolidity/lsp/rename/import_directive.sol @@ -0,0 +1,247 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +import "./contract.sol" as externalFile; +// ^^^^^^^^^^^^ @FileAliasInImportDirective +// ^ @CursorOnFileAliasInImportDirective +import {ToRename as ExternalContract, User} from "./contract.sol"; +// ^^^^^^^^^^^^^^^^ @RenamedContractInImportDirective +// ^ @CursorOnRenamedContractInImportDirective +// ^^^^^^^^ @OriginalNameInImportDirective +// ^ @CursorOnOriginalNameInImportDirective +// ^^^^ @UserInImportDirective +// ^ @CursorOnUserInImportDirective + +contract C +{ + ExternalContract public externalContract; +// ^^^^^^^^^^^^^^^^ @RenamedContractInPublicVariable +// ^ @CursorOnRenamedContractInPublicVariable + externalFile.ToRename public externalFileContract; +// ^^^^^^^^^^^^ @FileAliasInPublicVariable +// ^ @CursorOnFileAliasInPublicVariable +// ^^^^^^^^ @OriginalNameInPublicVariable +// ^ @CursorOnOriginalNameInPublicVariable + User public externalUserContract; +// ^^^^ @UserInPublicVariable +// ^ @CursorOnUserInPublicVariable +} + +// ---- +// contract: +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnFileAliasInImportDirective +// } +// <- { +// "changes": { +// "rename/import_directive.sol": [ +// { +// "newText": "Renamed", +// "range": @FileAliasInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @FileAliasInImportDirective +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnRenamedContractInImportDirective +// } +// <- { +// "changes": { +// "rename/import_directive.sol": [ +// { +// "newText": "Renamed", +// "range": @RenamedContractInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @RenamedContractInImportDirective +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnOriginalNameInImportDirective +// } +// <- { +// "changes": { +// "rename/contract.sol": [ +// { +// "newText": "Renamed", +// "range": @ContractInParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnExpression +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInMapping +// }, +// { +// "newText": "Renamed", +// "range": @ContractInArrayType +// }, +// { +// "newText": "Renamed", +// "range": @ContractInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @ContractInDefinition +// } +// ], +// "rename/import_directive.sol": [ +// { +// "newText": "Renamed", +// "range": @OriginalNameInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @OriginalNameInImportDirective +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnRenamedContractInPublicVariable +// } +// <- { +// "changes": { +// "rename/import_directive.sol": [ +// { +// "newText": "Renamed", +// "range": @RenamedContractInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @RenamedContractInImportDirective +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnFileAliasInPublicVariable +// } +// <- { +// "changes": { +// "rename/import_directive.sol": [ +// { +// "newText": "Renamed", +// "range": @FileAliasInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @FileAliasInImportDirective +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnOriginalNameInPublicVariable +// } +// <- { +// "changes": { +// "rename/contract.sol": [ +// { +// "newText": "Renamed", +// "range": @ContractInParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnExpression +// }, +// { +// "newText": "Renamed", +// "range": @ContractInReturnParameter +// }, +// { +// "newText": "Renamed", +// "range": @ContractInMapping +// }, +// { +// "newText": "Renamed", +// "range": @ContractInArrayType +// }, +// { +// "newText": "Renamed", +// "range": @ContractInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @ContractInDefinition +// } +// ], +// "rename/import_directive.sol": [ +// { +// "newText": "Renamed", +// "range": @OriginalNameInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @OriginalNameInImportDirective +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnUserInPublicVariable +// } +// <- { +// "changes": { +// "rename/contract.sol": [ +// { +// "newText": "Renamed", +// "range": @UserContractInContractTest +// } +// ], +// "rename/import_directive.sol": [ +// { +// "newText": "Renamed", +// "range": @UserInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @UserInImportDirective +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnUserInImportDirective +// } +// <- { +// "changes": { +// "rename/contract.sol": [ +// { +// "newText": "Renamed", +// "range": @UserContractInContractTest +// } +// ], +// "rename/import_directive.sol": [ +// { +// "newText": "Renamed", +// "range": @UserInPublicVariable +// }, +// { +// "newText": "Renamed", +// "range": @UserInImportDirective +// } +// ] +// } +// } diff --git a/test/libsolidity/lsp/rename/variable.sol b/test/libsolidity/lsp/rename/variable.sol new file mode 100644 index 000000000..39c23bcd7 --- /dev/null +++ b/test/libsolidity/lsp/rename/variable.sol @@ -0,0 +1,132 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract C +{ + int public renameMe; + // ^^^^^^^^ @VariableInDefinition + // ^ @CursorOnVariableDefinition + + function foo() public returns(int) + { + renameMe = 1; +// ^^^^^^^^ @VariableInFunction +// ^ @CursorOnVariableInFunction + return this.renameMe(); +// ^^^^^^^^ @VariableInGetter +// ^ @CursorOnVariableInGetter + } +} + +function freeFunction(C _contract) view returns(int) +{ + return _contract.renameMe(); + // ^^^^^^^^ @VariableInFreeFunction + // ^ @CursorOnVariableInFreeFunction +} + +// ---- +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnVariableInFunction +// } +// <- { +// "changes": { +// "rename/variable.sol": [ +// { +// "newText": "Renamed", +// "range": @VariableInFreeFunction +// }, +// { +// "newText": "Renamed", +// "range": @VariableInGetter +// }, +// { +// "newText": "Renamed", +// "range": @VariableInFunction +// }, +// { +// "newText": "Renamed", +// "range": @VariableInDefinition +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnVariableDefinition +// } +// <- { +// "changes": { +// "rename/variable.sol": [ +// { +// "newText": "Renamed", +// "range": @VariableInFreeFunction +// }, +// { +// "newText": "Renamed", +// "range": @VariableInGetter +// }, +// { +// "newText": "Renamed", +// "range": @VariableInFunction +// }, +// { +// "newText": "Renamed", +// "range": @VariableInDefinition +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnVariableInGetter +// } +// <- { +// "changes": { +// "rename/variable.sol": [ +// { +// "newText": "Renamed", +// "range": @VariableInFreeFunction +// }, +// { +// "newText": "Renamed", +// "range": @VariableInGetter +// }, +// { +// "newText": "Renamed", +// "range": @VariableInFunction +// }, +// { +// "newText": "Renamed", +// "range": @VariableInDefinition +// } +// ] +// } +// } +// -> textDocument/rename { +// "newName": "Renamed", +// "position": @CursorOnVariableInFreeFunction +// } +// <- { +// "changes": { +// "rename/variable.sol": [ +// { +// "newText": "Renamed", +// "range": @VariableInFreeFunction +// }, +// { +// "newText": "Renamed", +// "range": @VariableInGetter +// }, +// { +// "newText": "Renamed", +// "range": @VariableInFunction +// }, +// { +// "newText": "Renamed", +// "range": @VariableInDefinition +// } +// ] +// } +// } diff --git a/test/libsolidity/lsp/semanticTokens/enums.sol b/test/libsolidity/lsp/semanticTokens/enums.sol new file mode 100644 index 000000000..ea1655e1e --- /dev/null +++ b/test/libsolidity/lsp/semanticTokens/enums.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +enum Weather { + Sunny, + Cloudy, + Rainy +} + +enum Color { + Red, + Green, + Blue +} + +function getColorEnum() pure returns (Color result) +{ + result = Color.Red; +} + +// ---- +// -> textDocument/semanticTokens/full { +// } +// <- { +// "data": [ +// 1, 0, 24, 8, 0, +// 2, 5, 7, 2, 0, +// 1, 4, 5, 3, 0, +// 1, 4, 6, 3, 0, +// 1, 4, 5, 3, 0, +// 3, 5, 5, 2, 0, +// 1, 4, 3, 3, 0, +// 1, 4, 5, 3, 0, +// 1, 4, 4, 3, 0, +// 3, 9, 12, 5, 0, +// 0, 29, 5, 2, 0, +// 0, 6, 6, 19, 0, +// 2, 4, 6, 2, 0, +// 0, 9, 5, 2, 0, +// 0, 6, 3, 3, 0 +// ] +// } diff --git a/test/libsolidity/lsp/semanticTokens/functions.sol b/test/libsolidity/lsp/semanticTokens/functions.sol new file mode 100644 index 000000000..fee9af788 --- /dev/null +++ b/test/libsolidity/lsp/semanticTokens/functions.sol @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +library Lib +{ + function add(uint a, uint b) public pure returns (uint result) + { + result = a + b; + } + + function warningWithUnused() public pure + { + uint unused; +// ^^^^^^^^^^^ @unusedVariable + } +} + +contract Contract +{ + function doNothing() pure public returns (bool) + { + return true; + } +} + +// ---- +// functions: @unusedVariable 2072 +// -> textDocument/semanticTokens/full { +// } +// <- { +// "data": [ +// 1, 0, 24, 8, 0, +// 2, 8, 3, 0, 0, +// 2, 13, 3, 5, 0, +// 0, 4, 4, 11, 0, +// 0, 5, 1, 19, 0, +// 0, 3, 4, 11, 0, +// 0, 5, 1, 19, 0, +// 0, 24, 4, 11, 0, +// 0, 5, 6, 19, 0, +// 2, 8, 6, 19, 0, +// 0, 9, 1, 19, 0, +// 0, 4, 1, 19, 0, +// 3, 13, 17, 5, 0, +// 2, 8, 4, 11, 0, +// 0, 5, 6, 19, 0, +// 5, 9, 8, 0, 0, +// 2, 13, 9, 5, 0, +// 0, 33, 4, 11, 0, +// 2, 15, 4, 11, 0 +// ] +// } diff --git a/test/libsolidity/lsp/semanticTokens/modifiers.sol b/test/libsolidity/lsp/semanticTokens/modifiers.sol new file mode 100644 index 000000000..5a4b5a39c --- /dev/null +++ b/test/libsolidity/lsp/semanticTokens/modifiers.sol @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract C +{ + bool public locked = false; + int public calls = 0; + int public totalSum = 0; + + function add(uint a, uint b) lock() monitor(a, b) public returns (uint result) + { + result = a + b; + } + + modifier lock() + { + require(!locked); + locked = true; + _; + locked = false; + } + + modifier monitor(uint a, uint b) + { + calls++; + totalSum = totalSum + a + b; + // ^^^^^^^^^^^^^^^^ @totalSumWarning + // ^^^^^^^^^^^^ @totalSumWarningSub + _; + } +} +// ---- +// modifiers: @totalSumWarningSub 2271 @totalSumWarning 2271 +// -> textDocument/semanticTokens/full { +// } +// <- { +// "data": [ +// 1, 0, 24, 8, 0, +// 2, 9, 1, 0, 0, +// 2, 4, 4, 11, 0, +// 0, 12, 6, 19, 0, +// 0, 9, 5, 11, 0, +// 1, 4, 3, 11, 0, +// 0, 11, 5, 19, 0, +// 0, 8, 1, 11, 0, +// 1, 4, 3, 11, 0, +// 0, 11, 8, 19, 0, +// 0, 11, 1, 11, 0, +// 2, 13, 3, 5, 0, +// 0, 4, 4, 11, 0, +// 0, 5, 1, 19, 0, +// 0, 3, 4, 11, 0, +// 0, 5, 1, 19, 0, +// 0, 40, 4, 11, 0, +// 0, 5, 6, 19, 0, +// 0, -42, 4, 19, 0, +// 0, 7, 7, 19, 0, +// 0, 8, 1, 19, 0, +// 0, 3, 1, 19, 0, +// 2, 8, 6, 19, 0, +// 0, 9, 1, 19, 0, +// 0, 4, 1, 19, 0, +// 3, 13, 4, 10, 0, +// 2, 8, 7, 19, 0, +// 0, 9, 6, 19, 0, +// 1, 8, 6, 19, 0, +// 0, 9, 4, 11, 0, +// 2, 8, 6, 19, 0, +// 0, 9, 5, 11, 0, +// 3, 13, 7, 10, 0, +// 0, 8, 4, 11, 0, +// 0, 5, 1, 19, 0, +// 0, 3, 4, 11, 0, +// 0, 5, 1, 19, 0, +// 2, 8, 5, 19, 0, +// 1, 8, 8, 19, 0, +// 0, 11, 8, 19, 0, +// 0, 11, 1, 19, 0, +// 0, 4, 1, 19, 0 +// ] +// } diff --git a/test/libsolidity/lsp/semanticTokens/structs.sol b/test/libsolidity/lsp/semanticTokens/structs.sol new file mode 100644 index 000000000..ddbbcf3ce --- /dev/null +++ b/test/libsolidity/lsp/semanticTokens/structs.sol @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +struct Tag +{ + uint id; + string name; +} + +struct RGBColor +{ + uint8 red; + uint8 green; + uint8 blue; + Tag tag; +} + +function memberAccess(RGBColor memory color) pure returns(uint) +{ + return color.red + color.green + color.blue; +} +// ---- +// -> textDocument/semanticTokens/full { +// } +// <- { +// "data": [ +// 1, 0, 24, 8, 0, +// 4, 4, 4, 11, 0, +// 0, 5, 2, 19, 0, +// 1, 4, 6, 17, 0, +// 0, 7, 4, 19, 0, +// 5, 4, 5, 11, 0, +// 0, 6, 3, 19, 0, +// 1, 4, 5, 11, 0, +// 0, 6, 5, 19, 0, +// 1, 4, 5, 11, 0, +// 0, 6, 4, 19, 0, +// 1, 4, 3, 16, 0, +// 0, 4, 3, 19, 0, +// 3, 9, 12, 5, 0, +// 0, 13, 8, 16, 0, +// 0, 16, 5, 19, 0, +// 0, 20, 4, 11, 0, +// 2, 17, 3, 19, 0, +// 0, 12, 5, 19, 0, +// 0, 14, 4, 19, 0 +// ] +// } diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_dynamic_array.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_dynamic_array.sol index 4a67993ee..180d89ec1 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_dynamic_array.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_dynamic_array.sol @@ -4,7 +4,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 0xc0, 0x20, 0x4, 0x3, 0x4, 0x5, 0x6 -> 0x20, 0x4, 0x3, 0x4, 0x5, 0x6 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_fixed_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_fixed_arrays.sol index b421f7bd0..2624591ab 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_fixed_arrays.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_fixed_arrays.sol @@ -4,7 +4,5 @@ contract C { return (a[i], b[j][k]); } } -// ==== -// compileViaYul: also // ---- // f(uint16[3],uint16[2][3],uint256,uint256,uint256): 1, 2, 3, 11, 12, 21, 22, 31, 32, 1, 2, 1 -> 2, 32 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_static_array.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_static_array.sol index eeb8bfc70..270a5abc0 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_static_array.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_static_array.sol @@ -8,7 +8,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 0xc0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6 -> 1, 2, 3, 4, 5, 6 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_static_array_v2.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_static_array_v2.sol index 08467feb8..5e4d03a7e 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_static_array_v2.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_static_array_v2.sol @@ -11,7 +11,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 0xc0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6 -> 1, 2, 3, 4, 5, 6 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_trivial.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_trivial.sol index f02d75d17..7b873951f 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_trivial.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_trivial.sol @@ -4,7 +4,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 0x20, 0x21 -> 33 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2.sol index 6f1c652a0..eb4bd70fb 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2.sol @@ -18,7 +18,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f() -> 0x20, 0x8, 0x40, 0x3, 0x9, 0xa, 0xb diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_calldata.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_calldata.sol index bcb14d684..ddfe34329 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_calldata.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_calldata.sol @@ -12,7 +12,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 0xe0, 0x20, 0x21, 0x40, 0x3, 0xa, 0xb, 0xc -> 0x20, 0x21, 0x40, 0x3, 0xa, 0xb, 0xc diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol index 07f4ab275..fd7bc2083 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol @@ -20,10 +20,8 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f() -> 0x20, 0x8, 0x40, 0x3, 0x9, 0xa, 0xb -// gas irOptimized: 203310 -// gas legacy: 206075 -// gas legacyOptimized: 203059 +// gas irOptimized: 203172 +// gas legacy: 206343 +// gas legacyOptimized: 203162 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode.sol index 1bd84a418..773b7d2c6 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode.sol @@ -30,7 +30,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f0() -> 0x20, 0x0 // f1() -> 0x20, 0x40, 0x1, 0x2 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_call.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_call.sol index d11914fce..d73db5da6 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_call.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_call.sol @@ -22,7 +22,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol index 8503e5790..67680b852 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol @@ -57,13 +57,12 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // test_bytes() -> -// gas irOptimized: 371912 -// gas legacy: 416585 -// gas legacyOptimized: 322043 +// gas irOptimized: 362400 +// gas legacy: 414569 +// gas legacyOptimized: 319271 // test_uint256() -> -// gas irOptimized: 523016 -// gas legacy: 583100 -// gas legacyOptimized: 444161 +// gas irOptimized: 511919 +// gas legacy: 581876 +// gas legacyOptimized: 442757 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_decode_simple.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_decode_simple.sol index 61aec760a..fb093b41a 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_decode_simple.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_decode_simple.sol @@ -7,6 +7,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x21, 0x40, 0x7, "abcdefg" diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_rational.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_rational.sol index d891ad8b4..c5ba49368 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_rational.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_rational.sol @@ -7,6 +7,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x20, 0x40, 0x1, -2 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/bool_out_of_bounds.sol b/test/libsolidity/semanticTests/abiEncoderV1/bool_out_of_bounds.sol index 92ca61f12..d9b94ac2e 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/bool_out_of_bounds.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/bool_out_of_bounds.sol @@ -4,6 +4,7 @@ contract C { } // ==== // ABIEncoderV1Only: true +// compileViaYul: false // ---- // f(bool): true -> true // f(bool): false -> false diff --git a/test/libsolidity/semanticTests/abiEncoderV1/byte_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV1/byte_arrays.sol index fbe533bb4..9895c666a 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/byte_arrays.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/byte_arrays.sol @@ -9,8 +9,6 @@ contract C { return (a, b.length, b[3], c); } } -// ==== -// compileViaYul: also // ---- // f(uint256,bytes,uint256): 6, 0x60, 9, 7, "abcdefg" -> 6, 7, "d", 9 // f_external(uint256,bytes,uint256): 6, 0x60, 9, 7, "abcdefg" -> 6, 7, "d", 9 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/calldata_arrays_too_large.sol b/test/libsolidity/semanticTests/abiEncoderV1/calldata_arrays_too_large.sol index 4d48a1dee..b372a4c47 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/calldata_arrays_too_large.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/calldata_arrays_too_large.sol @@ -5,6 +5,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256,uint256[],uint256): 6, 0x60, 9, 0x8000000000000000000000000000000000000000000000000000000000000002, 1, 2 -> FAILURE diff --git a/test/libsolidity/semanticTests/abiEncoderV1/calldata_bytes_bytes32_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV1/calldata_bytes_bytes32_arrays.sol new file mode 100644 index 000000000..18a4ee1a9 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV1/calldata_bytes_bytes32_arrays.sol @@ -0,0 +1,14 @@ +pragma abicoder v1; + +contract C { + function f(bool a, bytes calldata b, bytes32[2] calldata c) + public + returns (bool, bytes calldata, bytes32[2] calldata) + { + return (a, b, c); + } +} +// ==== +// compileViaYul: false +// ---- +// f(bool,bytes,bytes32[2]): true, 0x80, "a", "b", 4, "abcd" -> true, 0x80, "a", "b", 4, "abcd" diff --git a/test/libsolidity/semanticTests/abiEncoderV1/cleanup/cleanup.sol b/test/libsolidity/semanticTests/abiEncoderV1/cleanup/cleanup.sol index 3a671486f..262c4412f 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/cleanup/cleanup.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/cleanup/cleanup.sol @@ -7,6 +7,7 @@ contract C { } // ==== // ABIEncoderV1Only: true +// compileViaYul: false // ---- // f(uint16,int16,address,bytes3,bool): 1, 2, 3, "a", true -> 1, 2, 3, "a", true // f(uint16,int16,address,bytes3,bool): 0xffffff, 0x1ffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, "abcd", 1 -> 0xffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffff, "abc", true diff --git a/test/libsolidity/semanticTests/abiEncoderV1/decode_slice.sol b/test/libsolidity/semanticTests/abiEncoderV1/decode_slice.sol index a85504db4..11e79dec0 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/decode_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/decode_slice.sol @@ -8,6 +8,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256,uint256): 42, 23 -> 42, 23, 42, 23 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/dynamic_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV1/dynamic_arrays.sol index 8813be109..7eb9a3885 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/dynamic_arrays.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/dynamic_arrays.sol @@ -4,7 +4,5 @@ contract C { return (b.length, b[a], c); } } -// ==== -// compileViaYul: also // ---- // f(uint256,uint16[],uint256): 6, 0x60, 9, 7, 11, 12, 13, 14, 15, 16, 17 -> 7, 17, 9 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/dynamic_memory_copy.sol b/test/libsolidity/semanticTests/abiEncoderV1/dynamic_memory_copy.sol index 450dfa4d5..126c6c950 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/dynamic_memory_copy.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/dynamic_memory_copy.sol @@ -19,8 +19,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // test(bytes): 0x20, 0x80, 0x40, 0x60, 0, 0 -> false, false // test(bytes): 0x20, 0xC0, 0x40, 0x80, 1, 0x42, 1, 0x42 -> false, false diff --git a/test/libsolidity/semanticTests/abiEncoderV1/enums.sol b/test/libsolidity/semanticTests/abiEncoderV1/enums.sol index b3f32d01e..a51aaebde 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/enums.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/enums.sol @@ -7,6 +7,7 @@ contract C { } // ==== // ABIEncoderV1Only: true +// compileViaYul: false // ---- // f(uint8): 0 -> 0 // f(uint8): 1 -> 1 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/memory_dynamic_array_and_calldata_bytes.sol b/test/libsolidity/semanticTests/abiEncoderV1/memory_dynamic_array_and_calldata_bytes.sol new file mode 100644 index 000000000..3b2b90c6c --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV1/memory_dynamic_array_and_calldata_bytes.sol @@ -0,0 +1,17 @@ +pragma abicoder v1; + +contract C { + function f(uint256[] memory a, bytes calldata b) public returns (bytes memory) { + return abi.encode(a, b); + } + + function g(uint256[] memory a, bytes calldata b) external returns (bytes memory) { + return f(a, b); + } +} + +// ==== +// EVMVersion: >homestead +// ---- +// f(uint256[],bytes): 0x40, 0x80, 1, 0xFF, 6, "123456" -> 0x20, 0xc0, 0x40, 0x80, 1, 0xff, 6, "123456" +// g(uint256[],bytes): 0x40, 0x80, 1, 0xffff, 8, "12345678" -> 0x20, 0xc0, 0x40, 0x80, 1, 0xffff, 8, "12345678" diff --git a/test/libsolidity/semanticTests/abiEncoderV1/memory_params_in_external_function.sol b/test/libsolidity/semanticTests/abiEncoderV1/memory_params_in_external_function.sol index b86129d77..dbabfc35b 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/memory_params_in_external_function.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/memory_params_in_external_function.sol @@ -12,7 +12,5 @@ contract C { return this.f("abc", "def", x); } } -// ==== -// compileViaYul: also // ---- // g() -> 3, 0x6200000000000000000000000000000000000000000000000000000000000000, 3, 0x6600000000000000000000000000000000000000000000000000000000000000, 4, 7 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_advanced.sol b/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_advanced.sol index aee924a80..24c1b2325 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_advanced.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_advanced.sol @@ -13,6 +13,5 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f() -> 0x80, -1, 0xe0, 0x1234, 40, "12345678901234567890123456789012", "34567890", 4, 97767552542602192590433234714624, 0, 0, 537879995309340587922569878831104 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_out_of_range_1.sol b/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_out_of_range_1.sol index c90180f49..191b4e6be 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_out_of_range_1.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_out_of_range_1.sol @@ -12,7 +12,6 @@ contract C { } } // ==== -// compileViaYul: also // EVMVersion: =homestead // ---- // f(uint256): 0x60 -> true diff --git a/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_out_of_range_2.sol b/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_out_of_range_2.sol index c976be064..cfbd00324 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_out_of_range_2.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_out_of_range_2.sol @@ -13,7 +13,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f(uint256): 0x60 -> FAILURE // f(uint256): 0x61 -> true diff --git a/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_simple.sol b/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_simple.sol index 4b52f7022..bd12b0a9b 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_simple.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/return_dynamic_types_cross_call_simple.sol @@ -8,6 +8,5 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f() -> 0x20, 40, "12345678901234567890123456789012", "34567890" diff --git a/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol b/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol index cfdecd7a0..a6d601412 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol @@ -21,11 +21,9 @@ contract C { return (r[2], s.x, a, b, c, d); } } -// ==== -// compileViaYul: also // ---- // library: L // f() -> 8, 7, 1, 2, 7, 12 -// gas irOptimized: 167691 +// gas irOptimized: 166525 // gas legacy: 169347 // gas legacyOptimized: 167269 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol index 2710f202d..0d2e4f9c0 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol @@ -58,13 +58,12 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // test_bytes() -> -// gas irOptimized: 371912 -// gas legacy: 416585 -// gas legacyOptimized: 322043 +// gas irOptimized: 362400 +// gas legacy: 414569 +// gas legacyOptimized: 319271 // test_uint256() -> -// gas irOptimized: 523016 -// gas legacy: 583100 -// gas legacyOptimized: 444161 +// gas irOptimized: 511919 +// gas legacy: 581876 +// gas legacyOptimized: 442757 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_empty_string_v2.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_empty_string_v2.sol index 73222d1a9..8db4674c2 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_empty_string_v2.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_empty_string_v2.sol @@ -11,6 +11,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x40, 0xa0, 0x40, 0x20, 0x0, 0x0 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_rational_v2.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_rational_v2.sol index e19017110..106c26ea9 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_rational_v2.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_rational_v2.sol @@ -10,6 +10,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x20, 0x40, 0x1, -2 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol index e1e2d0ab6..58b38a9c3 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol @@ -45,14 +45,12 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f0() -> 0x20, 0x0 // f1() -> 0x20, 0x40, 0x1, 0x2 // f2() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc" // f3() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc" // f4() -> 0x20, 0x160, 0x1, 0x80, 0xc0, 0x2, 0x3, "abc", 0x7, 0x40, 0x2, 0x2, 0x3 -// gas irOptimized: 113277 -// gas legacy: 114900 -// gas legacyOptimized: 112606 +// gas irOptimized: 112646 +// gas legacy: 114866 +// gas legacyOptimized: 112586 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol index b7d917dbf..e0ab2c97f 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol @@ -28,10 +28,8 @@ contract C is B { return foo(new A()); } } -// ==== -// compileViaYul: also // ---- // test() -> 77 -// gas irOptimized: 119711 +// gas irOptimized: 120170 // gas legacy: 155093 // gas legacyOptimized: 111550 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 153118355..407cbf7a1 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 @@ -36,8 +36,6 @@ contract C is B { return (x, y); } } -// ==== -// compileViaYul: also // ---- // test() -> 5, 10 // gas irOptimized: 87337 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encoder_v2_head_overflow_with_static_array_cleanup_bug.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encoder_v2_head_overflow_with_static_array_cleanup_bug.sol new file mode 100644 index 000000000..9e5d57552 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encoder_v2_head_overflow_with_static_array_cleanup_bug.sol @@ -0,0 +1,17 @@ +pragma abicoder v2; + +struct T { + bytes x; + uint[3] y; +} + +contract E { + function f(bool a, T calldata b, bytes32[2] calldata c) + public + returns (bool, T calldata, bytes32[2] calldata) + { + return (a, b, c); + } +} +// ---- +// f(bool,(bytes,uint256[3]),bytes32[2]): 1, 0x80, "a", "b", 0x80, 11, 12, 13, 4, "abcd" -> 1, 0x80, "a", "b", 0x80, 11, 12, 13, 4, "abcd" diff --git a/test/libsolidity/semanticTests/abiEncoderV2/bool_out_of_bounds.sol b/test/libsolidity/semanticTests/abiEncoderV2/bool_out_of_bounds.sol index abbbe7ab2..1a6856ff4 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/bool_out_of_bounds.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/bool_out_of_bounds.sol @@ -5,7 +5,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bool): true -> true // f(bool): false -> false diff --git a/test/libsolidity/semanticTests/abiEncoderV2/byte_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV2/byte_arrays.sol index 9155d8c6b..078da3fdc 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/byte_arrays.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/byte_arrays.sol @@ -11,8 +11,6 @@ contract C { return (a, b.length, b[3], c); } } -// ==== -// compileViaYul: also // ---- // f(uint256,bytes,uint256): 6, 0x60, 9, 7, "abcdefg" -> 6, 7, "d", 9 // f_external(uint256,bytes,uint256): 6, 0x60, 9, 7, "abcdefg" -> 6, 7, "d", 9 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol index 63ee9bd02..689bb9810 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol @@ -16,11 +16,10 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f(uint256[][1]): 32, 32, 0 -> true // 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: 171829 -// gas legacy: 140672 -// gas legacyOptimized: 119588 +// gas irOptimized: 127347 +// gas legacy: 140553 +// gas legacyOptimized: 119450 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic.sol index 6fe3f6924..c1208218b 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic.sol @@ -22,7 +22,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f(uint256[]): 32, 3, 23, 42, 87 -> 32, 160, 32, 3, 23, 42, 87 // g(uint256[]): 32, 3, 23, 42, 87 -> 32, 160, 32, 3, 23, 42, 87 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_index_access.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_index_access.sol index b8179a131..a9e3d8b15 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_index_access.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_index_access.sol @@ -22,7 +22,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f(uint256[]): 32, 3, 42, 23, 87 -> 32, 160, 32, 3, 42, 23, 87 // g(uint256[][2],uint256): 0x40, 0, 0x40, 0xC0, 3, 42, 23, 87, 4, 11, 13, 17 -> 32, 160, 32, 3, 42, 23, 87 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_static_dynamic.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_static_dynamic.sol index 08180ab24..ecea716bd 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_static_dynamic.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_static_dynamic.sol @@ -44,7 +44,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // g() -> 32, 196, hex"eccb829a", 32, 1, 32, 32, 1, 42, hex"00000000000000000000000000000000000000000000000000000000" // h() -> 32, 196, hex"eccb829a", 32, 1, 32, 32, 1, 42, hex"00000000000000000000000000000000000000000000000000000000" diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_static_in_library.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_static_in_library.sol new file mode 100644 index 000000000..b15a203f2 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_static_in_library.sol @@ -0,0 +1,17 @@ +library L { + // This case used to be affected by the buggy cleanup due to ABIEncoderV2HeadOverflowWithStaticArrayCleanup bug. + function g(uint[] memory a, uint[1] calldata b) public returns (uint[] memory, uint[1] calldata) { + return (a, b); + } +} + +contract C { + function f(uint[] memory a, uint[1] calldata b) public returns (uint[] memory, uint[1] memory) { + return L.g(a, b); + } +} +// ==== +// EVMVersion: >homestead +// ---- +// library: L +// f(uint256[],uint256[1]): 0x40, 0xff, 1, 0xffff -> 0x40, 0xff, 0x01, 0xffff diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_static_short_decode.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_static_short_decode.sol index cd6cd9864..9fab29f9f 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_static_short_decode.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_static_short_decode.sol @@ -7,7 +7,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256[][2][]): 0x20, 0x01, 0x20, 0x40, 0x60, 0x00, 0x00 -> 23 # this is the common encoding for x.length == 1 && x[0][0].length == 0 && x[0][1].length == 0 # // f(uint256[][2][]): 0x20, 0x01, 0x20, 0x00, 0x00 -> 23 # exotic, but still valid encoding # diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_static_short_reencode.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_static_short_reencode.sol index 2cf09b19b..170f88640 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_static_short_reencode.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_dynamic_static_short_reencode.sol @@ -7,8 +7,6 @@ contract C { return this.f(x); } } -// ==== -// compileViaYul: also // ---- // g(uint256[][2][]): 0x20, 0x01, 0x20, 0x40, 0x60, 0x00, 0x00 -> 42 // g(uint256[][2][]): 0x20, 0x01, 0x20, 0x00, 0x00 -> 42 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_function_types.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_function_types.sol index f5380901f..a52a065e6 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_function_types.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_function_types.sol @@ -25,8 +25,6 @@ contract C { return reenc ? this.f_reenc(a) : this.f(a); } } -// ==== -// compileViaYul: also // ---- // g(bool): false -> 23, 37, 71 // g(bool): true -> 23, 37, 71 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_multi_dynamic.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_multi_dynamic.sol index c4e02ec26..b9b3bd145 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_multi_dynamic.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_multi_dynamic.sol @@ -22,7 +22,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f(uint256[][]): 0x20, 2, 0x40, 0xC0, 3, 13, 17, 23, 4, 27, 31, 37, 41 -> 32, 416, 32, 2, 64, 192, 3, 13, 17, 23, 4, 27, 31, 37, 41 // g(uint256[][]): 0x20, 2, 0x40, 0xC0, 3, 13, 17, 23, 4, 27, 31, 37, 41 -> 32, 416, 32, 2, 64, 192, 3, 13, 17, 23, 4, 27, 31, 37, 41 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_short.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_short.sol index b2a126d50..b8cb0226e 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_short.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_short.sol @@ -5,7 +5,6 @@ contract C { } // ==== // revertStrings: debug -// compileViaYul: also // ---- // f(uint256[]): 0x20, 0 -> // f(uint256[]): 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 0x2b, "ABI decoding: invalid calldata a", "rray stride" diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_short_no_revert_string.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_short_no_revert_string.sol index 19aa30a08..7fc08caaf 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_short_no_revert_string.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_short_no_revert_string.sol @@ -1,8 +1,6 @@ contract C { function f(uint[] calldata) public {} } -// ==== -// compileViaYul: also // ---- // f(uint256[]): 0x20, 0 -> // f(uint256[]): 0x20, 1 -> FAILURE diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_static.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_static.sol index 86c2b139f..aaf7616ec 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_static.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_static.sol @@ -16,7 +16,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f(uint256[3]): 23, 42, 87 -> 32, 96, 23, 42, 87 // g(uint256[3]): 23, 42, 87 -> 32, 96, 23, 42, 87 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_static_dynamic_static.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_static_dynamic_static.sol index 6e5944fdc..dd59ac8cf 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_static_dynamic_static.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_static_dynamic_static.sol @@ -42,7 +42,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // g() -> 32, 132, hex"15cfcc01", 32, 32, 1, 42, hex"00000000000000000000000000000000000000000000000000000000" // h() -> 32, 132, hex"15cfcc01", 32, 32, 1, 42, hex"00000000000000000000000000000000000000000000000000000000" diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_static_index_access.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_static_index_access.sol index b89c8644d..a75e2c2e0 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_static_index_access.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_static_index_access.sol @@ -16,7 +16,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f(uint256[3]): 23, 42, 87 -> 32, 96, 23, 42, 87 // g(uint256[3][2],uint256): 23, 42, 87, 123, 142, 187, 0 -> 32, 96, 23, 42, 87 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_struct_dynamic.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_struct_dynamic.sol index 3c05dacd6..68dbe88f7 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_struct_dynamic.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_struct_dynamic.sol @@ -11,7 +11,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f((uint256[])[]): 32, 1, 32, 32, 3, 17, 42, 23 -> 32, 256, 32, 1, 32, 32, 3, 17, 42, 23 // g((uint256[])[]): 32, 1, 32, 32, 3, 17, 42, 23 -> 32, 256, 32, 1, 32, 32, 3, 17, 42, 23 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_two_dynamic.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_two_dynamic.sol index ece02aa8e..5e43a1c4b 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_two_dynamic.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_two_dynamic.sol @@ -13,7 +13,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f(uint256[],uint256[],bool): 0x60, 0xE0, true, 3, 23, 42, 87, 2, 51, 72 -> 32, 160, 0x20, 3, 23, 42, 87 // f(uint256[],uint256[],bool): 0x60, 0xE0, false, 3, 23, 42, 87, 2, 51, 72 -> 32, 128, 0x20, 2, 51, 72 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_two_static.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_two_static.sol index 9deff8bf7..554c06aa9 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_two_static.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array_two_static.sol @@ -13,7 +13,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f(uint256[3],uint256[2],bool): 23, 42, 87, 51, 72, true -> 32, 96, 23, 42, 87 // f(uint256[3],uint256[2],bool): 23, 42, 87, 51, 72, false -> 32, 64, 51, 72 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_dynamic_array_to_memory.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_dynamic_array_to_memory.sol new file mode 100644 index 000000000..f044d6f05 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_dynamic_array_to_memory.sol @@ -0,0 +1,25 @@ +pragma abicoder v2; + +contract C { + function f(uint[][] calldata a) public returns (uint[][] memory) { + return a; + } + + function g(uint[][][] calldata a) public returns (uint[][][] memory) { + return a; + } + + function h(uint[2][][] calldata a) public returns (uint[2][][] memory) { + return a; + } +} + +// ---- +// f(uint256[][]): 0x20, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8 -> 0x20, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8 +// f(uint256[][]): 0x20, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8, 9 -> 0x20, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8 +// f(uint256[][]): 0x20, 2, 0x40, 0xa0, 2, 5, 6, 3, 7, 8 -> FAILURE +// g(uint256[][][]): 0x20, 2, 0x40, 0x60, 0, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8 -> 0x20, 2, 0x40, 0x60, 0, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8 +// g(uint256[][][]): 0x20, 2, 0x40, 0x60, 0, 2, 0x40, 0xa0, 2, 5, 6, 2, 7 -> FAILURE +// h(uint256[2][][]): 0x20, 2, 0x40, 0x60, 0, 2, 5, 6, 7, 8 -> 0x20, 2, 0x40, 0x60, 0, 2, 5, 6, 7, 8 +// h(uint256[2][][]): 0x20, 2, 0x40, 0x60, 0, 2, 5, 6, 7, 8, 9 -> 0x20, 2, 0x40, 0x60, 0, 2, 5, 6, 7, 8 +// h(uint256[2][][]): 0x20, 2, 0x40, 0x60, 0, 2, 5, 6, 7 -> FAILURE diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol index 042ad586e..96573fb4b 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol @@ -1,23 +1,36 @@ pragma abicoder v2; contract C { - function h(uint[][] calldata a) public { - abi.encode(a); - } - struct S { uint[] x; } - function f(S calldata a) public { - abi.encode(a); - } + function f(uint[][] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + function g(uint8[][][] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + function h(uint16[][2][] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + function i(uint16[][][1] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + function j(uint16[2][][] calldata a) public returns (bytes memory) { + return abi.encode(a); + } } // ==== -// compileViaYul: also // revertStrings: debug // ---- -// h(uint256[][]): 0x20, 1, 0x20, 0 -> -// h(uint256[][]): 0x20, 1, 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" -// h(uint256[][]): 0x20, 1, 0x20, 2 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" -// h(uint256[][]): 0x20, 1, 0x20, 3 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" -// f((uint256[])): 0x20, 0x20, 0 -> -// f((uint256[])): 0x20, 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" -// f((uint256[])): 0x20, 0x20, 2 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" -// f((uint256[])): 0x20, 0x20, 3 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" +// f(uint256[][]): 0x20, 1, 0x20, 0 -> 0x20, 0x80, 0x20, 1, 0x20, 0 +// f(uint256[][]): 0x20, 1, 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" +// f(uint256[][]): 0x20, 1, 0x20, 2 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" +// f(uint256[][]): 0x20, 1, 0x20, 3 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" +// g(uint8[][][]): 0x20, 2, 0x40, 0x0140, 2, 0x40, 0x80, 1, 10, 2, 11, 12, 0 -> 0x20, 0x01a0, 0x20, 2, 0x40, 0x0140, 2, 0x40, 0x80, 1, 10, 2, 11, 12, 0 +// g(uint8[][][]): 0x20, 2, 0x40, 0x0140, 2, 0x40, 0x80, 1, 10, 2, 11, 12 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access offset" +// g(uint8[][][]): 0x20, 2, 0x40, 0x0140, 2, 0x40, 0x80, 1, 10, 2, 11, 12, 1, 0x20, 0 -> 0x20, 0x01e0, 0x20, 2, 0x40, 0x0140, 2, 0x40, 0x80, 1, 10, 2, 11, 12, 1, 0x20, 0 +// g(uint8[][][]): 0x20, 2, 0x40, 0x0140, 2, 0x40, 0x80, 1, 10, 2, 11, 12, 1, 0x20, 0, 1 -> 0x20, 0x01e0, 0x20, 2, 0x40, 0x0140, 2, 0x40, 0x80, 1, 10, 2, 11, 12, 1, 0x20, 0 +// h(uint16[][2][]): 0x20, 2, 0x40, 0x0120, 0x40, 0x80, 1, 10, 2, 11, 12, 0x40, 0x60, 0, 1, 13 -> 0x20, 0x0200, 0x20, 2, 0x40, 288, 0x40, 0x80, 1, 10, 2, 11, 12, 0x40, 0x60, 0, 1, 13 +// h(uint16[][2][]): 0x20, 2, 0x40, 0x0120, 0x40, 0x80, 1, 10, 2, 11, 12, 0x40, 0x60, 0, 1 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" +// i(uint16[][][1]): 0x20, 0x20, 2, 0x40, 0x80, 1, 10, 2, 11, 12 -> 0x20, 0x0140, 0x20, 0x20, 2, 0x40, 0x80, 1, 10, 2, 11, 12 +// i(uint16[][][1]): 0x20, 0x20, 2, 0x40, 0x80, 1, 10, 2, 11 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" +// j(uint16[2][][]): 0x20, 2, 0x40, 0xa0, 1, 0x0a, 11, 2, 12, 13, 14, 15 -> 0x20, 0x0180, 0x20, 2, 0x40, 0xa0, 1, 10, 11, 2, 12, 13, 14, 15 +// j(uint16[2][][]): 0x20, 2, 0x40, 0xa0, 1, 0x0a, 11, 2, 12, 13, 14 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_static_reencode.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_static_reencode.sol index a0b500876..440f8e14c 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_static_reencode.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_static_reencode.sol @@ -11,8 +11,6 @@ contract C { abi.encode(a); } } -// ==== -// compileViaYul: also // ---- // f(uint256[3][]): 0x20, 1, 0x01 -> FAILURE // f(uint256[3][]): 0x20, 1, 0x01, 0x02 -> FAILURE diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol new file mode 100644 index 000000000..1ec1ca4c5 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol @@ -0,0 +1,41 @@ +pragma abicoder v2; + +contract C { + uint[] s; + uint[2] n; + + function f_memory(uint[] calldata a, uint[2] calldata b) public returns (uint[] memory, uint[2] memory) { + return (a, b); + } + + function f_encode(uint[] calldata a, uint[2] calldata b) public returns (bytes memory) { + return abi.encode(a, b); + } + + function f_which(uint[] calldata a, uint[2] calldata b, uint which) public returns (bytes memory) { + return abi.encode(a[which], b[1]); + } + + function f_storage(uint[] calldata a, uint[2] calldata b ) public returns (bytes memory) { + s = a; + n = b; + return abi.encode(s); + } +} + +// ---- +// f_memory(uint256[],uint256[2]): 0x20, 1, 2 -> 0x60, 0x01, 0x02, 1, 2 +// f_memory(uint256[],uint256[2]): 0x40, 1, 2, 5, 6 -> 0x60, 1, 2, 2, 5, 6 +// f_memory(uint256[],uint256[2]): 0x40, 1, 2, 5 -> FAILURE +// f_encode(uint256[],uint256[2]): 0x20, 1, 2 -> 0x20, 0xa0, 0x60, 1, 2, 1, 2 +// f_encode(uint256[],uint256[2]): 0x40, 1, 2, 5, 6 -> 0x20, 0xc0, 0x60, 1, 2, 2, 5, 6 +// f_encode(uint256[],uint256[2]): 0x40, 1, 2, 5 -> FAILURE +// f_which(uint256[],uint256[2],uint256): 0x40, 1, 2, 1, 5 -> 0x20, 0x40, 5, 2 +// f_which(uint256[],uint256[2],uint256): 0x40, 1, 2, 1, 5, 6 -> 0x20, 0x40, 5, 2 +// f_which(uint256[],uint256[2],uint256): 0x40, 1, 2, 1 -> FAILURE +// f_storage(uint256[],uint256[2]): 0x20, 1, 2 -> 0x20, 0x60, 0x20, 1, 2 +// gas irOptimized: 111653 +// gas legacy: 112979 +// gas legacyOptimized: 112104 +// f_storage(uint256[],uint256[2]): 0x40, 1, 2, 5, 6 -> 0x20, 0x80, 0x20, 2, 5, 6 +// f_storage(uint256[],uint256[2]): 0x40, 1, 2, 5 -> FAILURE diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol new file mode 100644 index 000000000..f7ed9daf4 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol @@ -0,0 +1,35 @@ +pragma abicoder v2; + +contract C { + uint[] s; + uint[2] n; + + function f_memory(uint[][] calldata a) public returns (uint[][] memory) { + return a; + } + + function f_encode(uint[][] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + + function f_which(uint[][] calldata a, uint which) public returns (uint[] memory) { + return a[which]; + } +} + +// ---- +// f_memory(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 1, 2 -> 0x20, 2, 0x40, 0xa0, 2, 1, 2, 2, 1, 2 +// f_memory(uint256[][]): 0x20, 2, 0x40, 0x60, 2, 1, 2 -> 0x20, 2, 0x40, 0xa0, 2, 1, 2, 1, 2 +// f_memory(uint256[][]): 0x20, 2, 0, 0x60, 2, 1, 2 -> 0x20, 2, 0x40, 0x60, 0, 1, 2 +// f_memory(uint256[][]): 0x20, 2, 0, 0x60, 2, 2, 2 -> FAILURE +// f_encode(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 1, 2 -> 0x20, 0x0140, 0x20, 2, 0x40, 0xa0, 2, 1, 2, 2, 1, 2 +// f_encode(uint256[][]): 0x20, 2, 0x40, 0x60, 2, 1, 2 -> 0x20, 0x0120, 0x20, 2, 0x40, 0xa0, 2, 1, 2, 1, 2 +// f_encode(uint256[][]): 0x20, 2, 0, 0x60, 2, 1, 2 -> 0x20, 0xe0, 0x20, 2, 0x40, 0x60, 0, 1, 2 +// f_encode(uint256[][]): 0x20, 2, 0, 0x60, 2, 2, 2 -> FAILURE +// f_which(uint256[][],uint256): 0x40, 0, 2, 0x40, 0x40, 2, 1, 2 -> 0x20, 2, 1, 2 +// f_which(uint256[][],uint256): 0x40, 1, 2, 0x40, 0x40, 2, 1, 2 -> 0x20, 2, 1, 2 +// f_which(uint256[][],uint256): 0x40, 0, 2, 0x40, 0x60, 2, 1, 2 -> 0x20, 2, 1, 2 +// f_which(uint256[][],uint256): 0x40, 1, 2, 0x40, 0x60, 2, 1, 2 -> 0x20, 1, 2 +// f_which(uint256[][],uint256): 0x40, 0, 2, 0, 0x60, 2, 1, 2 -> 0x20, 0 +// f_which(uint256[][],uint256): 0x40, 1, 2, 0, 0x60, 2, 1, 2 -> 0x20, 1, 2 +// f_which(uint256[][],uint256): 0x40, 1, 2, 0, 0x60, 2, 2, 2 -> FAILURE diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_array_reencode.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_array_reencode.sol new file mode 100644 index 000000000..d456cdfcc --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_array_reencode.sol @@ -0,0 +1,54 @@ +pragma abicoder v2; + +contract C { + struct D { uint[] x; } + struct S { uint x; } + + function f(D calldata a) public returns (bytes memory){ + return abi.encode(a); + } + + function g(D[2] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + + function h(D[][] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + + function i(D[2][] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + + function j(S[] memory a) public returns (bytes memory) { + return abi.encode(a); + } + + function k(S[2] memory a) public returns (bytes memory) { + return abi.encode(a); + } + + function l(S[][] memory a) public returns (bytes memory) { + return abi.encode(a); + } + +} + +// ---- +// f((uint256[])): 0x20, 0x20, 0 -> 0x20, 0x60, 0x20, 0x20, 0 +// f((uint256[])): 0x20, 0x20, 1 -> FAILURE +// f((uint256[])): 0x20, 0x20, 2 -> FAILURE +// f((uint256[])): 0x20, 0x20, 3 -> FAILURE +// g((uint256[])[2]): 0x20, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1, 3 -> 0x20, 0x0140, 0x20, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1, 3 +// g((uint256[])[2]): 0x20, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1 -> FAILURE +// h((uint256[])[][]): 0x20, 0x02, 0x40, 0x0180, 2, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1, 3, 1, 0x20, 0x20, 1, 1 -> 0x20, 0x0260, 0x20, 2, 0x40, 0x0180, 2, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1, 3, 1, 0x20, 0x20, 1, 1 +// h((uint256[])[][]): 0x20, 0x02, 0x40, 0x0180, 2, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1, 3, 1, 0x20, 0x20, 1 -> FAILURE +// i((uint256[])[2][]): 0x20, 1, 0x20, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1, 3 -> 0x20, 0x0180, 0x20, 1, 0x20, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1, 3 +// i((uint256[])[2][]): 0x20, 1, 0x20, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1 -> FAILURE +// j((uint256)[]): 0x20, 2, 1, 2 -> 0x20, 0x80, 0x20, 2, 1, 2 +// j((uint256)[]): 0x20, 2, 1 -> FAILURE +// k((uint256)[2]): 1, 2 -> 0x20, 0x40, 1, 2 +// k((uint256)[2]): 1 -> FAILURE +// l((uint256)[][]): 0x20, 2, 0x40, 0xa0, 2, 5, 6, 3, 7, 8, 9 -> 0x20, 0x0160, 0x20, 2, 0x40, 0xa0, 2, 5, 6, 3, 7, 8, 9 +// l((uint256)[][]): 0x20, 2, 0x40, 0xa0, 2, 5, 6, 3, 7, 8, 9, 10 -> 0x20, 0x0160, 0x20, 2, 0x40, 0xa0, 2, 5, 6, 3, 7, 8, 9 +// l((uint256)[][]): 0x20, 2, 0x40, 0xa0, 2, 5, 6, 3, 7, 8 -> FAILURE diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_dynamic.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_dynamic.sol index 8c49af8c9..f275957c0 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_dynamic.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_dynamic.sol @@ -13,7 +13,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f((uint256[])): 0x20, 0x20, 3, 42, 23, 17 -> 32, 192, 0x20, 0x20, 3, 42, 23, 17 // g((uint256[])): 0x20, 0x20, 3, 42, 23, 17 -> 32, 192, 0x20, 0x20, 3, 42, 23, 17 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_member_offset.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_member_offset.sol index 7744fbf62..129373de6 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_member_offset.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_member_offset.sol @@ -19,7 +19,5 @@ contract C { return (b.b, this.g(b)); } } -// ==== -// compileViaYul: also // ---- // f() -> 11, 11 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_simple.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_simple.sol index c10504841..4c85fe767 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_simple.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_simple.sol @@ -13,7 +13,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f((uint256)): 3 -> 32, 32, 3 // g((uint256)): 3 -> 32, 32, 3 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_three_dimensional_dynamic_array_index_access.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_three_dimensional_dynamic_array_index_access.sol new file mode 100644 index 000000000..a97c4f6d8 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_three_dimensional_dynamic_array_index_access.sol @@ -0,0 +1,41 @@ +pragma abicoder v2; + +contract C { + struct S { uint[] a; } + + function f(uint[][] calldata s, uint i, uint j) public pure returns (bytes memory) { + return abi.encode(s[i][j]); + } + + function g(uint[][][] calldata s, uint i, uint j, uint k) public pure returns (bytes memory) { + return abi.encode(s[i][j][k]); + } + + function h(uint[][][1] calldata s, uint i) public pure returns (bytes memory) { + return abi.encode(s[0][i]); + } + + function k(S[][] calldata s, uint i, uint j) public pure returns (bytes memory) { + return abi.encode(s[i][j].a); + } + + function l(S[2][2] calldata s, uint i, uint j) public pure returns (bytes memory) { + return abi.encode(s[i][j].a); + } +} + +// ==== +// revertStrings: debug +// ---- +// f(uint256[][],uint256,uint256): 0x60, 0, 0, 2, 0x40, 0x80, 1, 7, 1, 8 -> 0x20, 0x20, 7 +// f(uint256[][],uint256,uint256): 0x60, 1, 0, 2, 0x40, 0x80, 1, 7, 1, 8 -> 0x20, 0x20, 8 +// g(uint256[][][],uint256,uint256,uint256): 0x80, 0, 0, 0, 2, 0x40, 0xc0, 1, 0x20, 1, 4, 2, 0x40, 0xa0, 2, 5, 6, 1, 7 -> 0x20, 0x20, 4 +// g(uint256[][][],uint256,uint256,uint256): 0x80, 1, 0, 1, 2, 0x40, 0xc0, 1, 0x20, 1, 4, 2, 0x40, 0xa0, 2, 5, 6, 1, 7 -> 0x20, 0x20, 6 +// g(uint256[][][],uint256,uint256,uint256): 0x80, 1, 0, 2, 2, 0x40, 0xc0, 1, 0x20, 1, 4, 2, 0x40, 0xa0, 2, 5, 6, 1, 7 -> FAILURE, hex"4e487b71", 0x32 +// g(uint256[][][],uint256,uint256,uint256): 0x80, 2, 0, 1, 2, 0x40, 0xc0, 1, 0x20, 1, 4, 2, 0x40, 0xa0, 2, 5, 6, 1, 7 -> FAILURE, hex"4e487b71", 0x32 +// h(uint256[][][1],uint256): 0x40, 1, 0x20, 2, 0x40, 0xA0, 2, 5, 6, 3, 7, 8, 9 -> 0x20, 0xa0, 0x20, 3, 7, 8, 9 +// h(uint256[][][1],uint256): 0x40, 2, 0x20, 2, 0x40, 0xA0, 2, 5, 6, 3, 7, 8, 9 -> FAILURE, hex"4e487b71", 0x32 +// k((uint256[])[][],uint256,uint256): 0x60, 0, 0, 2, 0x40, 0xe0, 1, 0x20, 0x20, 1, 6, 2, 0x40, 0xa0, 0x20, 1, 7, 0x20, 2, 8, 9 -> 0x20, 0x60, 0x20, 1, 6 +// k((uint256[])[][],uint256,uint256): 0x60, 0, 1, 2, 0x40, 0xe0, 1, 0x20, 0x20, 1, 6, 2, 0x40, 0xa0, 0x20, 1, 7, 0x20, 2, 8, 9 -> FAILURE, hex"4e487b71", 0x32 +// l((uint256[])[2][2],uint256,uint256): 0x60, 1, 1, 0x40, 0x0140, 0x40, 0xa0, 0x20, 1, 5, 0x20, 1, 6, 0x40, 0xa0, 0x20, 1, 7, 0x20, 2, 8, 9 -> 0x20, 0x80, 0x20, 2, 8, 9 +// l((uint256[])[2][2],uint256,uint256): 0x60, 1, 2, 0x40, 0x0140, 0x40, 0xa0, 0x20, 1, 5, 0x20, 1, 6, 0x40, 0xa0, 0x20, 1, 7, 0x20, 2, 8, 9 -> FAILURE, hex"4e487b71", 0x32 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_with_garbage.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_with_garbage.sol new file mode 100644 index 000000000..b12692854 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_with_garbage.sol @@ -0,0 +1,67 @@ +pragma abicoder v2; + +contract C { + uint[] aTmp; + uint[2] bTmp; + + function f_memory(uint[] calldata a) public returns (uint[] memory) { + return a; + } + + function f_encode(uint[] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + + function f_storage(uint[] calldata a) public returns (bytes memory) { + aTmp = a; + return abi.encode(aTmp); + } + + function f_index(uint[] calldata a, uint which) public returns (uint) { + return a[which]; + } + + function g_memory(uint[] calldata a, uint[2] calldata b) public returns (uint[] memory, uint[2] memory) { + return (a, b); + } + + function g_encode(uint[] calldata a, uint[2] calldata b) public returns (bytes memory) { + return abi.encode(a, b); + } + + function g_storage(uint[] calldata a, uint[2] calldata b) public returns (bytes memory) { + aTmp = a; + bTmp = b; + return abi.encode(aTmp, bTmp); + } + + function g_index(uint[] calldata a, uint[2] calldata b, uint which) public returns (uint, uint) { + return (a[which], b[0]); + } +} + +// ---- +// f_memory(uint256[]): 0x80, 9, 9, 9, 0 -> 0x20, 0 +// f_memory(uint256[]): 0x80, 9, 9, 9, 1, 7 -> 0x20, 1, 7 +// f_memory(uint256[]): 0x80, 9, 9, 9, 2, 7 -> FAILURE +// f_encode(uint256[]): 0x80, 9, 9, 9, 0 -> 0x20, 0x40, 0x20, 0 +// f_encode(uint256[]): 0x80, 9, 9, 9, 1, 7 -> 0x20, 0x60, 0x20, 1, 7 +// f_encode(uint256[]): 0x80, 9, 9, 9, 2, 7 -> FAILURE +// f_storage(uint256[]): 0x80, 9, 9, 9, 0 -> 0x20, 0x40, 0x20, 0 +// f_storage(uint256[]): 0x80, 9, 9, 9, 1, 7 -> 0x20, 0x60, 0x20, 1, 7 +// f_storage(uint256[]): 0x80, 9, 9, 9, 2, 7 -> FAILURE +// f_index(uint256[],uint256): 0xa0, 0, 9, 9, 9, 2, 7, 8 -> 7 +// f_index(uint256[],uint256): 0xa0, 1, 9, 9, 9, 2, 7, 8 -> 8 +// f_index(uint256[],uint256): 0xa0, 2, 9, 9, 9, 2, 7, 8 -> FAILURE, hex"4e487b71", 0x32 +// g_memory(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 0 -> 0x60, 1, 2, 0 +// g_memory(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 1, 7 -> 0x60, 1, 2, 1, 7 +// g_memory(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 2, 7 -> FAILURE +// g_encode(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 0 -> 0x20, 0x80, 0x60, 1, 2, 0 +// g_encode(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 1, 7 -> 0x20, 0xa0, 0x60, 1, 2, 1, 7 +// g_encode(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 2, 7 -> FAILURE +// g_storage(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 0 -> 0x20, 0x80, 0x60, 1, 2, 0 +// g_storage(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 1, 7 -> 0x20, 0xa0, 0x60, 1, 2, 1, 7 +// g_storage(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 2, 7 -> FAILURE +// g_index(uint256[],uint256[2],uint256): 0xe0, 1, 2, 0, 9, 9, 9, 2, 7, 8 -> 7, 1 +// g_index(uint256[],uint256[2],uint256): 0xe0, 1, 2, 1, 9, 9, 9, 2, 7, 8 -> 8, 1 +// g_index(uint256[],uint256[2],uint256): 0xe0, 1, 2, 1, 9, 9, 9, 2, 7 -> FAILURE diff --git a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/address.sol b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/address.sol index 3ac82eee5..44a462d13 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/address.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/address.sol @@ -10,8 +10,6 @@ contract C { return this.g(x); } } -// ==== -// compileViaYul: also // ---- // f(uint256): 0 -> 0 // g(address): 0 -> 0 # test validation as well as sanity check # diff --git a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/bool.sol b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/bool.sol index 79cf68795..8e788ab85 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/bool.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/bool.sol @@ -10,8 +10,6 @@ contract C { return this.gggg(x); } } -// ==== -// compileViaYul: also // ---- // f(uint256): 0 -> false // gggg(bool): 0 -> false # test validation as well as sanity check # diff --git a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/bytesx.sol b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/bytesx.sol index 26ff5fb69..92cffdd8a 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/bytesx.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/bytesx.sol @@ -42,8 +42,6 @@ contract C { return this.g16(x); } } -// ==== -// compileViaYul: also // ---- // f1(bytes32): left(0) -> left(0) // gg1(bytes1): left(0) -> left(0) # test validation as well as sanity check # diff --git a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/cleanup.sol b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/cleanup.sol index 0723d4d31..b680e9cd2 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/cleanup.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/cleanup.sol @@ -8,7 +8,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint16,int16,address,bytes3,bool): 1, 2, 3, "a", true -> 1, 2, 3, "a", true // f(uint16,int16,address,bytes3,bool): 0xffffff, 0x1ffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, "abcd", 1 -> FAILURE diff --git a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/dynamic_array.sol b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/dynamic_array.sol index ec4d4dcf5..240ec623f 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/dynamic_array.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/dynamic_array.sol @@ -15,7 +15,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f(uint256[]): 0x20, 2, 1, 1 -> 0x20, 0x84, hex"304a4c23", 0x20, 2, 1, 1, hex"00000000000000000000000000000000000000000000000000000000" // ggg(uint8[]): 0x20, 2, 1, 1 -> 0x20, 0x84, hex"304a4c23", 0x20, 2, 1, 1, hex"00000000000000000000000000000000000000000000000000000000" diff --git a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/function.sol b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/function.sol index 7a4ec0ce5..1ae459d29 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/function.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/function.sol @@ -16,8 +16,6 @@ contract C { return (this.ggg(s.f), this.h(s)); } } -// ==== -// compileViaYul: also // ---- // ffff(uint256): 0 -> 0, 0 // ggg(function): 0 -> 0 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/intx.sol b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/intx.sol index db636986e..8e60d5c33 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/intx.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/intx.sol @@ -42,8 +42,6 @@ contract C { return this.g128(x); } } -// ==== -// compileViaYul: also // ---- // f8(int256): 0 -> 0 // ggg8(int8): 0 -> 0 # test validation as well as sanity check # diff --git a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/reencoded_calldata_string.sol b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/reencoded_calldata_string.sol new file mode 100644 index 000000000..1cf129529 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/reencoded_calldata_string.sol @@ -0,0 +1,27 @@ +contract C { + function f(string calldata x) external returns (bytes memory r) { + uint mptr; + assembly { + // dirty memory + mptr := mload(0x40) + for { let i := mptr } lt(i, add(mptr, 0x0100)) { i := add(i, 32) } + { + mstore(i, sub(0, 1)) + } + } + r = abi.encode(x); + assembly { + // assert that we dirtied the memory that was encoded to + if iszero(eq(mptr, r)) { + revert(0, 0) + } + } + } + function test() external returns (bytes memory) { + return this.f("abc"); + } +} +// ==== +// EVMVersion: >homestead +// ---- +// test() -> 0x20, 0x60, 0x20, 3, "abc" diff --git a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/simple_struct.sol b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/simple_struct.sol index 1906750f8..2a019f5e7 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/simple_struct.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/simple_struct.sol @@ -17,7 +17,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f(uint256,bytes32): 1, left(0x01) -> 0x20, 0x44, hex"b63240b0", 1, left(0x01), hex"00000000000000000000000000000000000000000000000000000000" // gg((uint8,bytes1)): 1, left(0x01) -> 0x20, 0x44, hex"b63240b0", 1, left(0x01), hex"00000000000000000000000000000000000000000000000000000000" diff --git a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/static_array.sol b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/static_array.sol index a0a542b10..ce8cbfad5 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/static_array.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/static_array.sol @@ -16,7 +16,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f(uint256,uint256): 1, 1 -> 0x20, 0x44, hex"78b86ac6", 1, 1, hex"00000000000000000000000000000000000000000000000000000000" // gggggggg(uint8[2]): 1, 1 -> 0x20, 0x44, hex"78b86ac6", 1, 1, hex"00000000000000000000000000000000000000000000000000000000" diff --git a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/uintx.sol b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/uintx.sol index cf17ef623..9a33edda2 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/cleanup/uintx.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/cleanup/uintx.sol @@ -42,8 +42,6 @@ contract C { return this.g128(x); } } -// ==== -// compileViaYul: also // ---- // f8(uint256): 0 -> 0 // ggg8(uint8): 0 -> 0 # test validation as well as sanity check # diff --git a/test/libsolidity/semanticTests/abiEncoderV2/dynamic_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV2/dynamic_arrays.sol index d4d7f03d0..e8b64a108 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/dynamic_arrays.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/dynamic_arrays.sol @@ -6,7 +6,5 @@ contract C { return (b.length, b[a], c); } } -// ==== -// compileViaYul: also // ---- // f(uint256,uint16[],uint256): 6, 0x60, 9, 7, 11, 12, 13, 14, 15, 16, 17 -> 7, 17, 9 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/dynamic_nested_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV2/dynamic_nested_arrays.sol index 23faf0d89..e9816ef14 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/dynamic_nested_arrays.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/dynamic_nested_arrays.sol @@ -25,8 +25,6 @@ contract C { return this.f(12, b, c, 13); } } -// ==== -// compileViaYul: also // ---- // test() -> 12, 3, 4, 0x66, 5, 0x85, 13 // f(uint256,uint16[][],uint256[2][][3],uint256): 12, 0x80, 0x220, 13, 3, 0x60, 0xC0, 0x160, 2, 85, 86, 4, 101, 102, 103, 104, 0, 0x60, 0xC0, 0x220, 1, 0, 117, 5, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0 -> 12, 3, 4, 0x66, 5, 0x85, 13 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/enums.sol b/test/libsolidity/semanticTests/abiEncoderV2/enums.sol index d9637c23c..285bf334f 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/enums.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/enums.sol @@ -8,7 +8,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint8): 0 -> 0 // f(uint8): 1 -> 1 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/memory_dynamic_array_and_calldata_bytes.sol b/test/libsolidity/semanticTests/abiEncoderV2/memory_dynamic_array_and_calldata_bytes.sol new file mode 100644 index 000000000..07d035080 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/memory_dynamic_array_and_calldata_bytes.sol @@ -0,0 +1,13 @@ +contract C { + function f(uint256[] memory a, bytes calldata b) public returns (bytes memory) { + return abi.encode(a, b); + } + + function g(uint256[] memory a, bytes calldata b) external returns (bytes memory) { + return f(a, b); + } +} + +// ---- +// f(uint256[],bytes): 0x40, 0x80, 1, 0xFF, 6, "123456" -> 0x20, 0xc0, 0x40, 0x80, 1, 0xff, 6, "123456" +// g(uint256[],bytes): 0x40, 0x80, 1, 0xffff, 8, "12345678" -> 0x20, 0xc0, 0x40, 0x80, 1, 0xffff, 8, "12345678" diff --git a/test/libsolidity/semanticTests/abiEncoderV2/memory_dynamic_array_and_calldata_static_array.sol b/test/libsolidity/semanticTests/abiEncoderV2/memory_dynamic_array_and_calldata_static_array.sol new file mode 100644 index 000000000..a8f4f5554 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/memory_dynamic_array_and_calldata_static_array.sol @@ -0,0 +1,18 @@ +contract C { + function f(uint256[] memory a, uint256[1] calldata b) public returns (bytes memory) { + return abi.encode(a, b); + } + + function g(uint256[] memory a, uint256[1] calldata b) external returns (bytes memory) { + return f(a, b); + } + + function h(uint256[] memory a, uint256[1] calldata b) external returns (uint256[] memory, uint256[1] calldata) { + return (a, b); + } +} + +// ---- +// f(uint256[],uint256[1]): 0x40, 0xff, 1, 0xffff -> 0x20, 0x80, 0x40, 0xff, 1, 0xffff +// g(uint256[],uint256[1]): 0x40, 0xff, 1, 0xffff -> 0x20, 0x80, 0x40, 0xff, 1, 0xffff +// h(uint256[],uint256[1]): 0x40, 0xff, 1, 0xffff -> 0x40, 0xff, 1, 0xffff diff --git a/test/libsolidity/semanticTests/abiEncoderV2/memory_params_in_external_function.sol b/test/libsolidity/semanticTests/abiEncoderV2/memory_params_in_external_function.sol index 549838f95..f8beb5703 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/memory_params_in_external_function.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/memory_params_in_external_function.sol @@ -14,7 +14,5 @@ contract C { return this.f("abc", "def", x); } } -// ==== -// compileViaYul: also // ---- // g() -> 3, 0x6200000000000000000000000000000000000000000000000000000000000000, 3, 0x6600000000000000000000000000000000000000000000000000000000000000, 4, 7 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol b/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol index 5499c2594..16f365bd4 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol @@ -16,13 +16,12 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // h(uint256[2][]): 0x20, 3, 123, 124, 223, 224, 323, 324 -> 32, 256, 0x20, 3, 123, 124, 223, 224, 323, 324 -// gas irOptimized: 180924 -// gas legacy: 184929 -// gas legacyOptimized: 181504 +// gas irOptimized: 180829 +// gas legacy: 184921 +// gas legacyOptimized: 181506 // i(uint256[2][2]): 123, 124, 223, 224 -> 32, 128, 123, 124, 223, 224 -// gas irOptimized: 112520 -// gas legacy: 115468 -// gas legacyOptimized: 112988 +// gas irOptimized: 112464 +// gas legacy: 115460 +// gas legacyOptimized: 112990 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/struct/mediocre2_struct.sol b/test/libsolidity/semanticTests/abiEncoderV2/struct/mediocre2_struct.sol index afa16826d..5c13d7916 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/struct/mediocre2_struct.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/struct/mediocre2_struct.sol @@ -8,7 +8,5 @@ contract C { r3 = b; } } -// ==== -// compileViaYul: also // ---- // f(uint256,(address,uint256[])[2],uint256): 7, 0x60, 8, 0x40, 0xE0, 0x0, 0x40, 2, 0x11, 0x12, 0x99, 0x40, 4, 0x31, 0x32, 0x34, 0x35 -> 7, 0x0, 8 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/struct/mediocre_struct.sol b/test/libsolidity/semanticTests/abiEncoderV2/struct/mediocre_struct.sol index 7775423d4..c5ab31dc3 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/struct/mediocre_struct.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/struct/mediocre_struct.sol @@ -8,7 +8,5 @@ contract C { r3 = b; } } -// ==== -// compileViaYul: also // ---- // f(uint256,(address)[2],uint256): 7, 0, 0, 8 -> 7, 0, 8 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_function.sol b/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_function.sol index 7e3031ba5..3217a1734 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_function.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_function.sol @@ -10,7 +10,5 @@ contract C { } function g() public returns (uint) { return 7; } } -// ==== -// compileViaYul: also // ---- // test() -> 7, 3 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_short.sol b/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_short.sol index 55f09a3fd..73fa9b415 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_short.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_short.sol @@ -8,7 +8,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f((int256,uint256,bytes16)): 0xff010, 0xff0002, "abcd" -> 0xff010, 0xff0002, "abcd" // f((int256,uint256,bytes16)): 0xff010, 0xff0002, 0x1111222233334444555566667777888800000000000000000000000000000000 -> 0xff010, 0xff0002, left(0x11112222333344445555666677778888) diff --git a/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_simple.sol b/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_simple.sol index 9cfd19fd4..80fe3149b 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_simple.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_simple.sol @@ -11,6 +11,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f((uint256,uint8,uint8,bytes2)): 1, 2, 3, "ab" -> 1, 2, 3, 0x6162 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_validation.sol b/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_validation.sol index 39e6e2731..3e2664102 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_validation.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/struct/struct_validation.sol @@ -11,7 +11,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f((int16,uint8,bytes2)): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01, 0xff, "ab" -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01, 0xff, "ab" diff --git a/test/libsolidity/semanticTests/abiEncoderV2/struct/validation_function_type_inside_struct.sol b/test/libsolidity/semanticTests/abiEncoderV2/struct/validation_function_type_inside_struct.sol index 190904745..b1151c2fa 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/struct/validation_function_type_inside_struct.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/struct/validation_function_type_inside_struct.sol @@ -7,7 +7,6 @@ contract C { function h(S calldata s) external pure returns (uint r) { s.x; r = 3; } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f((function)): "01234567890123456789abcd" -> 1 diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_decode_calldata.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_decode_calldata.sol index 0574c4dd2..3bab26b83 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_decode_calldata.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_decode_calldata.sol @@ -8,7 +8,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 0x80, 0x21, 0x40, 0x7, "abcdefg" -> 0x21, 0x40, 0x7, "abcdefg" diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple.sol index b3eb6724d..2703f25e9 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple.sol @@ -4,7 +4,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 0x80, 0x21, 0x40, 0x7, "abcdefg" -> 0x21, 0x40, 0x7, "abcdefg" diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol index 027ae4e16..15ba6f7de 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol @@ -7,10 +7,8 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 0x80, 0x21, 0x40, 0x7, "abcdefg" -> 0x21, 0x40, 0x7, "abcdefg" -// gas irOptimized: 135918 -// gas legacy: 137181 -// gas legacyOptimized: 136073 +// gas irOptimized: 135699 +// gas legacy: 137325 +// gas legacyOptimized: 136059 diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call.sol index dc6ead60b..ab7a94372 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call.sol @@ -45,7 +45,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // callExternal() -> true diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_declaration.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_declaration.sol index a70c6b903..863996141 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_declaration.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_declaration.sol @@ -48,7 +48,6 @@ contract C is Base { } // ==== -// compileViaYul: also // EVMVersion: >=byzantium // ---- // test() -> 11116 diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_is_consistent.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_is_consistent.sol index 3c053e38a..c54d6083c 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_is_consistent.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_is_consistent.sol @@ -49,8 +49,6 @@ contract C { assert(keccak256(fReturnedFunctionPointer()) == keccak256(fSignatureFromLiteral())); } } -// ==== -// compileViaYul: also // ---- // assertConsistentSelectors() -> // fSignatureFromLiteral() -> 0x20, 0x84, 23450202028776381066253055403048136312616272755117076566855971503345107992576, 26959946667150639794667015087019630673637144422540572481103610249216, 1725436586697640946858688965569256363112777243042596638790631055949824, 86060793054017993816230018372407419485142305772921726565498526629888, 0 diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_memory.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_memory.sol index 781a6684f..2e2420af3 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_memory.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_memory.sol @@ -22,7 +22,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // test() -> 0xa7a0d53700000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_special_args.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_special_args.sol index 24e6d065f..0ce29f406 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_special_args.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_special_args.sol @@ -36,8 +36,6 @@ contract C { assert(keccak256(fSignatureFromLiteralUint()) == keccak256(fPointerUint())); } } -// ==== -// compileViaYul: also // ---- // assertConsistentSelectors() -> // fSignatureFromLiteralNoArgs() -> 0x20, 0x04, 12200448252684243758085936796735499259670113115893304444050964496075123064832 diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_uint_bytes.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_uint_bytes.sol index d19a457f9..ec1ea14b5 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_uint_bytes.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_call_uint_bytes.sol @@ -14,7 +14,6 @@ contract C { } } // ==== -// compileViaYul: also // EVMVersion: >homestead // ---- // f() -> 0x20, 0x60, 0x1234000000000000000000000000000000000000000000000000000000000000, 0x6162000000000000000000000000000000000000000000000000000000000000, 0x1234000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_empty_string_v1.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_empty_string_v1.sol index b35266ced..9f7216e6b 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_empty_string_v1.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_empty_string_v1.sol @@ -8,5 +8,6 @@ contract C { } // ==== // ABIEncoderV1Only: true +// compileViaYul: false // ---- // f() -> 0x40, 0xa0, 0x40, 0x20, 0x0, 0x0 diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_selector.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_selector.sol index 71a6e5e49..45c71e4d8 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_selector.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_selector.sol @@ -16,7 +16,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f0() -> 0x20, 4, 8234104107246695022420661102507966550300666591269321702959126607540084801536 diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_selectorv2.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_selectorv2.sol index 648ba1f49..a4f24a963 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_selectorv2.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_selectorv2.sol @@ -25,7 +25,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f0() -> 0x20, 4, 8234104107246695022420661102507966550300666591269321702959126607540084801536 diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_signature.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_signature.sol index 7247ede17..61a8d0b43 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_signature.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_signature.sol @@ -25,8 +25,6 @@ contract C { ar = new uint[](2); } } -// ==== -// compileViaYul: also // ---- // f0() -> 0x20, 4, -34435155370463444793260793355178157075203752403645521721995013737368954863616 // f1() -> 0x20, 0x64, -34435155370463444793260793355178157075203752403645521721995013737368954863616, 862718293348820473429344482784628181556388621521298319395315527974912, 91135606241822717681769169345594720818313984248279388438121731325952, 0 diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_signaturev2.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_signaturev2.sol index 1968a76a8..402053086 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_signaturev2.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_encode_with_signaturev2.sol @@ -33,8 +33,6 @@ contract C { return abi.encodeWithSignature(s.b, type(uint).max, s, uint(3)); } } -// ==== -// compileViaYul: also // ---- // f0() -> 0x20, 4, -34435155370463444793260793355178157075203752403645521721995013737368954863616 // f1() -> 0x20, 0x64, -34435155370463444793260793355178157075203752403645521721995013737368954863616, 862718293348820473429344482784628181556388621521298319395315527974912, 91135606241822717681769169345594720818313984248279388438121731325952, 0 diff --git a/test/libsolidity/semanticTests/abiencodedecode/contract_array.sol b/test/libsolidity/semanticTests/abiencodedecode/contract_array.sol index c26aea83a..7187ccf5d 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/contract_array.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/contract_array.sol @@ -10,8 +10,6 @@ contract C { return abi.encode(c); } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 0xA0, 0x20, 3, 0x01, 0x02, 0x03 -> 0x20, 3, 0x01, 0x02, 0x03 // g() -> 0x20, 0xa0, 0x20, 3, 0x42, 0x21, 0x23 diff --git a/test/libsolidity/semanticTests/abiencodedecode/contract_array_v2.sol b/test/libsolidity/semanticTests/abiencodedecode/contract_array_v2.sol index 69360fe04..0e56ecf58 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/contract_array_v2.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/contract_array_v2.sol @@ -11,8 +11,6 @@ contract C { return abi.encode(c); } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 0xA0, 0x20, 3, 0x01, 0x02, 0x03 -> 0x20, 3, 0x01, 0x02, 0x03 // f(bytes): 0x20, 0x60, 0x20, 1, 0x0102030405060708090a0b0c0d0e0f1011121314 -> 0x20, 1, 0x0102030405060708090a0b0c0d0e0f1011121314 diff --git a/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding.sol b/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding.sol index 12223ed0c..736794dc4 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding.sol @@ -24,7 +24,6 @@ contract Test { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // test() -> FAILURE diff --git a/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_2.sol b/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_2.sol index a727e5719..fe956322f 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_2.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_2.sol @@ -25,7 +25,6 @@ contract Test { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // withinArray() -> FAILURE diff --git a/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_3.sol b/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_3.sol index 4793b5e6e..8a7e572cc 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_3.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/offset_overflow_in_array_decoding_3.sol @@ -18,7 +18,6 @@ contract Test { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // test() -> FAILURE diff --git a/test/libsolidity/semanticTests/accessor/accessor_for_const_state_variable.sol b/test/libsolidity/semanticTests/accessor/accessor_for_const_state_variable.sol index b180b2e6b..1d6346259 100644 --- a/test/libsolidity/semanticTests/accessor/accessor_for_const_state_variable.sol +++ b/test/libsolidity/semanticTests/accessor/accessor_for_const_state_variable.sol @@ -3,6 +3,5 @@ contract Lotto { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // ticketPrice() -> 555 diff --git a/test/libsolidity/semanticTests/accessor/accessor_for_state_variable.sol b/test/libsolidity/semanticTests/accessor/accessor_for_state_variable.sol index a6066107e..16b534585 100644 --- a/test/libsolidity/semanticTests/accessor/accessor_for_state_variable.sol +++ b/test/libsolidity/semanticTests/accessor/accessor_for_state_variable.sol @@ -4,6 +4,5 @@ contract Lotto { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // ticketPrice() -> 500 diff --git a/test/libsolidity/semanticTests/arithmetics/addmod_mulmod.sol b/test/libsolidity/semanticTests/arithmetics/addmod_mulmod.sol index 6afd7458a..034abce94 100644 --- a/test/libsolidity/semanticTests/arithmetics/addmod_mulmod.sol +++ b/test/libsolidity/semanticTests/arithmetics/addmod_mulmod.sol @@ -10,6 +10,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 0 diff --git a/test/libsolidity/semanticTests/arithmetics/addmod_mulmod_zero.sol b/test/libsolidity/semanticTests/arithmetics/addmod_mulmod_zero.sol index 51805ae11..cfcd9463f 100644 --- a/test/libsolidity/semanticTests/arithmetics/addmod_mulmod_zero.sol +++ b/test/libsolidity/semanticTests/arithmetics/addmod_mulmod_zero.sol @@ -20,7 +20,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 0 -> FAILURE, hex"4e487b71", 0x12 // g(uint256): 0 -> FAILURE, hex"4e487b71", 0x12 diff --git a/test/libsolidity/semanticTests/arithmetics/block_inside_unchecked.sol b/test/libsolidity/semanticTests/arithmetics/block_inside_unchecked.sol index 59ffb44f8..b62628910 100644 --- a/test/libsolidity/semanticTests/arithmetics/block_inside_unchecked.sol +++ b/test/libsolidity/semanticTests/arithmetics/block_inside_unchecked.sol @@ -9,6 +9,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x00 diff --git a/test/libsolidity/semanticTests/arithmetics/check_var_init.sol b/test/libsolidity/semanticTests/arithmetics/check_var_init.sol index 7e3edc127..29fa81ffe 100644 --- a/test/libsolidity/semanticTests/arithmetics/check_var_init.sol +++ b/test/libsolidity/semanticTests/arithmetics/check_var_init.sol @@ -13,8 +13,6 @@ contract D { return (new C{value: 11}()).x(); } } -// ==== -// compileViaYul: also // ---- // f() -> FAILURE, hex"4e487b71", 0x11 // g(), 100 wei -> 1 diff --git a/test/libsolidity/semanticTests/arithmetics/checked_add_v1.sol b/test/libsolidity/semanticTests/arithmetics/checked_add_v1.sol index 600ddee07..03c2bb567 100644 --- a/test/libsolidity/semanticTests/arithmetics/checked_add_v1.sol +++ b/test/libsolidity/semanticTests/arithmetics/checked_add_v1.sol @@ -7,6 +7,7 @@ contract C { } // ==== // ABIEncoderV1Only: true +// compileViaYul: false // ---- // f(uint16,uint16): 65534, 0 -> 0xfffe // f(uint16,uint16): 65536, 0 -> 0x00 diff --git a/test/libsolidity/semanticTests/arithmetics/checked_add_v2.sol b/test/libsolidity/semanticTests/arithmetics/checked_add_v2.sol index 884f4717e..8a29cb2b2 100644 --- a/test/libsolidity/semanticTests/arithmetics/checked_add_v2.sol +++ b/test/libsolidity/semanticTests/arithmetics/checked_add_v2.sol @@ -4,8 +4,6 @@ contract C { return a + b; } } -// ==== -// compileViaYul: also // ---- // f(uint16,uint16): 65534, 0 -> 0xfffe // f(uint16,uint16): 65536, 0 -> FAILURE diff --git a/test/libsolidity/semanticTests/arithmetics/checked_called_by_unchecked.sol b/test/libsolidity/semanticTests/arithmetics/checked_called_by_unchecked.sol index bf8b7bdfb..4fc0ff189 100644 --- a/test/libsolidity/semanticTests/arithmetics/checked_called_by_unchecked.sol +++ b/test/libsolidity/semanticTests/arithmetics/checked_called_by_unchecked.sol @@ -9,7 +9,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint16,uint16,uint16): 0xe000, 0xe500, 2 -> FAILURE, hex"4e487b71", 0x11 // f(uint16,uint16,uint16): 0xe000, 0x1000, 0x1000 -> 0x00 diff --git a/test/libsolidity/semanticTests/arithmetics/checked_modifier_called_by_unchecked.sol b/test/libsolidity/semanticTests/arithmetics/checked_modifier_called_by_unchecked.sol index 7a1021217..267489b41 100644 --- a/test/libsolidity/semanticTests/arithmetics/checked_modifier_called_by_unchecked.sol +++ b/test/libsolidity/semanticTests/arithmetics/checked_modifier_called_by_unchecked.sol @@ -9,7 +9,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(uint16,uint16,uint16): 0xe000, 0xe500, 2 -> 58626 diff --git a/test/libsolidity/semanticTests/arithmetics/divisiod_by_zero.sol b/test/libsolidity/semanticTests/arithmetics/divisiod_by_zero.sol index 47e9e4c1f..d996409ca 100644 --- a/test/libsolidity/semanticTests/arithmetics/divisiod_by_zero.sol +++ b/test/libsolidity/semanticTests/arithmetics/divisiod_by_zero.sol @@ -9,7 +9,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // div(uint256,uint256): 7, 2 -> 3 // div(uint256,uint256): 7, 0 -> FAILURE, hex"4e487b71", 0x12 # throws # diff --git a/test/libsolidity/semanticTests/arithmetics/exp_associativity.sol b/test/libsolidity/semanticTests/arithmetics/exp_associativity.sol index 4b2341949..730209fb5 100644 --- a/test/libsolidity/semanticTests/arithmetics/exp_associativity.sol +++ b/test/libsolidity/semanticTests/arithmetics/exp_associativity.sol @@ -30,8 +30,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // test_hardcode1(uint256,uint256,uint256): 2, 3, 4 -> 2417851639229258349412352 // test_hardcode2(uint256,uint256,uint256,uint256): 3, 2, 2, 2 -> 43046721 diff --git a/test/libsolidity/semanticTests/arithmetics/signed_mod.sol b/test/libsolidity/semanticTests/arithmetics/signed_mod.sol index 68274de5a..0239810ab 100644 --- a/test/libsolidity/semanticTests/arithmetics/signed_mod.sol +++ b/test/libsolidity/semanticTests/arithmetics/signed_mod.sol @@ -13,7 +13,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(int256,int256): 7, 5 -> 2 diff --git a/test/libsolidity/semanticTests/arithmetics/unchecked_called_by_checked.sol b/test/libsolidity/semanticTests/arithmetics/unchecked_called_by_checked.sol index 9fc665cb6..f7859e6c1 100644 --- a/test/libsolidity/semanticTests/arithmetics/unchecked_called_by_checked.sol +++ b/test/libsolidity/semanticTests/arithmetics/unchecked_called_by_checked.sol @@ -11,7 +11,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint16): 7 -> 0x0207 // f(uint16): 0xffff -> 511 diff --git a/test/libsolidity/semanticTests/arithmetics/unchecked_div_by_zero.sol b/test/libsolidity/semanticTests/arithmetics/unchecked_div_by_zero.sol index 7bb133960..6e9cc90ae 100644 --- a/test/libsolidity/semanticTests/arithmetics/unchecked_div_by_zero.sol +++ b/test/libsolidity/semanticTests/arithmetics/unchecked_div_by_zero.sol @@ -15,7 +15,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // div(uint256,uint256): 7, 2 -> 3 // div(uint256,uint256): 7, 0 -> FAILURE, hex"4e487b71", 0x12 # throws # diff --git a/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol b/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol index 8d1851c81..17243226f 100644 --- a/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol +++ b/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol @@ -10,11 +10,9 @@ contract Test { return data; } } -// ==== -// compileViaYul: also // ---- // set(uint24[3][]): 0x20, 0x06, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12 -> 0x06 -// gas irOptimized: 189800 +// gas irOptimized: 186766 // gas legacy: 211149 // gas legacyOptimized: 206054 // data(uint256,uint256): 0x02, 0x02 -> 0x09 diff --git a/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol b/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol index b176c7e86..72fa6860f 100644 --- a/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol +++ b/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol @@ -38,8 +38,6 @@ contract c { } } } -// ==== -// compileViaYul: also // ---- // storageEmpty -> 1 // test_short() -> 1780731860627700044960722568376587075150542249149356309979516913770823710 diff --git a/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol b/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol index f0b0d1bc0..fad9647ec 100644 --- a/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol +++ b/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol @@ -15,10 +15,8 @@ contract c { return 0; } } -// ==== -// compileViaYul: also // ---- // test() -> 0 -// gas irOptimized: 157949 +// gas irOptimized: 157200 // gas legacy: 188576 // gas legacyOptimized: 183333 diff --git a/test/libsolidity/semanticTests/array/bytes_length_member.sol b/test/libsolidity/semanticTests/array/bytes_length_member.sol index b4e018e65..387ef0930 100644 --- a/test/libsolidity/semanticTests/array/bytes_length_member.sol +++ b/test/libsolidity/semanticTests/array/bytes_length_member.sol @@ -10,12 +10,10 @@ contract c { bytes data; } -// ==== -// compileViaYul: also // ---- // getLength() -> 0 // set(): 1, 2 -> true -// gas irOptimized: 110435 -// gas legacy: 110723 -// gas legacyOptimized: 110564 +// gas irOptimized: 110402 +// gas legacy: 110968 +// gas legacyOptimized: 110585 // getLength() -> 68 diff --git a/test/libsolidity/semanticTests/array/bytes_to_fixed_bytes_simple.sol b/test/libsolidity/semanticTests/array/bytes_to_fixed_bytes_simple.sol index f495d880b..4300d8a6f 100644 --- a/test/libsolidity/semanticTests/array/bytes_to_fixed_bytes_simple.sol +++ b/test/libsolidity/semanticTests/array/bytes_to_fixed_bytes_simple.sol @@ -18,8 +18,6 @@ contract C { return bytes8(c[1:9]); } } -// ==== -// compileViaYul: also // ---- // fromMemory(bytes): 0x20, 16, "abcdefghabcdefgh" -> "abcdefghabcdefgh" // fromCalldata(bytes): 0x20, 16, "abcdefghabcdefgh" -> "abcdefghabcdefgh" diff --git a/test/libsolidity/semanticTests/array/bytes_to_fixed_bytes_too_long.sol b/test/libsolidity/semanticTests/array/bytes_to_fixed_bytes_too_long.sol index 72aba092f..04bdd83fc 100644 --- a/test/libsolidity/semanticTests/array/bytes_to_fixed_bytes_too_long.sol +++ b/test/libsolidity/semanticTests/array/bytes_to_fixed_bytes_too_long.sol @@ -14,8 +14,6 @@ contract C { return bytes32(c[0:33]); } } -// ==== -// compileViaYul: also // ---- // fromMemory(bytes): 0x20, 33, "abcdefghabcdefghabcdefghabcdefgh", "a" -> "abcdefghabcdefghabcdefghabcdefgh" // fromCalldata(bytes): 0x20, 33, "abcdefghabcdefghabcdefghabcdefgh", "a" -> "abcdefghabcdefghabcdefghabcdefgh" diff --git a/test/libsolidity/semanticTests/array/calldata_array.sol b/test/libsolidity/semanticTests/array/calldata_array.sol index 6a985b495..cdb1c9b6d 100644 --- a/test/libsolidity/semanticTests/array/calldata_array.sol +++ b/test/libsolidity/semanticTests/array/calldata_array.sol @@ -13,6 +13,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256[2]): 42, 23 -> 42, 23 diff --git a/test/libsolidity/semanticTests/array/calldata_array_as_argument_internal_function.sol b/test/libsolidity/semanticTests/array/calldata_array_as_argument_internal_function.sol index bef9fc651..99bd31c57 100644 --- a/test/libsolidity/semanticTests/array/calldata_array_as_argument_internal_function.sol +++ b/test/libsolidity/semanticTests/array/calldata_array_as_argument_internal_function.sol @@ -14,7 +14,6 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g(uint256[]): 0x20, 4, 1, 2, 3, 4 -> 4, 1 // h(uint256[],uint256,uint256): 0x60, 1, 3, 4, 1, 2, 3, 4 -> 2, 2 diff --git a/test/libsolidity/semanticTests/array/calldata_array_dynamic_invalid.sol b/test/libsolidity/semanticTests/array/calldata_array_dynamic_invalid.sol index 89d7172c1..190d73d79 100644 --- a/test/libsolidity/semanticTests/array/calldata_array_dynamic_invalid.sol +++ b/test/libsolidity/semanticTests/array/calldata_array_dynamic_invalid.sol @@ -13,7 +13,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256[][]): 0x20, 0x0 -> 42 # valid access stub # // f(uint256[][]): 0x20, 0x1 -> FAILURE # invalid on argument decoding # diff --git a/test/libsolidity/semanticTests/array/calldata_array_dynamic_invalid_static_middle.sol b/test/libsolidity/semanticTests/array/calldata_array_dynamic_invalid_static_middle.sol index d63b14302..93470f1d2 100644 --- a/test/libsolidity/semanticTests/array/calldata_array_dynamic_invalid_static_middle.sol +++ b/test/libsolidity/semanticTests/array/calldata_array_dynamic_invalid_static_middle.sol @@ -16,8 +16,6 @@ contract C { return 42; } } -// ==== -// compileViaYul: also // ---- // f(uint256[][1][]): 0x20, 0x0 -> 42 # valid access stub # // f(uint256[][1][]): 0x20, 0x1 -> FAILURE # invalid on argument decoding # diff --git a/test/libsolidity/semanticTests/array/calldata_array_of_struct.sol b/test/libsolidity/semanticTests/array/calldata_array_of_struct.sol index 2e0c871d6..c31ffcb53 100644 --- a/test/libsolidity/semanticTests/array/calldata_array_of_struct.sol +++ b/test/libsolidity/semanticTests/array/calldata_array_of_struct.sol @@ -22,6 +22,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f((uint256,uint256)[]): 0x20, 0x2, 0x1, 0x2, 0x3, 0x4 -> 2, 1, 2, 3, 4 diff --git a/test/libsolidity/semanticTests/array/calldata_array_two_dimensional.sol b/test/libsolidity/semanticTests/array/calldata_array_two_dimensional.sol index 95e257bee..69104d383 100644 --- a/test/libsolidity/semanticTests/array/calldata_array_two_dimensional.sol +++ b/test/libsolidity/semanticTests/array/calldata_array_two_dimensional.sol @@ -13,8 +13,6 @@ contract C { return this.test(a, i, j); } } -// ==== -// compileViaYul: also // ---- // test(uint256[][2]): 0x20, 0x40, 0xC0, 3, 0x0A01, 0x0A02, 0x0A03, 4, 0x0B01, 0x0B02, 0x0B03, 0x0B04 -> 2 // test(uint256[][2],uint256): 0x40, 0, 0x40, 0xC0, 3, 0x0A01, 0x0A02, 0x0A03, 4, 0x0B01, 0x0B02, 0x0B03, 0x0B04 -> 3 diff --git a/test/libsolidity/semanticTests/array/calldata_array_two_dimensional_1.sol b/test/libsolidity/semanticTests/array/calldata_array_two_dimensional_1.sol index 23c251307..e96f49284 100644 --- a/test/libsolidity/semanticTests/array/calldata_array_two_dimensional_1.sol +++ b/test/libsolidity/semanticTests/array/calldata_array_two_dimensional_1.sol @@ -13,8 +13,6 @@ contract C { return this.test(a, i, j); } } -// ==== -// compileViaYul: also // ---- // test(uint256[][]): 0x20, 2, 0x40, 0xC0, 3, 0x0A01, 0x0A02, 0x0A03, 4, 0x0B01, 0x0B02, 0x0B03, 0x0B04 -> 2 // test(uint256[][],uint256): 0x40, 0, 2, 0x40, 0xC0, 3, 0x0A01, 0x0A02, 0x0A03, 4, 0x0B01, 0x0B02, 0x0B03, 0x0B04 -> 3 diff --git a/test/libsolidity/semanticTests/array/calldata_bytes_array_bounds.sol b/test/libsolidity/semanticTests/array/calldata_bytes_array_bounds.sol index df15ad38b..d6ff4679f 100644 --- a/test/libsolidity/semanticTests/array/calldata_bytes_array_bounds.sol +++ b/test/libsolidity/semanticTests/array/calldata_bytes_array_bounds.sol @@ -4,8 +4,6 @@ contract C { return uint8(a[0][i]); } } -// ==== -// compileViaYul: also // ---- // f(bytes[],uint256): 0x40, 0, 1, 0x20, 2, 0x6162000000000000000000000000000000000000000000000000000000000000 -> 0x61 // f(bytes[],uint256): 0x40, 1, 1, 0x20, 2, 0x6162000000000000000000000000000000000000000000000000000000000000 -> 0x62 diff --git a/test/libsolidity/semanticTests/array/calldata_slice_access.sol b/test/libsolidity/semanticTests/array/calldata_slice_access.sol index d898bf92f..b8eb63829 100644 --- a/test/libsolidity/semanticTests/array/calldata_slice_access.sol +++ b/test/libsolidity/semanticTests/array/calldata_slice_access.sol @@ -8,7 +8,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256[],uint256,uint256): 0x80, 0, 0, 0, 1, 42 -> // f(uint256[],uint256,uint256): 0x80, 0, 1, 0, 1, 42 -> diff --git a/test/libsolidity/semanticTests/array/concat/bytes_concat_2_args.sol b/test/libsolidity/semanticTests/array/concat/bytes_concat_2_args.sol index 239caf042..84c562116 100644 --- a/test/libsolidity/semanticTests/array/concat/bytes_concat_2_args.sol +++ b/test/libsolidity/semanticTests/array/concat/bytes_concat_2_args.sol @@ -3,8 +3,6 @@ contract C { return bytes.concat(a, b); } } -// ==== -// compileViaYul: also // ---- // f(bytes,bytes): 0x40, 0x80, 32, "abcdabcdabcdabcdabcdabcdabcdabcd", 5, "bcdef" -> 0x20, 37, "abcdabcdabcdabcdabcdabcdabcdabcd", "bcdef" // diff --git a/test/libsolidity/semanticTests/array/concat/bytes_concat_3_args.sol b/test/libsolidity/semanticTests/array/concat/bytes_concat_3_args.sol index d5a3bdc4d..d6b9e3767 100644 --- a/test/libsolidity/semanticTests/array/concat/bytes_concat_3_args.sol +++ b/test/libsolidity/semanticTests/array/concat/bytes_concat_3_args.sol @@ -3,8 +3,6 @@ contract C { return bytes.concat(a, b, c); } } -// ==== -// compileViaYul: also // ---- // f(bytes,bytes,bytes): 0x60, 0xa0, 0xe0, 32, "abcdabcdabcdabcdabcdabcdabcdabcd", 5, "bcdef", 3, "abc" -> 0x20, 40, "abcdabcdabcdabcdabcdabcdabcdabcd", "bcdefabc" // f(bytes,bytes,bytes): 0x60, 0xa0, 0xe0, 3, "abc", 2, "de", 3, "fgh" -> 0x20, 8, "abcdefgh" diff --git a/test/libsolidity/semanticTests/array/concat/bytes_concat_as_argument.sol b/test/libsolidity/semanticTests/array/concat/bytes_concat_as_argument.sol index 950ff3320..030a959a5 100644 --- a/test/libsolidity/semanticTests/array/concat/bytes_concat_as_argument.sol +++ b/test/libsolidity/semanticTests/array/concat/bytes_concat_as_argument.sol @@ -11,8 +11,6 @@ contract C { return h(bytes.concat(a, b)); } } -// ==== -// compileViaYul: also // ---- // f(bytes,bytes): 0x40, 0x80, 32, "abcdabcdabcdabcdabcdabcdabcdabcd", 5, "bcdef" -> 0x1106e19b6f06d1cce71c2d816754f83dfa5b95df958c5cbf12b7c472320c427c // g(bytes,bytes): 0x40, 0x80, 32, "abcdabcdabcdabcdabcdabcdabcdabcd", 5, "bcdef" -> 37 diff --git a/test/libsolidity/semanticTests/array/concat/bytes_concat_different_types.sol b/test/libsolidity/semanticTests/array/concat/bytes_concat_different_types.sol index bd28d478d..a6b7f5737 100644 --- a/test/libsolidity/semanticTests/array/concat/bytes_concat_different_types.sol +++ b/test/libsolidity/semanticTests/array/concat/bytes_concat_different_types.sol @@ -45,7 +45,6 @@ contract C { } } // ==== -// compileViaYul: also // revertStrings: debug // ---- // f(bytes): 0x20, 32, "abcdabcdabcdabcdabcdabcdabcdabcd" -> 0x20, 37, "abcdabcdabcdabcdabcdabcdabcdabcd", "bcdef" diff --git a/test/libsolidity/semanticTests/array/concat/bytes_concat_empty_argument_list.sol b/test/libsolidity/semanticTests/array/concat/bytes_concat_empty_argument_list.sol index 74f2a87b9..0485012e3 100644 --- a/test/libsolidity/semanticTests/array/concat/bytes_concat_empty_argument_list.sol +++ b/test/libsolidity/semanticTests/array/concat/bytes_concat_empty_argument_list.sol @@ -4,7 +4,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 0x20, 0 diff --git a/test/libsolidity/semanticTests/array/concat/bytes_concat_empty_strings.sol b/test/libsolidity/semanticTests/array/concat/bytes_concat_empty_strings.sol index 0dc856262..a83e5462b 100644 --- a/test/libsolidity/semanticTests/array/concat/bytes_concat_empty_strings.sol +++ b/test/libsolidity/semanticTests/array/concat/bytes_concat_empty_strings.sol @@ -20,7 +20,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x20, 0 // g() -> 0x20, 6, "abcabc" diff --git a/test/libsolidity/semanticTests/array/concat/bytes_concat_nested.sol b/test/libsolidity/semanticTests/array/concat/bytes_concat_nested.sol index 6a469314b..f4190322f 100644 --- a/test/libsolidity/semanticTests/array/concat/bytes_concat_nested.sol +++ b/test/libsolidity/semanticTests/array/concat/bytes_concat_nested.sol @@ -3,7 +3,5 @@ contract C { return bytes.concat(bytes.concat(a, b), c); } } -// ==== -// compileViaYul: also // ---- // f(bytes,bytes,bytes): 0x60, 0x60, 0x60, 2, "ab" -> 0x20, 6, "ababab" diff --git a/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol b/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol index 42d14ba24..fc51f4e30 100644 --- a/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol +++ b/test/libsolidity/semanticTests/array/constant_var_as_array_length.sol @@ -7,11 +7,9 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // constructor(): 1, 2, 3 -> -// gas irOptimized: 142640 +// gas irOptimized: 141581 // gas legacy: 183490 // gas legacyOptimized: 151938 // a(uint256): 0 -> 1 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol b/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol index f80da3500..6afd8f88f 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol @@ -18,11 +18,9 @@ contract c { g = m_byte_data[3][1]; } } -// ==== -// compileViaYul: also // ---- // store(uint256[9],uint8[3][]): 21, 22, 23, 24, 25, 26, 27, 28, 29, 0x140, 4, 1, 2, 3, 11, 12, 13, 21, 22, 23, 31, 32, 33 -> 32 -// gas irOptimized: 650608 +// gas irOptimized: 648324 // gas legacy: 694515 // gas legacyOptimized: 694013 // retrieve() -> 9, 28, 9, 28, 4, 3, 32 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint128.sol b/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint128.sol index 3449cdc2d..761feebec 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint128.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint128.sol @@ -19,8 +19,6 @@ contract C { return true; } } -// ==== -// compileViaYul: also // ---- // f() -> true // gas irOptimized: 92740 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol b/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol index 73abd2cf7..915c0aeed 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol @@ -44,10 +44,8 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f() -> true -// gas irOptimized: 153260 +// gas irOptimized: 146936 // gas legacy: 155961 // gas legacyOptimized: 153588 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol b/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol index e90cf7e58..416b48968 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol @@ -11,10 +11,8 @@ contract C { return x[3]; } } -// ==== -// compileViaYul: also // ---- // f() -> 0 -// gas irOptimized: 135098 +// gas irOptimized: 134365 // gas legacy: 135313 // gas legacyOptimized: 134548 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage_packed.sol b/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage_packed.sol index bd596b86c..13cb9c28f 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage_packed.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage_packed.sol @@ -38,8 +38,6 @@ contract C { return x2[1]; } } -// ==== -// compileViaYul: also // ---- // f() -> 0 // gas irOptimized: 92800 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol b/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol index 04b3b8e84..86da315c3 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol @@ -17,10 +17,8 @@ contract c { } } -// ==== -// compileViaYul: also // ---- // test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x05000000000000000000000000000000000000000000000000 -// gas irOptimized: 212564 +// gas irOptimized: 208149 // gas legacy: 221856 // gas legacyOptimized: 220680 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol b/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol index 92495b157..c3958abac 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol @@ -33,16 +33,14 @@ contract c { return (small.length, large.length); } } -// ==== -// compileViaYul: also // ---- // test() -> 0x02000202 -// gas irOptimized: 4652048 -// gas legacy: 4578320 -// gas legacyOptimized: 4548312 +// gas irOptimized: 4649835 +// gas legacy: 4578446 +// gas legacyOptimized: 4548309 // storageEmpty -> 1 // clear() -> 0, 0 -// gas irOptimized: 4483170 +// gas irOptimized: 4477223 // gas legacy: 4410748 // gas legacyOptimized: 4382489 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_copy_memory_to_storage.sol index 7b1750acc..205920f65 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_memory_to_storage.sol @@ -23,8 +23,6 @@ contract C { return (a[0], b[1], a[2]); } } -// ==== -// compileViaYul: also // ---- // f() -> 1, 3 // g() -> 1, 2, 3 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol b/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol index 88fed0d9b..a85765cd9 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol @@ -11,10 +11,8 @@ contract c { } } -// ==== -// compileViaYul: also // ---- // test(uint256[2][]): 32, 3, 7, 8, 9, 10, 11, 12 -> 10 -// gas irOptimized: 690203 +// gas irOptimized: 689759 // gas legacy: 686268 // gas legacyOptimized: 685688 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_abi_signed.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_abi_signed.sol index 1d2c978fb..0e225f1e5 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_abi_signed.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_abi_signed.sol @@ -16,7 +16,5 @@ contract c { } } -// ==== -// compileViaYul: also // ---- // test() -> 0x20, 0x8, -1, -1, 8, -16, -2, 6, 8, -1 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol index bd45f49a9..a0e600d1a 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol @@ -15,10 +15,8 @@ contract c { y = data2[4]; } } -// ==== -// compileViaYul: also // ---- // test() -> 5, 4 -// gas irOptimized: 225954 +// gas irOptimized: 225027 // gas legacy: 233801 // gas legacyOptimized: 232816 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol index 4a475ac55..3e59244bd 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol @@ -21,9 +21,8 @@ contract c { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 3, 4 -// gas irOptimized: 190480 +// gas irOptimized: 189690 // gas legacy: 195353 // gas legacyOptimized: 192441 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dyn_dyn.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dyn_dyn.sol index f90d4b852..5e12fa657 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dyn_dyn.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dyn_dyn.sol @@ -12,12 +12,10 @@ contract c { len = data2.length; if (index < len) val = data2[index]; } } -// ==== -// compileViaYul: also // ---- // setData1(uint256,uint256,uint256): 10, 5, 4 -> // copyStorageStorage() -> -// gas irOptimized: 111387 +// gas irOptimized: 111368 // gas legacy: 109278 // gas legacyOptimized: 109268 // getData2(uint256): 5 -> 10, 4 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol index 3b8fe6212..c9ae2c0e6 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol @@ -16,10 +16,8 @@ contract c { } } -// ==== -// compileViaYul: also // ---- // test() -> 5, 4 -// gas irOptimized: 272736 +// gas irOptimized: 272950 // gas legacy: 270834 // gas legacyOptimized: 269960 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol index d2d7f4e48..99e6b06f0 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol @@ -10,10 +10,8 @@ contract c { } } -// ==== -// compileViaYul: also // ---- // test() -> 9, 4 -// gas irOptimized: 123162 +// gas irOptimized: 123143 // gas legacy: 123579 // gas legacyOptimized: 123208 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_simple.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_simple.sol index a7dacd749..00c69b7de 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_simple.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_simple.sol @@ -11,7 +11,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> left(0x01), left(0x02) // gas legacy: 90001 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol index ad12cad12..8f6dd822d 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol @@ -15,7 +15,6 @@ contract c { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 8, 0 // gas irOptimized: 236079 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol index 676736dc1..3fc10b7a2 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol @@ -15,11 +15,9 @@ contract c { data2 = data1; } } -// ==== -// compileViaYul: also // ---- // test() -> 4, 5 -// gas irOptimized: 238799 +// gas irOptimized: 238623 // gas legacy: 238736 // gas legacyOptimized: 237159 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory.sol index cd3c184d2..8bc6b86a2 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory.sol @@ -6,7 +6,5 @@ contract C { return (b[0], b.length); } } -// ==== -// compileViaYul: also // ---- // f() -> 1, 3 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol index 3b2815526..0aa448e98 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol @@ -13,10 +13,8 @@ contract C { return m; } } -// ==== -// compileViaYul: also // ---- // f() -> 0x20, 2, 0x40, 0xa0, 2, 0, 1, 2, 2, 3 -// gas irOptimized: 161780 +// gas irOptimized: 161777 // gas legacy: 162278 // gas legacyOptimized: 159955 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol index 5325e9cdf..f2d02ee57 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol @@ -17,9 +17,8 @@ contract c { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 0xffffffff, 0x0000000000000000000000000a00090008000700060005000400030002000100, 0x0000000000000000000000000000000000000000000000000000000000000000 -// gas irOptimized: 129167 -// gas legacy: 186184 -// gas legacyOptimized: 165682 +// gas irOptimized: 124910 +// gas legacy: 187414 +// gas legacyOptimized: 165659 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover2.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover2.sol index b42b84dfe..0e0a26fc9 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover2.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover2.sol @@ -19,7 +19,6 @@ contract c { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 0x04000000000000000000000000000000000000000000000000, 0x0, 0x0 // gas irOptimized: 93858 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol index 68817ba4c..5c01bf219 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol @@ -19,9 +19,8 @@ contract c { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x0 -// gas irOptimized: 294770 +// gas irOptimized: 293621 // gas legacy: 303626 // gas legacyOptimized: 301945 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol index 346b1c469..89e30b0d4 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol @@ -19,9 +19,8 @@ contract c { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x00 -// gas irOptimized: 273961 +// gas irOptimized: 273177 // gas legacy: 276360 // gas legacyOptimized: 275411 diff --git a/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_memory.sol b/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_memory.sol index 7da4fc4ed..8e92d05f7 100644 --- a/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_memory.sol +++ b/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_memory.sol @@ -29,8 +29,6 @@ contract c { return (a4[0][0] + a4[1][1]); } } -// ==== -// compileViaYul: also // ---- // test1(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 23, 42 -> 2, 65 // test2(uint256[][2]): 0x20, 0x40, 0x40, 2, 23, 42 -> 2, 65 diff --git a/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol index 834f4d28c..02872f8dd 100644 --- a/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol @@ -38,10 +38,10 @@ contract c { // compileViaYul: true // ---- // test1(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 23, 42 -> 2, 65 -// gas irOptimized: 181298 +// gas irOptimized: 180769 // test2(uint256[][2]): 0x20, 0x40, 0x40, 2, 23, 42 -> 2, 65 -// gas irOptimized: 157929 +// gas irOptimized: 157567 // test3(uint256[2][]): 0x20, 2, 23, 42, 23, 42 -> 2, 65 -// gas irOptimized: 135098 +// gas irOptimized: 134644 // test4(uint256[2][2]): 23, 42, 23, 42 -> 65 -// gas irOptimized: 111346 +// gas irOptimized: 111271 diff --git a/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol index e199d37bc..8f8ed06ea 100644 --- a/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol @@ -36,16 +36,14 @@ contract Test { return a[0][0] + a[1][0] + a[2][1]; } } -// ==== -// compileViaYul: also // ---- // test() -> 24 -// gas irOptimized: 227133 -// gas legacy: 227133 -// gas legacyOptimized: 226547 +// gas irOptimized: 226700 +// gas legacy: 227121 +// gas legacyOptimized: 226557 // test1() -> 3 // test2() -> 6 // test3() -> 24 -// gas irOptimized: 133590 -// gas legacy: 134295 -// gas legacyOptimized: 133383 +// gas irOptimized: 133260 +// gas legacy: 134283 +// gas legacyOptimized: 133393 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic.sol b/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic.sol index e358feaf7..3b150f4f7 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic.sol @@ -43,11 +43,9 @@ contract C { internalArray0[2] == internalArray1[2]; } } -// ==== -// compileViaYul: also // ---- // copyExternalStorageArrayOfFunctionType() -> true -// gas irOptimized: 104659 +// gas irOptimized: 104615 // gas legacy: 108722 // gas legacyOptimized: 102438 // copyInternalArrayOfFunctionType() -> true diff --git a/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic_different_mutability.sol b/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic_different_mutability.sol index 551ed4616..6576149eb 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic_different_mutability.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_function_external_storage_to_storage_dynamic_different_mutability.sol @@ -46,11 +46,9 @@ contract C { internalArray0[2] == internalArray1[2]; } } -// ==== -// compileViaYul: also // ---- // copyExternalStorageArraysOfFunctionType() -> true -// gas irOptimized: 104332 +// gas irOptimized: 104288 // gas legacy: 108459 // gas legacyOptimized: 102171 // copyInternalArrayOfFunctionType() -> true diff --git a/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_memory.sol b/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_memory.sol index 7e2a209bc..a43a941a6 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_memory.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_memory.sol @@ -15,8 +15,6 @@ contract C { return (m[2].a, m[1].b, m[0].c); } } -// ==== -// compileViaYul: also // ---- // f((uint128,uint64,uint128)[3]): 0, 0, 12, 0, 11, 0, 10, 0, 0 -> 10, 11, 12 // g((uint128,uint64,uint128)[]): 0x20, 3, 0, 0, 12, 0, 11, 0, 10, 0, 0 -> 10, 11, 12 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol index c4aa6ac4b..a7487a64f 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol @@ -17,4 +17,4 @@ contract C { // compileViaYul: true // ---- // f((uint128,uint64,uint128)[]): 0x20, 3, 0, 0, 12, 0, 11, 0, 10, 0, 0 -> 10, 11, 12 -// gas irOptimized: 121019 +// gas irOptimized: 119737 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol index 0c554a32f..09653d536 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol @@ -19,4 +19,4 @@ contract C { // compileViaYul: true // ---- // f() -> 10, 11, 12 -// gas irOptimized: 119148 +// gas irOptimized: 118394 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_memory.sol b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_memory.sol index ba132fba3..482cecccc 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_memory.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_memory.sol @@ -17,7 +17,5 @@ contract C { return (s[1].a.length, s[1].a[0]); } } -// ==== -// compileViaYul: also // ---- // f((uint256[])[]): 0x20, 3, 0x60, 0x60, 0x60, 0x20, 3, 1, 2, 3 -> 3, 1 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol index 7d4e1f845..49d307fe2 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol @@ -23,4 +23,4 @@ contract C { // compileViaYul: true // ---- // f((uint256[])[]): 0x20, 3, 0x60, 0x60, 0x60, 0x20, 3, 1, 2, 3 -> 3, 1 -// gas irOptimized: 328592 +// gas irOptimized: 327798 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol index 0b1d71bdf..6701862b2 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol @@ -26,4 +26,4 @@ contract C { // compileViaYul: true // ---- // f() -> 3, 3, 3, 1 -// gas irOptimized: 183316 +// gas irOptimized: 182237 diff --git a/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol b/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol index de38034fd..fbb7244c5 100644 --- a/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol +++ b/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol @@ -12,9 +12,8 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1, 2, 3 -// gas irOptimized: 132298 +// gas irOptimized: 131933 // gas legacy: 134619 // gas legacyOptimized: 131940 diff --git a/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol b/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol index dadbceadc..d13381d80 100644 --- a/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol @@ -8,8 +8,6 @@ contract Test { return data; } } -// ==== -// compileViaYul: also // ---- // set(uint24[]): 0x20, 18, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 -> 18 // gas irOptimized: 99616 diff --git a/test/libsolidity/semanticTests/array/copying/bytes_calldata_to_string_calldata.sol b/test/libsolidity/semanticTests/array/copying/bytes_calldata_to_string_calldata.sol index 0d124f930..88cb47a57 100644 --- a/test/libsolidity/semanticTests/array/copying/bytes_calldata_to_string_calldata.sol +++ b/test/libsolidity/semanticTests/array/copying/bytes_calldata_to_string_calldata.sol @@ -3,7 +3,5 @@ contract C { return string(c); } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 3, "abc" -> 0x20, 3, "abc" diff --git a/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol b/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol index 26ad58f4c..99ee19d7a 100644 --- a/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol +++ b/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol @@ -3,17 +3,15 @@ contract c { function copy(uint from, uint to) public returns (bool) { data[to] = data[from]; return true; } mapping(uint => bytes) data; } -// ==== -// compileViaYul: also // ---- // set(uint256): 1, 2 -> true -// gas irOptimized: 110604 -// gas legacy: 111088 -// gas legacyOptimized: 110733 +// gas irOptimized: 110576 +// gas legacy: 111333 +// gas legacyOptimized: 110750 // set(uint256): 2, 2, 3, 4, 5 -> true -// gas irOptimized: 177564 -// gas legacy: 178018 -// gas legacyOptimized: 177663 +// gas irOptimized: 177527 +// gas legacy: 178335 +// gas legacyOptimized: 177725 // storageEmpty -> 0 // copy(uint256,uint256): 1, 2 -> true // storageEmpty -> 0 diff --git a/test/libsolidity/semanticTests/array/copying/bytes_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/bytes_memory_to_storage.sol index 0e5009624..6cdd48bf1 100644 --- a/test/libsolidity/semanticTests/array/copying/bytes_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/bytes_memory_to_storage.sol @@ -8,6 +8,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> "a" diff --git a/test/libsolidity/semanticTests/array/copying/bytes_storage_to_memory.sol b/test/libsolidity/semanticTests/array/copying/bytes_storage_to_memory.sol index 13a0e788c..e996714ce 100644 --- a/test/libsolidity/semanticTests/array/copying/bytes_storage_to_memory.sol +++ b/test/libsolidity/semanticTests/array/copying/bytes_storage_to_memory.sol @@ -7,6 +7,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> "a" diff --git a/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol b/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol index 29a017e08..ae17b76b1 100644 --- a/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol @@ -14,30 +14,28 @@ contract c { return b; } } -// ==== -// compileViaYul: also // ---- // f(uint256): 0 -> 0x20, 0x00 // f(uint256): 31 -> 0x20, 0x1f, 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e00 -// gas irOptimized: 121735 -// gas legacy: 123884 -// gas legacyOptimized: 119139 +// gas irOptimized: 109413 +// gas legacy: 124296 +// gas legacyOptimized: 119119 // f(uint256): 32 -> 0x20, 0x20, 1780731860627700044960722568376592200742329637303199754547598369979440671 -// gas irOptimized: 130727 -// gas legacy: 134936 -// gas legacyOptimized: 130046 +// gas irOptimized: 118565 +// gas legacy: 135251 +// gas legacyOptimized: 130091 // f(uint256): 33 -> 0x20, 33, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x2000000000000000000000000000000000000000000000000000000000000000 -// gas irOptimized: 137726 -// gas legacy: 141728 -// gas legacyOptimized: 136711 +// gas irOptimized: 125184 +// gas legacy: 142835 +// gas legacyOptimized: 137008 // f(uint256): 63 -> 0x20, 0x3f, 1780731860627700044960722568376592200742329637303199754547598369979440671, 14532552714582660066924456880521368950258152170031413196862950297402215316992 -// gas irOptimized: 152346 -// gas legacy: 159768 -// gas legacyOptimized: 150641 +// gas irOptimized: 128584 +// gas legacy: 160875 +// gas legacyOptimized: 150938 // f(uint256): 12 -> 0x20, 0x0c, 0x0102030405060708090a0b0000000000000000000000000000000000000000 // gas legacy: 59345 // gas legacyOptimized: 57279 // f(uint256): 129 -> 0x20, 0x81, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f, 29063324697304692433803953038474361308315562010425523193971352996434451193439, 0x606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f, -57896044618658097711785492504343953926634992332820282019728792003956564819968 -// gas irOptimized: 406083 -// gas legacy: 421067 -// gas legacyOptimized: 402910 +// gas irOptimized: 357699 +// gas legacy: 421674 +// gas legacyOptimized: 402977 diff --git a/test/libsolidity/semanticTests/array/copying/calldata_2d_bytes_to_memory.sol b/test/libsolidity/semanticTests/array/copying/calldata_2d_bytes_to_memory.sol index 1687fb54a..192ece49e 100644 --- a/test/libsolidity/semanticTests/array/copying/calldata_2d_bytes_to_memory.sol +++ b/test/libsolidity/semanticTests/array/copying/calldata_2d_bytes_to_memory.sol @@ -8,7 +8,5 @@ contract C { return g(c); } } -// ==== -// compileViaYul: also // ---- // f(bytes[2]): 0x20, 0x40, 0x40, 2, "ab" -> 0x20, 2, "ab" diff --git a/test/libsolidity/semanticTests/array/copying/calldata_2d_bytes_to_memory_2.sol b/test/libsolidity/semanticTests/array/copying/calldata_2d_bytes_to_memory_2.sol index 4f43cc1eb..3bdda3045 100644 --- a/test/libsolidity/semanticTests/array/copying/calldata_2d_bytes_to_memory_2.sol +++ b/test/libsolidity/semanticTests/array/copying/calldata_2d_bytes_to_memory_2.sol @@ -11,8 +11,6 @@ contract C { g(c); } } -// ==== -// compileViaYul: also // ---- // f(bytes[2]): 0x20, 0x40, 0x40, 2, "ab" -> // f(bytes[2]): 0x20, 0x40, 0x40, 1, "a" -> FAILURE, hex"4e487b71", 0x01 diff --git a/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol b/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol index d15044005..0905266d8 100644 --- a/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol @@ -7,10 +7,8 @@ contract C { return s[0]; } } -// ==== -// compileViaYul: also // ---- // f(uint256[]): 0x20, 0x03, 0x1, 0x2, 0x3 -> 0x1 -// gas irOptimized: 111159 +// gas irOptimized: 110971 // gas legacy: 111565 // gas legacyOptimized: 111347 diff --git a/test/libsolidity/semanticTests/array/copying/calldata_array_of_struct_to_memory.sol b/test/libsolidity/semanticTests/array/copying/calldata_array_of_struct_to_memory.sol index eba9105e5..25a2c05f1 100644 --- a/test/libsolidity/semanticTests/array/copying/calldata_array_of_struct_to_memory.sol +++ b/test/libsolidity/semanticTests/array/copying/calldata_array_of_struct_to_memory.sol @@ -21,7 +21,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f((uint256,uint256)[]): 0x20, 0x2, 0x1, 0x2, 0x3, 0x4 -> 2, 1, 2, 3, 4 diff --git a/test/libsolidity/semanticTests/array/copying/calldata_array_static_to_memory.sol b/test/libsolidity/semanticTests/array/copying/calldata_array_static_to_memory.sol index e4b474245..fbc1d03d9 100644 --- a/test/libsolidity/semanticTests/array/copying/calldata_array_static_to_memory.sol +++ b/test/libsolidity/semanticTests/array/copying/calldata_array_static_to_memory.sol @@ -6,6 +6,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256[2]): 43, 57 -> 43, 57 diff --git a/test/libsolidity/semanticTests/array/copying/calldata_bytes_array_to_memory.sol b/test/libsolidity/semanticTests/array/copying/calldata_bytes_array_to_memory.sol index 7a966f91f..56be37250 100644 --- a/test/libsolidity/semanticTests/array/copying/calldata_bytes_array_to_memory.sol +++ b/test/libsolidity/semanticTests/array/copying/calldata_bytes_array_to_memory.sol @@ -10,8 +10,6 @@ contract C { return (a.length, m.length, m); } } -// ==== -// compileViaYul: also // ---- // f(bytes[]): 0x20, 0x1, 0x20, 0x2, hex"6162000000000000000000000000000000000000000000000000000000000000" -> 0x1, 0x2, 0x60, 0x2, hex"6162000000000000000000000000000000000000000000000000000000000000" // f(bytes[]): 0x20, 0x1, 0x20, 0x20, hex"7878787878787878787878787878787878787878787878787878787878787878" -> 0x1, 0x20, 0x60, 0x20, hex"7878787878787878787878787878787878787878787878787878787878787878" diff --git a/test/libsolidity/semanticTests/array/copying/calldata_bytes_to_storage.sol b/test/libsolidity/semanticTests/array/copying/calldata_bytes_to_storage.sol index d0ca949f9..57f6b3a3e 100644 --- a/test/libsolidity/semanticTests/array/copying/calldata_bytes_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/calldata_bytes_to_storage.sol @@ -7,6 +7,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bytes): 0x20, 0x08, "abcdefgh" -> "a" diff --git a/test/libsolidity/semanticTests/array/copying/calldata_dyn_2d_bytes_to_memory.sol b/test/libsolidity/semanticTests/array/copying/calldata_dyn_2d_bytes_to_memory.sol index 07296aac0..ff7e9f488 100644 --- a/test/libsolidity/semanticTests/array/copying/calldata_dyn_2d_bytes_to_memory.sol +++ b/test/libsolidity/semanticTests/array/copying/calldata_dyn_2d_bytes_to_memory.sol @@ -5,7 +5,5 @@ contract C { return c; } } -// ==== -// compileViaYul: also // ---- // f(bytes[]): 0x20, 2, 0x60, 0x60, 0x20, 2, "ab" -> 0x20, 2, 0x40, 0x80, 2, "ab", 2, "ab" diff --git a/test/libsolidity/semanticTests/array/copying/calldata_dynamic_array_to_memory.sol b/test/libsolidity/semanticTests/array/copying/calldata_dynamic_array_to_memory.sol index a1cd58194..28eecc4f2 100644 --- a/test/libsolidity/semanticTests/array/copying/calldata_dynamic_array_to_memory.sol +++ b/test/libsolidity/semanticTests/array/copying/calldata_dynamic_array_to_memory.sol @@ -11,7 +11,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(uint256[][]): 0x20, 0x1, 0x20, 0x2, 0x17, 0x2a -> 0x1, 0x40, 0x2, 0x17, 0x2a diff --git a/test/libsolidity/semanticTests/array/copying/calldata_nested_array_copy_to_memory.sol b/test/libsolidity/semanticTests/array/copying/calldata_nested_array_copy_to_memory.sol index bfcd5ead4..a26936c9d 100644 --- a/test/libsolidity/semanticTests/array/copying/calldata_nested_array_copy_to_memory.sol +++ b/test/libsolidity/semanticTests/array/copying/calldata_nested_array_copy_to_memory.sol @@ -8,7 +8,5 @@ contract Test { return shouldBug(weapon); } } -// ==== -// compileViaYul: also // ---- // killer(uint256[][2]): 0x20, 0x40, 0x40, 2, 1, 2 -> 0x20, 0x20, 0x40, 0xa0, 2, 1, 2, 2, 1, 2 diff --git a/test/libsolidity/semanticTests/array/copying/calldata_to_storage_different_base.sol b/test/libsolidity/semanticTests/array/copying/calldata_to_storage_different_base.sol index d9771bf33..2fc3b0a0a 100644 --- a/test/libsolidity/semanticTests/array/copying/calldata_to_storage_different_base.sol +++ b/test/libsolidity/semanticTests/array/copying/calldata_to_storage_different_base.sol @@ -7,7 +7,5 @@ contract C { return (s.length, s[0], s[1], s[2]); } } -// ==== -// compileViaYul: also // ---- // f(bytes8[]): 0x20, 3, "abcd", "bcde", "cdef" -> 3, "abcd", "bcde", "cdef" diff --git a/test/libsolidity/semanticTests/array/copying/cleanup_during_multi_element_per_slot_copy.sol b/test/libsolidity/semanticTests/array/copying/cleanup_during_multi_element_per_slot_copy.sol new file mode 100644 index 000000000..999d49eaa --- /dev/null +++ b/test/libsolidity/semanticTests/array/copying/cleanup_during_multi_element_per_slot_copy.sol @@ -0,0 +1,22 @@ +contract C { + uint32[] s; + constructor() + { + s.push(); + s.push(); + } + function f() external returns (uint) + { + (s[1], s) = (4, [0]); + s = [0]; + s.push(); + return s[1]; + // used to return 4 via IR. + } +} +// ---- +// constructor() +// gas irOptimized: 237351 +// gas legacy: 221315 +// gas legacyOptimized: 185247 +// f() -> 0 diff --git a/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol b/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol index 05f8bd2bf..2b3cad19f 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol @@ -33,16 +33,14 @@ contract C { return (data.a, data.b); } } -// ==== -// compileViaYul: also // ---- // f() -> 0x40, 0x80, 6, 0x6162636465660000000000000000000000000000000000000000000000000000, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000 -// gas irOptimized: 179895 -// gas legacy: 180676 -// gas legacyOptimized: 180070 +// gas irOptimized: 179766 +// gas legacy: 181047 +// gas legacyOptimized: 180029 // g() -> 0x40, 0xc0, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000, 0x11, 0x3132333435363738393233343536373839000000000000000000000000000000 -// gas irOptimized: 107274 -// gas legacy: 107877 -// gas legacyOptimized: 107236 +// gas irOptimized: 107097 +// gas legacy: 110201 +// gas legacyOptimized: 107353 // h() -> 0x40, 0x60, 0x00, 0x00 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol b/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol index 41a5e9909..92f2a1f2e 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol @@ -44,10 +44,8 @@ contract C { return 0xff; } } -// ==== -// compileViaYul: also // ---- // f() -> 0xff -// gas irOptimized: 121123 -// gas legacy: 128005 -// gas legacyOptimized: 123446 +// gas irOptimized: 119584 +// gas legacy: 132274 +// gas legacyOptimized: 123756 diff --git a/test/libsolidity/semanticTests/array/copying/copy_function_internal_storage_array.sol b/test/libsolidity/semanticTests/array/copying/copy_function_internal_storage_array.sol index 4c223d30c..e938b03d6 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_function_internal_storage_array.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_function_internal_storage_array.sol @@ -14,10 +14,8 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // test() -> 7 -// gas irOptimized: 124034 +// gas irOptimized: 122483 // gas legacy: 205196 // gas legacyOptimized: 204987 diff --git a/test/libsolidity/semanticTests/array/copying/copy_internal_function_array_to_storage.sol b/test/libsolidity/semanticTests/array/copying/copy_internal_function_array_to_storage.sol index d2c7bb77d..b13d15e17 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_internal_function_array_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_internal_function_array_to_storage.sol @@ -19,7 +19,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // one() -> 3 // gas legacy: 140260 diff --git a/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol b/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol index cf8023a2f..1c7266611 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol @@ -5,13 +5,11 @@ contract c { bytes data1; bytes data2; } -// ==== -// compileViaYul: also // ---- // set(): 1, 2, 3, 4, 5 -> true // gas irOptimized: 177386 -// gas legacy: 177653 -// gas legacyOptimized: 177493 +// gas legacy: 177970 +// gas legacyOptimized: 177559 // storageEmpty -> 0 // reset() -> true // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/copying/copying_bytes_multiassign.sol b/test/libsolidity/semanticTests/array/copying/copying_bytes_multiassign.sol index 09457bb74..cc61509d4 100644 --- a/test/libsolidity/semanticTests/array/copying/copying_bytes_multiassign.sol +++ b/test/libsolidity/semanticTests/array/copying/copying_bytes_multiassign.sol @@ -18,12 +18,11 @@ contract sender { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // (): 7 -> -// gas irOptimized: 110954 -// gas legacy: 111071 -// gas legacyOptimized: 111016 +// gas irOptimized: 110826 +// gas legacy: 111408 +// gas legacyOptimized: 111078 // val() -> 0 // forward(bool): true -> true // val() -> 0x80 diff --git a/test/libsolidity/semanticTests/array/copying/dirty_memory_bytes_to_storage_copy.sol b/test/libsolidity/semanticTests/array/copying/dirty_memory_bytes_to_storage_copy.sol index 767e26856..ca154eee9 100644 --- a/test/libsolidity/semanticTests/array/copying/dirty_memory_bytes_to_storage_copy.sol +++ b/test/libsolidity/semanticTests/array/copying/dirty_memory_bytes_to_storage_copy.sol @@ -16,4 +16,4 @@ contract C { // ==== // compileViaYul: false // ---- -// f() -> 0x6465616462656566313564656164000000000000000000000000000000000010 +// f() -> 0x6465616462656566000000000000000000000000000000000000000000000010 diff --git a/test/libsolidity/semanticTests/array/copying/empty_bytes_copy.sol b/test/libsolidity/semanticTests/array/copying/empty_bytes_copy.sol index 0f19eaa0a..45ef42d46 100644 --- a/test/libsolidity/semanticTests/array/copying/empty_bytes_copy.sol +++ b/test/libsolidity/semanticTests/array/copying/empty_bytes_copy.sol @@ -22,8 +22,6 @@ contract C { return data[0]; } } -// ==== -// compileViaYul: also // ---- // fromMemory() -> 0x00 // fromCalldata(bytes): 0x40, 0x60, 0x00, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0x00 diff --git a/test/libsolidity/semanticTests/array/copying/function_type_array_to_storage.sol b/test/libsolidity/semanticTests/array/copying/function_type_array_to_storage.sol new file mode 100644 index 000000000..1e8760250 --- /dev/null +++ b/test/libsolidity/semanticTests/array/copying/function_type_array_to_storage.sol @@ -0,0 +1,56 @@ +contract C { + string log; + function() external[] fs; + function() external[] gs; + + function a() external { + log = string.concat(log, "[a called]"); + } + function b() external { + log = string.concat(log, "[b called]"); + } + + function f(function() external[] calldata x) external { + fs = x; + } + function g(function() external[] memory x) public { + fs = x; + } + function test() external returns (string memory) { + log = ""; + function() external[] memory x = new function() external[](2); + x[0] = this.a; + x[1] = this.b; + this.f(x); + fs[0](); + fs[1](); + return log; + } + function test2() external returns (string memory) { + log = ""; + function() external[] memory x = new function() external[](2); + x[0] = this.b; + x[1] = this.a; + g(x); + fs[0](); + fs[1](); + return log; + } + function test3() external returns (string memory) { + log = ""; + gs = fs; + gs[0](); + gs[1](); + return log; + } +} +// ---- +// test() -> 0x20, 0x14, "[a called][b called]" +// gas irOptimized: 116673 +// gas legacy: 119030 +// gas legacyOptimized: 117021 +// test2() -> 0x20, 0x14, "[b called][a called]" +// test3() -> 0x20, 0x14, "[b called][a called]" +// gas irOptimized: 103256 +// gas legacy: 102814 +// gas legacyOptimized: 101706 diff --git a/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol b/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol index 8908caa55..16d10a36d 100644 --- a/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol @@ -16,10 +16,8 @@ contract C { return s.length; } } -// ==== -// compileViaYul: also // ---- // f() -> 3 -// gas irOptimized: 129910 -// gas legacy: 130181 -// gas legacyOptimized: 129198 +// gas irOptimized: 128172 +// gas legacy: 130757 +// gas legacyOptimized: 129144 diff --git a/test/libsolidity/semanticTests/array/copying/memory_to_storage_different_base.sol b/test/libsolidity/semanticTests/array/copying/memory_to_storage_different_base.sol index 24ac2e202..af54de1b9 100644 --- a/test/libsolidity/semanticTests/array/copying/memory_to_storage_different_base.sol +++ b/test/libsolidity/semanticTests/array/copying/memory_to_storage_different_base.sol @@ -11,7 +11,5 @@ contract C { return (s.length, s[0], s[1], s[2]); } } -// ==== -// compileViaYul: also // ---- // f() -> 3, "abcd", "bcde", "cdef" diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol index c9c72543c..ddcae981f 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol @@ -15,10 +15,8 @@ contract C { return (m[0][0], m[0][3], m[1][1], m[1][4], m[2][0], m[3][2], m[3][3]); } } -// ==== -// compileViaYul: also // ---- // f() -> 1, 2, 3, 4, 5, 6, 7 -// gas irOptimized: 207781 +// gas irOptimized: 205985 // gas legacy: 212313 // gas legacyOptimized: 211462 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol index 35fd24fd8..550e74a6f 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol @@ -9,10 +9,8 @@ contract C { return m; } } -// ==== -// compileViaYul: also // ---- // f() -> 0x20, 0x02, 0x40, 0x80, 3, 0x6162630000000000000000000000000000000000000000000000000000000000, 0x99, 44048183304486788312148433451363384677562265908331949128489393215789685032262, 32241931068525137014058842823026578386641954854143559838526554899205067598957, 49951309422467613961193228765530489307475214998374779756599339590522149884499, 0x54555658595a6162636465666768696a6b6c6d6e6f707172737475767778797a, 0x4142434445464748494a4b4c4d4e4f5051525354555658595a00000000000000 -// gas irOptimized: 202840 -// gas legacy: 204441 -// gas legacyOptimized: 203419 +// gas irOptimized: 202808 +// gas legacy: 204860 +// gas legacyOptimized: 203385 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol index 8f98822e7..eabcb1666 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol @@ -16,10 +16,8 @@ contract C { return (m[0][0], m[0][3], m[1][1], m[1][4], m[2][0], m[3][2], m[3][3]); } } -// ==== -// compileViaYul: also // ---- // f() -> 1, 2, 3, 4, 5, 6, 7 -// gas irOptimized: 207781 +// gas irOptimized: 205985 // gas legacy: 212318 // gas legacyOptimized: 211467 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol index d9a50e73d..46eae913d 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol @@ -22,10 +22,8 @@ contract C { ); } } -// ==== -// compileViaYul: also // ---- // f() -> 11, 0x0c, 1, 0x15, 22, 4 -// gas irOptimized: 291848 +// gas irOptimized: 291168 // gas legacy: 293516 // gas legacyOptimized: 290263 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_packed.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_packed.sol index 4a4515ff6..b1410f7e2 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_packed.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_packed.sol @@ -11,6 +11,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 2, 3, 4 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol index f954701d5..7f3bf1798 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol @@ -11,10 +11,8 @@ contract C { return (m[0], m[16], m[32]); } } -// ==== -// compileViaYul: also // ---- // f() -> 2, 3, 4 -// gas irOptimized: 114114 +// gas irOptimized: 110135 // gas legacy: 126350 // gas legacyOptimized: 120704 diff --git a/test/libsolidity/semanticTests/array/copying/string_calldata_to_bytes_calldata.sol b/test/libsolidity/semanticTests/array/copying/string_calldata_to_bytes_calldata.sol index 04a125753..dec1a2d10 100644 --- a/test/libsolidity/semanticTests/array/copying/string_calldata_to_bytes_calldata.sol +++ b/test/libsolidity/semanticTests/array/copying/string_calldata_to_bytes_calldata.sol @@ -3,7 +3,5 @@ contract C { return bytes(s); } } -// ==== -// compileViaYul: also // ---- // f(string): 0x20, 3, "abc" -> 0x20, 3, "abc" diff --git a/test/libsolidity/semanticTests/array/create_dynamic_array_with_zero_length.sol b/test/libsolidity/semanticTests/array/create_dynamic_array_with_zero_length.sol index dfcb7aff2..3856e23dc 100644 --- a/test/libsolidity/semanticTests/array/create_dynamic_array_with_zero_length.sol +++ b/test/libsolidity/semanticTests/array/create_dynamic_array_with_zero_length.sol @@ -6,6 +6,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 7 diff --git a/test/libsolidity/semanticTests/array/create_memory_array.sol b/test/libsolidity/semanticTests/array/create_memory_array.sol index e107bd68a..fbef4ccfa 100644 --- a/test/libsolidity/semanticTests/array/create_memory_array.sol +++ b/test/libsolidity/semanticTests/array/create_memory_array.sol @@ -16,10 +16,8 @@ contract C { return (x[199], y[203][1], z[170].a[1], z[170].b[99]); } } -// ==== -// compileViaYul: also // ---- // f() -> "A", 8, 4, "B" -// gas irOptimized: 130592 +// gas irOptimized: 125828 // gas legacy: 121398 // gas legacyOptimized: 115494 diff --git a/test/libsolidity/semanticTests/array/create_memory_array_too_large.sol b/test/libsolidity/semanticTests/array/create_memory_array_too_large.sol index 11d69df02..ed6a37403 100644 --- a/test/libsolidity/semanticTests/array/create_memory_array_too_large.sol +++ b/test/libsolidity/semanticTests/array/create_memory_array_too_large.sol @@ -21,7 +21,6 @@ contract C { }} // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> FAILURE, hex"4e487b71", 0x41 // g() -> FAILURE, hex"4e487b71", 0x41 diff --git a/test/libsolidity/semanticTests/array/create_memory_byte_array.sol b/test/libsolidity/semanticTests/array/create_memory_byte_array.sol index 67dcbffc3..b4c29d0fd 100644 --- a/test/libsolidity/semanticTests/array/create_memory_byte_array.sol +++ b/test/libsolidity/semanticTests/array/create_memory_byte_array.sol @@ -6,7 +6,5 @@ contract C { return (x[34]); } } -// ==== -// compileViaYul: also // ---- // f() -> "A" diff --git a/test/libsolidity/semanticTests/array/create_multiple_dynamic_arrays.sol b/test/libsolidity/semanticTests/array/create_multiple_dynamic_arrays.sol index c29dca43e..ad5c39279 100644 --- a/test/libsolidity/semanticTests/array/create_multiple_dynamic_arrays.sol +++ b/test/libsolidity/semanticTests/array/create_multiple_dynamic_arrays.sol @@ -31,6 +31,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 7 diff --git a/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol b/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol index f6208ea6f..652854cb8 100644 --- a/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol +++ b/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol @@ -14,10 +14,8 @@ contract c { uint8(data[97]) == 97; } } -// ==== -// compileViaYul: also // ---- // test1() -> true -// gas irOptimized: 225890 -// gas legacy: 254650 -// gas legacyOptimized: 247384 +// gas irOptimized: 207928 +// gas legacy: 254905 +// gas legacyOptimized: 247415 diff --git a/test/libsolidity/semanticTests/array/delete/delete_bytes_array.sol b/test/libsolidity/semanticTests/array/delete/delete_bytes_array.sol index 2136f7895..77096a645 100644 --- a/test/libsolidity/semanticTests/array/delete/delete_bytes_array.sol +++ b/test/libsolidity/semanticTests/array/delete/delete_bytes_array.sol @@ -30,8 +30,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f() -> 0 // g() -> 0 diff --git a/test/libsolidity/semanticTests/array/delete/delete_memory_array.sol b/test/libsolidity/semanticTests/array/delete/delete_memory_array.sol index 64fc9a972..54abc495c 100644 --- a/test/libsolidity/semanticTests/array/delete/delete_memory_array.sol +++ b/test/libsolidity/semanticTests/array/delete/delete_memory_array.sol @@ -11,7 +11,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // len() -> 0 diff --git a/test/libsolidity/semanticTests/array/delete/delete_on_array_of_structs.sol b/test/libsolidity/semanticTests/array/delete/delete_on_array_of_structs.sol index b415ac7f6..316b8d9ef 100644 --- a/test/libsolidity/semanticTests/array/delete/delete_on_array_of_structs.sol +++ b/test/libsolidity/semanticTests/array/delete/delete_on_array_of_structs.sol @@ -16,7 +16,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f() -> true # This code interprets x as an array length and thus will go out of gas. neither of the two should throw due to out-of-bounds access # diff --git a/test/libsolidity/semanticTests/array/delete/delete_removes_bytes_data.sol b/test/libsolidity/semanticTests/array/delete/delete_removes_bytes_data.sol index 4c573f6fa..c407eb73f 100644 --- a/test/libsolidity/semanticTests/array/delete/delete_removes_bytes_data.sol +++ b/test/libsolidity/semanticTests/array/delete/delete_removes_bytes_data.sol @@ -3,8 +3,6 @@ contract c { function del() public returns (bool) { delete data; return true; } bytes data; } -// ==== -// compileViaYul: also // ---- // (): 7 -> // storageEmpty -> 0 diff --git a/test/libsolidity/semanticTests/array/delete/delete_storage_array.sol b/test/libsolidity/semanticTests/array/delete/delete_storage_array.sol index d8bf81d8a..0bb429674 100644 --- a/test/libsolidity/semanticTests/array/delete/delete_storage_array.sol +++ b/test/libsolidity/semanticTests/array/delete/delete_storage_array.sol @@ -33,8 +33,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // len() -> 0 // val() -> 0 diff --git a/test/libsolidity/semanticTests/array/delete/delete_storage_array_packed.sol b/test/libsolidity/semanticTests/array/delete/delete_storage_array_packed.sol index 8d0f6358e..22f31b1ef 100644 --- a/test/libsolidity/semanticTests/array/delete/delete_storage_array_packed.sol +++ b/test/libsolidity/semanticTests/array/delete/delete_storage_array_packed.sol @@ -12,8 +12,6 @@ contract C { return (data[0], data[1], data[2]); } } -// ==== -// compileViaYul: also // ---- // f() -> 0, 0, 0 // gas irOptimized: 90992 diff --git a/test/libsolidity/semanticTests/array/delete/memory_arrays_delete.sol b/test/libsolidity/semanticTests/array/delete/memory_arrays_delete.sol index 31c86b353..732e90adb 100644 --- a/test/libsolidity/semanticTests/array/delete/memory_arrays_delete.sol +++ b/test/libsolidity/semanticTests/array/delete/memory_arrays_delete.sol @@ -9,7 +9,5 @@ contract Test { return x; } } -// ==== -// compileViaYul: also // ---- // del() -> 0, 1, 2, 0, 0, 0, 0x20, 0x21, 0x22, 0x30, 0x31, 0 diff --git a/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol b/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol index 01ba8dcfe..4454914a9 100644 --- a/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol @@ -11,14 +11,12 @@ contract c { } function fullClear() public { delete dynamic; } } -// ==== -// compileViaYul: also // ---- // storageEmpty -> 1 // fill() -> -// gas irOptimized: 519884 -// gas legacy: 521710 -// gas legacyOptimized: 516922 +// gas irOptimized: 519487 +// gas legacy: 521584 +// gas legacyOptimized: 517027 // storageEmpty -> 0 // halfClear() -> // storageEmpty -> 0 diff --git a/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol b/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol index be8f6eff3..8ff67048c 100644 --- a/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol +++ b/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol @@ -39,12 +39,10 @@ contract c { } } -// ==== -// compileViaYul: also // ---- // getLengths() -> 0, 0 // setLengths(uint256,uint256): 48, 49 -> -// gas irOptimized: 111295 +// gas irOptimized: 111448 // gas legacy: 108571 // gas legacyOptimized: 100417 // getLengths() -> 48, 49 diff --git a/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol b/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol index 5bbd9e207..2e5d032d3 100644 --- a/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol @@ -13,12 +13,10 @@ contract c { } function clear() public { delete data; } } -// ==== -// compileViaYul: also // ---- // storageEmpty -> 1 // fill() -> 8 -// gas irOptimized: 122531 +// gas irOptimized: 123024 // gas legacy: 121756 // gas legacyOptimized: 120687 // storageEmpty -> 0 diff --git a/test/libsolidity/semanticTests/array/dynamic_out_of_bounds_array_access.sol b/test/libsolidity/semanticTests/array/dynamic_out_of_bounds_array_access.sol index e060ae2d9..844324f32 100644 --- a/test/libsolidity/semanticTests/array/dynamic_out_of_bounds_array_access.sol +++ b/test/libsolidity/semanticTests/array/dynamic_out_of_bounds_array_access.sol @@ -20,8 +20,6 @@ contract c { } } -// ==== -// compileViaYul: also // ---- // length() -> 0 // get(uint256): 3 -> FAILURE, hex"4e487b71", 0x32 diff --git a/test/libsolidity/semanticTests/array/evm_exceptions_out_of_band_access.sol b/test/libsolidity/semanticTests/array/evm_exceptions_out_of_band_access.sol index 02d56710b..f09757c6e 100644 --- a/test/libsolidity/semanticTests/array/evm_exceptions_out_of_band_access.sol +++ b/test/libsolidity/semanticTests/array/evm_exceptions_out_of_band_access.sol @@ -12,8 +12,6 @@ contract A { return true; } } -// ==== -// compileViaYul: also // ---- // test() -> false // testIt() -> FAILURE, hex"4e487b71", 0x32 diff --git a/test/libsolidity/semanticTests/array/external_array_args.sol b/test/libsolidity/semanticTests/array/external_array_args.sol index 72a8cdfc3..53cc75772 100644 --- a/test/libsolidity/semanticTests/array/external_array_args.sol +++ b/test/libsolidity/semanticTests/array/external_array_args.sol @@ -8,6 +8,5 @@ contract c { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test(uint256[8],uint256[],uint256[5],uint256,uint256,uint256): 1, 2, 3, 4, 5, 6, 7, 8, 0x220, 21, 22, 23, 24, 25, 0, 1, 2, 3, 11, 12, 13 -> 1, 12, 23 diff --git a/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol b/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol index fba3119e1..310217cfd 100644 --- a/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol @@ -9,13 +9,12 @@ contract c { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // storageEmpty -> 1 // fill() -> -// gas irOptimized: 465542 -// gas legacy: 471400 -// gas legacyOptimized: 467400 +// gas irOptimized: 465345 +// gas legacy: 471280 +// gas legacyOptimized: 467500 // storageEmpty -> 0 // clear() -> // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol b/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol index 3ce5f1a8d..4416635b6 100644 --- a/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol +++ b/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol @@ -17,10 +17,8 @@ contract B { } } -// ==== -// compileViaYul: also // ---- // f() -> 2, 3, 4, 5, 6, 1000, 1001, 1002, 1003, 1004 -// gas irOptimized: 127910 +// gas irOptimized: 116813 // gas legacy: 234719 // gas legacyOptimized: 132639 diff --git a/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol b/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol index 3f66dca6f..2749f0102 100644 --- a/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol +++ b/test/libsolidity/semanticTests/array/fixed_arrays_in_constructors.sol @@ -7,11 +7,9 @@ contract Creator { ch = s[2]; } } -// ==== -// compileViaYul: also // ---- // constructor(): 1, 2, 3, 4 -> -// gas irOptimized: 129013 +// gas irOptimized: 128288 // gas legacy: 176789 // gas legacyOptimized: 129585 // r() -> 4 diff --git a/test/libsolidity/semanticTests/array/fixed_arrays_in_storage.sol b/test/libsolidity/semanticTests/array/fixed_arrays_in_storage.sol index dc7b67378..eb167ee0c 100644 --- a/test/libsolidity/semanticTests/array/fixed_arrays_in_storage.sol +++ b/test/libsolidity/semanticTests/array/fixed_arrays_in_storage.sol @@ -35,7 +35,6 @@ contract c { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // setIDStatic(uint256): 0xb -> // getID(uint256): 0x2 -> 0xb diff --git a/test/libsolidity/semanticTests/array/fixed_bytes_length_access.sol b/test/libsolidity/semanticTests/array/fixed_bytes_length_access.sol index 9561a98e5..e22b56cfc 100644 --- a/test/libsolidity/semanticTests/array/fixed_bytes_length_access.sol +++ b/test/libsolidity/semanticTests/array/fixed_bytes_length_access.sol @@ -7,6 +7,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bytes32): "789" -> 32, 16, 8 diff --git a/test/libsolidity/semanticTests/array/fixed_out_of_bounds_array_access.sol b/test/libsolidity/semanticTests/array/fixed_out_of_bounds_array_access.sol index ad6d3769f..d82ef152c 100644 --- a/test/libsolidity/semanticTests/array/fixed_out_of_bounds_array_access.sol +++ b/test/libsolidity/semanticTests/array/fixed_out_of_bounds_array_access.sol @@ -17,7 +17,6 @@ contract c { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // length() -> 4 // set(uint256,uint256): 3, 4 -> true diff --git a/test/libsolidity/semanticTests/array/function_array_cross_calls.sol b/test/libsolidity/semanticTests/array/function_array_cross_calls.sol index 087ecf0a8..71bd36b90 100644 --- a/test/libsolidity/semanticTests/array/function_array_cross_calls.sol +++ b/test/libsolidity/semanticTests/array/function_array_cross_calls.sol @@ -41,10 +41,8 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // test() -> 5, 6, 7 -// gas irOptimized: 292502 +// gas irOptimized: 262057 // gas legacy: 452136 // gas legacyOptimized: 284945 diff --git a/test/libsolidity/semanticTests/array/function_memory_array.sol b/test/libsolidity/semanticTests/array/function_memory_array.sol index 5c07c1f90..322eed73e 100644 --- a/test/libsolidity/semanticTests/array/function_memory_array.sol +++ b/test/libsolidity/semanticTests/array/function_memory_array.sol @@ -32,7 +32,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test(uint256,uint256): 10, 0 -> 11 // test(uint256,uint256): 10, 1 -> 12 diff --git a/test/libsolidity/semanticTests/array/indexAccess/arrays_complex_memory_index_access.sol b/test/libsolidity/semanticTests/array/indexAccess/arrays_complex_memory_index_access.sol index d21bcc53f..79d8f2020 100644 --- a/test/libsolidity/semanticTests/array/indexAccess/arrays_complex_memory_index_access.sol +++ b/test/libsolidity/semanticTests/array/indexAccess/arrays_complex_memory_index_access.sol @@ -7,7 +7,5 @@ contract Test { e = _data[a][b]; } } -// ==== -// compileViaYul: also // ---- // set(uint24[3][],uint256,uint256): 0x60, 0x03, 0x02, 0x06, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12 -> 0x06, 0x0c diff --git a/test/libsolidity/semanticTests/array/indexAccess/bytes_index_access.sol b/test/libsolidity/semanticTests/array/indexAccess/bytes_index_access.sol index 9a0c85ac7..0e9168bce 100644 --- a/test/libsolidity/semanticTests/array/indexAccess/bytes_index_access.sol +++ b/test/libsolidity/semanticTests/array/indexAccess/bytes_index_access.sol @@ -19,8 +19,6 @@ contract c { return uint(uint8(data[30])) * 0x100 | uint(uint8(data[31])) * 0x10 | uint(uint8(data[32])); } } -// ==== -// compileViaYul: also // ---- // direct(bytes,uint256): 0x40, 33, 34, 0x000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F, left(0x2021) -> 0x21 // storageCopyRead(bytes,uint256): 0x40, 33, 34, 0x000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F, left(0x2021) -> 0x21 diff --git a/test/libsolidity/semanticTests/array/indexAccess/bytes_index_access_memory.sol b/test/libsolidity/semanticTests/array/indexAccess/bytes_index_access_memory.sol index 1dcd448b4..fa65d25c0 100644 --- a/test/libsolidity/semanticTests/array/indexAccess/bytes_index_access_memory.sol +++ b/test/libsolidity/semanticTests/array/indexAccess/bytes_index_access_memory.sol @@ -11,7 +11,5 @@ contract Main { return _s1; } } -// ==== -// compileViaYul: also // ---- // f(bytes,uint256,uint256,uint256): 0x80, 3, 4, 5, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> "d", "e", "f" diff --git a/test/libsolidity/semanticTests/array/indexAccess/bytes_memory_index_access.sol b/test/libsolidity/semanticTests/array/indexAccess/bytes_memory_index_access.sol index 5b7fd7ac3..6dd624993 100644 --- a/test/libsolidity/semanticTests/array/indexAccess/bytes_memory_index_access.sol +++ b/test/libsolidity/semanticTests/array/indexAccess/bytes_memory_index_access.sol @@ -7,7 +7,5 @@ contract Test { c = _data[i]; } } -// ==== -// compileViaYul: also // ---- // set(bytes,uint256): 0x40, 0x03, 0x08, "abcdefgh" -> 0x08, "d" diff --git a/test/libsolidity/semanticTests/array/indexAccess/fixed_bytes_index_access.sol b/test/libsolidity/semanticTests/array/indexAccess/fixed_bytes_index_access.sol index 40cc65763..9ab74eaf3 100644 --- a/test/libsolidity/semanticTests/array/indexAccess/fixed_bytes_index_access.sol +++ b/test/libsolidity/semanticTests/array/indexAccess/fixed_bytes_index_access.sol @@ -11,8 +11,6 @@ contract C { return uint256(uint8(data[0][4])); } } -// ==== -// compileViaYul: also // ---- // f(bytes32): "789" -> "9" // g(bytes32): "789" -> 0x35 diff --git a/test/libsolidity/semanticTests/array/indexAccess/index_access.sol b/test/libsolidity/semanticTests/array/indexAccess/index_access.sol index ad691a588..b90bbb12e 100644 --- a/test/libsolidity/semanticTests/array/indexAccess/index_access.sol +++ b/test/libsolidity/semanticTests/array/indexAccess/index_access.sol @@ -14,7 +14,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // to_little_endian_64(uint64): 0 -> 0x20, 8, 0x00 diff --git a/test/libsolidity/semanticTests/array/indexAccess/inline_array_index_access_ints.sol b/test/libsolidity/semanticTests/array/indexAccess/inline_array_index_access_ints.sol index 1dd807363..c1481fc99 100644 --- a/test/libsolidity/semanticTests/array/indexAccess/inline_array_index_access_ints.sol +++ b/test/libsolidity/semanticTests/array/indexAccess/inline_array_index_access_ints.sol @@ -6,6 +6,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 3 diff --git a/test/libsolidity/semanticTests/array/indexAccess/inline_array_index_access_strings.sol b/test/libsolidity/semanticTests/array/indexAccess/inline_array_index_access_strings.sol index 9292ed89f..b826dc13d 100644 --- a/test/libsolidity/semanticTests/array/indexAccess/inline_array_index_access_strings.sol +++ b/test/libsolidity/semanticTests/array/indexAccess/inline_array_index_access_strings.sol @@ -11,7 +11,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // test() -> diff --git a/test/libsolidity/semanticTests/array/indexAccess/memory_arrays_dynamic_index_access_write.sol b/test/libsolidity/semanticTests/array/indexAccess/memory_arrays_dynamic_index_access_write.sol index 046be080c..be824b759 100644 --- a/test/libsolidity/semanticTests/array/indexAccess/memory_arrays_dynamic_index_access_write.sol +++ b/test/libsolidity/semanticTests/array/indexAccess/memory_arrays_dynamic_index_access_write.sol @@ -15,7 +15,5 @@ contract Test { return set(data)[1]; } } -// ==== -// compileViaYul: also // ---- // f() -> 0x20, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07 diff --git a/test/libsolidity/semanticTests/array/indexAccess/memory_arrays_index_access_write.sol b/test/libsolidity/semanticTests/array/indexAccess/memory_arrays_index_access_write.sol index 881f9c944..ff83a4310 100644 --- a/test/libsolidity/semanticTests/array/indexAccess/memory_arrays_index_access_write.sol +++ b/test/libsolidity/semanticTests/array/indexAccess/memory_arrays_index_access_write.sol @@ -12,6 +12,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07 diff --git a/test/libsolidity/semanticTests/array/inline_array_return.sol b/test/libsolidity/semanticTests/array/inline_array_return.sol index b3c97f275..d6673882f 100644 --- a/test/libsolidity/semanticTests/array/inline_array_return.sol +++ b/test/libsolidity/semanticTests/array/inline_array_return.sol @@ -13,6 +13,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1, 2, 3, 4, 5 diff --git a/test/libsolidity/semanticTests/array/inline_array_singleton.sol b/test/libsolidity/semanticTests/array/inline_array_singleton.sol index bf26cf9cb..870c853e1 100644 --- a/test/libsolidity/semanticTests/array/inline_array_singleton.sol +++ b/test/libsolidity/semanticTests/array/inline_array_singleton.sol @@ -6,6 +6,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 4 diff --git a/test/libsolidity/semanticTests/array/inline_array_storage_to_memory_conversion_ints.sol b/test/libsolidity/semanticTests/array/inline_array_storage_to_memory_conversion_ints.sol index 62efbc25e..18626b055 100644 --- a/test/libsolidity/semanticTests/array/inline_array_storage_to_memory_conversion_ints.sol +++ b/test/libsolidity/semanticTests/array/inline_array_storage_to_memory_conversion_ints.sol @@ -9,6 +9,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 3, 6 diff --git a/test/libsolidity/semanticTests/array/inline_array_storage_to_memory_conversion_strings.sol b/test/libsolidity/semanticTests/array/inline_array_storage_to_memory_conversion_strings.sol index dd598ca71..2b456ca9a 100644 --- a/test/libsolidity/semanticTests/array/inline_array_storage_to_memory_conversion_strings.sol +++ b/test/libsolidity/semanticTests/array/inline_array_storage_to_memory_conversion_strings.sol @@ -10,6 +10,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x40, 0x80, 0x3, "ray", 0x2, "mi" diff --git a/test/libsolidity/semanticTests/array/inline_array_strings_from_document.sol b/test/libsolidity/semanticTests/array/inline_array_strings_from_document.sol index 1d58fc170..23f2d89c7 100644 --- a/test/libsolidity/semanticTests/array/inline_array_strings_from_document.sol +++ b/test/libsolidity/semanticTests/array/inline_array_strings_from_document.sol @@ -7,7 +7,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 0 -> 0x20, 0x4, "This" // f(uint256): 1 -> 0x20, 0x2, "is" diff --git a/test/libsolidity/semanticTests/array/invalid_encoding_for_storage_byte_array.sol b/test/libsolidity/semanticTests/array/invalid_encoding_for_storage_byte_array.sol index 57bbbb9d4..27d7e241e 100644 --- a/test/libsolidity/semanticTests/array/invalid_encoding_for_storage_byte_array.sol +++ b/test/libsolidity/semanticTests/array/invalid_encoding_for_storage_byte_array.sol @@ -23,8 +23,6 @@ contract C { function arrayPushEmpty() public { x.push(); } function del() public { delete x; } } -// ==== -// compileViaYul: also // ---- // x() -> 0x20, 3, 0x6162630000000000000000000000000000000000000000000000000000000000 // abiEncode() -> 0x20, 3, 0x6162630000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/array/memory.sol b/test/libsolidity/semanticTests/array/memory.sol index dba62a336..6bde7c26c 100644 --- a/test/libsolidity/semanticTests/array/memory.sol +++ b/test/libsolidity/semanticTests/array/memory.sol @@ -10,8 +10,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // h(uint256[4]): 1, 2, 3, 4 -> 10 // i(uint256[4]): 1, 2, 3, 4 -> 20 diff --git a/test/libsolidity/semanticTests/array/memory_arrays_of_various_sizes.sol b/test/libsolidity/semanticTests/array/memory_arrays_of_various_sizes.sol index fd1fba0a1..0ce758d9d 100644 --- a/test/libsolidity/semanticTests/array/memory_arrays_of_various_sizes.sol +++ b/test/libsolidity/semanticTests/array/memory_arrays_of_various_sizes.sol @@ -11,8 +11,6 @@ contract C { return rows[n][k - 1]; } } -// ==== -// compileViaYul: also // ---- // f(uint256,uint256): 3, 1 -> 1 // f(uint256,uint256): 9, 5 -> 70 diff --git a/test/libsolidity/semanticTests/array/pop/array_pop.sol b/test/libsolidity/semanticTests/array/pop/array_pop.sol index 9e64119e9..bbb140a38 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop.sol @@ -11,7 +11,5 @@ contract c { l = data.length; } } -// ==== -// compileViaYul: also // ---- // test() -> 1, 0 diff --git a/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol b/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol index 3b066cfaa..695f6c029 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol @@ -21,11 +21,9 @@ contract c { delete inner; } } -// ==== -// compileViaYul: also // ---- // test() -> 1, 2, 3 -// gas irOptimized: 2271044 +// gas irOptimized: 2280147 // gas legacy: 2273434 -// gas legacyOptimized: 2261820 +// gas legacyOptimized: 2261844 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/pop/array_pop_empty_exception.sol b/test/libsolidity/semanticTests/array/pop/array_pop_empty_exception.sol index 02b8e99c9..1750711e1 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop_empty_exception.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop_empty_exception.sol @@ -8,6 +8,5 @@ contract c { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> FAILURE, hex"4e487b71", 0x31 diff --git a/test/libsolidity/semanticTests/array/pop/array_pop_isolated.sol b/test/libsolidity/semanticTests/array/pop/array_pop_isolated.sol index 42213b96c..ce41673e0 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop_isolated.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop_isolated.sol @@ -10,6 +10,5 @@ contract c { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 3 diff --git a/test/libsolidity/semanticTests/array/pop/array_pop_storage_empty.sol b/test/libsolidity/semanticTests/array/pop/array_pop_storage_empty.sol index b49a738ec..17890cd19 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop_storage_empty.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop_storage_empty.sol @@ -5,8 +5,6 @@ contract c { data.pop(); } } -// ==== -// compileViaYul: also // ---- // test() -> // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol b/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol index 6ec59a75e..1b15ef84d 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol @@ -16,11 +16,9 @@ contract c { data.pop(); } } -// ==== -// compileViaYul: also // ---- // test() -> 38, 28, 18 -// gas irOptimized: 188649 +// gas irOptimized: 186370 // gas legacy: 189492 -// gas legacyOptimized: 178294 +// gas legacyOptimized: 178318 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol b/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol index 06f3c6cc9..ac52c4daf 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol @@ -16,11 +16,9 @@ contract c { data.pop(); } } -// ==== -// compileViaYul: also // ---- // test() -> 20, 10 -// gas irOptimized: 159169 +// gas irOptimized: 158020 // gas legacy: 159279 -// gas legacyOptimized: 152921 +// gas legacyOptimized: 152937 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop.sol index 260e6c342..81e1eb020 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop.sol @@ -14,6 +14,5 @@ contract c { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 2, 1, 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 227eb6afd..931069dee 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 @@ -8,10 +8,8 @@ contract c { } } -// ==== -// compileViaYul: also // ---- // test() -> 0x20, 29, 0x0303030303030303030303030303030303030303030303030303030303000000 -// gas irOptimized: 109499 -// gas legacy: 126728 -// gas legacyOptimized: 123444 +// gas irOptimized: 109310 +// gas legacy: 126702 +// gas legacyOptimized: 123422 diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_empty_exception.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_empty_exception.sol index 0ef64aca2..5d573a096 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_empty_exception.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_empty_exception.sol @@ -11,6 +11,5 @@ contract c { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> FAILURE, hex"4e487b71", 0x31 diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_isolated.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_isolated.sol index 6eb76a774..519b0c5ab 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_isolated.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_isolated.sol @@ -10,6 +10,5 @@ contract c { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 3 diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol index 146a4dfc3..3d25e354d 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol @@ -14,11 +14,9 @@ contract c { return true; } } -// ==== -// compileViaYul: also // ---- // test() -> true -// gas irOptimized: 196541 -// gas legacy: 228685 -// gas legacyOptimized: 209662 +// gas irOptimized: 176111 +// gas legacy: 224093 +// gas legacyOptimized: 205152 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol index d5d004f5f..ccb4de6e1 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol @@ -13,11 +13,9 @@ contract c { } } } -// ==== -// compileViaYul: also // ---- // test() -> -// gas irOptimized: 142639 +// gas irOptimized: 142636 // gas legacy: 164430 -// gas legacyOptimized: 157898 +// gas legacyOptimized: 158513 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol index fb05db350..9f3884dae 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol @@ -8,10 +8,8 @@ contract c { } } -// ==== -// compileViaYul: also // ---- // test() -> 0x20, 33, 0x303030303030303030303030303030303030303030303030303030303030303, 0x0300000000000000000000000000000000000000000000000000000000000000 -// gas irOptimized: 108487 -// gas legacy: 125610 -// gas legacyOptimized: 122582 +// gas irOptimized: 108115 +// gas legacy: 125584 +// gas legacyOptimized: 122560 diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_storage_empty.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_storage_empty.sol index 52716ecb3..4b2e88ffa 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_storage_empty.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_storage_empty.sol @@ -11,7 +11,6 @@ contract c { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/pop/parenthesized.sol b/test/libsolidity/semanticTests/array/pop/parenthesized.sol index 04ac0c3e3..478040fd2 100644 --- a/test/libsolidity/semanticTests/array/pop/parenthesized.sol +++ b/test/libsolidity/semanticTests/array/pop/parenthesized.sol @@ -6,7 +6,5 @@ contract C { return data.length; } } -// ==== -// compileViaYul: also // ---- // f() -> 0 diff --git a/test/libsolidity/semanticTests/array/push/array_push.sol b/test/libsolidity/semanticTests/array/push/array_push.sol index e8ec36639..e608c6bc1 100644 --- a/test/libsolidity/semanticTests/array/push/array_push.sol +++ b/test/libsolidity/semanticTests/array/push/array_push.sol @@ -14,10 +14,8 @@ contract c { z = data[2]; } } -// ==== -// compileViaYul: also // ---- // test() -> 5, 4, 3, 3 -// gas irOptimized: 111317 +// gas irOptimized: 111448 // gas legacy: 111838 // gas legacyOptimized: 111128 diff --git a/test/libsolidity/semanticTests/array/push/array_push_nested.sol b/test/libsolidity/semanticTests/array/push/array_push_nested.sol index 5829d5400..a86679d3d 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_nested.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_nested.sol @@ -11,7 +11,5 @@ contract C { assert(s[0][0] == 0); } } -// ==== -// compileViaYul: also // ---- // f() -> diff --git a/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol b/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol index 05299ae55..63f974498 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol @@ -10,10 +10,8 @@ contract C { return s[0][0]; } } -// ==== -// compileViaYul: also // ---- // f(uint120[]): 0x20, 3, 1, 2, 3 -> 1 -// gas irOptimized: 113256 +// gas irOptimized: 112832 // gas legacy: 113686 // gas legacyOptimized: 113499 diff --git a/test/libsolidity/semanticTests/array/push/array_push_nested_from_memory.sol b/test/libsolidity/semanticTests/array/push/array_push_nested_from_memory.sol index 8a975e0b8..0d85613f1 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_nested_from_memory.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_nested_from_memory.sol @@ -13,7 +13,5 @@ contract C { return s[0][0]; } } -// ==== -// compileViaYul: also // ---- // f() -> 1 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 04f9544a9..434168119 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_packed_array.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_packed_array.sol @@ -12,8 +12,6 @@ contract c { } } -// ==== -// compileViaYul: also // ---- // test() -> 1, 2, 3, 4 // gas irOptimized: 93017 diff --git a/test/libsolidity/semanticTests/array/push/array_push_struct.sol b/test/libsolidity/semanticTests/array/push/array_push_struct.sol index 60e317770..04f94b3db 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_struct.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_struct.sol @@ -18,10 +18,8 @@ contract c { return (data[0].a, data[0].b, data[0].c[2], data[0].d[2]); } } -// ==== -// compileViaYul: also // ---- // test() -> 2, 3, 4, 5 -// gas irOptimized: 136894 +// gas irOptimized: 135204 // gas legacy: 147484 // gas legacyOptimized: 146456 diff --git a/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol b/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol index a7b8d6d9d..9718f303c 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol @@ -14,10 +14,8 @@ contract c { return (data[0].a, data[0].b, data[0].c[2], data[0].d[2]); } } -// ==== -// compileViaYul: also // ---- // test((uint16,uint16,uint16[3],uint16[])): 0x20, 2, 3, 0, 0, 4, 0xC0, 4, 0, 0, 5, 0, 0 -> 2, 3, 4, 5 -// gas irOptimized: 138691 -// gas legacy: 145150 -// gas legacyOptimized: 139171 +// gas irOptimized: 137092 +// gas legacy: 142537 +// gas legacyOptimized: 138023 diff --git a/test/libsolidity/semanticTests/array/push/byte_array_push.sol b/test/libsolidity/semanticTests/array/push/byte_array_push.sol index 14265fca9..28afd9f89 100644 --- a/test/libsolidity/semanticTests/array/push/byte_array_push.sol +++ b/test/libsolidity/semanticTests/array/push/byte_array_push.sol @@ -15,6 +15,5 @@ contract c { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> false diff --git a/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol b/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol index c4f7cb44a..896fa47d4 100644 --- a/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol +++ b/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol @@ -13,10 +13,8 @@ contract c { return 0; } } -// ==== -// compileViaYul: also // ---- // test() -> 0 -// gas irOptimized: 176495 +// gas irOptimized: 174126 // gas legacy: 216790 -// gas legacyOptimized: 203886 +// gas legacyOptimized: 204003 diff --git a/test/libsolidity/semanticTests/array/push/nested_bytes_push.sol b/test/libsolidity/semanticTests/array/push/nested_bytes_push.sol index 7c4bdcb9a..71a21820d 100644 --- a/test/libsolidity/semanticTests/array/push/nested_bytes_push.sol +++ b/test/libsolidity/semanticTests/array/push/nested_bytes_push.sol @@ -11,10 +11,8 @@ contract C { assert(a[2][32] == "a"); } } -// ==== -// compileViaYul: also // ---- // f() -> -// gas irOptimized: 179590 -// gas legacy: 180602 -// gas legacyOptimized: 180385 +// gas irOptimized: 179170 +// gas legacy: 181066 +// gas legacyOptimized: 180435 diff --git a/test/libsolidity/semanticTests/array/push/push_no_args_1d.sol b/test/libsolidity/semanticTests/array/push/push_no_args_1d.sol index daf8d43b1..cf6f0687d 100644 --- a/test/libsolidity/semanticTests/array/push/push_no_args_1d.sol +++ b/test/libsolidity/semanticTests/array/push/push_no_args_1d.sol @@ -19,8 +19,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // l() -> 0 // lv(uint256): 42 -> 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 5b470e829..e9a521fbf 100644 --- a/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol +++ b/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol @@ -24,19 +24,17 @@ contract C { array2d.push().push() = value; } } -// ==== -// compileViaYul: also // ---- // l() -> 0 // f(uint256,uint256): 42, 64 -> -// gas irOptimized: 112517 +// gas irOptimized: 112476 // gas legacy: 108105 // gas legacyOptimized: 101987 // l() -> 1 // ll(uint256): 0 -> 43 // a(uint256,uint256): 0, 42 -> 64 // f(uint256,uint256): 84, 128 -> -// gas irOptimized: 116389 +// gas irOptimized: 116264 // gas legacy: 107525 // gas legacyOptimized: 96331 // l() -> 2 diff --git a/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol b/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol index 713c44ec1..602755845 100644 --- a/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol +++ b/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol @@ -18,12 +18,10 @@ contract C { return array[index]; } } -// ==== -// compileViaYul: also // ---- // l() -> 0 // g(uint256): 70 -> -// gas irOptimized: 185922 +// gas irOptimized: 183584 // gas legacy: 183811 // gas legacyOptimized: 179218 // l() -> 70 diff --git a/test/libsolidity/semanticTests/array/push/push_no_args_struct.sol b/test/libsolidity/semanticTests/array/push/push_no_args_struct.sol index 89df694c6..6f626d9c3 100644 --- a/test/libsolidity/semanticTests/array/push/push_no_args_struct.sol +++ b/test/libsolidity/semanticTests/array/push/push_no_args_struct.sol @@ -31,8 +31,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // l() -> 0 // f(uint256): 42 -> diff --git a/test/libsolidity/semanticTests/array/reusing_memory.sol b/test/libsolidity/semanticTests/array/reusing_memory.sol index 455d6f948..fa8e84931 100644 --- a/test/libsolidity/semanticTests/array/reusing_memory.sol +++ b/test/libsolidity/semanticTests/array/reusing_memory.sol @@ -22,10 +22,8 @@ contract Main { return map[a]; } } -// ==== -// compileViaYul: also // ---- // f(uint256): 0x34 -> 0x46bddb1178e94d7f2892ff5f366840eb658911794f2c3a44c450aa2c505186c1 -// gas irOptimized: 113198 +// gas irOptimized: 112899 // gas legacy: 126596 // gas legacyOptimized: 113823 diff --git a/test/libsolidity/semanticTests/array/short_fixed_array_cleanup.sol b/test/libsolidity/semanticTests/array/short_fixed_array_cleanup.sol index 3665a8784..6fada19c5 100644 --- a/test/libsolidity/semanticTests/array/short_fixed_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/short_fixed_array_cleanup.sol @@ -9,7 +9,6 @@ contract c { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // storageEmpty -> 1 // fill() -> diff --git a/test/libsolidity/semanticTests/array/slices/array_calldata_assignment.sol b/test/libsolidity/semanticTests/array/slices/array_calldata_assignment.sol index 739916e34..282ccba09 100644 --- a/test/libsolidity/semanticTests/array/slices/array_calldata_assignment.sol +++ b/test/libsolidity/semanticTests/array/slices/array_calldata_assignment.sol @@ -5,7 +5,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(uint256[],uint256[],uint256): 0x60, 0xA0, 1, 1, 0, 2, 1, 2 -> 2 diff --git a/test/libsolidity/semanticTests/array/slices/array_slice_calldata_as_argument_of_external_calls.sol b/test/libsolidity/semanticTests/array/slices/array_slice_calldata_as_argument_of_external_calls.sol index 1f5e929d4..079364d21 100644 --- a/test/libsolidity/semanticTests/array/slices/array_slice_calldata_as_argument_of_external_calls.sol +++ b/test/libsolidity/semanticTests/array/slices/array_slice_calldata_as_argument_of_external_calls.sol @@ -27,8 +27,6 @@ contract C { return true; } } -// ==== -// compileViaYul: also // ---- // f1(bytes,uint256,uint256,bytes): 0x80, 1, 5, 0xC0, 8, "abcdefgh", 4, "bcde" -> true // f1(bytes,uint256,uint256,bytes): 0x80, 1, 5, 0xC0, 8, "abcdefgh", 4, "bcdf" -> false diff --git a/test/libsolidity/semanticTests/array/slices/array_slice_calldata_to_calldata.sol b/test/libsolidity/semanticTests/array/slices/array_slice_calldata_to_calldata.sol index d1df5185d..89096c99a 100644 --- a/test/libsolidity/semanticTests/array/slices/array_slice_calldata_to_calldata.sol +++ b/test/libsolidity/semanticTests/array/slices/array_slice_calldata_to_calldata.sol @@ -20,8 +20,6 @@ contract C { return f1(c[s:e]); } } -// ==== -// compileViaYul: also // ---- // g((uint128,uint256[3],uint32)[],uint256,uint256): 0x60, 1, 3, 4, 55, 1, 2, 3, 66, 66, 2, 3, 4, 77, 77, 3, 4, 5, 88, 88, 4, 5, 6, 99 -> 0x20, 2, 66, 2, 3, 4, 77, 77, 3, 4, 5, 88 // g1(uint256[3][],uint256,uint256): 0x60, 1, 3, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 -> 0x20, 2, 4, 5, 6, 7, 8, 9 diff --git a/test/libsolidity/semanticTests/array/slices/array_slice_calldata_to_memory.sol b/test/libsolidity/semanticTests/array/slices/array_slice_calldata_to_memory.sol index 02c439c51..e37bdf0c0 100644 --- a/test/libsolidity/semanticTests/array/slices/array_slice_calldata_to_memory.sol +++ b/test/libsolidity/semanticTests/array/slices/array_slice_calldata_to_memory.sol @@ -21,8 +21,6 @@ contract C { return h1(b[start:end]); } } -// ==== -// compileViaYul: also // ---- // f(int256[],uint256,uint256): 0x60, 1, 3, 4, 1, 2, 3, 4 -> 2 // g(int256[],uint256,uint256): 0x60, 1, 3, 4, 1, 2, 3, 4 -> 0x20, 2, 2, 3 diff --git a/test/libsolidity/semanticTests/array/slices/array_slice_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/slices/array_slice_calldata_to_storage.sol index 6c36372bc..b50d74e4c 100644 --- a/test/libsolidity/semanticTests/array/slices/array_slice_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/slices/array_slice_calldata_to_storage.sol @@ -10,7 +10,5 @@ contract C { return s[0]; } } -// ==== -// compileViaYul: also // ---- // f(int256[],uint256,uint256): 0x60, 1, 3, 4, 1, 2, 3, 4 -> 2 diff --git a/test/libsolidity/semanticTests/array/storage_array_ref.sol b/test/libsolidity/semanticTests/array/storage_array_ref.sol index 4249fd277..0a896fed4 100644 --- a/test/libsolidity/semanticTests/array/storage_array_ref.sol +++ b/test/libsolidity/semanticTests/array/storage_array_ref.sol @@ -39,8 +39,6 @@ contract Store is BinarySearch { } } -// ==== -// compileViaYul: also // ---- // find(uint256): 7 -> -1 // add(uint256): 7 -> diff --git a/test/libsolidity/semanticTests/array/string_allocation_bug.sol b/test/libsolidity/semanticTests/array/string_allocation_bug.sol index cd1ad5fc5..bc974a438 100644 --- a/test/libsolidity/semanticTests/array/string_allocation_bug.sol +++ b/test/libsolidity/semanticTests/array/string_allocation_bug.sol @@ -17,7 +17,6 @@ contract Sample { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // p(uint256): 0x0 -> 0xbbbb, 0xcccc, 0x80, 0xc0, 0x05, "hello", 0x05, "world" diff --git a/test/libsolidity/semanticTests/array/string_bytes_conversion.sol b/test/libsolidity/semanticTests/array/string_bytes_conversion.sol index 5f6e73422..9578fc4f7 100644 --- a/test/libsolidity/semanticTests/array/string_bytes_conversion.sol +++ b/test/libsolidity/semanticTests/array/string_bytes_conversion.sol @@ -12,8 +12,6 @@ contract Test { return bytes(s).length; } } -// ==== -// compileViaYul: also // ---- // f(string,uint256): 0x40, 0x02, 0x06, "abcdef" -> "c" // l() -> 0x06 diff --git a/test/libsolidity/semanticTests/array/string_literal_assign_to_storage_bytes.sol b/test/libsolidity/semanticTests/array/string_literal_assign_to_storage_bytes.sol index ee3cda2d1..dfabd26c0 100644 --- a/test/libsolidity/semanticTests/array/string_literal_assign_to_storage_bytes.sol +++ b/test/libsolidity/semanticTests/array/string_literal_assign_to_storage_bytes.sol @@ -9,8 +9,6 @@ contract C { (s, s1) = ("abc", "abcd"); } } -// ==== -// compileViaYul: also // ---- // s() -> 0x20, 3, "abc" // s1() -> 0x20, 4, "abcd" diff --git a/test/libsolidity/semanticTests/array/strings_in_struct.sol b/test/libsolidity/semanticTests/array/strings_in_struct.sol index 412d5a408..1cc6b5a93 100644 --- a/test/libsolidity/semanticTests/array/strings_in_struct.sol +++ b/test/libsolidity/semanticTests/array/strings_in_struct.sol @@ -29,7 +29,6 @@ contract buggystruct { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // getFirst() -> 0x0a diff --git a/test/libsolidity/semanticTests/asmForLoop/for_loop_break.sol b/test/libsolidity/semanticTests/asmForLoop/for_loop_break.sol index 24a86d1ba..c0c580072 100644 --- a/test/libsolidity/semanticTests/asmForLoop/for_loop_break.sol +++ b/test/libsolidity/semanticTests/asmForLoop/for_loop_break.sol @@ -11,6 +11,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 6 diff --git a/test/libsolidity/semanticTests/asmForLoop/for_loop_continue.sol b/test/libsolidity/semanticTests/asmForLoop/for_loop_continue.sol index 690f2489a..4be20d6ba 100644 --- a/test/libsolidity/semanticTests/asmForLoop/for_loop_continue.sol +++ b/test/libsolidity/semanticTests/asmForLoop/for_loop_continue.sol @@ -11,6 +11,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 5 diff --git a/test/libsolidity/semanticTests/asmForLoop/for_loop_nested.sol b/test/libsolidity/semanticTests/asmForLoop/for_loop_nested.sol index fd10fd072..620f2c3ba 100644 --- a/test/libsolidity/semanticTests/asmForLoop/for_loop_nested.sol +++ b/test/libsolidity/semanticTests/asmForLoop/for_loop_nested.sol @@ -15,7 +15,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 0 -> 2 // f(uint256): 1 -> 18 diff --git a/test/libsolidity/semanticTests/builtinFunctions/assignment_to_const_var_involving_keccak.sol b/test/libsolidity/semanticTests/builtinFunctions/assignment_to_const_var_involving_keccak.sol index 38b5cefeb..2e8a66363 100644 --- a/test/libsolidity/semanticTests/builtinFunctions/assignment_to_const_var_involving_keccak.sol +++ b/test/libsolidity/semanticTests/builtinFunctions/assignment_to_const_var_involving_keccak.sol @@ -7,6 +7,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 diff --git a/test/libsolidity/semanticTests/builtinFunctions/blockhash.sol b/test/libsolidity/semanticTests/builtinFunctions/blockhash.sol index bd3d5a72f..dc6e26f14 100644 --- a/test/libsolidity/semanticTests/builtinFunctions/blockhash.sol +++ b/test/libsolidity/semanticTests/builtinFunctions/blockhash.sol @@ -11,7 +11,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x3737373737373737373737373737373737373737373737373737373737373738 // g() -> 0x3737373737373737373737373737373737373737373737373737373737373739 diff --git a/test/libsolidity/semanticTests/builtinFunctions/blockhash_shadow_resolution.sol b/test/libsolidity/semanticTests/builtinFunctions/blockhash_shadow_resolution.sol index ba6345bc2..fa1d01d40 100644 --- a/test/libsolidity/semanticTests/builtinFunctions/blockhash_shadow_resolution.sol +++ b/test/libsolidity/semanticTests/builtinFunctions/blockhash_shadow_resolution.sol @@ -4,6 +4,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0 diff --git a/test/libsolidity/semanticTests/builtinFunctions/function_types_sig.sol b/test/libsolidity/semanticTests/builtinFunctions/function_types_sig.sol index cd67e657f..9a8132950 100644 --- a/test/libsolidity/semanticTests/builtinFunctions/function_types_sig.sol +++ b/test/libsolidity/semanticTests/builtinFunctions/function_types_sig.sol @@ -21,7 +21,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x26121ff000000000000000000000000000000000000000000000000000000000 // g() -> 0x26121ff000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/builtinFunctions/iterated_keccak256_with_bytes.sol b/test/libsolidity/semanticTests/builtinFunctions/iterated_keccak256_with_bytes.sol index 9f34a5282..91a26945c 100644 --- a/test/libsolidity/semanticTests/builtinFunctions/iterated_keccak256_with_bytes.sol +++ b/test/libsolidity/semanticTests/builtinFunctions/iterated_keccak256_with_bytes.sol @@ -8,7 +8,5 @@ contract c { return keccak256(abi.encodePacked("b", keccak256(data), "a")); } } -// ==== -// compileViaYul: also // ---- // foo() -> 0xb338eefce206f9f57b83aa738deecd5326dc4b72dd81ee6a7c621a6facb7acdc diff --git a/test/libsolidity/semanticTests/builtinFunctions/keccak256_empty.sol b/test/libsolidity/semanticTests/builtinFunctions/keccak256_empty.sol index 5a44d14da..1898f0311 100644 --- a/test/libsolidity/semanticTests/builtinFunctions/keccak256_empty.sol +++ b/test/libsolidity/semanticTests/builtinFunctions/keccak256_empty.sol @@ -6,6 +6,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 diff --git a/test/libsolidity/semanticTests/builtinFunctions/keccak256_multiple_arguments.sol b/test/libsolidity/semanticTests/builtinFunctions/keccak256_multiple_arguments.sol index 4a31c6715..972aee839 100644 --- a/test/libsolidity/semanticTests/builtinFunctions/keccak256_multiple_arguments.sol +++ b/test/libsolidity/semanticTests/builtinFunctions/keccak256_multiple_arguments.sol @@ -3,7 +3,5 @@ contract c { d = keccak256(abi.encodePacked(a, b, c)); } } -// ==== -// compileViaYul: also // ---- // foo(uint256,uint256,uint256): 0xa, 0xc, 0xd -> 0xbc740a98aae5923e8f04c9aa798c9ee82f69e319997699f2782c40828db9fd81 diff --git a/test/libsolidity/semanticTests/builtinFunctions/keccak256_multiple_arguments_with_numeric_literals.sol b/test/libsolidity/semanticTests/builtinFunctions/keccak256_multiple_arguments_with_numeric_literals.sol index 958975966..01397f55f 100644 --- a/test/libsolidity/semanticTests/builtinFunctions/keccak256_multiple_arguments_with_numeric_literals.sol +++ b/test/libsolidity/semanticTests/builtinFunctions/keccak256_multiple_arguments_with_numeric_literals.sol @@ -3,7 +3,5 @@ contract c { d = keccak256(abi.encodePacked(a, b, uint8(145))); } } -// ==== -// compileViaYul: also // ---- // foo(uint256,uint16): 0xa, 0xc -> 0x88acd45f75907e7c560318bc1a5249850a0999c4896717b1167d05d116e6dbad diff --git a/test/libsolidity/semanticTests/builtinFunctions/keccak256_multiple_arguments_with_string_literals.sol b/test/libsolidity/semanticTests/builtinFunctions/keccak256_multiple_arguments_with_string_literals.sol index c4e0b7d09..b157178fb 100644 --- a/test/libsolidity/semanticTests/builtinFunctions/keccak256_multiple_arguments_with_string_literals.sol +++ b/test/libsolidity/semanticTests/builtinFunctions/keccak256_multiple_arguments_with_string_literals.sol @@ -7,8 +7,6 @@ contract c { d = keccak256(abi.encodePacked(a, b, uint8(145), "foo")); } } -// ==== -// compileViaYul: also // ---- // foo() -> 0x41b1a0649752af1b28b3dc29a1556eee781e4a4c3a1f7f53f90fa834de098c4d // bar(uint256,uint16): 0xa, 0xc -> 0x6990f36476dc412b1c4baa48e2d9f4aa4bb313f61fda367c8fdbbb2232dc6146 diff --git a/test/libsolidity/semanticTests/builtinFunctions/keccak256_with_bytes.sol b/test/libsolidity/semanticTests/builtinFunctions/keccak256_with_bytes.sol index b284b7f01..725d984d8 100644 --- a/test/libsolidity/semanticTests/builtinFunctions/keccak256_with_bytes.sol +++ b/test/libsolidity/semanticTests/builtinFunctions/keccak256_with_bytes.sol @@ -9,7 +9,5 @@ contract c { } } -// ==== -// compileViaYul: also // ---- // foo() -> true diff --git a/test/libsolidity/semanticTests/builtinFunctions/msg_sig.sol b/test/libsolidity/semanticTests/builtinFunctions/msg_sig.sol index 7457a2c8c..21c5ed76d 100644 --- a/test/libsolidity/semanticTests/builtinFunctions/msg_sig.sol +++ b/test/libsolidity/semanticTests/builtinFunctions/msg_sig.sol @@ -5,6 +5,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // foo(uint256): 0x0 -> 0x2fbebd3800000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/builtinFunctions/msg_sig_after_internal_call_is_same.sol b/test/libsolidity/semanticTests/builtinFunctions/msg_sig_after_internal_call_is_same.sol index 7369ddeda..a50521610 100644 --- a/test/libsolidity/semanticTests/builtinFunctions/msg_sig_after_internal_call_is_same.sol +++ b/test/libsolidity/semanticTests/builtinFunctions/msg_sig_after_internal_call_is_same.sol @@ -9,6 +9,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // foo(uint256): 0x0 -> 0x2fbebd3800000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/builtinFunctions/ripemd160_empty.sol b/test/libsolidity/semanticTests/builtinFunctions/ripemd160_empty.sol index ea0fda845..c79625d3c 100644 --- a/test/libsolidity/semanticTests/builtinFunctions/ripemd160_empty.sol +++ b/test/libsolidity/semanticTests/builtinFunctions/ripemd160_empty.sol @@ -4,7 +4,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f() -> 0x9c1185a5c5e9fc54612808977ee8f548b2258d31000000000000000000000000 diff --git a/test/libsolidity/semanticTests/builtinFunctions/sha256_empty.sol b/test/libsolidity/semanticTests/builtinFunctions/sha256_empty.sol index ededa2fab..bb9fc3616 100644 --- a/test/libsolidity/semanticTests/builtinFunctions/sha256_empty.sol +++ b/test/libsolidity/semanticTests/builtinFunctions/sha256_empty.sol @@ -3,7 +3,5 @@ contract C { return sha256(""); } } -// ==== -// compileViaYul: also // ---- // f() -> 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 diff --git a/test/libsolidity/semanticTests/byte_array_to_storage_cleanup.sol b/test/libsolidity/semanticTests/byte_array_to_storage_cleanup.sol new file mode 100644 index 000000000..745b8ee12 --- /dev/null +++ b/test/libsolidity/semanticTests/byte_array_to_storage_cleanup.sol @@ -0,0 +1,37 @@ +contract C { + event ev(uint[], uint); + bytes public s; + function h() external returns (bytes memory) { + uint[] memory x = new uint[](2); + emit ev(x, 0x21); + bytes memory m = new bytes(63); + s = m; + s.push(); + return s; + } + function g() external returns (bytes memory) { + bytes memory m = new bytes(63); + assembly { + mstore8(add(m, add(32, 63)), 0x42) + } + s = m; + s.push(); + return s; + } + function f(bytes calldata c) external returns (bytes memory) { + s = c; + s.push(); + return s; + } +} +// ==== +// compileViaYul: also +// ---- +// constructor() -> +// gas irOptimized: 518935 +// gas legacy: 729908 +// gas legacyOptimized: 493347 +// h() -> 0x20, 0x40, 0x00, 0 +// ~ emit ev(uint256[],uint256): 0x40, 0x21, 0x02, 0x00, 0x00 +// g() -> 0x20, 0x40, 0, 0x00 +// f(bytes): 0x20, 33, 0, -1 -> 0x20, 0x22, 0, 0xff00000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/c99_scoping_activation.sol b/test/libsolidity/semanticTests/c99_scoping_activation.sol index bca43e78c..394b211d6 100644 --- a/test/libsolidity/semanticTests/c99_scoping_activation.sol +++ b/test/libsolidity/semanticTests/c99_scoping_activation.sol @@ -36,7 +36,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 3 // g() -> 0 diff --git a/test/libsolidity/semanticTests/calldata/calldata_bound_bytes.sol b/test/libsolidity/semanticTests/calldata/calldata_bound_bytes.sol index 44126a18f..e41b75c2d 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_bound_bytes.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_bound_bytes.sol @@ -14,7 +14,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // test(uint256,bytes,uint256): 7, 0x60, 4, 2, "ab" -> "b", "a" diff --git a/test/libsolidity/semanticTests/calldata/calldata_bound_dynamic_array_or_slice.sol b/test/libsolidity/semanticTests/calldata/calldata_bound_dynamic_array_or_slice.sol index 251910eae..3ebb4787a 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_bound_dynamic_array_or_slice.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_bound_dynamic_array_or_slice.sol @@ -18,8 +18,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // testArray(uint256,uint256[],uint256): 7, 0x60, 4, 2, 66, 77 -> 77, 66 // testSlice(uint256,uint256[],uint256): 7, 0x60, 4, 2, 66, 77 -> 77, 66 diff --git a/test/libsolidity/semanticTests/calldata/calldata_bound_static_array.sol b/test/libsolidity/semanticTests/calldata/calldata_bound_static_array.sol index 252c12579..e43b17561 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_bound_static_array.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_bound_static_array.sol @@ -14,7 +14,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // test(uint256,uint256[2],uint256): 7, 66, 77, 4 -> 77, 66 diff --git a/test/libsolidity/semanticTests/calldata/calldata_bound_struct.sol b/test/libsolidity/semanticTests/calldata/calldata_bound_struct.sol index 2d599ac12..ee4420470 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_bound_struct.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_bound_struct.sol @@ -18,7 +18,5 @@ contract C { return _s.reverse(); } } -// ==== -// compileViaYul: also // ---- // test(uint256,(uint256,uint256),uint256): 7, 66, 77, 4 -> 77, 66 diff --git a/test/libsolidity/semanticTests/calldata/calldata_bytes_external.sol b/test/libsolidity/semanticTests/calldata/calldata_bytes_external.sol index c4686cc01..a39758271 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_bytes_external.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_bytes_external.sol @@ -8,6 +8,5 @@ contract CalldataTest { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // tester(bytes): 0x20, 0x08, "abcdefgh" -> "c" diff --git a/test/libsolidity/semanticTests/calldata/calldata_bytes_internal.sol b/test/libsolidity/semanticTests/calldata/calldata_bytes_internal.sol index a0384f887..79cf94be1 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_bytes_internal.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_bytes_internal.sol @@ -6,7 +6,5 @@ contract C { return f(b, 2); } } -// ==== -// compileViaYul: also // ---- // f(uint256,bytes,uint256): 7, 0x60, 7, 4, "abcd" -> "c" diff --git a/test/libsolidity/semanticTests/calldata/calldata_bytes_to_memory.sol b/test/libsolidity/semanticTests/calldata/calldata_bytes_to_memory.sol index ca6a444d8..164ac8a8e 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_bytes_to_memory.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_bytes_to_memory.sol @@ -3,7 +3,5 @@ contract C { return keccak256(bytes(data)); } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 0x08, "abcdefgh" -> 0x48624fa43c68d5c552855a4e2919e74645f683f5384f72b5b051b71ea41d4f2d diff --git a/test/libsolidity/semanticTests/calldata/calldata_bytes_to_memory_encode.sol b/test/libsolidity/semanticTests/calldata/calldata_bytes_to_memory_encode.sol index 4bb97779c..5f30aff30 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_bytes_to_memory_encode.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_bytes_to_memory_encode.sol @@ -3,7 +3,5 @@ contract C { return abi.encode(bytes(data)); } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 0x08, "abcdefgh" -> 0x20, 0x60, 0x20, 8, 44048183304486788309563647967830685498285570828042699209880294173606615711744 diff --git a/test/libsolidity/semanticTests/calldata/calldata_internal_function_pointer.sol b/test/libsolidity/semanticTests/calldata/calldata_internal_function_pointer.sol index d6871d7e4..ee4bdf58c 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_internal_function_pointer.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_internal_function_pointer.sol @@ -13,7 +13,5 @@ contract C { return this.h(a); } } -// ==== -// compileViaYul: also // ---- // g() -> 0x0700000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/calldata/calldata_internal_library.sol b/test/libsolidity/semanticTests/calldata/calldata_internal_library.sol index fa44cc144..adc9963a2 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_internal_library.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_internal_library.sol @@ -16,7 +16,5 @@ contract C { return this.f(x); } } -// ==== -// compileViaYul: also // ---- // g() -> 0x0800000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/calldata/calldata_internal_multi_array.sol b/test/libsolidity/semanticTests/calldata/calldata_internal_multi_array.sol index 33f27a084..26343b7e6 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_internal_multi_array.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_internal_multi_array.sol @@ -17,7 +17,5 @@ contract C { return this.f(4, x, 5); } } -// ==== -// compileViaYul: also // ---- // g() -> 7, 8 diff --git a/test/libsolidity/semanticTests/calldata/calldata_internal_multi_fixed_array.sol b/test/libsolidity/semanticTests/calldata/calldata_internal_multi_fixed_array.sol index 6fb892dde..cd5a8cfeb 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_internal_multi_fixed_array.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_internal_multi_fixed_array.sol @@ -13,7 +13,5 @@ contract C { return this.f(4, x, 5); } } -// ==== -// compileViaYul: also // ---- // g() -> 7, 8 diff --git a/test/libsolidity/semanticTests/calldata/calldata_memory_mixed.sol b/test/libsolidity/semanticTests/calldata/calldata_memory_mixed.sol index 2798a6ab7..f5948d2d0 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_memory_mixed.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_memory_mixed.sol @@ -15,7 +15,5 @@ contract C { return this.f(x, y, z); } } -// ==== -// compileViaYul: also // ---- // g() -> 0x0e, 0x0800000000000000000000000000000000000000000000000000000000000000, 0x0900000000000000000000000000000000000000000000000000000000000000, 0x0a00000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/calldata/calldata_string_array.sol b/test/libsolidity/semanticTests/calldata/calldata_string_array.sol index 1ab1b25a8..79efb1712 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_string_array.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_string_array.sol @@ -11,7 +11,5 @@ contract C { return (a.length, m1.length, uint8(m1[0]), s1); } } -// ==== -// compileViaYul: also // ---- // f(string[]): 0x20, 0x1, 0x20, 0x2, hex"6162000000000000000000000000000000000000000000000000000000000000" -> 1, 2, 97, 0x80, 2, "ab" diff --git a/test/libsolidity/semanticTests/calldata/calldata_struct.sol b/test/libsolidity/semanticTests/calldata/calldata_struct.sol index 6eae8b0c5..247c00a7e 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_struct.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_struct.sol @@ -16,7 +16,5 @@ contract C { return L.reverse(_s); } } -// ==== -// compileViaYul: also // ---- // test(uint256,(uint256,uint256),uint256): 7, 66, 77, 4 -> 77, 66 diff --git a/test/libsolidity/semanticTests/calldata/calldata_struct_cleaning.sol b/test/libsolidity/semanticTests/calldata/calldata_struct_cleaning.sol index 771f2591a..493b1ef0b 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_struct_cleaning.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_struct_cleaning.sol @@ -18,7 +18,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f((uint8,bytes1)): 0x12, hex"3400000000000000000000000000000000000000000000000000000000000000" -> 0x12, hex"3400000000000000000000000000000000000000000000000000000000000000" # double check that the valid case goes through # // f((uint8,bytes1)): 0x1234, hex"5678000000000000000000000000000000000000000000000000000000000000" -> FAILURE diff --git a/test/libsolidity/semanticTests/calldata/calldata_struct_internal.sol b/test/libsolidity/semanticTests/calldata/calldata_struct_internal.sol index 50351087e..8a6c2687d 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_struct_internal.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_struct_internal.sol @@ -13,7 +13,5 @@ contract C { return f(s); } } -// ==== -// compileViaYul: also // ---- // f(uint256,(uint256,uint256),uint256): 7, 1, 2, 4 -> 1, 2 diff --git a/test/libsolidity/semanticTests/calldata/copy_from_calldata_removes_bytes_data.sol b/test/libsolidity/semanticTests/calldata/copy_from_calldata_removes_bytes_data.sol index b8dbff46a..9fc432e8c 100644 --- a/test/libsolidity/semanticTests/calldata/copy_from_calldata_removes_bytes_data.sol +++ b/test/libsolidity/semanticTests/calldata/copy_from_calldata_removes_bytes_data.sol @@ -8,12 +8,11 @@ contract c { // ==== // EVMVersion: >=byzantium // compileToEwasm: false -// compileViaYul: also // ---- // (): 1, 2, 3, 4, 5 -> -// gas irOptimized: 155170 -// gas legacy: 155249 -// gas legacyOptimized: 155212 +// gas irOptimized: 155158 +// gas legacy: 155483 +// gas legacyOptimized: 155303 // checkIfDataIsEmpty() -> false // sendMessage() -> true, 0x40, 0 // checkIfDataIsEmpty() -> true diff --git a/test/libsolidity/semanticTests/cleanup/bool_conversion_v1.sol b/test/libsolidity/semanticTests/cleanup/bool_conversion_v1.sol index 531f4d05c..18fa6ed65 100644 --- a/test/libsolidity/semanticTests/cleanup/bool_conversion_v1.sol +++ b/test/libsolidity/semanticTests/cleanup/bool_conversion_v1.sol @@ -11,6 +11,7 @@ contract C { } // ==== // ABIEncoderV1Only: true +// compileViaYul: false // ---- // f(bool): 0x0 -> 0x0 // f(bool): 0x1 -> 0x1 diff --git a/test/libsolidity/semanticTests/cleanup/bool_conversion_v2.sol b/test/libsolidity/semanticTests/cleanup/bool_conversion_v2.sol index 4960b6e95..821da2dac 100644 --- a/test/libsolidity/semanticTests/cleanup/bool_conversion_v2.sol +++ b/test/libsolidity/semanticTests/cleanup/bool_conversion_v2.sol @@ -13,7 +13,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bool): 0x0 -> 0x0 // f(bool): 0x1 -> 0x1 diff --git a/test/libsolidity/semanticTests/cleanup/cleanup_address_types_shortening.sol b/test/libsolidity/semanticTests/cleanup/cleanup_address_types_shortening.sol index 391fa4993..916f2e5aa 100644 --- a/test/libsolidity/semanticTests/cleanup/cleanup_address_types_shortening.sol +++ b/test/libsolidity/semanticTests/cleanup/cleanup_address_types_shortening.sol @@ -28,7 +28,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x1122334455667788990011223344556677889900 // g() -> 0x1122334455667788990011223344556677889900 diff --git a/test/libsolidity/semanticTests/cleanup/cleanup_address_types_v1.sol b/test/libsolidity/semanticTests/cleanup/cleanup_address_types_v1.sol index 7c71d8bd6..a8622cb0b 100644 --- a/test/libsolidity/semanticTests/cleanup/cleanup_address_types_v1.sol +++ b/test/libsolidity/semanticTests/cleanup/cleanup_address_types_v1.sol @@ -13,6 +13,7 @@ contract C { } // ==== // ABIEncoderV1Only: true +// compileViaYul: false // ---- // f(address): 0xffff1234567890123456789012345678901234567890 -> 0x0 # We input longer data on purpose.# // g(address): 0xffff1234567890123456789012345678901234567890 -> 0x0 diff --git a/test/libsolidity/semanticTests/cleanup/cleanup_address_types_v2.sol b/test/libsolidity/semanticTests/cleanup/cleanup_address_types_v2.sol index d9f6fdafd..d6157ab23 100644 --- a/test/libsolidity/semanticTests/cleanup/cleanup_address_types_v2.sol +++ b/test/libsolidity/semanticTests/cleanup/cleanup_address_types_v2.sol @@ -15,7 +15,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(address): 0xffff1234567890123456789012345678901234567890 -> FAILURE # We input longer data on purpose.# // g(address): 0xffff1234567890123456789012345678901234567890 -> FAILURE diff --git a/test/libsolidity/semanticTests/cleanup/cleanup_bytes_types_v1.sol b/test/libsolidity/semanticTests/cleanup/cleanup_bytes_types_v1.sol index ac085cd56..097da51e4 100644 --- a/test/libsolidity/semanticTests/cleanup/cleanup_bytes_types_v1.sol +++ b/test/libsolidity/semanticTests/cleanup/cleanup_bytes_types_v1.sol @@ -10,5 +10,6 @@ contract C { } // ==== // ABIEncoderV1Only: true +// compileViaYul: false // ---- // f(bytes2,uint16): "abc", 0x40102 -> 0x0 # We input longer data on purpose. # diff --git a/test/libsolidity/semanticTests/cleanup/cleanup_bytes_types_v2.sol b/test/libsolidity/semanticTests/cleanup/cleanup_bytes_types_v2.sol index a075a3763..f481ffed6 100644 --- a/test/libsolidity/semanticTests/cleanup/cleanup_bytes_types_v2.sol +++ b/test/libsolidity/semanticTests/cleanup/cleanup_bytes_types_v2.sol @@ -12,6 +12,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bytes2,uint16): "abc", 0x40102 -> FAILURE # We input longer data on purpose. # diff --git a/test/libsolidity/semanticTests/cleanup/cleanup_in_compound_assign.sol b/test/libsolidity/semanticTests/cleanup/cleanup_in_compound_assign.sol index b1cd6637a..51815f5e9 100644 --- a/test/libsolidity/semanticTests/cleanup/cleanup_in_compound_assign.sol +++ b/test/libsolidity/semanticTests/cleanup/cleanup_in_compound_assign.sol @@ -10,6 +10,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 0xff, 0xff diff --git a/test/libsolidity/semanticTests/cleanup/exp_cleanup.sol b/test/libsolidity/semanticTests/cleanup/exp_cleanup.sol index 19edfcc98..a5145bceb 100644 --- a/test/libsolidity/semanticTests/cleanup/exp_cleanup.sol +++ b/test/libsolidity/semanticTests/cleanup/exp_cleanup.sol @@ -8,7 +8,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 0x1 diff --git a/test/libsolidity/semanticTests/cleanup/exp_cleanup_direct.sol b/test/libsolidity/semanticTests/cleanup/exp_cleanup_direct.sol index 4efdd351a..663716a12 100644 --- a/test/libsolidity/semanticTests/cleanup/exp_cleanup_direct.sol +++ b/test/libsolidity/semanticTests/cleanup/exp_cleanup_direct.sol @@ -7,7 +7,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 0x1 diff --git a/test/libsolidity/semanticTests/cleanup/exp_cleanup_nonzero_base.sol b/test/libsolidity/semanticTests/cleanup/exp_cleanup_nonzero_base.sol index 92457e2a9..12c3afba4 100644 --- a/test/libsolidity/semanticTests/cleanup/exp_cleanup_nonzero_base.sol +++ b/test/libsolidity/semanticTests/cleanup/exp_cleanup_nonzero_base.sol @@ -8,7 +8,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 0x1 diff --git a/test/libsolidity/semanticTests/cleanup/exp_cleanup_smaller_base.sol b/test/libsolidity/semanticTests/cleanup/exp_cleanup_smaller_base.sol index f0ff36ad8..b282948cb 100644 --- a/test/libsolidity/semanticTests/cleanup/exp_cleanup_smaller_base.sol +++ b/test/libsolidity/semanticTests/cleanup/exp_cleanup_smaller_base.sol @@ -10,7 +10,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 0x00 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 df6bc2192..742c02693 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 @@ -9,8 +9,6 @@ contract C { emit ev0(x); } } -// ==== -// compileViaYul: also // ---- // constructor() -> // ~ emit ev0(bytes1): #"1" diff --git a/test/libsolidity/semanticTests/constantEvaluator/negative_fractional_mod.sol b/test/libsolidity/semanticTests/constantEvaluator/negative_fractional_mod.sol index 83388da1f..0385a4c30 100644 --- a/test/libsolidity/semanticTests/constantEvaluator/negative_fractional_mod.sol +++ b/test/libsolidity/semanticTests/constantEvaluator/negative_fractional_mod.sol @@ -7,6 +7,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 11, 10 diff --git a/test/libsolidity/semanticTests/constantEvaluator/rounding.sol b/test/libsolidity/semanticTests/constantEvaluator/rounding.sol index 6a3f953bd..a7c1b4b45 100644 --- a/test/libsolidity/semanticTests/constantEvaluator/rounding.sol +++ b/test/libsolidity/semanticTests/constantEvaluator/rounding.sol @@ -11,6 +11,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 2, 2, 2, 2 diff --git a/test/libsolidity/semanticTests/constants/asm_address_constant_regression.sol b/test/libsolidity/semanticTests/constants/asm_address_constant_regression.sol index 0a4549858..3da3ff646 100644 --- a/test/libsolidity/semanticTests/constants/asm_address_constant_regression.sol +++ b/test/libsolidity/semanticTests/constants/asm_address_constant_regression.sol @@ -10,6 +10,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x00 diff --git a/test/libsolidity/semanticTests/constants/asm_constant_file_level.sol b/test/libsolidity/semanticTests/constants/asm_constant_file_level.sol index 30f832d6b..89d2e250d 100644 --- a/test/libsolidity/semanticTests/constants/asm_constant_file_level.sol +++ b/test/libsolidity/semanticTests/constants/asm_constant_file_level.sol @@ -6,7 +6,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 0x1212121212121212121212121000002134593163 diff --git a/test/libsolidity/semanticTests/constants/constant_string.sol b/test/libsolidity/semanticTests/constants/constant_string.sol index 53b1cf970..638b24382 100644 --- a/test/libsolidity/semanticTests/constants/constant_string.sol +++ b/test/libsolidity/semanticTests/constants/constant_string.sol @@ -18,7 +18,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x20, 3, "\x03\x01\x02" // g() -> 0x20, 3, "\x03\x01\x02" diff --git a/test/libsolidity/semanticTests/constants/constant_string_at_file_level.sol b/test/libsolidity/semanticTests/constants/constant_string_at_file_level.sol index 7b2e0ae99..a8822176d 100644 --- a/test/libsolidity/semanticTests/constants/constant_string_at_file_level.sol +++ b/test/libsolidity/semanticTests/constants/constant_string_at_file_level.sol @@ -26,7 +26,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x20, 3, "\x03\x01\x02" // g() -> 0x20, 3, "\x03\x01\x02" diff --git a/test/libsolidity/semanticTests/constants/constant_variables.sol b/test/libsolidity/semanticTests/constants/constant_variables.sol index 9ef73515a..4ae4edb97 100644 --- a/test/libsolidity/semanticTests/constants/constant_variables.sol +++ b/test/libsolidity/semanticTests/constants/constant_variables.sol @@ -7,6 +7,5 @@ contract Foo { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // constructor() -> diff --git a/test/libsolidity/semanticTests/constants/constants_at_file_level_referencing.sol b/test/libsolidity/semanticTests/constants/constants_at_file_level_referencing.sol index 1e6757321..a1ae3911f 100644 --- a/test/libsolidity/semanticTests/constants/constants_at_file_level_referencing.sol +++ b/test/libsolidity/semanticTests/constants/constants_at_file_level_referencing.sol @@ -34,7 +34,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x20, 3, "\x03\x01\x02" // g() -> 0x20, 3, "\x03\x01\x02" diff --git a/test/libsolidity/semanticTests/constants/function_unreferenced.sol b/test/libsolidity/semanticTests/constants/function_unreferenced.sol index 399c5171d..2b80c440f 100644 --- a/test/libsolidity/semanticTests/constants/function_unreferenced.sol +++ b/test/libsolidity/semanticTests/constants/function_unreferenced.sol @@ -6,7 +6,6 @@ contract C is B { function f() external pure returns (bytes4) { return s2; } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 0xe2179b8e00000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/constants/same_constants_different_files.sol b/test/libsolidity/semanticTests/constants/same_constants_different_files.sol index 9af6723d3..5a85c5fd7 100644 --- a/test/libsolidity/semanticTests/constants/same_constants_different_files.sol +++ b/test/libsolidity/semanticTests/constants/same_constants_different_files.sol @@ -22,6 +22,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x0d, 0x59, 0x59, 0x59 diff --git a/test/libsolidity/semanticTests/constants/simple_constant_variables_test.sol b/test/libsolidity/semanticTests/constants/simple_constant_variables_test.sol index 1df6224ac..ea35262ef 100644 --- a/test/libsolidity/semanticTests/constants/simple_constant_variables_test.sol +++ b/test/libsolidity/semanticTests/constants/simple_constant_variables_test.sol @@ -8,6 +8,5 @@ contract Foo { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // getX() -> 56 diff --git a/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol b/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol index 82050efa2..1d311be80 100644 --- a/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol +++ b/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol @@ -22,10 +22,8 @@ contract Creator { ch = c.part(x); } } -// ==== -// compileViaYul: also // ---- // f(uint256,address[]): 7, 0x40, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 -> 7, 8 -// gas irOptimized: 437093 +// gas irOptimized: 429680 // gas legacy: 590683 // gas legacyOptimized: 448326 diff --git a/test/libsolidity/semanticTests/constructor/base_constructor_arguments.sol b/test/libsolidity/semanticTests/constructor/base_constructor_arguments.sol index 76c18244e..d6d76adc5 100644 --- a/test/libsolidity/semanticTests/constructor/base_constructor_arguments.sol +++ b/test/libsolidity/semanticTests/constructor/base_constructor_arguments.sol @@ -20,7 +20,5 @@ contract Derived is Base { } } -// ==== -// compileViaYul: also // ---- // getA() -> 49 diff --git a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol index bdd5c6eb5..4e3f92c81 100644 --- a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol +++ b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol @@ -22,10 +22,8 @@ contract Creator { ch = c.part(x); } } -// ==== -// compileViaYul: also // ---- // f(uint256,bytes): 7, 0x40, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> 7, "h" -// gas irOptimized: 293203 -// gas legacy: 428711 -// gas legacyOptimized: 297922 +// gas irOptimized: 279069 +// gas legacy: 427192 +// gas legacyOptimized: 296504 diff --git a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_unpacker.sol b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_unpacker.sol index d0b3f64cb..905114aba 100644 --- a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_unpacker.sol +++ b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_unpacker.sol @@ -6,12 +6,10 @@ contract Test { m_s = s; } } -// ==== -// compileViaYul: also // ---- // constructor(): 7, 0x40, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> -// gas irOptimized: 283829 -// gas legacy: 309607 -// gas legacyOptimized: 260566 +// gas irOptimized: 270118 +// gas legacy: 315616 +// gas legacyOptimized: 260686 // m_x() -> 7 // m_s() -> 0x20, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" diff --git a/test/libsolidity/semanticTests/constructor/callvalue_check.sol b/test/libsolidity/semanticTests/constructor/callvalue_check.sol index 3b7c63a9d..f45fbed92 100644 --- a/test/libsolidity/semanticTests/constructor/callvalue_check.sol +++ b/test/libsolidity/semanticTests/constructor/callvalue_check.sol @@ -29,7 +29,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f(uint256), 2000 ether: 0 -> true // f(uint256), 2000 ether: 100 -> false diff --git a/test/libsolidity/semanticTests/constructor/constructor_arguments_external.sol b/test/libsolidity/semanticTests/constructor/constructor_arguments_external.sol index 701f4accb..3f12c4e27 100644 --- a/test/libsolidity/semanticTests/constructor/constructor_arguments_external.sol +++ b/test/libsolidity/semanticTests/constructor/constructor_arguments_external.sol @@ -15,11 +15,9 @@ contract Main { return flag; } } -// ==== -// compileViaYul: also // ---- // constructor(): "abc", true -// gas irOptimized: 106683 +// gas irOptimized: 106546 // gas legacy: 145838 // gas legacyOptimized: 104017 // getFlag() -> true diff --git a/test/libsolidity/semanticTests/constructor/constructor_arguments_internal.sol b/test/libsolidity/semanticTests/constructor/constructor_arguments_internal.sol index c7534faaf..bb7e7e596 100644 --- a/test/libsolidity/semanticTests/constructor/constructor_arguments_internal.sol +++ b/test/libsolidity/semanticTests/constructor/constructor_arguments_internal.sol @@ -33,8 +33,6 @@ contract Main { } } -// ==== -// compileViaYul: also // ---- // getFlag() -> true // getName() -> "abc" diff --git a/test/libsolidity/semanticTests/constructor/constructor_function_argument.sol b/test/libsolidity/semanticTests/constructor/constructor_function_argument.sol index b52f10de0..159f2943d 100644 --- a/test/libsolidity/semanticTests/constructor/constructor_function_argument.sol +++ b/test/libsolidity/semanticTests/constructor/constructor_function_argument.sol @@ -3,7 +3,5 @@ contract D { constructor(function() external returns (uint)) { } } -// ==== -// compileViaYul: also // ---- // constructor(): 0xfdd67305928fcac8d213d1e47bfa6165cd0b87b946644cd0000000000000000 -> diff --git a/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol b/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol index f1043f559..220db16d5 100644 --- a/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol +++ b/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol @@ -15,8 +15,6 @@ contract C { return 16; } } -// ==== -// compileViaYul: also // ---- // f() -> 16 // gas legacy: 103488 diff --git a/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol b/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol index 0c38107cc..7daf503d4 100644 --- a/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol +++ b/test/libsolidity/semanticTests/constructor/constructor_static_array_argument.sol @@ -8,11 +8,9 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // constructor(): 1, 2, 3, 4 -> -// gas irOptimized: 174020 +// gas irOptimized: 172948 // gas legacy: 221377 // gas legacyOptimized: 177671 // a() -> 1 diff --git a/test/libsolidity/semanticTests/constructor/evm_exceptions_in_constructor_call_fail.sol b/test/libsolidity/semanticTests/constructor/evm_exceptions_in_constructor_call_fail.sol index 5310d097b..92633cdda 100644 --- a/test/libsolidity/semanticTests/constructor/evm_exceptions_in_constructor_call_fail.sol +++ b/test/libsolidity/semanticTests/constructor/evm_exceptions_in_constructor_call_fail.sol @@ -14,8 +14,6 @@ contract B { } } -// ==== -// compileViaYul: also // ---- // testIt() -> // test() -> 2 diff --git a/test/libsolidity/semanticTests/constructor/function_usage_in_constructor_arguments.sol b/test/libsolidity/semanticTests/constructor/function_usage_in_constructor_arguments.sol index 44d376cb6..0c0b6e314 100644 --- a/test/libsolidity/semanticTests/constructor/function_usage_in_constructor_arguments.sol +++ b/test/libsolidity/semanticTests/constructor/function_usage_in_constructor_arguments.sol @@ -20,7 +20,5 @@ contract Derived is Base { } } -// ==== -// compileViaYul: also // ---- // getA() -> 2 diff --git a/test/libsolidity/semanticTests/constructor/functions_called_by_constructor.sol b/test/libsolidity/semanticTests/constructor/functions_called_by_constructor.sol index 716bef332..397c314a9 100644 --- a/test/libsolidity/semanticTests/constructor/functions_called_by_constructor.sol +++ b/test/libsolidity/semanticTests/constructor/functions_called_by_constructor.sol @@ -17,6 +17,5 @@ contract Test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // getName() -> "abc" diff --git a/test/libsolidity/semanticTests/constructor/functions_called_by_constructor_through_dispatch.sol b/test/libsolidity/semanticTests/constructor/functions_called_by_constructor_through_dispatch.sol index 41602c09e..763393a99 100644 --- a/test/libsolidity/semanticTests/constructor/functions_called_by_constructor_through_dispatch.sol +++ b/test/libsolidity/semanticTests/constructor/functions_called_by_constructor_through_dispatch.sol @@ -27,6 +27,5 @@ contract Test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // getName() -> "def\x00\x00\x00" diff --git a/test/libsolidity/semanticTests/constructor/inline_member_init_inheritence_without_constructor.sol b/test/libsolidity/semanticTests/constructor/inline_member_init_inheritence_without_constructor.sol index e4d392115..6e1f46f86 100644 --- a/test/libsolidity/semanticTests/constructor/inline_member_init_inheritence_without_constructor.sol +++ b/test/libsolidity/semanticTests/constructor/inline_member_init_inheritence_without_constructor.sol @@ -16,7 +16,6 @@ contract Derived is Base { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // getBMember() -> 5 // getDMember() -> 6 diff --git a/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol b/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol index 9908b2386..bad890226 100644 --- a/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol +++ b/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol @@ -15,10 +15,8 @@ contract C { return true; } } -// ==== -// compileViaYul: also // ---- // f(), 2000 ether -> true -// gas irOptimized: 120037 +// gas irOptimized: 120052 // gas legacy: 123226 // gas legacyOptimized: 123092 diff --git a/test/libsolidity/semanticTests/constructor/order_of_evaluation.sol b/test/libsolidity/semanticTests/constructor/order_of_evaluation.sol index c05c2104f..2416f124e 100644 --- a/test/libsolidity/semanticTests/constructor/order_of_evaluation.sol +++ b/test/libsolidity/semanticTests/constructor/order_of_evaluation.sol @@ -18,7 +18,5 @@ contract X is D, C, B, A { function g() public view returns (uint[] memory) { return x; } constructor() A(f(1)) C(f(2)) B(f(3)) D(f(4)) {} } -// ==== -// compileViaYul: also // ---- // g() -> 0x20, 4, 1, 3, 2, 4 diff --git a/test/libsolidity/semanticTests/constructor/payable_constructor.sol b/test/libsolidity/semanticTests/constructor/payable_constructor.sol index 260b302a7..0f19eb7e2 100644 --- a/test/libsolidity/semanticTests/constructor/payable_constructor.sol +++ b/test/libsolidity/semanticTests/constructor/payable_constructor.sol @@ -4,6 +4,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // constructor(), 27 wei -> diff --git a/test/libsolidity/semanticTests/constructor/store_function_in_constructor.sol b/test/libsolidity/semanticTests/constructor/store_function_in_constructor.sol index ebe94bde9..7f0514041 100644 --- a/test/libsolidity/semanticTests/constructor/store_function_in_constructor.sol +++ b/test/libsolidity/semanticTests/constructor/store_function_in_constructor.sol @@ -18,7 +18,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // use(uint256): 3 -> 6 // result_in_constructor() -> 4 diff --git a/test/libsolidity/semanticTests/constructor/store_function_in_constructor_packed.sol b/test/libsolidity/semanticTests/constructor/store_function_in_constructor_packed.sol index 223a6ba07..7fef18a15 100644 --- a/test/libsolidity/semanticTests/constructor/store_function_in_constructor_packed.sol +++ b/test/libsolidity/semanticTests/constructor/store_function_in_constructor_packed.sol @@ -19,7 +19,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // use(uint16): 3 -> 0xfff9 // result_in_constructor() -> 0xfffb diff --git a/test/libsolidity/semanticTests/constructor/store_internal_unused_function_in_constructor.sol b/test/libsolidity/semanticTests/constructor/store_internal_unused_function_in_constructor.sol index 2004d045d..6721329a1 100644 --- a/test/libsolidity/semanticTests/constructor/store_internal_unused_function_in_constructor.sol +++ b/test/libsolidity/semanticTests/constructor/store_internal_unused_function_in_constructor.sol @@ -16,6 +16,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // t() -> 7 diff --git a/test/libsolidity/semanticTests/constructor/store_internal_unused_library_function_in_constructor.sol b/test/libsolidity/semanticTests/constructor/store_internal_unused_library_function_in_constructor.sol index 89795124a..7b166489f 100644 --- a/test/libsolidity/semanticTests/constructor/store_internal_unused_library_function_in_constructor.sol +++ b/test/libsolidity/semanticTests/constructor/store_internal_unused_library_function_in_constructor.sol @@ -17,7 +17,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // t() -> 7 diff --git a/test/libsolidity/semanticTests/constructor_inheritance_init_order_2.sol b/test/libsolidity/semanticTests/constructor_inheritance_init_order_2.sol index a583bd39f..1f10b6277 100644 --- a/test/libsolidity/semanticTests/constructor_inheritance_init_order_2.sol +++ b/test/libsolidity/semanticTests/constructor_inheritance_init_order_2.sol @@ -9,7 +9,6 @@ contract B is A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // constructor() -> // gas irOptimized: 121557 diff --git a/test/libsolidity/semanticTests/constructor_with_params.sol b/test/libsolidity/semanticTests/constructor_with_params.sol index ca4cf5a05..5304a9b1b 100644 --- a/test/libsolidity/semanticTests/constructor_with_params.sol +++ b/test/libsolidity/semanticTests/constructor_with_params.sol @@ -7,11 +7,9 @@ contract C { k = newK; } } -// ==== -// compileViaYul: also // ---- // constructor(): 2, 0 -> -// gas irOptimized: 103630 +// gas irOptimized: 103531 // gas legacy: 117158 // i() -> 2 // k() -> 0 diff --git a/test/libsolidity/semanticTests/constructor_with_params_diamond_inheritance.sol b/test/libsolidity/semanticTests/constructor_with_params_diamond_inheritance.sol index 3e9ae1ab2..8580d2150 100644 --- a/test/libsolidity/semanticTests/constructor_with_params_diamond_inheritance.sol +++ b/test/libsolidity/semanticTests/constructor_with_params_diamond_inheritance.sol @@ -19,13 +19,11 @@ contract C is A { contract D is B, C { constructor(uint newI, uint newK) B(newI) C(newI, newK + 1) {} } -// ==== -// compileViaYul: also // ---- // constructor(): 2, 0 -> -// gas irOptimized: 156071 -// gas legacy: 170665 -// gas legacyOptimized: 145396 +// gas irOptimized: 154331 +// gas legacy: 170115 +// gas legacyOptimized: 145429 // i() -> 2 // j() -> 2 // k() -> 1 diff --git a/test/libsolidity/semanticTests/constructor_with_params_inheritance.sol b/test/libsolidity/semanticTests/constructor_with_params_inheritance.sol index ede647d60..d34fb896c 100644 --- a/test/libsolidity/semanticTests/constructor_with_params_inheritance.sol +++ b/test/libsolidity/semanticTests/constructor_with_params_inheritance.sol @@ -10,12 +10,10 @@ contract C { contract D is C { constructor(uint newI, uint newK) C(newI, newK + 1) {} } -// ==== -// compileViaYul: also // ---- // constructor(): 2, 0 -> -// gas irOptimized: 124199 -// gas legacy: 139250 -// gas legacyOptimized: 119367 +// gas irOptimized: 123966 +// gas legacy: 138700 +// gas legacyOptimized: 119400 // i() -> 2 // k() -> 1 diff --git a/test/libsolidity/semanticTests/constructor_with_params_inheritance_2.sol b/test/libsolidity/semanticTests/constructor_with_params_inheritance_2.sol index e00969726..8a9fc03a7 100644 --- a/test/libsolidity/semanticTests/constructor_with_params_inheritance_2.sol +++ b/test/libsolidity/semanticTests/constructor_with_params_inheritance_2.sol @@ -8,8 +8,6 @@ contract C { } } contract D is C(2, 1) {} -// ==== -// compileViaYul: also // ---- // i() -> 2 // k() -> 1 diff --git a/test/libsolidity/semanticTests/conversions/function_type_array_to_storage.sol b/test/libsolidity/semanticTests/conversions/function_type_array_to_storage.sol index 4e0a8a561..94dc0307b 100644 --- a/test/libsolidity/semanticTests/conversions/function_type_array_to_storage.sol +++ b/test/libsolidity/semanticTests/conversions/function_type_array_to_storage.sol @@ -36,8 +36,6 @@ contract C { return (externalViewArray[0](), internalViewArray[0]()); } } -// ==== -// compileViaYul: also // ---- // testViewToDefault() -> 12, 22 // testPureToDefault() -> 13, 23 diff --git a/test/libsolidity/semanticTests/conversions/string_to_bytes.sol b/test/libsolidity/semanticTests/conversions/string_to_bytes.sol index ca258ca26..2f324588d 100644 --- a/test/libsolidity/semanticTests/conversions/string_to_bytes.sol +++ b/test/libsolidity/semanticTests/conversions/string_to_bytes.sol @@ -3,7 +3,5 @@ contract C { t = bytes(s); } } -// ==== -// compileViaYul: also // ---- // f(string): 32, 5, "Hello" -> 32, 5, "Hello" diff --git a/test/libsolidity/semanticTests/dirty_calldata_bytes.sol b/test/libsolidity/semanticTests/dirty_calldata_bytes.sol index cd801c2d4..48dc5ee2f 100644 --- a/test/libsolidity/semanticTests/dirty_calldata_bytes.sol +++ b/test/libsolidity/semanticTests/dirty_calldata_bytes.sol @@ -10,6 +10,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bytes): 0x20, 0x04, "dead" -> true diff --git a/test/libsolidity/semanticTests/dirty_calldata_dynamic_array.sol b/test/libsolidity/semanticTests/dirty_calldata_dynamic_array.sol index 6b4763ab1..b59eb922e 100644 --- a/test/libsolidity/semanticTests/dirty_calldata_dynamic_array.sol +++ b/test/libsolidity/semanticTests/dirty_calldata_dynamic_array.sol @@ -8,7 +8,5 @@ contract C { correct = r == 0x7fff; } } -// ==== -// compileViaYul: also // ---- // f(int16[]): 0x20, 0x02, 0x7fff, 0x7fff -> true diff --git a/test/libsolidity/semanticTests/ecrecover/ecrecover.sol b/test/libsolidity/semanticTests/ecrecover/ecrecover.sol index 1f462752b..1beb451de 100644 --- a/test/libsolidity/semanticTests/ecrecover/ecrecover.sol +++ b/test/libsolidity/semanticTests/ecrecover/ecrecover.sol @@ -3,8 +3,6 @@ contract test { return ecrecover(h, v, r, s); } } -// ==== -// compileViaYul: also // ---- // a(bytes32,uint8,bytes32,bytes32): // 0x18c547e4f7b0f325ad1e56f57e26c745b09a3e503d86e00e5255ff7f715d3d1c, diff --git a/test/libsolidity/semanticTests/ecrecover/ecrecover_abiV2.sol b/test/libsolidity/semanticTests/ecrecover/ecrecover_abiV2.sol index 265e58bda..995a1e456 100644 --- a/test/libsolidity/semanticTests/ecrecover/ecrecover_abiV2.sol +++ b/test/libsolidity/semanticTests/ecrecover/ecrecover_abiV2.sol @@ -4,8 +4,6 @@ contract test { return ecrecover(h, v, r, s); } } -// ==== -// compileViaYul: also // ---- // a(bytes32,uint8,bytes32,bytes32): // 0x18c547e4f7b0f325ad1e56f57e26c745b09a3e503d86e00e5255ff7f715d3d1c, diff --git a/test/libsolidity/semanticTests/ecrecover/failing_ecrecover_invalid_input.sol b/test/libsolidity/semanticTests/ecrecover/failing_ecrecover_invalid_input.sol index 3ee606d36..55621bdcd 100644 --- a/test/libsolidity/semanticTests/ecrecover/failing_ecrecover_invalid_input.sol +++ b/test/libsolidity/semanticTests/ecrecover/failing_ecrecover_invalid_input.sol @@ -6,7 +6,5 @@ contract C { return ecrecover(bytes32(type(uint256).max), 1, bytes32(uint(2)), bytes32(uint(3))); } } -// ==== -// compileViaYul: also // ---- // f() -> 0 diff --git a/test/libsolidity/semanticTests/ecrecover/failing_ecrecover_invalid_input_asm.sol b/test/libsolidity/semanticTests/ecrecover/failing_ecrecover_invalid_input_asm.sol index 607f3ec1a..5e8c3cdbf 100644 --- a/test/libsolidity/semanticTests/ecrecover/failing_ecrecover_invalid_input_asm.sol +++ b/test/libsolidity/semanticTests/ecrecover/failing_ecrecover_invalid_input_asm.sol @@ -11,7 +11,5 @@ contract C { ); } } -// ==== -// compileViaYul: also // ---- // f() -> 0 diff --git a/test/libsolidity/semanticTests/ecrecover/failing_ecrecover_invalid_input_proper.sol b/test/libsolidity/semanticTests/ecrecover/failing_ecrecover_invalid_input_proper.sol index 4fa1ec514..511bd4e41 100644 --- a/test/libsolidity/semanticTests/ecrecover/failing_ecrecover_invalid_input_proper.sol +++ b/test/libsolidity/semanticTests/ecrecover/failing_ecrecover_invalid_input_proper.sol @@ -16,7 +16,5 @@ contract C { return ecrecover(hash, v, r, s); } } -// ==== -// compileViaYul: also // ---- // f() -> 0 diff --git a/test/libsolidity/semanticTests/empty_contract.sol b/test/libsolidity/semanticTests/empty_contract.sol index 3691eae35..511b72469 100644 --- a/test/libsolidity/semanticTests/empty_contract.sol +++ b/test/libsolidity/semanticTests/empty_contract.sol @@ -3,6 +3,5 @@ contract test { // ==== // allowNonExistingFunctions: true // compileToEwasm: also -// compileViaYul: also // ---- // i_am_not_there() -> FAILURE diff --git a/test/libsolidity/semanticTests/empty_for_loop.sol b/test/libsolidity/semanticTests/empty_for_loop.sol index 4df1ae82e..d4ba09f13 100644 --- a/test/libsolidity/semanticTests/empty_for_loop.sol +++ b/test/libsolidity/semanticTests/empty_for_loop.sol @@ -9,6 +9,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 10 diff --git a/test/libsolidity/semanticTests/enums/constructing_enums_from_ints.sol b/test/libsolidity/semanticTests/enums/constructing_enums_from_ints.sol index a1608e33a..ddf1a66fa 100644 --- a/test/libsolidity/semanticTests/enums/constructing_enums_from_ints.sol +++ b/test/libsolidity/semanticTests/enums/constructing_enums_from_ints.sol @@ -8,6 +8,5 @@ contract c { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 1 diff --git a/test/libsolidity/semanticTests/enums/enum_explicit_overflow.sol b/test/libsolidity/semanticTests/enums/enum_explicit_overflow.sol index eee24bbc7..a538946ad 100644 --- a/test/libsolidity/semanticTests/enums/enum_explicit_overflow.sol +++ b/test/libsolidity/semanticTests/enums/enum_explicit_overflow.sol @@ -22,7 +22,6 @@ contract test { } // ==== -// compileViaYul: also // compileToEwasm: also // EVMVersion: >=byzantium // ---- diff --git a/test/libsolidity/semanticTests/enums/enum_explicit_overflow_homestead.sol b/test/libsolidity/semanticTests/enums/enum_explicit_overflow_homestead.sol index 90e5e1b3e..9b783b404 100644 --- a/test/libsolidity/semanticTests/enums/enum_explicit_overflow_homestead.sol +++ b/test/libsolidity/semanticTests/enums/enum_explicit_overflow_homestead.sol @@ -23,7 +23,6 @@ contract test { // ==== // EVMVersion: FAILURE # These should throw # // getChoiceFromSigned(int256): -1 -> FAILURE diff --git a/test/libsolidity/semanticTests/enums/enum_referencing.sol b/test/libsolidity/semanticTests/enums/enum_referencing.sol index 537c05182..a475f3748 100644 --- a/test/libsolidity/semanticTests/enums/enum_referencing.sol +++ b/test/libsolidity/semanticTests/enums/enum_referencing.sol @@ -28,7 +28,6 @@ contract C is I { } } // ==== -// compileViaYul: also // compileToEwasm: false // ---- // library: L diff --git a/test/libsolidity/semanticTests/enums/enum_with_256_members.sol b/test/libsolidity/semanticTests/enums/enum_with_256_members.sol index ea94bc0c1..8bfded3c2 100644 --- a/test/libsolidity/semanticTests/enums/enum_with_256_members.sol +++ b/test/libsolidity/semanticTests/enums/enum_with_256_members.sol @@ -46,8 +46,6 @@ contract C { return e; } } -// ==== -// compileViaYul: also // ---- // getMinMax() -> 0, 255 // intToEnum(uint8): 0 -> 0 diff --git a/test/libsolidity/semanticTests/enums/invalid_enum_logged.sol b/test/libsolidity/semanticTests/enums/invalid_enum_logged.sol index 33cec7482..243a7920c 100644 --- a/test/libsolidity/semanticTests/enums/invalid_enum_logged.sol +++ b/test/libsolidity/semanticTests/enums/invalid_enum_logged.sol @@ -16,8 +16,6 @@ contract C { return 1; } } -// ==== -// compileViaYul: also // ---- // test_log_ok() -> 1 // ~ emit Log(uint8): 0x00 diff --git a/test/libsolidity/semanticTests/enums/minmax.sol b/test/libsolidity/semanticTests/enums/minmax.sol index 3b298a6fa..4b929c36c 100644 --- a/test/libsolidity/semanticTests/enums/minmax.sol +++ b/test/libsolidity/semanticTests/enums/minmax.sol @@ -5,8 +5,6 @@ contract test { function max() public returns(uint) { return uint(type(MinMax).max); } } -// ==== -// compileViaYul: also // ---- // min() -> 0 // max() -> 3 diff --git a/test/libsolidity/semanticTests/enums/using_contract_enums_with_explicit_contract_name.sol b/test/libsolidity/semanticTests/enums/using_contract_enums_with_explicit_contract_name.sol index 7e1c5b8c3..cda5d06ac 100644 --- a/test/libsolidity/semanticTests/enums/using_contract_enums_with_explicit_contract_name.sol +++ b/test/libsolidity/semanticTests/enums/using_contract_enums_with_explicit_contract_name.sol @@ -8,6 +8,5 @@ contract test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // answer() -> 1 diff --git a/test/libsolidity/semanticTests/enums/using_enums.sol b/test/libsolidity/semanticTests/enums/using_enums.sol index 5f5e3056e..ec014160a 100644 --- a/test/libsolidity/semanticTests/enums/using_enums.sol +++ b/test/libsolidity/semanticTests/enums/using_enums.sol @@ -14,6 +14,5 @@ contract test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // getChoice() -> 2 diff --git a/test/libsolidity/semanticTests/enums/using_inherited_enum.sol b/test/libsolidity/semanticTests/enums/using_inherited_enum.sol index 615f90f01..8d65aeac8 100644 --- a/test/libsolidity/semanticTests/enums/using_inherited_enum.sol +++ b/test/libsolidity/semanticTests/enums/using_inherited_enum.sol @@ -10,6 +10,5 @@ contract test is base { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // answer() -> 1 diff --git a/test/libsolidity/semanticTests/enums/using_inherited_enum_excplicitly.sol b/test/libsolidity/semanticTests/enums/using_inherited_enum_excplicitly.sol index ce2415a1b..cac059774 100644 --- a/test/libsolidity/semanticTests/enums/using_inherited_enum_excplicitly.sol +++ b/test/libsolidity/semanticTests/enums/using_inherited_enum_excplicitly.sol @@ -10,6 +10,5 @@ contract test is base { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // answer() -> 1 diff --git a/test/libsolidity/semanticTests/error/selector.sol b/test/libsolidity/semanticTests/error/selector.sol deleted file mode 100644 index fab71f443..000000000 --- a/test/libsolidity/semanticTests/error/selector.sol +++ /dev/null @@ -1,20 +0,0 @@ -library L { - error E(); -} -library S { - error E(uint); -} -library T { - error E(); -} -contract C { - function f() public pure returns (bytes4, bytes4) { - assert(L.E.selector == T.E.selector); - assert(L.E.selector != S.E.selector); - return (L.E.selector, S.E.selector); - } -} -// ==== -// compileViaYul: also -// ---- -// f() -> 0x92bbf6e800000000000000000000000000000000000000000000000000000000, 0x2ff06700000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/errors/error_in_library_and_interface.sol b/test/libsolidity/semanticTests/errors/error_in_library_and_interface.sol index 81f6c1548..fad9d8bbf 100644 --- a/test/libsolidity/semanticTests/errors/error_in_library_and_interface.sol +++ b/test/libsolidity/semanticTests/errors/error_in_library_and_interface.sol @@ -16,8 +16,6 @@ contract C { revert I.E(1, 2, 3); } } -// ==== -// compileViaYul: also // ---- // f() -> FAILURE, hex"002ff067", hex"0000000000000000000000000000000000000000000000000000000000000001" // g() -> FAILURE, hex"85208890", hex"0000000000000000000000000000000000000000000000000000000000000001", hex"0000000000000000000000000000000000000000000000000000000000000002" diff --git a/test/libsolidity/semanticTests/errors/error_selector.sol b/test/libsolidity/semanticTests/errors/error_selector.sol new file mode 100644 index 000000000..e7e40fd6e --- /dev/null +++ b/test/libsolidity/semanticTests/errors/error_selector.sol @@ -0,0 +1,48 @@ +library L { + error E(); +} +library S { + error E(uint); +} +library T { + error E(); +} + +error E(); + +interface I { + error E(); + function f() external pure; +} + +contract D { + error F(); +} + +contract C is D { + function test1() public pure returns (bytes4, bytes4, bytes4, bytes4) { + assert(L.E.selector == T.E.selector); + assert(L.E.selector != S.E.selector); + assert(E.selector == L.E.selector); + assert(I.E.selector == L.E.selector); + return (L.E.selector, S.E.selector, E.selector, I.E.selector); + } + + bytes4 s1 = L.E.selector; + bytes4 s2 = S.E.selector; + bytes4 s3 = T.E.selector; + bytes4 s4 = I.E.selector; + function test2() external returns (bytes4, bytes4, bytes4, bytes4) { + return (s1, s2, s3, s4); + } + + function test3() external returns (bytes4) { + return (F.selector); + } +} +// ==== +// compileViaYul: also +// ---- +// test1() -> 0x92bbf6e800000000000000000000000000000000000000000000000000000000, 0x2ff06700000000000000000000000000000000000000000000000000000000, 0x92bbf6e800000000000000000000000000000000000000000000000000000000, 0x92bbf6e800000000000000000000000000000000000000000000000000000000 +// test2() -> 0x92bbf6e800000000000000000000000000000000000000000000000000000000, 0x2ff06700000000000000000000000000000000000000000000000000000000, 0x92bbf6e800000000000000000000000000000000000000000000000000000000, 0x92bbf6e800000000000000000000000000000000000000000000000000000000 +// test3() -> 0x28811f5900000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/errors/error_static_calldata_uint_array_and_dynamic_array.sol b/test/libsolidity/semanticTests/errors/error_static_calldata_uint_array_and_dynamic_array.sol new file mode 100644 index 000000000..bfda3b126 --- /dev/null +++ b/test/libsolidity/semanticTests/errors/error_static_calldata_uint_array_and_dynamic_array.sol @@ -0,0 +1,10 @@ +contract C { + error E(uint[], uint[1]); + + // This case used to be affected by the buggy cleanup due to ABIEncoderV2HeadOverflowWithStaticArrayCleanup bug. + function f(uint[] memory a, uint[1] calldata b) public { + revert E(a, b); + } +} +// ---- +// f(uint256[],uint256[1]): 0x40, 0xff, 1, 0xffff -> FAILURE, hex"f42f106d", 0x40, 0xff, 1, 0xffff diff --git a/test/libsolidity/semanticTests/errors/named_error_args.sol b/test/libsolidity/semanticTests/errors/named_error_args.sol index e311d403a..28df2c4cc 100644 --- a/test/libsolidity/semanticTests/errors/named_error_args.sol +++ b/test/libsolidity/semanticTests/errors/named_error_args.sol @@ -5,7 +5,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> FAILURE, hex"85208890", hex"0000000000000000000000000000000000000000000000000000000000000002", hex"0000000000000000000000000000000000000000000000000000000000000007" diff --git a/test/libsolidity/semanticTests/errors/named_parameters_shadowing_types.sol b/test/libsolidity/semanticTests/errors/named_parameters_shadowing_types.sol index 5af0205c6..a0d43c274 100644 --- a/test/libsolidity/semanticTests/errors/named_parameters_shadowing_types.sol +++ b/test/libsolidity/semanticTests/errors/named_parameters_shadowing_types.sol @@ -20,7 +20,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> FAILURE, hex"33a54193", hex"000000000000000000000000000000000000000000000000000000000000002a" // g() -> FAILURE, hex"374b9387", hex"0000000000000000000000000000000000000000000000000000000000000001", hex"000000000000000000000000000000000000000000000000000000000000002a" diff --git a/test/libsolidity/semanticTests/errors/panic_via_import.sol b/test/libsolidity/semanticTests/errors/panic_via_import.sol index a2f7e70ad..b763164c9 100644 --- a/test/libsolidity/semanticTests/errors/panic_via_import.sol +++ b/test/libsolidity/semanticTests/errors/panic_via_import.sol @@ -12,7 +12,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // a() -> FAILURE, hex"002ff067", hex"0000000000000000000000000000000000000000000000000000000000000001" diff --git a/test/libsolidity/semanticTests/errors/revert_conversion.sol b/test/libsolidity/semanticTests/errors/revert_conversion.sol index fd8fb7dc9..bef34704f 100644 --- a/test/libsolidity/semanticTests/errors/revert_conversion.sol +++ b/test/libsolidity/semanticTests/errors/revert_conversion.sol @@ -6,7 +6,5 @@ contract C { revert E("abc", x); } } -// ==== -// compileViaYul: also // ---- // f() -> FAILURE, hex"59e4d4df", 0x40, 0x80, 3, "abc", 1, 7 diff --git a/test/libsolidity/semanticTests/errors/simple.sol b/test/libsolidity/semanticTests/errors/simple.sol index 304e90e23..b8a8e0d60 100644 --- a/test/libsolidity/semanticTests/errors/simple.sol +++ b/test/libsolidity/semanticTests/errors/simple.sol @@ -5,7 +5,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> FAILURE, hex"85208890", 2, 7 diff --git a/test/libsolidity/semanticTests/errors/using_structs.sol b/test/libsolidity/semanticTests/errors/using_structs.sol index ac12f9d03..47979a955 100644 --- a/test/libsolidity/semanticTests/errors/using_structs.sol +++ b/test/libsolidity/semanticTests/errors/using_structs.sol @@ -14,7 +14,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(bool): true -> FAILURE, hex"e96e07f0", hex"0000000000000000000000000000000000000000000000000000000000000002", hex"0000000000000000000000000000000000000000000000000000000000000060", hex"0000000000000000000000000000000000000000000000000000000000000007", hex"0000000000000000000000000000000000000000000000000000000000000009", hex"0000000000000000000000000000000000000000000000000000000000000040", hex"0000000000000000000000000000000000000000000000000000000000000003", hex"6162630000000000000000000000000000000000000000000000000000000000" diff --git a/test/libsolidity/semanticTests/errors/via_contract_type.sol b/test/libsolidity/semanticTests/errors/via_contract_type.sol index 856b824c9..f0ea6ca3c 100644 --- a/test/libsolidity/semanticTests/errors/via_contract_type.sol +++ b/test/libsolidity/semanticTests/errors/via_contract_type.sol @@ -11,7 +11,6 @@ contract B is A { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> FAILURE, hex"002ff067", hex"0000000000000000000000000000000000000000000000000000000000000001" diff --git a/test/libsolidity/semanticTests/errors/via_import.sol b/test/libsolidity/semanticTests/errors/via_import.sol index 1039dcd02..6a6d3399e 100644 --- a/test/libsolidity/semanticTests/errors/via_import.sol +++ b/test/libsolidity/semanticTests/errors/via_import.sol @@ -18,7 +18,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // x() -> FAILURE, hex"002ff067", hex"0000000000000000000000000000000000000000000000000000000000000001" diff --git a/test/libsolidity/semanticTests/errors/weird_name.sol b/test/libsolidity/semanticTests/errors/weird_name.sol index 5998dc851..d3d754549 100644 --- a/test/libsolidity/semanticTests/errors/weird_name.sol +++ b/test/libsolidity/semanticTests/errors/weird_name.sol @@ -5,7 +5,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> FAILURE, hex"b48fb6cf", hex"0000000000000000000000000000000000000000000000000000000000000002" diff --git a/test/libsolidity/semanticTests/events/event.sol b/test/libsolidity/semanticTests/events/event.sol index 0143b8835..0f70dc655 100644 --- a/test/libsolidity/semanticTests/events/event.sol +++ b/test/libsolidity/semanticTests/events/event.sol @@ -14,8 +14,6 @@ contract ClientReceipt { } } } -// ==== -// compileViaYul: also // ---- // deposit(bytes32,bool), 18 wei: 0x1234, true -> // ~ emit Deposit(address,bytes32,uint256): #0x1212121212121212121212121212120000000012, #0x1234, 0x12 diff --git a/test/libsolidity/semanticTests/events/event_access_through_base_name_emit.sol b/test/libsolidity/semanticTests/events/event_access_through_base_name_emit.sol index 2e55940de..dede5eacb 100644 --- a/test/libsolidity/semanticTests/events/event_access_through_base_name_emit.sol +++ b/test/libsolidity/semanticTests/events/event_access_through_base_name_emit.sol @@ -7,8 +7,6 @@ contract B is A { return 1; } } -// ==== -// compileViaYul: also // ---- // f() -> 1 // ~ emit x() diff --git a/test/libsolidity/semanticTests/events/event_anonymous.sol b/test/libsolidity/semanticTests/events/event_anonymous.sol index e890fc1cb..1aaffa39b 100644 --- a/test/libsolidity/semanticTests/events/event_anonymous.sol +++ b/test/libsolidity/semanticTests/events/event_anonymous.sol @@ -4,8 +4,6 @@ contract ClientReceipt { emit Deposit(); } } -// ==== -// compileViaYul: also // ---- // deposit() -> // ~ emit diff --git a/test/libsolidity/semanticTests/events/event_anonymous_with_signature_collision.sol b/test/libsolidity/semanticTests/events/event_anonymous_with_signature_collision.sol index 96b06cc12..c4ac4e83b 100644 --- a/test/libsolidity/semanticTests/events/event_anonymous_with_signature_collision.sol +++ b/test/libsolidity/semanticTests/events/event_anonymous_with_signature_collision.sol @@ -4,8 +4,6 @@ contract ClientReceipt { emit Deposit(0x2012159ca6b6372f102c535a4814d13a00bfc5568ddfd72151364061b00355d1, _id, msg.value); // 0x2012159c -> 'Deposit(uint256,bytes32,uint256)' } } -// ==== -// compileViaYul: also // ---- // deposit(bytes32), 18 wei: 0x1234 -> // ~ emit : #0x2012159ca6b6372f102c535a4814d13a00bfc5568ddfd72151364061b00355d1, #0x1234, 0x12 diff --git a/test/libsolidity/semanticTests/events/event_anonymous_with_signature_collision2.sol b/test/libsolidity/semanticTests/events/event_anonymous_with_signature_collision2.sol index 1ddaa8d7b..3d2b3bb74 100644 --- a/test/libsolidity/semanticTests/events/event_anonymous_with_signature_collision2.sol +++ b/test/libsolidity/semanticTests/events/event_anonymous_with_signature_collision2.sol @@ -5,8 +5,6 @@ contract ClientReceipt { emit Deposit(0x5ddaa77ac5bda319ba947e31bee594711f39ed1b20d079d438dbad5ed729fb30, _id, msg.value); // 0x5ddaa77a -> 'Withdraw(uint256,string)' } } -// ==== -// compileViaYul: also // ---- // deposit(bytes32), 18 wei: 0x1234 -> // ~ emit Withdraw(uint256,string): #0x1234, 0x12 diff --git a/test/libsolidity/semanticTests/events/event_anonymous_with_topics.sol b/test/libsolidity/semanticTests/events/event_anonymous_with_topics.sol index 0bbe9f09b..a46d9799b 100644 --- a/test/libsolidity/semanticTests/events/event_anonymous_with_topics.sol +++ b/test/libsolidity/semanticTests/events/event_anonymous_with_topics.sol @@ -4,8 +4,6 @@ contract ClientReceipt { emit Deposit(msg.sender, _id, msg.value, 2, "abc"); } } -// ==== -// compileViaYul: also // ---- // deposit(bytes32), 18 wei: 0x1234 -> // ~ emit : #0x1212121212121212121212121212120000000012, #0x1234, #0x12, #0x02, "abc" diff --git a/test/libsolidity/semanticTests/events/event_constructor.sol b/test/libsolidity/semanticTests/events/event_constructor.sol index f5fa4e119..bbb66cbac 100644 --- a/test/libsolidity/semanticTests/events/event_constructor.sol +++ b/test/libsolidity/semanticTests/events/event_constructor.sol @@ -4,8 +4,6 @@ contract ClientReceipt { emit Deposit(msg.sender, bytes32("abc"), 7); } } -// ==== -// compileViaYul: also // ---- // constructor() // ~ emit Deposit(address,bytes32,uint256): #0x1212121212121212121212121212120000000012, #"abc", 0x07 diff --git a/test/libsolidity/semanticTests/events/event_dynamic_array_memory.sol b/test/libsolidity/semanticTests/events/event_dynamic_array_memory.sol index 943d3b1ac..4dd63819f 100644 --- a/test/libsolidity/semanticTests/events/event_dynamic_array_memory.sol +++ b/test/libsolidity/semanticTests/events/event_dynamic_array_memory.sol @@ -8,8 +8,6 @@ contract C { emit E(arr); } } -// ==== -// compileViaYul: also // ---- // createEvent(uint256): 42 -> // ~ emit E(uint256[]): 0x20, 0x03, 0x2a, 0x2b, 0x2c diff --git a/test/libsolidity/semanticTests/events/event_dynamic_array_memory_v2.sol b/test/libsolidity/semanticTests/events/event_dynamic_array_memory_v2.sol index c7b564d38..8bde9a2a8 100644 --- a/test/libsolidity/semanticTests/events/event_dynamic_array_memory_v2.sol +++ b/test/libsolidity/semanticTests/events/event_dynamic_array_memory_v2.sol @@ -9,8 +9,6 @@ contract C { emit E(arr); } } -// ==== -// compileViaYul: also // ---- // createEvent(uint256): 42 -> // ~ emit E(uint256[]): 0x20, 0x03, 0x2a, 0x2b, 0x2c diff --git a/test/libsolidity/semanticTests/events/event_dynamic_array_storage.sol b/test/libsolidity/semanticTests/events/event_dynamic_array_storage.sol index dedffe232..f9f06134f 100644 --- a/test/libsolidity/semanticTests/events/event_dynamic_array_storage.sol +++ b/test/libsolidity/semanticTests/events/event_dynamic_array_storage.sol @@ -10,11 +10,9 @@ contract C { emit E(arr); } } -// ==== -// compileViaYul: also // ---- // createEvent(uint256): 42 -> // ~ emit E(uint256[]): 0x20, 0x03, 0x2a, 0x2b, 0x2c -// gas irOptimized: 114741 -// gas legacy: 116393 -// gas legacyOptimized: 114415 +// gas irOptimized: 113511 +// gas legacy: 116381 +// gas legacyOptimized: 114425 diff --git a/test/libsolidity/semanticTests/events/event_dynamic_array_storage_v2.sol b/test/libsolidity/semanticTests/events/event_dynamic_array_storage_v2.sol index 947e5ad9e..a2862d689 100644 --- a/test/libsolidity/semanticTests/events/event_dynamic_array_storage_v2.sol +++ b/test/libsolidity/semanticTests/events/event_dynamic_array_storage_v2.sol @@ -11,11 +11,9 @@ contract C { emit E(arr); } } -// ==== -// compileViaYul: also // ---- // createEvent(uint256): 42 -> // ~ emit E(uint256[]): 0x20, 0x03, 0x2a, 0x2b, 0x2c -// gas irOptimized: 114741 -// gas legacy: 116393 -// gas legacyOptimized: 114415 +// gas irOptimized: 113511 +// gas legacy: 116381 +// gas legacyOptimized: 114425 diff --git a/test/libsolidity/semanticTests/events/event_dynamic_nested_array_memory_v2.sol b/test/libsolidity/semanticTests/events/event_dynamic_nested_array_memory_v2.sol index 13698e200..00fda110f 100644 --- a/test/libsolidity/semanticTests/events/event_dynamic_nested_array_memory_v2.sol +++ b/test/libsolidity/semanticTests/events/event_dynamic_nested_array_memory_v2.sol @@ -12,8 +12,6 @@ contract C { emit E(arr); } } -// ==== -// compileViaYul: also // ---- // createEvent(uint256): 42 -> // ~ emit E(uint256[][]): 0x20, 0x02, 0x40, 0xa0, 0x02, 0x2a, 0x2b, 0x02, 0x2c, 0x2d diff --git a/test/libsolidity/semanticTests/events/event_dynamic_nested_array_storage_v2.sol b/test/libsolidity/semanticTests/events/event_dynamic_nested_array_storage_v2.sol index 552444dd8..a625e3de3 100644 --- a/test/libsolidity/semanticTests/events/event_dynamic_nested_array_storage_v2.sol +++ b/test/libsolidity/semanticTests/events/event_dynamic_nested_array_storage_v2.sol @@ -12,11 +12,9 @@ contract C { emit E(arr); } } -// ==== -// compileViaYul: also // ---- // createEvent(uint256): 42 -> // ~ emit E(uint256[][]): 0x20, 0x02, 0x40, 0xa0, 0x02, 0x2a, 0x2b, 0x02, 0x2c, 0x2d -// gas irOptimized: 185444 -// gas legacy: 187621 -// gas legacyOptimized: 184551 +// gas irOptimized: 185142 +// gas legacy: 187603 +// gas legacyOptimized: 184566 diff --git a/test/libsolidity/semanticTests/events/event_emit.sol b/test/libsolidity/semanticTests/events/event_emit.sol index 70cd70589..07224d97b 100644 --- a/test/libsolidity/semanticTests/events/event_emit.sol +++ b/test/libsolidity/semanticTests/events/event_emit.sol @@ -4,8 +4,6 @@ contract ClientReceipt { emit Deposit(msg.sender, _id, msg.value); } } -// ==== -// compileViaYul: also // ---- // deposit(bytes32), 18 wei: 0x1234 -> // ~ emit Deposit(address,bytes32,uint256): #0x1212121212121212121212121212120000000012, #0x1234, 0x12 diff --git a/test/libsolidity/semanticTests/events/event_emit_from_other_contract.sol b/test/libsolidity/semanticTests/events/event_emit_from_other_contract.sol index 0f685b783..300efd739 100644 --- a/test/libsolidity/semanticTests/events/event_emit_from_other_contract.sol +++ b/test/libsolidity/semanticTests/events/event_emit_from_other_contract.sol @@ -13,11 +13,9 @@ contract C { d.deposit(_id); } } -// ==== -// compileViaYul: also // ---- // constructor() -> -// gas irOptimized: 173094 +// gas irOptimized: 166854 // gas legacy: 250376 // gas legacyOptimized: 174522 // deposit(bytes32), 18 wei: 0x1234 -> diff --git a/test/libsolidity/semanticTests/events/event_indexed_function.sol b/test/libsolidity/semanticTests/events/event_indexed_function.sol index 400d6d93f..d075270a8 100644 --- a/test/libsolidity/semanticTests/events/event_indexed_function.sol +++ b/test/libsolidity/semanticTests/events/event_indexed_function.sol @@ -4,8 +4,6 @@ contract C { emit Test(this.f); } } -// ==== -// compileViaYul: also // ---- // f() -> // ~ emit Test(function): #0x0fdd67305928fcac8d213d1e47bfa6165cd0b87b26121ff00000000000000000 diff --git a/test/libsolidity/semanticTests/events/event_indexed_function2.sol b/test/libsolidity/semanticTests/events/event_indexed_function2.sol index 508744ca1..9c5ef3263 100644 --- a/test/libsolidity/semanticTests/events/event_indexed_function2.sol +++ b/test/libsolidity/semanticTests/events/event_indexed_function2.sol @@ -8,8 +8,6 @@ contract C { emit TestB(this.f2); } } -// ==== -// compileViaYul: also // ---- // f1() -> // ~ emit TestA(function): #0x0fdd67305928fcac8d213d1e47bfa6165cd0b87bc27fc3050000000000000000 diff --git a/test/libsolidity/semanticTests/events/event_indexed_mixed.sol b/test/libsolidity/semanticTests/events/event_indexed_mixed.sol index 47aca1e2a..ad753ef16 100644 --- a/test/libsolidity/semanticTests/events/event_indexed_mixed.sol +++ b/test/libsolidity/semanticTests/events/event_indexed_mixed.sol @@ -8,8 +8,6 @@ contract C { emit E(1, 2, 3, "def"); } } -// ==== -// compileViaYul: also // ---- // deposit() -> // ~ emit E(uint256,uint256,uint256,bytes): #0x02, 0x01, 0x03, 0x60, 0x03, "def" diff --git a/test/libsolidity/semanticTests/events/event_indexed_string.sol b/test/libsolidity/semanticTests/events/event_indexed_string.sol index 5d3ad5840..08dd7ce66 100644 --- a/test/libsolidity/semanticTests/events/event_indexed_string.sol +++ b/test/libsolidity/semanticTests/events/event_indexed_string.sol @@ -14,11 +14,9 @@ contract C { emit E(x, y); } } -// ==== -// compileViaYul: also // ---- // deposit() -> // ~ emit E(string,uint256[4]): #0xa7fb06bb999a5eb9aff9e0779953f4e1e4ce58044936c2f51c7fb879b85c08bd, #0xe755d8cc1a8cde16a2a31160dcd8017ac32d7e2f13215b29a23cdae40a78aa81 -// gas irOptimized: 343396 +// gas irOptimized: 333476 // gas legacy: 388679 // gas legacyOptimized: 374441 diff --git a/test/libsolidity/semanticTests/events/event_lots_of_data.sol b/test/libsolidity/semanticTests/events/event_lots_of_data.sol index c38537f5a..b7926a840 100644 --- a/test/libsolidity/semanticTests/events/event_lots_of_data.sol +++ b/test/libsolidity/semanticTests/events/event_lots_of_data.sol @@ -4,8 +4,6 @@ contract ClientReceipt { emit Deposit(msg.sender, _id, msg.value, true); } } -// ==== -// compileViaYul: also // ---- // deposit(bytes32), 18 wei: 0x1234 -> // ~ emit Deposit(address,bytes32,uint256,bool): 0x1212121212121212121212121212120000000012, 0x1234, 0x12, true diff --git a/test/libsolidity/semanticTests/events/event_no_arguments.sol b/test/libsolidity/semanticTests/events/event_no_arguments.sol index ba4048107..235afeb6c 100644 --- a/test/libsolidity/semanticTests/events/event_no_arguments.sol +++ b/test/libsolidity/semanticTests/events/event_no_arguments.sol @@ -4,8 +4,6 @@ contract ClientReceipt { emit Deposit(); } } -// ==== -// compileViaYul: also // ---- // deposit() -> // ~ emit Deposit() diff --git a/test/libsolidity/semanticTests/events/event_really_lots_of_data.sol b/test/libsolidity/semanticTests/events/event_really_lots_of_data.sol index 7322e56d3..9e9c08063 100644 --- a/test/libsolidity/semanticTests/events/event_really_lots_of_data.sol +++ b/test/libsolidity/semanticTests/events/event_really_lots_of_data.sol @@ -4,8 +4,6 @@ contract ClientReceipt { emit Deposit(10, msg.data, 15); } } -// ==== -// compileViaYul: also // ---- // deposit() -> // ~ emit Deposit(uint256,bytes,uint256): 0x0a, 0x60, 0x0f, 0x04, 0xd0e30db000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/events/event_really_lots_of_data_from_storage.sol b/test/libsolidity/semanticTests/events/event_really_lots_of_data_from_storage.sol index da8e7799d..1c993113c 100644 --- a/test/libsolidity/semanticTests/events/event_really_lots_of_data_from_storage.sol +++ b/test/libsolidity/semanticTests/events/event_really_lots_of_data_from_storage.sol @@ -8,8 +8,6 @@ contract ClientReceipt { emit Deposit(10, x, 15); } } -// ==== -// compileViaYul: also // ---- // deposit() -> // ~ emit Deposit(uint256,bytes,uint256): 0x0a, 0x60, 0x0f, 0x03, "ABC" diff --git a/test/libsolidity/semanticTests/events/event_really_really_lots_of_data_from_storage.sol b/test/libsolidity/semanticTests/events/event_really_really_lots_of_data_from_storage.sol index f944163eb..01fcc4565 100644 --- a/test/libsolidity/semanticTests/events/event_really_really_lots_of_data_from_storage.sol +++ b/test/libsolidity/semanticTests/events/event_really_really_lots_of_data_from_storage.sol @@ -10,8 +10,6 @@ contract ClientReceipt { emit Deposit(10, x, 15); } } -// ==== -// compileViaYul: also // ---- // deposit() -> // ~ emit Deposit(uint256,bytes,uint256): 0x0a, 0x60, 0x0f, 0x1f, "ABC\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0Z" diff --git a/test/libsolidity/semanticTests/events/event_selector.sol b/test/libsolidity/semanticTests/events/event_selector.sol new file mode 100644 index 000000000..116e2329e --- /dev/null +++ b/test/libsolidity/semanticTests/events/event_selector.sol @@ -0,0 +1,41 @@ +library L { + event E(); +} +library S { + event E(uint); +} +library T { + event E(); +} + +contract D { + event F(); +} + +contract C is D { + function test1() external pure returns (bytes32, bytes32) { + assert(L.E.selector == T.E.selector); + + assert(L.E.selector != S.E.selector); + assert(T.E.selector != S.E.selector); + + return (L.E.selector, S.E.selector); + } + + bytes32 s1 = L.E.selector; + bytes32 s2 = S.E.selector; + bytes32 s3 = T.E.selector; + function test2() external returns (bytes32, bytes32, bytes32) { + return (s1, s2, s3); + } + + function test3() external returns (bytes32) { + return (F.selector); + } +} +// ==== +// compileViaYul: also +// ---- +// test1() -> 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028, 0x2ff0672f372fbe844b353429d4510ea5e43683af134c54f75f789ff57bc0c0 +// test2() -> 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028, 0x2ff0672f372fbe844b353429d4510ea5e43683af134c54f75f789ff57bc0c0, 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028 +// test3() -> 0x28811f5935c16a099486acb976b3a6b4942950a1425a74e9eb3e9b7f7135e12a diff --git a/test/libsolidity/semanticTests/events/event_signature_in_library.sol b/test/libsolidity/semanticTests/events/event_signature_in_library.sol index b301ebfd5..d8dc0f158 100644 --- a/test/libsolidity/semanticTests/events/event_signature_in_library.sol +++ b/test/libsolidity/semanticTests/events/event_signature_in_library.sol @@ -15,8 +15,6 @@ contract C { L.f(); } } -// ==== -// compileViaYul: also // ---- // constructor() // ~ emit E((uint8,int16),(uint8,int16)): #0xad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5, 0x00, 0x00 diff --git a/test/libsolidity/semanticTests/events/event_static_calldata_uint_array_and_dynamic_array.sol b/test/libsolidity/semanticTests/events/event_static_calldata_uint_array_and_dynamic_array.sol new file mode 100644 index 000000000..a72ad938c --- /dev/null +++ b/test/libsolidity/semanticTests/events/event_static_calldata_uint_array_and_dynamic_array.sol @@ -0,0 +1,11 @@ +contract C { + event E(uint[], uint[1]); + + // This case used to be affected by the buggy cleanup due to ABIEncoderV2HeadOverflowWithStaticArrayCleanup bug. + function f(uint[] memory a, uint[1] calldata b) public { + emit E(a, b); + } +} +// ---- +// f(uint256[],uint256[1]): 0x40, 0xff, 1, 0xffff -> +// ~ emit E(uint256[],uint256[1]): 0x40, 0xff, 0x01, 0xffff diff --git a/test/libsolidity/semanticTests/events/event_string.sol b/test/libsolidity/semanticTests/events/event_string.sol index e383ef934..b29988877 100644 --- a/test/libsolidity/semanticTests/events/event_string.sol +++ b/test/libsolidity/semanticTests/events/event_string.sol @@ -4,8 +4,6 @@ contract C { emit E("HELLO WORLD"); } } -// ==== -// compileViaYul: also // ---- // deposit() -> // ~ emit E(string): 0x20, 0x0b, "HELLO WORLD" diff --git a/test/libsolidity/semanticTests/events/event_struct_memory_v2.sol b/test/libsolidity/semanticTests/events/event_struct_memory_v2.sol index a08b4f574..a77c3150d 100644 --- a/test/libsolidity/semanticTests/events/event_struct_memory_v2.sol +++ b/test/libsolidity/semanticTests/events/event_struct_memory_v2.sol @@ -6,8 +6,6 @@ contract C { emit E(S(x)); } } -// ==== -// compileViaYul: also // ---- // createEvent(uint256): 42 -> // ~ emit E((uint256)): 0x2a diff --git a/test/libsolidity/semanticTests/events/event_struct_storage_v2.sol b/test/libsolidity/semanticTests/events/event_struct_storage_v2.sol index ae91efc3e..b64d8cff2 100644 --- a/test/libsolidity/semanticTests/events/event_struct_storage_v2.sol +++ b/test/libsolidity/semanticTests/events/event_struct_storage_v2.sol @@ -8,8 +8,6 @@ contract C { emit E(s); } } -// ==== -// compileViaYul: also // ---- // createEvent(uint256): 42 -> // ~ emit E((uint256)): 0x2a diff --git a/test/libsolidity/semanticTests/events/events_with_same_name.sol b/test/libsolidity/semanticTests/events/events_with_same_name.sol index 5eef0deb9..22a0895fb 100644 --- a/test/libsolidity/semanticTests/events/events_with_same_name.sol +++ b/test/libsolidity/semanticTests/events/events_with_same_name.sol @@ -20,8 +20,6 @@ contract ClientReceipt { return 4; } } -// ==== -// compileViaYul: also // ---- // deposit() -> 1 // ~ emit Deposit() diff --git a/test/libsolidity/semanticTests/events/events_with_same_name_inherited_emit.sol b/test/libsolidity/semanticTests/events/events_with_same_name_inherited_emit.sol index 472502504..de87fe416 100644 --- a/test/libsolidity/semanticTests/events/events_with_same_name_inherited_emit.sol +++ b/test/libsolidity/semanticTests/events/events_with_same_name_inherited_emit.sol @@ -21,8 +21,6 @@ contract ClientReceipt is A, B { return 1; } } -// ==== -// compileViaYul: also // ---- // deposit() -> 1 // ~ emit Deposit() diff --git a/test/libsolidity/semanticTests/events/simple.sol b/test/libsolidity/semanticTests/events/simple.sol new file mode 100644 index 000000000..018c91e70 --- /dev/null +++ b/test/libsolidity/semanticTests/events/simple.sol @@ -0,0 +1,17 @@ +contract C { + event E(); +} + +contract Test is C { + event E(uint256, uint256); + function f() public { + emit C.E(); + emit E(1,2); + } +} +// ==== +// compileViaYul: also +// ---- +// f() -> +// ~ emit E() +// ~ emit E(uint256,uint256): 0x01, 0x02 diff --git a/test/libsolidity/semanticTests/exponentiation/literal_base.sol b/test/libsolidity/semanticTests/exponentiation/literal_base.sol index e1c178ec3..f00999c97 100644 --- a/test/libsolidity/semanticTests/exponentiation/literal_base.sol +++ b/test/libsolidity/semanticTests/exponentiation/literal_base.sol @@ -8,7 +8,6 @@ contract test { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(uint256): 0 -> 1, 1 diff --git a/test/libsolidity/semanticTests/exponentiation/signed_base.sol b/test/libsolidity/semanticTests/exponentiation/signed_base.sol index f71208067..105a8ef5f 100644 --- a/test/libsolidity/semanticTests/exponentiation/signed_base.sol +++ b/test/libsolidity/semanticTests/exponentiation/signed_base.sol @@ -12,6 +12,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 9, -27 diff --git a/test/libsolidity/semanticTests/exponentiation/small_exp.sol b/test/libsolidity/semanticTests/exponentiation/small_exp.sol index f12453795..945b65c9d 100644 --- a/test/libsolidity/semanticTests/exponentiation/small_exp.sol +++ b/test/libsolidity/semanticTests/exponentiation/small_exp.sol @@ -11,7 +11,6 @@ contract test { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 4 diff --git a/test/libsolidity/semanticTests/expressions/bit_operators.sol b/test/libsolidity/semanticTests/expressions/bit_operators.sol index 2cac78c7e..733951e2c 100644 --- a/test/libsolidity/semanticTests/expressions/bit_operators.sol +++ b/test/libsolidity/semanticTests/expressions/bit_operators.sol @@ -15,6 +15,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 3855, 268374015, 268370160 diff --git a/test/libsolidity/semanticTests/expressions/bytes_comparison.sol b/test/libsolidity/semanticTests/expressions/bytes_comparison.sol index ee43abe1b..634486d91 100644 --- a/test/libsolidity/semanticTests/expressions/bytes_comparison.sol +++ b/test/libsolidity/semanticTests/expressions/bytes_comparison.sol @@ -8,6 +8,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/expressions/conditional_expression_different_types.sol b/test/libsolidity/semanticTests/expressions/conditional_expression_different_types.sol index 1dbb5ad83..66eb86d50 100644 --- a/test/libsolidity/semanticTests/expressions/conditional_expression_different_types.sol +++ b/test/libsolidity/semanticTests/expressions/conditional_expression_different_types.sol @@ -7,7 +7,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bool): true -> 0xcd // f(bool): false -> 0xabab diff --git a/test/libsolidity/semanticTests/expressions/conditional_expression_false_literal.sol b/test/libsolidity/semanticTests/expressions/conditional_expression_false_literal.sol index 7f201b8cd..f8c3abf2d 100644 --- a/test/libsolidity/semanticTests/expressions/conditional_expression_false_literal.sol +++ b/test/libsolidity/semanticTests/expressions/conditional_expression_false_literal.sol @@ -5,6 +5,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 10 diff --git a/test/libsolidity/semanticTests/expressions/conditional_expression_functions.sol b/test/libsolidity/semanticTests/expressions/conditional_expression_functions.sol index 221dcf805..5abc4e1e3 100644 --- a/test/libsolidity/semanticTests/expressions/conditional_expression_functions.sol +++ b/test/libsolidity/semanticTests/expressions/conditional_expression_functions.sol @@ -9,7 +9,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bool): true -> 1 // f(bool): false -> 2 diff --git a/test/libsolidity/semanticTests/expressions/conditional_expression_multiple.sol b/test/libsolidity/semanticTests/expressions/conditional_expression_multiple.sol index 536c1ea65..c51172b0d 100644 --- a/test/libsolidity/semanticTests/expressions/conditional_expression_multiple.sol +++ b/test/libsolidity/semanticTests/expressions/conditional_expression_multiple.sol @@ -8,7 +8,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 1001 -> 1000 // f(uint256): 500 -> 100 diff --git a/test/libsolidity/semanticTests/expressions/conditional_expression_storage_memory_1.sol b/test/libsolidity/semanticTests/expressions/conditional_expression_storage_memory_1.sol index be90b8db8..40cfc7a9d 100644 --- a/test/libsolidity/semanticTests/expressions/conditional_expression_storage_memory_1.sol +++ b/test/libsolidity/semanticTests/expressions/conditional_expression_storage_memory_1.sol @@ -24,7 +24,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bool): true -> 1 // f(bool): false -> 2 diff --git a/test/libsolidity/semanticTests/expressions/conditional_expression_storage_memory_2.sol b/test/libsolidity/semanticTests/expressions/conditional_expression_storage_memory_2.sol index f522ca6e5..8633d2bfa 100644 --- a/test/libsolidity/semanticTests/expressions/conditional_expression_storage_memory_2.sol +++ b/test/libsolidity/semanticTests/expressions/conditional_expression_storage_memory_2.sol @@ -23,8 +23,6 @@ contract test { return ret; } } -// ==== -// compileViaYul: also // ---- // f(bool): true -> 1 // f(bool): false -> 2 diff --git a/test/libsolidity/semanticTests/expressions/conditional_expression_true_literal.sol b/test/libsolidity/semanticTests/expressions/conditional_expression_true_literal.sol index 21c4fcca6..968a4a02a 100644 --- a/test/libsolidity/semanticTests/expressions/conditional_expression_true_literal.sol +++ b/test/libsolidity/semanticTests/expressions/conditional_expression_true_literal.sol @@ -5,6 +5,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 5 diff --git a/test/libsolidity/semanticTests/expressions/conditional_expression_tuples.sol b/test/libsolidity/semanticTests/expressions/conditional_expression_tuples.sol index 8f00a8afe..a28dd1f06 100644 --- a/test/libsolidity/semanticTests/expressions/conditional_expression_tuples.sol +++ b/test/libsolidity/semanticTests/expressions/conditional_expression_tuples.sol @@ -5,7 +5,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bool): true -> 1, 2 // f(bool): false -> 3, 4 diff --git a/test/libsolidity/semanticTests/expressions/conditional_expression_with_return_values.sol b/test/libsolidity/semanticTests/expressions/conditional_expression_with_return_values.sol index 89308d30b..fdf691ae4 100644 --- a/test/libsolidity/semanticTests/expressions/conditional_expression_with_return_values.sol +++ b/test/libsolidity/semanticTests/expressions/conditional_expression_with_return_values.sol @@ -5,7 +5,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bool,uint256): true, 20 -> 20, 0 // f(bool,uint256): false, 20 -> 0, 20 diff --git a/test/libsolidity/semanticTests/expressions/exp_operator_const.sol b/test/libsolidity/semanticTests/expressions/exp_operator_const.sol index 90ffdf7f1..ef71a3d2b 100644 --- a/test/libsolidity/semanticTests/expressions/exp_operator_const.sol +++ b/test/libsolidity/semanticTests/expressions/exp_operator_const.sol @@ -3,6 +3,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 8 diff --git a/test/libsolidity/semanticTests/expressions/exp_operator_const_signed.sol b/test/libsolidity/semanticTests/expressions/exp_operator_const_signed.sol index 93333eadc..4901f5c78 100644 --- a/test/libsolidity/semanticTests/expressions/exp_operator_const_signed.sol +++ b/test/libsolidity/semanticTests/expressions/exp_operator_const_signed.sol @@ -3,6 +3,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> -8 diff --git a/test/libsolidity/semanticTests/expressions/exp_zero_literal.sol b/test/libsolidity/semanticTests/expressions/exp_zero_literal.sol index 034ee7be1..716f72aee 100644 --- a/test/libsolidity/semanticTests/expressions/exp_zero_literal.sol +++ b/test/libsolidity/semanticTests/expressions/exp_zero_literal.sol @@ -3,6 +3,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1 diff --git a/test/libsolidity/semanticTests/expressions/inc_dec_operators.sol b/test/libsolidity/semanticTests/expressions/inc_dec_operators.sol index c30a9a7f5..b9eaa6480 100644 --- a/test/libsolidity/semanticTests/expressions/inc_dec_operators.sol +++ b/test/libsolidity/semanticTests/expressions/inc_dec_operators.sol @@ -13,6 +13,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x053866 diff --git a/test/libsolidity/semanticTests/expressions/unary_too_long_literal.sol b/test/libsolidity/semanticTests/expressions/unary_too_long_literal.sol index ea49d7d3f..29bf66169 100644 --- a/test/libsolidity/semanticTests/expressions/unary_too_long_literal.sol +++ b/test/libsolidity/semanticTests/expressions/unary_too_long_literal.sol @@ -5,7 +5,5 @@ contract C { ~~84926290883049832306107864558384249403874903260938453235235091622489261765859; } } -// ==== -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/expressions/uncalled_address_transfer_send.sol b/test/libsolidity/semanticTests/expressions/uncalled_address_transfer_send.sol index a2f628721..837f9f741 100644 --- a/test/libsolidity/semanticTests/expressions/uncalled_address_transfer_send.sol +++ b/test/libsolidity/semanticTests/expressions/uncalled_address_transfer_send.sol @@ -8,6 +8,5 @@ contract TransferTest { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> diff --git a/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol b/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol index 58087a3b5..d281d6f27 100644 --- a/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol +++ b/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol @@ -72,13 +72,11 @@ contract FixedFeeRegistrar is Registrar { } uint constant c_fee = 69 ether; } -// ==== -// compileViaYul: also // ---- // constructor() -// gas irOptimized: 402812 -// gas legacy: 935817 -// gas legacyOptimized: 489951 +// gas irOptimized: 415761 +// gas legacy: 933867 +// gas legacyOptimized: 487352 // reserve(string), 69 ether: 0x20, 3, "abc" -> // ~ emit Changed(string): #0x4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 // gas irOptimized: 45967 diff --git a/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathCommon.sol b/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathCommon.sol index 923b54c2d..9ec351b6c 100644 --- a/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathCommon.sol +++ b/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathCommon.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.0; /// @dev Common mathematical functions used in both PRBMathSD59x18 and PRBMathUD60x18. Note that this shared library /// does not always assume the signed 59.18-decimal fixed-point or the unsigned 60.18-decimal fixed-point -// representation. When it does not, it is annonated in the function's NatSpec documentation. +// representation. When it does not, it is annotated in the function's NatSpec documentation. library PRBMathCommon { /// @dev How many trailing decimals can be represented. uint256 internal constant SCALE = 1e18; diff --git a/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathUD60x18.sol b/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathUD60x18.sol index 2732d95b6..0313481f6 100644 --- a/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathUD60x18.sol +++ b/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathUD60x18.sol @@ -28,7 +28,7 @@ library PRBMathUD60x18 { /// @notice Calculates arithmetic average of x and y, rounding down. /// @param x The first operand as an unsigned 60.18-decimal fixed-point number. /// @param y The second operand as an unsigned 60.18-decimal fixed-point number. - /// @return result The arithmetic average as an usigned 60.18-decimal fixed-point number. + /// @return result The arithmetic average as an unsigned 60.18-decimal fixed-point number. function avg(uint256 x, uint256 y) internal pure returns (uint256 result) { // The operations can never overflow. unchecked { diff --git a/test/libsolidity/semanticTests/externalContracts/base64.sol b/test/libsolidity/semanticTests/externalContracts/base64.sol index 7101af594..5133da878 100644 --- a/test/libsolidity/semanticTests/externalContracts/base64.sol +++ b/test/libsolidity/semanticTests/externalContracts/base64.sol @@ -31,12 +31,11 @@ contract test { // // ==== // EVMVersion: >=constantinople -// compileViaYul: also // ---- // constructor() -// gas irOptimized: 443542 -// gas legacy: 765640 -// gas legacyOptimized: 541810 +// gas irOptimized: 438376 +// gas legacy: 750723 +// gas legacyOptimized: 536620 // encode_inline_asm(bytes): 0x20, 0 -> 0x20, 0 // encode_inline_asm(bytes): 0x20, 1, "f" -> 0x20, 4, "Zg==" // encode_inline_asm(bytes): 0x20, 2, "fo" -> 0x20, 4, "Zm8=" @@ -52,10 +51,10 @@ contract test { // encode_no_asm(bytes): 0x20, 5, "fooba" -> 0x20, 8, "Zm9vYmE=" // encode_no_asm(bytes): 0x20, 6, "foobar" -> 0x20, 8, "Zm9vYmFy" // encode_inline_asm_large() -// gas irOptimized: 1385042 -// gas legacy: 1652033 -// gas legacyOptimized: 1201033 +// gas irOptimized: 1387039 +// gas legacy: 1688033 +// gas legacyOptimized: 1205033 // encode_no_asm_large() -// gas irOptimized: 3335099 -// gas legacy: 4777077 -// gas legacyOptimized: 2890077 +// gas irOptimized: 3316107 +// gas legacy: 4765077 +// gas legacyOptimized: 2908077 diff --git a/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol b/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol index 9e3211ecb..7b5418ed1 100644 --- a/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol +++ b/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol @@ -174,39 +174,37 @@ contract DepositContract is IDepositContract, ERC165 { ret[7] = bytesValue[0]; } } -// ==== -// compileViaYul: also // ---- // constructor() -// gas irOptimized: 1529797 -// gas legacy: 2435803 -// gas legacyOptimized: 1775425 +// gas irOptimized: 1428137 +// gas legacy: 2425301 +// gas legacyOptimized: 1770477 // supportsInterface(bytes4): 0x0 -> 0 // supportsInterface(bytes4): 0xffffffff00000000000000000000000000000000000000000000000000000000 -> false # defined to be false by ERC-165 # // supportsInterface(bytes4): 0x01ffc9a700000000000000000000000000000000000000000000000000000000 -> true # ERC-165 id # // supportsInterface(bytes4): 0x8564090700000000000000000000000000000000000000000000000000000000 -> true # the deposit interface id # // get_deposit_root() -> 0xd70a234731285c6804c2a4f56711ddb8c82c99740f207854891028af34e27e5e -// gas irOptimized: 122134 -// gas legacy: 150273 -// gas legacyOptimized: 122510 +// gas irOptimized: 114626 +// gas legacy: 149888 +// gas legacyOptimized: 121887 // get_deposit_count() -> 0x20, 8, 0 # TODO: check balance and logs after each deposit # // deposit(bytes,bytes,bytes,bytes32), 32 ether: 0 -> FAILURE # Empty input # // get_deposit_root() -> 0xd70a234731285c6804c2a4f56711ddb8c82c99740f207854891028af34e27e5e -// gas irOptimized: 122134 -// gas legacy: 150273 -// gas legacyOptimized: 122510 +// gas irOptimized: 114626 +// gas legacy: 149888 +// gas legacyOptimized: 121887 // get_deposit_count() -> 0x20, 8, 0 // deposit(bytes,bytes,bytes,bytes32), 1 ether: 0x80, 0xe0, 0x120, 0xaa4a8d0b7d9077248630f1a4701ae9764e42271d7f22b7838778411857fd349e, 0x30, 0x933ad9491b62059dd065b560d256d8957a8c402cc6e8d8ee7290ae11e8f73292, 0x67a8811c397529dac52ae1342ba58c9500000000000000000000000000000000, 0x20, 0x00f50428677c60f997aadeab24aabf7fceaef491c96a52b463ae91f95611cf71, 0x60, 0xa29d01cc8c6296a8150e515b5995390ef841dc18948aa3e79be6d7c1851b4cbb, 0x5d6ff49fa70b9c782399506a22a85193151b9b691245cebafd2063012443c132, 0x4b6c36debaedefb7b2d71b0503ffdc00150aaffd42e63358238ec888901738b8 -> # txhash: 0x7085c586686d666e8bb6e9477a0f0b09565b2060a11f1c4209d3a52295033832 # // ~ emit DepositEvent(bytes,bytes,bytes,bytes,bytes): 0xa0, 0x0100, 0x0140, 0x0180, 0x0200, 0x30, 0x933ad9491b62059dd065b560d256d8957a8c402cc6e8d8ee7290ae11e8f73292, 0x67a8811c397529dac52ae1342ba58c9500000000000000000000000000000000, 0x20, 0xf50428677c60f997aadeab24aabf7fceaef491c96a52b463ae91f95611cf71, 0x08, 0xca9a3b00000000000000000000000000000000000000000000000000000000, 0x60, 0xa29d01cc8c6296a8150e515b5995390ef841dc18948aa3e79be6d7c1851b4cbb, 0x5d6ff49fa70b9c782399506a22a85193151b9b691245cebafd2063012443c132, 0x4b6c36debaedefb7b2d71b0503ffdc00150aaffd42e63358238ec888901738b8, 0x08, 0x00 // get_deposit_root() -> 0x2089653123d9c721215120b6db6738ba273bbc5228ac093b1f983badcdc8a438 -// gas irOptimized: 122113 -// gas legacy: 150283 -// gas legacyOptimized: 122523 +// gas irOptimized: 114611 +// gas legacy: 149898 +// gas legacyOptimized: 121900 // get_deposit_count() -> 0x20, 8, 0x0100000000000000000000000000000000000000000000000000000000000000 // deposit(bytes,bytes,bytes,bytes32), 32 ether: 0x80, 0xe0, 0x120, 0xdbd986dc85ceb382708cf90a3500f500f0a393c5ece76963ac3ed72eccd2c301, 0x30, 0xb2ce0f79f90e7b3a113ca5783c65756f96c4b4673c2b5c1eb4efc22280259441, 0x06d601211e8866dc5b50dc48a244dd7c00000000000000000000000000000000, 0x20, 0x00344b6c73f71b11c56aba0d01b7d8ad83559f209d0a4101a515f6ad54c89771, 0x60, 0x945caaf82d18e78c033927d51f452ebcd76524497b91d7a11219cb3db6a1d369, 0x7595fc095ce489e46b2ef129591f2f6d079be4faaf345a02c5eb133c072e7c56, 0x0c6c3617eee66b4b878165c502357d49485326bc6b31bc96873f308c8f19c09d -> # txhash: 0x404d8e109822ce448e68f45216c12cb051b784d068fbe98317ab8e50c58304ac # // ~ emit DepositEvent(bytes,bytes,bytes,bytes,bytes): 0xa0, 0x0100, 0x0140, 0x0180, 0x0200, 0x30, 0xb2ce0f79f90e7b3a113ca5783c65756f96c4b4673c2b5c1eb4efc22280259441, 0x06d601211e8866dc5b50dc48a244dd7c00000000000000000000000000000000, 0x20, 0x344b6c73f71b11c56aba0d01b7d8ad83559f209d0a4101a515f6ad54c89771, 0x08, 0x40597307000000000000000000000000000000000000000000000000000000, 0x60, 0x945caaf82d18e78c033927d51f452ebcd76524497b91d7a11219cb3db6a1d369, 0x7595fc095ce489e46b2ef129591f2f6d079be4faaf345a02c5eb133c072e7c56, 0x0c6c3617eee66b4b878165c502357d49485326bc6b31bc96873f308c8f19c09d, 0x08, 0x0100000000000000000000000000000000000000000000000000000000000000 // get_deposit_root() -> 0x40255975859377d912c53aa853245ebd939bdd2b33a28e084babdcc1ed8238ee -// gas irOptimized: 122113 -// gas legacy: 150283 -// gas legacyOptimized: 122523 +// gas irOptimized: 114611 +// gas legacy: 149898 +// gas legacyOptimized: 121900 // get_deposit_count() -> 0x20, 8, 0x0200000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol b/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol index e45d3360e..bf257815a 100644 --- a/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol +++ b/test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol @@ -46,13 +46,11 @@ contract test { assert(z1 == z2); } } -// ==== -// compileViaYul: also // ---- // constructor() -// gas irOptimized: 1926032 -// gas legacy: 2478955 -// gas legacyOptimized: 1877737 +// gas irOptimized: 1876171 +// gas legacy: 2471603 +// gas legacyOptimized: 1876669 // div(int256,int256): 3141592653589793238, 88714123 -> 35412542528203691288251815328 // gas irOptimized: 22137 // gas legacy: 22767 diff --git a/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol b/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol index c37fe52b5..5cea75abe 100644 --- a/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol +++ b/test/libsolidity/semanticTests/externalContracts/prbmath_unsigned.sol @@ -46,13 +46,11 @@ contract test { assert(z1 == z2); } } -// ==== -// compileViaYul: also // ---- // constructor() -// gas irOptimized: 1780841 -// gas legacy: 2248594 -// gas legacyOptimized: 1749096 +// gas irOptimized: 1735588 +// gas legacy: 2241243 +// gas legacyOptimized: 1748028 // div(uint256,uint256): 3141592653589793238, 88714123 -> 35412542528203691288251815328 // gas irOptimized: 22004 // gas legacy: 22497 diff --git a/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol b/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol index b1c4c0169..b4b7054a4 100644 --- a/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol +++ b/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol @@ -31,14 +31,12 @@ contract test { ret = prb_scale(1).div(ret); } } -// ==== -// compileViaYul: also // ---- // constructor() -// gas irOptimized: 455866 -// gas legacy: 671453 -// gas legacyOptimized: 480242 +// gas irOptimized: 430305 +// gas legacy: 649335 +// gas legacyOptimized: 473132 // prb_pi() -> 3141592656369545286 // gas irOptimized: 57478 -// gas legacy: 98903 +// gas legacy: 103112 // gas legacyOptimized: 75735 diff --git a/test/libsolidity/semanticTests/externalContracts/snark.sol b/test/libsolidity/semanticTests/externalContracts/snark.sol index 05b4ddb25..7d04b5af6 100644 --- a/test/libsolidity/semanticTests/externalContracts/snark.sol +++ b/test/libsolidity/semanticTests/externalContracts/snark.sol @@ -289,7 +289,6 @@ contract Test { // // ==== // EVMVersion: >=constantinople -// compileViaYul: also // ---- // library: Pairing // f() -> true @@ -298,5 +297,5 @@ contract Test { // verifyTx() -> true // ~ emit Verified(string): 0x20, 0x16, "Successfully verified." // gas irOptimized: 95261 -// gas legacy: 113731 +// gas legacy: 116473 // gas legacyOptimized: 83670 diff --git a/test/libsolidity/semanticTests/externalContracts/strings.sol b/test/libsolidity/semanticTests/externalContracts/strings.sol index ce582e7c9..654562ef0 100644 --- a/test/libsolidity/semanticTests/externalContracts/strings.sol +++ b/test/libsolidity/semanticTests/externalContracts/strings.sol @@ -47,13 +47,11 @@ contract test { return d.toSlice().len(); } } -// ==== -// compileViaYul: also // ---- // constructor() -// gas irOptimized: 691317 -// gas legacy: 1127730 -// gas legacyOptimized: 753807 +// gas irOptimized: 670586 +// gas legacy: 1096108 +// gas legacyOptimized: 741962 // toSlice(string): 0x20, 11, "hello world" -> 11, 0xa0 // gas irOptimized: 22660 // gas legacy: 23190 @@ -71,6 +69,6 @@ contract test { // gas legacy: 31621 // gas legacyOptimized: 27914 // benchmark(string,bytes32): 0x40, 0x0842021, 8, "solidity" -> 0x2020 -// gas irOptimized: 2040019 -// gas legacy: 4356286 -// gas legacyOptimized: 2268278 +// gas irOptimized: 2017770 +// gas legacy: 4294552 +// gas legacyOptimized: 2327981 diff --git a/test/libsolidity/semanticTests/externalSource/multiple_equals_signs.sol b/test/libsolidity/semanticTests/externalSource/multiple_equals_signs.sol index d6bd1e27c..149109f6d 100644 --- a/test/libsolidity/semanticTests/externalSource/multiple_equals_signs.sol +++ b/test/libsolidity/semanticTests/externalSource/multiple_equals_signs.sol @@ -2,7 +2,5 @@ import {External} from "a"; contract C { } -// ==== -// compileViaYul: also // ---- // constructor() diff --git a/test/libsolidity/semanticTests/externalSource/multiple_external_source.sol b/test/libsolidity/semanticTests/externalSource/multiple_external_source.sol index 4b4c3d9bb..f16a7b0a1 100644 --- a/test/libsolidity/semanticTests/externalSource/multiple_external_source.sol +++ b/test/libsolidity/semanticTests/externalSource/multiple_external_source.sol @@ -4,7 +4,5 @@ import {External} from "_external/external.sol"; import {OtherExternal} from "_external/other_external.sol"; contract C { } -// ==== -// compileViaYul: also // ---- // constructor() diff --git a/test/libsolidity/semanticTests/externalSource/multisource.sol b/test/libsolidity/semanticTests/externalSource/multisource.sol index 8291f66ae..685f0b9da 100644 --- a/test/libsolidity/semanticTests/externalSource/multisource.sol +++ b/test/libsolidity/semanticTests/externalSource/multisource.sol @@ -7,8 +7,6 @@ contract S1 { import {S1} from "s1.sol"; contract C { } -// ==== -// compileViaYul: also // ---- // constructor() diff --git a/test/libsolidity/semanticTests/externalSource/non_normalized_paths.sol b/test/libsolidity/semanticTests/externalSource/non_normalized_paths.sol index 4d1854e96..7316cc7d5 100644 --- a/test/libsolidity/semanticTests/externalSource/non_normalized_paths.sol +++ b/test/libsolidity/semanticTests/externalSource/non_normalized_paths.sol @@ -6,7 +6,5 @@ import {C} from "C/////c.sol"; import {D} from "C/../////D/d.sol"; contract Contract { } -// ==== -// compileViaYul: also // ---- // constructor() diff --git a/test/libsolidity/semanticTests/externalSource/relative_imports.sol b/test/libsolidity/semanticTests/externalSource/relative_imports.sol index 744684f4f..9a37896bb 100644 --- a/test/libsolidity/semanticTests/externalSource/relative_imports.sol +++ b/test/libsolidity/semanticTests/externalSource/relative_imports.sol @@ -8,7 +8,5 @@ import {A, B, C, D, G, H, Contract} from "_relative_imports/dir/contract.sol"; contract CC { } -// ==== -// compileViaYul: also // ---- // constructor() diff --git a/test/libsolidity/semanticTests/externalSource/source.sol b/test/libsolidity/semanticTests/externalSource/source.sol index 5fc5a3b89..12a50ff82 100644 --- a/test/libsolidity/semanticTests/externalSource/source.sol +++ b/test/libsolidity/semanticTests/externalSource/source.sol @@ -2,7 +2,5 @@ import {External} from "_external/external.sol"; contract C { } -// ==== -// compileViaYul: also // ---- // constructor() diff --git a/test/libsolidity/semanticTests/externalSource/source_import.sol b/test/libsolidity/semanticTests/externalSource/source_import.sol index 4b4c3d9bb..f16a7b0a1 100644 --- a/test/libsolidity/semanticTests/externalSource/source_import.sol +++ b/test/libsolidity/semanticTests/externalSource/source_import.sol @@ -4,7 +4,5 @@ import {External} from "_external/external.sol"; import {OtherExternal} from "_external/other_external.sol"; contract C { } -// ==== -// compileViaYul: also // ---- // constructor() diff --git a/test/libsolidity/semanticTests/externalSource/source_import_subdir.sol b/test/libsolidity/semanticTests/externalSource/source_import_subdir.sol index f3fa73085..35f3b5ba1 100644 --- a/test/libsolidity/semanticTests/externalSource/source_import_subdir.sol +++ b/test/libsolidity/semanticTests/externalSource/source_import_subdir.sol @@ -4,7 +4,5 @@ import {SubExternal} from "sub_external.sol"; contract C { } -// ==== -// compileViaYul: also // ---- // constructor() diff --git a/test/libsolidity/semanticTests/externalSource/source_name_starting_with_dots.sol b/test/libsolidity/semanticTests/externalSource/source_name_starting_with_dots.sol index 829485e6d..b671c94f9 100644 --- a/test/libsolidity/semanticTests/externalSource/source_name_starting_with_dots.sol +++ b/test/libsolidity/semanticTests/externalSource/source_name_starting_with_dots.sol @@ -6,7 +6,5 @@ import {A, B} from "_source_name_starting_with_dots/dir/contract.sol"; contract Contract { } -// ==== -// compileViaYul: also // ---- // constructor() diff --git a/test/libsolidity/semanticTests/externalSource/source_remapping.sol b/test/libsolidity/semanticTests/externalSource/source_remapping.sol index 4edb2200f..079a222fd 100644 --- a/test/libsolidity/semanticTests/externalSource/source_remapping.sol +++ b/test/libsolidity/semanticTests/externalSource/source_remapping.sol @@ -6,7 +6,5 @@ contract C { External _external; OtherExternal _otherExternal; } -// ==== -// compileViaYul: also // ---- // constructor() diff --git a/test/libsolidity/semanticTests/fallback/call_forward_bytes.sol b/test/libsolidity/semanticTests/fallback/call_forward_bytes.sol index 39122e757..4a35fad1d 100644 --- a/test/libsolidity/semanticTests/fallback/call_forward_bytes.sol +++ b/test/libsolidity/semanticTests/fallback/call_forward_bytes.sol @@ -15,7 +15,6 @@ contract sender { // ==== // allowNonExistingFunctions: true // compileToEwasm: false -// compileViaYul: also // ---- // recv(uint256): 7 -> // val() -> 0 diff --git a/test/libsolidity/semanticTests/fallback/falback_return.sol b/test/libsolidity/semanticTests/fallback/falback_return.sol index 475a9f19b..55e65348b 100644 --- a/test/libsolidity/semanticTests/fallback/falback_return.sol +++ b/test/libsolidity/semanticTests/fallback/falback_return.sol @@ -7,7 +7,6 @@ contract A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // () // x() -> 1 diff --git a/test/libsolidity/semanticTests/fallback/fallback_argument.sol b/test/libsolidity/semanticTests/fallback/fallback_argument.sol index f20c14493..d35172076 100644 --- a/test/libsolidity/semanticTests/fallback/fallback_argument.sol +++ b/test/libsolidity/semanticTests/fallback/fallback_argument.sol @@ -11,7 +11,6 @@ contract A { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f() -> 0x01, 0x40, 0x00 // x() -> 3 diff --git a/test/libsolidity/semanticTests/fallback/fallback_argument_to_storage.sol b/test/libsolidity/semanticTests/fallback/fallback_argument_to_storage.sol index 5e0c3fbdf..1a995a8cd 100644 --- a/test/libsolidity/semanticTests/fallback/fallback_argument_to_storage.sol +++ b/test/libsolidity/semanticTests/fallback/fallback_argument_to_storage.sol @@ -11,7 +11,6 @@ contract A { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f() -> 0x01, 0x40, 0x00 // x() -> 0x20, 3, "abc" diff --git a/test/libsolidity/semanticTests/fallback/fallback_or_receive.sol b/test/libsolidity/semanticTests/fallback/fallback_or_receive.sol index 231f999bc..14366886c 100644 --- a/test/libsolidity/semanticTests/fallback/fallback_or_receive.sol +++ b/test/libsolidity/semanticTests/fallback/fallback_or_receive.sol @@ -7,7 +7,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0, 0 // () -> diff --git a/test/libsolidity/semanticTests/fallback/fallback_override.sol b/test/libsolidity/semanticTests/fallback/fallback_override.sol index c1099e151..5e5adb37c 100644 --- a/test/libsolidity/semanticTests/fallback/fallback_override.sol +++ b/test/libsolidity/semanticTests/fallback/fallback_override.sol @@ -14,6 +14,5 @@ contract B is A { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f() -> 0x01, 0x40, 0x03, 0x78797a0000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/fallback/fallback_override2.sol b/test/libsolidity/semanticTests/fallback/fallback_override2.sol index e92163476..67925fd5b 100644 --- a/test/libsolidity/semanticTests/fallback/fallback_override2.sol +++ b/test/libsolidity/semanticTests/fallback/fallback_override2.sol @@ -13,6 +13,5 @@ contract B is A { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f() -> 1, 0x40, 0x00 diff --git a/test/libsolidity/semanticTests/fallback/fallback_override_multi.sol b/test/libsolidity/semanticTests/fallback/fallback_override_multi.sol index 1e2b3a630..ce268e4f4 100644 --- a/test/libsolidity/semanticTests/fallback/fallback_override_multi.sol +++ b/test/libsolidity/semanticTests/fallback/fallback_override_multi.sol @@ -17,6 +17,5 @@ contract C is B, A { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f() -> 0x01, 0x40, 0x00 diff --git a/test/libsolidity/semanticTests/fallback/fallback_return_data.sol b/test/libsolidity/semanticTests/fallback/fallback_return_data.sol index 5cef4466c..d22c11e71 100644 --- a/test/libsolidity/semanticTests/fallback/fallback_return_data.sol +++ b/test/libsolidity/semanticTests/fallback/fallback_return_data.sol @@ -9,6 +9,5 @@ contract A { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f() -> 0x01, 0x40, 0x03, 0x6162630000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/fallback/inherited.sol b/test/libsolidity/semanticTests/fallback/inherited.sol index 7139bb9c1..75ab307bf 100644 --- a/test/libsolidity/semanticTests/fallback/inherited.sol +++ b/test/libsolidity/semanticTests/fallback/inherited.sol @@ -5,7 +5,6 @@ contract A { } contract B is A {} // ==== -// compileViaYul: also // compileToEwasm: also // ---- // getData() -> 0 diff --git a/test/libsolidity/semanticTests/fallback/short_data_calls_fallback.sol b/test/libsolidity/semanticTests/fallback/short_data_calls_fallback.sol index ad2dec373..cb62135ed 100644 --- a/test/libsolidity/semanticTests/fallback/short_data_calls_fallback.sol +++ b/test/libsolidity/semanticTests/fallback/short_data_calls_fallback.sol @@ -6,7 +6,6 @@ contract A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // (): hex"d88e0b" // x() -> 2 diff --git a/test/libsolidity/semanticTests/freeFunctions/easy.sol b/test/libsolidity/semanticTests/freeFunctions/easy.sol index 8dae85e2d..dae3b4037 100644 --- a/test/libsolidity/semanticTests/freeFunctions/easy.sol +++ b/test/libsolidity/semanticTests/freeFunctions/easy.sol @@ -9,6 +9,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 7 -> 9 diff --git a/test/libsolidity/semanticTests/freeFunctions/free_namesake_contract_function.sol b/test/libsolidity/semanticTests/freeFunctions/free_namesake_contract_function.sol index 9c88bb49f..465b80f7a 100644 --- a/test/libsolidity/semanticTests/freeFunctions/free_namesake_contract_function.sol +++ b/test/libsolidity/semanticTests/freeFunctions/free_namesake_contract_function.sol @@ -6,6 +6,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> FAILURE diff --git a/test/libsolidity/semanticTests/freeFunctions/free_runtimecode.sol b/test/libsolidity/semanticTests/freeFunctions/free_runtimecode.sol index 5c2e2f909..7a05ff5d0 100644 --- a/test/libsolidity/semanticTests/freeFunctions/free_runtimecode.sol +++ b/test/libsolidity/semanticTests/freeFunctions/free_runtimecode.sol @@ -11,7 +11,5 @@ contract D { return test(); } } -// ==== -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/freeFunctions/import.sol b/test/libsolidity/semanticTests/freeFunctions/import.sol index d7d46d7b6..f4ecd6bac 100644 --- a/test/libsolidity/semanticTests/freeFunctions/import.sol +++ b/test/libsolidity/semanticTests/freeFunctions/import.sol @@ -16,6 +16,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 7 -> 7, 8 diff --git a/test/libsolidity/semanticTests/freeFunctions/libraries_from_free.sol b/test/libsolidity/semanticTests/freeFunctions/libraries_from_free.sol index 861313e92..f7d2cf20e 100644 --- a/test/libsolidity/semanticTests/freeFunctions/libraries_from_free.sol +++ b/test/libsolidity/semanticTests/freeFunctions/libraries_from_free.sol @@ -16,8 +16,6 @@ contract C { return fu(); } } -// ==== -// compileViaYul: also // ---- // library: L // f() -> 7, 8 diff --git a/test/libsolidity/semanticTests/freeFunctions/new_operator.sol b/test/libsolidity/semanticTests/freeFunctions/new_operator.sol index 0e89c7560..6daaa5407 100644 --- a/test/libsolidity/semanticTests/freeFunctions/new_operator.sol +++ b/test/libsolidity/semanticTests/freeFunctions/new_operator.sol @@ -11,8 +11,6 @@ contract D { return test(); } } -// ==== -// compileViaYul: also // ---- // f() -> 2 // gas legacy: 101626 diff --git a/test/libsolidity/semanticTests/freeFunctions/overloads.sol b/test/libsolidity/semanticTests/freeFunctions/overloads.sol index ae579e30f..468f75be9 100644 --- a/test/libsolidity/semanticTests/freeFunctions/overloads.sol +++ b/test/libsolidity/semanticTests/freeFunctions/overloads.sol @@ -12,6 +12,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 2, 3 diff --git a/test/libsolidity/semanticTests/freeFunctions/recursion.sol b/test/libsolidity/semanticTests/freeFunctions/recursion.sol index ab68c2ffb..b6a131b63 100644 --- a/test/libsolidity/semanticTests/freeFunctions/recursion.sol +++ b/test/libsolidity/semanticTests/freeFunctions/recursion.sol @@ -14,7 +14,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g(uint256,uint256): 0, 0 -> 1 // g(uint256,uint256): 0, 1 -> 0x00 diff --git a/test/libsolidity/semanticTests/freeFunctions/storage_calldata_refs.sol b/test/libsolidity/semanticTests/freeFunctions/storage_calldata_refs.sol index 3b94b06fc..3633fa957 100644 --- a/test/libsolidity/semanticTests/freeFunctions/storage_calldata_refs.sol +++ b/test/libsolidity/semanticTests/freeFunctions/storage_calldata_refs.sol @@ -11,7 +11,5 @@ contract C { function fun(uint[] calldata _x, uint[] storage _y) view returns (uint, uint[] calldata) { return (_y[0], _x); } -// ==== -// compileViaYul: also // ---- // f(uint256,uint256[]): 7, 0x40, 3, 8, 9, 10 -> 7, 9 diff --git a/test/libsolidity/semanticTests/functionCall/array_multiple_local_vars.sol b/test/libsolidity/semanticTests/functionCall/array_multiple_local_vars.sol index bf3ac302d..0605888d0 100644 --- a/test/libsolidity/semanticTests/functionCall/array_multiple_local_vars.sol +++ b/test/libsolidity/semanticTests/functionCall/array_multiple_local_vars.sol @@ -24,7 +24,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256[]): 32, 3, 1000, 1, 2 -> 3 // f(uint256[]): 32, 3, 100, 500, 300 -> 600 diff --git a/test/libsolidity/semanticTests/functionCall/bare_call_no_returndatacopy.sol b/test/libsolidity/semanticTests/functionCall/bare_call_no_returndatacopy.sol index e45eeaa4e..17b6f74c8 100644 --- a/test/libsolidity/semanticTests/functionCall/bare_call_no_returndatacopy.sol +++ b/test/libsolidity/semanticTests/functionCall/bare_call_no_returndatacopy.sol @@ -4,7 +4,5 @@ contract C { return success; } } -// ==== -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/functionCall/bound_function_in_function.sol b/test/libsolidity/semanticTests/functionCall/bound_function_in_function.sol index 983de5e3c..97bc083af 100644 --- a/test/libsolidity/semanticTests/functionCall/bound_function_in_function.sol +++ b/test/libsolidity/semanticTests/functionCall/bound_function_in_function.sol @@ -10,7 +10,6 @@ contract C { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: L // f() -> 7 diff --git a/test/libsolidity/semanticTests/functionCall/bound_function_in_var.sol b/test/libsolidity/semanticTests/functionCall/bound_function_in_var.sol index ad8024127..d8d55dc9b 100644 --- a/test/libsolidity/semanticTests/functionCall/bound_function_in_var.sol +++ b/test/libsolidity/semanticTests/functionCall/bound_function_in_var.sol @@ -9,7 +9,6 @@ contract C { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: D // f(uint256): 7 -> 0x2a diff --git a/test/libsolidity/semanticTests/functionCall/bound_function_to_string.sol b/test/libsolidity/semanticTests/functionCall/bound_function_to_string.sol index 376768b86..d374573dc 100644 --- a/test/libsolidity/semanticTests/functionCall/bound_function_to_string.sol +++ b/test/libsolidity/semanticTests/functionCall/bound_function_to_string.sol @@ -13,7 +13,6 @@ contract C { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: D // f() -> 3 diff --git a/test/libsolidity/semanticTests/functionCall/call_function_returning_function.sol b/test/libsolidity/semanticTests/functionCall/call_function_returning_function.sol index 6040b7a99..82c38cca5 100644 --- a/test/libsolidity/semanticTests/functionCall/call_function_returning_function.sol +++ b/test/libsolidity/semanticTests/functionCall/call_function_returning_function.sol @@ -24,6 +24,5 @@ contract test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 2 diff --git a/test/libsolidity/semanticTests/functionCall/call_function_returning_nothing_via_pointer.sol b/test/libsolidity/semanticTests/functionCall/call_function_returning_nothing_via_pointer.sol index f05f0eb1c..ea5edaaef 100644 --- a/test/libsolidity/semanticTests/functionCall/call_function_returning_nothing_via_pointer.sol +++ b/test/libsolidity/semanticTests/functionCall/call_function_returning_nothing_via_pointer.sol @@ -14,7 +14,6 @@ contract test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> true // flag() -> true diff --git a/test/libsolidity/semanticTests/functionCall/call_internal_function_via_expression.sol b/test/libsolidity/semanticTests/functionCall/call_internal_function_via_expression.sol index 26c959675..043ee05a8 100644 --- a/test/libsolidity/semanticTests/functionCall/call_internal_function_via_expression.sol +++ b/test/libsolidity/semanticTests/functionCall/call_internal_function_via_expression.sol @@ -19,7 +19,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // associated() -> 42 // unassociated() -> 42 diff --git a/test/libsolidity/semanticTests/functionCall/call_internal_function_with_multislot_arguments_via_pointer.sol b/test/libsolidity/semanticTests/functionCall/call_internal_function_with_multislot_arguments_via_pointer.sol index 344d1dc63..a93adf245 100644 --- a/test/libsolidity/semanticTests/functionCall/call_internal_function_with_multislot_arguments_via_pointer.sol +++ b/test/libsolidity/semanticTests/functionCall/call_internal_function_with_multislot_arguments_via_pointer.sol @@ -25,7 +25,5 @@ contract C { return multi_slot_function(this.foo, this.foo)() + single_slot_function(5, 1); } } -// ==== -// compileViaYul: also // ---- // test() -> 12 diff --git a/test/libsolidity/semanticTests/functionCall/call_options_overload.sol b/test/libsolidity/semanticTests/functionCall/call_options_overload.sol index 0881c5bac..5e889e925 100644 --- a/test/libsolidity/semanticTests/functionCall/call_options_overload.sol +++ b/test/libsolidity/semanticTests/functionCall/call_options_overload.sol @@ -10,8 +10,6 @@ contract C { function bal() external returns (uint) { return address(this).balance; } receive() external payable {} } -// ==== -// compileViaYul: also // ---- // (), 1 ether // call() -> 1, 2, 2, 2 diff --git a/test/libsolidity/semanticTests/functionCall/calling_nonexisting_contract_throws.sol b/test/libsolidity/semanticTests/functionCall/calling_nonexisting_contract_throws.sol index 7d4a947da..9753015a4 100644 --- a/test/libsolidity/semanticTests/functionCall/calling_nonexisting_contract_throws.sol +++ b/test/libsolidity/semanticTests/functionCall/calling_nonexisting_contract_throws.sol @@ -24,7 +24,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> FAILURE // g() -> FAILURE diff --git a/test/libsolidity/semanticTests/functionCall/calling_other_functions.sol b/test/libsolidity/semanticTests/functionCall/calling_other_functions.sol index 157d13aea..12139fc68 100644 --- a/test/libsolidity/semanticTests/functionCall/calling_other_functions.sol +++ b/test/libsolidity/semanticTests/functionCall/calling_other_functions.sol @@ -14,7 +14,6 @@ contract collatz { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // run(uint256): 0 -> 0 // run(uint256): 1 -> 1 diff --git a/test/libsolidity/semanticTests/functionCall/calling_uninitialized_function.sol b/test/libsolidity/semanticTests/functionCall/calling_uninitialized_function.sol index d2bf644dd..2f660c24c 100644 --- a/test/libsolidity/semanticTests/functionCall/calling_uninitialized_function.sol +++ b/test/libsolidity/semanticTests/functionCall/calling_uninitialized_function.sol @@ -13,7 +13,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // intern() -> FAILURE, hex"4e487b71", 0x51 # This should throw exceptions # // extern() -> FAILURE diff --git a/test/libsolidity/semanticTests/functionCall/calling_uninitialized_function_in_detail.sol b/test/libsolidity/semanticTests/functionCall/calling_uninitialized_function_in_detail.sol index 0a2a10290..a7295928a 100644 --- a/test/libsolidity/semanticTests/functionCall/calling_uninitialized_function_in_detail.sol +++ b/test/libsolidity/semanticTests/functionCall/calling_uninitialized_function_in_detail.sol @@ -18,6 +18,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // t() -> FAILURE, hex"4e487b71", 0x51 diff --git a/test/libsolidity/semanticTests/functionCall/calling_uninitialized_function_through_array.sol b/test/libsolidity/semanticTests/functionCall/calling_uninitialized_function_through_array.sol index fc915792c..f7d90c8f2 100644 --- a/test/libsolidity/semanticTests/functionCall/calling_uninitialized_function_through_array.sol +++ b/test/libsolidity/semanticTests/functionCall/calling_uninitialized_function_through_array.sol @@ -17,6 +17,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // t() -> FAILURE, hex"4e487b71", 0x51 diff --git a/test/libsolidity/semanticTests/functionCall/conditional_with_arguments.sol b/test/libsolidity/semanticTests/functionCall/conditional_with_arguments.sol index f476d9dbc..65dbeaaee 100644 --- a/test/libsolidity/semanticTests/functionCall/conditional_with_arguments.sol +++ b/test/libsolidity/semanticTests/functionCall/conditional_with_arguments.sol @@ -8,6 +8,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1 diff --git a/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol b/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol index 0ab6fe0c3..b6c33fd07 100644 --- a/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol +++ b/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol @@ -9,8 +9,6 @@ contract D { return new C().i(); } } -// ==== -// compileViaYul: also // ---- // f() -> 2 // gas legacy: 101599 diff --git a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol index 0f1b63523..c6a556a19 100644 --- a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol +++ b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_args.sol @@ -13,11 +13,9 @@ contract D { return c.i(); } } -// ==== -// compileViaYul: also // ---- // constructor(): 2 -> -// gas irOptimized: 200217 +// gas irOptimized: 195258 // gas legacy: 245842 // gas legacyOptimized: 195676 // f() -> 2 diff --git a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol index 462e9ad76..0c81a0bae 100644 --- a/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol +++ b/test/libsolidity/semanticTests/functionCall/creation_function_call_with_salt.sol @@ -15,10 +15,9 @@ contract D { } // ==== // EVMVersion: >=constantinople -// compileViaYul: also // ---- // constructor(): 2 -> -// gas irOptimized: 200380 +// gas irOptimized: 195421 // gas legacy: 246202 // gas legacyOptimized: 195914 // f() -> 2 diff --git a/test/libsolidity/semanticTests/functionCall/delegatecall_return_value.sol b/test/libsolidity/semanticTests/functionCall/delegatecall_return_value.sol index 9fa72aeaa..1e6d542cf 100644 --- a/test/libsolidity/semanticTests/functionCall/delegatecall_return_value.sol +++ b/test/libsolidity/semanticTests/functionCall/delegatecall_return_value.sol @@ -23,7 +23,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // get() -> 0x00 // assert0_delegated() -> 0x01, 0x40, 0x0 diff --git a/test/libsolidity/semanticTests/functionCall/delegatecall_return_value_pre_byzantium.sol b/test/libsolidity/semanticTests/functionCall/delegatecall_return_value_pre_byzantium.sol index 00f1f8a77..498449d17 100644 --- a/test/libsolidity/semanticTests/functionCall/delegatecall_return_value_pre_byzantium.sol +++ b/test/libsolidity/semanticTests/functionCall/delegatecall_return_value_pre_byzantium.sol @@ -24,7 +24,6 @@ contract C { } } // ==== -// compileViaYul: also // EVMVersion: 0x00 diff --git a/test/libsolidity/semanticTests/functionCall/disordered_named_args.sol b/test/libsolidity/semanticTests/functionCall/disordered_named_args.sol index dc34aa8a2..5529b90a0 100644 --- a/test/libsolidity/semanticTests/functionCall/disordered_named_args.sol +++ b/test/libsolidity/semanticTests/functionCall/disordered_named_args.sol @@ -4,6 +4,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // b() -> 123 diff --git a/test/libsolidity/semanticTests/functionCall/external_call.sol b/test/libsolidity/semanticTests/functionCall/external_call.sol index b732f5e95..48dddecec 100644 --- a/test/libsolidity/semanticTests/functionCall/external_call.sol +++ b/test/libsolidity/semanticTests/functionCall/external_call.sol @@ -10,8 +10,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // g(uint256): 4 -> 5 // f(uint256): 2 -> 5 diff --git a/test/libsolidity/semanticTests/functionCall/external_call_at_construction_time.sol b/test/libsolidity/semanticTests/functionCall/external_call_at_construction_time.sol index 2fb2f266d..69a2193a3 100644 --- a/test/libsolidity/semanticTests/functionCall/external_call_at_construction_time.sol +++ b/test/libsolidity/semanticTests/functionCall/external_call_at_construction_time.sol @@ -19,7 +19,6 @@ contract C { // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f(uint256): 0 -> FAILURE // f(uint256): 1 -> FAILURE diff --git a/test/libsolidity/semanticTests/functionCall/external_call_dynamic_returndata.sol b/test/libsolidity/semanticTests/functionCall/external_call_dynamic_returndata.sol index c87f73f06..56a2876ed 100644 --- a/test/libsolidity/semanticTests/functionCall/external_call_dynamic_returndata.sol +++ b/test/libsolidity/semanticTests/functionCall/external_call_dynamic_returndata.sol @@ -19,6 +19,5 @@ contract C { // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // dt(uint256): 4 -> 6 diff --git a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol index 79c3adccb..d0c3c4d80 100644 --- a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol +++ b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting.sol @@ -21,13 +21,11 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // constructor(), 1 ether -> -// gas irOptimized: 303935 -// gas legacy: 464030 -// gas legacyOptimized: 304049 +// gas irOptimized: 266135 +// gas legacy: 454729 +// gas legacyOptimized: 301679 // f(uint256): 0 -> FAILURE // f(uint256): 1 -> FAILURE // f(uint256): 2 -> FAILURE diff --git a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol index 2e9be2ff5..9cc2846ac 100644 --- a/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol +++ b/test/libsolidity/semanticTests/functionCall/external_call_to_nonexisting_debugstrings.sol @@ -23,13 +23,12 @@ contract C { // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // constructor(), 1 ether -> -// gas irOptimized: 446871 -// gas legacy: 832976 -// gas legacyOptimized: 509560 +// gas irOptimized: 424088 +// gas legacy: 823681 +// gas legacyOptimized: 505900 // f(uint256): 0 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code" // f(uint256): 1 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code" // f(uint256): 2 -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code" diff --git a/test/libsolidity/semanticTests/functionCall/external_call_value.sol b/test/libsolidity/semanticTests/functionCall/external_call_value.sol index 47e2bfb76..5a946533d 100644 --- a/test/libsolidity/semanticTests/functionCall/external_call_value.sol +++ b/test/libsolidity/semanticTests/functionCall/external_call_value.sol @@ -10,8 +10,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // g(uint256), 1 ether: 4 -> 1000000000000000000000, 4 // f(uint256), 11 ether: 2 -> 10000, 2 diff --git a/test/libsolidity/semanticTests/functionCall/external_function.sol b/test/libsolidity/semanticTests/functionCall/external_function.sol index 7f79350d8..d6c13a4ef 100644 --- a/test/libsolidity/semanticTests/functionCall/external_function.sol +++ b/test/libsolidity/semanticTests/functionCall/external_function.sol @@ -14,6 +14,5 @@ contract c { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test(uint256,uint256): 2, 3 -> 9, 3 diff --git a/test/libsolidity/semanticTests/functionCall/external_public_override.sol b/test/libsolidity/semanticTests/functionCall/external_public_override.sol index 4f5c6aaa2..31f474205 100644 --- a/test/libsolidity/semanticTests/functionCall/external_public_override.sol +++ b/test/libsolidity/semanticTests/functionCall/external_public_override.sol @@ -17,7 +17,6 @@ contract B is A { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 2 // g() -> 2 diff --git a/test/libsolidity/semanticTests/functionCall/failed_create.sol b/test/libsolidity/semanticTests/functionCall/failed_create.sol index 19fd10bf6..c963c0e20 100644 --- a/test/libsolidity/semanticTests/functionCall/failed_create.sol +++ b/test/libsolidity/semanticTests/functionCall/failed_create.sol @@ -15,20 +15,19 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // constructor(), 20 wei -// gas irOptimized: 212583 +// gas irOptimized: 184005 // gas legacy: 294335 -// gas legacyOptimized: 174279 +// gas legacyOptimized: 173427 // f(uint256): 20 -> 1370859564726510389319704988634906228201275401179 // x() -> 1 // f(uint256): 20 -> FAILURE // x() -> 1 // stack(uint256): 1023 -> FAILURE -// gas irOptimized: 314884 +// gas irOptimized: 260987 // gas legacy: 483942 -// gas legacyOptimized: 298807 +// gas legacyOptimized: 302349 // x() -> 1 // stack(uint256): 10 -> 693016686122178122849713379390321835634789309880 // x() -> 2 diff --git a/test/libsolidity/semanticTests/functionCall/file_level_call_via_module.sol b/test/libsolidity/semanticTests/functionCall/file_level_call_via_module.sol index d50e2d95d..7db64dafc 100644 --- a/test/libsolidity/semanticTests/functionCall/file_level_call_via_module.sol +++ b/test/libsolidity/semanticTests/functionCall/file_level_call_via_module.sol @@ -11,6 +11,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 7, 3 diff --git a/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol b/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol index 40de1b509..977f1a56a 100644 --- a/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol +++ b/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol @@ -37,11 +37,9 @@ contract test { } } -// ==== -// compileViaYul: also // ---- // constructor(), 20 wei -> -// gas irOptimized: 270609 +// gas irOptimized: 261698 // gas legacy: 402654 // gas legacyOptimized: 274470 // sendAmount(uint256): 5 -> 5 diff --git a/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol b/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol index 6b3f99dee..48365a61a 100644 --- a/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol +++ b/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol @@ -36,11 +36,9 @@ contract test { } } -// ==== -// compileViaYul: also // ---- // constructor(), 20 wei -> -// gas irOptimized: 270609 +// gas irOptimized: 261698 // gas legacy: 402654 // gas legacyOptimized: 274470 // sendAmount(uint256): 5 -> 5 diff --git a/test/libsolidity/semanticTests/functionCall/inheritance/base_base_overload.sol b/test/libsolidity/semanticTests/functionCall/inheritance/base_base_overload.sol index cc6f0bb91..749e7c01b 100644 --- a/test/libsolidity/semanticTests/functionCall/inheritance/base_base_overload.sol +++ b/test/libsolidity/semanticTests/functionCall/inheritance/base_base_overload.sol @@ -36,7 +36,6 @@ contract Child is Base { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // x() -> 0 // y() -> 0 diff --git a/test/libsolidity/semanticTests/functionCall/inheritance/base_overload.sol b/test/libsolidity/semanticTests/functionCall/inheritance/base_overload.sol index 991031890..fa65755b8 100644 --- a/test/libsolidity/semanticTests/functionCall/inheritance/base_overload.sol +++ b/test/libsolidity/semanticTests/functionCall/inheritance/base_overload.sol @@ -20,7 +20,6 @@ contract Child is Base { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // x() -> 0 // y() -> 0 diff --git a/test/libsolidity/semanticTests/functionCall/inheritance/call_base.sol b/test/libsolidity/semanticTests/functionCall/inheritance/call_base.sol index 366c45a28..85302de76 100644 --- a/test/libsolidity/semanticTests/functionCall/inheritance/call_base.sol +++ b/test/libsolidity/semanticTests/functionCall/inheritance/call_base.sol @@ -11,6 +11,5 @@ contract Child is Base { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g(uint256): 4 -> 8 diff --git a/test/libsolidity/semanticTests/functionCall/inheritance/call_base_base.sol b/test/libsolidity/semanticTests/functionCall/inheritance/call_base_base.sol index 673f3145f..70ec4fd72 100644 --- a/test/libsolidity/semanticTests/functionCall/inheritance/call_base_base.sol +++ b/test/libsolidity/semanticTests/functionCall/inheritance/call_base_base.sol @@ -24,7 +24,6 @@ contract Child is Base { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g(uint256): 4 -> 12 // h(uint256): 4 -> 16 diff --git a/test/libsolidity/semanticTests/functionCall/inheritance/call_base_base_explicit.sol b/test/libsolidity/semanticTests/functionCall/inheritance/call_base_base_explicit.sol index a443585af..169e1a6ba 100644 --- a/test/libsolidity/semanticTests/functionCall/inheritance/call_base_base_explicit.sol +++ b/test/libsolidity/semanticTests/functionCall/inheritance/call_base_base_explicit.sol @@ -27,7 +27,6 @@ contract Child is Base { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g(uint256): 4 -> 8 // k(uint256): 4 -> 16 diff --git a/test/libsolidity/semanticTests/functionCall/inheritance/call_base_explicit.sol b/test/libsolidity/semanticTests/functionCall/inheritance/call_base_explicit.sol index ff29b9a91..7ff1eae99 100644 --- a/test/libsolidity/semanticTests/functionCall/inheritance/call_base_explicit.sol +++ b/test/libsolidity/semanticTests/functionCall/inheritance/call_base_explicit.sol @@ -11,6 +11,5 @@ contract Child is Base { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g(uint256): 4 -> 8 diff --git a/test/libsolidity/semanticTests/functionCall/inheritance/call_unimplemented_base.sol b/test/libsolidity/semanticTests/functionCall/inheritance/call_unimplemented_base.sol index 4d84dcd7a..61b428303 100644 --- a/test/libsolidity/semanticTests/functionCall/inheritance/call_unimplemented_base.sol +++ b/test/libsolidity/semanticTests/functionCall/inheritance/call_unimplemented_base.sol @@ -16,6 +16,5 @@ contract C is V } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // b() -> 42 diff --git a/test/libsolidity/semanticTests/functionCall/inheritance/super_skip_unimplemented_in_abstract_contract.sol b/test/libsolidity/semanticTests/functionCall/inheritance/super_skip_unimplemented_in_abstract_contract.sol index 82dc5d513..7dc726be2 100644 --- a/test/libsolidity/semanticTests/functionCall/inheritance/super_skip_unimplemented_in_abstract_contract.sol +++ b/test/libsolidity/semanticTests/functionCall/inheritance/super_skip_unimplemented_in_abstract_contract.sol @@ -17,6 +17,5 @@ contract B is A, I { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 42 diff --git a/test/libsolidity/semanticTests/functionCall/inheritance/super_skip_unimplemented_in_interface.sol b/test/libsolidity/semanticTests/functionCall/inheritance/super_skip_unimplemented_in_interface.sol index 8f7914013..218d1bca8 100644 --- a/test/libsolidity/semanticTests/functionCall/inheritance/super_skip_unimplemented_in_interface.sol +++ b/test/libsolidity/semanticTests/functionCall/inheritance/super_skip_unimplemented_in_interface.sol @@ -17,6 +17,5 @@ contract B is A, I { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 42 diff --git a/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol b/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol index f422b43d9..99ca5e3f7 100644 --- a/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol +++ b/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol @@ -16,11 +16,9 @@ contract test { return (a[0][key], a[1][key], b[0][key], b[1][key]); } } -// ==== -// compileViaYul: also // ---- // set(uint8,uint8,uint8,uint8,uint8): 1, 21, 22, 42, 43 -> 0, 0, 0, 0 -// gas irOptimized: 111909 +// gas irOptimized: 111669 // gas legacy: 113806 // gas legacyOptimized: 111781 // get(uint8): 1 -> 21, 22, 42, 43 diff --git a/test/libsolidity/semanticTests/functionCall/mapping_internal_argument.sol b/test/libsolidity/semanticTests/functionCall/mapping_internal_argument.sol index 4154baa9b..728be2c09 100644 --- a/test/libsolidity/semanticTests/functionCall/mapping_internal_argument.sol +++ b/test/libsolidity/semanticTests/functionCall/mapping_internal_argument.sol @@ -14,8 +14,6 @@ contract test { return (a[key], b[key]); } } -// ==== -// compileViaYul: also // ---- // set(uint8,uint8,uint8): 1, 21, 42 -> 0, 0 // get(uint8): 1 -> 21, 42 diff --git a/test/libsolidity/semanticTests/functionCall/mapping_internal_return.sol b/test/libsolidity/semanticTests/functionCall/mapping_internal_return.sol index b152298b9..7756a92b1 100644 --- a/test/libsolidity/semanticTests/functionCall/mapping_internal_return.sol +++ b/test/libsolidity/semanticTests/functionCall/mapping_internal_return.sol @@ -17,8 +17,6 @@ contract test { return (a[0], a[1], a[2], b[0], b[1], b[2]); } } -// ==== -// compileViaYul: also // ---- // g() -> 0, 42, 0, 0, 84, 21 // h() -> 0, 42, 0, 0, 84, 17 diff --git a/test/libsolidity/semanticTests/functionCall/member_accessors.sol b/test/libsolidity/semanticTests/functionCall/member_accessors.sol index 9bdade4a2..ad0b8a3e2 100644 --- a/test/libsolidity/semanticTests/functionCall/member_accessors.sol +++ b/test/libsolidity/semanticTests/functionCall/member_accessors.sol @@ -15,7 +15,6 @@ contract test { // ==== // allowNonExistingFunctions: true // compileToEwasm: also -// compileViaYul: also // ---- // data() -> 8 // name() -> "Celina" diff --git a/test/libsolidity/semanticTests/functionCall/multiple_functions.sol b/test/libsolidity/semanticTests/functionCall/multiple_functions.sol index 834d20c3d..63fac55e0 100644 --- a/test/libsolidity/semanticTests/functionCall/multiple_functions.sol +++ b/test/libsolidity/semanticTests/functionCall/multiple_functions.sol @@ -7,7 +7,6 @@ contract test { // ==== // allowNonExistingFunctions: true // compileToEwasm: also -// compileViaYul: also // ---- // a() -> 0 // b() -> 1 diff --git a/test/libsolidity/semanticTests/functionCall/multiple_return_values.sol b/test/libsolidity/semanticTests/functionCall/multiple_return_values.sol index f46021bf2..ef746eb03 100644 --- a/test/libsolidity/semanticTests/functionCall/multiple_return_values.sol +++ b/test/libsolidity/semanticTests/functionCall/multiple_return_values.sol @@ -5,6 +5,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // run(bool,uint256): true, 0xcd -> 0xcd, true, 0 diff --git a/test/libsolidity/semanticTests/functionCall/named_args.sol b/test/libsolidity/semanticTests/functionCall/named_args.sol index 171e0f2c7..4966f5186 100644 --- a/test/libsolidity/semanticTests/functionCall/named_args.sol +++ b/test/libsolidity/semanticTests/functionCall/named_args.sol @@ -5,7 +5,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // b() -> 123 // c() -> 123 diff --git a/test/libsolidity/semanticTests/functionCall/named_args_overload.sol b/test/libsolidity/semanticTests/functionCall/named_args_overload.sol index 1de25455e..0c31e47c5 100644 --- a/test/libsolidity/semanticTests/functionCall/named_args_overload.sol +++ b/test/libsolidity/semanticTests/functionCall/named_args_overload.sol @@ -28,7 +28,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // call(uint256): 0 -> 0 // call(uint256): 1 -> 1 diff --git a/test/libsolidity/semanticTests/functionCall/precompile_extcodesize_check.sol b/test/libsolidity/semanticTests/functionCall/precompile_extcodesize_check.sol index b82c5f9b7..beda5f9b1 100644 --- a/test/libsolidity/semanticTests/functionCall/precompile_extcodesize_check.sol +++ b/test/libsolidity/semanticTests/functionCall/precompile_extcodesize_check.sol @@ -27,7 +27,6 @@ contract C { } // ==== // EVMVersion: >=constantinople -// compileViaYul: also // ---- // testHighLevel() -> true // testLowLevel() -> 0xc76596d400000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol b/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol index a3d93043d..1a120beba 100644 --- a/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol +++ b/test/libsolidity/semanticTests/functionCall/send_zero_ether.sol @@ -16,7 +16,6 @@ contract Main { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // constructor(), 20 wei -> // gas irOptimized: 100264 diff --git a/test/libsolidity/semanticTests/functionCall/transaction_status.sol b/test/libsolidity/semanticTests/functionCall/transaction_status.sol index 6251c833f..309cb8ef1 100644 --- a/test/libsolidity/semanticTests/functionCall/transaction_status.sol +++ b/test/libsolidity/semanticTests/functionCall/transaction_status.sol @@ -5,7 +5,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> // g() -> FAILURE diff --git a/test/libsolidity/semanticTests/functionCall/value_test.sol b/test/libsolidity/semanticTests/functionCall/value_test.sol index 46c566c6b..c15e6332f 100644 --- a/test/libsolidity/semanticTests/functionCall/value_test.sol +++ b/test/libsolidity/semanticTests/functionCall/value_test.sol @@ -4,7 +4,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(), 1 ether -> 1000000000000000000 diff --git a/test/libsolidity/semanticTests/functionSelector/function_selector_via_contract_name.sol b/test/libsolidity/semanticTests/functionSelector/function_selector_via_contract_name.sol index 7fae98694..5052ad2b4 100644 --- a/test/libsolidity/semanticTests/functionSelector/function_selector_via_contract_name.sol +++ b/test/libsolidity/semanticTests/functionSelector/function_selector_via_contract_name.sol @@ -17,7 +17,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test1() -> left(0x26121ff0), left(0xe420264a), left(0x26121ff0), left(0xe420264a) // test2() -> left(0x26121ff0), left(0xe420264a), left(0x26121ff0), left(0xe420264a) diff --git a/test/libsolidity/semanticTests/functionTypes/address_member.sol b/test/libsolidity/semanticTests/functionTypes/address_member.sol index 029aac950..91229be10 100644 --- a/test/libsolidity/semanticTests/functionTypes/address_member.sol +++ b/test/libsolidity/semanticTests/functionTypes/address_member.sol @@ -7,7 +7,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 90572315268751552425567948436632610904688605307, 90572315268751552425567948436632610904688605307 diff --git a/test/libsolidity/semanticTests/functionTypes/comparison_operator_for_external_function_cleans_dirty_bits.sol b/test/libsolidity/semanticTests/functionTypes/comparison_operator_for_external_function_cleans_dirty_bits.sol index 3347d9b77..da9c528fd 100644 --- a/test/libsolidity/semanticTests/functionTypes/comparison_operator_for_external_function_cleans_dirty_bits.sol +++ b/test/libsolidity/semanticTests/functionTypes/comparison_operator_for_external_function_cleans_dirty_bits.sol @@ -11,7 +11,6 @@ contract C { } } // ==== -// compileViaYul: also // EVMVersion: >=constantinople // ---- // comparison_operators_for_external_function_pointers_with_dirty_bits() -> true diff --git a/test/libsolidity/semanticTests/functionTypes/comparison_operators_for_external_functions.sol b/test/libsolidity/semanticTests/functionTypes/comparison_operators_for_external_functions.sol index da75ea071..6c47752c6 100644 --- a/test/libsolidity/semanticTests/functionTypes/comparison_operators_for_external_functions.sol +++ b/test/libsolidity/semanticTests/functionTypes/comparison_operators_for_external_functions.sol @@ -74,8 +74,6 @@ contract C { return true; } } -// ==== -// compileViaYul: also // ---- // comparison_operators_for_external_functions() -> true // comparison_operators_for_local_external_function_pointers() -> true diff --git a/test/libsolidity/semanticTests/functionTypes/function_delete_stack.sol b/test/libsolidity/semanticTests/functionTypes/function_delete_stack.sol index 218afb00b..409bb809e 100644 --- a/test/libsolidity/semanticTests/functionTypes/function_delete_stack.sol +++ b/test/libsolidity/semanticTests/functionTypes/function_delete_stack.sol @@ -12,6 +12,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> FAILURE, hex"4e487b71", 0x51 diff --git a/test/libsolidity/semanticTests/functionTypes/function_delete_storage.sol b/test/libsolidity/semanticTests/functionTypes/function_delete_storage.sol index 2bb710399..4cf8be204 100644 --- a/test/libsolidity/semanticTests/functionTypes/function_delete_storage.sol +++ b/test/libsolidity/semanticTests/functionTypes/function_delete_storage.sol @@ -22,7 +22,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // set() -> 7 // ca() -> 7 diff --git a/test/libsolidity/semanticTests/functionTypes/function_external_delete_storage.sol b/test/libsolidity/semanticTests/functionTypes/function_external_delete_storage.sol index a7604872b..b432719ec 100644 --- a/test/libsolidity/semanticTests/functionTypes/function_external_delete_storage.sol +++ b/test/libsolidity/semanticTests/functionTypes/function_external_delete_storage.sol @@ -19,8 +19,6 @@ contract C { delete x; } } -// ==== -// compileViaYul: also // ---- // x() -> 0 // y() -> 0 diff --git a/test/libsolidity/semanticTests/functionTypes/function_type_library_internal.sol b/test/libsolidity/semanticTests/functionTypes/function_type_library_internal.sol index c4554740d..f096a4979 100644 --- a/test/libsolidity/semanticTests/functionTypes/function_type_library_internal.sol +++ b/test/libsolidity/semanticTests/functionTypes/function_type_library_internal.sol @@ -22,7 +22,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(uint256[]): 0x20, 0x3, 0x1, 0x7, 0x3 -> 11 diff --git a/test/libsolidity/semanticTests/functionTypes/inline_array_with_value_call_option.sol b/test/libsolidity/semanticTests/functionTypes/inline_array_with_value_call_option.sol index 3b9a70aa1..e65da6e1e 100644 --- a/test/libsolidity/semanticTests/functionTypes/inline_array_with_value_call_option.sol +++ b/test/libsolidity/semanticTests/functionTypes/inline_array_with_value_call_option.sol @@ -6,7 +6,5 @@ contract C { return [this.f, this.g][0]{value: 1}(); } } -// ==== -// compileViaYul: also // ---- // h(), 1 ether -> 1 diff --git a/test/libsolidity/semanticTests/functionTypes/mapping_of_functions.sol b/test/libsolidity/semanticTests/functionTypes/mapping_of_functions.sol index 64f55a420..353844723 100644 --- a/test/libsolidity/semanticTests/functionTypes/mapping_of_functions.sol +++ b/test/libsolidity/semanticTests/functionTypes/mapping_of_functions.sol @@ -25,8 +25,6 @@ contract Flow { } } -// ==== -// compileViaYul: also // ---- // success() -> false // f() -> 7 diff --git a/test/libsolidity/semanticTests/functionTypes/pass_function_types_externally.sol b/test/libsolidity/semanticTests/functionTypes/pass_function_types_externally.sol index 2cb6428f7..ebef9a254 100644 --- a/test/libsolidity/semanticTests/functionTypes/pass_function_types_externally.sol +++ b/test/libsolidity/semanticTests/functionTypes/pass_function_types_externally.sol @@ -16,8 +16,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(uint256): 7 -> 8 // f2(uint256): 7 -> 8 diff --git a/test/libsolidity/semanticTests/functionTypes/pass_function_types_internally.sol b/test/libsolidity/semanticTests/functionTypes/pass_function_types_internally.sol index b189a9909..a2bab4051 100644 --- a/test/libsolidity/semanticTests/functionTypes/pass_function_types_internally.sol +++ b/test/libsolidity/semanticTests/functionTypes/pass_function_types_internally.sol @@ -13,6 +13,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 7 -> 8 diff --git a/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime.sol b/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime.sol index 3a1dea9a1..675c2d08b 100644 --- a/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime.sol +++ b/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime.sol @@ -15,7 +15,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // runtime(uint256): 3 -> 6 // initial() -> 4 diff --git a/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime_equality_check.sol b/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime_equality_check.sol index 7b371da31..d32db4d90 100644 --- a/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime_equality_check.sol +++ b/test/libsolidity/semanticTests/functionTypes/same_function_in_construction_and_runtime_equality_check.sol @@ -16,6 +16,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> true diff --git a/test/libsolidity/semanticTests/functionTypes/stack_height_check_on_adding_gas_variable_to_function.sol b/test/libsolidity/semanticTests/functionTypes/stack_height_check_on_adding_gas_variable_to_function.sol index 5726860b9..f811988fe 100644 --- a/test/libsolidity/semanticTests/functionTypes/stack_height_check_on_adding_gas_variable_to_function.sol +++ b/test/libsolidity/semanticTests/functionTypes/stack_height_check_on_adding_gas_variable_to_function.sol @@ -19,7 +19,5 @@ contract C { return true; } } -// ==== -// compileViaYul: also // ---- // test_function() -> true diff --git a/test/libsolidity/semanticTests/functionTypes/store_function.sol b/test/libsolidity/semanticTests/functionTypes/store_function.sol index dab82918a..ba8b65bbc 100644 --- a/test/libsolidity/semanticTests/functionTypes/store_function.sol +++ b/test/libsolidity/semanticTests/functionTypes/store_function.sol @@ -24,10 +24,8 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // t() -> 9 // gas irOptimized: 99064 -// gas legacy: 158955 -// gas legacyOptimized: 108788 +// gas legacy: 152137 +// gas legacyOptimized: 107793 diff --git a/test/libsolidity/semanticTests/functionTypes/struct_with_external_function.sol b/test/libsolidity/semanticTests/functionTypes/struct_with_external_function.sol index 19086df7a..9c7684245 100644 --- a/test/libsolidity/semanticTests/functionTypes/struct_with_external_function.sol +++ b/test/libsolidity/semanticTests/functionTypes/struct_with_external_function.sol @@ -28,7 +28,5 @@ contract Flow { } } -// ==== -// compileViaYul: also // ---- // f() -> 1, 2 diff --git a/test/libsolidity/semanticTests/functionTypes/struct_with_functions.sol b/test/libsolidity/semanticTests/functionTypes/struct_with_functions.sol index 98624a073..1ecd9eaf5 100644 --- a/test/libsolidity/semanticTests/functionTypes/struct_with_functions.sol +++ b/test/libsolidity/semanticTests/functionTypes/struct_with_functions.sol @@ -30,6 +30,5 @@ contract Flow { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1, 2 diff --git a/test/libsolidity/semanticTests/functionTypes/uninitialized_internal_storage_function_call.sol b/test/libsolidity/semanticTests/functionTypes/uninitialized_internal_storage_function_call.sol index 43f54a52f..fb34698bb 100644 --- a/test/libsolidity/semanticTests/functionTypes/uninitialized_internal_storage_function_call.sol +++ b/test/libsolidity/semanticTests/functionTypes/uninitialized_internal_storage_function_call.sol @@ -9,6 +9,5 @@ contract Test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> FAILURE, hex"4e487b71", 0x51 diff --git a/test/libsolidity/semanticTests/getters/array_mapping_struct.sol b/test/libsolidity/semanticTests/getters/array_mapping_struct.sol index 4aba17856..d824897e8 100644 --- a/test/libsolidity/semanticTests/getters/array_mapping_struct.sol +++ b/test/libsolidity/semanticTests/getters/array_mapping_struct.sol @@ -18,8 +18,6 @@ contract C { n[1][1].b = 10; } } -// ==== -// compileViaYul: also // ---- // m(uint256,uint256): 0, 0 -> 0x00, 0x00 // m(uint256,uint256): 1, 0 -> 1, 2 diff --git a/test/libsolidity/semanticTests/getters/arrays.sol b/test/libsolidity/semanticTests/getters/arrays.sol index 184d6ce7f..0ce2cdfcb 100644 --- a/test/libsolidity/semanticTests/getters/arrays.sol +++ b/test/libsolidity/semanticTests/getters/arrays.sol @@ -5,8 +5,6 @@ contract C { a[1].push(4); } } -// ==== -// compileViaYul: also // ---- // a(uint256,uint256): 0, 0 -> FAILURE // a(uint256,uint256): 1, 0 -> 3 diff --git a/test/libsolidity/semanticTests/getters/bytes.sol b/test/libsolidity/semanticTests/getters/bytes.sol index 13c21daa3..24f384fa5 100644 --- a/test/libsolidity/semanticTests/getters/bytes.sol +++ b/test/libsolidity/semanticTests/getters/bytes.sol @@ -5,7 +5,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // b() -> 0x20, 0x03, 0x6162630000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/getters/mapping.sol b/test/libsolidity/semanticTests/getters/mapping.sol index b54c028ca..524cac361 100644 --- a/test/libsolidity/semanticTests/getters/mapping.sol +++ b/test/libsolidity/semanticTests/getters/mapping.sol @@ -4,8 +4,6 @@ contract C { x[1][2] = 3; } } -// ==== -// compileViaYul: also // ---- // x(uint256,uint256): 1, 2 -> 3 // x(uint256,uint256): 0, 0 -> 0 diff --git a/test/libsolidity/semanticTests/getters/mapping_array_struct.sol b/test/libsolidity/semanticTests/getters/mapping_array_struct.sol index 01c15320a..60683dfc0 100644 --- a/test/libsolidity/semanticTests/getters/mapping_array_struct.sol +++ b/test/libsolidity/semanticTests/getters/mapping_array_struct.sol @@ -16,8 +16,6 @@ contract C { n[1][1].b = 10; } } -// ==== -// compileViaYul: also // ---- // m(uint256,uint256): 0, 0 -> FAILURE // m(uint256,uint256): 1, 0 -> 1, 2 diff --git a/test/libsolidity/semanticTests/getters/mapping_of_string.sol b/test/libsolidity/semanticTests/getters/mapping_of_string.sol index 319f0a655..db8de8062 100644 --- a/test/libsolidity/semanticTests/getters/mapping_of_string.sol +++ b/test/libsolidity/semanticTests/getters/mapping_of_string.sol @@ -7,8 +7,6 @@ contract C { x["def"][1] = 9; } } -// ==== -// compileViaYul: also // ---- // x(string,uint256): 0x40, 0, 3, "abc" -> 1 // x(string,uint256): 0x40, 1, 3, "abc" -> 2 diff --git a/test/libsolidity/semanticTests/getters/mapping_to_struct.sol b/test/libsolidity/semanticTests/getters/mapping_to_struct.sol index c2d70a35a..d601fd90f 100644 --- a/test/libsolidity/semanticTests/getters/mapping_to_struct.sol +++ b/test/libsolidity/semanticTests/getters/mapping_to_struct.sol @@ -13,8 +13,6 @@ contract C { x[1][2].d = 6; } } -// ==== -// compileViaYul: also // ---- // x(uint256,uint256): 1, 2 -> 3, 4, 5, 6 // x(uint256,uint256): 0, 0 -> 0x00, 0x00, 0x00, 0x00 diff --git a/test/libsolidity/semanticTests/getters/string_and_bytes.sol b/test/libsolidity/semanticTests/getters/string_and_bytes.sol index 0c81ad65b..9452ff97c 100644 --- a/test/libsolidity/semanticTests/getters/string_and_bytes.sol +++ b/test/libsolidity/semanticTests/getters/string_and_bytes.sol @@ -10,7 +10,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // a() -> 0x20, 11, "hello world" diff --git a/test/libsolidity/semanticTests/getters/struct_with_bytes.sol b/test/libsolidity/semanticTests/getters/struct_with_bytes.sol index 92815d78a..477a1297f 100644 --- a/test/libsolidity/semanticTests/getters/struct_with_bytes.sol +++ b/test/libsolidity/semanticTests/getters/struct_with_bytes.sol @@ -14,7 +14,5 @@ contract C { s.d.push(10); } } -// ==== -// compileViaYul: also // ---- // s() -> 7, 0x40, 3, 0x6162630000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/getters/struct_with_bytes_simple.sol b/test/libsolidity/semanticTests/getters/struct_with_bytes_simple.sol index 59589be52..281b29c87 100644 --- a/test/libsolidity/semanticTests/getters/struct_with_bytes_simple.sol +++ b/test/libsolidity/semanticTests/getters/struct_with_bytes_simple.sol @@ -13,7 +13,5 @@ contract C { s.c[0] = 9; } } -// ==== -// compileViaYul: also // ---- // s() -> 0x07, 0x40, 0x03, 0x6162630000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/getters/value_types.sol b/test/libsolidity/semanticTests/getters/value_types.sol index 3b0cbaa93..3d590ded1 100644 --- a/test/libsolidity/semanticTests/getters/value_types.sol +++ b/test/libsolidity/semanticTests/getters/value_types.sol @@ -22,7 +22,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // a() -> 3 // b() -> 4 diff --git a/test/libsolidity/semanticTests/immutable/assign_at_declaration.sol b/test/libsolidity/semanticTests/immutable/assign_at_declaration.sol index 030a3544c..3f71a31e0 100644 --- a/test/libsolidity/semanticTests/immutable/assign_at_declaration.sol +++ b/test/libsolidity/semanticTests/immutable/assign_at_declaration.sol @@ -4,7 +4,5 @@ contract A { return a; } } -// ==== -// compileViaYul: also // ---- // f() -> 2 diff --git a/test/libsolidity/semanticTests/immutable/assign_from_immutables.sol b/test/libsolidity/semanticTests/immutable/assign_from_immutables.sol index 4e8610bb6..e1440be56 100644 --- a/test/libsolidity/semanticTests/immutable/assign_from_immutables.sol +++ b/test/libsolidity/semanticTests/immutable/assign_from_immutables.sol @@ -11,8 +11,6 @@ contract C { d = c; } } -// ==== -// compileViaYul: also // ---- // a() -> 1 // b() -> 1 diff --git a/test/libsolidity/semanticTests/immutable/fun_read_in_ctor.sol b/test/libsolidity/semanticTests/immutable/fun_read_in_ctor.sol index b402ea8f2..0aafbae3e 100644 --- a/test/libsolidity/semanticTests/immutable/fun_read_in_ctor.sol +++ b/test/libsolidity/semanticTests/immutable/fun_read_in_ctor.sol @@ -15,8 +15,6 @@ contract A { return a; } } -// ==== -// compileViaYul: also // ---- // readX() -> 3 // readA() -> 3 diff --git a/test/libsolidity/semanticTests/immutable/getter.sol b/test/libsolidity/semanticTests/immutable/getter.sol index c0997744e..bb4b191cf 100644 --- a/test/libsolidity/semanticTests/immutable/getter.sol +++ b/test/libsolidity/semanticTests/immutable/getter.sol @@ -1,7 +1,5 @@ contract C { uint immutable public x = 1; } -// ==== -// compileViaYul: also // ---- // x() -> 1 diff --git a/test/libsolidity/semanticTests/immutable/getter_call_in_constructor.sol b/test/libsolidity/semanticTests/immutable/getter_call_in_constructor.sol index ea59e8371..2ef12c04a 100644 --- a/test/libsolidity/semanticTests/immutable/getter_call_in_constructor.sol +++ b/test/libsolidity/semanticTests/immutable/getter_call_in_constructor.sol @@ -13,6 +13,5 @@ contract C { } // ==== // EVMVersion: >=tangerineWhistle -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/immutable/immutable_signed.sol b/test/libsolidity/semanticTests/immutable/immutable_signed.sol index 752048739..6bb193f82 100644 --- a/test/libsolidity/semanticTests/immutable/immutable_signed.sol +++ b/test/libsolidity/semanticTests/immutable/immutable_signed.sol @@ -9,7 +9,5 @@ contract C { } function g() internal pure returns (uint) { return 2; } } -// ==== -// compileViaYul: also // ---- // viaasm() -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x6162000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/immutable/inheritance.sol b/test/libsolidity/semanticTests/immutable/inheritance.sol index 0e131535e..889c273e4 100644 --- a/test/libsolidity/semanticTests/immutable/inheritance.sol +++ b/test/libsolidity/semanticTests/immutable/inheritance.sol @@ -26,7 +26,5 @@ contract D is B, C { return (a, b, c, d); } } -// ==== -// compileViaYul: also // ---- // f() -> 4, 3, 2, 1 diff --git a/test/libsolidity/semanticTests/immutable/internal_function_pointer.sol b/test/libsolidity/semanticTests/immutable/internal_function_pointer.sol index f046395d2..f56db7f27 100644 --- a/test/libsolidity/semanticTests/immutable/internal_function_pointer.sol +++ b/test/libsolidity/semanticTests/immutable/internal_function_pointer.sol @@ -10,8 +10,6 @@ contract C { return z(); } } -// ==== -// compileViaYul: also // ---- // f() -> 7 // callZ() -> 7 diff --git a/test/libsolidity/semanticTests/immutable/multi_creation.sol b/test/libsolidity/semanticTests/immutable/multi_creation.sol index a66c86027..88f3ed5eb 100644 --- a/test/libsolidity/semanticTests/immutable/multi_creation.sol +++ b/test/libsolidity/semanticTests/immutable/multi_creation.sol @@ -25,11 +25,9 @@ contract C { return (a, (new A()).f(), (new B()).f()); } } -// ==== -// compileViaYul: also // ---- // f() -> 3, 7, 5 -// gas irOptimized: 126136 +// gas irOptimized: 126044 // gas legacy: 151334 // gas legacyOptimized: 125166 // x() -> 7 diff --git a/test/libsolidity/semanticTests/immutable/read_in_ctor.sol b/test/libsolidity/semanticTests/immutable/read_in_ctor.sol index 4b1201306..329a37764 100644 --- a/test/libsolidity/semanticTests/immutable/read_in_ctor.sol +++ b/test/libsolidity/semanticTests/immutable/read_in_ctor.sol @@ -11,7 +11,5 @@ contract A { return x; } } -// ==== -// compileViaYul: also // ---- // readX() -> 3 diff --git a/test/libsolidity/semanticTests/immutable/small_types_in_reverse.sol b/test/libsolidity/semanticTests/immutable/small_types_in_reverse.sol index 677b87d32..167bd48a1 100644 --- a/test/libsolidity/semanticTests/immutable/small_types_in_reverse.sol +++ b/test/libsolidity/semanticTests/immutable/small_types_in_reverse.sol @@ -10,8 +10,6 @@ contract A { x = [a, b, c]; } } -// ==== -// compileViaYul: also // ---- // a() -> 4660 // b() -> 0x0f0f diff --git a/test/libsolidity/semanticTests/immutable/stub.sol b/test/libsolidity/semanticTests/immutable/stub.sol index eda441c75..092edfab4 100644 --- a/test/libsolidity/semanticTests/immutable/stub.sol +++ b/test/libsolidity/semanticTests/immutable/stub.sol @@ -9,7 +9,5 @@ contract C { return (x+x,y); } } -// ==== -// compileViaYul: also // ---- // f() -> 84, 23 diff --git a/test/libsolidity/semanticTests/immutable/use_scratch.sol b/test/libsolidity/semanticTests/immutable/use_scratch.sol index 9dec40935..364ac525e 100644 --- a/test/libsolidity/semanticTests/immutable/use_scratch.sol +++ b/test/libsolidity/semanticTests/immutable/use_scratch.sol @@ -13,12 +13,10 @@ contract C { return (x+x,y); } } -// ==== -// compileViaYul: also // ---- // constructor(): 3 -> -// gas irOptimized: 127454 -// gas legacy: 209361 -// gas legacyOptimized: 139324 +// gas irOptimized: 125477 +// gas legacy: 202011 +// gas legacyOptimized: 139552 // f() -> 84, 23 // m(uint256): 3 -> 7 diff --git a/test/libsolidity/semanticTests/inheritance/access_base_storage.sol b/test/libsolidity/semanticTests/inheritance/access_base_storage.sol index 014a19534..4b11c3598 100644 --- a/test/libsolidity/semanticTests/inheritance/access_base_storage.sol +++ b/test/libsolidity/semanticTests/inheritance/access_base_storage.sol @@ -24,7 +24,6 @@ contract Derived is Base { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // setData(uint256,uint256): 1, 2 -> true // getViaBase() -> 1 diff --git a/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol b/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol index 6a9ff7c31..fac3a61ad 100644 --- a/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol +++ b/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol @@ -19,8 +19,6 @@ contract D { } } -// ==== -// compileViaYul: also // ---- // f() -> 1 // gas irOptimized: 77051 diff --git a/test/libsolidity/semanticTests/inheritance/base_access_to_function_type_variables.sol b/test/libsolidity/semanticTests/inheritance/base_access_to_function_type_variables.sol index 6bf594a97..7b5e856d3 100644 --- a/test/libsolidity/semanticTests/inheritance/base_access_to_function_type_variables.sol +++ b/test/libsolidity/semanticTests/inheritance/base_access_to_function_type_variables.sol @@ -16,7 +16,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 2 // h() -> FAILURE, hex"4e487b71", 0x51 diff --git a/test/libsolidity/semanticTests/inheritance/derived_overload_base_function_direct.sol b/test/libsolidity/semanticTests/inheritance/derived_overload_base_function_direct.sol index c10180582..87571f2d0 100644 --- a/test/libsolidity/semanticTests/inheritance/derived_overload_base_function_direct.sol +++ b/test/libsolidity/semanticTests/inheritance/derived_overload_base_function_direct.sol @@ -17,6 +17,5 @@ contract C is B { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 2 diff --git a/test/libsolidity/semanticTests/inheritance/derived_overload_base_function_indirect.sol b/test/libsolidity/semanticTests/inheritance/derived_overload_base_function_indirect.sol index 6f0d1e449..23f01e419 100644 --- a/test/libsolidity/semanticTests/inheritance/derived_overload_base_function_indirect.sol +++ b/test/libsolidity/semanticTests/inheritance/derived_overload_base_function_indirect.sol @@ -24,7 +24,6 @@ contract C is A, B { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 10 // h() -> 2 diff --git a/test/libsolidity/semanticTests/inheritance/explicit_base_class.sol b/test/libsolidity/semanticTests/inheritance/explicit_base_class.sol index a45fc2379..4c5468f03 100644 --- a/test/libsolidity/semanticTests/inheritance/explicit_base_class.sol +++ b/test/libsolidity/semanticTests/inheritance/explicit_base_class.sol @@ -23,7 +23,6 @@ contract Derived is Base { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 3 // f() -> 1 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_constant_state_var.sol b/test/libsolidity/semanticTests/inheritance/inherited_constant_state_var.sol index 0373ca41a..256367df4 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_constant_state_var.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_constant_state_var.sol @@ -11,6 +11,5 @@ contract B is A { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 7 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_function.sol b/test/libsolidity/semanticTests/inheritance/inherited_function.sol index 655820edc..471fe7943 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function.sol @@ -16,6 +16,5 @@ contract B is A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 1 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 ed28477b2..cfa124c25 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol @@ -21,8 +21,6 @@ contract B { } } -// ==== -// compileViaYul: also // ---- // g() -> 42 // gas irOptimized: 80813 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory.sol b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory.sol index a9956cc80..a6274ed77 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory.sol @@ -17,7 +17,5 @@ contract B is A { return A(this).f(m); } } -// ==== -// compileViaYul: also // ---- // g() -> 23 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 2ce71c31f..388a4de42 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol @@ -21,10 +21,8 @@ contract B { } } -// ==== -// compileViaYul: also // ---- // g() -> 42 -// gas irOptimized: 101944 +// gas irOptimized: 100874 // gas legacy: 185053 // gas legacyOptimized: 114598 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_function_from_a_library.sol b/test/libsolidity/semanticTests/inheritance/inherited_function_from_a_library.sol index 3756a4e97..42d4f711c 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_from_a_library.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_from_a_library.sol @@ -15,7 +15,5 @@ contract B { } } -// ==== -// compileViaYul: also // ---- // g() -> 1 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_function_through_dispatch.sol b/test/libsolidity/semanticTests/inheritance/inherited_function_through_dispatch.sol index 36e4d33e5..e304fc281 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_through_dispatch.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_through_dispatch.sol @@ -17,6 +17,5 @@ contract B is A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 1 diff --git a/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol b/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol index a400531ca..44cbb1e14 100644 --- a/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol +++ b/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol @@ -18,8 +18,6 @@ contract A { } } -// ==== -// compileViaYul: also // ---- // g(int256): -1 -> -1 // gas legacy: 103494 diff --git a/test/libsolidity/semanticTests/inheritance/overloaded_function_call_resolve_to_first.sol b/test/libsolidity/semanticTests/inheritance/overloaded_function_call_resolve_to_first.sol index ee0c1dc16..b54f9bc27 100644 --- a/test/libsolidity/semanticTests/inheritance/overloaded_function_call_resolve_to_first.sol +++ b/test/libsolidity/semanticTests/inheritance/overloaded_function_call_resolve_to_first.sol @@ -14,6 +14,5 @@ contract test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 3 diff --git a/test/libsolidity/semanticTests/inheritance/overloaded_function_call_resolve_to_second.sol b/test/libsolidity/semanticTests/inheritance/overloaded_function_call_resolve_to_second.sol index 7dc307415..5479960ac 100644 --- a/test/libsolidity/semanticTests/inheritance/overloaded_function_call_resolve_to_second.sol +++ b/test/libsolidity/semanticTests/inheritance/overloaded_function_call_resolve_to_second.sol @@ -14,6 +14,5 @@ contract test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 10 diff --git a/test/libsolidity/semanticTests/inheritance/overloaded_function_call_with_if_else.sol b/test/libsolidity/semanticTests/inheritance/overloaded_function_call_with_if_else.sol index 5af1a28f0..70be159e8 100644 --- a/test/libsolidity/semanticTests/inheritance/overloaded_function_call_with_if_else.sol +++ b/test/libsolidity/semanticTests/inheritance/overloaded_function_call_with_if_else.sol @@ -15,7 +15,6 @@ contract test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g(bool): true -> 3 // g(bool): false -> 10 diff --git a/test/libsolidity/semanticTests/inheritance/pass_dynamic_arguments_to_the_base.sol b/test/libsolidity/semanticTests/inheritance/pass_dynamic_arguments_to_the_base.sol index e564c560c..7b8af54e9 100644 --- a/test/libsolidity/semanticTests/inheritance/pass_dynamic_arguments_to_the_base.sol +++ b/test/libsolidity/semanticTests/inheritance/pass_dynamic_arguments_to_the_base.sol @@ -14,7 +14,5 @@ contract Derived is Base { contract Final is Derived(4) {} -// ==== -// compileViaYul: also // ---- // m_i() -> 4 diff --git a/test/libsolidity/semanticTests/inheritance/pass_dynamic_arguments_to_the_base_base.sol b/test/libsolidity/semanticTests/inheritance/pass_dynamic_arguments_to_the_base_base.sol index 0ae3e1ce4..d028630e1 100644 --- a/test/libsolidity/semanticTests/inheritance/pass_dynamic_arguments_to_the_base_base.sol +++ b/test/libsolidity/semanticTests/inheritance/pass_dynamic_arguments_to_the_base_base.sol @@ -19,7 +19,5 @@ contract Derived is Base, Base1 { contract Final is Derived(4) {} -// ==== -// compileViaYul: also // ---- // m_i() -> 4 diff --git a/test/libsolidity/semanticTests/inheritance/pass_dynamic_arguments_to_the_base_base_with_gap.sol b/test/libsolidity/semanticTests/inheritance/pass_dynamic_arguments_to_the_base_base_with_gap.sol index def996344..221368f0d 100644 --- a/test/libsolidity/semanticTests/inheritance/pass_dynamic_arguments_to_the_base_base_with_gap.sol +++ b/test/libsolidity/semanticTests/inheritance/pass_dynamic_arguments_to_the_base_base_with_gap.sol @@ -19,7 +19,5 @@ contract Derived is Base, Base1 { contract Final is Derived(4) {} -// ==== -// compileViaYul: also // ---- // m_i() -> 4 diff --git a/test/libsolidity/semanticTests/inheritance/super_in_constructor.sol b/test/libsolidity/semanticTests/inheritance/super_in_constructor.sol index 6c2a4103d..c4b677453 100644 --- a/test/libsolidity/semanticTests/inheritance/super_in_constructor.sol +++ b/test/libsolidity/semanticTests/inheritance/super_in_constructor.sol @@ -32,6 +32,5 @@ contract D is B, C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 15 diff --git a/test/libsolidity/semanticTests/inheritance/super_in_constructor_assignment.sol b/test/libsolidity/semanticTests/inheritance/super_in_constructor_assignment.sol index 3bf4c590d..47978ddbc 100644 --- a/test/libsolidity/semanticTests/inheritance/super_in_constructor_assignment.sol +++ b/test/libsolidity/semanticTests/inheritance/super_in_constructor_assignment.sol @@ -35,6 +35,5 @@ contract D is B, C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 15 diff --git a/test/libsolidity/semanticTests/inheritance/super_overload.sol b/test/libsolidity/semanticTests/inheritance/super_overload.sol index 96ef08002..1bb36ca2a 100644 --- a/test/libsolidity/semanticTests/inheritance/super_overload.sol +++ b/test/libsolidity/semanticTests/inheritance/super_overload.sol @@ -24,7 +24,6 @@ contract C is A, B { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 10 // h() -> 2 diff --git a/test/libsolidity/semanticTests/inheritance/value_for_constructor.sol b/test/libsolidity/semanticTests/inheritance/value_for_constructor.sol index b38e9a6ad..8917ad68e 100644 --- a/test/libsolidity/semanticTests/inheritance/value_for_constructor.sol +++ b/test/libsolidity/semanticTests/inheritance/value_for_constructor.sol @@ -38,11 +38,9 @@ contract Main { } } -// ==== -// compileViaYul: also // ---- // constructor(), 22 wei -> -// gas irOptimized: 277680 +// gas irOptimized: 268544 // gas legacy: 402045 // gas legacyOptimized: 266772 // getFlag() -> true diff --git a/test/libsolidity/semanticTests/inlineAssembly/calldata_array_assign_dynamic.sol b/test/libsolidity/semanticTests/inlineAssembly/calldata_array_assign_dynamic.sol index 91eff04e0..631e61fe0 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/calldata_array_assign_dynamic.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/calldata_array_assign_dynamic.sol @@ -4,7 +4,5 @@ contract C { r = x; } } -// ==== -// compileViaYul: also // ---- // f(uint256[2][]): 0x0, 1, 8, 7, 6, 5 -> 0x20, 2, 8, 7, 6, 5 diff --git a/test/libsolidity/semanticTests/inlineAssembly/calldata_array_assign_static.sol b/test/libsolidity/semanticTests/inlineAssembly/calldata_array_assign_static.sol index 3c0437819..32931be18 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/calldata_array_assign_static.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/calldata_array_assign_static.sol @@ -4,7 +4,5 @@ contract C { r = x; } } -// ==== -// compileViaYul: also // ---- // f(uint256[2][2]): 0x0, 8, 7, 6, 5 -> 8, 7, 6, 5 diff --git a/test/libsolidity/semanticTests/inlineAssembly/calldata_array_read.sol b/test/libsolidity/semanticTests/inlineAssembly/calldata_array_read.sol index bdb3ba51a..21b52f84e 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/calldata_array_read.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/calldata_array_read.sol @@ -8,6 +8,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256[2][]): 0x20, 2, 1, 2, 3, 4 -> 0x44, 2, 0x84 diff --git a/test/libsolidity/semanticTests/inlineAssembly/calldata_assign.sol b/test/libsolidity/semanticTests/inlineAssembly/calldata_assign.sol index f17dd975c..f5d557e55 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/calldata_assign.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/calldata_assign.sol @@ -4,7 +4,5 @@ contract C { return x; } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 0, 0 -> 0x20, 3, 0x5754f80000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/inlineAssembly/calldata_assign_from_nowhere.sol b/test/libsolidity/semanticTests/inlineAssembly/calldata_assign_from_nowhere.sol index 1b559f27b..876fffd42 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/calldata_assign_from_nowhere.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/calldata_assign_from_nowhere.sol @@ -3,7 +3,5 @@ contract C { assembly { x.offset := 0 x.length := 4 } } } -// ==== -// compileViaYul: also // ---- // f() -> 0x20, 4, 0x26121ff000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/inlineAssembly/calldata_length_read.sol b/test/libsolidity/semanticTests/inlineAssembly/calldata_length_read.sol index 559421f78..04ec0b614 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/calldata_length_read.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/calldata_length_read.sol @@ -9,7 +9,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // lenBytesRead(bytes): 0x20, 4, "abcd" -> 4 // lenBytesRead(bytes): 0x20, 0, "abcd" -> 0x00 diff --git a/test/libsolidity/semanticTests/inlineAssembly/calldata_offset_read.sol b/test/libsolidity/semanticTests/inlineAssembly/calldata_offset_read.sol index d819ff68b..a9b82d11e 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/calldata_offset_read.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/calldata_offset_read.sol @@ -12,7 +12,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bytes): 0x20, 0, 0 -> 0x44 // f(bytes): 0x22, 0, 0, 0 -> 0x46 diff --git a/test/libsolidity/semanticTests/inlineAssembly/calldata_offset_read_write.sol b/test/libsolidity/semanticTests/inlineAssembly/calldata_offset_read_write.sol index 036c1af32..6375055fe 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/calldata_offset_read_write.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/calldata_offset_read_write.sol @@ -13,7 +13,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256,bytes,uint256): 7, 0x60, 8, 2, 0 -> 8, 0x14 // f(uint256,bytes,uint256): 0, 0, 0 -> 8, 0x14 diff --git a/test/libsolidity/semanticTests/inlineAssembly/calldata_struct_assign.sol b/test/libsolidity/semanticTests/inlineAssembly/calldata_struct_assign.sol index bc8f9ffb7..96c01ae58 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/calldata_struct_assign.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/calldata_struct_assign.sol @@ -12,7 +12,5 @@ contract C { r2 = s2.x; } } -// ==== -// compileViaYul: also // ---- // f((uint256),(uint256,uint256)): 0x42, 0x07, 0x77 -> 0x07, 0x42 diff --git a/test/libsolidity/semanticTests/inlineAssembly/calldata_struct_assign_and_return.sol b/test/libsolidity/semanticTests/inlineAssembly/calldata_struct_assign_and_return.sol index 56a67f383..4c699bc40 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/calldata_struct_assign_and_return.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/calldata_struct_assign_and_return.sol @@ -13,8 +13,6 @@ contract C { function h() public pure returns(uint256) { f(); return 0x42; } function i() public pure returns(uint256) { abi.decode(msg.data[4:], (S)); return 0x42; } } -// ==== -// compileViaYul: also // ---- // g(): 0xCAFFEE, 0x42, 0x21 -> 0x42, 0x21 // g(): 0xCAFFEE, 0x4242, 0x2121 -> FAILURE diff --git a/test/libsolidity/semanticTests/inlineAssembly/chainid.sol b/test/libsolidity/semanticTests/inlineAssembly/chainid.sol index 8e6a36835..f93d87c99 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/chainid.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/chainid.sol @@ -7,6 +7,5 @@ contract C { } // ==== // EVMVersion: >=istanbul -// compileViaYul: also // ---- // f() -> 1 diff --git a/test/libsolidity/semanticTests/inlineAssembly/constant_access.sol b/test/libsolidity/semanticTests/inlineAssembly/constant_access.sol index 93b9566c2..130ebcd33 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/constant_access.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/constant_access.sol @@ -16,6 +16,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 2, left(0xabcd), left(0x616263), true, 0x1212121212121212121212121212121212121212 diff --git a/test/libsolidity/semanticTests/inlineAssembly/constant_access_referencing.sol b/test/libsolidity/semanticTests/inlineAssembly/constant_access_referencing.sol index ccf213f28..91644d1ac 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/constant_access_referencing.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/constant_access_referencing.sol @@ -24,6 +24,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 2, left(0xabcd), left(0x616263), true, 0x1212121212121212121212121212121212121212 diff --git a/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_address.sol b/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_address.sol index 7c3ad6d50..d0461363c 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_address.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_address.sol @@ -12,8 +12,6 @@ contract C { return this.testFunction.address; } } -// ==== -// compileViaYul: also // ---- // testYul() -> 0x0fdd67305928fcac8d213d1e47bfa6165cd0b87b // testSol() -> 0x0fdd67305928fcac8d213d1e47bfa6165cd0b87b diff --git a/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_address_assignment.sol b/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_address_assignment.sol index 7550e7785..eb28a6d20 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_address_assignment.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_address_assignment.sol @@ -11,8 +11,6 @@ contract C { return fp.address; } } -// ==== -// compileViaYul: also // ---- // testYul(address): 0x1234567890 -> 0x1234567890 // testYul(address): 0xC0FFEE3EA7 -> 0xC0FFEE3EA7 diff --git a/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_selector.sol b/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_selector.sol index 99ba2370f..2fa372f81 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_selector.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_selector.sol @@ -16,8 +16,6 @@ contract C { return uint32(this.testFunction.selector); } } -// ==== -// compileViaYul: also // ---- // testYul() -> 0xe16b4a9b // testSol() -> 0xe16b4a9b diff --git a/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_selector_assignment.sol b/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_selector_assignment.sol index 3bec26382..a8e886147 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_selector_assignment.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/external_function_pointer_selector_assignment.sol @@ -11,8 +11,6 @@ contract C { return uint32(fp.selector); } } -// ==== -// compileViaYul: also // ---- // testYul(uint32): 0x12345678 -> 0x12345678 // testYul(uint32): 0xABCDEF00 -> 0xABCDEF00 diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_embedded_function_call.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_embedded_function_call.sol index ca6b39f86..5d917437e 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_embedded_function_call.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_embedded_function_call.sol @@ -23,6 +23,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x1, 0x4, 0x7, 0x10 diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_for.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_for.sol index e869a9746..d074e677f 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_for.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_for.sol @@ -18,7 +18,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 0 -> 1 // f(uint256): 1 -> 1 diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_for2.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_for2.sol index 15f9f6abb..c4af2ea5f 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_for2.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_for2.sol @@ -23,7 +23,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 0 -> 0, 2, 0 // f(uint256): 1 -> 1, 4, 3 diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_function_call.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_function_call.sol index 52870e085..48cceeb99 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_function_call.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_function_call.sol @@ -17,6 +17,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1, 2, 7 diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_function_call2.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_function_call2.sol index a934d4bae..caf441dd4 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_function_call2.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_function_call2.sol @@ -20,6 +20,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x1, 0x2, 0x7, 0x10 diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_function_call_assignment.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_function_call_assignment.sol index 648b6872e..675ec3b1d 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_function_call_assignment.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_function_call_assignment.sol @@ -19,6 +19,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1, 2, 7 diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_if.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_if.sol index 785b42aa9..852f10ac8 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_if.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_if.sol @@ -10,7 +10,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 0 -> 0 // f(uint256): 1 -> 0 diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_in_modifiers.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_in_modifiers.sol index 48aafefe2..f74fbbc63 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_in_modifiers.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_in_modifiers.sol @@ -29,7 +29,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_memory_access.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_memory_access.sol index 1efae8b68..448cc3991 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_memory_access.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_memory_access.sol @@ -11,6 +11,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 0x20, 0x5, "12345" diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_read_and_write_stack.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_read_and_write_stack.sol index 9f621e23f..58c77a81d 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_read_and_write_stack.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_read_and_write_stack.sol @@ -9,6 +9,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 45 diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_recursion.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_recursion.sol index aff4dc7aa..c3c9297bc 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_recursion.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_recursion.sol @@ -20,7 +20,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 0 -> 1 // f(uint256): 1 -> 1 diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access.sol index 819ab391c..d81bff29e 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access.sol @@ -18,7 +18,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> true // z() -> 7 diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_inside_function.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_inside_function.sol index f9038252b..dda8565b7 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_inside_function.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_inside_function.sol @@ -19,7 +19,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> true // z() -> 7 diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_local_var.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_local_var.sol index fcc6fcc64..5544d90ef 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_local_var.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_local_var.sol @@ -14,6 +14,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 7 diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_via_pointer.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_via_pointer.sol index f482b650c..687b1d914 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_via_pointer.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_storage_access_via_pointer.sol @@ -20,7 +20,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> true // a() -> 7 diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_switch.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_switch.sol index 1cc2dfda4..e4d8419b4 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_switch.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_switch.sol @@ -17,7 +17,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 0 -> 2 // f(uint256): 1 -> 8 diff --git a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_write_to_stack.sol b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_write_to_stack.sol index d7651f273..b181f8259 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_write_to_stack.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inline_assembly_write_to_stack.sol @@ -9,6 +9,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 7, "abcdef" diff --git a/test/libsolidity/semanticTests/inlineAssembly/inlineasm_empty_let.sol b/test/libsolidity/semanticTests/inlineAssembly/inlineasm_empty_let.sol index d23413bac..b9aa70aed 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/inlineasm_empty_let.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/inlineasm_empty_let.sol @@ -11,6 +11,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0, 0 diff --git a/test/libsolidity/semanticTests/inlineAssembly/keccak256_assembly.sol b/test/libsolidity/semanticTests/inlineAssembly/keccak256_assembly.sol index d4034f10b..741d03a8b 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/keccak256_assembly.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/keccak256_assembly.sol @@ -6,7 +6,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f() -> 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 diff --git a/test/libsolidity/semanticTests/inlineAssembly/keccak256_optimization.sol b/test/libsolidity/semanticTests/inlineAssembly/keccak256_optimization.sol index 59b32a4c9..2a245b35c 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/keccak256_optimization.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/keccak256_optimization.sol @@ -10,7 +10,5 @@ contract C { } } } -// ==== -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/inlineAssembly/keccak256_optimizer_bug_different_memory_location.sol b/test/libsolidity/semanticTests/inlineAssembly/keccak256_optimizer_bug_different_memory_location.sol index 1e9847be3..233e4f727 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/keccak256_optimizer_bug_different_memory_location.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/keccak256_optimizer_bug_different_memory_location.sol @@ -10,7 +10,5 @@ contract C { } } } -// ==== -// compileViaYul: also // ---- // f() -> false diff --git a/test/libsolidity/semanticTests/inlineAssembly/keccak256_optimizer_cache_bug.sol b/test/libsolidity/semanticTests/inlineAssembly/keccak256_optimizer_cache_bug.sol index 545ad3617..4023a809b 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/keccak256_optimizer_cache_bug.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/keccak256_optimizer_cache_bug.sol @@ -15,7 +15,5 @@ contract C { return true; } } -// ==== -// compileViaYul: also // ---- // val() -> true diff --git a/test/libsolidity/semanticTests/inlineAssembly/keccak_optimization_bug_string.sol b/test/libsolidity/semanticTests/inlineAssembly/keccak_optimization_bug_string.sol index 009b514e0..35f8ae5ec 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/keccak_optimization_bug_string.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/keccak_optimization_bug_string.sol @@ -7,8 +7,6 @@ contract C { } } } -// ==== -// compileViaYul: also // ---- // f(string): "" -> false // f(string): 0x20, 5, "hello" -> false diff --git a/test/libsolidity/semanticTests/inlineAssembly/keccak_yul_optimization.sol b/test/libsolidity/semanticTests/inlineAssembly/keccak_yul_optimization.sol index 85a93b3dc..88088bbda 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/keccak_yul_optimization.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/keccak_yul_optimization.sol @@ -22,8 +22,6 @@ contract C { } } } -// ==== -// compileViaYul: also // ---- // f() -> 0xcdb56c384a9682c600315e3470157a4cf7638d0d33e9dae5c40ffd2644fc5a80 // gas irOptimized: 22239 diff --git a/test/libsolidity/semanticTests/inlineAssembly/leave.sol b/test/libsolidity/semanticTests/inlineAssembly/leave.sol index fab19f230..f007368ad 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/leave.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/leave.sol @@ -12,6 +12,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 2 diff --git a/test/libsolidity/semanticTests/inlineAssembly/optimize_memory_store_multi_block.sol b/test/libsolidity/semanticTests/inlineAssembly/optimize_memory_store_multi_block.sol new file mode 100644 index 000000000..1a72925d6 --- /dev/null +++ b/test/libsolidity/semanticTests/inlineAssembly/optimize_memory_store_multi_block.sol @@ -0,0 +1,29 @@ +contract C { + function f() external returns (uint256 x) { + assembly { + mstore(0, 0x42) + } + assembly { + x := mload(0) + } + } + function g() external returns (bool) { + uint initialFreeMemoryPointer; + assembly { + initialFreeMemoryPointer := mload(0x40) + } + assembly { + let ptr := mload(0x40) + mstore(0x40, add(ptr, 0x20)) + } + uint finalFreeMemoryPointer; + assembly { + finalFreeMemoryPointer := mload(0x40) + } + assert(initialFreeMemoryPointer != finalFreeMemoryPointer); + return true; + } +} +// ---- +// f() -> 0x42 +// g() -> true diff --git a/test/libsolidity/semanticTests/inlineAssembly/optimize_memory_store_multi_block_bugreport.sol b/test/libsolidity/semanticTests/inlineAssembly/optimize_memory_store_multi_block_bugreport.sol new file mode 100644 index 000000000..023d178a9 --- /dev/null +++ b/test/libsolidity/semanticTests/inlineAssembly/optimize_memory_store_multi_block_bugreport.sol @@ -0,0 +1,23 @@ +contract Test { + uint256 x; + + function test() public returns (uint256) { + uint256 a = myGetX(); + x = 5; + uint256 b = myGetX(); + assembly { + log0(0, 64) + } + return a + b + myGetX(); + } + + function myGetX() internal view returns (uint256) { + assembly { + mstore(1, 0x123456789abcdef) + } + return x; + } +} +// ---- +// test() -> 10 +// ~ emit : 0x0123456789abcd, 0xef00000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/inlineAssembly/selfbalance.sol b/test/libsolidity/semanticTests/inlineAssembly/selfbalance.sol index b16678833..1637de5b9 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/selfbalance.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/selfbalance.sol @@ -7,6 +7,5 @@ contract C { } // ==== // EVMVersion: >=istanbul -// compileViaYul: also // ---- // f(), 254 wei -> 254 diff --git a/test/libsolidity/semanticTests/inlineAssembly/shadowing_local_function_opcode.sol b/test/libsolidity/semanticTests/inlineAssembly/shadowing_local_function_opcode.sol index 862088e17..ea24ec6c4 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/shadowing_local_function_opcode.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/shadowing_local_function_opcode.sol @@ -8,7 +8,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // g() -> 7, 3 diff --git a/test/libsolidity/semanticTests/inlineAssembly/slot_access.sol b/test/libsolidity/semanticTests/inlineAssembly/slot_access.sol index a1f9874eb..abfc6d09b 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/slot_access.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/slot_access.sol @@ -25,8 +25,6 @@ contract C { return data().a; } } -// ==== -// compileViaYul: also // ---- // get() -> 0 // mappingAccess(uint256): 1 -> 0, 0 diff --git a/test/libsolidity/semanticTests/inlineAssembly/truefalse.sol b/test/libsolidity/semanticTests/inlineAssembly/truefalse.sol index 4741538b6..eb57b8092 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/truefalse.sol +++ b/test/libsolidity/semanticTests/inlineAssembly/truefalse.sol @@ -8,6 +8,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1, 0 diff --git a/test/libsolidity/semanticTests/integer/basic.sol b/test/libsolidity/semanticTests/integer/basic.sol index b7272365a..b03cb20f2 100644 --- a/test/libsolidity/semanticTests/integer/basic.sol +++ b/test/libsolidity/semanticTests/integer/basic.sol @@ -20,6 +20,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // basic() -> true diff --git a/test/libsolidity/semanticTests/integer/int.sol b/test/libsolidity/semanticTests/integer/int.sol index 13db801ec..770fa0be7 100644 --- a/test/libsolidity/semanticTests/integer/int.sol +++ b/test/libsolidity/semanticTests/integer/int.sol @@ -234,7 +234,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // intMinA() -> true // intMinB() -> true diff --git a/test/libsolidity/semanticTests/integer/many_local_variables.sol b/test/libsolidity/semanticTests/integer/many_local_variables.sol index 4f05c9d8f..0f3f0f642 100644 --- a/test/libsolidity/semanticTests/integer/many_local_variables.sol +++ b/test/libsolidity/semanticTests/integer/many_local_variables.sol @@ -7,6 +7,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // run(uint256,uint256,uint256): 0x1000, 0x10000, 0x100000 -> 0x121121 diff --git a/test/libsolidity/semanticTests/integer/small_signed_types.sol b/test/libsolidity/semanticTests/integer/small_signed_types.sol index b807de551..e1173b955 100644 --- a/test/libsolidity/semanticTests/integer/small_signed_types.sol +++ b/test/libsolidity/semanticTests/integer/small_signed_types.sol @@ -5,6 +5,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // run() -> 200 diff --git a/test/libsolidity/semanticTests/integer/uint.sol b/test/libsolidity/semanticTests/integer/uint.sol index 1855ae4b7..2fa602806 100644 --- a/test/libsolidity/semanticTests/integer/uint.sol +++ b/test/libsolidity/semanticTests/integer/uint.sol @@ -233,7 +233,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // uintMinA() -> true // uintMinB() -> true diff --git a/test/libsolidity/semanticTests/interfaceID/homer.sol b/test/libsolidity/semanticTests/interfaceID/homer.sol index df95816fe..49b60b12f 100644 --- a/test/libsolidity/semanticTests/interfaceID/homer.sol +++ b/test/libsolidity/semanticTests/interfaceID/homer.sol @@ -31,7 +31,6 @@ contract Homer is ERC165, Simpson { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // supportsInterface(bytes4): left(0x01ffc9a0) -> false // supportsInterface(bytes4): left(0x01ffc9a7) -> true diff --git a/test/libsolidity/semanticTests/interfaceID/homer_interfaceId.sol b/test/libsolidity/semanticTests/interfaceID/homer_interfaceId.sol index 5849e6182..9bf0e3c59 100644 --- a/test/libsolidity/semanticTests/interfaceID/homer_interfaceId.sol +++ b/test/libsolidity/semanticTests/interfaceID/homer_interfaceId.sol @@ -31,7 +31,6 @@ contract Homer is ERC165, Simpson { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // supportsInterface(bytes4): left(0x01ffc9a0) -> false // supportsInterface(bytes4): left(0x01ffc9a7) -> true diff --git a/test/libsolidity/semanticTests/interfaceID/interfaceId_events.sol b/test/libsolidity/semanticTests/interfaceID/interfaceId_events.sol index 6509c884b..51d48f497 100644 --- a/test/libsolidity/semanticTests/interfaceID/interfaceId_events.sol +++ b/test/libsolidity/semanticTests/interfaceID/interfaceId_events.sol @@ -16,7 +16,6 @@ contract Test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // hello_world() -> left(0xc6be8b58) // hello_world_with_event() -> left(0xc6be8b58) diff --git a/test/libsolidity/semanticTests/interfaceID/interfaces.sol b/test/libsolidity/semanticTests/interfaceID/interfaces.sol index 9a203fb76..77cf83707 100644 --- a/test/libsolidity/semanticTests/interfaceID/interfaces.sol +++ b/test/libsolidity/semanticTests/interfaceID/interfaces.sol @@ -53,7 +53,6 @@ contract Test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // hello() -> left(0x19ff1d21) // world() -> left(0xdf419679) diff --git a/test/libsolidity/semanticTests/interfaceID/lisa.sol b/test/libsolidity/semanticTests/interfaceID/lisa.sol index 7c50b5f16..885cf9b24 100644 --- a/test/libsolidity/semanticTests/interfaceID/lisa.sol +++ b/test/libsolidity/semanticTests/interfaceID/lisa.sol @@ -40,8 +40,6 @@ contract Lisa is ERC165MappingImplementation, Simpson { } } -// ==== -// compileViaYul: also // ---- // supportsInterface(bytes4): left(0x01ffc9a0) -> false // supportsInterface(bytes4): left(0x01ffc9a7) -> true diff --git a/test/libsolidity/semanticTests/interfaceID/lisa_interfaceId.sol b/test/libsolidity/semanticTests/interfaceID/lisa_interfaceId.sol index c535df528..c9a7c4905 100644 --- a/test/libsolidity/semanticTests/interfaceID/lisa_interfaceId.sol +++ b/test/libsolidity/semanticTests/interfaceID/lisa_interfaceId.sol @@ -40,8 +40,6 @@ contract Lisa is ERC165MappingImplementation, Simpson { } } -// ==== -// compileViaYul: also // ---- // supportsInterface(bytes4): left(0x01ffc9a0) -> false // supportsInterface(bytes4): left(0x01ffc9a7) -> true diff --git a/test/libsolidity/semanticTests/interface_inheritance_conversions.sol b/test/libsolidity/semanticTests/interface_inheritance_conversions.sol index 95f831e24..70c7fac40 100644 --- a/test/libsolidity/semanticTests/interface_inheritance_conversions.sol +++ b/test/libsolidity/semanticTests/interface_inheritance_conversions.sol @@ -33,8 +33,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // convertParent() -> 1 // gas irOptimized: 85524 diff --git a/test/libsolidity/semanticTests/isoltestFormatting.sol b/test/libsolidity/semanticTests/isoltestFormatting.sol index 9206eb7c1..88ec15f57 100644 --- a/test/libsolidity/semanticTests/isoltestFormatting.sol +++ b/test/libsolidity/semanticTests/isoltestFormatting.sol @@ -10,7 +10,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 4, 11, 0x0111, 0x333333, 2222222222222222222 // g() -> 0x10, 0x0100, 0x0101, 0x333333, 2222222222222222222 diff --git a/test/libsolidity/semanticTests/isoltestTesting/account.sol b/test/libsolidity/semanticTests/isoltestTesting/account.sol index 0703f4a37..7b6c55b1e 100644 --- a/test/libsolidity/semanticTests/isoltestTesting/account.sol +++ b/test/libsolidity/semanticTests/isoltestTesting/account.sol @@ -3,8 +3,6 @@ contract AccountBuiltinTest { result = msg.sender; } } -// ==== -// compileViaYul: also // ---- // constructor() // account: 0 -> 0x1212121212121212121212121212120000000012 diff --git a/test/libsolidity/semanticTests/isoltestTesting/balance_other_contract.sol b/test/libsolidity/semanticTests/isoltestTesting/balance_other_contract.sol index b02e48804..c536367a4 100644 --- a/test/libsolidity/semanticTests/isoltestTesting/balance_other_contract.sol +++ b/test/libsolidity/semanticTests/isoltestTesting/balance_other_contract.sol @@ -14,11 +14,9 @@ contract ClientReceipt { return other.getAddress(); } } -// ==== -// compileViaYul: also // ---- // constructor(), 2000 wei -> -// gas irOptimized: 183544 +// gas irOptimized: 173106 // gas legacy: 235195 // gas legacyOptimized: 176766 // balance -> 1500 diff --git a/test/libsolidity/semanticTests/isoltestTesting/balance_with_balance.sol b/test/libsolidity/semanticTests/isoltestTesting/balance_with_balance.sol index 5b6324910..3fd67d57c 100644 --- a/test/libsolidity/semanticTests/isoltestTesting/balance_with_balance.sol +++ b/test/libsolidity/semanticTests/isoltestTesting/balance_with_balance.sol @@ -1,8 +1,6 @@ contract ClientReceipt { constructor() payable {} } -// ==== -// compileViaYul: also // ---- // constructor(), 1000 wei -> // balance -> 1000 diff --git a/test/libsolidity/semanticTests/isoltestTesting/balance_with_balance2.sol b/test/libsolidity/semanticTests/isoltestTesting/balance_with_balance2.sol index f7d62afe5..4b940fe86 100644 --- a/test/libsolidity/semanticTests/isoltestTesting/balance_with_balance2.sol +++ b/test/libsolidity/semanticTests/isoltestTesting/balance_with_balance2.sol @@ -1,8 +1,6 @@ contract ClientReceipt { constructor() payable {} } -// ==== -// compileViaYul: also // ---- // constructor(), 1 ether -> // balance -> 1000000000000000000 diff --git a/test/libsolidity/semanticTests/isoltestTesting/balance_without_balance.sol b/test/libsolidity/semanticTests/isoltestTesting/balance_without_balance.sol index b89977035..222fba4ec 100644 --- a/test/libsolidity/semanticTests/isoltestTesting/balance_without_balance.sol +++ b/test/libsolidity/semanticTests/isoltestTesting/balance_without_balance.sol @@ -1,7 +1,5 @@ contract ClientReceipt { } -// ==== -// compileViaYul: also // ---- // balance -> 0 // balance: 0x0000000000000000000000000000000000000000 -> 0 diff --git a/test/libsolidity/semanticTests/isoltestTesting/builtins.sol b/test/libsolidity/semanticTests/isoltestTesting/builtins.sol index c34cfa4e4..e8faa0cc4 100644 --- a/test/libsolidity/semanticTests/isoltestTesting/builtins.sol +++ b/test/libsolidity/semanticTests/isoltestTesting/builtins.sol @@ -1,6 +1,4 @@ contract SmokeTest { } -// ==== -// compileViaYul: also // ---- // isoltest_builtin_test -> 0x1234 diff --git a/test/libsolidity/semanticTests/isoltestTesting/effects.sol b/test/libsolidity/semanticTests/isoltestTesting/effects.sol index 0f00e5de8..c9ab6c3eb 100644 --- a/test/libsolidity/semanticTests/isoltestTesting/effects.sol +++ b/test/libsolidity/semanticTests/isoltestTesting/effects.sol @@ -1,7 +1,5 @@ contract SmokeTest { } -// ==== -// compileViaYul: also // ---- // isoltest_side_effects_test -> 0 // isoltest_side_effects_test: 0x1234 -> 0x1234 diff --git a/test/libsolidity/semanticTests/isoltestTesting/format_raw_string_with_control_chars.sol b/test/libsolidity/semanticTests/isoltestTesting/format_raw_string_with_control_chars.sol index 205a4ae3d..a230cc9ab 100644 --- a/test/libsolidity/semanticTests/isoltestTesting/format_raw_string_with_control_chars.sol +++ b/test/libsolidity/semanticTests/isoltestTesting/format_raw_string_with_control_chars.sol @@ -6,7 +6,5 @@ contract C { // NOTE: The test is here to illustrate the problem with formatting control chars in strings in // test expectations but unfortunately it can only be triggered manually. It does not test anything // unless you introduce a difference in expectations to force isoltest to reformat them. -// ==== -// compileViaYul: also // ---- // f(string): 0x20, 16, "\xf0\x9f\x98\x83\xf0\x9f\x98\x83\xf0\x9f\x98\x83\xf0\x9f\x98\x83" -> 0x20, 16, "\xf0\x9f\x98\x83\xf0\x9f\x98\x83\xf0\x9f\x98\x83\xf0\x9f\x98\x83" # Input/Output: "😃😃😃😃" # diff --git a/test/libsolidity/semanticTests/isoltestTesting/storage/storage_empty.sol b/test/libsolidity/semanticTests/isoltestTesting/storage/storage_empty.sol index 8fd5a635e..11832a519 100644 --- a/test/libsolidity/semanticTests/isoltestTesting/storage/storage_empty.sol +++ b/test/libsolidity/semanticTests/isoltestTesting/storage/storage_empty.sol @@ -1,6 +1,4 @@ contract StorageEmpty { } -// ==== -// compileViaYul: also // ---- // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/isoltestTesting/storage/storage_nonempty.sol b/test/libsolidity/semanticTests/isoltestTesting/storage/storage_nonempty.sol index 9c8a582e7..33b1a4d69 100644 --- a/test/libsolidity/semanticTests/isoltestTesting/storage/storage_nonempty.sol +++ b/test/libsolidity/semanticTests/isoltestTesting/storage/storage_nonempty.sol @@ -2,8 +2,6 @@ contract StorageNotEmpty { uint256 x; function set(uint256 _a) public { x = _a; } } -// ==== -// compileViaYul: also // ---- // storageEmpty -> 1 // set(uint256): 1 -> diff --git a/test/libsolidity/semanticTests/libraries/bound_returning_calldata.sol b/test/libsolidity/semanticTests/libraries/bound_returning_calldata.sol index 6cd9045b4..5c32d31e7 100644 --- a/test/libsolidity/semanticTests/libraries/bound_returning_calldata.sol +++ b/test/libsolidity/semanticTests/libraries/bound_returning_calldata.sol @@ -13,7 +13,5 @@ contract C { return (_x.f()[0], _x.g()[0]); } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 4, "abcd" -> 0x6100000000000000000000000000000000000000000000000000000000000000, 0x6100000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/libraries/bound_returning_calldata_external.sol b/test/libsolidity/semanticTests/libraries/bound_returning_calldata_external.sol index e3c6d9b39..c194af882 100644 --- a/test/libsolidity/semanticTests/libraries/bound_returning_calldata_external.sol +++ b/test/libsolidity/semanticTests/libraries/bound_returning_calldata_external.sol @@ -15,7 +15,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // library: D // f(bytes): 0x20, 4, "abcd" -> 0x6100000000000000000000000000000000000000000000000000000000000000, 0x6100000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/libraries/bound_to_calldata.sol b/test/libsolidity/semanticTests/libraries/bound_to_calldata.sol index b80d2fdc7..bc9e11de1 100644 --- a/test/libsolidity/semanticTests/libraries/bound_to_calldata.sol +++ b/test/libsolidity/semanticTests/libraries/bound_to_calldata.sol @@ -13,7 +13,5 @@ contract C { return (_x.f(), _x.g()); } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 4, "abcd" -> 0x6100000000000000000000000000000000000000000000000000000000000000, 0x6100000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/libraries/bound_to_calldata_external.sol b/test/libsolidity/semanticTests/libraries/bound_to_calldata_external.sol index 33a53f48f..1c1f0457f 100644 --- a/test/libsolidity/semanticTests/libraries/bound_to_calldata_external.sol +++ b/test/libsolidity/semanticTests/libraries/bound_to_calldata_external.sol @@ -15,7 +15,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // library: D // f(bytes): 0x20, 4, "abcd" -> 0x6100000000000000000000000000000000000000000000000000000000000000, 0x6100000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/libraries/external_call_with_function_pointer_parameter.sol b/test/libsolidity/semanticTests/libraries/external_call_with_function_pointer_parameter.sol index a0843bfcb..1808d6139 100644 --- a/test/libsolidity/semanticTests/libraries/external_call_with_function_pointer_parameter.sol +++ b/test/libsolidity/semanticTests/libraries/external_call_with_function_pointer_parameter.sol @@ -19,8 +19,6 @@ contract C { return L.run(this.double, _value); } } -// ==== -// compileViaYul: also // ---- // library: L // g(uint256): 4 -> 16 diff --git a/test/libsolidity/semanticTests/libraries/external_call_with_storage_array_parameter.sol b/test/libsolidity/semanticTests/libraries/external_call_with_storage_array_parameter.sol index 81268af7a..e842fecaf 100644 --- a/test/libsolidity/semanticTests/libraries/external_call_with_storage_array_parameter.sol +++ b/test/libsolidity/semanticTests/libraries/external_call_with_storage_array_parameter.sol @@ -12,8 +12,6 @@ contract C { return L.f(x); } } -// ==== -// compileViaYul: also // ---- // library: L // g(uint256): 4 -> 16 diff --git a/test/libsolidity/semanticTests/libraries/external_call_with_storage_mapping_parameter.sol b/test/libsolidity/semanticTests/libraries/external_call_with_storage_mapping_parameter.sol index 821aebea7..d009bed5c 100644 --- a/test/libsolidity/semanticTests/libraries/external_call_with_storage_mapping_parameter.sol +++ b/test/libsolidity/semanticTests/libraries/external_call_with_storage_mapping_parameter.sol @@ -12,8 +12,6 @@ contract C { return L.f(x); } } -// ==== -// compileViaYul: also // ---- // library: L // g(uint256): 4 -> 16 diff --git a/test/libsolidity/semanticTests/libraries/internal_call_bound_with_parentheses.sol b/test/libsolidity/semanticTests/libraries/internal_call_bound_with_parentheses.sol index 6d073c627..43ce7ea66 100644 --- a/test/libsolidity/semanticTests/libraries/internal_call_bound_with_parentheses.sol +++ b/test/libsolidity/semanticTests/libraries/internal_call_bound_with_parentheses.sol @@ -21,7 +21,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f() -> 0x0a diff --git a/test/libsolidity/semanticTests/libraries/internal_call_bound_with_parentheses1.sol b/test/libsolidity/semanticTests/libraries/internal_call_bound_with_parentheses1.sol index 514cea6ba..4de0f4dc9 100644 --- a/test/libsolidity/semanticTests/libraries/internal_call_bound_with_parentheses1.sol +++ b/test/libsolidity/semanticTests/libraries/internal_call_bound_with_parentheses1.sol @@ -10,7 +10,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // foo() -> 3 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function.sol b/test/libsolidity/semanticTests/libraries/internal_library_function.sol index 8e8d561e9..a3c8a8700 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function.sol @@ -17,7 +17,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f() -> 2 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound.sol index a6ea94fed..f59ec9440 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound.sol @@ -22,7 +22,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f() -> 2 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_address.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_address.sol index ffb854e07..c5581b799 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_address.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_address.sol @@ -11,8 +11,6 @@ contract C { return a.equals(b); } } -// ==== -// compileViaYul: also // ---- // foo(address,address): 0x111122223333444455556666777788889999aAaa, 0x111122223333444455556666777788889999aAaa -> true // foo(address,address): 0x111122223333444455556666777788889999aAaa, 0x0000000000000000000000000000000000000000 -> false diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_address_named_send_transfer.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_address_named_send_transfer.sol index bfc5a3d62..a4facc02a 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_address_named_send_transfer.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_address_named_send_transfer.sol @@ -14,8 +14,6 @@ contract C { a.send(); } } -// ==== -// compileViaYul: also // ---- // useTransfer(address): 0x111122223333444455556666777788889999aAaa -> // useSend(address): 0x111122223333444455556666777788889999aAaa -> diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_array_named_pop_push.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_array_named_pop_push.sol index c684cc77f..80e0153b6 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_array_named_pop_push.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_array_named_pop_push.sol @@ -13,7 +13,5 @@ contract C { input.pop(); } } -// ==== -// compileViaYul: also // ---- // test() -> diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_bool.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_bool.sol index 33f5535ce..bf49f4e7b 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_bool.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_bool.sol @@ -11,8 +11,6 @@ contract C { return a.xor(b); } } -// ==== -// compileViaYul: also // ---- // foo(bool,bool): true, true -> false // foo(bool,bool): true, false -> true diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_contract.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_contract.sol index a9566ca59..afe9b0deb 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_contract.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_contract.sol @@ -15,7 +15,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // test() -> 42 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_dynamic_array.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_dynamic_array.sol index 0ea7e4144..f759ea78d 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_dynamic_array.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_dynamic_array.sol @@ -15,7 +15,5 @@ contract C { return input.at(1); } } -// ==== -// compileViaYul: also // ---- // secondItem() -> 0x22 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_enum.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_enum.sol index 93c5fd4a0..4dd3bad4e 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_enum.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_enum.sol @@ -14,8 +14,6 @@ contract C { return x.equals(L.E(choice)); } } -// ==== -// compileViaYul: also // ---- // equalsA(uint256): 0 -> true // equalsA(uint256): 1 -> false diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_external_function.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_external_function.sol index f68cb4e21..63ca1e0b7 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_external_function.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_external_function.sol @@ -17,7 +17,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // test(uint256): 5 -> 10 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_fixed_array.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_fixed_array.sol index 842911079..28f621d59 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_fixed_array.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_fixed_array.sol @@ -15,7 +15,5 @@ contract C { return input.at(1); } } -// ==== -// compileViaYul: also // ---- // secondItem() -> 0x22 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_fixed_bytes.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_fixed_bytes.sol index 02db54572..bf7d0ede8 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_fixed_bytes.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_fixed_bytes.sol @@ -11,7 +11,5 @@ contract C { return a.add(b); } } -// ==== -// compileViaYul: also // ---- // sum(bytes2,bytes2): left(0x1100), left(0x0022) -> left(0x1122) diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_function_named_selector.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_function_named_selector.sol index 75c4e4cb8..d66bac750 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_function_named_selector.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_function_named_selector.sol @@ -16,7 +16,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // test(uint256): 5 -> 10 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_integer.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_integer.sol index 258e4940c..5234fb5e4 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_integer.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_integer.sol @@ -11,7 +11,5 @@ contract C { return a.add(b); } } -// ==== -// compileViaYul: also // ---- // foo(uint256,uint256): 8, 42 -> 50 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_interface.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_interface.sol index 47e58bb32..e00fd4612 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_interface.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_interface.sol @@ -16,7 +16,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // test() -> 42 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_internal_function.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_internal_function.sol index 519eafddd..c566da79c 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_internal_function.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_internal_function.sol @@ -16,7 +16,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // test(uint256): 5 -> 10 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_literal.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_literal.sol index 632d52709..da7ee6ccc 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_literal.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_literal.sol @@ -19,8 +19,6 @@ contract C { return "abc".double(); } } -// ==== -// compileViaYul: also // ---- // double42() -> 84 // doubleABC() -> 0x20, 6, "abcabc" diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_mapping.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_mapping.sol index ec1250a62..d4cee5c97 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_mapping.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_mapping.sol @@ -16,7 +16,5 @@ contract C { return map.at(a); } } -// ==== -// compileViaYul: also // ---- // mapValue(uint256): 42 -> 0x24 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_storage_string.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_storage_string.sol index 6c15fa735..b7bc103f4 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_storage_string.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_storage_string.sol @@ -16,7 +16,5 @@ contract C { return (s.f(), s.g()); } } -// ==== -// compileViaYul: also // ---- // test(string): 0x20, 3, "def" -> 0x40, 0x80, 3, "def", 3, "def" diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_string.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_string.sol index d8d420512..3ed398f9a 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_string.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound_to_string.sol @@ -12,7 +12,5 @@ contract C { return input.at(1); } } -// ==== -// compileViaYul: also // ---- // secondChar() -> 98 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_calling_private.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_calling_private.sol index e9806aa4f..2283c30ff 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_calling_private.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_calling_private.sol @@ -22,7 +22,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f() -> 2 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_pointer.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_pointer.sol index bc2f2da0a..0681fd0d0 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_pointer.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_pointer.sol @@ -11,7 +11,5 @@ contract C { return ptr(); } } -// ==== -// compileViaYul: also // ---- // g() -> 66 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_return_var_size.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_return_var_size.sol index 1406e0117..21417b599 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_return_var_size.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_return_var_size.sol @@ -22,7 +22,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f() -> 2 diff --git a/test/libsolidity/semanticTests/libraries/internal_types_in_library.sol b/test/libsolidity/semanticTests/libraries/internal_types_in_library.sol index 9cf5f65ff..9caaa89b9 100644 --- a/test/libsolidity/semanticTests/libraries/internal_types_in_library.sol +++ b/test/libsolidity/semanticTests/libraries/internal_types_in_library.sol @@ -21,10 +21,9 @@ contract Test { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: Lib // f() -> 4, 0x11 -// gas irOptimized: 115868 +// gas irOptimized: 112281 // gas legacy: 135820 // gas legacyOptimized: 119448 diff --git a/test/libsolidity/semanticTests/libraries/library_address.sol b/test/libsolidity/semanticTests/libraries/library_address.sol index e8e60bc04..6ca064445 100644 --- a/test/libsolidity/semanticTests/libraries/library_address.sol +++ b/test/libsolidity/semanticTests/libraries/library_address.sol @@ -36,7 +36,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // library: L // addr() -> false diff --git a/test/libsolidity/semanticTests/libraries/library_address_homestead.sol b/test/libsolidity/semanticTests/libraries/library_address_homestead.sol index 256b43d3a..ce7344f4a 100644 --- a/test/libsolidity/semanticTests/libraries/library_address_homestead.sol +++ b/test/libsolidity/semanticTests/libraries/library_address_homestead.sol @@ -12,8 +12,6 @@ contract C { return success; } } -// ==== -// compileViaYul: also // ---- // library: L // g(uint256,uint256): 1, 1 -> true diff --git a/test/libsolidity/semanticTests/libraries/library_address_via_module.sol b/test/libsolidity/semanticTests/libraries/library_address_via_module.sol index effcd13c8..4c9646902 100644 --- a/test/libsolidity/semanticTests/libraries/library_address_via_module.sol +++ b/test/libsolidity/semanticTests/libraries/library_address_via_module.sol @@ -40,7 +40,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // library: "a.sol":L // addr() -> false diff --git a/test/libsolidity/semanticTests/libraries/library_call_in_homestead.sol b/test/libsolidity/semanticTests/libraries/library_call_in_homestead.sol index 6841221f4..a49dc602a 100644 --- a/test/libsolidity/semanticTests/libraries/library_call_in_homestead.sol +++ b/test/libsolidity/semanticTests/libraries/library_call_in_homestead.sol @@ -6,7 +6,6 @@ contract Test { } } // ==== -// compileViaYul: also // compileToEwasm: false // EVMVersion: >=homestead // ---- diff --git a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_pure.sol b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_pure.sol index 61e182843..b540e9a63 100644 --- a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_pure.sol +++ b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_pure.sol @@ -25,7 +25,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // library: L // f() -> 23 diff --git a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_needed.sol b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_needed.sol index 169738029..3c5274990 100644 --- a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_needed.sol +++ b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_needed.sol @@ -25,7 +25,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // library: L // f() -> 1 diff --git a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_not_needed.sol b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_not_needed.sol index 9d31db25b..2d4e6468e 100644 --- a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_not_needed.sol +++ b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_not_needed.sol @@ -24,7 +24,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // library: L // f() -> 84 diff --git a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_staticcall.sol b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_staticcall.sol index 2af36bb21..d8cdb9a4d 100644 --- a/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_staticcall.sol +++ b/test/libsolidity/semanticTests/libraries/library_delegatecall_guard_view_staticcall.sol @@ -24,7 +24,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // library: L // f() -> 42 diff --git a/test/libsolidity/semanticTests/libraries/library_enum_as_an_expression.sol b/test/libsolidity/semanticTests/libraries/library_enum_as_an_expression.sol index 31a64ce20..f24d93c2d 100644 --- a/test/libsolidity/semanticTests/libraries/library_enum_as_an_expression.sol +++ b/test/libsolidity/semanticTests/libraries/library_enum_as_an_expression.sol @@ -10,7 +10,5 @@ contract Tsra { } } -// ==== -// compileViaYul: also // ---- // f() -> 1 diff --git a/test/libsolidity/semanticTests/libraries/library_function_selectors.sol b/test/libsolidity/semanticTests/libraries/library_function_selectors.sol index e4347d15a..baeb5cedd 100644 --- a/test/libsolidity/semanticTests/libraries/library_function_selectors.sol +++ b/test/libsolidity/semanticTests/libraries/library_function_selectors.sol @@ -23,7 +23,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // library: L // f() -> true, true, 7 diff --git a/test/libsolidity/semanticTests/libraries/library_function_selectors_struct.sol b/test/libsolidity/semanticTests/libraries/library_function_selectors_struct.sol index e57f5ce1a..186fad7db 100644 --- a/test/libsolidity/semanticTests/libraries/library_function_selectors_struct.sol +++ b/test/libsolidity/semanticTests/libraries/library_function_selectors_struct.sol @@ -21,7 +21,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // library: L // f() -> true, true, 42 diff --git a/test/libsolidity/semanticTests/libraries/library_return_struct_with_mapping.sol b/test/libsolidity/semanticTests/libraries/library_return_struct_with_mapping.sol index bb3c26f8c..00001a2f8 100644 --- a/test/libsolidity/semanticTests/libraries/library_return_struct_with_mapping.sol +++ b/test/libsolidity/semanticTests/libraries/library_return_struct_with_mapping.sol @@ -16,8 +16,6 @@ contract C { assembly { slot := ptr.slot } } } -// ==== -// compileViaYul: also // ---- // library: Lib // f() -> 123 diff --git a/test/libsolidity/semanticTests/libraries/library_staticcall_delegatecall.sol b/test/libsolidity/semanticTests/libraries/library_staticcall_delegatecall.sol index d566f7180..e7692ed83 100644 --- a/test/libsolidity/semanticTests/libraries/library_staticcall_delegatecall.sol +++ b/test/libsolidity/semanticTests/libraries/library_staticcall_delegatecall.sol @@ -13,8 +13,6 @@ contract Test { return Lib.x(); } } -// ==== -// compileViaYul: also // ---- // library: Lib // f() -> 1 diff --git a/test/libsolidity/semanticTests/libraries/library_stray_values.sol b/test/libsolidity/semanticTests/libraries/library_stray_values.sol index 1692b018a..61f52b86c 100644 --- a/test/libsolidity/semanticTests/libraries/library_stray_values.sol +++ b/test/libsolidity/semanticTests/libraries/library_stray_values.sol @@ -8,7 +8,6 @@ contract Test { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: Lib // f(uint256): 33 -> 0x2a diff --git a/test/libsolidity/semanticTests/libraries/library_struct_as_an_expression.sol b/test/libsolidity/semanticTests/libraries/library_struct_as_an_expression.sol index 9965a3815..d7df52434 100644 --- a/test/libsolidity/semanticTests/libraries/library_struct_as_an_expression.sol +++ b/test/libsolidity/semanticTests/libraries/library_struct_as_an_expression.sol @@ -13,7 +13,5 @@ contract Tsra { } } -// ==== -// compileViaYul: also // ---- // f() -> 1 diff --git a/test/libsolidity/semanticTests/libraries/mapping_arguments_in_library.sol b/test/libsolidity/semanticTests/libraries/mapping_arguments_in_library.sol index 06cfd6e1a..8a82350dc 100644 --- a/test/libsolidity/semanticTests/libraries/mapping_arguments_in_library.sol +++ b/test/libsolidity/semanticTests/libraries/mapping_arguments_in_library.sol @@ -22,7 +22,6 @@ contract Test { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: Lib // set(uint256,uint256): 1, 42 -> 0 diff --git a/test/libsolidity/semanticTests/libraries/mapping_returns_in_library.sol b/test/libsolidity/semanticTests/libraries/mapping_returns_in_library.sol index dd2b2953f..a8188fcc6 100644 --- a/test/libsolidity/semanticTests/libraries/mapping_returns_in_library.sol +++ b/test/libsolidity/semanticTests/libraries/mapping_returns_in_library.sol @@ -26,7 +26,6 @@ contract Test { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: Lib // set(bool,uint256,uint256): true, 1, 42 -> 0 diff --git a/test/libsolidity/semanticTests/libraries/mapping_returns_in_library_named.sol b/test/libsolidity/semanticTests/libraries/mapping_returns_in_library_named.sol index 23f851279..6ddad7979 100644 --- a/test/libsolidity/semanticTests/libraries/mapping_returns_in_library_named.sol +++ b/test/libsolidity/semanticTests/libraries/mapping_returns_in_library_named.sol @@ -24,7 +24,6 @@ contract Test { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: Lib // f() -> 0, 0x2a, 0, 0, 0x15, 0x54 diff --git a/test/libsolidity/semanticTests/libraries/payable_function_calls_library.sol b/test/libsolidity/semanticTests/libraries/payable_function_calls_library.sol index 6b0488f06..5e78713b7 100644 --- a/test/libsolidity/semanticTests/libraries/payable_function_calls_library.sol +++ b/test/libsolidity/semanticTests/libraries/payable_function_calls_library.sol @@ -8,7 +8,6 @@ contract C { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: L // f(): 27 -> 7 diff --git a/test/libsolidity/semanticTests/libraries/stub.sol b/test/libsolidity/semanticTests/libraries/stub.sol index 4ed1f2673..8bae3df27 100644 --- a/test/libsolidity/semanticTests/libraries/stub.sol +++ b/test/libsolidity/semanticTests/libraries/stub.sol @@ -6,8 +6,6 @@ contract C { return L.f(v); } } -// ==== -// compileViaYul: also // ---- // library: L // g(uint256): 1 -> 1 diff --git a/test/libsolidity/semanticTests/libraries/stub_internal.sol b/test/libsolidity/semanticTests/libraries/stub_internal.sol index 4634d4e7a..075b8dbb2 100644 --- a/test/libsolidity/semanticTests/libraries/stub_internal.sol +++ b/test/libsolidity/semanticTests/libraries/stub_internal.sol @@ -6,8 +6,6 @@ contract C { return L.f(v); } } -// ==== -// compileViaYul: also // ---- // g(uint256): 1 -> 1 // g(uint256): 2 -> 4 diff --git a/test/libsolidity/semanticTests/libraries/using_for_by_name.sol b/test/libsolidity/semanticTests/libraries/using_for_by_name.sol index 8a84c8aaa..f9add4cb8 100644 --- a/test/libsolidity/semanticTests/libraries/using_for_by_name.sol +++ b/test/libsolidity/semanticTests/libraries/using_for_by_name.sol @@ -9,7 +9,6 @@ contract C { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: D // f(uint256): 7 -> 0x2a diff --git a/test/libsolidity/semanticTests/libraries/using_for_function_on_int.sol b/test/libsolidity/semanticTests/libraries/using_for_function_on_int.sol index ffa07acc1..f44da5a8b 100644 --- a/test/libsolidity/semanticTests/libraries/using_for_function_on_int.sol +++ b/test/libsolidity/semanticTests/libraries/using_for_function_on_int.sol @@ -7,8 +7,6 @@ contract C { return a.double(); } } -// ==== -// compileViaYul: also // ---- // library: D // f(uint256): 9 -> 18 diff --git a/test/libsolidity/semanticTests/libraries/using_for_overload.sol b/test/libsolidity/semanticTests/libraries/using_for_overload.sol index 54cfe0ce1..5bc0bc948 100644 --- a/test/libsolidity/semanticTests/libraries/using_for_overload.sol +++ b/test/libsolidity/semanticTests/libraries/using_for_overload.sol @@ -13,7 +13,6 @@ contract C { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: D // f(uint256): 7 -> 0x2a diff --git a/test/libsolidity/semanticTests/libraries/using_for_storage_structs.sol b/test/libsolidity/semanticTests/libraries/using_for_storage_structs.sol index 2749fb444..cd45726b6 100644 --- a/test/libsolidity/semanticTests/libraries/using_for_storage_structs.sol +++ b/test/libsolidity/semanticTests/libraries/using_for_storage_structs.sol @@ -21,7 +21,5 @@ contract C { return (s.f(), h(s)); } } -// ==== -// compileViaYul: also // ---- // g() -> 7, 7 diff --git a/test/libsolidity/semanticTests/libraries/using_library_mappings_public.sol b/test/libsolidity/semanticTests/libraries/using_library_mappings_public.sol index 6304e12d8..f4f9405b6 100644 --- a/test/libsolidity/semanticTests/libraries/using_library_mappings_public.sol +++ b/test/libsolidity/semanticTests/libraries/using_library_mappings_public.sol @@ -18,10 +18,9 @@ contract Test { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: Lib // f() -> 1, 0, 0x2a, 0x17, 0, 0x63 -// gas irOptimized: 119499 +// gas irOptimized: 119659 // gas legacy: 124793 // gas legacyOptimized: 119694 diff --git a/test/libsolidity/semanticTests/libraries/using_library_mappings_return.sol b/test/libsolidity/semanticTests/libraries/using_library_mappings_return.sol index 86e7fa3d7..80e831a4c 100644 --- a/test/libsolidity/semanticTests/libraries/using_library_mappings_return.sol +++ b/test/libsolidity/semanticTests/libraries/using_library_mappings_return.sol @@ -16,10 +16,9 @@ contract Test { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: Lib // f() -> 1, 0, 0x2a, 0x17, 0, 0x63 -// gas irOptimized: 120572 +// gas irOptimized: 120270 // gas legacy: 125245 // gas legacyOptimized: 120153 diff --git a/test/libsolidity/semanticTests/libraries/using_library_structs.sol b/test/libsolidity/semanticTests/libraries/using_library_structs.sol index 1f1ac6eb0..888c9c048 100644 --- a/test/libsolidity/semanticTests/libraries/using_library_structs.sol +++ b/test/libsolidity/semanticTests/libraries/using_library_structs.sol @@ -19,7 +19,6 @@ contract Test { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: Lib // f() -> 7, 8 diff --git a/test/libsolidity/semanticTests/literals/denominations.sol b/test/libsolidity/semanticTests/literals/denominations.sol index 8600e46b9..9aec493cd 100644 --- a/test/libsolidity/semanticTests/literals/denominations.sol +++ b/test/libsolidity/semanticTests/literals/denominations.sol @@ -5,6 +5,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1000000001000000001 diff --git a/test/libsolidity/semanticTests/literals/escape.sol b/test/libsolidity/semanticTests/literals/escape.sol index 54108ec53..c198f21dc 100644 --- a/test/libsolidity/semanticTests/literals/escape.sol +++ b/test/libsolidity/semanticTests/literals/escape.sol @@ -9,6 +9,5 @@ contract C } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 2, 0x5c00000000000000000000000000000000000000000000000000000000000000, 0x5c00000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/literals/ether.sol b/test/libsolidity/semanticTests/literals/ether.sol index f640ddff3..d2942a065 100644 --- a/test/libsolidity/semanticTests/literals/ether.sol +++ b/test/libsolidity/semanticTests/literals/ether.sol @@ -5,6 +5,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1000000000000000000 diff --git a/test/libsolidity/semanticTests/literals/gwei.sol b/test/libsolidity/semanticTests/literals/gwei.sol index e154415ad..3058ee720 100644 --- a/test/libsolidity/semanticTests/literals/gwei.sol +++ b/test/libsolidity/semanticTests/literals/gwei.sol @@ -5,6 +5,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1000000000 diff --git a/test/libsolidity/semanticTests/literals/hex_string_with_non_printable_characters.sol b/test/libsolidity/semanticTests/literals/hex_string_with_non_printable_characters.sol index 5b703b614..d10904cfa 100644 --- a/test/libsolidity/semanticTests/literals/hex_string_with_non_printable_characters.sol +++ b/test/libsolidity/semanticTests/literals/hex_string_with_non_printable_characters.sol @@ -7,6 +7,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f diff --git a/test/libsolidity/semanticTests/literals/hex_string_with_underscore.sol b/test/libsolidity/semanticTests/literals/hex_string_with_underscore.sol index 118068654..b14297a94 100644 --- a/test/libsolidity/semanticTests/literals/hex_string_with_underscore.sol +++ b/test/libsolidity/semanticTests/literals/hex_string_with_underscore.sol @@ -5,6 +5,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 32, 5, left(0x123456789A) diff --git a/test/libsolidity/semanticTests/literals/scientific_notation.sol b/test/libsolidity/semanticTests/literals/scientific_notation.sol index 492d87de6..b03adee39 100644 --- a/test/libsolidity/semanticTests/literals/scientific_notation.sol +++ b/test/libsolidity/semanticTests/literals/scientific_notation.sol @@ -26,7 +26,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 20000000000 // g() -> 2 diff --git a/test/libsolidity/semanticTests/literals/ternary_operator_with_literal_types_overflow.sol b/test/libsolidity/semanticTests/literals/ternary_operator_with_literal_types_overflow.sol index 22d61c6c5..82ec72d80 100644 --- a/test/libsolidity/semanticTests/literals/ternary_operator_with_literal_types_overflow.sol +++ b/test/libsolidity/semanticTests/literals/ternary_operator_with_literal_types_overflow.sol @@ -12,8 +12,6 @@ contract TestTernary a = (t ? 63 : 255) + (f ? 63 : 255); } } -// ==== -// compileViaYul: also // ---- // g() -> FAILURE, hex"4e487b71", 0x11 // h() -> FAILURE, hex"4e487b71", 0x11 diff --git a/test/libsolidity/semanticTests/literals/wei.sol b/test/libsolidity/semanticTests/literals/wei.sol index 1fbf95862..bf115f1dc 100644 --- a/test/libsolidity/semanticTests/literals/wei.sol +++ b/test/libsolidity/semanticTests/literals/wei.sol @@ -5,6 +5,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1 diff --git a/test/libsolidity/semanticTests/memoryManagement/assembly_access.sol b/test/libsolidity/semanticTests/memoryManagement/assembly_access.sol index ec711ef3e..e69c93e46 100644 --- a/test/libsolidity/semanticTests/memoryManagement/assembly_access.sol +++ b/test/libsolidity/semanticTests/memoryManagement/assembly_access.sol @@ -12,6 +12,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> diff --git a/test/libsolidity/semanticTests/memoryManagement/memory_types_initialisation.sol b/test/libsolidity/semanticTests/memoryManagement/memory_types_initialisation.sol index 7ad6b6167..ed51a5992 100644 --- a/test/libsolidity/semanticTests/memoryManagement/memory_types_initialisation.sol +++ b/test/libsolidity/semanticTests/memoryManagement/memory_types_initialisation.sol @@ -8,8 +8,6 @@ contract Test { function nested() public returns (uint[3][] memory) { stat(); } function nestedStat() public returns (uint[3][7] memory) { stat(); } } -// ==== -// compileViaYul: also // ---- // stat() -> 0, 0, 0, 0, 0 // dyn() -> 0x20, 0 diff --git a/test/libsolidity/semanticTests/memoryManagement/return_variable.sol b/test/libsolidity/semanticTests/memoryManagement/return_variable.sol index 501fea0f1..a28672c93 100644 --- a/test/libsolidity/semanticTests/memoryManagement/return_variable.sol +++ b/test/libsolidity/semanticTests/memoryManagement/return_variable.sol @@ -24,7 +24,5 @@ contract C { return x; } } -// ==== -// compileViaYul: also // ---- // f() -> 0x0500, 0x0500, 0x0a00 diff --git a/test/libsolidity/semanticTests/memoryManagement/static_memory_array_allocation.sol b/test/libsolidity/semanticTests/memoryManagement/static_memory_array_allocation.sol index 868d532b8..9b27b3492 100644 --- a/test/libsolidity/semanticTests/memoryManagement/static_memory_array_allocation.sol +++ b/test/libsolidity/semanticTests/memoryManagement/static_memory_array_allocation.sol @@ -17,8 +17,6 @@ contract C { return memorySizeAfter - memorySizeBefore; } } -// ==== -// compileViaYul: also // ---- // withValue() -> 0x00 // withoutValue() -> 0x0280 diff --git a/test/libsolidity/semanticTests/memoryManagement/struct_allocation.sol b/test/libsolidity/semanticTests/memoryManagement/struct_allocation.sol index 78308eed3..f3a326534 100644 --- a/test/libsolidity/semanticTests/memoryManagement/struct_allocation.sol +++ b/test/libsolidity/semanticTests/memoryManagement/struct_allocation.sol @@ -19,7 +19,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // withValue() -> 0x00 // withoutValue() -> 0x60 diff --git a/test/libsolidity/semanticTests/metaTypes/name_other_contract.sol b/test/libsolidity/semanticTests/metaTypes/name_other_contract.sol index aaf2874c8..4f9bfe971 100644 --- a/test/libsolidity/semanticTests/metaTypes/name_other_contract.sol +++ b/test/libsolidity/semanticTests/metaTypes/name_other_contract.sol @@ -23,7 +23,6 @@ contract Test is C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // c() -> 0x20, 1, "C" diff --git a/test/libsolidity/semanticTests/modifiers/access_through_contract_name.sol b/test/libsolidity/semanticTests/modifiers/access_through_contract_name.sol index 8c756419b..f56d611c2 100644 --- a/test/libsolidity/semanticTests/modifiers/access_through_contract_name.sol +++ b/test/libsolidity/semanticTests/modifiers/access_through_contract_name.sol @@ -13,7 +13,6 @@ contract C is A { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // x() -> 7 diff --git a/test/libsolidity/semanticTests/modifiers/access_through_module_name.sol b/test/libsolidity/semanticTests/modifiers/access_through_module_name.sol index de3632808..925797b7e 100644 --- a/test/libsolidity/semanticTests/modifiers/access_through_module_name.sol +++ b/test/libsolidity/semanticTests/modifiers/access_through_module_name.sol @@ -16,7 +16,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // x() -> 0x00 diff --git a/test/libsolidity/semanticTests/modifiers/break_in_modifier.sol b/test/libsolidity/semanticTests/modifiers/break_in_modifier.sol index ff830d075..b15a80df1 100644 --- a/test/libsolidity/semanticTests/modifiers/break_in_modifier.sol +++ b/test/libsolidity/semanticTests/modifiers/break_in_modifier.sol @@ -15,7 +15,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // x() -> 0 diff --git a/test/libsolidity/semanticTests/modifiers/continue_in_modifier.sol b/test/libsolidity/semanticTests/modifiers/continue_in_modifier.sol index a81d4d6d2..bc4c79739 100644 --- a/test/libsolidity/semanticTests/modifiers/continue_in_modifier.sol +++ b/test/libsolidity/semanticTests/modifiers/continue_in_modifier.sol @@ -15,7 +15,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // x() -> 0 diff --git a/test/libsolidity/semanticTests/modifiers/evaluation_order.sol b/test/libsolidity/semanticTests/modifiers/evaluation_order.sol index b8b383e88..b92df61f9 100644 --- a/test/libsolidity/semanticTests/modifiers/evaluation_order.sol +++ b/test/libsolidity/semanticTests/modifiers/evaluation_order.sol @@ -16,7 +16,5 @@ contract D is A, B, C { function f(uint y) internal returns (uint) { x.push(y); return 0; } } -// ==== -// compileViaYul: also // ---- // query() -> 0x20, 7, 4, 2, 6, 1, 3, 5, 7 diff --git a/test/libsolidity/semanticTests/modifiers/function_modifier.sol b/test/libsolidity/semanticTests/modifiers/function_modifier.sol index 52ceb5c9c..cca7e04b1 100644 --- a/test/libsolidity/semanticTests/modifiers/function_modifier.sol +++ b/test/libsolidity/semanticTests/modifiers/function_modifier.sol @@ -9,7 +9,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // getOne() -> 0 diff --git a/test/libsolidity/semanticTests/modifiers/function_modifier_calling_functions_in_creation_context.sol b/test/libsolidity/semanticTests/modifiers/function_modifier_calling_functions_in_creation_context.sol index 912b34b9a..182baec8c 100644 --- a/test/libsolidity/semanticTests/modifiers/function_modifier_calling_functions_in_creation_context.sol +++ b/test/libsolidity/semanticTests/modifiers/function_modifier_calling_functions_in_creation_context.sol @@ -46,7 +46,6 @@ contract C is A { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // getData() -> 0x4300 diff --git a/test/libsolidity/semanticTests/modifiers/function_modifier_empty.sol b/test/libsolidity/semanticTests/modifiers/function_modifier_empty.sol index 4c988229c..222f87f97 100644 --- a/test/libsolidity/semanticTests/modifiers/function_modifier_empty.sol +++ b/test/libsolidity/semanticTests/modifiers/function_modifier_empty.sol @@ -14,7 +14,6 @@ contract C is A { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> false diff --git a/test/libsolidity/semanticTests/modifiers/function_modifier_for_constructor.sol b/test/libsolidity/semanticTests/modifiers/function_modifier_for_constructor.sol index de211b777..71cbc4203 100644 --- a/test/libsolidity/semanticTests/modifiers/function_modifier_for_constructor.sol +++ b/test/libsolidity/semanticTests/modifiers/function_modifier_for_constructor.sol @@ -23,7 +23,6 @@ contract C is A { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // getData() -> 6 diff --git a/test/libsolidity/semanticTests/modifiers/function_modifier_library.sol b/test/libsolidity/semanticTests/modifiers/function_modifier_library.sol index a47b4dea5..f10ebb0e7 100644 --- a/test/libsolidity/semanticTests/modifiers/function_modifier_library.sol +++ b/test/libsolidity/semanticTests/modifiers/function_modifier_library.sol @@ -24,7 +24,5 @@ contract Test { } } -// ==== -// compileViaYul: also // ---- // f() -> 0x202 diff --git a/test/libsolidity/semanticTests/modifiers/function_modifier_library_inheritance.sol b/test/libsolidity/semanticTests/modifiers/function_modifier_library_inheritance.sol index 00779ef9b..3d5e97de0 100644 --- a/test/libsolidity/semanticTests/modifiers/function_modifier_library_inheritance.sol +++ b/test/libsolidity/semanticTests/modifiers/function_modifier_library_inheritance.sol @@ -30,7 +30,5 @@ contract Test { } } -// ==== -// compileViaYul: also // ---- // f() -> 0x202 diff --git a/test/libsolidity/semanticTests/modifiers/function_modifier_local_variables.sol b/test/libsolidity/semanticTests/modifiers/function_modifier_local_variables.sol index 05c072eb8..dc44d6659 100644 --- a/test/libsolidity/semanticTests/modifiers/function_modifier_local_variables.sol +++ b/test/libsolidity/semanticTests/modifiers/function_modifier_local_variables.sol @@ -15,7 +15,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(bool): true -> 0 diff --git a/test/libsolidity/semanticTests/modifiers/function_modifier_multiple_times.sol b/test/libsolidity/semanticTests/modifiers/function_modifier_multiple_times.sol index 708e5d6cb..83f855d2c 100644 --- a/test/libsolidity/semanticTests/modifiers/function_modifier_multiple_times.sol +++ b/test/libsolidity/semanticTests/modifiers/function_modifier_multiple_times.sol @@ -11,7 +11,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(uint256): 3 -> 10 diff --git a/test/libsolidity/semanticTests/modifiers/function_modifier_multiple_times_local_vars.sol b/test/libsolidity/semanticTests/modifiers/function_modifier_multiple_times_local_vars.sol index cbb870918..264d256bd 100644 --- a/test/libsolidity/semanticTests/modifiers/function_modifier_multiple_times_local_vars.sol +++ b/test/libsolidity/semanticTests/modifiers/function_modifier_multiple_times_local_vars.sol @@ -14,7 +14,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(uint256): 3 -> 10 diff --git a/test/libsolidity/semanticTests/modifiers/function_modifier_overriding.sol b/test/libsolidity/semanticTests/modifiers/function_modifier_overriding.sol index 3107f5d20..bef92dac2 100644 --- a/test/libsolidity/semanticTests/modifiers/function_modifier_overriding.sol +++ b/test/libsolidity/semanticTests/modifiers/function_modifier_overriding.sol @@ -16,7 +16,6 @@ contract C is A { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> false diff --git a/test/libsolidity/semanticTests/modifiers/function_modifier_return_reference.sol b/test/libsolidity/semanticTests/modifiers/function_modifier_return_reference.sol index 1da6c011d..f14496fa1 100644 --- a/test/libsolidity/semanticTests/modifiers/function_modifier_return_reference.sol +++ b/test/libsolidity/semanticTests/modifiers/function_modifier_return_reference.sol @@ -9,7 +9,5 @@ contract C { function f() public m1(x = 2) m2(y = 3) returns (uint x, uint y) { } } -// ==== -// compileViaYul: also // ---- // f() -> 2, 3 diff --git a/test/libsolidity/semanticTests/modifiers/function_return_parameter.sol b/test/libsolidity/semanticTests/modifiers/function_return_parameter.sol index d0d3321aa..e1a0c36d3 100644 --- a/test/libsolidity/semanticTests/modifiers/function_return_parameter.sol +++ b/test/libsolidity/semanticTests/modifiers/function_return_parameter.sol @@ -5,7 +5,6 @@ contract B { modifier mod2(bytes7 a) { while (a == "1234567") _; } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(uint8): 5 -> 0x00 diff --git a/test/libsolidity/semanticTests/modifiers/function_return_parameter_complex.sol b/test/libsolidity/semanticTests/modifiers/function_return_parameter_complex.sol index 06de394be..ab14d14c2 100644 --- a/test/libsolidity/semanticTests/modifiers/function_return_parameter_complex.sol +++ b/test/libsolidity/semanticTests/modifiers/function_return_parameter_complex.sol @@ -27,7 +27,6 @@ contract A { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 0x10, 0x20, 0x40 diff --git a/test/libsolidity/semanticTests/modifiers/modifer_recursive.sol b/test/libsolidity/semanticTests/modifiers/modifer_recursive.sol index a0e550b25..006af1c2c 100644 --- a/test/libsolidity/semanticTests/modifiers/modifer_recursive.sol +++ b/test/libsolidity/semanticTests/modifiers/modifer_recursive.sol @@ -10,7 +10,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // called() -> 0x00 diff --git a/test/libsolidity/semanticTests/modifiers/modifier_in_constructor_ice.sol b/test/libsolidity/semanticTests/modifiers/modifier_in_constructor_ice.sol index 4a3904de8..88a2fa107 100644 --- a/test/libsolidity/semanticTests/modifiers/modifier_in_constructor_ice.sol +++ b/test/libsolidity/semanticTests/modifiers/modifier_in_constructor_ice.sol @@ -2,7 +2,6 @@ contract A { modifier m1{_;} } contract B is A { constructor() A() m1{} } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // constructor() -> diff --git a/test/libsolidity/semanticTests/modifiers/modifier_init_return.sol b/test/libsolidity/semanticTests/modifiers/modifier_init_return.sol index 814011899..df4fa914c 100644 --- a/test/libsolidity/semanticTests/modifiers/modifier_init_return.sol +++ b/test/libsolidity/semanticTests/modifiers/modifier_init_return.sol @@ -9,7 +9,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(uint256): 9 -> 0x00, 0x00, 0x00, 0x00, 0x00 diff --git a/test/libsolidity/semanticTests/modifiers/modifiers_in_construction_context.sol b/test/libsolidity/semanticTests/modifiers/modifiers_in_construction_context.sol index 834a5f446..3f2b4ebea 100644 --- a/test/libsolidity/semanticTests/modifiers/modifiers_in_construction_context.sol +++ b/test/libsolidity/semanticTests/modifiers/modifiers_in_construction_context.sol @@ -8,7 +8,6 @@ contract B is A { constructor() A() m1 m2 { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // constructor() -> diff --git a/test/libsolidity/semanticTests/modifiers/return_does_not_skip_modifier.sol b/test/libsolidity/semanticTests/modifiers/return_does_not_skip_modifier.sol index 31b19b111..1d71e5ac9 100644 --- a/test/libsolidity/semanticTests/modifiers/return_does_not_skip_modifier.sol +++ b/test/libsolidity/semanticTests/modifiers/return_does_not_skip_modifier.sol @@ -11,7 +11,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // x() -> 0 diff --git a/test/libsolidity/semanticTests/modifiers/return_in_modifier.sol b/test/libsolidity/semanticTests/modifiers/return_in_modifier.sol index 50746d706..ffc503ae2 100644 --- a/test/libsolidity/semanticTests/modifiers/return_in_modifier.sol +++ b/test/libsolidity/semanticTests/modifiers/return_in_modifier.sol @@ -15,7 +15,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // x() -> 0 diff --git a/test/libsolidity/semanticTests/modifiers/stacked_return_with_modifiers.sol b/test/libsolidity/semanticTests/modifiers/stacked_return_with_modifiers.sol index a38969c02..a9b6bfa6c 100644 --- a/test/libsolidity/semanticTests/modifiers/stacked_return_with_modifiers.sol +++ b/test/libsolidity/semanticTests/modifiers/stacked_return_with_modifiers.sol @@ -16,7 +16,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // x() -> 0 diff --git a/test/libsolidity/semanticTests/multiSource/circular_import.sol b/test/libsolidity/semanticTests/multiSource/circular_import.sol index 74df4ac74..15d75fde5 100644 --- a/test/libsolidity/semanticTests/multiSource/circular_import.sol +++ b/test/libsolidity/semanticTests/multiSource/circular_import.sol @@ -11,6 +11,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // foo() -> 1 diff --git a/test/libsolidity/semanticTests/multiSource/circular_import_2.sol b/test/libsolidity/semanticTests/multiSource/circular_import_2.sol index c1cf12150..de47c0380 100644 --- a/test/libsolidity/semanticTests/multiSource/circular_import_2.sol +++ b/test/libsolidity/semanticTests/multiSource/circular_import_2.sol @@ -12,6 +12,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // foo() -> 992 diff --git a/test/libsolidity/semanticTests/multiSource/circular_reimport.sol b/test/libsolidity/semanticTests/multiSource/circular_reimport.sol index f4394e428..8b7fc32a5 100644 --- a/test/libsolidity/semanticTests/multiSource/circular_reimport.sol +++ b/test/libsolidity/semanticTests/multiSource/circular_reimport.sol @@ -14,6 +14,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // foo() -> 0x60 diff --git a/test/libsolidity/semanticTests/multiSource/circular_reimport_2.sol b/test/libsolidity/semanticTests/multiSource/circular_reimport_2.sol index b7c98118a..3ae209daa 100644 --- a/test/libsolidity/semanticTests/multiSource/circular_reimport_2.sol +++ b/test/libsolidity/semanticTests/multiSource/circular_reimport_2.sol @@ -14,6 +14,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // foo() -> 0x2324 diff --git a/test/libsolidity/semanticTests/multiSource/free_different_interger_types.sol b/test/libsolidity/semanticTests/multiSource/free_different_interger_types.sol index 345b5de0f..5c4286366 100644 --- a/test/libsolidity/semanticTests/multiSource/free_different_interger_types.sol +++ b/test/libsolidity/semanticTests/multiSource/free_different_interger_types.sol @@ -10,6 +10,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // foo() -> 24, true diff --git a/test/libsolidity/semanticTests/multiSource/free_function_resolution_base_contract.sol b/test/libsolidity/semanticTests/multiSource/free_function_resolution_base_contract.sol index dee4184bf..4e91d42fb 100644 --- a/test/libsolidity/semanticTests/multiSource/free_function_resolution_base_contract.sol +++ b/test/libsolidity/semanticTests/multiSource/free_function_resolution_base_contract.sol @@ -14,6 +14,5 @@ contract D is C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // h() -> 1337 diff --git a/test/libsolidity/semanticTests/multiSource/free_function_resolution_override_virtual.sol b/test/libsolidity/semanticTests/multiSource/free_function_resolution_override_virtual.sol index c7726815f..6df3631a7 100644 --- a/test/libsolidity/semanticTests/multiSource/free_function_resolution_override_virtual.sol +++ b/test/libsolidity/semanticTests/multiSource/free_function_resolution_override_virtual.sol @@ -14,6 +14,5 @@ contract D is C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 1337 diff --git a/test/libsolidity/semanticTests/multiSource/free_function_resolution_override_virtual_super.sol b/test/libsolidity/semanticTests/multiSource/free_function_resolution_override_virtual_super.sol index 5c14eefd2..71fed293b 100644 --- a/test/libsolidity/semanticTests/multiSource/free_function_resolution_override_virtual_super.sol +++ b/test/libsolidity/semanticTests/multiSource/free_function_resolution_override_virtual_super.sol @@ -14,6 +14,5 @@ contract D is C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 1337 diff --git a/test/libsolidity/semanticTests/multiSource/free_function_resolution_override_virtual_transitive.sol b/test/libsolidity/semanticTests/multiSource/free_function_resolution_override_virtual_transitive.sol index aa026edcc..e31fdfa3d 100644 --- a/test/libsolidity/semanticTests/multiSource/free_function_resolution_override_virtual_transitive.sol +++ b/test/libsolidity/semanticTests/multiSource/free_function_resolution_override_virtual_transitive.sol @@ -21,6 +21,5 @@ contract E is D { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 1339 diff --git a/test/libsolidity/semanticTests/multiSource/free_function_transitive_import.sol b/test/libsolidity/semanticTests/multiSource/free_function_transitive_import.sol index e10b0634c..585ef8986 100644 --- a/test/libsolidity/semanticTests/multiSource/free_function_transitive_import.sol +++ b/test/libsolidity/semanticTests/multiSource/free_function_transitive_import.sol @@ -23,6 +23,5 @@ contract E is D { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // i() -> 1337 diff --git a/test/libsolidity/semanticTests/multiSource/import.sol b/test/libsolidity/semanticTests/multiSource/import.sol index e7e3400d5..bcaf6f290 100644 --- a/test/libsolidity/semanticTests/multiSource/import.sol +++ b/test/libsolidity/semanticTests/multiSource/import.sol @@ -9,7 +9,6 @@ contract B is A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 1337 -> 1337 // g(uint256): 1337 -> 1338 diff --git a/test/libsolidity/semanticTests/multiSource/import_overloaded_function.sol b/test/libsolidity/semanticTests/multiSource/import_overloaded_function.sol index 503f65680..8d714dd45 100644 --- a/test/libsolidity/semanticTests/multiSource/import_overloaded_function.sol +++ b/test/libsolidity/semanticTests/multiSource/import_overloaded_function.sol @@ -9,7 +9,5 @@ contract C return (sub(1, 2), sub(2)); } } -// ==== -// compileViaYul: also // ---- // f() -> 1, 2 diff --git a/test/libsolidity/semanticTests/multiSource/imported_free_function_via_alias.sol b/test/libsolidity/semanticTests/multiSource/imported_free_function_via_alias.sol index b8a6816db..f980805ed 100644 --- a/test/libsolidity/semanticTests/multiSource/imported_free_function_via_alias.sol +++ b/test/libsolidity/semanticTests/multiSource/imported_free_function_via_alias.sol @@ -15,6 +15,5 @@ contract D is M.C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 61337 diff --git a/test/libsolidity/semanticTests/multiSource/imported_free_function_via_alias_direct_call.sol b/test/libsolidity/semanticTests/multiSource/imported_free_function_via_alias_direct_call.sol index b29fbcb3e..5188f0e4a 100644 --- a/test/libsolidity/semanticTests/multiSource/imported_free_function_via_alias_direct_call.sol +++ b/test/libsolidity/semanticTests/multiSource/imported_free_function_via_alias_direct_call.sol @@ -10,6 +10,5 @@ contract D { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // h() -> 61337 diff --git a/test/libsolidity/semanticTests/multiSource/reimport_imported_function.sol b/test/libsolidity/semanticTests/multiSource/reimport_imported_function.sol index 2c59b4126..a31b438ff 100644 --- a/test/libsolidity/semanticTests/multiSource/reimport_imported_function.sol +++ b/test/libsolidity/semanticTests/multiSource/reimport_imported_function.sol @@ -11,6 +11,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // foo() -> 1337 diff --git a/test/libsolidity/semanticTests/operators/compound_assign.sol b/test/libsolidity/semanticTests/operators/compound_assign.sol index 12c4da348..6ede4522d 100644 --- a/test/libsolidity/semanticTests/operators/compound_assign.sol +++ b/test/libsolidity/semanticTests/operators/compound_assign.sol @@ -11,7 +11,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256,uint256): 0, 6 -> 7 // f(uint256,uint256): 1, 3 -> 0x23 diff --git a/test/libsolidity/semanticTests/operators/shifts/bitwise_shifting_constantinople.sol b/test/libsolidity/semanticTests/operators/shifts/bitwise_shifting_constantinople.sol index c6ada8c6a..e4f0834a0 100644 --- a/test/libsolidity/semanticTests/operators/shifts/bitwise_shifting_constantinople.sol +++ b/test/libsolidity/semanticTests/operators/shifts/bitwise_shifting_constantinople.sol @@ -19,7 +19,6 @@ contract C { } // ==== // EVMVersion: >=constantinople -// compileViaYul: also // ---- // shl(uint256,uint256): 0x01, 0x02 -> 0x04 // shl(uint256,uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x01 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe diff --git a/test/libsolidity/semanticTests/operators/shifts/bitwise_shifting_constantinople_combined.sol b/test/libsolidity/semanticTests/operators/shifts/bitwise_shifting_constantinople_combined.sol index 6cacbe300..6e3bb173c 100644 --- a/test/libsolidity/semanticTests/operators/shifts/bitwise_shifting_constantinople_combined.sol +++ b/test/libsolidity/semanticTests/operators/shifts/bitwise_shifting_constantinople_combined.sol @@ -85,7 +85,6 @@ contract C { } // ==== // EVMVersion: >=constantinople -// compileViaYul: also // ---- // shl_zero(uint256): 0x00 -> 0x00 // shl_zero(uint256): 0xffff -> 0xffff diff --git a/test/libsolidity/semanticTests/operators/shifts/bitwise_shifting_constants_constantinople.sol b/test/libsolidity/semanticTests/operators/shifts/bitwise_shifting_constants_constantinople.sol index bbc5ddaa4..526909c6c 100644 --- a/test/libsolidity/semanticTests/operators/shifts/bitwise_shifting_constants_constantinople.sol +++ b/test/libsolidity/semanticTests/operators/shifts/bitwise_shifting_constants_constantinople.sol @@ -73,7 +73,6 @@ contract C { } // ==== // EVMVersion: >=constantinople -// compileViaYul: also // ---- // shl_1() -> 0x01 // shl_2() -> 0x01 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_cleanup.sol b/test/libsolidity/semanticTests/operators/shifts/shift_cleanup.sol index 85a273940..9f13f4bdc 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_cleanup.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_cleanup.sol @@ -11,6 +11,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x0 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_cleanup_garbled.sol b/test/libsolidity/semanticTests/operators/shifts/shift_cleanup_garbled.sol index 1e83d1038..560def3b4 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_cleanup_garbled.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_cleanup_garbled.sol @@ -9,6 +9,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x0 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_constant_left.sol b/test/libsolidity/semanticTests/operators/shifts/shift_constant_left.sol index b5121261b..1af493006 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_constant_left.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_constant_left.sol @@ -3,6 +3,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // a() -> 0x4200 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_constant_left_assignment.sol b/test/libsolidity/semanticTests/operators/shifts/shift_constant_left_assignment.sol index 7db6248de..aa75ca487 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_constant_left_assignment.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_constant_left_assignment.sol @@ -7,6 +7,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x4200 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_constant_right.sol b/test/libsolidity/semanticTests/operators/shifts/shift_constant_right.sol index 5e12394ab..c39407215 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_constant_right.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_constant_right.sol @@ -3,6 +3,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // a() -> 0x42 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_constant_right_assignment.sol b/test/libsolidity/semanticTests/operators/shifts/shift_constant_right_assignment.sol index 4aebfcf86..0a959aa11 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_constant_right_assignment.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_constant_right_assignment.sol @@ -7,6 +7,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x42 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_left.sol b/test/libsolidity/semanticTests/operators/shifts/shift_left.sol index d2b4cf6b3..058d233e9 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_left.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_left.sol @@ -6,7 +6,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256,uint256): 0x4266, 0x0 -> 0x4266 // f(uint256,uint256): 0x4266, 0x8 -> 0x426600 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_left_assignment.sol b/test/libsolidity/semanticTests/operators/shifts/shift_left_assignment.sol index be470e4d0..55883ddae 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_left_assignment.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_left_assignment.sol @@ -7,7 +7,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256,uint256): 0x4266, 0x0 -> 0x4266 // f(uint256,uint256): 0x4266, 0x8 -> 0x426600 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_left_assignment_different_type.sol b/test/libsolidity/semanticTests/operators/shifts/shift_left_assignment_different_type.sol index 21ad474d3..2242d2a16 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_left_assignment_different_type.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_left_assignment_different_type.sol @@ -7,7 +7,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256,uint8): 0x4266, 0x0 -> 0x4266 // f(uint256,uint8): 0x4266, 0x8 -> 0x426600 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_left_larger_type.sol b/test/libsolidity/semanticTests/operators/shifts/shift_left_larger_type.sol index 8eb90736d..a1c3fc4cf 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_left_larger_type.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_left_larger_type.sol @@ -8,6 +8,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_left_uint32.sol b/test/libsolidity/semanticTests/operators/shifts/shift_left_uint32.sol index 737227697..6a208e9fc 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_left_uint32.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_left_uint32.sol @@ -6,7 +6,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint32,uint32): 0x4266, 0x0 -> 0x4266 // f(uint32,uint32): 0x4266, 0x8 -> 0x426600 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_left_uint8.sol b/test/libsolidity/semanticTests/operators/shifts/shift_left_uint8.sol index 25c9e2c30..f9517fb61 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_left_uint8.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_left_uint8.sol @@ -6,7 +6,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint8,uint8): 0x66, 0x0 -> 0x66 // f(uint8,uint8): 0x66, 0x8 -> 0 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_negative_constant_left.sol b/test/libsolidity/semanticTests/operators/shifts/shift_negative_constant_left.sol index ceaad1799..e303e73ea 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_negative_constant_left.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_negative_constant_left.sol @@ -3,6 +3,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // a() -> -16896 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_negative_constant_right.sol b/test/libsolidity/semanticTests/operators/shifts/shift_negative_constant_right.sol index 02ddee654..32ae16edc 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_negative_constant_right.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_negative_constant_right.sol @@ -3,6 +3,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // a() -> -66 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_overflow.sol b/test/libsolidity/semanticTests/operators/shifts/shift_overflow.sol index 8303f4271..3e63bc8eb 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_overflow.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_overflow.sol @@ -10,7 +10,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // leftU(uint8,uint8): 255, 8 -> 0 // leftU(uint8,uint8): 255, 1 -> 254 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right.sol index 4e4e3a27a..97ca0a5c4 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right.sol @@ -6,7 +6,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256,uint256): 0x4266, 0x0 -> 0x4266 // f(uint256,uint256): 0x4266, 0x8 -> 0x42 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_assignment.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_assignment.sol index 74b1db2f9..b42721084 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_assignment.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_assignment.sol @@ -7,7 +7,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256,uint256): 0x4266, 0x0 -> 0x4266 // f(uint256,uint256): 0x4266, 0x8 -> 0x42 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_signed_v1.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_signed_v1.sol index 4e1779d27..094d75b68 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_signed_v1.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_signed_v1.sol @@ -18,6 +18,7 @@ contract C { } // ==== // ABIEncoderV1Only: true +// compileViaYul: false // ---- // f(int8,uint8): 0x00, 0x03 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe // f(int8,uint8): 0x00, 0x04 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_signed_v2.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_signed_v2.sol index c0cd5ad34..c7fa35495 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_signed_v2.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_signed_v2.sol @@ -20,7 +20,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(int8,uint8): 0x00, 0x03 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe // f(int8,uint8): 0x00, 0x04 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_v1.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_v1.sol index 8649871a0..8412e372b 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_v1.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_v1.sol @@ -10,6 +10,7 @@ contract C { } // ==== // ABIEncoderV1Only: true +// compileViaYul: false // ---- // f(uint8,uint8): 0x00, 0x04 -> 0x0f // f(uint8,uint8): 0x00, 0x1004 -> 0x0f diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_v2.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_v2.sol index 39e6760f3..ecb51e902 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_v2.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_garbled_v2.sol @@ -12,7 +12,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint8,uint8): 0x00, 0x04 -> 0x0f // f(uint8,uint8): 0x00, 0x1004 -> FAILURE diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_literal.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_literal.sol index 4e6487c57..630f4905e 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_literal.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_literal.sol @@ -50,7 +50,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f1() -> true // f2() -> true diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue.sol index 0147bb102..6d2f7ae58 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue.sol @@ -5,7 +5,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(int256,uint256): -4266, 0 -> -4266 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_assignment.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_assignment.sol index d801c9a06..74b704f48 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_assignment.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_assignment.sol @@ -6,7 +6,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(int256,uint256): -4266, 0 -> -4266 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_int16.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_int16.sol index 9c0a0879e..533c93bc9 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_int16.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_int16.sol @@ -5,7 +5,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(int16,uint16): -4266, 0 -> -4266 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_int32.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_int32.sol index f41be2fd5..3dc12b223 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_int32.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_int32.sol @@ -5,7 +5,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(int32,uint32): -4266, 0 -> -4266 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_int8.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_int8.sol index 61d4ab080..f6dda7059 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_int8.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_int8.sol @@ -5,7 +5,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(int8,uint8): -66, 0 -> -66 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int16_v1.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int16_v1.sol index 8200f69cf..0b8d0e833 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int16_v1.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int16_v1.sol @@ -6,6 +6,7 @@ contract C { } // ==== // ABIEncoderV1Only: true +// compileViaYul: false // ---- // f(int16,uint16): 0xff99, 0x00 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff99 // f(int16,uint16): 0xff99, 0x01 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int16_v2.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int16_v2.sol index 5c2ef4b19..d81e00fd5 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int16_v2.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int16_v2.sol @@ -8,7 +8,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(int16,uint16): 0xff99, 0x00 -> FAILURE // f(int16,uint16): 0xff99, 0x01 -> FAILURE diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int32_v1.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int32_v1.sol index 245925b3d..a6b6378c6 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int32_v1.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int32_v1.sol @@ -6,6 +6,7 @@ contract C { } // ==== // ABIEncoderV1Only: true +// compileViaYul: false // ---- // f(int32,uint32): 0xffffff99, 0x00 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff99 // f(int32,uint32): 0xffffff99, 0x01 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int32_v2.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int32_v2.sol index 6f74dadd1..cac3a53b6 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int32_v2.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int32_v2.sol @@ -8,7 +8,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(int32,uint32): 0xffffff99, 0x00 -> FAILURE // f(int32,uint32): 0xffffff99, 0x01 -> FAILURE diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int8_v1.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int8_v1.sol index 4b557fccc..52529a85c 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int8_v1.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int8_v1.sol @@ -6,6 +6,7 @@ contract C { } // ==== // ABIEncoderV1Only: true +// compileViaYul: false // ---- // f(int8,uint8): 0x99, 0x00 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff99 // f(int8,uint8): 0x99, 0x01 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int8_v2.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int8_v2.sol index 0dbdb92ea..0fe10c937 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int8_v2.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_negative_lvalue_signextend_int8_v2.sol @@ -8,7 +8,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(int8,uint8): 0x99, 0x00 -> FAILURE // f(int8,uint8): 0x99, 0x01 -> FAILURE diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_uint32.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_uint32.sol index a384e23ea..a5d1ed51c 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_uint32.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_uint32.sol @@ -6,7 +6,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint32,uint32): 0x4266, 0x0 -> 0x4266 // f(uint32,uint32): 0x4266, 0x8 -> 0x42 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_right_uint8.sol b/test/libsolidity/semanticTests/operators/shifts/shift_right_uint8.sol index 5ae655676..7ac59b3fc 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_right_uint8.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_right_uint8.sol @@ -6,7 +6,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint8,uint8): 0x66, 0x0 -> 0x66 // f(uint8,uint8): 0x66, 0x8 -> 0x0 diff --git a/test/libsolidity/semanticTests/operators/shifts/shift_underflow_negative_rvalue.sol b/test/libsolidity/semanticTests/operators/shifts/shift_underflow_negative_rvalue.sol index 7bc85eb00..111357e9e 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shift_underflow_negative_rvalue.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shift_underflow_negative_rvalue.sol @@ -10,7 +10,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(int256,uint256): 1, -1 -> 0 // g(int256,uint256): 1, -1 -> 0 diff --git a/test/libsolidity/semanticTests/operators/shifts/shifts.sol b/test/libsolidity/semanticTests/operators/shifts/shifts.sol index 6e21956d5..e202f2889 100644 --- a/test/libsolidity/semanticTests/operators/shifts/shifts.sol +++ b/test/libsolidity/semanticTests/operators/shifts/shifts.sol @@ -5,6 +5,5 @@ contract C { } // ==== // EVMVersion: >=constantinople -// compileViaYul: also // ---- // f(uint256): 7 -> 28 diff --git a/test/libsolidity/semanticTests/optimizer/shift_bytes.sol b/test/libsolidity/semanticTests/optimizer/shift_bytes.sol index 1960ee6a8..49d693a77 100644 --- a/test/libsolidity/semanticTests/optimizer/shift_bytes.sol +++ b/test/libsolidity/semanticTests/optimizer/shift_bytes.sol @@ -38,7 +38,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(uint256): 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f -> 0x1f, 0x1f, 3 diff --git a/test/libsolidity/semanticTests/payable/no_nonpayable_circumvention_by_modifier.sol b/test/libsolidity/semanticTests/payable/no_nonpayable_circumvention_by_modifier.sol index b24ca2291..4c6557cd7 100644 --- a/test/libsolidity/semanticTests/payable/no_nonpayable_circumvention_by_modifier.sol +++ b/test/libsolidity/semanticTests/payable/no_nonpayable_circumvention_by_modifier.sol @@ -10,7 +10,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(), 27 wei -> FAILURE diff --git a/test/libsolidity/semanticTests/receive/empty_calldata_calls_receive.sol b/test/libsolidity/semanticTests/receive/empty_calldata_calls_receive.sol index fc87540a0..1be435ff6 100644 --- a/test/libsolidity/semanticTests/receive/empty_calldata_calls_receive.sol +++ b/test/libsolidity/semanticTests/receive/empty_calldata_calls_receive.sol @@ -4,7 +4,6 @@ contract A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // x() -> 0 // () diff --git a/test/libsolidity/semanticTests/receive/ether_and_data.sol b/test/libsolidity/semanticTests/receive/ether_and_data.sol index 5776ecd80..df3c89884 100644 --- a/test/libsolidity/semanticTests/receive/ether_and_data.sol +++ b/test/libsolidity/semanticTests/receive/ether_and_data.sol @@ -3,7 +3,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // (), 1 ether // (), 1 ether: 1 -> FAILURE diff --git a/test/libsolidity/semanticTests/receive/inherited.sol b/test/libsolidity/semanticTests/receive/inherited.sol index 5a5df320a..9ca685399 100644 --- a/test/libsolidity/semanticTests/receive/inherited.sol +++ b/test/libsolidity/semanticTests/receive/inherited.sol @@ -6,7 +6,6 @@ contract A { contract B is A {} // ==== // compileToEwasm: also -// compileViaYul: also // ---- // getData() -> 0 // () -> diff --git a/test/libsolidity/semanticTests/revertStrings/array_slices.sol b/test/libsolidity/semanticTests/revertStrings/array_slices.sol index 2966ab534..dec3e916d 100644 --- a/test/libsolidity/semanticTests/revertStrings/array_slices.sol +++ b/test/libsolidity/semanticTests/revertStrings/array_slices.sol @@ -5,7 +5,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // f(uint256,uint256,uint256[]): 2, 1, 0x80, 3, 1, 2, 3 -> FAILURE, hex"08c379a0", 0x20, 22, "Slice starts after end" diff --git a/test/libsolidity/semanticTests/revertStrings/bubble.sol b/test/libsolidity/semanticTests/revertStrings/bubble.sol index d143aeef8..5e9a0730d 100644 --- a/test/libsolidity/semanticTests/revertStrings/bubble.sol +++ b/test/libsolidity/semanticTests/revertStrings/bubble.sol @@ -10,7 +10,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // f() -> FAILURE, hex"08c379a0", 0x20, 4, "fail" diff --git a/test/libsolidity/semanticTests/revertStrings/calldata_array_dynamic_invalid.sol b/test/libsolidity/semanticTests/revertStrings/calldata_array_dynamic_invalid.sol index b28c05b44..355c47223 100644 --- a/test/libsolidity/semanticTests/revertStrings/calldata_array_dynamic_invalid.sol +++ b/test/libsolidity/semanticTests/revertStrings/calldata_array_dynamic_invalid.sol @@ -6,7 +6,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // f(uint256[][]): 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride" diff --git a/test/libsolidity/semanticTests/revertStrings/calldata_array_dynamic_static_short_decode.sol b/test/libsolidity/semanticTests/revertStrings/calldata_array_dynamic_static_short_decode.sol index f09dca528..7c5ba33b7 100644 --- a/test/libsolidity/semanticTests/revertStrings/calldata_array_dynamic_static_short_decode.sol +++ b/test/libsolidity/semanticTests/revertStrings/calldata_array_dynamic_static_short_decode.sol @@ -7,7 +7,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // f(uint256[][2][]): 0x20, 0x01, 0x20, 0x00 -> FAILURE, hex"08c379a0", 0x20, 28, "Invalid calldata tail offset" diff --git a/test/libsolidity/semanticTests/revertStrings/calldata_array_dynamic_static_short_reencode.sol b/test/libsolidity/semanticTests/revertStrings/calldata_array_dynamic_static_short_reencode.sol index 2eb8d2fb9..77341fa26 100644 --- a/test/libsolidity/semanticTests/revertStrings/calldata_array_dynamic_static_short_reencode.sol +++ b/test/libsolidity/semanticTests/revertStrings/calldata_array_dynamic_static_short_reencode.sol @@ -9,7 +9,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // g(uint256[][2][]): 0x20, 0x01, 0x20, 0x00 -> FAILURE, hex"08c379a0", 0x20, 30, "Invalid calldata access offset" diff --git a/test/libsolidity/semanticTests/revertStrings/calldata_array_invalid_length.sol b/test/libsolidity/semanticTests/revertStrings/calldata_array_invalid_length.sol index 3405ef350..4af015f33 100644 --- a/test/libsolidity/semanticTests/revertStrings/calldata_array_invalid_length.sol +++ b/test/libsolidity/semanticTests/revertStrings/calldata_array_invalid_length.sol @@ -6,7 +6,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // f(uint256[][]): 0x20, 1, 0x20, 0x0100000000000000000000 -> FAILURE, hex"08c379a0", 0x20, 28, "Invalid calldata tail length" diff --git a/test/libsolidity/semanticTests/revertStrings/calldata_arrays_too_large.sol b/test/libsolidity/semanticTests/revertStrings/calldata_arrays_too_large.sol index 3988dd892..34a6f0a02 100644 --- a/test/libsolidity/semanticTests/revertStrings/calldata_arrays_too_large.sol +++ b/test/libsolidity/semanticTests/revertStrings/calldata_arrays_too_large.sol @@ -6,7 +6,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // f(uint256,uint256[],uint256): 6, 0x60, 9, 0x1000000000000000000000000000000000000000000000000000000000000002, 1, 2 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray length" diff --git a/test/libsolidity/semanticTests/revertStrings/calldata_tail_short.sol b/test/libsolidity/semanticTests/revertStrings/calldata_tail_short.sol index f60e97ef2..c0c1e3f4c 100644 --- a/test/libsolidity/semanticTests/revertStrings/calldata_tail_short.sol +++ b/test/libsolidity/semanticTests/revertStrings/calldata_tail_short.sol @@ -4,7 +4,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // f(uint256[][]): 0x20, 1, 0x20, 2, 0x42 -> FAILURE, hex"08c379a0", 0x20, 23, "Calldata tail too short" diff --git a/test/libsolidity/semanticTests/revertStrings/calldata_too_short_v1.sol b/test/libsolidity/semanticTests/revertStrings/calldata_too_short_v1.sol index e9fc7e331..4677d350f 100644 --- a/test/libsolidity/semanticTests/revertStrings/calldata_too_short_v1.sol +++ b/test/libsolidity/semanticTests/revertStrings/calldata_too_short_v1.sol @@ -8,5 +8,6 @@ contract C { // EVMVersion: >=byzantium // revertStrings: debug // ABIEncoderV1Only: true +// compileViaYul: false // ---- // d(bytes): 0x20, 0x01, 0x0000000000000000000000000000000000000000000000000000000000000000 -> FAILURE, hex"08c379a0", 0x20, 18, "Calldata too short" diff --git a/test/libsolidity/semanticTests/revertStrings/called_contract_has_code.sol b/test/libsolidity/semanticTests/revertStrings/called_contract_has_code.sol index 356a3f1d4..110b1e50c 100644 --- a/test/libsolidity/semanticTests/revertStrings/called_contract_has_code.sol +++ b/test/libsolidity/semanticTests/revertStrings/called_contract_has_code.sol @@ -7,7 +7,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // g() -> FAILURE, hex"08c379a0", 0x20, 37, "Target contract does not contain", " code" diff --git a/test/libsolidity/semanticTests/revertStrings/empty_v1.sol b/test/libsolidity/semanticTests/revertStrings/empty_v1.sol index 4e6fffc79..b9658c794 100644 --- a/test/libsolidity/semanticTests/revertStrings/empty_v1.sol +++ b/test/libsolidity/semanticTests/revertStrings/empty_v1.sol @@ -10,8 +10,8 @@ contract C { // ==== // ABIEncoderV1Only: true // EVMVersion: >=byzantium -// compileViaYul: false // revertStrings: debug +// compileViaYul: false // ---- // f() -> FAILURE, hex"08c379a0", 0x20, 0 // g(string): 0x20, 0, "" -> FAILURE, hex"08c379a0", 0x20, 0 diff --git a/test/libsolidity/semanticTests/revertStrings/empty_v2.sol b/test/libsolidity/semanticTests/revertStrings/empty_v2.sol index ea81afbe8..24a684904 100644 --- a/test/libsolidity/semanticTests/revertStrings/empty_v2.sol +++ b/test/libsolidity/semanticTests/revertStrings/empty_v2.sol @@ -9,7 +9,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // f() -> FAILURE, hex"08c379a0", 0x20, 0 diff --git a/test/libsolidity/semanticTests/revertStrings/enum_v1.sol b/test/libsolidity/semanticTests/revertStrings/enum_v1.sol index ebf042653..305e43a57 100644 --- a/test/libsolidity/semanticTests/revertStrings/enum_v1.sol +++ b/test/libsolidity/semanticTests/revertStrings/enum_v1.sol @@ -9,5 +9,6 @@ contract C { // EVMVersion: >=byzantium // revertStrings: debug // ABIEncoderV1Only: true +// compileViaYul: false // ---- // f(uint8[]): 0x20, 2, 3, 3 -> FAILURE, hex"08c379a0", 0x20, 17, "Enum out of range" diff --git a/test/libsolidity/semanticTests/revertStrings/enum_v2.sol b/test/libsolidity/semanticTests/revertStrings/enum_v2.sol index 6952dc0ce..e2f77e551 100644 --- a/test/libsolidity/semanticTests/revertStrings/enum_v2.sol +++ b/test/libsolidity/semanticTests/revertStrings/enum_v2.sol @@ -7,7 +7,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // f(uint8[]): 0x20, 2, 3, 3 -> FAILURE diff --git a/test/libsolidity/semanticTests/revertStrings/ether_non_payable_function.sol b/test/libsolidity/semanticTests/revertStrings/ether_non_payable_function.sol index cabe385ef..ffaea6878 100644 --- a/test/libsolidity/semanticTests/revertStrings/ether_non_payable_function.sol +++ b/test/libsolidity/semanticTests/revertStrings/ether_non_payable_function.sol @@ -3,7 +3,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // f(), 1 ether -> FAILURE, hex"08c379a0", 0x20, 34, "Ether sent to non-payable functi", "on" diff --git a/test/libsolidity/semanticTests/revertStrings/function_entry_checks_v1.sol b/test/libsolidity/semanticTests/revertStrings/function_entry_checks_v1.sol index 2a57f728b..13c3d8542 100644 --- a/test/libsolidity/semanticTests/revertStrings/function_entry_checks_v1.sol +++ b/test/libsolidity/semanticTests/revertStrings/function_entry_checks_v1.sol @@ -5,7 +5,7 @@ contract C { // ==== // EVMVersion: >=byzantium // ABIEncoderV1Only: true -// compileViaYul: false // revertStrings: debug +// compileViaYul: false // ---- // t(uint256) -> FAILURE, hex"08c379a0", 0x20, 0x12, "Calldata too short" diff --git a/test/libsolidity/semanticTests/revertStrings/function_entry_checks_v2.sol b/test/libsolidity/semanticTests/revertStrings/function_entry_checks_v2.sol index 92e0cc70c..3412f58c6 100644 --- a/test/libsolidity/semanticTests/revertStrings/function_entry_checks_v2.sol +++ b/test/libsolidity/semanticTests/revertStrings/function_entry_checks_v2.sol @@ -4,7 +4,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // t(uint256) -> FAILURE, hex"08c379a0", 0x20, 34, "ABI decoding: tuple data too sho", "rt" diff --git a/test/libsolidity/semanticTests/revertStrings/invalid_abi_decoding_calldata_v1.sol b/test/libsolidity/semanticTests/revertStrings/invalid_abi_decoding_calldata_v1.sol index a74af7c1c..41cd0f4d2 100644 --- a/test/libsolidity/semanticTests/revertStrings/invalid_abi_decoding_calldata_v1.sol +++ b/test/libsolidity/semanticTests/revertStrings/invalid_abi_decoding_calldata_v1.sol @@ -8,6 +8,7 @@ contract C { // EVMVersion: >=byzantium // revertStrings: debug // ABIEncoderV1Only: true +// compileViaYul: false // ---- // d(bytes): 0x20, 0x20, 0x0000000000000000000000000000000000000000000000000000000000000000 -> 0 // d(bytes): 0x100, 0x20, 0x0000000000000000000000000000000000000000000000000000000000000000 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI calldata decoding: invalid h", "ead pointer" diff --git a/test/libsolidity/semanticTests/revertStrings/invalid_abi_decoding_memory_v1.sol b/test/libsolidity/semanticTests/revertStrings/invalid_abi_decoding_memory_v1.sol index 3f4c8cb3b..af9d822dd 100644 --- a/test/libsolidity/semanticTests/revertStrings/invalid_abi_decoding_memory_v1.sol +++ b/test/libsolidity/semanticTests/revertStrings/invalid_abi_decoding_memory_v1.sol @@ -16,6 +16,7 @@ contract C { // EVMVersion: >=byzantium // revertStrings: debug // ABIEncoderV1Only: true +// compileViaYul: false // ---- // f(uint256,uint256,uint256): 0, 0x200, 0x60 -> FAILURE, hex"08c379a0", 0x20, 39, "ABI memory decoding: invalid dat", "a start" // f(uint256,uint256,uint256): 0, 0x20, 0x60 -> FAILURE, hex"08c379a0", 0x20, 40, "ABI memory decoding: invalid dat", "a length" diff --git a/test/libsolidity/semanticTests/revertStrings/library_non_view_call.sol b/test/libsolidity/semanticTests/revertStrings/library_non_view_call.sol index 9df7705ca..1a079a04a 100644 --- a/test/libsolidity/semanticTests/revertStrings/library_non_view_call.sol +++ b/test/libsolidity/semanticTests/revertStrings/library_non_view_call.sol @@ -10,7 +10,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // library: L diff --git a/test/libsolidity/semanticTests/revertStrings/short_input_array.sol b/test/libsolidity/semanticTests/revertStrings/short_input_array.sol index d41e5128f..4a96accf0 100644 --- a/test/libsolidity/semanticTests/revertStrings/short_input_array.sol +++ b/test/libsolidity/semanticTests/revertStrings/short_input_array.sol @@ -4,7 +4,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // f(uint256[]): 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride" diff --git a/test/libsolidity/semanticTests/revertStrings/short_input_bytes.sol b/test/libsolidity/semanticTests/revertStrings/short_input_bytes.sol index a79b3cd2b..2f275b86d 100644 --- a/test/libsolidity/semanticTests/revertStrings/short_input_bytes.sol +++ b/test/libsolidity/semanticTests/revertStrings/short_input_bytes.sol @@ -4,7 +4,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // e(bytes): 0x20, 7 -> FAILURE, hex"08c379a0", 0x20, 39, "ABI decoding: invalid byte array", " length" diff --git a/test/libsolidity/semanticTests/revertStrings/transfer.sol b/test/libsolidity/semanticTests/revertStrings/transfer.sol index a9c9bc845..ef2e72859 100644 --- a/test/libsolidity/semanticTests/revertStrings/transfer.sol +++ b/test/libsolidity/semanticTests/revertStrings/transfer.sol @@ -19,7 +19,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // (), 10 wei -> diff --git a/test/libsolidity/semanticTests/revertStrings/unknown_sig_no_fallback.sol b/test/libsolidity/semanticTests/revertStrings/unknown_sig_no_fallback.sol index fc128fb8e..62b245885 100644 --- a/test/libsolidity/semanticTests/revertStrings/unknown_sig_no_fallback.sol +++ b/test/libsolidity/semanticTests/revertStrings/unknown_sig_no_fallback.sol @@ -3,7 +3,6 @@ contract A { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // revertStrings: debug // ---- // (): hex"00" -> FAILURE, hex"08c379a0", 0x20, 41, "Unknown signature and no fallbac", "k defined" diff --git a/test/libsolidity/semanticTests/reverts/assert_require.sol b/test/libsolidity/semanticTests/reverts/assert_require.sol index af2418061..ee60fc192 100644 --- a/test/libsolidity/semanticTests/reverts/assert_require.sol +++ b/test/libsolidity/semanticTests/reverts/assert_require.sol @@ -16,7 +16,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> FAILURE, hex"4e487b71", 0x01 // g(bool): false -> FAILURE, hex"4e487b71", 0x01 diff --git a/test/libsolidity/semanticTests/reverts/error_struct.sol b/test/libsolidity/semanticTests/reverts/error_struct.sol index d837068a7..4ca57bd6e 100644 --- a/test/libsolidity/semanticTests/reverts/error_struct.sol +++ b/test/libsolidity/semanticTests/reverts/error_struct.sol @@ -11,7 +11,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> FAILURE, hex"f8a8fd6d" diff --git a/test/libsolidity/semanticTests/reverts/invalid_enum_as_external_arg.sol b/test/libsolidity/semanticTests/reverts/invalid_enum_as_external_arg.sol index 5c0ee13dc..1e3e34cb1 100644 --- a/test/libsolidity/semanticTests/reverts/invalid_enum_as_external_arg.sol +++ b/test/libsolidity/semanticTests/reverts/invalid_enum_as_external_arg.sol @@ -18,6 +18,5 @@ contract C { // ==== // EVMVersion: >=byzantium // compileToEwasm: also -// compileViaYul: also // ---- // test() -> FAILURE, hex"4e487b71", 0x21 # should throw # diff --git a/test/libsolidity/semanticTests/reverts/invalid_enum_as_external_ret.sol b/test/libsolidity/semanticTests/reverts/invalid_enum_as_external_ret.sol index 81f514b4c..987931fa7 100644 --- a/test/libsolidity/semanticTests/reverts/invalid_enum_as_external_ret.sol +++ b/test/libsolidity/semanticTests/reverts/invalid_enum_as_external_ret.sol @@ -27,7 +27,6 @@ contract C { // ==== // EVMVersion: >=byzantium // compileToEwasm: also -// compileViaYul: also // ---- // test_return() -> FAILURE, hex"4e487b71", 33 # both should throw # // test_inline_assignment() -> FAILURE, hex"4e487b71", 33 diff --git a/test/libsolidity/semanticTests/reverts/invalid_enum_compared.sol b/test/libsolidity/semanticTests/reverts/invalid_enum_compared.sol index bf99c6377..afdbd20b6 100644 --- a/test/libsolidity/semanticTests/reverts/invalid_enum_compared.sol +++ b/test/libsolidity/semanticTests/reverts/invalid_enum_compared.sol @@ -25,7 +25,6 @@ contract C { // ==== // EVMVersion: >=byzantium // compileToEwasm: also -// compileViaYul: also // ---- // test_eq_ok() -> 1 // test_eq() -> FAILURE, hex"4e487b71", 33 # both should throw # diff --git a/test/libsolidity/semanticTests/reverts/invalid_enum_stored.sol b/test/libsolidity/semanticTests/reverts/invalid_enum_stored.sol index b77076a70..fdf5e6bbb 100644 --- a/test/libsolidity/semanticTests/reverts/invalid_enum_stored.sol +++ b/test/libsolidity/semanticTests/reverts/invalid_enum_stored.sol @@ -19,7 +19,6 @@ contract C { // ==== // EVMVersion: >=byzantium // compileToEwasm: also -// compileViaYul: also // ---- // test_store_ok() -> 1 // x() -> 0 diff --git a/test/libsolidity/semanticTests/reverts/invalid_instruction.sol b/test/libsolidity/semanticTests/reverts/invalid_instruction.sol index 1bb64db6e..f4f64a11e 100644 --- a/test/libsolidity/semanticTests/reverts/invalid_instruction.sol +++ b/test/libsolidity/semanticTests/reverts/invalid_instruction.sol @@ -8,6 +8,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> FAILURE diff --git a/test/libsolidity/semanticTests/reverts/revert.sol b/test/libsolidity/semanticTests/reverts/revert.sol index 9f99ed86e..cac02076d 100644 --- a/test/libsolidity/semanticTests/reverts/revert.sol +++ b/test/libsolidity/semanticTests/reverts/revert.sol @@ -16,7 +16,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> FAILURE // a() -> 42 diff --git a/test/libsolidity/semanticTests/reverts/revert_return_area.sol b/test/libsolidity/semanticTests/reverts/revert_return_area.sol index 99ef69ce9..fa8156b30 100644 --- a/test/libsolidity/semanticTests/reverts/revert_return_area.sol +++ b/test/libsolidity/semanticTests/reverts/revert_return_area.sol @@ -15,6 +15,5 @@ contract C { // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f() -> 0x00, 0x08c379a000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/reverts/simple_throw.sol b/test/libsolidity/semanticTests/reverts/simple_throw.sol index 0e075c0dc..0d43c97e9 100644 --- a/test/libsolidity/semanticTests/reverts/simple_throw.sol +++ b/test/libsolidity/semanticTests/reverts/simple_throw.sol @@ -8,7 +8,6 @@ contract Test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 11 -> 21 // f(uint256): 1 -> FAILURE diff --git a/test/libsolidity/semanticTests/salted_create/salted_create.sol b/test/libsolidity/semanticTests/salted_create/salted_create.sol index 51b987c2c..80869b5aa 100644 --- a/test/libsolidity/semanticTests/salted_create/salted_create.sol +++ b/test/libsolidity/semanticTests/salted_create/salted_create.sol @@ -18,10 +18,9 @@ contract A { } // ==== // EVMVersion: >=constantinople -// compileViaYul: also // ---- // different_salt() -> true // same_salt() -> true -// gas irOptimized: 98438898 +// gas irOptimized: 98438900 // gas legacy: 98439116 // gas legacyOptimized: 98438970 diff --git a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol index 6613e471b..d51b99b59 100644 --- a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol +++ b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol @@ -19,9 +19,8 @@ contract A { } // ==== // EVMVersion: >=constantinople -// compileViaYul: also // ---- // f(), 10 ether -> 3007, 3008, 3009 -// gas irOptimized: 271831 -// gas legacy: 422501 -// gas legacyOptimized: 287472 +// gas irOptimized: 255997 +// gas legacy: 387712 +// gas legacyOptimized: 283266 diff --git a/test/libsolidity/semanticTests/smoke/alignment.sol b/test/libsolidity/semanticTests/smoke/alignment.sol index 80c69bb43..bdf2ed446 100644 --- a/test/libsolidity/semanticTests/smoke/alignment.sol +++ b/test/libsolidity/semanticTests/smoke/alignment.sol @@ -18,8 +18,6 @@ contract D { return (stateBool, stateDecimal, stateBytes); } } -// ==== -// compileViaYul: also // ---- // stateBool() -> true // stateBool() -> right(true) diff --git a/test/libsolidity/semanticTests/smoke/arrays.sol b/test/libsolidity/semanticTests/smoke/arrays.sol index 85d721d14..404c7157f 100644 --- a/test/libsolidity/semanticTests/smoke/arrays.sol +++ b/test/libsolidity/semanticTests/smoke/arrays.sol @@ -32,8 +32,6 @@ contract C { return (["any", "any"], ["any", "any", "any"]); } } -// ==== -// compileViaYul: also // ---- // r() -> true, false, true // s() -> 123, 456, 789 diff --git a/test/libsolidity/semanticTests/smoke/basic.sol b/test/libsolidity/semanticTests/smoke/basic.sol index 36ed181d5..81e8bd829 100644 --- a/test/libsolidity/semanticTests/smoke/basic.sol +++ b/test/libsolidity/semanticTests/smoke/basic.sol @@ -29,7 +29,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // d() -> diff --git a/test/libsolidity/semanticTests/smoke/bytes_and_strings.sol b/test/libsolidity/semanticTests/smoke/bytes_and_strings.sol index f1094fe5f..c20dd919e 100644 --- a/test/libsolidity/semanticTests/smoke/bytes_and_strings.sol +++ b/test/libsolidity/semanticTests/smoke/bytes_and_strings.sol @@ -12,8 +12,6 @@ contract C { return "any"; } } -// ==== -// compileViaYul: also // ---- // e(bytes): 32, 3, hex"AB33BB" -> 32, 3, left(0xAB33BB) // e(bytes): 32, 32, 0x20 -> 32, 32, 0x20 diff --git a/test/libsolidity/semanticTests/smoke/constructor.sol b/test/libsolidity/semanticTests/smoke/constructor.sol index 3003c5d8d..b834f8018 100644 --- a/test/libsolidity/semanticTests/smoke/constructor.sol +++ b/test/libsolidity/semanticTests/smoke/constructor.sol @@ -10,11 +10,9 @@ contract C { state = _state; } } -// ==== -// compileViaYul: also // ---- // constructor(), 2 wei: 3 -> -// gas irOptimized: 107627 +// gas irOptimized: 107003 // gas legacy: 151416 // gas legacyOptimized: 108388 // state() -> 3 diff --git a/test/libsolidity/semanticTests/smoke/failure.sol b/test/libsolidity/semanticTests/smoke/failure.sol index ed672dcf6..eeb82a3ce 100644 --- a/test/libsolidity/semanticTests/smoke/failure.sol +++ b/test/libsolidity/semanticTests/smoke/failure.sol @@ -17,7 +17,6 @@ contract C { // EVMVersion: >homestead // allowNonExistingFunctions: true // compileToEwasm: also -// compileViaYul: also // ---- // _() -> FAILURE // e() -> FAILURE, hex"08c379a0", 0x20, 0x13, "Transaction failed." diff --git a/test/libsolidity/semanticTests/smoke/fallback.sol b/test/libsolidity/semanticTests/smoke/fallback.sol index f789ed276..5a4f89d84 100644 --- a/test/libsolidity/semanticTests/smoke/fallback.sol +++ b/test/libsolidity/semanticTests/smoke/fallback.sol @@ -10,7 +10,6 @@ contract A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // data() -> 0 // () diff --git a/test/libsolidity/semanticTests/smoke/multiline.sol b/test/libsolidity/semanticTests/smoke/multiline.sol index 587532cfe..97fbd5b3b 100644 --- a/test/libsolidity/semanticTests/smoke/multiline.sol +++ b/test/libsolidity/semanticTests/smoke/multiline.sol @@ -6,7 +6,6 @@ contract C { // ==== // allowNonExistingFunctions: true // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256,uint256,uint256,uint256,uint256): 1, 1, 1, 1, 1 // -> 5 diff --git a/test/libsolidity/semanticTests/smoke/multiline_comments.sol b/test/libsolidity/semanticTests/smoke/multiline_comments.sol index 4fde637fa..cdfe43f5e 100644 --- a/test/libsolidity/semanticTests/smoke/multiline_comments.sol +++ b/test/libsolidity/semanticTests/smoke/multiline_comments.sol @@ -5,7 +5,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256,uint256,uint256,uint256,uint256): 1, 1, 1, 1, 1 // # A comment on the function parameters. # diff --git a/test/libsolidity/semanticTests/smoke/structs.sol b/test/libsolidity/semanticTests/smoke/structs.sol index d291e59ec..813d6954c 100644 --- a/test/libsolidity/semanticTests/smoke/structs.sol +++ b/test/libsolidity/semanticTests/smoke/structs.sol @@ -19,7 +19,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // s() -> 23, 42 // t() -> 0x20, 23, 42, 0x60, 3, "any" diff --git a/test/libsolidity/semanticTests/specialFunctions/abi_encode_with_signature_from_string.sol b/test/libsolidity/semanticTests/specialFunctions/abi_encode_with_signature_from_string.sol index 7598d382a..f38eee429 100644 --- a/test/libsolidity/semanticTests/specialFunctions/abi_encode_with_signature_from_string.sol +++ b/test/libsolidity/semanticTests/specialFunctions/abi_encode_with_signature_from_string.sol @@ -10,6 +10,5 @@ contract C { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // f() -> 0x40, 0xa0, 0x24, -813742827273327954027712588510533233455028711326166692885570228492575965184, 26959946667150639794667015087019630673637144422540572481103610249216, 0x24, -813742827273327954027712588510533233455028711326166692885570228492575965184, 26959946667150639794667015087019630673637144422540572481103610249216 diff --git a/test/libsolidity/semanticTests/specialFunctions/abi_functions_member_access.sol b/test/libsolidity/semanticTests/specialFunctions/abi_functions_member_access.sol index c377c616d..4c46d1ea0 100644 --- a/test/libsolidity/semanticTests/specialFunctions/abi_functions_member_access.sol +++ b/test/libsolidity/semanticTests/specialFunctions/abi_functions_member_access.sol @@ -9,6 +9,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> diff --git a/test/libsolidity/semanticTests/specialFunctions/keccak256_optimized.sol b/test/libsolidity/semanticTests/specialFunctions/keccak256_optimized.sol index cb3c8d608..6dcb53e2d 100644 --- a/test/libsolidity/semanticTests/specialFunctions/keccak256_optimized.sol +++ b/test/libsolidity/semanticTests/specialFunctions/keccak256_optimized.sol @@ -12,8 +12,6 @@ contract C { return (a == keccak256(s), sc == keccak256(s)); } } -// ==== -// compileViaYul: also // ---- // short() -> true // long() -> true, true diff --git a/test/libsolidity/semanticTests/state/block_basefee.sol b/test/libsolidity/semanticTests/state/block_basefee.sol index 0b54008b0..ebeaceec7 100644 --- a/test/libsolidity/semanticTests/state/block_basefee.sol +++ b/test/libsolidity/semanticTests/state/block_basefee.sol @@ -10,7 +10,6 @@ contract C { } // ==== // EVMVersion: >=london -// compileViaYul: also // ---- // f() -> 7 // g() -> 7 diff --git a/test/libsolidity/semanticTests/state/block_chainid.sol b/test/libsolidity/semanticTests/state/block_chainid.sol index 473629d8d..5d157323e 100644 --- a/test/libsolidity/semanticTests/state/block_chainid.sol +++ b/test/libsolidity/semanticTests/state/block_chainid.sol @@ -5,7 +5,6 @@ contract C { } // ==== // EVMVersion: >=istanbul -// compileViaYul: also // ---- // f() -> 1 // f() -> 1 diff --git a/test/libsolidity/semanticTests/state/block_coinbase.sol b/test/libsolidity/semanticTests/state/block_coinbase.sol index 4d0f70539..5087fe732 100644 --- a/test/libsolidity/semanticTests/state/block_coinbase.sol +++ b/test/libsolidity/semanticTests/state/block_coinbase.sol @@ -5,7 +5,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x7878787878787878787878787878787878787878 // f() -> 0x7878787878787878787878787878787878787878 diff --git a/test/libsolidity/semanticTests/state/block_difficulty.sol b/test/libsolidity/semanticTests/state/block_difficulty.sol index cb25e87cb..ae2a5b43a 100644 --- a/test/libsolidity/semanticTests/state/block_difficulty.sol +++ b/test/libsolidity/semanticTests/state/block_difficulty.sol @@ -4,7 +4,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 200000000 diff --git a/test/libsolidity/semanticTests/state/block_gaslimit.sol b/test/libsolidity/semanticTests/state/block_gaslimit.sol index 3ca022182..3ccc37543 100644 --- a/test/libsolidity/semanticTests/state/block_gaslimit.sol +++ b/test/libsolidity/semanticTests/state/block_gaslimit.sol @@ -5,7 +5,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 20000000 // f() -> 20000000 diff --git a/test/libsolidity/semanticTests/state/block_number.sol b/test/libsolidity/semanticTests/state/block_number.sol index 8faa72c14..a55c2a3ca 100644 --- a/test/libsolidity/semanticTests/state/block_number.sol +++ b/test/libsolidity/semanticTests/state/block_number.sol @@ -6,7 +6,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // constructor() // f() -> 2 diff --git a/test/libsolidity/semanticTests/state/block_timestamp.sol b/test/libsolidity/semanticTests/state/block_timestamp.sol index 4617ab0e0..84cfe3b9f 100644 --- a/test/libsolidity/semanticTests/state/block_timestamp.sol +++ b/test/libsolidity/semanticTests/state/block_timestamp.sol @@ -6,7 +6,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // constructor() # This is the 1st block # // f() -> 0x1e # This is the 2nd block (each block is "15 seconds") # diff --git a/test/libsolidity/semanticTests/state/blockhash_basic.sol b/test/libsolidity/semanticTests/state/blockhash_basic.sol index 829a8695d..f6830a202 100644 --- a/test/libsolidity/semanticTests/state/blockhash_basic.sol +++ b/test/libsolidity/semanticTests/state/blockhash_basic.sol @@ -10,11 +10,9 @@ contract C { return blockhash(blockNumber); } } -// ==== -// compileViaYul: also // ---- // constructor() -// gas irOptimized: 111584 +// gas irOptimized: 110504 // gas legacy: 155081 // gas legacyOptimized: 107997 // genesisHash() -> 0x3737373737373737373737373737373737373737373737373737373737373737 diff --git a/test/libsolidity/semanticTests/state/gasleft.sol b/test/libsolidity/semanticTests/state/gasleft.sol index 61edb5480..9f50ef46d 100644 --- a/test/libsolidity/semanticTests/state/gasleft.sol +++ b/test/libsolidity/semanticTests/state/gasleft.sol @@ -5,7 +5,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> true // f() -> true diff --git a/test/libsolidity/semanticTests/state/msg_data.sol b/test/libsolidity/semanticTests/state/msg_data.sol index 6217da3b6..5a240461a 100644 --- a/test/libsolidity/semanticTests/state/msg_data.sol +++ b/test/libsolidity/semanticTests/state/msg_data.sol @@ -6,8 +6,6 @@ contract C { return msg.data; } } -// ==== -// compileViaYul: also // ---- // f() -> 0x20, 4, 17219911917854084299749778639755835327755045716242581057573779540915269926912 // g(uint256,bool): 1234, true -> 0x20, 0x44, 35691323728519381642872894128098848782337736632589179916067422734266033766400, 33268574187263889506619096617382224251268236217415066441681855047532544, 26959946667150639794667015087019630673637144422540572481103610249216 diff --git a/test/libsolidity/semanticTests/state/msg_sender.sol b/test/libsolidity/semanticTests/state/msg_sender.sol index 45f384c5f..eda4e5a05 100644 --- a/test/libsolidity/semanticTests/state/msg_sender.sol +++ b/test/libsolidity/semanticTests/state/msg_sender.sol @@ -5,6 +5,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x1212121212121212121212121212120000000012 diff --git a/test/libsolidity/semanticTests/state/msg_sig.sol b/test/libsolidity/semanticTests/state/msg_sig.sol index 0003c2ada..858ee9853 100644 --- a/test/libsolidity/semanticTests/state/msg_sig.sol +++ b/test/libsolidity/semanticTests/state/msg_sig.sol @@ -8,7 +8,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x26121ff000000000000000000000000000000000000000000000000000000000 // g() -> 0xe2179b8e00000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/state/msg_value.sol b/test/libsolidity/semanticTests/state/msg_value.sol index e3a72f599..2d14d1d7b 100644 --- a/test/libsolidity/semanticTests/state/msg_value.sol +++ b/test/libsolidity/semanticTests/state/msg_value.sol @@ -4,7 +4,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 0 diff --git a/test/libsolidity/semanticTests/state/tx_gasprice.sol b/test/libsolidity/semanticTests/state/tx_gasprice.sol index c41edc590..59ddfbe5c 100644 --- a/test/libsolidity/semanticTests/state/tx_gasprice.sol +++ b/test/libsolidity/semanticTests/state/tx_gasprice.sol @@ -4,7 +4,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 3000000000 diff --git a/test/libsolidity/semanticTests/state/tx_origin.sol b/test/libsolidity/semanticTests/state/tx_origin.sol index 861ef3d6d..838353824 100644 --- a/test/libsolidity/semanticTests/state/tx_origin.sol +++ b/test/libsolidity/semanticTests/state/tx_origin.sol @@ -5,7 +5,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x9292929292929292929292929292929292929292 // f() -> 0x9292929292929292929292929292929292929292 diff --git a/test/libsolidity/semanticTests/state/uncalled_blockhash.sol b/test/libsolidity/semanticTests/state/uncalled_blockhash.sol index a038478e0..02c55c7d3 100644 --- a/test/libsolidity/semanticTests/state/uncalled_blockhash.sol +++ b/test/libsolidity/semanticTests/state/uncalled_blockhash.sol @@ -5,6 +5,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x3737373737373737373737373737373737373737373737373737373737373738 diff --git a/test/libsolidity/semanticTests/state_var_initialization.sol b/test/libsolidity/semanticTests/state_var_initialization.sol index df3997603..93b22bfa9 100644 --- a/test/libsolidity/semanticTests/state_var_initialization.sol +++ b/test/libsolidity/semanticTests/state_var_initialization.sol @@ -9,7 +9,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // i() -> 2 // k() -> 0 diff --git a/test/libsolidity/semanticTests/state_variables_init_order.sol b/test/libsolidity/semanticTests/state_variables_init_order.sol index 740bdb152..b6ac20cd0 100644 --- a/test/libsolidity/semanticTests/state_variables_init_order.sol +++ b/test/libsolidity/semanticTests/state_variables_init_order.sol @@ -10,6 +10,5 @@ contract B is A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // x() -> 1 diff --git a/test/libsolidity/semanticTests/state_variables_init_order_2.sol b/test/libsolidity/semanticTests/state_variables_init_order_2.sol index 8a339f2b8..95c0b4200 100644 --- a/test/libsolidity/semanticTests/state_variables_init_order_2.sol +++ b/test/libsolidity/semanticTests/state_variables_init_order_2.sol @@ -14,6 +14,5 @@ contract B is A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // z() -> 1 diff --git a/test/libsolidity/semanticTests/statements/do_while_loop_continue.sol b/test/libsolidity/semanticTests/statements/do_while_loop_continue.sol index 5242a2a19..761cc76bd 100644 --- a/test/libsolidity/semanticTests/statements/do_while_loop_continue.sol +++ b/test/libsolidity/semanticTests/statements/do_while_loop_continue.sol @@ -12,6 +12,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 42 diff --git a/test/libsolidity/semanticTests/storage/accessors_mapping_for_array.sol b/test/libsolidity/semanticTests/storage/accessors_mapping_for_array.sol index 2a478f35f..f309bcf16 100644 --- a/test/libsolidity/semanticTests/storage/accessors_mapping_for_array.sol +++ b/test/libsolidity/semanticTests/storage/accessors_mapping_for_array.sol @@ -8,8 +8,6 @@ contract test { dynamicData[2][2] = 8; } } -// ==== -// compileViaYul: also // ---- // data(uint256,uint256): 2, 2 -> 8 // data(uint256,uint256): 2, 8 -> FAILURE # NB: the original code contained a bug here # diff --git a/test/libsolidity/semanticTests/storage/array_accessor.sol b/test/libsolidity/semanticTests/storage/array_accessor.sol index f9efae437..599931a37 100644 --- a/test/libsolidity/semanticTests/storage/array_accessor.sol +++ b/test/libsolidity/semanticTests/storage/array_accessor.sol @@ -22,8 +22,6 @@ contract test { multiple_map[2][1][2].finalArray[3] = 5; } } -// ==== -// compileViaYul: also // ---- // data(uint256): 0 -> 8 // data(uint256): 8 -> FAILURE diff --git a/test/libsolidity/semanticTests/storage/chop_sign_bits.sol b/test/libsolidity/semanticTests/storage/chop_sign_bits.sol index 4993ecb35..51cba0261 100644 --- a/test/libsolidity/semanticTests/storage/chop_sign_bits.sol +++ b/test/libsolidity/semanticTests/storage/chop_sign_bits.sol @@ -19,8 +19,6 @@ contract Test { return z; } } -// ==== -// compileViaYul: also // ---- // x(uint256): 0 -> -1 // x(uint256): 1 -> -2 diff --git a/test/libsolidity/semanticTests/storage/complex_accessors.sol b/test/libsolidity/semanticTests/storage/complex_accessors.sol index d1087f800..59ad86a1a 100644 --- a/test/libsolidity/semanticTests/storage/complex_accessors.sol +++ b/test/libsolidity/semanticTests/storage/complex_accessors.sol @@ -10,8 +10,6 @@ contract test { to_multiple_map[42][23] = 31; } } -// ==== -// compileViaYul: also // ---- // to_string_map(uint256): 42 -> "24" // to_bool_map(uint256): 42 -> false diff --git a/test/libsolidity/semanticTests/storage/empty_nonempty_empty.sol b/test/libsolidity/semanticTests/storage/empty_nonempty_empty.sol index eeeea2943..a010aeb13 100644 --- a/test/libsolidity/semanticTests/storage/empty_nonempty_empty.sol +++ b/test/libsolidity/semanticTests/storage/empty_nonempty_empty.sol @@ -2,8 +2,6 @@ contract Test { bytes x; function set(bytes memory _a) public { x = _a; } } -// ==== -// compileViaYul: also // ---- // set(bytes): 0x20, 3, "abc" // storageEmpty -> 0 diff --git a/test/libsolidity/semanticTests/storage/mapping_state.sol b/test/libsolidity/semanticTests/storage/mapping_state.sol index 28178bca2..9059e72d0 100644 --- a/test/libsolidity/semanticTests/storage/mapping_state.sol +++ b/test/libsolidity/semanticTests/storage/mapping_state.sol @@ -15,8 +15,6 @@ contract Ballot { return true; } } -// ==== -// compileViaYul: also // ---- // getVoteCount(address): 0 -> 0 // getVoteCount(address): 1 -> 0 diff --git a/test/libsolidity/semanticTests/storage/mapping_string_key.sol b/test/libsolidity/semanticTests/storage/mapping_string_key.sol index 84ac9b09a..be7516926 100644 --- a/test/libsolidity/semanticTests/storage/mapping_string_key.sol +++ b/test/libsolidity/semanticTests/storage/mapping_string_key.sol @@ -13,8 +13,6 @@ contract C { return m_nameToRecord["fixed"]; } } -// ==== -// compileViaYul: also // ---- // set(string,uint256): 0x40, 8, 3, "abc" -> // get(string): 0x20, 3, "abc" -> 8 diff --git a/test/libsolidity/semanticTests/storage/packed_functions.sol b/test/libsolidity/semanticTests/storage/packed_functions.sol index 32597923b..4a49a614f 100644 --- a/test/libsolidity/semanticTests/storage/packed_functions.sol +++ b/test/libsolidity/semanticTests/storage/packed_functions.sol @@ -39,8 +39,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // set() -> // t1() -> 7 diff --git a/test/libsolidity/semanticTests/storage/packed_storage_overflow.sol b/test/libsolidity/semanticTests/storage/packed_storage_overflow.sol index 84dfae3c5..c10931f99 100644 --- a/test/libsolidity/semanticTests/storage/packed_storage_overflow.sol +++ b/test/libsolidity/semanticTests/storage/packed_storage_overflow.sol @@ -12,7 +12,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 0x1234, 0x0, 0x0, 0xfffe diff --git a/test/libsolidity/semanticTests/storage/packed_storage_signed.sol b/test/libsolidity/semanticTests/storage/packed_storage_signed.sol index b1080a7b0..b457d0731 100644 --- a/test/libsolidity/semanticTests/storage/packed_storage_signed.sol +++ b/test/libsolidity/semanticTests/storage/packed_storage_signed.sol @@ -22,6 +22,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> -2, 4, -112, 0 diff --git a/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol b/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol index caa385887..a2f7ba1d8 100644 --- a/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol +++ b/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol @@ -43,9 +43,8 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> true -// gas irOptimized: 134587 +// gas irOptimized: 132506 // gas legacy: 136036 // gas legacyOptimized: 133480 diff --git a/test/libsolidity/semanticTests/storage/packed_storage_structs_enum.sol b/test/libsolidity/semanticTests/storage/packed_storage_structs_enum.sol index a24973fd1..d9e897762 100644 --- a/test/libsolidity/semanticTests/storage/packed_storage_structs_enum.sol +++ b/test/libsolidity/semanticTests/storage/packed_storage_structs_enum.sol @@ -31,6 +31,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 1 diff --git a/test/libsolidity/semanticTests/storage/packed_storage_structs_uint.sol b/test/libsolidity/semanticTests/storage/packed_storage_structs_uint.sol index 509cad55e..d01f07268 100644 --- a/test/libsolidity/semanticTests/storage/packed_storage_structs_uint.sol +++ b/test/libsolidity/semanticTests/storage/packed_storage_structs_uint.sol @@ -28,6 +28,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 1 diff --git a/test/libsolidity/semanticTests/storage/simple_accessor.sol b/test/libsolidity/semanticTests/storage/simple_accessor.sol index 1171753b6..72398d9ab 100644 --- a/test/libsolidity/semanticTests/storage/simple_accessor.sol +++ b/test/libsolidity/semanticTests/storage/simple_accessor.sol @@ -6,6 +6,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // data() -> 8 diff --git a/test/libsolidity/semanticTests/storage/state_smoke_test.sol b/test/libsolidity/semanticTests/storage/state_smoke_test.sol index 6d1bae100..0bcdd1ad3 100644 --- a/test/libsolidity/semanticTests/storage/state_smoke_test.sol +++ b/test/libsolidity/semanticTests/storage/state_smoke_test.sol @@ -12,7 +12,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // get(uint8): 0x00 -> 0 // get(uint8): 0x01 -> 0 diff --git a/test/libsolidity/semanticTests/storage/struct_accessor.sol b/test/libsolidity/semanticTests/storage/struct_accessor.sol index ea030de1a..8d8fc178c 100644 --- a/test/libsolidity/semanticTests/storage/struct_accessor.sol +++ b/test/libsolidity/semanticTests/storage/struct_accessor.sol @@ -8,7 +8,5 @@ contract test { data[7].d = true; } } -// ==== -// compileViaYul: also // ---- // data(uint256): 7 -> 1, 2, true diff --git a/test/libsolidity/semanticTests/strings/concat/string_concat_2_args.sol b/test/libsolidity/semanticTests/strings/concat/string_concat_2_args.sol index 7b7bc828c..304ccecb4 100644 --- a/test/libsolidity/semanticTests/strings/concat/string_concat_2_args.sol +++ b/test/libsolidity/semanticTests/strings/concat/string_concat_2_args.sol @@ -3,8 +3,6 @@ contract C { return string.concat(a, b); } } -// ==== -// compileViaYul: also // ---- // f(string,string): 0x40, 0x80, 32, "abcdabcdabcdabcdabcdabcdabcdabcd", 5, "bcdef" -> 0x20, 0x25, 0x6162636461626364616263646162636461626364616263646162636461626364, 44502269928904312298000709931354278973409164155382318144318241583783949107200 // f(string,string): 0x40, 0xa0, 64, "abcdabcdabcdabcdabcdabcdabcdabcd", "abcdabcdabcdabcdabcdabcdabcdabcd", 5, "bcdef" -> 0x20, 0x45, 0x6162636461626364616263646162636461626364616263646162636461626364, 0x6162636461626364616263646162636461626364616263646162636461626364, 44502269928904312298000709931354278973409164155382318144318241583783949107200 diff --git a/test/libsolidity/semanticTests/strings/concat/string_concat_different_types.sol b/test/libsolidity/semanticTests/strings/concat/string_concat_different_types.sol index ab59c1bf6..0891e30c9 100644 --- a/test/libsolidity/semanticTests/strings/concat/string_concat_different_types.sol +++ b/test/libsolidity/semanticTests/strings/concat/string_concat_different_types.sol @@ -25,8 +25,6 @@ contract C{ return string.concat(string(a), "bcdef"); } } -// ==== -// compileViaYul: also // ---- // f(string): 0x20, 32, "abcdabcdabcdabcdabcdabcdabcdabcd" -> 0x20, 0x25, 0x6162636461626364616263646162636461626364616263646162636461626364, 44502269928904312298000709931354278973409164155382318144318241583783949107200 // g(string): 0x20, 32, "abcdabcdabcdabcdabcdabcdabcdabcd" -> 0x20, 0x42, 0x6162636461626364616263646162636461626364616263646162636461626364, 0x6162636465666768616263646566676861626364656667686162636465666768, 44047497324925121336511606693520958599579173549109180625971642598225011015680 diff --git a/test/libsolidity/semanticTests/strings/concat/string_concat_empty_argument_list.sol b/test/libsolidity/semanticTests/strings/concat/string_concat_empty_argument_list.sol index 70be494ba..b5db79e8f 100644 --- a/test/libsolidity/semanticTests/strings/concat/string_concat_empty_argument_list.sol +++ b/test/libsolidity/semanticTests/strings/concat/string_concat_empty_argument_list.sol @@ -5,6 +5,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x20, 0 diff --git a/test/libsolidity/semanticTests/strings/concat/string_concat_empty_strings.sol b/test/libsolidity/semanticTests/strings/concat/string_concat_empty_strings.sol index ca520884e..f452c3b35 100644 --- a/test/libsolidity/semanticTests/strings/concat/string_concat_empty_strings.sol +++ b/test/libsolidity/semanticTests/strings/concat/string_concat_empty_strings.sol @@ -20,7 +20,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x20, 0 // g() -> 0x20, 6, "abcabc" diff --git a/test/libsolidity/semanticTests/strings/concat/string_concat_nested.sol b/test/libsolidity/semanticTests/strings/concat/string_concat_nested.sol index 82931cd86..ce594b6a5 100644 --- a/test/libsolidity/semanticTests/strings/concat/string_concat_nested.sol +++ b/test/libsolidity/semanticTests/strings/concat/string_concat_nested.sol @@ -3,7 +3,5 @@ contract C { return string.concat(string.concat(a, b), c); } } -// ==== -// compileViaYul: also // ---- // f(string,string,string): 0x60, 0x60, 0x60, 2, "ab" -> 0x20, 6, "ababab" diff --git a/test/libsolidity/semanticTests/strings/constant_string_literal.sol b/test/libsolidity/semanticTests/strings/constant_string_literal.sol index 9c112c1fa..817a9081f 100644 --- a/test/libsolidity/semanticTests/strings/constant_string_literal.sol +++ b/test/libsolidity/semanticTests/strings/constant_string_literal.sol @@ -14,8 +14,6 @@ contract Test { return 2; } } -// ==== -// compileViaYul: also // ---- // b() -> 0x6162636465666768696a6b6c6d6e6f7071000000000000000000000000000000 // x() -> 0x20, 0x35, 0x616265666768696a6b6c6d6e6f70716162636465666768696a6b6c6d6e6f7071, 44048183304486788312148433451363384677562177293131179093971701692629931524096 diff --git a/test/libsolidity/semanticTests/strings/empty_storage_string.sol b/test/libsolidity/semanticTests/strings/empty_storage_string.sol new file mode 100644 index 000000000..70d85f24b --- /dev/null +++ b/test/libsolidity/semanticTests/strings/empty_storage_string.sol @@ -0,0 +1,100 @@ +contract C { + + string uninitializedString; + string emptyString = ""; + string nonEmptyString = "This is a non empty string"; + string nonEmptyString2 = "Another string"; + bytes uninitializedBytes; + bytes emptyBytes = ""; + error EmptyError(string); + event EmptyEvent(string); + + function f() public returns (string memory) { + return uninitializedString; + } + + function g() public returns (string memory, string memory) { + return (uninitializedString, emptyString); + } + + function h() public returns (string memory, string memory) { + return (uninitializedString, nonEmptyString); + } + + function i() public returns (string memory, string memory) { + return (nonEmptyString, emptyString); + } + + function j(string calldata _s) public returns (string memory) { + return _s; + } + + function k() public returns (string memory) { + nonEmptyString2 = ""; + return nonEmptyString2; + } + + function l(string calldata _s) public returns (bytes memory) { + return abi.encode(_s); + } + + function m() public returns (string memory) { + bytes memory b = abi.encode(emptyString); + return string(b); + } + + function n() public { + revert EmptyError(uninitializedString); + } + + function o() public { + emit EmptyEvent(emptyString); + } + + function p() public { + emit EmptyEvent(""); + } + + function q() public returns (bytes memory) { + return uninitializedBytes; + } + + function r() public returns (bytes memory) { + emptyBytes = abi.encode(""); + return emptyBytes; + } + + function s() public returns (bytes memory) { + emptyBytes = abi.encode(uninitializedString); + return emptyBytes; + } + + function set(string calldata _s) public { + nonEmptyString = _s; + } + + function get() public returns (string memory) { + return nonEmptyString; + } +} +// ==== +// compileViaYul: also +// ---- +// f() -> 0x20, 0 +// g() -> 0x40, 0x60, 0, 0 +// h() -> 0x40, 0x60, 0, 0x1a, 38178759162904981154304545770567765692299154484752076569098748838215919075328 +// i() -> 0x40, 0x80, 0x1a, 38178759162904981154304545770567765692299154484752076569098748838215919075328, 0 +// j(string): 0x20, 0, "" -> 0x20, 0 +// k() -> 0x20, 0 +// l(string): 0x20, 0, "" -> 0x20, 0x40, 0x20, 0 +// m() -> 0x20, 0x40, 0x20, 0 +// n() -> FAILURE, hex"d3f13430", hex"0000000000000000000000000000000000000000000000000000000000000020", hex"0000000000000000000000000000000000000000000000000000000000000000" +// o() -> +// ~ emit EmptyEvent(string): 0x20, 0x00 +// p() -> +// ~ emit EmptyEvent(string): 0x20, 0x00 +// q() -> 0x20, 0 +// r() -> 0x20, 0x40, 0x20, 0 +// s() -> 0x20, 0x40, 0x20, 0 +// set(string): 0x20, 0, "" -> +// get() -> 0x20, 0 diff --git a/test/libsolidity/semanticTests/strings/empty_string.sol b/test/libsolidity/semanticTests/strings/empty_string.sol index abf72be38..d1a6fc584 100644 --- a/test/libsolidity/semanticTests/strings/empty_string.sol +++ b/test/libsolidity/semanticTests/strings/empty_string.sol @@ -5,6 +5,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x20, 0 diff --git a/test/libsolidity/semanticTests/strings/empty_string_input.sol b/test/libsolidity/semanticTests/strings/empty_string_input.sol index c1f0bca22..bd9fbc85f 100644 --- a/test/libsolidity/semanticTests/strings/empty_string_input.sol +++ b/test/libsolidity/semanticTests/strings/empty_string_input.sol @@ -16,8 +16,6 @@ contract C { return (msg1, "", v); } } -// ==== -// compileViaYul: also // ---- // f() -> 0x20, 0 // g(string): 0x20, 0, "" -> 0x20, 0 diff --git a/test/libsolidity/semanticTests/strings/return_string.sol b/test/libsolidity/semanticTests/strings/return_string.sol index f221a5e15..4393d7dcc 100644 --- a/test/libsolidity/semanticTests/strings/return_string.sol +++ b/test/libsolidity/semanticTests/strings/return_string.sol @@ -12,7 +12,6 @@ contract Main { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // set(string): 0x20, 5, "Julia" -> // get1() -> 0x20, 5, "Julia" diff --git a/test/libsolidity/semanticTests/strings/string_escapes.sol b/test/libsolidity/semanticTests/strings/string_escapes.sol index 89231e851..3ccae698f 100644 --- a/test/libsolidity/semanticTests/strings/string_escapes.sol +++ b/test/libsolidity/semanticTests/strings/string_escapes.sol @@ -6,6 +6,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x090a0d27225c0000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/strings/unicode_escapes.sol b/test/libsolidity/semanticTests/strings/unicode_escapes.sol index 2c0e19121..95c322f5b 100644 --- a/test/libsolidity/semanticTests/strings/unicode_escapes.sol +++ b/test/libsolidity/semanticTests/strings/unicode_escapes.sol @@ -17,7 +17,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // oneByteUTF8() -> 0x20, 7, "aaa$aaa" // twoBytesUTF8() -> 0x20, 8, "aaa\xc2\xa2aaa" diff --git a/test/libsolidity/semanticTests/strings/unicode_string.sol b/test/libsolidity/semanticTests/strings/unicode_string.sol index f9d1cb1e3..516febe6e 100644 --- a/test/libsolidity/semanticTests/strings/unicode_string.sol +++ b/test/libsolidity/semanticTests/strings/unicode_string.sol @@ -9,7 +9,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x20, 0x14, "\xf0\x9f\x98\x83, \xf0\x9f\x98\xad, and \xf0\x9f\x98\x88" // g() -> 0x20, 0x14, "\xf0\x9f\x98\x83, \xf0\x9f\x98\xad, and \xf0\x9f\x98\x88" diff --git a/test/libsolidity/semanticTests/structs/array_of_recursive_struct.sol b/test/libsolidity/semanticTests/structs/array_of_recursive_struct.sol index 1bfc7ce1f..f62f4c084 100644 --- a/test/libsolidity/semanticTests/structs/array_of_recursive_struct.sol +++ b/test/libsolidity/semanticTests/structs/array_of_recursive_struct.sol @@ -10,6 +10,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // func() -> diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_nested_structs.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_nested_structs.sol index ac3d5a4e7..425144403 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_nested_structs.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_nested_structs.sol @@ -41,8 +41,6 @@ contract C { return (p, m.p1, m.a[0][0], m.a[1][1], m.p2); } } -// ==== -// compileViaYul: also // ---- // f((uint128,(uint128,uint256[][2],uint32)),uint32): 0x40, 44, 11, 0x40, 22, 0x60, 33, 0x40, 0x40, 2, 1, 2 -> 44, 22, 1, 2, 33 // g(((uint128,uint256[][2],uint32)[2])): 0x20, 0x20, 0x40, 0x40, 22, 0x60, 33, 0x40, 0x40, 2, 1, 2 -> 22, 1, 2, 33 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct.sol index 2fe78260a..ca635aeb4 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct.sol @@ -15,6 +15,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f((uint256,uint256)): 42, 23 -> 42, 23 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_and_ints.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_and_ints.sol index 7d4d124bb..144df2d61 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_and_ints.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_and_ints.sol @@ -16,7 +16,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(uint256,(uint256,uint256),uint256): 1, 2, 3, 4 -> 1, 2, 3, 4 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_array_member.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_array_member.sol index 0439aeff5..34d2bf476 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_array_member.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_array_member.sol @@ -19,7 +19,5 @@ contract C { c = s.c; } } -// ==== -// compileViaYul: also // ---- // f((uint256,uint256[2],uint256)): 42, 1, 2, 23 -> 42, 1, 2, 23 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_array_member_dynamic.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_array_member_dynamic.sol index 22e4547cd..e6972e03f 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_array_member_dynamic.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_array_member_dynamic.sol @@ -20,6 +20,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f((uint32,uint256[],uint64)): 0x20, 42, 0x60, 23, 2, 1, 2 -> 42, 1, 2, 23 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_as_argument_of_lib_function.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_as_argument_of_lib_function.sol index 4849b4748..35d51d7b4 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_as_argument_of_lib_function.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_as_argument_of_lib_function.sol @@ -22,8 +22,6 @@ contract C { return L.f(c, p); } } -// ==== -// compileViaYul: also // ---- // library: L // f((uint128,(uint128,uint256[][2],uint32)),uint32): 0x40, 44, 11, 0x40, 22, 0x60, 33, 0x40, 0x40, 2, 1, 2 -> 44, 22, 1, 2, 33 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_as_memory_argument.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_as_memory_argument.sol index 8f092ace0..c43e6fb18 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_as_memory_argument.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_as_memory_argument.sol @@ -17,7 +17,5 @@ contract C { return g(p1, c); } } -// ==== -// compileViaYul: also // ---- // f(uint32,(uint128,uint256[][2],uint32)): 55, 0x40, 77, 0x60, 88, 0x40, 0x40, 2, 1, 2 -> 55, 78, 1, 2, 88 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_struct_member.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_struct_member.sol index 6762368f1..cc5288058 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_struct_member.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_struct_member.sol @@ -22,7 +22,5 @@ contract C { c = s1.c; } } -// ==== -// compileViaYul: also // ---- // f((uint256,(uint64,uint64),uint256)): 42, 1, 2, 23 -> 42, 1, 2, 23 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_struct_member_dynamic.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_struct_member_dynamic.sol index 28a8e57dd..7c84a096f 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_struct_member_dynamic.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_struct_member_dynamic.sol @@ -22,7 +22,5 @@ contract C { c = s1.c; } } -// ==== -// compileViaYul: also // ---- // f((uint256,(uint64,bytes),uint256)): 0x20, 42, 0x60, 23, 1, 0x40, 2, "ab" -> 42, 1, "a", 23 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_to_memory.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_to_memory.sol index e4f911161..76e6f7c1d 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_to_memory.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_to_memory.sol @@ -15,6 +15,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f((uint256,uint256,bytes2)): 42, 23, "ab" -> 42, 23, "b" diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_to_memory_tuple_assignment.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_to_memory_tuple_assignment.sol index 868fea982..516179804 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_to_memory_tuple_assignment.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_to_memory_tuple_assignment.sol @@ -16,7 +16,5 @@ contract C { return (p2, m.p1, m.a[0][0], m.a[1][1], m.p2); } } -// ==== -// compileViaYul: also // ---- // f(uint32,(uint128,uint256[][2],uint32)): 55, 0x40, 77, 0x60, 88, 0x40, 0x40, 2, 1, 2 -> 55, 78, 1, 2, 88 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_to_storage.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_to_storage.sol index 2dc65bb11..74d30f505 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_to_storage.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_to_storage.sol @@ -18,6 +18,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint32,(uint256,uint64,bytes2),uint256): 1, 42, 23, "ab", 1 -> 42, 23, "b" diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_array_to_memory.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_array_to_memory.sol index 25530a181..7ae085dbb 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_array_to_memory.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_array_to_memory.sol @@ -17,7 +17,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f((uint256,uint256[2],uint256)): 42, 1, 2, 23 -> 42, 1, 2, 23 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_bytes_to_memory.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_bytes_to_memory.sol index f62742fa7..0adc4c5a7 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_bytes_to_memory.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_bytes_to_memory.sol @@ -17,7 +17,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f((uint256,bytes,uint256)): 0x20, 42, 0x60, 23, 2, "ab" -> 42, "a", "b", 23 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_memory.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_memory.sol index 4f9c3162a..b3c7f4695 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_memory.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_memory.sol @@ -17,7 +17,5 @@ contract C { return (p1, s.p1, s.a[0][0], s.a[1][1], s.p2); } } -// ==== -// compileViaYul: also // ---- // f(uint32,(uint128,uint256[][2],uint32)): 55, 0x40, 77, 0x60, 88, 0x40, 0x40, 2, 1, 2 -> 55, 78, 1, 2, 88 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol index c5f2e7343..1f6987199 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol @@ -14,10 +14,8 @@ contract C { return (p1, s.p1, s.a[0][0], s.a[1][1], s.p2); } } -// ==== -// compileViaYul: also // ---- // f(uint32,(uint128,uint256[][2],uint32)): 55, 0x40, 77, 0x60, 88, 0x40, 0x40, 2, 1, 2 -> 55, 77, 1, 2, 88 -// gas irOptimized: 203299 -// gas legacy: 209194 -// gas legacyOptimized: 203583 +// gas irOptimized: 202838 +// gas legacy: 207487 +// gas legacyOptimized: 203611 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_structs.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_structs.sol index 6cac49d8c..6092b161d 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_structs.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_structs.sol @@ -25,6 +25,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f((uint256,uint256),(uint256),(uint256,uint256)): 1, 2, 3, 4, 5 -> 1, 2, 3, 4, 5 diff --git a/test/libsolidity/semanticTests/structs/calldata/dynamic_nested.sol b/test/libsolidity/semanticTests/structs/calldata/dynamic_nested.sol index 11ef1917e..2b7544139 100644 --- a/test/libsolidity/semanticTests/structs/calldata/dynamic_nested.sol +++ b/test/libsolidity/semanticTests/structs/calldata/dynamic_nested.sol @@ -9,6 +9,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f((uint256,(uint256)[])): 32, 17, 64, 2, 23, 42 -> 2, 17, 23, 42 diff --git a/test/libsolidity/semanticTests/structs/calldata/dynamically_encoded.sol b/test/libsolidity/semanticTests/structs/calldata/dynamically_encoded.sol index 1b71f2f94..b4beff941 100644 --- a/test/libsolidity/semanticTests/structs/calldata/dynamically_encoded.sol +++ b/test/libsolidity/semanticTests/structs/calldata/dynamically_encoded.sol @@ -8,6 +8,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f((uint256[])): 32, 32, 2, 42, 23 -> 2, 42, 23 diff --git a/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol b/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol index 509fd29ed..3d062fc95 100644 --- a/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol +++ b/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol @@ -21,10 +21,8 @@ contract CopyTest { return (memoryTree.children.length, memoryTree.children[0].children.length, memoryTree.children[1].children.length); } } -// ==== -// compileViaYul: also // ---- // run() -> 2, 23, 42 -// gas irOptimized: 194003 +// gas irOptimized: 193756 // gas legacy: 186016 // gas legacyOptimized: 184668 diff --git a/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory_complex.sol b/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory_complex.sol index 3f3a9a3d2..d14bff969 100644 --- a/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory_complex.sol +++ b/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory_complex.sol @@ -46,7 +46,5 @@ contract CopyTest { return result; } } -// ==== -// compileViaYul: also // ---- // run() -> 0x20, 10, 0x42, 0x4200, 0x420000, 0x420001, 0x420002, 0x4201, 0x420100, 0x420101, 0x420102, 0x420103 diff --git a/test/libsolidity/semanticTests/structs/copy_from_calldata.sol b/test/libsolidity/semanticTests/structs/copy_from_calldata.sol index bfe6fc949..e78d5bdd8 100644 --- a/test/libsolidity/semanticTests/structs/copy_from_calldata.sol +++ b/test/libsolidity/semanticTests/structs/copy_from_calldata.sol @@ -33,6 +33,5 @@ contract Test { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // test() -> true diff --git a/test/libsolidity/semanticTests/structs/copy_from_storage.sol b/test/libsolidity/semanticTests/structs/copy_from_storage.sol index d4a970bdc..b3d730453 100644 --- a/test/libsolidity/semanticTests/structs/copy_from_storage.sol +++ b/test/libsolidity/semanticTests/structs/copy_from_storage.sol @@ -18,7 +18,5 @@ contract C { return sMemory; } } -// ==== -// compileViaYul: also // ---- // f() -> 0x20, 1, 13 diff --git a/test/libsolidity/semanticTests/structs/copy_struct_array_from_storage.sol b/test/libsolidity/semanticTests/structs/copy_struct_array_from_storage.sol index 876a7f6c8..33621c9eb 100644 --- a/test/libsolidity/semanticTests/structs/copy_struct_array_from_storage.sol +++ b/test/libsolidity/semanticTests/structs/copy_struct_array_from_storage.sol @@ -85,10 +85,9 @@ contract Test { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // test1() -> true -// gas irOptimized: 150533 +// gas irOptimized: 150163 // gas legacy: 150266 // gas legacyOptimized: 149875 // test2() -> true diff --git a/test/libsolidity/semanticTests/structs/delete_struct.sol b/test/libsolidity/semanticTests/structs/delete_struct.sol index 265fa2fbb..ad32f6dac 100644 --- a/test/libsolidity/semanticTests/structs/delete_struct.sol +++ b/test/libsolidity/semanticTests/structs/delete_struct.sol @@ -26,8 +26,6 @@ contract test { nestedValue = str.nstr.nestedValue; } } -// ==== -// compileViaYul: also // ---- // getToDelete() -> 0 // getTopValue() -> 0 diff --git a/test/libsolidity/semanticTests/structs/event.sol b/test/libsolidity/semanticTests/structs/event.sol index 36df8787f..5a96c7cfa 100644 --- a/test/libsolidity/semanticTests/structs/event.sol +++ b/test/libsolidity/semanticTests/structs/event.sol @@ -10,8 +10,6 @@ contract C { L.o(); } } -// ==== -// compileViaYul: also // ---- // library: L // f() -> diff --git a/test/libsolidity/semanticTests/structs/function_type_copy.sol b/test/libsolidity/semanticTests/structs/function_type_copy.sol index 79fe5ef4c..6230d47f9 100644 --- a/test/libsolidity/semanticTests/structs/function_type_copy.sol +++ b/test/libsolidity/semanticTests/structs/function_type_copy.sol @@ -39,6 +39,5 @@ contract Test { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // test() -> true diff --git a/test/libsolidity/semanticTests/structs/global.sol b/test/libsolidity/semanticTests/structs/global.sol index b0485aea0..d51194ca0 100644 --- a/test/libsolidity/semanticTests/structs/global.sol +++ b/test/libsolidity/semanticTests/structs/global.sol @@ -8,6 +8,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f((uint256,uint256)): 42, 23 -> 42, 23 diff --git a/test/libsolidity/semanticTests/structs/lone_struct_array_type.sol b/test/libsolidity/semanticTests/structs/lone_struct_array_type.sol index 15854aca5..fe6de19f4 100644 --- a/test/libsolidity/semanticTests/structs/lone_struct_array_type.sol +++ b/test/libsolidity/semanticTests/structs/lone_struct_array_type.sol @@ -12,6 +12,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 3 diff --git a/test/libsolidity/semanticTests/structs/memory_struct_named_constructor.sol b/test/libsolidity/semanticTests/structs/memory_struct_named_constructor.sol index 0d2d0c1de..445961e2d 100644 --- a/test/libsolidity/semanticTests/structs/memory_struct_named_constructor.sol +++ b/test/libsolidity/semanticTests/structs/memory_struct_named_constructor.sol @@ -14,6 +14,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // s() -> 8, true diff --git a/test/libsolidity/semanticTests/structs/memory_structs_as_function_args.sol b/test/libsolidity/semanticTests/structs/memory_structs_as_function_args.sol index 9459c3477..a76518684 100644 --- a/test/libsolidity/semanticTests/structs/memory_structs_as_function_args.sol +++ b/test/libsolidity/semanticTests/structs/memory_structs_as_function_args.sol @@ -30,6 +30,5 @@ contract Test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 1, 2, 3 diff --git a/test/libsolidity/semanticTests/structs/memory_structs_nested.sol b/test/libsolidity/semanticTests/structs/memory_structs_nested.sol index 786147c40..3fee9b210 100644 --- a/test/libsolidity/semanticTests/structs/memory_structs_nested.sol +++ b/test/libsolidity/semanticTests/structs/memory_structs_nested.sol @@ -40,6 +40,5 @@ contract Test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 1, 2, 3, 4 diff --git a/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol b/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol index 89f575577..9d157d70e 100644 --- a/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol +++ b/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol @@ -66,10 +66,9 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // load() -> 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 -// gas irOptimized: 111425 +// gas irOptimized: 110327 // gas legacy: 112999 // gas legacyOptimized: 110881 // store() -> 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 diff --git a/test/libsolidity/semanticTests/structs/memory_structs_read_write.sol b/test/libsolidity/semanticTests/structs/memory_structs_read_write.sol index 5e47a42fb..5cafe5323 100644 --- a/test/libsolidity/semanticTests/structs/memory_structs_read_write.sol +++ b/test/libsolidity/semanticTests/structs/memory_structs_read_write.sol @@ -51,7 +51,6 @@ contract Test { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // testInit() -> 0, 0, 0, 0, true diff --git a/test/libsolidity/semanticTests/structs/msg_data_to_struct_member_copy.sol b/test/libsolidity/semanticTests/structs/msg_data_to_struct_member_copy.sol index f28bbf477..d88797d57 100644 --- a/test/libsolidity/semanticTests/structs/msg_data_to_struct_member_copy.sol +++ b/test/libsolidity/semanticTests/structs/msg_data_to_struct_member_copy.sol @@ -35,8 +35,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f() -> 0x20, 0x20, 4, 0x26121ff000000000000000000000000000000000000000000000000000000000 // g() -> 0x20, 0x20, 4, 0xe2179b8e00000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/structs/multislot_struct_allocation.sol b/test/libsolidity/semanticTests/structs/multislot_struct_allocation.sol index 9766880bf..3336b30b1 100644 --- a/test/libsolidity/semanticTests/structs/multislot_struct_allocation.sol +++ b/test/libsolidity/semanticTests/structs/multislot_struct_allocation.sol @@ -18,7 +18,5 @@ contract C { -// ==== -// compileViaYul: also // ---- // f() -> 2 diff --git a/test/libsolidity/semanticTests/structs/nested_struct_allocation.sol b/test/libsolidity/semanticTests/structs/nested_struct_allocation.sol index d5f9e8dc7..64328b2de 100644 --- a/test/libsolidity/semanticTests/structs/nested_struct_allocation.sol +++ b/test/libsolidity/semanticTests/structs/nested_struct_allocation.sol @@ -14,6 +14,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1 diff --git a/test/libsolidity/semanticTests/structs/packed_storage_structs_delete.sol b/test/libsolidity/semanticTests/structs/packed_storage_structs_delete.sol index 8d4931554..741b55f3f 100644 --- a/test/libsolidity/semanticTests/structs/packed_storage_structs_delete.sol +++ b/test/libsolidity/semanticTests/structs/packed_storage_structs_delete.sol @@ -20,8 +20,6 @@ contract C { return 1; } } -// ==== -// compileViaYul: also // ---- // test() -> 1 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/structs/recursive_struct_2.sol b/test/libsolidity/semanticTests/structs/recursive_struct_2.sol index 5214b1a48..65cfcf209 100644 --- a/test/libsolidity/semanticTests/structs/recursive_struct_2.sol +++ b/test/libsolidity/semanticTests/structs/recursive_struct_2.sol @@ -20,7 +20,5 @@ contract C { assembly { a := sload(s.slot) b := sload(slot1) c := sload(slot2) d := sload(slot3) } } } -// ==== -// compileViaYul: also // ---- // f() -> 0, 0, 0, 0 diff --git a/test/libsolidity/semanticTests/structs/recursive_structs.sol b/test/libsolidity/semanticTests/structs/recursive_structs.sol index 4336b54db..58f178e5e 100644 --- a/test/libsolidity/semanticTests/structs/recursive_structs.sol +++ b/test/libsolidity/semanticTests/structs/recursive_structs.sol @@ -17,6 +17,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1 diff --git a/test/libsolidity/semanticTests/structs/simple_struct_allocation.sol b/test/libsolidity/semanticTests/structs/simple_struct_allocation.sol index f357474c6..c05d87b37 100644 --- a/test/libsolidity/semanticTests/structs/simple_struct_allocation.sol +++ b/test/libsolidity/semanticTests/structs/simple_struct_allocation.sol @@ -10,6 +10,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1 diff --git a/test/libsolidity/semanticTests/structs/struct_assign_reference_to_struct.sol b/test/libsolidity/semanticTests/structs/struct_assign_reference_to_struct.sol index 695b29a36..357863abb 100644 --- a/test/libsolidity/semanticTests/structs/struct_assign_reference_to_struct.sol +++ b/test/libsolidity/semanticTests/structs/struct_assign_reference_to_struct.sol @@ -34,6 +34,5 @@ contract test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // assign() -> 2, 2, 3, 3 diff --git a/test/libsolidity/semanticTests/structs/struct_constructor_nested.sol b/test/libsolidity/semanticTests/structs/struct_constructor_nested.sol index 7868a620e..7ce22e45a 100644 --- a/test/libsolidity/semanticTests/structs/struct_constructor_nested.sol +++ b/test/libsolidity/semanticTests/structs/struct_constructor_nested.sol @@ -26,7 +26,5 @@ contract C { x2 = s.s3.x2; } } -// ==== -// compileViaYul: also // ---- // get() -> 0x01, 0x00, 0x09, 0x00, 0x04, 0x05 diff --git a/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol b/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol index f77156d64..998007572 100644 --- a/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol +++ b/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol @@ -20,14 +20,12 @@ contract c { return data1.data[i]; } } -// ==== -// compileViaYul: also // ---- // storageEmpty -> 1 // set(uint256,bytes,uint256): 12, 0x60, 13, 33, "12345678901234567890123456789012", "3" -> true -// gas irOptimized: 133728 -// gas legacy: 134433 -// gas legacyOptimized: 133876 +// gas irOptimized: 133599 +// gas legacy: 134654 +// gas legacyOptimized: 133882 // test(uint256): 32 -> "3" // storageEmpty -> 0 // copy() -> true diff --git a/test/libsolidity/semanticTests/structs/struct_copy.sol b/test/libsolidity/semanticTests/structs/struct_copy.sol index f7083c7a0..27e726f15 100644 --- a/test/libsolidity/semanticTests/structs/struct_copy.sol +++ b/test/libsolidity/semanticTests/structs/struct_copy.sol @@ -34,16 +34,14 @@ contract c { } } -// ==== -// compileViaYul: also // ---- // set(uint256): 7 -> true -// gas irOptimized: 110051 +// gas irOptimized: 110032 // gas legacy: 110616 // gas legacyOptimized: 110006 // retrieve(uint256): 7 -> 1, 3, 4, 2 // copy(uint256,uint256): 7, 8 -> true -// gas irOptimized: 118581 +// gas irOptimized: 118594 // gas legacy: 119166 // gas legacyOptimized: 118622 // retrieve(uint256): 7 -> 1, 3, 4, 2 diff --git a/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol b/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol index 4305687b7..d33b8fd02 100644 --- a/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol +++ b/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol @@ -18,9 +18,8 @@ contract c { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> true -// gas irOptimized: 110177 +// gas irOptimized: 109714 // gas legacy: 110627 // gas legacyOptimized: 109706 diff --git a/test/libsolidity/semanticTests/structs/struct_delete_member.sol b/test/libsolidity/semanticTests/structs/struct_delete_member.sol index 1db9edd4e..c881d8a93 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_member.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_member.sol @@ -18,6 +18,5 @@ contract test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // deleteMember() -> 0 diff --git a/test/libsolidity/semanticTests/structs/struct_delete_storage.sol b/test/libsolidity/semanticTests/structs/struct_delete_storage.sol index d57aea3c7..776ceddc6 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_storage.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_storage.sol @@ -19,6 +19,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> diff --git a/test/libsolidity/semanticTests/structs/struct_delete_storage_nested_small.sol b/test/libsolidity/semanticTests/structs/struct_delete_storage_nested_small.sol index ded05d8d6..57bf38e52 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_storage_nested_small.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_storage_nested_small.sol @@ -33,4 +33,4 @@ contract C { // compileViaYul: true // ---- // f() -> 0, 0, 0 -// gas irOptimized: 117403 +// gas irOptimized: 117101 diff --git a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol index bdb60b877..15acf7a2f 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol @@ -40,11 +40,9 @@ contract C { assert(s.b == 2); } } -// ==== -// compileViaYul: also // ---- // f() -> -// gas irOptimized: 121619 +// gas irOptimized: 121657 // gas legacy: 122132 // gas legacyOptimized: 121500 // g() -> diff --git a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_arrays_small.sol b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_arrays_small.sol index abc10d8aa..d07d14dd6 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_arrays_small.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_arrays_small.sol @@ -27,4 +27,4 @@ contract C { // compileViaYul: true // ---- // f() -> 0 -// gas irOptimized: 112129 +// gas irOptimized: 111594 diff --git a/test/libsolidity/semanticTests/structs/struct_delete_struct_in_mapping.sol b/test/libsolidity/semanticTests/structs/struct_delete_struct_in_mapping.sol index 85d2c0556..b5c8a2cfa 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_struct_in_mapping.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_struct_in_mapping.sol @@ -14,7 +14,5 @@ contract test { } } -// ==== -// compileViaYul: also // ---- // deleteIt() -> 0 diff --git a/test/libsolidity/semanticTests/structs/struct_memory_to_storage.sol b/test/libsolidity/semanticTests/structs/struct_memory_to_storage.sol index 3d4eafa34..66657fc67 100644 --- a/test/libsolidity/semanticTests/structs/struct_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/structs/struct_memory_to_storage.sol @@ -24,6 +24,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 42, 23, 34 diff --git a/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol b/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol index 6c317598b..e2821a5a6 100644 --- a/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol +++ b/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol @@ -29,9 +29,8 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 42, 23, 34, 42, 42 -// gas irOptimized: 110843 +// gas irOptimized: 110389 // gas legacy: 112021 // gas legacyOptimized: 110548 diff --git a/test/libsolidity/semanticTests/structs/struct_named_constructor.sol b/test/libsolidity/semanticTests/structs/struct_named_constructor.sol index cb0b0525f..2433da866 100644 --- a/test/libsolidity/semanticTests/structs/struct_named_constructor.sol +++ b/test/libsolidity/semanticTests/structs/struct_named_constructor.sol @@ -12,6 +12,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // s() -> 1, true diff --git a/test/libsolidity/semanticTests/structs/struct_reference.sol b/test/libsolidity/semanticTests/structs/struct_reference.sol index c836d3f1d..79eeccbe7 100644 --- a/test/libsolidity/semanticTests/structs/struct_reference.sol +++ b/test/libsolidity/semanticTests/structs/struct_reference.sol @@ -18,8 +18,6 @@ contract test { inner.recursive[0].z = inner.recursive[1].z + 1; } } -// ==== -// compileViaYul: also // ---- // check() -> false // set() -> diff --git a/test/libsolidity/semanticTests/structs/struct_referencing.sol b/test/libsolidity/semanticTests/structs/struct_referencing.sol index af2357a23..0d7d1a754 100644 --- a/test/libsolidity/semanticTests/structs/struct_referencing.sol +++ b/test/libsolidity/semanticTests/structs/struct_referencing.sol @@ -47,7 +47,6 @@ contract C is I { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: L // f() -> 1 diff --git a/test/libsolidity/semanticTests/structs/struct_storage_push_zero_value.sol b/test/libsolidity/semanticTests/structs/struct_storage_push_zero_value.sol index 2ef6f4cf4..d42776189 100644 --- a/test/libsolidity/semanticTests/structs/struct_storage_push_zero_value.sol +++ b/test/libsolidity/semanticTests/structs/struct_storage_push_zero_value.sol @@ -22,7 +22,5 @@ contract C { assert(a == 17); } } -// ==== -// compileViaYul: also // ---- // f() -> diff --git a/test/libsolidity/semanticTests/structs/struct_storage_to_mapping.sol b/test/libsolidity/semanticTests/structs/struct_storage_to_mapping.sol index 31952dede..b77c696b4 100644 --- a/test/libsolidity/semanticTests/structs/struct_storage_to_mapping.sol +++ b/test/libsolidity/semanticTests/structs/struct_storage_to_mapping.sol @@ -11,7 +11,5 @@ contract C { return m[1].a == 12; } } -// ==== -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/structs/struct_storage_to_memory.sol b/test/libsolidity/semanticTests/structs/struct_storage_to_memory.sol index e079f61e7..8b9035d18 100644 --- a/test/libsolidity/semanticTests/structs/struct_storage_to_memory.sol +++ b/test/libsolidity/semanticTests/structs/struct_storage_to_memory.sol @@ -22,6 +22,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 42, 23, 34 diff --git a/test/libsolidity/semanticTests/structs/struct_storage_to_memory_function_ptr.sol b/test/libsolidity/semanticTests/structs/struct_storage_to_memory_function_ptr.sol index e42004571..c3aa23c3b 100644 --- a/test/libsolidity/semanticTests/structs/struct_storage_to_memory_function_ptr.sol +++ b/test/libsolidity/semanticTests/structs/struct_storage_to_memory_function_ptr.sol @@ -27,7 +27,6 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 42, 23, 34, 42, 42 diff --git a/test/libsolidity/semanticTests/structs/structs.sol b/test/libsolidity/semanticTests/structs/structs.sol index 412b71d39..ada5534ca 100644 --- a/test/libsolidity/semanticTests/structs/structs.sol +++ b/test/libsolidity/semanticTests/structs/structs.sol @@ -27,12 +27,10 @@ contract test { data.recursive[4].z = 9; } } -// ==== -// compileViaYul: also // ---- // check() -> false // set() -> -// gas irOptimized: 134411 +// gas irOptimized: 134436 // gas legacy: 135277 // gas legacyOptimized: 134064 // check() -> true diff --git a/test/libsolidity/semanticTests/structs/using_for_function_on_struct.sol b/test/libsolidity/semanticTests/structs/using_for_function_on_struct.sol index 347aeb595..f97935fb6 100644 --- a/test/libsolidity/semanticTests/structs/using_for_function_on_struct.sol +++ b/test/libsolidity/semanticTests/structs/using_for_function_on_struct.sol @@ -9,7 +9,6 @@ contract C { } // ==== // compileToEwasm: false -// compileViaYul: also // ---- // library: D // f(uint256): 7 -> 0x15 diff --git a/test/libsolidity/semanticTests/tryCatch/assert.sol b/test/libsolidity/semanticTests/tryCatch/assert.sol index be475a3f2..8b6a7b996 100644 --- a/test/libsolidity/semanticTests/tryCatch/assert.sol +++ b/test/libsolidity/semanticTests/tryCatch/assert.sol @@ -11,8 +11,6 @@ contract C { } } } -// ==== -// compileViaYul: also // ---- // f(bool): true -> 1 // f(bool): false -> 2 diff --git a/test/libsolidity/semanticTests/tryCatch/create.sol b/test/libsolidity/semanticTests/tryCatch/create.sol index 6923b6cb6..ad7f734c7 100644 --- a/test/libsolidity/semanticTests/tryCatch/create.sol +++ b/test/libsolidity/semanticTests/tryCatch/create.sol @@ -27,7 +27,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f() -> 0, 0, 96, 13, "test message." // g() -> 0xf01f7809444bd9a93a854361c6fae3f23d9e23db, 0, 96, 7, "success" diff --git a/test/libsolidity/semanticTests/tryCatch/invalid_error_encoding.sol b/test/libsolidity/semanticTests/tryCatch/invalid_error_encoding.sol index 1b89213cf..2bfc23191 100644 --- a/test/libsolidity/semanticTests/tryCatch/invalid_error_encoding.sol +++ b/test/libsolidity/semanticTests/tryCatch/invalid_error_encoding.sol @@ -149,7 +149,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f1() -> 2 // f1a() -> 2 diff --git a/test/libsolidity/semanticTests/tryCatch/lowLevel.sol b/test/libsolidity/semanticTests/tryCatch/lowLevel.sol index 06710050e..ac275522d 100644 --- a/test/libsolidity/semanticTests/tryCatch/lowLevel.sol +++ b/test/libsolidity/semanticTests/tryCatch/lowLevel.sol @@ -13,7 +13,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f(bool): true -> 1, 2, 96, 0 // f(bool): false -> 0, 0, 96, 100, 0x8c379a000000000000000000000000000000000000000000000000000000000, 0x2000000000000000000000000000000000000000000000000000000000, 0x76d657373616765000000000000000000000000000000000000000000, 0 diff --git a/test/libsolidity/semanticTests/tryCatch/malformed_error.sol b/test/libsolidity/semanticTests/tryCatch/malformed_error.sol index bcac7c1c6..95c29276e 100644 --- a/test/libsolidity/semanticTests/tryCatch/malformed_error.sol +++ b/test/libsolidity/semanticTests/tryCatch/malformed_error.sol @@ -79,7 +79,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // a() -> 0x00 // b() -> 0x00 diff --git a/test/libsolidity/semanticTests/tryCatch/malformed_panic.sol b/test/libsolidity/semanticTests/tryCatch/malformed_panic.sol index 8bd2e822a..816dab7c4 100644 --- a/test/libsolidity/semanticTests/tryCatch/malformed_panic.sol +++ b/test/libsolidity/semanticTests/tryCatch/malformed_panic.sol @@ -47,7 +47,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // a() -> 0x00 // b() -> 0x00 diff --git a/test/libsolidity/semanticTests/tryCatch/malformed_panic_2.sol b/test/libsolidity/semanticTests/tryCatch/malformed_panic_2.sol index bb7e48f32..bf47c01a8 100644 --- a/test/libsolidity/semanticTests/tryCatch/malformed_panic_2.sol +++ b/test/libsolidity/semanticTests/tryCatch/malformed_panic_2.sol @@ -45,7 +45,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // a() -> FAILURE, hex"4e487b" // b() -> FAILURE, hex"4e487b710000" diff --git a/test/libsolidity/semanticTests/tryCatch/malformed_panic_3.sol b/test/libsolidity/semanticTests/tryCatch/malformed_panic_3.sol index 52a76f181..cad5aaa46 100644 --- a/test/libsolidity/semanticTests/tryCatch/malformed_panic_3.sol +++ b/test/libsolidity/semanticTests/tryCatch/malformed_panic_3.sol @@ -51,7 +51,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // a() -> FAILURE, hex"4e487b" // b() -> FAILURE, hex"4e487b710000" diff --git a/test/libsolidity/semanticTests/tryCatch/malformed_panic_4.sol b/test/libsolidity/semanticTests/tryCatch/malformed_panic_4.sol index 2efce6853..ad096b9b8 100644 --- a/test/libsolidity/semanticTests/tryCatch/malformed_panic_4.sol +++ b/test/libsolidity/semanticTests/tryCatch/malformed_panic_4.sol @@ -55,7 +55,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // a() -> 0x00 // b() -> 0x00 diff --git a/test/libsolidity/semanticTests/tryCatch/nested.sol b/test/libsolidity/semanticTests/tryCatch/nested.sol index 03e6ad553..7c56a81b7 100644 --- a/test/libsolidity/semanticTests/tryCatch/nested.sol +++ b/test/libsolidity/semanticTests/tryCatch/nested.sol @@ -26,7 +26,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f(bool,bool): true, true -> 1, 2, 96, 7, "success" // f(bool,bool): true, false -> 12, 0, 96, 7, "failure" diff --git a/test/libsolidity/semanticTests/tryCatch/panic.sol b/test/libsolidity/semanticTests/tryCatch/panic.sol index 9211b4fa4..eb7dd8c8b 100644 --- a/test/libsolidity/semanticTests/tryCatch/panic.sol +++ b/test/libsolidity/semanticTests/tryCatch/panic.sol @@ -22,7 +22,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // onlyPanic(bool,uint256,uint256): true, 7, 6 -> 1, 0x00 // onlyPanic(bool,uint256,uint256): true, 6, 7 -> 0x00, 0x11 diff --git a/test/libsolidity/semanticTests/tryCatch/return_function.sol b/test/libsolidity/semanticTests/tryCatch/return_function.sol index b9c2d903f..82d5dc821 100644 --- a/test/libsolidity/semanticTests/tryCatch/return_function.sol +++ b/test/libsolidity/semanticTests/tryCatch/return_function.sol @@ -13,7 +13,5 @@ contract C { } function fun() public pure {} } -// ==== -// compileViaYul: also // ---- // f() -> 0x1, 0xfdd67305928fcac8d213d1e47bfa6165cd0b87b946644cd0000000000000000, 9 diff --git a/test/libsolidity/semanticTests/tryCatch/simple.sol b/test/libsolidity/semanticTests/tryCatch/simple.sol index 1f12614a7..48bccfa5a 100644 --- a/test/libsolidity/semanticTests/tryCatch/simple.sol +++ b/test/libsolidity/semanticTests/tryCatch/simple.sol @@ -13,7 +13,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f(bool): true -> 1, 2 // f(bool): false -> 9, 10 diff --git a/test/libsolidity/semanticTests/tryCatch/simple_notuple.sol b/test/libsolidity/semanticTests/tryCatch/simple_notuple.sol index 7b58006f4..6368edf70 100644 --- a/test/libsolidity/semanticTests/tryCatch/simple_notuple.sol +++ b/test/libsolidity/semanticTests/tryCatch/simple_notuple.sol @@ -13,7 +13,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f(bool): true -> 13 // f(bool): false -> 9 diff --git a/test/libsolidity/semanticTests/tryCatch/structured.sol b/test/libsolidity/semanticTests/tryCatch/structured.sol index e4c04932a..e5aa238b3 100644 --- a/test/libsolidity/semanticTests/tryCatch/structured.sol +++ b/test/libsolidity/semanticTests/tryCatch/structured.sol @@ -14,7 +14,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f(bool): true -> 1, 2, 0x60, 7, "success" // f(bool): false -> 0, 0, 0x60, 7, "message" diff --git a/test/libsolidity/semanticTests/tryCatch/structuredAndLowLevel.sol b/test/libsolidity/semanticTests/tryCatch/structuredAndLowLevel.sol index 91542d7ba..8a8cb3d1b 100644 --- a/test/libsolidity/semanticTests/tryCatch/structuredAndLowLevel.sol +++ b/test/libsolidity/semanticTests/tryCatch/structuredAndLowLevel.sol @@ -18,7 +18,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f(bool): true -> 1, 2, 96, 7, "success" // f(bool): false -> 99, 0, 96, 82, "message longer than 32 bytes 32 ", "bytes 32 bytes 32 bytes 32 bytes", " 32 bytes 32 bytes" diff --git a/test/libsolidity/semanticTests/tryCatch/super_trivial.sol b/test/libsolidity/semanticTests/tryCatch/super_trivial.sol index 9c0340522..98fbcddb2 100644 --- a/test/libsolidity/semanticTests/tryCatch/super_trivial.sol +++ b/test/libsolidity/semanticTests/tryCatch/super_trivial.sol @@ -12,7 +12,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f(bool): true -> 1 // f(bool): false -> 2 diff --git a/test/libsolidity/semanticTests/tryCatch/trivial.sol b/test/libsolidity/semanticTests/tryCatch/trivial.sol index 567b4b714..d43477e99 100644 --- a/test/libsolidity/semanticTests/tryCatch/trivial.sol +++ b/test/libsolidity/semanticTests/tryCatch/trivial.sol @@ -11,8 +11,6 @@ contract C { } } } -// ==== -// compileViaYul: also // ---- // f(bool): true -> 1 // f(bool): false -> 2 diff --git a/test/libsolidity/semanticTests/tryCatch/try_catch_library_call.sol b/test/libsolidity/semanticTests/tryCatch/try_catch_library_call.sol index cccec9a3c..e7bad76b0 100644 --- a/test/libsolidity/semanticTests/tryCatch/try_catch_library_call.sol +++ b/test/libsolidity/semanticTests/tryCatch/try_catch_library_call.sol @@ -37,7 +37,6 @@ contract C { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // library: L // f(bool): true -> 8, 0x40, 0 diff --git a/test/libsolidity/semanticTests/types/array_mapping_abstract_constructor_param.sol b/test/libsolidity/semanticTests/types/array_mapping_abstract_constructor_param.sol index 6ccfc5550..6a41ddbe9 100644 --- a/test/libsolidity/semanticTests/types/array_mapping_abstract_constructor_param.sol +++ b/test/libsolidity/semanticTests/types/array_mapping_abstract_constructor_param.sol @@ -11,8 +11,6 @@ contract C is A { constructor() A(m[1]) { } } -// ==== -// compileViaYul: also // ---- // m(uint256,uint256,uint256): 0, 0, 0 -> FAILURE // m(uint256,uint256,uint256): 1, 0, 1 -> 2 diff --git a/test/libsolidity/semanticTests/types/assign_calldata_value_type.sol b/test/libsolidity/semanticTests/types/assign_calldata_value_type.sol index 53f7fe974..04724f4c7 100644 --- a/test/libsolidity/semanticTests/types/assign_calldata_value_type.sol +++ b/test/libsolidity/semanticTests/types/assign_calldata_value_type.sol @@ -7,6 +7,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 23 -> 42, 23 diff --git a/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_fixed_bytes_greater_size.sol b/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_fixed_bytes_greater_size.sol index 83677d2ea..09558a697 100644 --- a/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_fixed_bytes_greater_size.sol +++ b/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_fixed_bytes_greater_size.sol @@ -5,6 +5,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // bytesToBytes(bytes2): "ab" -> "ab" diff --git a/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_fixed_bytes_same_size.sol b/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_fixed_bytes_same_size.sol index 6663b4dfe..541780027 100644 --- a/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_fixed_bytes_same_size.sol +++ b/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_fixed_bytes_same_size.sol @@ -5,6 +5,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // bytesToBytes(bytes4): "abcd" -> "abcd" diff --git a/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_fixed_bytes_smaller_size.sol b/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_fixed_bytes_smaller_size.sol index 2c7029e69..586849294 100644 --- a/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_fixed_bytes_smaller_size.sol +++ b/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_fixed_bytes_smaller_size.sol @@ -5,6 +5,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // bytesToBytes(bytes4): "abcd" -> "ab" diff --git a/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_greater_size.sol b/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_greater_size.sol index fb2872418..93906e6e0 100644 --- a/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_greater_size.sol +++ b/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_greater_size.sol @@ -5,6 +5,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // bytesToUint(bytes4): "abcd" -> 0x61626364 diff --git a/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_same_min_size.sol b/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_same_min_size.sol index 00a0f748c..52a99511d 100644 --- a/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_same_min_size.sol +++ b/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_same_min_size.sol @@ -5,6 +5,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // bytesToUint(bytes1): "a" -> 0x61 diff --git a/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_same_type.sol b/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_same_type.sol index c17a192e8..e13f99cd6 100644 --- a/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_same_type.sol +++ b/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_same_type.sol @@ -5,6 +5,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // bytesToUint(bytes32): "abc2" -> left(0x61626332) diff --git a/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_smaller_size.sol b/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_smaller_size.sol index 65db2cd9c..aae1576e5 100644 --- a/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_smaller_size.sol +++ b/test/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_smaller_size.sol @@ -5,6 +5,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // bytesToUint(bytes4): "abcd" -> 0x6364 diff --git a/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_greater_size.sol b/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_greater_size.sol index 07313e085..cf170a2aa 100644 --- a/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_greater_size.sol +++ b/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_greater_size.sol @@ -5,6 +5,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // UintToBytes(uint16): 0x6162 -> "\x00\x00\x00\x00\x00\x00ab" diff --git a/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_same_min_size.sol b/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_same_min_size.sol index 454a92d4f..18a09dfe5 100644 --- a/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_same_min_size.sol +++ b/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_same_min_size.sol @@ -5,6 +5,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // UintToBytes(uint8): 0x61 -> "a" diff --git a/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_same_size.sol b/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_same_size.sol index 3aa27fa2b..10c3a351d 100644 --- a/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_same_size.sol +++ b/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_same_size.sol @@ -5,6 +5,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // uintToBytes(uint256): left(0x616263) -> left(0x616263) diff --git a/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_smaller_size.sol b/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_smaller_size.sol index 8ede41746..8abc70d3d 100644 --- a/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_smaller_size.sol +++ b/test/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_smaller_size.sol @@ -5,6 +5,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // uintToBytes(uint32): 0x61626364 -> "cd" diff --git a/test/libsolidity/semanticTests/types/external_function_to_address.sol b/test/libsolidity/semanticTests/types/external_function_to_address.sol index 5ebcbeb2b..d2f5523b1 100644 --- a/test/libsolidity/semanticTests/types/external_function_to_address.sol +++ b/test/libsolidity/semanticTests/types/external_function_to_address.sol @@ -7,7 +7,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/types/mapping/user_defined_types_mapping_storage.sol b/test/libsolidity/semanticTests/types/mapping/user_defined_types_mapping_storage.sol index ae6756822..ef092f3ea 100644 --- a/test/libsolidity/semanticTests/types/mapping/user_defined_types_mapping_storage.sol +++ b/test/libsolidity/semanticTests/types/mapping/user_defined_types_mapping_storage.sol @@ -20,8 +20,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // library: L // testAB() -> true diff --git a/test/libsolidity/semanticTests/types/mapping_abstract_constructor_param.sol b/test/libsolidity/semanticTests/types/mapping_abstract_constructor_param.sol index 26a3b853e..e9ff60d5c 100644 --- a/test/libsolidity/semanticTests/types/mapping_abstract_constructor_param.sol +++ b/test/libsolidity/semanticTests/types/mapping_abstract_constructor_param.sol @@ -10,8 +10,6 @@ contract C is A { constructor() A(m) { } } -// ==== -// compileViaYul: also // ---- // m(uint256): 1 -> 0 // m(uint256): 5 -> 20 diff --git a/test/libsolidity/semanticTests/types/mapping_contract_key.sol b/test/libsolidity/semanticTests/types/mapping_contract_key.sol index 877ead6de..401776ffa 100644 --- a/test/libsolidity/semanticTests/types/mapping_contract_key.sol +++ b/test/libsolidity/semanticTests/types/mapping_contract_key.sol @@ -8,8 +8,6 @@ contract test { table[k] = v; } } -// ==== -// compileViaYul: also // ---- // get(address): 0 -> 0 // get(address): 0x01 -> 0 diff --git a/test/libsolidity/semanticTests/types/mapping_contract_key_getter.sol b/test/libsolidity/semanticTests/types/mapping_contract_key_getter.sol index 8e29ad63e..ee916a63d 100644 --- a/test/libsolidity/semanticTests/types/mapping_contract_key_getter.sol +++ b/test/libsolidity/semanticTests/types/mapping_contract_key_getter.sol @@ -8,8 +8,6 @@ contract test { return this.table(k); } } -// ==== -// compileViaYul: also // ---- // table(address): 0 -> 0 // table(address): 0x01 -> 0 diff --git a/test/libsolidity/semanticTests/types/mapping_contract_key_library.sol b/test/libsolidity/semanticTests/types/mapping_contract_key_library.sol index 8b78209ae..bedb605c1 100644 --- a/test/libsolidity/semanticTests/types/mapping_contract_key_library.sol +++ b/test/libsolidity/semanticTests/types/mapping_contract_key_library.sol @@ -16,8 +16,6 @@ contract test { L.set(table, k, v); } } -// ==== -// compileViaYul: also // ---- // library: L // get(address): 0 -> 0 diff --git a/test/libsolidity/semanticTests/types/mapping_enum_key_getter_v1.sol b/test/libsolidity/semanticTests/types/mapping_enum_key_getter_v1.sol index 973432d80..b34ef7798 100644 --- a/test/libsolidity/semanticTests/types/mapping_enum_key_getter_v1.sol +++ b/test/libsolidity/semanticTests/types/mapping_enum_key_getter_v1.sol @@ -12,6 +12,7 @@ contract test { // ==== // ABIEncoderV1Only: true // EVMVersion: >=byzantium +// compileViaYul: false // ---- // table(uint8): 0 -> 0 // table(uint8): 0x01 -> 0 diff --git a/test/libsolidity/semanticTests/types/mapping_enum_key_getter_v2.sol b/test/libsolidity/semanticTests/types/mapping_enum_key_getter_v2.sol index 834e866a3..cd252a3a5 100644 --- a/test/libsolidity/semanticTests/types/mapping_enum_key_getter_v2.sol +++ b/test/libsolidity/semanticTests/types/mapping_enum_key_getter_v2.sol @@ -9,8 +9,6 @@ contract test { return this.table(k); } } -// ==== -// compileViaYul: also // ---- // table(uint8): 0 -> 0 // table(uint8): 0x01 -> 0 diff --git a/test/libsolidity/semanticTests/types/mapping_enum_key_library_v1.sol b/test/libsolidity/semanticTests/types/mapping_enum_key_library_v1.sol index 3df034fc7..798ef812a 100644 --- a/test/libsolidity/semanticTests/types/mapping_enum_key_library_v1.sol +++ b/test/libsolidity/semanticTests/types/mapping_enum_key_library_v1.sol @@ -20,6 +20,7 @@ contract test { // ==== // EVMVersion: >=byzantium // ABIEncoderV1Only: true +// compileViaYul: false // ---- // library: L // get(uint8): 0 -> 0 diff --git a/test/libsolidity/semanticTests/types/mapping_enum_key_library_v2.sol b/test/libsolidity/semanticTests/types/mapping_enum_key_library_v2.sol index 5d2218b35..87676aa0d 100644 --- a/test/libsolidity/semanticTests/types/mapping_enum_key_library_v2.sol +++ b/test/libsolidity/semanticTests/types/mapping_enum_key_library_v2.sol @@ -20,7 +20,6 @@ contract test { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // library: L // get(uint8): 0 -> 0 diff --git a/test/libsolidity/semanticTests/types/mapping_enum_key_v2.sol b/test/libsolidity/semanticTests/types/mapping_enum_key_v2.sol index b8c28d249..a35fdd227 100644 --- a/test/libsolidity/semanticTests/types/mapping_enum_key_v2.sol +++ b/test/libsolidity/semanticTests/types/mapping_enum_key_v2.sol @@ -11,7 +11,6 @@ contract test { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // get(uint8): 0 -> 0 // get(uint8): 0x01 -> 0 diff --git a/test/libsolidity/semanticTests/types/mapping_simple.sol b/test/libsolidity/semanticTests/types/mapping_simple.sol index edee1d855..4da4c5b10 100644 --- a/test/libsolidity/semanticTests/types/mapping_simple.sol +++ b/test/libsolidity/semanticTests/types/mapping_simple.sol @@ -7,8 +7,6 @@ contract test { table[k] = v; } } -// ==== -// compileViaYul: also // ---- // get(uint8): 0 -> 0 // get(uint8): 0x01 -> 0 diff --git a/test/libsolidity/semanticTests/types/nested_tuples.sol b/test/libsolidity/semanticTests/types/nested_tuples.sol index 43cc88bf8..c3e96240a 100644 --- a/test/libsolidity/semanticTests/types/nested_tuples.sol +++ b/test/libsolidity/semanticTests/types/nested_tuples.sol @@ -28,7 +28,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f0() -> 2, true // f1() -> 1 diff --git a/test/libsolidity/semanticTests/types/packing_signed_types.sol b/test/libsolidity/semanticTests/types/packing_signed_types.sol index 16b11061a..392a52f2c 100644 --- a/test/libsolidity/semanticTests/types/packing_signed_types.sol +++ b/test/libsolidity/semanticTests/types/packing_signed_types.sol @@ -6,6 +6,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // run() -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa diff --git a/test/libsolidity/semanticTests/types/packing_unpacking_types.sol b/test/libsolidity/semanticTests/types/packing_unpacking_types.sol index 77015a9dc..7d12c47a4 100644 --- a/test/libsolidity/semanticTests/types/packing_unpacking_types.sol +++ b/test/libsolidity/semanticTests/types/packing_unpacking_types.sol @@ -7,7 +7,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // run(bool,uint32,uint64): true, 0x0f0f0f0f, 0xf0f0f0f0f0f0f0f0 // -> 0x0000000000000000000000000000000000000001f0f0f0f00f0f0f0f0f0f0f0f diff --git a/test/libsolidity/semanticTests/types/strings.sol b/test/libsolidity/semanticTests/types/strings.sol index 9f2df8ae6..9242eca2e 100644 --- a/test/libsolidity/semanticTests/types/strings.sol +++ b/test/libsolidity/semanticTests/types/strings.sol @@ -13,7 +13,6 @@ contract test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // fixedBytesHex() -> "\xaa\xbb\x00\xff" // fixedBytes() -> "abc\x00\xff__" diff --git a/test/libsolidity/semanticTests/types/struct_mapping_abstract_constructor_param.sol b/test/libsolidity/semanticTests/types/struct_mapping_abstract_constructor_param.sol index 47eaf7dc4..2040df1dd 100644 --- a/test/libsolidity/semanticTests/types/struct_mapping_abstract_constructor_param.sol +++ b/test/libsolidity/semanticTests/types/struct_mapping_abstract_constructor_param.sol @@ -18,8 +18,6 @@ contract C is A { return m[a].m[b]; } } -// ==== -// compileViaYul: also // ---- // getM(uint256,uint256): 0, 0 -> 0 // getM(uint256,uint256): 1, 5 -> 0x10 diff --git a/test/libsolidity/semanticTests/types/tuple_assign_multi_slot_grow.sol b/test/libsolidity/semanticTests/types/tuple_assign_multi_slot_grow.sol index 0e0c66802..5ac35853b 100644 --- a/test/libsolidity/semanticTests/types/tuple_assign_multi_slot_grow.sol +++ b/test/libsolidity/semanticTests/types/tuple_assign_multi_slot_grow.sol @@ -9,6 +9,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x30, 0x31, 0x32 diff --git a/test/libsolidity/semanticTests/types/type_conversion_cleanup.sol b/test/libsolidity/semanticTests/types/type_conversion_cleanup.sol index fda96b6cc..320290c9f 100644 --- a/test/libsolidity/semanticTests/types/type_conversion_cleanup.sol +++ b/test/libsolidity/semanticTests/types/type_conversion_cleanup.sol @@ -3,6 +3,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 0xffffffffffffffffffffffffffffffff diff --git a/test/libsolidity/semanticTests/underscore/as_function.sol b/test/libsolidity/semanticTests/underscore/as_function.sol index e97cc1705..8f9fe0b59 100644 --- a/test/libsolidity/semanticTests/underscore/as_function.sol +++ b/test/libsolidity/semanticTests/underscore/as_function.sol @@ -14,7 +14,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // _() -> 88 // g() -> 88 diff --git a/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidInConstructor.sol b/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidInConstructor.sol index 85c12f0ad..e2551a2a8 100644 --- a/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidInConstructor.sol +++ b/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidInConstructor.sol @@ -21,6 +21,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> FAILURE, hex"4e487b71", 0x51 diff --git a/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidStoredInConstructor.sol b/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidStoredInConstructor.sol index 0c5ac1e57..209ad8bb2 100644 --- a/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidStoredInConstructor.sol +++ b/test/libsolidity/semanticTests/uninitializedFunctionPointer/invalidStoredInConstructor.sol @@ -21,6 +21,5 @@ contract Test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> FAILURE, hex"4e487b71", 0x51 diff --git a/test/libsolidity/semanticTests/uninitializedFunctionPointer/store2.sol b/test/libsolidity/semanticTests/uninitializedFunctionPointer/store2.sol index d791bbcb1..0f446f775 100644 --- a/test/libsolidity/semanticTests/uninitializedFunctionPointer/store2.sol +++ b/test/libsolidity/semanticTests/uninitializedFunctionPointer/store2.sol @@ -37,6 +37,5 @@ contract InvalidTest { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // run() -> FAILURE, hex"4e487b71", 0x51 diff --git a/test/libsolidity/semanticTests/uninitializedFunctionPointer/storeInConstructor.sol b/test/libsolidity/semanticTests/uninitializedFunctionPointer/storeInConstructor.sol index cd20189d4..e534e4231 100644 --- a/test/libsolidity/semanticTests/uninitializedFunctionPointer/storeInConstructor.sol +++ b/test/libsolidity/semanticTests/uninitializedFunctionPointer/storeInConstructor.sol @@ -16,7 +16,6 @@ contract InvalidTest { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> FAILURE, hex"4e487b71", 0x51 // f() -> FAILURE, hex"4e487b71", 0x51 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/abicodec.sol b/test/libsolidity/semanticTests/userDefinedValueType/abicodec.sol index 65c604d1b..c2f89ba86 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/abicodec.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/abicodec.sol @@ -30,7 +30,6 @@ contract C { } } // ==== -// compileViaYul: also // EVMVersion: >=byzantium // ---- // g() -> true diff --git a/test/libsolidity/semanticTests/userDefinedValueType/assembly_access_bytes2_abicoder_v2.sol b/test/libsolidity/semanticTests/userDefinedValueType/assembly_access_bytes2_abicoder_v2.sol index 6af03b847..67e6107a6 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/assembly_access_bytes2_abicoder_v2.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/assembly_access_bytes2_abicoder_v2.sol @@ -24,8 +24,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(bytes2): "ab" -> 0x6162000000000000000000000000000000000000000000000000000000000000 // g(bytes2): "ab" -> 0x6162000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/calldata.sol b/test/libsolidity/semanticTests/userDefinedValueType/calldata.sol index 433470160..fe7ea4596 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/calldata.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/calldata.sol @@ -47,11 +47,9 @@ contract C { } } } -// ==== -// compileViaYul: also // ---- // test_f() -> true -// gas irOptimized: 122329 +// gas irOptimized: 122053 // gas legacy: 126150 // gas legacyOptimized: 123163 // test_g() -> true diff --git a/test/libsolidity/semanticTests/userDefinedValueType/calldata_to_storage.sol b/test/libsolidity/semanticTests/userDefinedValueType/calldata_to_storage.sol index 0305fd473..c3d58811a 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/calldata_to_storage.sol @@ -20,8 +20,6 @@ contract C { return l; } } -// ==== -// compileViaYul: also // ---- // s() -> 0, 0, 0x00, 0 // f((uint8,uint16,bytes2,uint8)): 1, 0xff, "ab", 15 -> diff --git a/test/libsolidity/semanticTests/userDefinedValueType/cleanup.sol b/test/libsolidity/semanticTests/userDefinedValueType/cleanup.sol index 771e0f80c..cc5304ed7 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/cleanup.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/cleanup.sol @@ -34,8 +34,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // ret() -> 0xff // f(uint8): 0x1ff -> FAILURE diff --git a/test/libsolidity/semanticTests/userDefinedValueType/constant.sol b/test/libsolidity/semanticTests/userDefinedValueType/constant.sol index 9559c3d7a..a1e587522 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/constant.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/constant.sol @@ -5,8 +5,6 @@ contract C { T constant public t = s; int224 constant public u = T.unwrap(t); } -// ==== -// compileViaYul: also // ---- // s() -> 165521356710917456517261742455526507355687727119203895813322792776 // t() -> 165521356710917456517261742455526507355687727119203895813322792776 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/conversion.sol b/test/libsolidity/semanticTests/userDefinedValueType/conversion.sol index bbf5dcf29..bcdc9440e 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/conversion.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/conversion.sol @@ -28,8 +28,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(uint256): 1 -> 1 // f(uint256): 2 -> 2 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/dirty_slot.sol b/test/libsolidity/semanticTests/userDefinedValueType/dirty_slot.sol index a74d02ff1..4936ba808 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/dirty_slot.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/dirty_slot.sol @@ -20,8 +20,6 @@ contract C { return MyBytes2.unwrap(b)[index]; } } -// ==== -// compileViaYul: also // ---- // a() -> 13 // b() -> 0x0401000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/dirty_uint8_read.sol b/test/libsolidity/semanticTests/userDefinedValueType/dirty_uint8_read.sol index 4100e17f8..a5a51461b 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/dirty_uint8_read.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/dirty_uint8_read.sol @@ -18,8 +18,6 @@ contract C { } } } -// ==== -// compileViaYul: also // ---- // x() -> -5 // create_dirty_slot() -> diff --git a/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol b/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol index d65af8e8c..167521bff 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/erc20.sol @@ -110,14 +110,12 @@ contract ERC20 { _approve(account, msg.sender, _allowances[account][msg.sender].sub(value)); } } -// ==== -// compileViaYul: also // ---- // constructor() // ~ emit Transfer(address,address,uint256): #0x00, #0x1212121212121212121212121212120000000012, 0x14 -// gas irOptimized: 418388 -// gas legacy: 860880 -// gas legacyOptimized: 420959 +// gas irOptimized: 362054 +// gas legacy: 852973 +// gas legacyOptimized: 419237 // totalSupply() -> 20 // gas irOptimized: 23415 // gas legacy: 23653 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/fixedpoint.sol b/test/libsolidity/semanticTests/userDefinedValueType/fixedpoint.sol index 47140a773..4afd48087 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/fixedpoint.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/fixedpoint.sol @@ -40,8 +40,6 @@ contract TestFixedMath { return FixedMath.toUFixed256x18(a); } } -// ==== -// compileViaYul: also // ---- // add(uint256,uint256): 0, 0 -> 0 // add(uint256,uint256): 25, 45 -> 0x46 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/immutable_signed.sol b/test/libsolidity/semanticTests/userDefinedValueType/immutable_signed.sol index 8923984a4..ec017a982 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/immutable_signed.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/immutable_signed.sol @@ -14,8 +14,6 @@ contract C { } function g() internal pure returns (uint) { return 2; } } -// ==== -// compileViaYul: also // ---- // direct() -> -2, 0x6162000000000000000000000000000000000000000000000000000000000000 // viaasm() -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 0x6162000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/in_parenthesis.sol b/test/libsolidity/semanticTests/userDefinedValueType/in_parenthesis.sol index 0691a4c3a..1b64dbcee 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/in_parenthesis.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/in_parenthesis.sol @@ -7,7 +7,5 @@ contract C { b = (MyInt).unwrap((MyInt).wrap(10)); } } -// ==== -// compileViaYul: also // ---- // f() -> 5, 10 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/mapping_key.sol b/test/libsolidity/semanticTests/userDefinedValueType/mapping_key.sol index e698308b4..f209c7a42 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/mapping_key.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/mapping_key.sol @@ -8,8 +8,6 @@ contract C { m[MyInt.wrap(key)] = value; } } -// ==== -// compileViaYul: also // ---- // set(int256,int256): 1, 1 -> // m(int256): 1 -> 1 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/memory_to_storage.sol b/test/libsolidity/semanticTests/userDefinedValueType/memory_to_storage.sol index b250bea87..db745dce3 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/memory_to_storage.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/memory_to_storage.sol @@ -20,8 +20,6 @@ contract C { return l; } } -// ==== -// compileViaYul: also // ---- // s() -> 0, 0, 0x00, 0 // f((uint8,uint16,bytes2,uint8)): 1, 0xff, "ab", 15 -> diff --git a/test/libsolidity/semanticTests/userDefinedValueType/multisource.sol b/test/libsolidity/semanticTests/userDefinedValueType/multisource.sol index 67069157c..d30c73605 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/multisource.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/multisource.sol @@ -7,8 +7,6 @@ contract A { function f(int x) external view returns(MyInt) { return MyInt.wrap(x); } function f(address x) external view returns(OurAddress) { return OurAddress.wrap(x); } } -// ==== -// compileViaYul: also // ---- // f(int256): 5 -> 5 // f(address): 1 -> 1 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/multisource_module.sol b/test/libsolidity/semanticTests/userDefinedValueType/multisource_module.sol index 2d2833059..5f107ce15 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/multisource_module.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/multisource_module.sol @@ -6,8 +6,6 @@ contract C { function f(int x) public pure returns (M.MyInt) { return M.MyInt.wrap(x); } function g(M.MyInt x) public pure returns (int) { return M.MyInt.unwrap(x); } } -// ==== -// compileViaYul: also // ---- // f(int256): 5 -> 5 // g(int256): 1 -> 1 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/ownable.sol b/test/libsolidity/semanticTests/userDefinedValueType/ownable.sol index 3f31acaca..3c9787fdc 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/ownable.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/ownable.sol @@ -21,8 +21,6 @@ contract Ownable { owner = Owner.wrap(address(0)); } } -// ==== -// compileViaYul: also // ---- // owner() -> 0x1212121212121212121212121212120000000012 // setOwner(address): 0x1212121212121212121212121212120000000012 -> diff --git a/test/libsolidity/semanticTests/userDefinedValueType/parameter.sol b/test/libsolidity/semanticTests/userDefinedValueType/parameter.sol index 56cebc923..bbabc1dd6 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/parameter.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/parameter.sol @@ -22,8 +22,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // id(address): 5 -> 5 // id(address): 0xffffffffffffffffffffffffffffffffffffffff -> 0xffffffffffffffffffffffffffffffffffffffff diff --git a/test/libsolidity/semanticTests/userDefinedValueType/simple.sol b/test/libsolidity/semanticTests/userDefinedValueType/simple.sol index fd5cdd07a..e2c23c4f6 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/simple.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/simple.sol @@ -7,8 +7,6 @@ contract C { c = MyInt.wrap(1); } } -// ==== -// compileViaYul: also // ---- // f() -> 0 // g() -> 1, 1 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/storage_layout.sol b/test/libsolidity/semanticTests/userDefinedValueType/storage_layout.sol index aab0b86d8..284b41225 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/storage_layout.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/storage_layout.sol @@ -62,8 +62,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // storage_a() -> 0, 0 // storage_b() -> 0, 1 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/storage_layout_struct.sol b/test/libsolidity/semanticTests/userDefinedValueType/storage_layout_struct.sol index 219145a57..ee63c185d 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/storage_layout_struct.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/storage_layout_struct.sol @@ -151,8 +151,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // storage_a() -> 0, 0 // set_a(int64,int64): 100, 200 -> diff --git a/test/libsolidity/semanticTests/userDefinedValueType/storage_signed.sol b/test/libsolidity/semanticTests/userDefinedValueType/storage_signed.sol index 80745866a..813931e02 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/storage_signed.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/storage_signed.sol @@ -23,8 +23,6 @@ contract C { assembly { x := st } } } -// ==== -// compileViaYul: also // ---- // a() -> -2 // direct() -> -2 diff --git a/test/libsolidity/semanticTests/userDefinedValueType/wrap_unwrap.sol b/test/libsolidity/semanticTests/userDefinedValueType/wrap_unwrap.sol index c3b68e7c3..117e0dd84 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/wrap_unwrap.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/wrap_unwrap.sol @@ -5,7 +5,5 @@ contract C { MyAddress.unwrap; } } -// ==== -// compileViaYul: also // ---- // f() -> diff --git a/test/libsolidity/semanticTests/userDefinedValueType/wrap_unwrap_via_contract_name.sol b/test/libsolidity/semanticTests/userDefinedValueType/wrap_unwrap_via_contract_name.sol index f6103c596..1da734fae 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/wrap_unwrap_via_contract_name.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/wrap_unwrap_via_contract_name.sol @@ -15,8 +15,6 @@ contract D { return g(f(x)); } } -// ==== -// compileViaYul: also // ---- // f(uint256): 0x42 -> 0x42 // g(uint256): 0x42 -> 0x42 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 d2d46c708..1c3b66b28 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/zero_cost_abstraction_comparison_elementary.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/zero_cost_abstraction_comparison_elementary.sol @@ -16,8 +16,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // getX() -> 0 // gas irOptimized: 23379 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 44d87c397..55e38689f 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/zero_cost_abstraction_comparison_userdefined.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/zero_cost_abstraction_comparison_userdefined.sol @@ -17,8 +17,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // getX() -> 0 // gas irOptimized: 23379 diff --git a/test/libsolidity/semanticTests/using/calldata_memory_copy.sol b/test/libsolidity/semanticTests/using/calldata_memory_copy.sol index 493cfc29b..a9b99dd34 100644 --- a/test/libsolidity/semanticTests/using/calldata_memory_copy.sol +++ b/test/libsolidity/semanticTests/using/calldata_memory_copy.sol @@ -13,7 +13,5 @@ function sum(uint[] memory arr) returns (uint result) { using {sum} for uint[]; -// ==== -// compileViaYul: also // ---- // f(uint256[]): 0x20, 3, 1, 2, 8 -> 11 diff --git a/test/libsolidity/semanticTests/using/free_function_braces.sol b/test/libsolidity/semanticTests/using/free_function_braces.sol index e522ff61b..897914b9b 100644 --- a/test/libsolidity/semanticTests/using/free_function_braces.sol +++ b/test/libsolidity/semanticTests/using/free_function_braces.sol @@ -17,8 +17,6 @@ contract C { using {id, zero} for uint; } -// ==== -// compileViaYul: also // ---- // f(uint256): 10 -> 10 // g(uint256): 10 -> 0 diff --git a/test/libsolidity/semanticTests/using/free_function_multi.sol b/test/libsolidity/semanticTests/using/free_function_multi.sol index bf71e4d44..feec1beb3 100644 --- a/test/libsolidity/semanticTests/using/free_function_multi.sol +++ b/test/libsolidity/semanticTests/using/free_function_multi.sol @@ -18,8 +18,6 @@ function zero(uint) pure returns (uint) { return 0; } -// ==== -// compileViaYul: also // ---- // f(uint256): 10 -> 10 // g(uint256): 10 -> 0 diff --git a/test/libsolidity/semanticTests/using/free_functions_individual.sol b/test/libsolidity/semanticTests/using/free_functions_individual.sol index 334b427e1..170eae4d0 100644 --- a/test/libsolidity/semanticTests/using/free_functions_individual.sol +++ b/test/libsolidity/semanticTests/using/free_functions_individual.sol @@ -21,8 +21,6 @@ function zero(uint) pure returns (uint) { } -// ==== -// compileViaYul: also // ---- // f(uint256): 10 -> 10 // g(uint256): 10 -> 0 diff --git a/test/libsolidity/semanticTests/using/imported_functions.sol b/test/libsolidity/semanticTests/using/imported_functions.sol index d99e558fd..60a801ba3 100644 --- a/test/libsolidity/semanticTests/using/imported_functions.sol +++ b/test/libsolidity/semanticTests/using/imported_functions.sol @@ -12,8 +12,6 @@ contract C { using {A.inc, f} for uint; import {inc as f} from "A"; import "A" as A; -// ==== -// compileViaYul: also // ---- // f(uint256): 5 -> 12 // f(uint256): 10 -> 0x16 diff --git a/test/libsolidity/semanticTests/using/library_on_interface.sol b/test/libsolidity/semanticTests/using/library_on_interface.sol index ff716dadb..48553c218 100644 --- a/test/libsolidity/semanticTests/using/library_on_interface.sol +++ b/test/libsolidity/semanticTests/using/library_on_interface.sol @@ -12,7 +12,5 @@ contract C is I { } function f() public pure returns (uint) { return 7; } } -// ==== -// compileViaYul: also // ---- // x() -> 7 diff --git a/test/libsolidity/semanticTests/using/library_through_module.sol b/test/libsolidity/semanticTests/using/library_through_module.sol index 6102f5a70..cb33613cb 100644 --- a/test/libsolidity/semanticTests/using/library_through_module.sol +++ b/test/libsolidity/semanticTests/using/library_through_module.sol @@ -24,8 +24,6 @@ contract C { import "A" as M; -// ==== -// compileViaYul: also // ---- // library: "A":L // f(uint256): 5 -> 5 diff --git a/test/libsolidity/semanticTests/using/module_renamed.sol b/test/libsolidity/semanticTests/using/module_renamed.sol index d648e88d1..427e220ff 100644 --- a/test/libsolidity/semanticTests/using/module_renamed.sol +++ b/test/libsolidity/semanticTests/using/module_renamed.sol @@ -20,7 +20,5 @@ using {M.g, M.f} for uint; import "B" as M; -// ==== -// compileViaYul: also // ---- // test(uint256,uint256): 1, 1 -> 9, 3 diff --git a/test/libsolidity/semanticTests/using/recursive_import.sol b/test/libsolidity/semanticTests/using/recursive_import.sol index 09d27db60..6c8962598 100644 --- a/test/libsolidity/semanticTests/using/recursive_import.sol +++ b/test/libsolidity/semanticTests/using/recursive_import.sol @@ -19,7 +19,5 @@ contract C { return cr().f().g(); } } -// ==== -// compileViaYul: also // ---- // f() -> 11 diff --git a/test/libsolidity/semanticTests/using/using_global_all_the_types.sol b/test/libsolidity/semanticTests/using/using_global_all_the_types.sol index b4f071fa2..f19c0c0fb 100644 --- a/test/libsolidity/semanticTests/using/using_global_all_the_types.sol +++ b/test/libsolidity/semanticTests/using/using_global_all_the_types.sol @@ -32,7 +32,5 @@ contract C { import {E, S, T} from "A"; -// ==== -// compileViaYul: also // ---- // f() -> 1, 7, 9 diff --git a/test/libsolidity/semanticTests/using/using_global_for_global.sol b/test/libsolidity/semanticTests/using/using_global_for_global.sol index 7d7809d2a..77bbb896f 100644 --- a/test/libsolidity/semanticTests/using/using_global_for_global.sol +++ b/test/libsolidity/semanticTests/using/using_global_for_global.sol @@ -14,7 +14,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(uint256): 100 -> 111 \ No newline at end of file diff --git a/test/libsolidity/semanticTests/using/using_global_invisible.sol b/test/libsolidity/semanticTests/using/using_global_invisible.sol index e4bf286ee..2ad94f050 100644 --- a/test/libsolidity/semanticTests/using/using_global_invisible.sol +++ b/test/libsolidity/semanticTests/using/using_global_invisible.sol @@ -37,9 +37,7 @@ contract D { return c.f().inc().inc().dec().unwrap(); } } -// ==== -// compileViaYul: also // ---- // library: "A":L // test() -> 3 -// gas legacy: 130369 +// gas legacy: 123521 diff --git a/test/libsolidity/semanticTests/using/using_global_library.sol b/test/libsolidity/semanticTests/using/using_global_library.sol index 747ed6bd0..f18024f37 100644 --- a/test/libsolidity/semanticTests/using/using_global_library.sol +++ b/test/libsolidity/semanticTests/using/using_global_library.sol @@ -20,8 +20,6 @@ contract C { import {T} from "A"; -// ==== -// compileViaYul: also // ---- // library: "A":L // f() -> 2, 1 diff --git a/test/libsolidity/semanticTests/variables/delete_local.sol b/test/libsolidity/semanticTests/variables/delete_local.sol index 4b28e1966..21f4c8edf 100644 --- a/test/libsolidity/semanticTests/variables/delete_local.sol +++ b/test/libsolidity/semanticTests/variables/delete_local.sol @@ -7,6 +7,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // delLocal() -> 0 diff --git a/test/libsolidity/semanticTests/variables/delete_locals.sol b/test/libsolidity/semanticTests/variables/delete_locals.sol index c90048589..8c14639d3 100644 --- a/test/libsolidity/semanticTests/variables/delete_locals.sol +++ b/test/libsolidity/semanticTests/variables/delete_locals.sol @@ -10,6 +10,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // delLocal() -> 6, 7 diff --git a/test/libsolidity/semanticTests/variables/mapping_local_assignment.sol b/test/libsolidity/semanticTests/variables/mapping_local_assignment.sol index b4b158f62..b99385823 100644 --- a/test/libsolidity/semanticTests/variables/mapping_local_assignment.sol +++ b/test/libsolidity/semanticTests/variables/mapping_local_assignment.sol @@ -11,7 +11,5 @@ contract test { return (m1[1], m1[2], m2[1], m2[2]); } } -// ==== -// compileViaYul: also // ---- // f() -> 42, 0, 0, 21 diff --git a/test/libsolidity/semanticTests/variables/mapping_local_compound_assignment.sol b/test/libsolidity/semanticTests/variables/mapping_local_compound_assignment.sol index 5e237ae17..df3ee2f54 100644 --- a/test/libsolidity/semanticTests/variables/mapping_local_compound_assignment.sol +++ b/test/libsolidity/semanticTests/variables/mapping_local_compound_assignment.sol @@ -10,7 +10,5 @@ contract test { return (m1[1], m1[2], m2[1], m2[2]); } } -// ==== -// compileViaYul: also // ---- // f() -> 42, 0, 0, 21 diff --git a/test/libsolidity/semanticTests/variables/mapping_local_tuple_assignment.sol b/test/libsolidity/semanticTests/variables/mapping_local_tuple_assignment.sol index eb5e6b854..39dd04abb 100644 --- a/test/libsolidity/semanticTests/variables/mapping_local_tuple_assignment.sol +++ b/test/libsolidity/semanticTests/variables/mapping_local_tuple_assignment.sol @@ -12,7 +12,5 @@ contract test { return (m1[1], m1[2], m2[1], m2[2]); } } -// ==== -// compileViaYul: also // ---- // f() -> 42, 0, 0, 21 diff --git a/test/libsolidity/semanticTests/variables/public_state_overridding.sol b/test/libsolidity/semanticTests/variables/public_state_overridding.sol index 05bd32ac2..752c429ca 100644 --- a/test/libsolidity/semanticTests/variables/public_state_overridding.sol +++ b/test/libsolidity/semanticTests/variables/public_state_overridding.sol @@ -13,7 +13,6 @@ contract X is A } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> 0 // set() -> diff --git a/test/libsolidity/semanticTests/variables/public_state_overridding_dynamic_struct.sol b/test/libsolidity/semanticTests/variables/public_state_overridding_dynamic_struct.sol index fb74e078c..2195c85e1 100644 --- a/test/libsolidity/semanticTests/variables/public_state_overridding_dynamic_struct.sol +++ b/test/libsolidity/semanticTests/variables/public_state_overridding_dynamic_struct.sol @@ -19,7 +19,6 @@ contract X is A // ==== -// compileViaYul: also // compileToEwasm: also // ---- // test() -> 0, 64, 0 diff --git a/test/libsolidity/semanticTests/variables/public_state_overridding_mapping_to_dynamic_struct.sol b/test/libsolidity/semanticTests/variables/public_state_overridding_mapping_to_dynamic_struct.sol index befa5ab2a..5a3df6d21 100644 --- a/test/libsolidity/semanticTests/variables/public_state_overridding_mapping_to_dynamic_struct.sol +++ b/test/libsolidity/semanticTests/variables/public_state_overridding_mapping_to_dynamic_struct.sol @@ -18,8 +18,6 @@ contract X is A } -// ==== -// compileViaYul: also // ---- // test(uint256): 0 -> 0, 64, 0 // test(uint256): 42 -> 0, 64, 0 diff --git a/test/libsolidity/semanticTests/variables/storing_invalid_boolean.sol b/test/libsolidity/semanticTests/variables/storing_invalid_boolean.sol index 930ded40b..7a4d36205 100644 --- a/test/libsolidity/semanticTests/variables/storing_invalid_boolean.sol +++ b/test/libsolidity/semanticTests/variables/storing_invalid_boolean.sol @@ -25,8 +25,6 @@ contract C { return 1; } } -// ==== -// compileViaYul: also // ---- // set() -> 1 // perm() -> true diff --git a/test/libsolidity/semanticTests/various/address_code.sol b/test/libsolidity/semanticTests/various/address_code.sol index 2adf31716..8dcdd13e7 100644 --- a/test/libsolidity/semanticTests/various/address_code.sol +++ b/test/libsolidity/semanticTests/various/address_code.sol @@ -14,12 +14,11 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // constructor() -> -// gas irOptimized: 192317 -// gas legacy: 240889 -// gas legacyOptimized: 155314 +// gas irOptimized: 175791 +// gas legacy: 247263 +// gas legacyOptimized: 155977 // initCode() -> 0x20, 0 // f() -> true // g() -> 0 diff --git a/test/libsolidity/semanticTests/various/address_code_complex.sol b/test/libsolidity/semanticTests/various/address_code_complex.sol index 0d3bf862a..f2d21c906 100644 --- a/test/libsolidity/semanticTests/various/address_code_complex.sol +++ b/test/libsolidity/semanticTests/various/address_code_complex.sol @@ -12,8 +12,6 @@ contract C { function f() public returns (bytes memory) { return address(new A()).code; } function g() public returns (uint) { return address(new A()).code.length; } } -// ==== -// compileViaYul: also // ---- // f() -> 0x20, 0x20, 0x48aa5566000000 // g() -> 0x20 diff --git a/test/libsolidity/semanticTests/various/assignment_to_const_var_involving_expression.sol b/test/libsolidity/semanticTests/various/assignment_to_const_var_involving_expression.sol index 4216c4d7e..0aa7ceb95 100644 --- a/test/libsolidity/semanticTests/various/assignment_to_const_var_involving_expression.sol +++ b/test/libsolidity/semanticTests/various/assignment_to_const_var_involving_expression.sol @@ -8,6 +8,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x57a diff --git a/test/libsolidity/semanticTests/various/balance.sol b/test/libsolidity/semanticTests/various/balance.sol index 92c388961..916c7fbff 100644 --- a/test/libsolidity/semanticTests/various/balance.sol +++ b/test/libsolidity/semanticTests/various/balance.sol @@ -8,7 +8,6 @@ contract test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // constructor(), 23 wei -> // getBalance() -> 23 diff --git a/test/libsolidity/semanticTests/various/byte_optimization_bug.sol b/test/libsolidity/semanticTests/various/byte_optimization_bug.sol index d21752021..f023e971f 100644 --- a/test/libsolidity/semanticTests/various/byte_optimization_bug.sol +++ b/test/libsolidity/semanticTests/various/byte_optimization_bug.sol @@ -14,7 +14,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 2 -> 0 // g(uint256): 2 -> 2 diff --git a/test/libsolidity/semanticTests/various/code_access_content.sol b/test/libsolidity/semanticTests/various/code_access_content.sol index 39ac71b54..5ed7db5a3 100644 --- a/test/libsolidity/semanticTests/various/code_access_content.sol +++ b/test/libsolidity/semanticTests/various/code_access_content.sol @@ -36,8 +36,6 @@ contract C { return true; } } -// ==== -// compileViaYul: also // ---- // testRuntime() -> true // gas legacy: 101579 diff --git a/test/libsolidity/semanticTests/various/code_access_create.sol b/test/libsolidity/semanticTests/various/code_access_create.sol index ce0d6305d..ae3825651 100644 --- a/test/libsolidity/semanticTests/various/code_access_create.sol +++ b/test/libsolidity/semanticTests/various/code_access_create.sol @@ -22,8 +22,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // test() -> 7 // gas legacy: 102264 diff --git a/test/libsolidity/semanticTests/various/code_access_padding.sol b/test/libsolidity/semanticTests/various/code_access_padding.sol index d2f333bf2..831d4bde4 100644 --- a/test/libsolidity/semanticTests/various/code_access_padding.sol +++ b/test/libsolidity/semanticTests/various/code_access_padding.sol @@ -14,7 +14,5 @@ contract C { } } } -// ==== -// compileViaYul: also // ---- // diff() -> 0 # This checks that the allocation function pads to multiples of 32 bytes # diff --git a/test/libsolidity/semanticTests/various/code_access_runtime.sol b/test/libsolidity/semanticTests/various/code_access_runtime.sol index 49d0d9ceb..588ed3ac5 100644 --- a/test/libsolidity/semanticTests/various/code_access_runtime.sol +++ b/test/libsolidity/semanticTests/various/code_access_runtime.sol @@ -22,7 +22,6 @@ contract C { // ==== // EVMVersion: >=constantinople -// compileViaYul: also // ---- // test() -> 42 // gas legacy: 101638 diff --git a/test/libsolidity/semanticTests/various/code_length.sol b/test/libsolidity/semanticTests/various/code_length.sol index ad4b6f874..0e17ae2a2 100644 --- a/test/libsolidity/semanticTests/various/code_length.sol +++ b/test/libsolidity/semanticTests/various/code_length.sol @@ -59,7 +59,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // constructor() // gas legacy: 126455 diff --git a/test/libsolidity/semanticTests/various/code_length_contract_member.sol b/test/libsolidity/semanticTests/various/code_length_contract_member.sol index 0f697af30..8486671ed 100644 --- a/test/libsolidity/semanticTests/various/code_length_contract_member.sol +++ b/test/libsolidity/semanticTests/various/code_length_contract_member.sol @@ -12,7 +12,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 0x20, 0x20, true diff --git a/test/libsolidity/semanticTests/various/codebalance_assembly.sol b/test/libsolidity/semanticTests/various/codebalance_assembly.sol index 98f4e2969..be2b89f29 100644 --- a/test/libsolidity/semanticTests/various/codebalance_assembly.sol +++ b/test/libsolidity/semanticTests/various/codebalance_assembly.sol @@ -20,7 +20,6 @@ contract C { // ==== // EVMVersion: >=constantinople -// compileViaYul: also // ---- // constructor(), 23 wei -> // gas legacy: 100517 diff --git a/test/libsolidity/semanticTests/various/codehash.sol b/test/libsolidity/semanticTests/various/codehash.sol index c8730cca6..f787ca5be 100644 --- a/test/libsolidity/semanticTests/various/codehash.sol +++ b/test/libsolidity/semanticTests/various/codehash.sol @@ -14,7 +14,6 @@ contract C { // ==== // EVMVersion: >=constantinople -// compileViaYul: also // ---- // f() -> 0x0 // g() -> 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 diff --git a/test/libsolidity/semanticTests/various/codehash_assembly.sol b/test/libsolidity/semanticTests/various/codehash_assembly.sol index 4ac2a93f1..71e3a20ef 100644 --- a/test/libsolidity/semanticTests/various/codehash_assembly.sol +++ b/test/libsolidity/semanticTests/various/codehash_assembly.sol @@ -18,7 +18,6 @@ contract C { // ==== // EVMVersion: >=constantinople -// compileViaYul: also // ---- // f() -> 0 // g() -> 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 diff --git a/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol b/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol index 9ff4fe5e2..561e31688 100644 --- a/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol +++ b/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol @@ -18,7 +18,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // constructor() -> -// gas irOptimized: 101063 +// gas irOptimized: 100415 diff --git a/test/libsolidity/semanticTests/various/crazy_elementary_typenames_on_stack.sol b/test/libsolidity/semanticTests/various/crazy_elementary_typenames_on_stack.sol index 473358bad..135543898 100644 --- a/test/libsolidity/semanticTests/various/crazy_elementary_typenames_on_stack.sol +++ b/test/libsolidity/semanticTests/various/crazy_elementary_typenames_on_stack.sol @@ -11,6 +11,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> -7 diff --git a/test/libsolidity/semanticTests/various/cross_contract_types.sol b/test/libsolidity/semanticTests/various/cross_contract_types.sol index d2fd2aa28..b0cf070a7 100644 --- a/test/libsolidity/semanticTests/various/cross_contract_types.sol +++ b/test/libsolidity/semanticTests/various/cross_contract_types.sol @@ -15,6 +15,5 @@ contract Test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 3 diff --git a/test/libsolidity/semanticTests/various/decayed_tuple.sol b/test/libsolidity/semanticTests/various/decayed_tuple.sol index 486613036..f143b9847 100644 --- a/test/libsolidity/semanticTests/various/decayed_tuple.sol +++ b/test/libsolidity/semanticTests/various/decayed_tuple.sol @@ -7,6 +7,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 2 diff --git a/test/libsolidity/semanticTests/various/destructuring_assignment.sol b/test/libsolidity/semanticTests/various/destructuring_assignment.sol index 23b6c9e58..99a8e8d4b 100644 --- a/test/libsolidity/semanticTests/various/destructuring_assignment.sol +++ b/test/libsolidity/semanticTests/various/destructuring_assignment.sol @@ -32,10 +32,8 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(bytes): 0x20, 0x5, "abcde" -> 0 -// gas irOptimized: 240662 -// gas legacy: 240349 -// gas legacyOptimized: 239673 +// gas irOptimized: 239090 +// gas legacy: 240541 +// gas legacyOptimized: 239654 diff --git a/test/libsolidity/semanticTests/various/empty_name_return_parameter.sol b/test/libsolidity/semanticTests/various/empty_name_return_parameter.sol index 6509db3f0..906df85cc 100644 --- a/test/libsolidity/semanticTests/various/empty_name_return_parameter.sol +++ b/test/libsolidity/semanticTests/various/empty_name_return_parameter.sol @@ -6,6 +6,5 @@ contract test { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 9 -> 9 diff --git a/test/libsolidity/semanticTests/various/erc20.sol b/test/libsolidity/semanticTests/various/erc20.sol index 109a27578..236ebbce5 100644 --- a/test/libsolidity/semanticTests/various/erc20.sol +++ b/test/libsolidity/semanticTests/various/erc20.sol @@ -93,14 +93,12 @@ contract ERC20 { _approve(account, msg.sender, _allowances[account][msg.sender] - value); } } -// ==== -// compileViaYul: also // ---- // constructor() // ~ emit Transfer(address,address,uint256): #0x00, #0x1212121212121212121212121212120000000012, 0x14 -// gas irOptimized: 413852 -// gas legacy: 832643 -// gas legacyOptimized: 416135 +// gas irOptimized: 357746 +// gas legacy: 824737 +// gas legacyOptimized: 414462 // totalSupply() -> 20 // gas irOptimized: 23415 // gas legacy: 23524 diff --git a/test/libsolidity/semanticTests/various/external_types_in_calls.sol b/test/libsolidity/semanticTests/various/external_types_in_calls.sol index 1b50465b4..55c201513 100644 --- a/test/libsolidity/semanticTests/various/external_types_in_calls.sol +++ b/test/libsolidity/semanticTests/various/external_types_in_calls.sol @@ -23,8 +23,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // test() -> 9, 7 // gas legacy: 129760 diff --git a/test/libsolidity/semanticTests/various/flipping_sign_tests.sol b/test/libsolidity/semanticTests/various/flipping_sign_tests.sol index 42251caf5..f2f63575a 100644 --- a/test/libsolidity/semanticTests/various/flipping_sign_tests.sol +++ b/test/libsolidity/semanticTests/various/flipping_sign_tests.sol @@ -7,7 +7,6 @@ contract test { } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/various/gasleft_decrease.sol b/test/libsolidity/semanticTests/various/gasleft_decrease.sol index 71810956a..22566bfb1 100644 --- a/test/libsolidity/semanticTests/various/gasleft_decrease.sol +++ b/test/libsolidity/semanticTests/various/gasleft_decrease.sol @@ -17,7 +17,6 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> true // g() -> true diff --git a/test/libsolidity/semanticTests/various/gasleft_shadow_resolution.sol b/test/libsolidity/semanticTests/various/gasleft_shadow_resolution.sol index 4cea82259..3fe3ba10d 100644 --- a/test/libsolidity/semanticTests/various/gasleft_shadow_resolution.sol +++ b/test/libsolidity/semanticTests/various/gasleft_shadow_resolution.sol @@ -10,6 +10,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0 diff --git a/test/libsolidity/semanticTests/various/inline_member_init.sol b/test/libsolidity/semanticTests/various/inline_member_init.sol index 6575b6161..7d3b75492 100644 --- a/test/libsolidity/semanticTests/various/inline_member_init.sol +++ b/test/libsolidity/semanticTests/various/inline_member_init.sol @@ -16,6 +16,5 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // get() -> 5, 6, 8 diff --git a/test/libsolidity/semanticTests/various/inline_member_init_inheritence.sol b/test/libsolidity/semanticTests/various/inline_member_init_inheritence.sol index c06233de4..825bd6d2f 100644 --- a/test/libsolidity/semanticTests/various/inline_member_init_inheritence.sol +++ b/test/libsolidity/semanticTests/various/inline_member_init_inheritence.sol @@ -20,7 +20,6 @@ contract Derived is Base { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // getBMember() -> 5 // getDMember() -> 6 diff --git a/test/libsolidity/semanticTests/various/inline_tuple_with_rational_numbers.sol b/test/libsolidity/semanticTests/various/inline_tuple_with_rational_numbers.sol index 73697c74a..f8c396dd1 100644 --- a/test/libsolidity/semanticTests/various/inline_tuple_with_rational_numbers.sol +++ b/test/libsolidity/semanticTests/various/inline_tuple_with_rational_numbers.sol @@ -7,6 +7,5 @@ contract c { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1 diff --git a/test/libsolidity/semanticTests/various/iszero_bnot_correct.sol b/test/libsolidity/semanticTests/various/iszero_bnot_correct.sol index a1cd64725..5744272ce 100644 --- a/test/libsolidity/semanticTests/various/iszero_bnot_correct.sol +++ b/test/libsolidity/semanticTests/various/iszero_bnot_correct.sol @@ -17,6 +17,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/various/literal_empty_string.sol b/test/libsolidity/semanticTests/various/literal_empty_string.sol index ab916ae8c..bf4da5409 100644 --- a/test/libsolidity/semanticTests/various/literal_empty_string.sol +++ b/test/libsolidity/semanticTests/various/literal_empty_string.sol @@ -12,8 +12,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // x() -> 0 // a() -> 0 diff --git a/test/libsolidity/semanticTests/various/memory_overwrite.sol b/test/libsolidity/semanticTests/various/memory_overwrite.sol index 028ee903b..930b06f4a 100644 --- a/test/libsolidity/semanticTests/various/memory_overwrite.sol +++ b/test/libsolidity/semanticTests/various/memory_overwrite.sol @@ -8,6 +8,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x20, 5, "b23a5" diff --git a/test/libsolidity/semanticTests/various/multi_modifiers.sol b/test/libsolidity/semanticTests/various/multi_modifiers.sol index 59cceb496..b6d8dd84c 100644 --- a/test/libsolidity/semanticTests/various/multi_modifiers.sol +++ b/test/libsolidity/semanticTests/various/multi_modifiers.sol @@ -17,7 +17,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f1() -> diff --git a/test/libsolidity/semanticTests/various/multi_variable_declaration.sol b/test/libsolidity/semanticTests/various/multi_variable_declaration.sol index 3f8e40cda..e054329c9 100644 --- a/test/libsolidity/semanticTests/various/multi_variable_declaration.sol +++ b/test/libsolidity/semanticTests/various/multi_variable_declaration.sol @@ -44,6 +44,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/various/nested_calldata_struct.sol b/test/libsolidity/semanticTests/various/nested_calldata_struct.sol index 4971352b3..8ba68599e 100644 --- a/test/libsolidity/semanticTests/various/nested_calldata_struct.sol +++ b/test/libsolidity/semanticTests/various/nested_calldata_struct.sol @@ -24,6 +24,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f((uint256,uint256,(uint256,uint256),uint256)): 1, 2, 3, 4, 5 -> 1, 2, 3, 4, 5 diff --git a/test/libsolidity/semanticTests/various/nested_calldata_struct_to_memory.sol b/test/libsolidity/semanticTests/various/nested_calldata_struct_to_memory.sol index 3e96f2a6f..595f88f54 100644 --- a/test/libsolidity/semanticTests/various/nested_calldata_struct_to_memory.sol +++ b/test/libsolidity/semanticTests/various/nested_calldata_struct_to_memory.sol @@ -23,7 +23,5 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f((uint256,uint256,(uint256,uint256),uint256)): 1, 2, 3, 4, 5 -> 1, 2, 3, 4, 5 diff --git a/test/libsolidity/semanticTests/various/positive_integers_to_signed.sol b/test/libsolidity/semanticTests/various/positive_integers_to_signed.sol index 56f072b2e..4c2356499 100644 --- a/test/libsolidity/semanticTests/various/positive_integers_to_signed.sol +++ b/test/libsolidity/semanticTests/various/positive_integers_to_signed.sol @@ -5,7 +5,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // x() -> 2 // y() -> 127 diff --git a/test/libsolidity/semanticTests/various/senders_balance.sol b/test/libsolidity/semanticTests/various/senders_balance.sol index 0e0e59996..8241ec554 100644 --- a/test/libsolidity/semanticTests/various/senders_balance.sol +++ b/test/libsolidity/semanticTests/various/senders_balance.sol @@ -15,11 +15,9 @@ contract D { } } -// ==== -// compileViaYul: also // ---- // constructor(), 27 wei -> -// gas irOptimized: 175157 +// gas irOptimized: 170627 // gas legacy: 222977 // gas legacyOptimized: 169779 // f() -> 27 diff --git a/test/libsolidity/semanticTests/various/single_copy_with_multiple_inheritance.sol b/test/libsolidity/semanticTests/various/single_copy_with_multiple_inheritance.sol index 68aac998e..c1dab1895 100644 --- a/test/libsolidity/semanticTests/various/single_copy_with_multiple_inheritance.sol +++ b/test/libsolidity/semanticTests/various/single_copy_with_multiple_inheritance.sol @@ -29,7 +29,6 @@ contract Derived is Base, B, A {} // ==== // compileToEwasm: also -// compileViaYul: also // ---- // getViaB() -> 0 // setViaA(uint256): 23 -> diff --git a/test/libsolidity/semanticTests/various/skip_dynamic_types.sol b/test/libsolidity/semanticTests/various/skip_dynamic_types.sol index a0231678f..186b162c2 100644 --- a/test/libsolidity/semanticTests/various/skip_dynamic_types.sol +++ b/test/libsolidity/semanticTests/various/skip_dynamic_types.sol @@ -10,7 +10,5 @@ contract C { return (a, b); } } -// ==== -// compileViaYul: also // ---- // g() -> 7, 8 diff --git a/test/libsolidity/semanticTests/various/skip_dynamic_types_for_static_arrays_with_dynamic_elements.sol b/test/libsolidity/semanticTests/various/skip_dynamic_types_for_static_arrays_with_dynamic_elements.sol index 65e0b4769..75fdb1e8d 100644 --- a/test/libsolidity/semanticTests/various/skip_dynamic_types_for_static_arrays_with_dynamic_elements.sol +++ b/test/libsolidity/semanticTests/various/skip_dynamic_types_for_static_arrays_with_dynamic_elements.sol @@ -19,7 +19,5 @@ contract C { return (a, b); } } -// ==== -// compileViaYul: also // ---- // g() -> 5, 6 diff --git a/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol b/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol index 971d83407..cd34a419d 100644 --- a/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol +++ b/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol @@ -18,10 +18,8 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // g() -> 2, 6 -// gas irOptimized: 178805 -// gas legacy: 180753 -// gas legacyOptimized: 179472 +// gas irOptimized: 178549 +// gas legacy: 180893 +// gas legacyOptimized: 179394 diff --git a/test/libsolidity/semanticTests/various/state_variable_local_variable_mixture.sol b/test/libsolidity/semanticTests/various/state_variable_local_variable_mixture.sol index 4cea04c96..d3203160a 100644 --- a/test/libsolidity/semanticTests/various/state_variable_local_variable_mixture.sol +++ b/test/libsolidity/semanticTests/various/state_variable_local_variable_mixture.sol @@ -8,6 +8,5 @@ contract A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // a() -> 2 diff --git a/test/libsolidity/semanticTests/various/state_variable_under_contract_name.sol b/test/libsolidity/semanticTests/various/state_variable_under_contract_name.sol index 53306c88b..e71d802fb 100644 --- a/test/libsolidity/semanticTests/various/state_variable_under_contract_name.sol +++ b/test/libsolidity/semanticTests/various/state_variable_under_contract_name.sol @@ -7,6 +7,5 @@ contract Scope { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // getStateVar() -> 42 diff --git a/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol b/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol index 90dd3a6f7..413e129ef 100644 --- a/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol +++ b/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol @@ -33,15 +33,14 @@ contract D { } // ==== // EVMVersion: >=byzantium -// compileViaYul: also // ---- // f() -> 0x1 # This should work, next should throw # // gas legacy: 103716 // fview() -> FAILURE -// gas irOptimized: 98438619 +// gas irOptimized: 98438605 // gas legacy: 98438801 // gas legacyOptimized: 98438594 // fpure() -> FAILURE -// gas irOptimized: 98438619 +// gas irOptimized: 98438605 // gas legacy: 98438801 // gas legacyOptimized: 98438595 diff --git a/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure_pre_byzantium.sol b/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure_pre_byzantium.sol index e9157e34c..a193e8752 100644 --- a/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure_pre_byzantium.sol +++ b/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure_pre_byzantium.sol @@ -32,7 +32,6 @@ contract D { } } // ==== -// compileViaYul: also // EVMVersion: 0x1 diff --git a/test/libsolidity/semanticTests/various/storage_string_as_mapping_key_without_variable.sol b/test/libsolidity/semanticTests/various/storage_string_as_mapping_key_without_variable.sol index d5f53c120..df3f97ebf 100644 --- a/test/libsolidity/semanticTests/various/storage_string_as_mapping_key_without_variable.sol +++ b/test/libsolidity/semanticTests/various/storage_string_as_mapping_key_without_variable.sol @@ -6,7 +6,5 @@ contract Test { return data["abc"]; } } -// ==== -// compileViaYul: also // ---- // f() -> 2 diff --git a/test/libsolidity/semanticTests/various/store_bytes.sol b/test/libsolidity/semanticTests/various/store_bytes.sol index 34c0b6f3d..4b92a251a 100644 --- a/test/libsolidity/semanticTests/various/store_bytes.sol +++ b/test/libsolidity/semanticTests/various/store_bytes.sol @@ -8,8 +8,6 @@ contract C { bytes savedData; } -// ==== -// compileViaYul: also // ---- // save() -> 24 # empty copy loop # // save(): "abcdefg" -> 24 diff --git a/test/libsolidity/semanticTests/various/string_tuples.sol b/test/libsolidity/semanticTests/various/string_tuples.sol index 4af1b83f3..935c0b3c2 100644 --- a/test/libsolidity/semanticTests/various/string_tuples.sol +++ b/test/libsolidity/semanticTests/various/string_tuples.sol @@ -13,7 +13,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x40, 0x8, 0x3, "abc" // g() -> 0x40, 0x80, 0x3, "abc", 0x3, "def" diff --git a/test/libsolidity/semanticTests/various/super.sol b/test/libsolidity/semanticTests/various/super.sol index e730a7966..9035f0ca2 100644 --- a/test/libsolidity/semanticTests/various/super.sol +++ b/test/libsolidity/semanticTests/various/super.sol @@ -27,6 +27,5 @@ contract D is B, C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 15 diff --git a/test/libsolidity/semanticTests/various/super_alone.sol b/test/libsolidity/semanticTests/various/super_alone.sol index 726b788ae..069df9a91 100644 --- a/test/libsolidity/semanticTests/various/super_alone.sol +++ b/test/libsolidity/semanticTests/various/super_alone.sol @@ -6,6 +6,5 @@ contract A { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> diff --git a/test/libsolidity/semanticTests/various/super_parentheses.sol b/test/libsolidity/semanticTests/various/super_parentheses.sol index 0f54acdcb..3c687d9c1 100644 --- a/test/libsolidity/semanticTests/various/super_parentheses.sol +++ b/test/libsolidity/semanticTests/various/super_parentheses.sol @@ -27,6 +27,5 @@ contract D is B, C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 15 diff --git a/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol b/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol index 9b7a4306f..129a78931 100644 --- a/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol +++ b/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol @@ -25,12 +25,11 @@ contract c { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // x() -> 0, 0 // y() -> 0, 0 // set() -> -// gas irOptimized: 109713 +// gas irOptimized: 109691 // gas legacy: 109732 // gas legacyOptimized: 109682 // x() -> 1, 2 diff --git a/test/libsolidity/semanticTests/various/test_underscore_in_hex.sol b/test/libsolidity/semanticTests/various/test_underscore_in_hex.sol index 05cb1d5d3..76c6828cd 100644 --- a/test/libsolidity/semanticTests/various/test_underscore_in_hex.sol +++ b/test/libsolidity/semanticTests/various/test_underscore_in_hex.sol @@ -7,7 +7,6 @@ contract test { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bool): true -> 0x1234ab // f(bool): false -> 0x1234abcd1234 diff --git a/test/libsolidity/semanticTests/various/tuples.sol b/test/libsolidity/semanticTests/various/tuples.sol index b89928a72..458007595 100644 --- a/test/libsolidity/semanticTests/various/tuples.sol +++ b/test/libsolidity/semanticTests/various/tuples.sol @@ -25,7 +25,5 @@ contract C { if (a != 8 || b != 10) return 4; } } -// ==== -// compileViaYul: also // ---- // f() -> 0 diff --git a/test/libsolidity/semanticTests/various/typed_multi_variable_declaration.sol b/test/libsolidity/semanticTests/various/typed_multi_variable_declaration.sol index 2836953dc..018ee9669 100644 --- a/test/libsolidity/semanticTests/various/typed_multi_variable_declaration.sol +++ b/test/libsolidity/semanticTests/various/typed_multi_variable_declaration.sol @@ -24,6 +24,5 @@ contract C { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/various/value_complex.sol b/test/libsolidity/semanticTests/various/value_complex.sol index c868652a0..6f57e9e32 100644 --- a/test/libsolidity/semanticTests/various/value_complex.sol +++ b/test/libsolidity/semanticTests/various/value_complex.sol @@ -18,11 +18,9 @@ contract test { } } -// ==== -// compileViaYul: also // ---- // constructor(), 20 wei -> -// gas irOptimized: 190275 -// gas legacy: 265006 -// gas legacyOptimized: 182842 +// gas irOptimized: 176003 +// gas legacy: 257656 +// gas legacyOptimized: 183070 // sendAmount(uint256): 5 -> 8 diff --git a/test/libsolidity/semanticTests/various/value_insane.sol b/test/libsolidity/semanticTests/various/value_insane.sol index c304732bb..8aba90d96 100644 --- a/test/libsolidity/semanticTests/various/value_insane.sol +++ b/test/libsolidity/semanticTests/various/value_insane.sol @@ -17,11 +17,9 @@ contract test { } } -// ==== -// compileViaYul: also // ---- // constructor(), 20 wei -> -// gas irOptimized: 191991 -// gas legacy: 266728 -// gas legacyOptimized: 184762 +// gas irOptimized: 176867 +// gas legacy: 259378 +// gas legacyOptimized: 183682 // sendAmount(uint256): 5 -> 8 diff --git a/test/libsolidity/semanticTests/various/write_storage_external.sol b/test/libsolidity/semanticTests/various/write_storage_external.sol index 7ed94b6f8..0bbe52248 100644 --- a/test/libsolidity/semanticTests/various/write_storage_external.sol +++ b/test/libsolidity/semanticTests/various/write_storage_external.sol @@ -34,8 +34,6 @@ contract D { } } -// ==== -// compileViaYul: also // ---- // f() -> 3 // g() -> 8 diff --git a/test/libsolidity/semanticTests/viaYul/array_2d_assignment.sol b/test/libsolidity/semanticTests/viaYul/array_2d_assignment.sol index ff9c03cbe..9a4093c38 100644 --- a/test/libsolidity/semanticTests/viaYul/array_2d_assignment.sol +++ b/test/libsolidity/semanticTests/viaYul/array_2d_assignment.sol @@ -8,7 +8,5 @@ contract C { return b[1]; } } -// ==== -// compileViaYul: also // ---- // f(uint256): 42 -> 42 diff --git a/test/libsolidity/semanticTests/viaYul/array_2d_new.sol b/test/libsolidity/semanticTests/viaYul/array_2d_new.sol index bfc8b2013..13c0ac201 100644 --- a/test/libsolidity/semanticTests/viaYul/array_2d_new.sol +++ b/test/libsolidity/semanticTests/viaYul/array_2d_new.sol @@ -6,7 +6,5 @@ contract C { return a[0][0] = n; } } -// ==== -// compileViaYul: also // ---- // f(uint256): 42 -> 42 diff --git a/test/libsolidity/semanticTests/viaYul/array_3d_assignment.sol b/test/libsolidity/semanticTests/viaYul/array_3d_assignment.sol index a2b3de54f..f987a17de 100644 --- a/test/libsolidity/semanticTests/viaYul/array_3d_assignment.sol +++ b/test/libsolidity/semanticTests/viaYul/array_3d_assignment.sol @@ -13,7 +13,5 @@ contract C { return c[1]; } } -// ==== -// compileViaYul: also // ---- // f(uint256): 42 -> 42 diff --git a/test/libsolidity/semanticTests/viaYul/array_3d_new.sol b/test/libsolidity/semanticTests/viaYul/array_3d_new.sol index c3ff22ca3..b4bb4e626 100644 --- a/test/libsolidity/semanticTests/viaYul/array_3d_new.sol +++ b/test/libsolidity/semanticTests/viaYul/array_3d_new.sol @@ -10,7 +10,5 @@ contract C { return a[1][1][1] = n; } } -// ==== -// compileViaYul: also // ---- // f(uint256): 42 -> 42 diff --git a/test/libsolidity/semanticTests/viaYul/array_function_pointers.sol b/test/libsolidity/semanticTests/viaYul/array_function_pointers.sol index 32fed9a23..5d4707ec3 100644 --- a/test/libsolidity/semanticTests/viaYul/array_function_pointers.sol +++ b/test/libsolidity/semanticTests/viaYul/array_function_pointers.sol @@ -20,8 +20,6 @@ contract C { arr[a][b](); } } -// ==== -// compileViaYul: also // ---- // f(uint256,uint256): 1823621, 12323 -> FAILURE # Out of gas # // f2(uint256,uint256,uint256,uint256): 18723921, 1823621, 123, 12323 -> FAILURE # Out of gas # diff --git a/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_2d_zeroed_memory_index_access.sol b/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_2d_zeroed_memory_index_access.sol index 45e567e1d..683eca903 100644 --- a/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_2d_zeroed_memory_index_access.sol +++ b/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_2d_zeroed_memory_index_access.sol @@ -15,8 +15,6 @@ contract C { return x[a][b]; } } -// ==== -// compileViaYul: also // ---- // set(string,uint256,uint256,uint256,uint256): 0xa0, 2, 4, 0, 0, 32, "01234567890123456789012345678901" -> 0 // set(string,uint256,uint256,uint256,uint256): 0xa0, 2, 4, 1, 3, 32, "01234567890123456789012345678901" -> 0 diff --git a/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_array_static.sol b/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_array_static.sol index 8678e1aa3..6113cfeef 100644 --- a/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_array_static.sol +++ b/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_array_static.sol @@ -13,8 +13,6 @@ contract C { return x[m][0]; } } -// ==== -// compileViaYul: also // ---- // set(string,uint256,uint256): 0x60, 2, 0, 32, "01234567890123456789012345678901" -> 0 // set(string,uint256,uint256): 0x60, 2, 1, 32, "01234567890123456789012345678901" -> 0 diff --git a/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_static_return_param_zeroed_memory_index_access.sol b/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_static_return_param_zeroed_memory_index_access.sol index 31dd0a66a..13af18a5e 100644 --- a/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_static_return_param_zeroed_memory_index_access.sol +++ b/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_static_return_param_zeroed_memory_index_access.sol @@ -11,7 +11,5 @@ contract C { map[s] = 0; } } -// ==== -// compileViaYul: also // ---- // set(string): 0x20, 32, "01234567890123456789012345678901" -> 0, 0, 0, 0, 0, 0xe0, 0, 0 diff --git a/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_static_zeroed_memory_index_access.sol b/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_static_zeroed_memory_index_access.sol index 6cf73bd8e..eddf0e720 100644 --- a/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_static_zeroed_memory_index_access.sol +++ b/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_static_zeroed_memory_index_access.sol @@ -13,7 +13,5 @@ contract C { return x[2]; } } -// ==== -// compileViaYul: also // ---- // set(string): 0x20, 32, "01234567890123456789012345678901" -> 0 diff --git a/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_zeroed_memory_index_access.sol b/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_zeroed_memory_index_access.sol index 76a412adf..5eeaad7db 100644 --- a/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_zeroed_memory_index_access.sol +++ b/test/libsolidity/semanticTests/viaYul/array_memory_allocation/array_zeroed_memory_index_access.sol @@ -13,8 +13,6 @@ contract C { return x[a]; } } -// ==== -// compileViaYul: also // ---- // set(string,uint256,uint256): 0x60, 5, 0, 32, "01234567890123456789012345678901" -> 0 // set(string,uint256,uint256): 0x60, 5, 1, 32, "01234567890123456789012345678901" -> 0 diff --git a/test/libsolidity/semanticTests/viaYul/array_memory_as_parameter.sol b/test/libsolidity/semanticTests/viaYul/array_memory_as_parameter.sol index 55e10487e..151fe0894 100644 --- a/test/libsolidity/semanticTests/viaYul/array_memory_as_parameter.sol +++ b/test/libsolidity/semanticTests/viaYul/array_memory_as_parameter.sol @@ -17,8 +17,6 @@ contract C { return array[idx]; } } -// ==== -// compileViaYul: also // ---- // test(uint256,uint256): 0, 0 -> FAILURE, hex"4e487b71", 0x32 // test(uint256,uint256): 1, 0 -> 1 diff --git a/test/libsolidity/semanticTests/viaYul/array_memory_create.sol b/test/libsolidity/semanticTests/viaYul/array_memory_create.sol index d1a9c5e2e..91e72bc9a 100644 --- a/test/libsolidity/semanticTests/viaYul/array_memory_create.sol +++ b/test/libsolidity/semanticTests/viaYul/array_memory_create.sol @@ -5,8 +5,6 @@ contract C { return array.length; } } -// ==== -// compileViaYul: also // ---- // create(uint256): 0 -> 0 // create(uint256): 7 -> 7 diff --git a/test/libsolidity/semanticTests/viaYul/array_memory_index_access.sol b/test/libsolidity/semanticTests/viaYul/array_memory_index_access.sol index 5bd5fe137..d8cad3e8d 100644 --- a/test/libsolidity/semanticTests/viaYul/array_memory_index_access.sol +++ b/test/libsolidity/semanticTests/viaYul/array_memory_index_access.sol @@ -21,16 +21,14 @@ contract C { return array[uint256(idx)]; } } -// ==== -// compileViaYul: also // ---- // index(uint256): 0 -> true // index(uint256): 10 -> true // index(uint256): 20 -> true // index(uint256): 0xFF -> true -// gas irOptimized: 137634 -// gas legacy: 247324 -// gas legacyOptimized: 149578 +// gas irOptimized: 135584 +// gas legacy: 244264 +// gas legacyOptimized: 152128 // accessIndex(uint256,int256): 10, 1 -> 2 // accessIndex(uint256,int256): 10, 0 -> 1 // accessIndex(uint256,int256): 10, 11 -> FAILURE, hex"4e487b71", 0x32 diff --git a/test/libsolidity/semanticTests/viaYul/array_push_return_reference.sol b/test/libsolidity/semanticTests/viaYul/array_push_return_reference.sol index d83fd53ef..a7e5454bd 100644 --- a/test/libsolidity/semanticTests/viaYul/array_push_return_reference.sol +++ b/test/libsolidity/semanticTests/viaYul/array_push_return_reference.sol @@ -10,8 +10,6 @@ contract C { return storageArray[a]; } } -// ==== -// compileViaYul: also // ---- // getLength() -> 0 // test(uint256): 42 -> diff --git a/test/libsolidity/semanticTests/viaYul/array_push_with_arg.sol b/test/libsolidity/semanticTests/viaYul/array_push_with_arg.sol index a93778b3f..b143c199a 100644 --- a/test/libsolidity/semanticTests/viaYul/array_push_with_arg.sol +++ b/test/libsolidity/semanticTests/viaYul/array_push_with_arg.sol @@ -10,8 +10,6 @@ contract C { return storageArray[a]; } } -// ==== -// compileViaYul: also // ---- // getLength() -> 0 // test(uint256): 42 -> diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol b/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol index 31cf4ad69..8ef60a53b 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol @@ -13,38 +13,36 @@ contract C { require(storageArray[i] == i + 1); } } -// ==== -// compileViaYul: also // ---- // test_indices(uint256): 1 -> // test_indices(uint256): 129 -> -// gas irOptimized: 3032985 -// gas legacy: 3070431 -// gas legacyOptimized: 3010325 +// gas irOptimized: 3018684 +// gas legacy: 3068883 +// gas legacyOptimized: 3011615 // test_indices(uint256): 5 -> -// gas irOptimized: 367641 -// gas legacy: 369211 -// gas legacyOptimized: 366089 +// gas irOptimized: 372540 +// gas legacy: 369151 +// gas legacyOptimized: 366139 // test_indices(uint256): 10 -> // test_indices(uint256): 15 -> // gas irOptimized: 72860 // test_indices(uint256): 0xFF -> -// gas irOptimized: 3438609 -// gas legacy: 3512637 -// gas legacyOptimized: 3395047 +// gas irOptimized: 3410252 +// gas legacy: 3509577 +// gas legacyOptimized: 3397597 // test_indices(uint256): 1000 -> -// gas irOptimized: 18318371 -// gas legacy: 18611999 -// gas legacyOptimized: 18166944 +// gas irOptimized: 18206119 +// gas legacy: 18599999 +// gas legacyOptimized: 18176944 // test_indices(uint256): 129 -> -// gas irOptimized: 2733569 -// gas legacy: 2771961 -// gas legacyOptimized: 2714999 +// gas irOptimized: 2756952 +// gas legacy: 2770413 +// gas legacyOptimized: 2716289 // test_indices(uint256): 128 -> -// gas irOptimized: 426681 -// gas legacy: 466504 -// gas legacyOptimized: 416888 +// gas irOptimized: 411900 +// gas legacy: 464968 +// gas legacyOptimized: 418168 // test_indices(uint256): 1 -> -// gas irOptimized: 363073 -// gas legacy: 363401 -// gas legacyOptimized: 361799 +// gas irOptimized: 368568 +// gas legacy: 363389 +// gas legacyOptimized: 361809 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_index_boundary_test.sol b/test/libsolidity/semanticTests/viaYul/array_storage_index_boundary_test.sol index ea64676a8..e4e69ffa3 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_index_boundary_test.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_index_boundary_test.sol @@ -9,8 +9,6 @@ contract C { return storageArray[access]; } } -// ==== -// compileViaYul: also // ---- // test_boundary_check(uint256,uint256): 10, 11 -> FAILURE, hex"4e487b71", 0x32 // test_boundary_check(uint256,uint256): 10, 9 -> 0 @@ -18,11 +16,11 @@ contract C { // test_boundary_check(uint256,uint256): 1, 1 -> FAILURE, hex"4e487b71", 0x32 // test_boundary_check(uint256,uint256): 10, 10 -> FAILURE, hex"4e487b71", 0x32 // test_boundary_check(uint256,uint256): 256, 256 -> FAILURE, hex"4e487b71", 0x32 -// gas irOptimized: 137834 +// gas irOptimized: 137831 // gas legacy: 131830 // gas legacyOptimized: 112054 // test_boundary_check(uint256,uint256): 256, 255 -> 0 -// gas irOptimized: 140017 +// gas irOptimized: 139963 // gas legacy: 134149 // gas legacyOptimized: 114233 // test_boundary_check(uint256,uint256): 256, 0xFFFF -> FAILURE, hex"4e487b71", 0x32 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol b/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol index 26c0d8394..b1bcd8273 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol @@ -49,23 +49,21 @@ contract C { } } } -// ==== -// compileViaYul: also // ---- // test_zeroed_indicies(uint256): 1 -> // test_zeroed_indicies(uint256): 5 -> -// gas irOptimized: 131192 -// gas legacy: 132331 -// gas legacyOptimized: 129514 +// gas irOptimized: 131174 +// gas legacy: 132301 +// gas legacyOptimized: 129539 // test_zeroed_indicies(uint256): 10 -> -// gas irOptimized: 174810 -// gas legacy: 177248 -// gas legacyOptimized: 172062 +// gas irOptimized: 174777 +// gas legacy: 177188 +// gas legacyOptimized: 172112 // test_zeroed_indicies(uint256): 15 -> -// gas irOptimized: 198070 -// gas legacy: 201828 -// gas legacyOptimized: 194352 +// gas irOptimized: 198022 +// gas legacy: 201738 +// gas legacyOptimized: 194427 // test_zeroed_indicies(uint256): 0xFF -> -// gas irOptimized: 6098680 -// gas legacy: 6160863 -// gas legacyOptimized: 6024902 +// gas irOptimized: 6097912 +// gas legacy: 6159333 +// gas legacyOptimized: 6026177 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_length_access.sol b/test/libsolidity/semanticTests/viaYul/array_storage_length_access.sol index 1c3f8410c..5febab1c6 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_length_access.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_length_access.sol @@ -6,8 +6,6 @@ contract C { return storageArray.length; } } -// ==== -// compileViaYul: also // ---- // set_get_length(uint256): 0 -> 0 // set_get_length(uint256): 1 -> 1 @@ -18,7 +16,7 @@ contract C { // gas legacy: 126722 // gas legacyOptimized: 107818 // set_get_length(uint256): 0xFFF -> 0xFFF -// gas irOptimized: 1217851 +// gas irOptimized: 1217848 // gas legacy: 1702119 // gas legacyOptimized: 1398420 // set_get_length(uint256): 0xFFFFF -> FAILURE # Out-of-gas # diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_pop_zero_length.sol b/test/libsolidity/semanticTests/viaYul/array_storage_pop_zero_length.sol index 2a09ba31e..ed946e197 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_pop_zero_length.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_pop_zero_length.sol @@ -6,6 +6,5 @@ contract C { } // ==== // EVMVersion: >=petersburg -// compileViaYul: also // ---- // popEmpty() -> FAILURE, hex"4e487b71", 0x31 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol b/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol index 6e126a150..270b92ffa 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol @@ -10,14 +10,13 @@ contract C { } // ==== // EVMVersion: >=petersburg -// compileViaYul: also // ---- // pushEmpty(uint256): 128 -// gas irOptimized: 412561 +// gas irOptimized: 406798 // gas legacy: 416903 // gas legacyOptimized: 398280 // pushEmpty(uint256): 256 -// gas irOptimized: 702549 +// gas irOptimized: 691026 // gas legacy: 714315 // gas legacyOptimized: 687372 // pushEmpty(uint256): 38869 -> FAILURE # out-of-gas # diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_push_empty_length_address.sol b/test/libsolidity/semanticTests/viaYul/array_storage_push_empty_length_address.sol index cb23435d1..c7561ba7a 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_push_empty_length_address.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_push_empty_length_address.sol @@ -11,7 +11,6 @@ contract C { } // ==== // EVMVersion: >=petersburg -// compileViaYul: also // ---- // set_get_length(uint256): 0 -> 0 // set_get_length(uint256): 1 -> 1 @@ -22,11 +21,11 @@ contract C { // gas legacy: 77730 // gas legacyOptimized: 77162 // set_get_length(uint256): 0xFF -> 0xFF -// gas irOptimized: 141799 +// gas irOptimized: 141796 // gas legacy: 678237 // gas legacyOptimized: 115104 // set_get_length(uint256): 0xFFF -> 0xFFF -// gas irOptimized: 1801666 +// gas irOptimized: 1801663 // gas legacy: 9873774 // gas legacyOptimized: 1398546 // set_get_length(uint256): 0xFFFFF -> FAILURE # Out-of-gas # diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_push_pop.sol b/test/libsolidity/semanticTests/viaYul/array_storage_push_pop.sol index 25a2f5f9a..45c6a9fa3 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_push_pop.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_push_pop.sol @@ -8,8 +8,6 @@ contract C { return storageArray.length; } } -// ==== -// compileViaYul: also // ---- // set_get_length(uint256): 0 -> 0 // set_get_length(uint256): 1 -> 0 @@ -19,11 +17,11 @@ contract C { // gas legacy: 85822 // gas legacyOptimized: 83608 // set_get_length(uint256): 0xFF -> 0 -// gas irOptimized: 821875 +// gas irOptimized: 821872 // gas legacy: 810327 // gas legacyOptimized: 786258 // set_get_length(uint256): 0xFFF -> 0 -// gas irOptimized: 12841087 +// gas irOptimized: 12841084 // gas legacy: 12649059 // gas legacyOptimized: 12267870 // set_get_length(uint256): 0xFFFF -> FAILURE # Out-of-gas # diff --git a/test/libsolidity/semanticTests/viaYul/assert.sol b/test/libsolidity/semanticTests/viaYul/assert.sol index f7b2c3c3c..aa8de1c27 100644 --- a/test/libsolidity/semanticTests/viaYul/assert.sol +++ b/test/libsolidity/semanticTests/viaYul/assert.sol @@ -15,7 +15,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bool): true -> true // f(bool): false -> FAILURE, hex"4e487b71", 0x01 diff --git a/test/libsolidity/semanticTests/viaYul/assert_and_require.sol b/test/libsolidity/semanticTests/viaYul/assert_and_require.sol index b163097e8..290ef35b3 100644 --- a/test/libsolidity/semanticTests/viaYul/assert_and_require.sol +++ b/test/libsolidity/semanticTests/viaYul/assert_and_require.sol @@ -12,7 +12,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bool): true -> true // f(bool): false -> FAILURE, hex"4e487b71", 0x01 diff --git a/test/libsolidity/semanticTests/viaYul/assign_tuple_from_function_call.sol b/test/libsolidity/semanticTests/viaYul/assign_tuple_from_function_call.sol index c371f8371..c36cc26dc 100644 --- a/test/libsolidity/semanticTests/viaYul/assign_tuple_from_function_call.sol +++ b/test/libsolidity/semanticTests/viaYul/assign_tuple_from_function_call.sol @@ -11,7 +11,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 3, 2, 1 // h() -> 3 diff --git a/test/libsolidity/semanticTests/viaYul/calldata_array_access.sol b/test/libsolidity/semanticTests/viaYul/calldata_array_access.sol index f8ad6b9ec..6dedc2a7f 100644 --- a/test/libsolidity/semanticTests/viaYul/calldata_array_access.sol +++ b/test/libsolidity/semanticTests/viaYul/calldata_array_access.sol @@ -7,8 +7,6 @@ contract C { return x[i][j]; } } -// ==== -// compileViaYul: also // ---- // f(uint256[],uint256): 0x40, 0, 0 -> FAILURE, hex"4e487b71", 0x32 // f(uint256[],uint256): 0x40, 0, 1, 23 -> 23 diff --git a/test/libsolidity/semanticTests/viaYul/calldata_array_index_range_access.sol b/test/libsolidity/semanticTests/viaYul/calldata_array_index_range_access.sol index 60ea3a8dd..610135968 100644 --- a/test/libsolidity/semanticTests/viaYul/calldata_array_index_range_access.sol +++ b/test/libsolidity/semanticTests/viaYul/calldata_array_index_range_access.sol @@ -27,7 +27,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256[],uint256,uint256): 0x60, 2, 4, 5, 1, 2, 3, 4, 5 -> 2 // f(uint256[],uint256,uint256): 0x60, 2, 6, 5, 1, 2, 3, 4, 5 -> FAILURE diff --git a/test/libsolidity/semanticTests/viaYul/calldata_array_length.sol b/test/libsolidity/semanticTests/viaYul/calldata_array_length.sol index 5f7d9bbb8..779d261a0 100644 --- a/test/libsolidity/semanticTests/viaYul/calldata_array_length.sol +++ b/test/libsolidity/semanticTests/viaYul/calldata_array_length.sol @@ -12,8 +12,6 @@ contract C { return x.length; } } -// ==== -// compileViaYul: also // ---- // f(uint256[]): 0x20, 0 -> 0 // f(uint256[]): 0x20, 1, 23 -> 1 diff --git a/test/libsolidity/semanticTests/viaYul/calldata_array_three_dimensional.sol b/test/libsolidity/semanticTests/viaYul/calldata_array_three_dimensional.sol index 37bb54058..826c5f723 100644 --- a/test/libsolidity/semanticTests/viaYul/calldata_array_three_dimensional.sol +++ b/test/libsolidity/semanticTests/viaYul/calldata_array_three_dimensional.sol @@ -10,7 +10,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256[][2][],uint256,uint256,uint256): 0x80, 0, 0, 0, 1, 0x20, 0x40, 0x80, 1, 42, 1, 23 -> 1, 2, 1, 42 // f(uint256[][2][],uint256,uint256,uint256): 0x80, 0, 1, 0, 1, 0x20, 0x40, 0x80, 1, 42, 1, 23 -> 1, 2, 1, 23 diff --git a/test/libsolidity/semanticTests/viaYul/calldata_bytes_array_bounds.sol b/test/libsolidity/semanticTests/viaYul/calldata_bytes_array_bounds.sol index 6bd1acbbf..eb19897cc 100644 --- a/test/libsolidity/semanticTests/viaYul/calldata_bytes_array_bounds.sol +++ b/test/libsolidity/semanticTests/viaYul/calldata_bytes_array_bounds.sol @@ -4,8 +4,6 @@ contract C { return uint8(a[0][i]); } } -// ==== -// compileViaYul: also // ---- // f(bytes[],uint256): 0x40, 0, 1, 0x20, 2, hex"6162" -> 0x61 // f(bytes[],uint256): 0x40, 1, 1, 0x20, 2, hex"6162" -> 0x62 diff --git a/test/libsolidity/semanticTests/viaYul/cleanup/comparison.sol b/test/libsolidity/semanticTests/viaYul/cleanup/comparison.sol index 1ac815ea3..ab3d92a18 100644 --- a/test/libsolidity/semanticTests/viaYul/cleanup/comparison.sol +++ b/test/libsolidity/semanticTests/viaYul/cleanup/comparison.sol @@ -32,7 +32,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // eq() -> true // neq() -> false diff --git a/test/libsolidity/semanticTests/viaYul/comparison.sol b/test/libsolidity/semanticTests/viaYul/comparison.sol index d84b2dd6f..0b0763b6e 100644 --- a/test/libsolidity/semanticTests/viaYul/comparison.sol +++ b/test/libsolidity/semanticTests/viaYul/comparison.sol @@ -37,7 +37,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(address): 0x1234 -> false diff --git a/test/libsolidity/semanticTests/viaYul/comparison_functions.sol b/test/libsolidity/semanticTests/viaYul/comparison_functions.sol index d039f4282..89d90e577 100644 --- a/test/libsolidity/semanticTests/viaYul/comparison_functions.sol +++ b/test/libsolidity/semanticTests/viaYul/comparison_functions.sol @@ -26,7 +26,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // equal() -> true, false, false // unequal() -> false, true, true diff --git a/test/libsolidity/semanticTests/viaYul/conditional/conditional_multiple.sol b/test/libsolidity/semanticTests/viaYul/conditional/conditional_multiple.sol index 5009b01e9..9e1e8c778 100644 --- a/test/libsolidity/semanticTests/viaYul/conditional/conditional_multiple.sol +++ b/test/libsolidity/semanticTests/viaYul/conditional/conditional_multiple.sol @@ -6,6 +6,5 @@ contract A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 7 diff --git a/test/libsolidity/semanticTests/viaYul/conditional/conditional_true_false_literal.sol b/test/libsolidity/semanticTests/viaYul/conditional/conditional_true_false_literal.sol index e80355f39..3eda8bfc7 100644 --- a/test/libsolidity/semanticTests/viaYul/conditional/conditional_true_false_literal.sol +++ b/test/libsolidity/semanticTests/viaYul/conditional/conditional_true_false_literal.sol @@ -7,6 +7,5 @@ contract A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 2 diff --git a/test/libsolidity/semanticTests/viaYul/conditional/conditional_tuple.sol b/test/libsolidity/semanticTests/viaYul/conditional/conditional_tuple.sol index 257b24360..a0b206a12 100644 --- a/test/libsolidity/semanticTests/viaYul/conditional/conditional_tuple.sol +++ b/test/libsolidity/semanticTests/viaYul/conditional/conditional_tuple.sol @@ -6,7 +6,6 @@ contract A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bool): true -> 1, 2 // f(bool): false -> 3, 4 diff --git a/test/libsolidity/semanticTests/viaYul/conditional/conditional_with_assignment.sol b/test/libsolidity/semanticTests/viaYul/conditional/conditional_with_assignment.sol index 7ab894a60..a132e8873 100644 --- a/test/libsolidity/semanticTests/viaYul/conditional/conditional_with_assignment.sol +++ b/test/libsolidity/semanticTests/viaYul/conditional/conditional_with_assignment.sol @@ -9,6 +9,5 @@ contract A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 6, 1, 5, 5 diff --git a/test/libsolidity/semanticTests/viaYul/conditional/conditional_with_variables.sol b/test/libsolidity/semanticTests/viaYul/conditional/conditional_with_variables.sol index 260f4d688..c5bf8e018 100644 --- a/test/libsolidity/semanticTests/viaYul/conditional/conditional_with_variables.sol +++ b/test/libsolidity/semanticTests/viaYul/conditional/conditional_with_variables.sol @@ -9,6 +9,5 @@ contract A { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 3, 1, 3, 1 diff --git a/test/libsolidity/semanticTests/viaYul/conversion/explicit_cast_assignment.sol b/test/libsolidity/semanticTests/viaYul/conversion/explicit_cast_assignment.sol index 150bdcc2e..5d0d50dad 100644 --- a/test/libsolidity/semanticTests/viaYul/conversion/explicit_cast_assignment.sol +++ b/test/libsolidity/semanticTests/viaYul/conversion/explicit_cast_assignment.sol @@ -6,6 +6,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x78 diff --git a/test/libsolidity/semanticTests/viaYul/conversion/explicit_cast_function_call.sol b/test/libsolidity/semanticTests/viaYul/conversion/explicit_cast_function_call.sol index 0e41b2a93..34cc69ffe 100644 --- a/test/libsolidity/semanticTests/viaYul/conversion/explicit_cast_function_call.sol +++ b/test/libsolidity/semanticTests/viaYul/conversion/explicit_cast_function_call.sol @@ -8,6 +8,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 0x1234567800000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/viaYul/conversion/explicit_cast_local_assignment.sol b/test/libsolidity/semanticTests/viaYul/conversion/explicit_cast_local_assignment.sol index 63f6cb895..fe07146e1 100644 --- a/test/libsolidity/semanticTests/viaYul/conversion/explicit_cast_local_assignment.sol +++ b/test/libsolidity/semanticTests/viaYul/conversion/explicit_cast_local_assignment.sol @@ -6,6 +6,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 0x12345678 -> 0x78 diff --git a/test/libsolidity/semanticTests/viaYul/conversion/explicit_string_bytes_calldata_cast.sol b/test/libsolidity/semanticTests/viaYul/conversion/explicit_string_bytes_calldata_cast.sol index 4a5b01d39..46d4492e9 100644 --- a/test/libsolidity/semanticTests/viaYul/conversion/explicit_string_bytes_calldata_cast.sol +++ b/test/libsolidity/semanticTests/viaYul/conversion/explicit_string_bytes_calldata_cast.sol @@ -5,7 +5,5 @@ contract C { return string(test); } } -// ==== -// compileViaYul: also // ---- // f(string): 0x20, 3, "123" -> 0x20, 3, "123" diff --git a/test/libsolidity/semanticTests/viaYul/conversion/function_cast.sol b/test/libsolidity/semanticTests/viaYul/conversion/function_cast.sol index 08462c5f8..0d9eb6cae 100644 --- a/test/libsolidity/semanticTests/viaYul/conversion/function_cast.sol +++ b/test/libsolidity/semanticTests/viaYul/conversion/function_cast.sol @@ -15,8 +15,6 @@ contract C { b = this.f; } } -// ==== -// compileViaYul: also // ---- // f(uint256): 2 -> 4 // h(uint256): 2 -> 5 diff --git a/test/libsolidity/semanticTests/viaYul/conversion/implicit_cast_assignment.sol b/test/libsolidity/semanticTests/viaYul/conversion/implicit_cast_assignment.sol index 641d074b1..05d265343 100644 --- a/test/libsolidity/semanticTests/viaYul/conversion/implicit_cast_assignment.sol +++ b/test/libsolidity/semanticTests/viaYul/conversion/implicit_cast_assignment.sol @@ -10,6 +10,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x78 diff --git a/test/libsolidity/semanticTests/viaYul/conversion/implicit_cast_function_call.sol b/test/libsolidity/semanticTests/viaYul/conversion/implicit_cast_function_call.sol index f619355d1..a2c2d9207 100644 --- a/test/libsolidity/semanticTests/viaYul/conversion/implicit_cast_function_call.sol +++ b/test/libsolidity/semanticTests/viaYul/conversion/implicit_cast_function_call.sol @@ -13,6 +13,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 0x78 diff --git a/test/libsolidity/semanticTests/viaYul/conversion/implicit_cast_local_assignment.sol b/test/libsolidity/semanticTests/viaYul/conversion/implicit_cast_local_assignment.sol index dd1d869c7..e582ff394 100644 --- a/test/libsolidity/semanticTests/viaYul/conversion/implicit_cast_local_assignment.sol +++ b/test/libsolidity/semanticTests/viaYul/conversion/implicit_cast_local_assignment.sol @@ -9,6 +9,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0x78 diff --git a/test/libsolidity/semanticTests/viaYul/copy_struct_invalid_ir_bug.sol b/test/libsolidity/semanticTests/viaYul/copy_struct_invalid_ir_bug.sol index f1a6f592b..502e4bde1 100644 --- a/test/libsolidity/semanticTests/viaYul/copy_struct_invalid_ir_bug.sol +++ b/test/libsolidity/semanticTests/viaYul/copy_struct_invalid_ir_bug.sol @@ -19,10 +19,8 @@ contract C { assert(externalCalled == 2); } } -// ==== -// compileViaYul: also // ---- // f() -> -// gas irOptimized: 112992 +// gas irOptimized: 113019 // gas legacy: 112931 // gas legacyOptimized: 112602 diff --git a/test/libsolidity/semanticTests/viaYul/define_tuple_from_function_call.sol b/test/libsolidity/semanticTests/viaYul/define_tuple_from_function_call.sol index 1030748db..24c72943f 100644 --- a/test/libsolidity/semanticTests/viaYul/define_tuple_from_function_call.sol +++ b/test/libsolidity/semanticTests/viaYul/define_tuple_from_function_call.sol @@ -13,7 +13,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 3, 2, 1 // h() -> 3 diff --git a/test/libsolidity/semanticTests/viaYul/delete.sol b/test/libsolidity/semanticTests/viaYul/delete.sol index 90d3660bb..3439bc4df 100644 --- a/test/libsolidity/semanticTests/viaYul/delete.sol +++ b/test/libsolidity/semanticTests/viaYul/delete.sol @@ -20,7 +20,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // call_deleted_internal_func() -> FAILURE, hex"4e487b71", 0x51 // call_internal_func() -> true diff --git a/test/libsolidity/semanticTests/viaYul/detect_add_overflow.sol b/test/libsolidity/semanticTests/viaYul/detect_add_overflow.sol index 0d0661221..6e6f108a6 100644 --- a/test/libsolidity/semanticTests/viaYul/detect_add_overflow.sol +++ b/test/libsolidity/semanticTests/viaYul/detect_add_overflow.sol @@ -7,7 +7,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(uint256,uint256): 5, 6 -> 11 diff --git a/test/libsolidity/semanticTests/viaYul/detect_add_overflow_signed.sol b/test/libsolidity/semanticTests/viaYul/detect_add_overflow_signed.sol index e3fc39461..0e7d2db37 100644 --- a/test/libsolidity/semanticTests/viaYul/detect_add_overflow_signed.sol +++ b/test/libsolidity/semanticTests/viaYul/detect_add_overflow_signed.sol @@ -7,7 +7,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(int256,int256): 5, 6 -> 11 diff --git a/test/libsolidity/semanticTests/viaYul/detect_div_overflow.sol b/test/libsolidity/semanticTests/viaYul/detect_div_overflow.sol index 54f291e6f..ab3d97f46 100644 --- a/test/libsolidity/semanticTests/viaYul/detect_div_overflow.sol +++ b/test/libsolidity/semanticTests/viaYul/detect_div_overflow.sol @@ -10,7 +10,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(uint256,uint256): 10, 3 -> 3 diff --git a/test/libsolidity/semanticTests/viaYul/detect_mod_zero.sol b/test/libsolidity/semanticTests/viaYul/detect_mod_zero.sol index 5a4f2d822..5307f9589 100644 --- a/test/libsolidity/semanticTests/viaYul/detect_mod_zero.sol +++ b/test/libsolidity/semanticTests/viaYul/detect_mod_zero.sol @@ -8,7 +8,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256,uint256): 10, 3 -> 1 // f(uint256,uint256): 10, 2 -> 0 diff --git a/test/libsolidity/semanticTests/viaYul/detect_mod_zero_signed.sol b/test/libsolidity/semanticTests/viaYul/detect_mod_zero_signed.sol index 8277a557e..102df82f3 100644 --- a/test/libsolidity/semanticTests/viaYul/detect_mod_zero_signed.sol +++ b/test/libsolidity/semanticTests/viaYul/detect_mod_zero_signed.sol @@ -7,7 +7,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(int256,int256): 10, 3 -> 1 diff --git a/test/libsolidity/semanticTests/viaYul/detect_mul_overflow.sol b/test/libsolidity/semanticTests/viaYul/detect_mul_overflow.sol index 0c9c3f709..8cc64ffa0 100644 --- a/test/libsolidity/semanticTests/viaYul/detect_mul_overflow.sol +++ b/test/libsolidity/semanticTests/viaYul/detect_mul_overflow.sol @@ -7,7 +7,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(uint256,uint256): 5, 6 -> 30 diff --git a/test/libsolidity/semanticTests/viaYul/detect_mul_overflow_signed.sol b/test/libsolidity/semanticTests/viaYul/detect_mul_overflow_signed.sol index 5833dff13..a9581c49f 100644 --- a/test/libsolidity/semanticTests/viaYul/detect_mul_overflow_signed.sol +++ b/test/libsolidity/semanticTests/viaYul/detect_mul_overflow_signed.sol @@ -5,9 +5,11 @@ contract C { function g(int8 a, int8 b) public pure returns (int8 x) { x = a * b; } + function h(int160 a, int160 b) public pure returns (int160 x) { + x = a * b; + } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(int256,int256): 5, 6 -> 30 @@ -16,6 +18,9 @@ contract C { // f(int256,int256): 0x3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, 2 -> 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE // f(int256,int256): 0x4000000000000000000000000000000000000000000000000000000000000000, 2 -> FAILURE, hex"4e487b71", 0x11 // f(int256,int256): 2, 0x3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -> 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE +// f(int256,int256): 2, 0x4000000000000000000000000000000000000000000000000000000000000000 -> FAILURE, hex"4e487b71", 0x11 +// f(int256,int256): -1, 0x8000000000000000000000000000000000000000000000000000000000000000 -> FAILURE, hex"4e487b71", 0x11 +// f(int256,int256): 0x8000000000000000000000000000000000000000000000000000000000000000, -1 -> FAILURE, hex"4e487b71", 0x11 // f(int256,int256): 2, 0x4000000000000000000000000000000000000000000000000000000000000000 -> FAILURE, hex"4e487b71", 0x11 # positive, negative # // f(int256,int256): 2, 0x4000000000000000000000000000000000000000000000000000000000000000 -> FAILURE, hex"4e487b71", 0x11 # positive, negative # // f(int256,int256): 2, 0x4000000000000000000000000000000000000000000000000000000000000000 -> FAILURE, hex"4e487b71", 0x11 # positive, negative # @@ -62,3 +67,18 @@ contract C { // g(int8,int8): -64, -2 -> FAILURE, hex"4e487b71", 0x11 // g(int8,int8): -2, -63 -> 126 // g(int8,int8): -2, -64 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): -1, 1 -> -1 +// h(int160,int160): 1, -1 -> -1 +// h(int160,int160): -1, 2 -> -2 +// h(int160,int160): 2, -1 -> -2 +// h(int160,int160): -1, 0xFFFFFFFFFFFFFFFFFFFFFFFF8000000000000000000000000000000000000000 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): -1, 0xFFFFFFFFFFFFFFFFFFFFFFFF8000000000000000000000000000000000000000 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): 0xFFFFFFFFFFFFFFFFFFFFFFFF8000000000000000000000000000000000000000, -1 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): 0x0000000000000000000000004000000000000000000000000000000000000000, -2 -> 0xFFFFFFFFFFFFFFFFFFFFFFFF8000000000000000000000000000000000000000 +// h(int160,int160): -2, 0x0000000000000000000000004000000000000000000000000000000000000000 -> 0xFFFFFFFFFFFFFFFFFFFFFFFF8000000000000000000000000000000000000000 +// h(int160,int160): -2, 0x0000000000000000000000004000000000000000000000000000000000000001 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): 0x0000000000000000000000004000000000000000000000000000000000000001, -2 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): 0x0000000000000000000000004000000000000000000000000000000000000001, 2 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): 2, 0x0000000000000000000000004000000000000000000000000000000000000001 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): 0x0000000000000000000000003FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, 2 -> 0x0000000000000000000000007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE +// h(int160,int160): 2, 0x0000000000000000000000004000000000000000000000000000000000000001 -> FAILURE, hex"4e487b71", 0x11 diff --git a/test/libsolidity/semanticTests/viaYul/detect_sub_overflow.sol b/test/libsolidity/semanticTests/viaYul/detect_sub_overflow.sol index 0ee16e27b..1f6a0d7e5 100644 --- a/test/libsolidity/semanticTests/viaYul/detect_sub_overflow.sol +++ b/test/libsolidity/semanticTests/viaYul/detect_sub_overflow.sol @@ -8,7 +8,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256,uint256): 6, 5 -> 1 // f(uint256,uint256): 6, 6 -> 0 diff --git a/test/libsolidity/semanticTests/viaYul/detect_sub_overflow_signed.sol b/test/libsolidity/semanticTests/viaYul/detect_sub_overflow_signed.sol index b4d1d9e84..349926079 100644 --- a/test/libsolidity/semanticTests/viaYul/detect_sub_overflow_signed.sol +++ b/test/libsolidity/semanticTests/viaYul/detect_sub_overflow_signed.sol @@ -7,7 +7,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(int256,int256): 5, 6 -> -1 diff --git a/test/libsolidity/semanticTests/viaYul/empty_return_corrupted_free_memory_pointer.sol b/test/libsolidity/semanticTests/viaYul/empty_return_corrupted_free_memory_pointer.sol index cdc2f2448..ae6cff0e9 100644 --- a/test/libsolidity/semanticTests/viaYul/empty_return_corrupted_free_memory_pointer.sol +++ b/test/libsolidity/semanticTests/viaYul/empty_return_corrupted_free_memory_pointer.sol @@ -3,7 +3,5 @@ contract C { assembly{ mstore(0x40, sub(0, 1)) } } } -// ==== -// compileViaYul: also // ---- // f() -> diff --git a/test/libsolidity/semanticTests/viaYul/exp.sol b/test/libsolidity/semanticTests/viaYul/exp.sol index 23ac4ad97..1ca5842ab 100644 --- a/test/libsolidity/semanticTests/viaYul/exp.sol +++ b/test/libsolidity/semanticTests/viaYul/exp.sol @@ -5,7 +5,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256,uint256): 0, 0 -> 1 // f(uint256,uint256): 0, 1 -> 0x00 diff --git a/test/libsolidity/semanticTests/viaYul/exp_literals_success.sol b/test/libsolidity/semanticTests/viaYul/exp_literals_success.sol index bc4f56118..d28a56eb4 100644 --- a/test/libsolidity/semanticTests/viaYul/exp_literals_success.sol +++ b/test/libsolidity/semanticTests/viaYul/exp_literals_success.sol @@ -30,7 +30,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // exp_2(uint256): 255 -> 57896044618658097711785492504343953926634992332820282019728792003956564819968 // exp_minus_2(uint256): 255 -> -57896044618658097711785492504343953926634992332820282019728792003956564819968 diff --git a/test/libsolidity/semanticTests/viaYul/exp_neg.sol b/test/libsolidity/semanticTests/viaYul/exp_neg.sol index cd3cca64e..de58d6592 100644 --- a/test/libsolidity/semanticTests/viaYul/exp_neg.sol +++ b/test/libsolidity/semanticTests/viaYul/exp_neg.sol @@ -4,7 +4,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(int256,uint256): 0, 0 -> 1 diff --git a/test/libsolidity/semanticTests/viaYul/exp_neg_overflow.sol b/test/libsolidity/semanticTests/viaYul/exp_neg_overflow.sol index 1b668877e..9d4b59d52 100644 --- a/test/libsolidity/semanticTests/viaYul/exp_neg_overflow.sol +++ b/test/libsolidity/semanticTests/viaYul/exp_neg_overflow.sol @@ -7,7 +7,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(int8,uint256): 2, 6 -> 64 diff --git a/test/libsolidity/semanticTests/viaYul/exp_overflow.sol b/test/libsolidity/semanticTests/viaYul/exp_overflow.sol index d8bcd0e6c..8ba9c1d4a 100644 --- a/test/libsolidity/semanticTests/viaYul/exp_overflow.sol +++ b/test/libsolidity/semanticTests/viaYul/exp_overflow.sol @@ -7,7 +7,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f(uint8,uint8): 2, 7 -> 0x80 diff --git a/test/libsolidity/semanticTests/viaYul/exp_various.sol b/test/libsolidity/semanticTests/viaYul/exp_various.sol index e9a5bc026..a1a69ed03 100644 --- a/test/libsolidity/semanticTests/viaYul/exp_various.sol +++ b/test/libsolidity/semanticTests/viaYul/exp_various.sol @@ -8,7 +8,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint8,uint8): 0, 0 -> 1 // f(uint8,uint8): 0, 1 -> 0x00 diff --git a/test/libsolidity/semanticTests/viaYul/function_address.sol b/test/libsolidity/semanticTests/viaYul/function_address.sol index 6904bf676..af629a4fe 100644 --- a/test/libsolidity/semanticTests/viaYul/function_address.sol +++ b/test/libsolidity/semanticTests/viaYul/function_address.sol @@ -10,7 +10,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> 0x0fdd67305928fcac8d213d1e47bfa6165cd0b87b diff --git a/test/libsolidity/semanticTests/viaYul/function_entry_checks.sol b/test/libsolidity/semanticTests/viaYul/function_entry_checks.sol index cf06479a7..29812e018 100644 --- a/test/libsolidity/semanticTests/viaYul/function_entry_checks.sol +++ b/test/libsolidity/semanticTests/viaYul/function_entry_checks.sol @@ -18,7 +18,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0 // g(uint256,uint256): 1, -2 -> 0 diff --git a/test/libsolidity/semanticTests/viaYul/function_pointers.sol b/test/libsolidity/semanticTests/viaYul/function_pointers.sol index 30129ce53..8bc69baa8 100644 --- a/test/libsolidity/semanticTests/viaYul/function_pointers.sol +++ b/test/libsolidity/semanticTests/viaYul/function_pointers.sol @@ -18,7 +18,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> FAILURE, hex"4e487b71", 0x51 // g() -> FAILURE diff --git a/test/libsolidity/semanticTests/viaYul/function_selector.sol b/test/libsolidity/semanticTests/viaYul/function_selector.sol index dea1d3a10..d21afdcf5 100644 --- a/test/libsolidity/semanticTests/viaYul/function_selector.sol +++ b/test/libsolidity/semanticTests/viaYul/function_selector.sol @@ -7,7 +7,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // f() -> left(0x26121ff0) diff --git a/test/libsolidity/semanticTests/viaYul/if.sol b/test/libsolidity/semanticTests/viaYul/if.sol index 66af17f72..d2f582bb1 100644 --- a/test/libsolidity/semanticTests/viaYul/if.sol +++ b/test/libsolidity/semanticTests/viaYul/if.sol @@ -61,7 +61,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bool): 0 -> 23 // f(bool): 1 -> 42 diff --git a/test/libsolidity/semanticTests/viaYul/keccak.sol b/test/libsolidity/semanticTests/viaYul/keccak.sol index 1befe8f7c..017d67c50 100644 --- a/test/libsolidity/semanticTests/viaYul/keccak.sol +++ b/test/libsolidity/semanticTests/viaYul/keccak.sol @@ -7,8 +7,6 @@ contract C { return keccak256(a); } } -// ==== -// compileViaYul: also // ---- // keccak1() -> 0x64e604787cbf194841e7b68d7cd28786f6c9a0a3ab9f8b0a0e87cb4387ab0107 // keccak2() -> 0x64e604787cbf194841e7b68d7cd28786f6c9a0a3ab9f8b0a0e87cb4387ab0107 diff --git a/test/libsolidity/semanticTests/viaYul/local_address_assignment.sol b/test/libsolidity/semanticTests/viaYul/local_address_assignment.sol index 9b8626db5..35a2765ff 100644 --- a/test/libsolidity/semanticTests/viaYul/local_address_assignment.sol +++ b/test/libsolidity/semanticTests/viaYul/local_address_assignment.sol @@ -6,6 +6,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(address): 0x1234 -> 0x1234 diff --git a/test/libsolidity/semanticTests/viaYul/local_assignment.sol b/test/libsolidity/semanticTests/viaYul/local_assignment.sol index ac3beb492..978b905e3 100644 --- a/test/libsolidity/semanticTests/viaYul/local_assignment.sol +++ b/test/libsolidity/semanticTests/viaYul/local_assignment.sol @@ -6,6 +6,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256): 6 -> 6 diff --git a/test/libsolidity/semanticTests/viaYul/local_bool_assignment.sol b/test/libsolidity/semanticTests/viaYul/local_bool_assignment.sol index 32f7d4bac..c95cbf41a 100644 --- a/test/libsolidity/semanticTests/viaYul/local_bool_assignment.sol +++ b/test/libsolidity/semanticTests/viaYul/local_bool_assignment.sol @@ -6,6 +6,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(bool): true -> true diff --git a/test/libsolidity/semanticTests/viaYul/local_tuple_assignment.sol b/test/libsolidity/semanticTests/viaYul/local_tuple_assignment.sol index feeeb490e..a6b14a9e0 100644 --- a/test/libsolidity/semanticTests/viaYul/local_tuple_assignment.sol +++ b/test/libsolidity/semanticTests/viaYul/local_tuple_assignment.sol @@ -23,7 +23,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // x() -> 17 // f(uint256,uint256): 23, 42 -> 23, 42 diff --git a/test/libsolidity/semanticTests/viaYul/local_variable_without_init.sol b/test/libsolidity/semanticTests/viaYul/local_variable_without_init.sol index e43c94a84..f11cd661f 100644 --- a/test/libsolidity/semanticTests/viaYul/local_variable_without_init.sol +++ b/test/libsolidity/semanticTests/viaYul/local_variable_without_init.sol @@ -6,6 +6,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0 diff --git a/test/libsolidity/semanticTests/viaYul/loops/break.sol b/test/libsolidity/semanticTests/viaYul/loops/break.sol index 433adbf11..939cd0b7f 100644 --- a/test/libsolidity/semanticTests/viaYul/loops/break.sol +++ b/test/libsolidity/semanticTests/viaYul/loops/break.sol @@ -25,7 +25,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 2 // g() -> 2 diff --git a/test/libsolidity/semanticTests/viaYul/loops/continue.sol b/test/libsolidity/semanticTests/viaYul/loops/continue.sol index 889a18e55..25e57dac1 100644 --- a/test/libsolidity/semanticTests/viaYul/loops/continue.sol +++ b/test/libsolidity/semanticTests/viaYul/loops/continue.sol @@ -31,7 +31,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 11 // g() -> 11 diff --git a/test/libsolidity/semanticTests/viaYul/loops/return.sol b/test/libsolidity/semanticTests/viaYul/loops/return.sol index 3ad4abc86..3f3b709ba 100644 --- a/test/libsolidity/semanticTests/viaYul/loops/return.sol +++ b/test/libsolidity/semanticTests/viaYul/loops/return.sol @@ -28,7 +28,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1 // g() -> 1 diff --git a/test/libsolidity/semanticTests/viaYul/loops/simple.sol b/test/libsolidity/semanticTests/viaYul/loops/simple.sol index a4dcf38d1..3a09098ab 100644 --- a/test/libsolidity/semanticTests/viaYul/loops/simple.sol +++ b/test/libsolidity/semanticTests/viaYul/loops/simple.sol @@ -31,7 +31,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 1024 // g() -> 1024 diff --git a/test/libsolidity/semanticTests/viaYul/mapping_enum_key_getter.sol b/test/libsolidity/semanticTests/viaYul/mapping_enum_key_getter.sol index c7790aa0c..306474274 100644 --- a/test/libsolidity/semanticTests/viaYul/mapping_enum_key_getter.sol +++ b/test/libsolidity/semanticTests/viaYul/mapping_enum_key_getter.sol @@ -6,8 +6,6 @@ contract test { table[k] = v; } } -// ==== -// compileViaYul: also // ---- // table(uint8): 0 -> 0 // table(uint8): 0x01 -> 0 diff --git a/test/libsolidity/semanticTests/viaYul/mapping_getters.sol b/test/libsolidity/semanticTests/viaYul/mapping_getters.sol index 1db4eb8c5..a709bc168 100644 --- a/test/libsolidity/semanticTests/viaYul/mapping_getters.sol +++ b/test/libsolidity/semanticTests/viaYul/mapping_getters.sol @@ -8,8 +8,6 @@ contract test { m2[k1][k2] = v; } } -// ==== -// compileViaYul: also // ---- // m1(uint256): 0 -> 0 // m1(uint256): 0x01 -> 0 diff --git a/test/libsolidity/semanticTests/viaYul/mapping_string_key.sol b/test/libsolidity/semanticTests/viaYul/mapping_string_key.sol index 299f790ce..8dcd76775 100644 --- a/test/libsolidity/semanticTests/viaYul/mapping_string_key.sol +++ b/test/libsolidity/semanticTests/viaYul/mapping_string_key.sol @@ -4,7 +4,5 @@ contract C { map[s]; } } -// ==== -// compileViaYul: also // ---- // set(string): 0x20, 32, "01234567890123456789012345678901" -> diff --git a/test/libsolidity/semanticTests/viaYul/memory_struct_allow.sol b/test/libsolidity/semanticTests/viaYul/memory_struct_allow.sol index 02ec2fe95..47213b7b4 100644 --- a/test/libsolidity/semanticTests/viaYul/memory_struct_allow.sol +++ b/test/libsolidity/semanticTests/viaYul/memory_struct_allow.sol @@ -17,6 +17,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 0, 0 diff --git a/test/libsolidity/semanticTests/viaYul/msg_sender.sol b/test/libsolidity/semanticTests/viaYul/msg_sender.sol index d4177b4d6..520c9be4e 100644 --- a/test/libsolidity/semanticTests/viaYul/msg_sender.sol +++ b/test/libsolidity/semanticTests/viaYul/msg_sender.sol @@ -7,6 +7,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // test() -> true diff --git a/test/libsolidity/semanticTests/viaYul/negation_bug.sol b/test/libsolidity/semanticTests/viaYul/negation_bug.sol index 6174eadd1..d4d1b82ff 100644 --- a/test/libsolidity/semanticTests/viaYul/negation_bug.sol +++ b/test/libsolidity/semanticTests/viaYul/negation_bug.sol @@ -7,7 +7,5 @@ contract C { } } } -// ==== -// compileViaYul: also // ---- // f() -> diff --git a/test/libsolidity/semanticTests/viaYul/require.sol b/test/libsolidity/semanticTests/viaYul/require.sol index ca129a885..7546921f1 100644 --- a/test/libsolidity/semanticTests/viaYul/require.sol +++ b/test/libsolidity/semanticTests/viaYul/require.sol @@ -31,7 +31,6 @@ contract C { // ==== // EVMVersion: >=byzantium // compileToEwasm: also -// compileViaYul: also // ---- // f(bool): true -> true // f(bool): false -> FAILURE diff --git a/test/libsolidity/semanticTests/viaYul/return.sol b/test/libsolidity/semanticTests/viaYul/return.sol index 9988f6a29..c42353e60 100644 --- a/test/libsolidity/semanticTests/viaYul/return.sol +++ b/test/libsolidity/semanticTests/viaYul/return.sol @@ -6,6 +6,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 7 diff --git a/test/libsolidity/semanticTests/viaYul/return_and_convert.sol b/test/libsolidity/semanticTests/viaYul/return_and_convert.sol index 57b92691a..547838371 100644 --- a/test/libsolidity/semanticTests/viaYul/return_and_convert.sol +++ b/test/libsolidity/semanticTests/viaYul/return_and_convert.sol @@ -7,6 +7,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 255 diff --git a/test/libsolidity/semanticTests/viaYul/return_storage_pointers.sol b/test/libsolidity/semanticTests/viaYul/return_storage_pointers.sol index f99f7d072..fd886596f 100644 --- a/test/libsolidity/semanticTests/viaYul/return_storage_pointers.sol +++ b/test/libsolidity/semanticTests/viaYul/return_storage_pointers.sol @@ -12,6 +12,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 0, 0 diff --git a/test/libsolidity/semanticTests/viaYul/short_circuit.sol b/test/libsolidity/semanticTests/viaYul/short_circuit.sol index 23172d02a..5823f7734 100644 --- a/test/libsolidity/semanticTests/viaYul/short_circuit.sol +++ b/test/libsolidity/semanticTests/viaYul/short_circuit.sol @@ -10,7 +10,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // or(uint256): 0 -> true, 0 // and(uint256): 0 -> true, 8 diff --git a/test/libsolidity/semanticTests/viaYul/simple_assignment.sol b/test/libsolidity/semanticTests/viaYul/simple_assignment.sol index 21576ebd1..016f7438d 100644 --- a/test/libsolidity/semanticTests/viaYul/simple_assignment.sol +++ b/test/libsolidity/semanticTests/viaYul/simple_assignment.sol @@ -6,6 +6,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint256,uint256): 5, 6 -> 5, 6 diff --git a/test/libsolidity/semanticTests/viaYul/simple_inline_asm.sol b/test/libsolidity/semanticTests/viaYul/simple_inline_asm.sol index 1802fb956..99e0cbcdf 100644 --- a/test/libsolidity/semanticTests/viaYul/simple_inline_asm.sol +++ b/test/libsolidity/semanticTests/viaYul/simple_inline_asm.sol @@ -13,6 +13,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 6 diff --git a/test/libsolidity/semanticTests/viaYul/smoke_test.sol b/test/libsolidity/semanticTests/viaYul/smoke_test.sol index c2dbce275..6460ad90f 100644 --- a/test/libsolidity/semanticTests/viaYul/smoke_test.sol +++ b/test/libsolidity/semanticTests/viaYul/smoke_test.sol @@ -3,6 +3,5 @@ contract C { // ==== // allowNonExistingFunctions: true // compileToEwasm: also -// compileViaYul: also // ---- // f() -> FAILURE diff --git a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes.sol b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes.sol index b968f92ba..f61808084 100644 --- a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes.sol +++ b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes.sol @@ -14,6 +14,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes_long.sol b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes_long.sol index 39f89c370..3f822cbbb 100644 --- a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes_long.sol +++ b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_bytes_long.sol @@ -14,7 +14,5 @@ contract C { correct = r == (0x66 << 248); } } -// ==== -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_dynamic_array.sol b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_dynamic_array.sol index 011cf7d88..e5d2c702e 100644 --- a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_dynamic_array.sol +++ b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_dynamic_array.sol @@ -14,7 +14,5 @@ contract C { correct = (s[0] == 0x01) && (r == 0x01); } } -// ==== -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_static_array.sol b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_static_array.sol index 49d26789e..59b63ddf2 100644 --- a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_static_array.sol +++ b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_static_array.sol @@ -14,6 +14,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_struct.sol b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_struct.sol index 695184c8f..adcd09c7e 100644 --- a/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_struct.sol +++ b/test/libsolidity/semanticTests/viaYul/storage/dirty_storage_struct.sol @@ -17,7 +17,5 @@ contract C { correct = r == 0x01; } } -// ==== -// compileViaYul: also // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/viaYul/storage/mappings.sol b/test/libsolidity/semanticTests/viaYul/storage/mappings.sol index 5666635b5..42b7fe802 100644 --- a/test/libsolidity/semanticTests/viaYul/storage/mappings.sol +++ b/test/libsolidity/semanticTests/viaYul/storage/mappings.sol @@ -28,8 +28,6 @@ contract C { b = twodim[2][3]; } } -// ==== -// compileViaYul: also // ---- // test_simple(uint256): 0 -> 3, 4, 5 // test_simple(uint256): 1 -> 3, 4, 5 diff --git a/test/libsolidity/semanticTests/viaYul/storage/packed_storage.sol b/test/libsolidity/semanticTests/viaYul/storage/packed_storage.sol index 6049fb7cf..a39c0797d 100644 --- a/test/libsolidity/semanticTests/viaYul/storage/packed_storage.sol +++ b/test/libsolidity/semanticTests/viaYul/storage/packed_storage.sol @@ -12,6 +12,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f(uint8): 6 -> 9 diff --git a/test/libsolidity/semanticTests/viaYul/storage/simple_storage.sol b/test/libsolidity/semanticTests/viaYul/storage/simple_storage.sol index a01b545d4..df2575a88 100644 --- a/test/libsolidity/semanticTests/viaYul/storage/simple_storage.sol +++ b/test/libsolidity/semanticTests/viaYul/storage/simple_storage.sol @@ -12,7 +12,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // setX(uint256): 6 -> 6 // setY(uint256): 2 -> 2 diff --git a/test/libsolidity/semanticTests/viaYul/string_format.sol b/test/libsolidity/semanticTests/viaYul/string_format.sol index 76297e31d..49746adb4 100644 --- a/test/libsolidity/semanticTests/viaYul/string_format.sol +++ b/test/libsolidity/semanticTests/viaYul/string_format.sol @@ -6,7 +6,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f1() -> 0x20, 6, left(0x616263616263) // f2() -> 32, 47, 44048183223289766195424279195050628400112610419087780792899004030957505095210, 18165586057823232067963737336409268114628061002662705707816940456850361417728 diff --git a/test/libsolidity/semanticTests/viaYul/string_literals.sol b/test/libsolidity/semanticTests/viaYul/string_literals.sol index 997ac3896..f1140ffb4 100644 --- a/test/libsolidity/semanticTests/viaYul/string_literals.sol +++ b/test/libsolidity/semanticTests/viaYul/string_literals.sol @@ -20,7 +20,6 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // short_dyn() -> 0x20, 3, "abc" // long_dyn() -> 0x20, 80, "12345678901234567890123456789012", "34567890123456789012345678901234", "5678901234567890" diff --git a/test/libsolidity/semanticTests/viaYul/struct_member_access.sol b/test/libsolidity/semanticTests/viaYul/struct_member_access.sol index 108c94589..a2d9a02fd 100644 --- a/test/libsolidity/semanticTests/viaYul/struct_member_access.sol +++ b/test/libsolidity/semanticTests/viaYul/struct_member_access.sol @@ -31,7 +31,6 @@ contract C { } // ==== // EVMVersion: >homestead -// compileViaYul: also // ---- // f((uint256,uint256[],uint256)): 0x20, 42, 0x60, 21, 3, 1, 2, 3 -> 42, 0x60, 21, 3, 1, 2, 3 // g((uint256,uint256[],uint256)): 0x20, 42, 0x60, 21, 3, 1, 2, 3 -> 42, 3, 21, 1, 2, 3 diff --git a/test/libsolidity/semanticTests/viaYul/tuple_evaluation_order.sol b/test/libsolidity/semanticTests/viaYul/tuple_evaluation_order.sol index f8500b7db..edde64588 100644 --- a/test/libsolidity/semanticTests/viaYul/tuple_evaluation_order.sol +++ b/test/libsolidity/semanticTests/viaYul/tuple_evaluation_order.sol @@ -10,6 +10,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 3, 1 diff --git a/test/libsolidity/semanticTests/viaYul/unary_fixedbytes.sol b/test/libsolidity/semanticTests/viaYul/unary_fixedbytes.sol index bb211b27c..f0e811ac2 100644 --- a/test/libsolidity/semanticTests/viaYul/unary_fixedbytes.sol +++ b/test/libsolidity/semanticTests/viaYul/unary_fixedbytes.sol @@ -59,7 +59,6 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also // ---- // conv(bytes25): left(0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff) -> 0xff00ff00ff00ff00ff00ff00ff00ff00ffffffffffffffffffffffffffffffff diff --git a/test/libsolidity/semanticTests/viaYul/various_inline_asm.sol b/test/libsolidity/semanticTests/viaYul/various_inline_asm.sol index 57c028547..dc9057121 100644 --- a/test/libsolidity/semanticTests/viaYul/various_inline_asm.sol +++ b/test/libsolidity/semanticTests/viaYul/various_inline_asm.sol @@ -19,6 +19,5 @@ contract C { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 70 diff --git a/test/libsolidity/semanticTests/viaYul/virtual_functions.sol b/test/libsolidity/semanticTests/viaYul/virtual_functions.sol index b7cb10837..ea43914b7 100644 --- a/test/libsolidity/semanticTests/viaYul/virtual_functions.sol +++ b/test/libsolidity/semanticTests/viaYul/virtual_functions.sol @@ -25,7 +25,6 @@ contract C is X { } // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 3 // f1() -> 3 diff --git a/test/libsolidity/semanticTests/virtualFunctions/internal_virtual_function_calls.sol b/test/libsolidity/semanticTests/virtualFunctions/internal_virtual_function_calls.sol index 2f0ce489c..7c5658ae2 100644 --- a/test/libsolidity/semanticTests/virtualFunctions/internal_virtual_function_calls.sol +++ b/test/libsolidity/semanticTests/virtualFunctions/internal_virtual_function_calls.sol @@ -17,6 +17,5 @@ contract Derived is Base { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // f() -> 2 diff --git a/test/libsolidity/semanticTests/virtualFunctions/internal_virtual_function_calls_through_dispatch.sol b/test/libsolidity/semanticTests/virtualFunctions/internal_virtual_function_calls_through_dispatch.sol index 6c387e2e0..f74a2df7a 100644 --- a/test/libsolidity/semanticTests/virtualFunctions/internal_virtual_function_calls_through_dispatch.sol +++ b/test/libsolidity/semanticTests/virtualFunctions/internal_virtual_function_calls_through_dispatch.sol @@ -22,6 +22,5 @@ contract Derived is Base { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // h() -> 2 diff --git a/test/libsolidity/semanticTests/virtualFunctions/virtual_function_calls.sol b/test/libsolidity/semanticTests/virtualFunctions/virtual_function_calls.sol index a351cf990..d277712f0 100644 --- a/test/libsolidity/semanticTests/virtualFunctions/virtual_function_calls.sol +++ b/test/libsolidity/semanticTests/virtualFunctions/virtual_function_calls.sol @@ -17,7 +17,6 @@ contract Derived is Base { // ==== // compileToEwasm: also -// compileViaYul: also // ---- // g() -> 2 // f() -> 2 diff --git a/test/libsolidity/semanticTests/virtualFunctions/virtual_function_usage_in_constructor_arguments.sol b/test/libsolidity/semanticTests/virtualFunctions/virtual_function_usage_in_constructor_arguments.sol index 71ee82fd3..d8417e3e2 100644 --- a/test/libsolidity/semanticTests/virtualFunctions/virtual_function_usage_in_constructor_arguments.sol +++ b/test/libsolidity/semanticTests/virtualFunctions/virtual_function_usage_in_constructor_arguments.sol @@ -28,7 +28,5 @@ contract Derived is Base { } } -// ==== -// compileViaYul: also // ---- // getA() -> 2 diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_hash.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_hash.sol index a9608a828..1cde51069 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_hash.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_hash.sol @@ -11,7 +11,6 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- -// Warning 1218: (281-319): CHC: Error trying to invoke SMT solver. -// Warning 6328: (281-319): CHC: Assertion violation might happen here. -// Warning 4661: (281-319): BMC: Assertion violation happens here. +// Warning 6328: (281-319): CHC: Assertion violation happens here.\nCounterexample:\n\na = 0\nb = 0\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedHash(0, 0) diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_hash.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_hash.sol index f60d5f52b..ae6ea018f 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_hash.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_hash.sol @@ -13,11 +13,8 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreCex: yes // ---- // Warning 2072: (161-176): Unused local variable. -// Warning 1218: (379-417): CHC: Error trying to invoke SMT solver. -// Warning 1218: (436-474): CHC: Error trying to invoke SMT solver. -// Warning 6328: (379-417): CHC: Assertion violation might happen here. -// Warning 6328: (436-474): CHC: Assertion violation might happen here. -// Warning 4661: (379-417): BMC: Assertion violation happens here. -// Warning 4661: (436-474): BMC: Assertion violation happens here. +// Warning 6328: (379-417): CHC: Assertion violation happens here. +// Warning 6328: (436-474): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_vs_sig.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_vs_sig.sol index b5346b049..66ec1c69b 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_vs_sig.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_vs_sig.sol @@ -9,5 +9,6 @@ contract C { // ==== // SMTEngine: all // ---- +// Warning 1218: (294-324): CHC: Error trying to invoke SMT solver. // Warning 6328: (294-324): CHC: Assertion violation might happen here. // Warning 7812: (294-324): BMC: Assertion violation might happen here. diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_hash.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_hash.sol index 61e755d82..00836f228 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_hash.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_hash.sol @@ -13,7 +13,5 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 1218: (394-432): CHC: Error trying to invoke SMT solver. // Warning 6328: (337-375): CHC: Assertion violation happens here. -// Warning 6328: (394-432): CHC: Assertion violation might happen here. -// Warning 4661: (394-432): BMC: Assertion violation happens here. +// Warning 6328: (394-432): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_simple.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_simple.sol index 96f3e48d9..1fe781974 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_simple.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_simple.sol @@ -25,7 +25,7 @@ contract C { // ---- // Warning 5667: (107-122): Unused function parameter. Remove or comment out the variable name to silence this warning. // Warning 1218: (824-854): CHC: Error trying to invoke SMT solver. -// Warning 6328: (543-573): CHC: Assertion violation happens here. +// Warning 6328: (543-573): CHC: Assertion violation happens here.\nCounterexample:\n\nt = false\nx = 0\ny = 0\nz = 0\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeSimple(sig, false, 0, 0, 0, a, b) // Warning 6328: (664-694): CHC: Assertion violation happens here. // Warning 6328: (713-743): CHC: Assertion violation happens here. // Warning 6328: (824-854): CHC: Assertion violation might happen here. diff --git a/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_and_rhs_bytes.sol b/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_and_rhs_bytes.sol index 6126b5b10..cf86c7c4d 100644 --- a/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_and_rhs_bytes.sol +++ b/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_and_rhs_bytes.sol @@ -12,5 +12,6 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- -// Warning 6328: (203-244): CHC: Assertion violation happens here. +// Warning 6328: (203-244): CHC: Assertion violation happens here.\nCounterexample:\nb = [0x0, 0x0]\nlength = 2\n\nTransaction trace:\nC.constructor()\nState: b = []\nC.f() diff --git a/test/libsolidity/smtCheckerTests/external_calls/call_with_value_1.sol b/test/libsolidity/smtCheckerTests/external_calls/call_with_value_1.sol index f9293f693..813185adf 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/call_with_value_1.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/call_with_value_1.sol @@ -12,5 +12,5 @@ contract C { // ---- // Warning 9302: (96-117): Return value of low-level calls not used. // Warning 6328: (121-156): CHC: Assertion violation might happen here. -// Warning 6328: (175-211): CHC: Assertion violation happens here.\nCounterexample:\n\ni = 0x0\n\nTransaction trace:\nC.constructor()\nC.g(0x0)\n i.call{value: 10}("") -- untrusted external call +// Warning 6328: (175-211): CHC: Assertion violation happens here. // Warning 4661: (121-156): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/call_with_value_2.sol b/test/libsolidity/smtCheckerTests/external_calls/call_with_value_2.sol index c38658080..968095bb2 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/call_with_value_2.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/call_with_value_2.sol @@ -11,5 +11,5 @@ contract C { // ---- // Warning 9302: (96-116): Return value of low-level calls not used. // Warning 6328: (120-156): CHC: Assertion violation might happen here. -// Warning 6328: (175-210): CHC: Assertion violation happens here.\nCounterexample:\n\ni = 0x0\n\nTransaction trace:\nC.constructor()\nC.g(0x0)\n i.call{value: 0}("") -- untrusted external call +// Warning 6328: (175-210): CHC: Assertion violation happens here. // Warning 4661: (120-156): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_call_from_constructor_3.sol b/test/libsolidity/smtCheckerTests/external_calls/external_call_from_constructor_3.sol index 9d27d6d3b..ba0dc90b0 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_call_from_constructor_3.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_call_from_constructor_3.sol @@ -18,6 +18,7 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Warning 6328: (69-85): CHC: Assertion violation happens here.\nCounterexample:\n\n_x = 100\n = 0\n\nTransaction trace:\nState.constructor()\nState.f(100) -// Warning 6328: (203-217): CHC: Assertion violation happens here.\nCounterexample:\ns = 0, z = 0\n\nTransaction trace:\nC.constructor()\nState: s = 0, z = 0\nC.f() +// Warning 6328: (203-217): CHC: Assertion violation happens here.\nCounterexample:\ns = 0, z = 3\n\nTransaction trace:\nC.constructor()\nState: s = 0, z = 3\nC.f() diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_call_this_with_value_1.sol b/test/libsolidity/smtCheckerTests/external_calls/external_call_this_with_value_1.sol index c52e0773f..06390b12c 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_call_this_with_value_1.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_call_this_with_value_1.sol @@ -11,4 +11,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 6328: (157-192): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nC.g()\n C.h() -- trusted external call +// Warning 6328: (157-192): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_call_with_value_3.sol b/test/libsolidity/smtCheckerTests/external_calls/external_call_with_value_3.sol index fa7ef4462..2a535329a 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_call_with_value_3.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_call_with_value_3.sol @@ -14,8 +14,6 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Warning 1218: (202-236): CHC: Error trying to invoke SMT solver. // Warning 6328: (150-183): CHC: Assertion violation might happen here. -// Warning 6328: (202-236): CHC: Assertion violation might happen here. +// Warning 6328: (202-236): CHC: Assertion violation happens here.\nCounterexample:\n\ni = 0\n\nTransaction trace:\nC.constructor()\nC.g(0)\n i.f{value: 20}() -- untrusted external call // Warning 4661: (150-183): BMC: Assertion violation happens here. -// Warning 4661: (202-236): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_2.sol b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_2.sol index 37509269b..be9f698e1 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_2.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_2.sol @@ -42,6 +42,4 @@ contract C { // SMTIgnoreOS: macos // ---- // Warning 2018: (33-88): Function state mutability can be restricted to view -// Warning 1218: (367-381): CHC: Error trying to invoke SMT solver. -// Warning 6328: (367-381): CHC: Assertion violation might happen here. -// Warning 4661: (367-381): BMC: Assertion violation happens here. +// Warning 6328: (367-381): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_indirect.sol b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_indirect.sol index bd779b56a..ea9764e17 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_indirect.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_indirect.sol @@ -44,5 +44,7 @@ contract C { // SMTIgnoreCex: yes // SMTIgnoreOS: macos // ---- +// Warning 1218: (437-463): CHC: Error trying to invoke SMT solver. // Warning 6328: (419-433): CHC: Assertion violation happens here. -// Warning 6328: (437-463): CHC: Assertion violation happens here. +// Warning 6328: (437-463): CHC: Assertion violation might happen here. +// Warning 4661: (437-463): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_1.sol b/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_1.sol index 5683a5248..9cf0d3643 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_1.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_1.sol @@ -15,6 +15,7 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Warning 1218: (206-220): CHC: Error trying to invoke SMT solver. // Warning 6328: (206-220): CHC: Assertion violation might happen here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_2.sol b/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_2.sol index 1e8ce8816..19ff2bbad 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_2.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_2.sol @@ -13,6 +13,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 1218: (117-131): CHC: Error trying to invoke SMT solver. -// Warning 6328: (117-131): CHC: Assertion violation might happen here. -// Warning 4661: (117-131): BMC: Assertion violation happens here. +// Warning 6328: (117-131): CHC: Assertion violation happens here.\nCounterexample:\nlocked = false\ntarget = 0x0\n\nTransaction trace:\nC.constructor()\nState: locked = true\nC.call(0x0)\n D(target).e() -- untrusted external call, synthesized as:\n C.call(0x0) -- reentrant call diff --git a/test/libsolidity/smtCheckerTests/function_selector/homer.sol b/test/libsolidity/smtCheckerTests/function_selector/homer.sol index 552a4d895..aaab88488 100644 --- a/test/libsolidity/smtCheckerTests/function_selector/homer.sol +++ b/test/libsolidity/smtCheckerTests/function_selector/homer.sol @@ -43,4 +43,4 @@ contract Homer is ERC165, Simpson { // ==== // SMTEngine: all // ---- -// Warning 6328: (1340-1395): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nHomer.constructor()\nHomer.check()\n Homer.supportsInterface(0x73b6b492) -- internal call\n Homer.supportsInterface(0x01ffc9a7) -- internal call\n Homer.supportsInterface(0x8b9eb9ca) -- internal call +// Warning 6328: (1340-1395): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nHomer.constructor()\nHomer.supportsInterface(0x01ffc9a7)\nHomer.check()\n Homer.supportsInterface(0x73b6b492) -- internal call\n Homer.supportsInterface(0x01ffc9a7) -- internal call\n Homer.supportsInterface(0x8b9eb9ca) -- internal call diff --git a/test/libsolidity/smtCheckerTests/functions/functions_storage_var_1_fail.sol b/test/libsolidity/smtCheckerTests/functions/functions_storage_var_1_fail.sol index a7f0c879f..e775c97a9 100644 --- a/test/libsolidity/smtCheckerTests/functions/functions_storage_var_1_fail.sol +++ b/test/libsolidity/smtCheckerTests/functions/functions_storage_var_1_fail.sol @@ -13,5 +13,6 @@ contract C // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Warning 6328: (112-125): CHC: Assertion violation happens here.\nCounterexample:\na = 0\n\nTransaction trace:\nC.constructor()\nState: a = 0\nC.g()\n C.f(0) -- internal call diff --git a/test/libsolidity/smtCheckerTests/imports/import_as_module_2.sol b/test/libsolidity/smtCheckerTests/imports/import_as_module_2.sol index 8ddef2da9..bdf2e349c 100644 --- a/test/libsolidity/smtCheckerTests/imports/import_as_module_2.sol +++ b/test/libsolidity/smtCheckerTests/imports/import_as_module_2.sol @@ -18,5 +18,9 @@ function f(uint _x) pure { // ==== // SMTEngine: all // ---- -// Warning 6328: (A:50-64): CHC: Assertion violation happens here.\nCounterexample:\n\n_y = 0\n\nTransaction trace:\nD.constructor()\nD.g(0)\n s1.sol:f(200) -- internal call\n s1.sol:f(0) -- internal call\n A:f(10) -- internal call\n A:f(0) -- internal call -// Warning 6328: (s1.sol:28-44): CHC: Assertion violation happens here.\nCounterexample:\n\n_y = 0\n\nTransaction trace:\nD.constructor()\nD.g(0)\n s1.sol:f(200) -- internal call\n s1.sol:f(0) -- internal call +// Warning 1218: (A:50-64): CHC: Error trying to invoke SMT solver. +// Warning 1218: (s1.sol:28-44): CHC: Error trying to invoke SMT solver. +// Warning 6328: (A:50-64): CHC: Assertion violation might happen here. +// Warning 6328: (s1.sol:28-44): CHC: Assertion violation might happen here. +// Warning 4661: (s1.sol:28-44): BMC: Assertion violation happens here. +// Warning 4661: (A:50-64): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/inheritance/receive_fallback.sol b/test/libsolidity/smtCheckerTests/inheritance/receive_fallback.sol index 95ae12019..3d4c5e06a 100644 --- a/test/libsolidity/smtCheckerTests/inheritance/receive_fallback.sol +++ b/test/libsolidity/smtCheckerTests/inheritance/receive_fallback.sol @@ -21,6 +21,6 @@ contract B is A { // ==== // SMTEngine: all // ---- -// Warning 6328: (87-101): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\n\nTransaction trace:\nA.constructor()\nState: x = 0\nA.receive(){ msg.value: 2 } +// Warning 6328: (87-101): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\n\nTransaction trace:\nA.constructor()\nState: x = 0\nA.receive(){ msg.value: 1 } // Warning 6328: (136-150): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\n\nTransaction trace:\nA.constructor()\nState: x = 0\nA.g() // Warning 6328: (255-269): CHC: Assertion violation happens here.\nCounterexample:\ny = 0, x = 0\n\nTransaction trace:\nB.constructor()\nState: y = 0, x = 0\nB.fallback() diff --git a/test/libsolidity/smtCheckerTests/modifiers/modifier_inside_branch_assignment.sol b/test/libsolidity/smtCheckerTests/modifiers/modifier_inside_branch_assignment.sol index f8091f9df..d496baf6c 100644 --- a/test/libsolidity/smtCheckerTests/modifiers/modifier_inside_branch_assignment.sol +++ b/test/libsolidity/smtCheckerTests/modifiers/modifier_inside_branch_assignment.sol @@ -20,4 +20,6 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 6328: (254-267): CHC: Assertion violation happens here.\nCounterexample:\nx = 0, owner = 0x0\ny = 1\n\nTransaction trace:\nC.constructor()\nState: x = 0, owner = 0x0\nC.g(1)\n C.f() -- internal call +// Warning 1218: (254-267): CHC: Error trying to invoke SMT solver. +// Warning 6328: (254-267): CHC: Assertion violation might happen here. +// Warning 4661: (254-267): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/operators/compound_assignment_division_3.sol b/test/libsolidity/smtCheckerTests/operators/compound_assignment_division_3.sol index aa90aa252..3e646ec3d 100644 --- a/test/libsolidity/smtCheckerTests/operators/compound_assignment_division_3.sol +++ b/test/libsolidity/smtCheckerTests/operators/compound_assignment_division_3.sol @@ -12,4 +12,4 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Warning 6328: (162-181): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 2\np = 0\n\nTransaction trace:\nC.constructor()\nC.f(2, 0) +// Warning 6328: (162-181): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/operators/compound_bitwise_string_literal_3.sol b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_string_literal_3.sol index b2d56cb12..3ac248fb2 100644 --- a/test/libsolidity/smtCheckerTests/operators/compound_bitwise_string_literal_3.sol +++ b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_string_literal_3.sol @@ -18,5 +18,4 @@ contract C { // SMTEngine: all // ---- // Warning 6328: (229-276): CHC: Assertion violation happens here.\nCounterexample:\n\ny = 0x6062606464666060606260646466606060626064646660606062606464666060\nz = 0x6062606464666060606260646466606060626064646660606062606464666060\n\nTransaction trace:\nC.constructor()\nC.f() -// Warning 6328: (394-437): CHC: Assertion violation might happen here. -// Warning 4661: (394-437): BMC: Assertion violation happens here. +// Warning 6328: (394-437): CHC: Assertion violation happens here.\nCounterexample:\n\ny = 0x63666566676e616263666566676e616263666566676e616263666566676e6162\nz = 0x63666566676e616263666566676e616263666566676e616263666566676e6162\n\nTransaction trace:\nC.constructor()\nC.f() diff --git a/test/libsolidity/smtCheckerTests/out_of_bounds/array_1.sol b/test/libsolidity/smtCheckerTests/out_of_bounds/array_1.sol index c26e64fcc..ee57f069d 100644 --- a/test/libsolidity/smtCheckerTests/out_of_bounds/array_1.sol +++ b/test/libsolidity/smtCheckerTests/out_of_bounds/array_1.sol @@ -21,6 +21,7 @@ contract C { // SMTIgnoreOS: macos // ---- // Warning 4984: (112-115): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here. +// Warning 3944: (181-184): CHC: Underflow (resulting value less than 0) might happen here. // Warning 6368: (259-263): CHC: Out of bounds access happens here.\nCounterexample:\na = [0], l = 1\n = 0\n\nTransaction trace:\nC.constructor()\nState: a = [], l = 0\nC.p()\nState: a = [0], l = 1\nC.r() -// Info 1180: Contract invariant(s) for :C:\n((a.length + ((- 1) * l)) <= 0)\n // Warning 2661: (112-115): BMC: Overflow (resulting value larger than 2**256 - 1) happens here. +// Warning 4144: (181-184): BMC: Underflow (resulting value less than 0) happens here. diff --git a/test/libsolidity/smtCheckerTests/overflow/signed_guard_sub_overflow.sol b/test/libsolidity/smtCheckerTests/overflow/signed_guard_sub_overflow.sol index b28b6598c..95221c912 100644 --- a/test/libsolidity/smtCheckerTests/overflow/signed_guard_sub_overflow.sol +++ b/test/libsolidity/smtCheckerTests/overflow/signed_guard_sub_overflow.sol @@ -8,4 +8,4 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Warning 4984: (96-101): CHC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here.\nCounterexample:\n\nx = 0\ny = (- 57896044618658097711785492504343953926634992332820282019728792003956564819968)\n = 0\n\nTransaction trace:\nC.constructor()\nC.f(0, (- 57896044618658097711785492504343953926634992332820282019728792003956564819968)) +// Warning 4984: (96-101): CHC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here.\nCounterexample:\n\nx = 57896044618658097711785492504343953926634992332820282019728792003956564819967\ny = (- 1)\n = 0\n\nTransaction trace:\nC.constructor()\nC.f(57896044618658097711785492504343953926634992332820282019728792003956564819967, (- 1)) diff --git a/test/libsolidity/smtCheckerTests/overflow/signed_guard_sum_overflow.sol b/test/libsolidity/smtCheckerTests/overflow/signed_guard_sum_overflow.sol index 4635ef966..2e4b84b70 100644 --- a/test/libsolidity/smtCheckerTests/overflow/signed_guard_sum_overflow.sol +++ b/test/libsolidity/smtCheckerTests/overflow/signed_guard_sum_overflow.sol @@ -8,5 +8,5 @@ contract C { // SMTEngine: all // SMTIgnoreCex: yes // ---- -// Warning 3944: (78-83): CHC: Underflow (resulting value less than -57896044618658097711785492504343953926634992332820282019728792003956564819968) happens here. +// Warning 3944: (78-83): CHC: Underflow (resulting value less than -0x80 * 2**248) happens here. // Warning 4984: (78-83): CHC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here. diff --git a/test/libsolidity/smtCheckerTests/overflow/signed_mul_overflow.sol b/test/libsolidity/smtCheckerTests/overflow/signed_mul_overflow.sol index 225d00689..e664174df 100644 --- a/test/libsolidity/smtCheckerTests/overflow/signed_mul_overflow.sol +++ b/test/libsolidity/smtCheckerTests/overflow/signed_mul_overflow.sol @@ -7,5 +7,5 @@ contract C { // SMTEngine: all // SMTIgnoreCex: yes // ---- -// Warning 3944: (77-82): CHC: Underflow (resulting value less than -57896044618658097711785492504343953926634992332820282019728792003956564819968) happens here. +// Warning 3944: (77-82): CHC: Underflow (resulting value less than -0x80 * 2**248) happens here. // Warning 4984: (77-82): CHC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here. diff --git a/test/libsolidity/smtCheckerTests/overflow/signed_sub_overflow.sol b/test/libsolidity/smtCheckerTests/overflow/signed_sub_overflow.sol index 81de2d5fe..dfb228b9a 100644 --- a/test/libsolidity/smtCheckerTests/overflow/signed_sub_overflow.sol +++ b/test/libsolidity/smtCheckerTests/overflow/signed_sub_overflow.sol @@ -7,5 +7,5 @@ contract C { // SMTEngine: all // SMTIgnoreCex: yes // ---- -// Warning 3944: (77-82): CHC: Underflow (resulting value less than -57896044618658097711785492504343953926634992332820282019728792003956564819968) happens here. +// Warning 3944: (77-82): CHC: Underflow (resulting value less than -0x80 * 2**248) happens here. // Warning 4984: (77-82): CHC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here. diff --git a/test/libsolidity/smtCheckerTests/overflow/signed_sum_overflow.sol b/test/libsolidity/smtCheckerTests/overflow/signed_sum_overflow.sol index 7bb6588e3..5ac0c812b 100644 --- a/test/libsolidity/smtCheckerTests/overflow/signed_sum_overflow.sol +++ b/test/libsolidity/smtCheckerTests/overflow/signed_sum_overflow.sol @@ -7,5 +7,5 @@ contract C { // SMTEngine: all // SMTIgnoreCex: yes // ---- -// Warning 3944: (77-82): CHC: Underflow (resulting value less than -57896044618658097711785492504343953926634992332820282019728792003956564819968) happens here. +// Warning 3944: (77-82): CHC: Underflow (resulting value less than -0x80 * 2**248) happens here. // Warning 4984: (77-82): CHC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here. diff --git a/test/libsolidity/smtCheckerTests/overflow/simple_overflow.sol b/test/libsolidity/smtCheckerTests/overflow/simple_overflow.sol index e8cf49a83..d872cb669 100644 --- a/test/libsolidity/smtCheckerTests/overflow/simple_overflow.sol +++ b/test/libsolidity/smtCheckerTests/overflow/simple_overflow.sol @@ -4,4 +4,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 4984: (80-85): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\na = 1\nb = 115792089237316195423570985008687907853269984665640564039457584007913129639935\n = 0\n\nTransaction trace:\nC.constructor()\nC.f(1, 115792089237316195423570985008687907853269984665640564039457584007913129639935) +// Warning 4984: (80-85): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\na = 115792089237316195423570985008687907853269984665640564039457584007913129639935\nb = 1\n = 0\n\nTransaction trace:\nC.constructor()\nC.f(115792089237316195423570985008687907853269984665640564039457584007913129639935, 1) diff --git a/test/libsolidity/smtCheckerTests/special/block_vars_chc_internal.sol b/test/libsolidity/smtCheckerTests/special/block_vars_chc_internal.sol index 6e4f5a620..ab355dbd2 100644 --- a/test/libsolidity/smtCheckerTests/special/block_vars_chc_internal.sol +++ b/test/libsolidity/smtCheckerTests/special/block_vars_chc_internal.sol @@ -31,5 +31,6 @@ contract C { } // ==== // SMTEngine: chc +// SMTIgnoreOS: macos // ---- -// Warning 6328: (770-799): CHC: Assertion violation happens here.\nCounterexample:\ncoin = 0x1e28, dif = 0, gas = 0, number = 0, timestamp = 0\n\nTransaction trace:\nC.constructor()\nState: coin = 0x0, dif = 0, gas = 0, number = 0, timestamp = 0\nC.f(){ block.coinbase: 0x1e28, block.difficulty: 0, block.gaslimit: 0, block.number: 0, block.timestamp: 0 }\n C.g() -- internal call +// Warning 6328: (770-799): CHC: Assertion violation happens here.\nCounterexample:\ncoin = 0x0, dif = 0, gas = 0, number = 0, timestamp = 0\n\nTransaction trace:\nC.constructor()\nState: coin = 0x0, dif = 0, gas = 0, number = 0, timestamp = 0\nC.f(){ block.coinbase: 0x0, block.difficulty: 0, block.gaslimit: 0, block.number: 0, block.timestamp: 0 }\n C.g() -- internal call diff --git a/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_1.sol b/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_1.sol index f1fed73c0..7d9c0ca56 100644 --- a/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_1.sol +++ b/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_1.sol @@ -13,4 +13,4 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Warning 6328: (135-169): CHC: Assertion violation happens here.\nCounterexample:\n\n_i = 0\nx = 9726\n\nTransaction trace:\nC.constructor()\nC.g(0){ msg.value: 2070 }\n _i.f() -- untrusted external call, synthesized as:\n C.g(0){ msg.value: 0 } -- reentrant call\n _i.f() -- untrusted external call +// Warning 6328: (135-169): CHC: Assertion violation happens here.\nCounterexample:\n\n_i = 0\nx = 868\n\nTransaction trace:\nC.constructor()\nC.g(0){ msg.value: 500 }\n _i.f() -- untrusted external call, synthesized as:\n C.g(0){ msg.value: 0 } -- reentrant call\n _i.f() -- untrusted external call diff --git a/test/libsolidity/smtCheckerTests/try_catch/try_public_var_mapping.sol b/test/libsolidity/smtCheckerTests/try_catch/try_public_var_mapping.sol index 627d06a2d..43f4b5f03 100644 --- a/test/libsolidity/smtCheckerTests/try_catch/try_public_var_mapping.sol +++ b/test/libsolidity/smtCheckerTests/try_catch/try_public_var_mapping.sol @@ -21,4 +21,4 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Warning 6328: (280-300): CHC: Assertion violation happens here. +// Warning 6328: (280-300): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nC.f() diff --git a/test/libsolidity/smtCheckerTests/typecast/bytes_to_fixed_bytes_1.sol b/test/libsolidity/smtCheckerTests/typecast/bytes_to_fixed_bytes_1.sol index 91166baa8..1d00e7fe3 100644 --- a/test/libsolidity/smtCheckerTests/typecast/bytes_to_fixed_bytes_1.sol +++ b/test/libsolidity/smtCheckerTests/typecast/bytes_to_fixed_bytes_1.sol @@ -3,20 +3,12 @@ contract C { bytes memory b = hex"00010203040506070809000102030405060708090001020304050607080900010203040506070809"; bytes8 c = bytes8(b); assert(c == 0x0001020304050607); // should hold - assert(c == 0x0001020304050608); // should fail bytes16 d = bytes16(b); assert(d == 0x00010203040506070809000102030405); - assert(d == 0x00010203040506070809000102030406); // should fail bytes24 e = bytes24(b); assert(e == 0x000102030405060708090001020304050607080900010203); // should hold - assert(e == 0x000102030405060708090001020304050607080900010204); // should fail bytes32 g = bytes32(b); assert(g == 0x0001020304050607080900010203040506070809000102030405060708090001); // should hold - assert(g == 0x0001020304050607080900010203040506070809000102030405060708090002); // should fail } } // ---- -// Warning 6328: (225-256): CHC: Assertion violation happens here.\nCounterexample:\n\nc = 0x01020304050607\nd = 0x0\ne = 0x0\ng = 0x0\n\nTransaction trace:\nC.constructor()\nC.f() -// Warning 6328: (352-399): CHC: Assertion violation happens here.\nCounterexample:\n\nc = 0x01020304050607\nd = 0x010203040506070809000102030405\ne = 0x0\ng = 0x0\n\nTransaction trace:\nC.constructor()\nC.f() -// Warning 6328: (526-589): CHC: Assertion violation happens here.\nCounterexample:\n\nc = 0x01020304050607\nd = 0x010203040506070809000102030405\ne = 0x0102030405060708090001020304050607080900010203\ng = 0x0\n\nTransaction trace:\nC.constructor()\nC.f() -// Warning 6328: (732-811): CHC: Assertion violation happens here.\nCounterexample:\n\nc = 0x01020304050607\nd = 0x010203040506070809000102030405\ne = 0x0102030405060708090001020304050607080900010203\ng = 0x01020304050607080900010203040506070809000102030405060708090001\n\nTransaction trace:\nC.constructor()\nC.f() diff --git a/test/libsolidity/smtCheckerTests/typecast/bytes_to_fixed_bytes_1_fail.sol b/test/libsolidity/smtCheckerTests/typecast/bytes_to_fixed_bytes_1_fail.sol new file mode 100644 index 000000000..40cd27776 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/typecast/bytes_to_fixed_bytes_1_fail.sol @@ -0,0 +1,25 @@ +contract C { + function f() external pure { + bytes memory b = hex"00010203040506070809000102030405060708090001020304050607080900010203040506070809"; + bytes8 c = bytes8(b); + //assert(c == 0x0001020304050607); // should hold + assert(c == 0x0001020304050608); // should fail + bytes16 d = bytes16(b); + //assert(d == 0x00010203040506070809000102030405); + assert(d == 0x00010203040506070809000102030406); // should fail + bytes24 e = bytes24(b); + //assert(e == 0x000102030405060708090001020304050607080900010203); // should hold + assert(e == 0x000102030405060708090001020304050607080900010204); // should fail + bytes32 g = bytes32(b); + //assert(g == 0x0001020304050607080900010203040506070809000102030405060708090001); // should hold + assert(g == 0x0001020304050607080900010203040506070809000102030405060708090002); // should fail + } +} +// ==== +// SMTEngine: all +// SMTIgnoreCex: yes +// ---- +// Warning 6328: (227-258): CHC: Assertion violation happens here. +// Warning 6328: (356-403): CHC: Assertion violation happens here. +// Warning 6328: (532-595): CHC: Assertion violation happens here. +// Warning 6328: (740-819): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/typecast/string_to_bytes_push_1.sol b/test/libsolidity/smtCheckerTests/typecast/string_to_bytes_push_1.sol index 4910c417e..33546b49c 100644 --- a/test/libsolidity/smtCheckerTests/typecast/string_to_bytes_push_1.sol +++ b/test/libsolidity/smtCheckerTests/typecast/string_to_bytes_push_1.sol @@ -11,4 +11,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 6328: (132-160): CHC: Assertion violation happens here.\nCounterexample:\nx = [0x61, 0x62, 0x63, 0x61]\n\nTransaction trace:\nC.constructor()\nState: x = []\nC.s() +// Warning 6328: (132-160): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nState: x = []\nC.s() diff --git a/test/libsolidity/smtCheckerTests/types/array_branch_1d.sol b/test/libsolidity/smtCheckerTests/types/array_branch_1d.sol index b04c632e9..b6f19302b 100644 --- a/test/libsolidity/smtCheckerTests/types/array_branch_1d.sol +++ b/test/libsolidity/smtCheckerTests/types/array_branch_1d.sol @@ -12,4 +12,6 @@ contract C // SMTEngine: all // SMTIgnoreCex: yes // ---- -// Warning 6328: (143-159): CHC: Assertion violation happens here. +// Warning 1218: (143-159): CHC: Error trying to invoke SMT solver. +// Warning 6328: (143-159): CHC: Assertion violation might happen here. +// Warning 4661: (143-159): BMC: Assertion violation happens here. diff --git a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_error_free_function.sol b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_error_free_function.sol new file mode 100644 index 000000000..c59b1b3f7 --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_error_free_function.sol @@ -0,0 +1,7 @@ +error E(uint); + +function f() { + abi.encodeCall(E, (1)); +} +// ---- +// TypeError 3509: (50-51): Expected regular external function type, or external view on public function. Cannot use errors for abi.encodeCall. diff --git a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_event_free_function.sol b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_event_free_function.sol new file mode 100644 index 000000000..39930125b --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_event_free_function.sol @@ -0,0 +1,9 @@ +library L { + event E(uint); +} + +function f() { + abi.encodeCall(L.E, (1)); +} +// ---- +// TypeError 3509: (68-71): Expected regular external function type, or external view on public function. Cannot use events for abi.encodeCall. diff --git a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_free_func.sol b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_free_func.sol new file mode 100644 index 000000000..5567810f4 --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_free_func.sol @@ -0,0 +1,7 @@ +function g(uint) {} + +function f() { + abi.encodeCall(g, (1)); +} +// ---- +// TypeError 3509: (55-56): Expected regular external function type, or external view on public function. Provided internal function. diff --git a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_on_lib_func_in_free_func.sol b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_on_lib_func_in_free_func.sol new file mode 100644 index 000000000..ed2e02a11 --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_on_lib_func_in_free_func.sol @@ -0,0 +1,9 @@ +library L { + function g() external {} +} + +function f() { + abi.encodeCall(L.g, (1)); +} +// ---- +// TypeError 3509: (78-81): Expected regular external function type, or external view on public function. Cannot use library functions for abi.encodeCall. diff --git a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_assignment_expression.sol b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_assignment_expression.sol new file mode 100644 index 000000000..955cea06a --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_assignment_expression.sol @@ -0,0 +1,24 @@ +contract C { + function g0() internal pure {} + function g2() internal pure returns (uint, uint) { return (2, 3); } + + function f0() public {} + function f2(uint, uint) public {} + + function h() public view { + uint a; + uint b; + + abi.encodeCall(this.f0, () = g0()); + abi.encodeCall(this.f0, () = ()); + abi.encodeCall(this.f2, (a, b) = g2()); + abi.encodeCall(this.f2, (a, b) = (2, 3)); + } +} +// ---- +// TypeError 5547: (284-286): Empty tuple on the left hand side. +// TypeError 9062: (284-293): Expected an inline tuple, not an expression of a tuple type. +// TypeError 5547: (328-330): Empty tuple on the left hand side. +// TypeError 9062: (328-335): Expected an inline tuple, not an expression of a tuple type. +// TypeError 9062: (370-383): Expected an inline tuple, not an expression of a tuple type. +// TypeError 9062: (418-433): Expected an inline tuple, not an expression of a tuple type. diff --git a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_conditional_ternary_expression.sol b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_conditional_ternary_expression.sol new file mode 100644 index 000000000..3b8b549ba --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_conditional_ternary_expression.sol @@ -0,0 +1,17 @@ +contract C { + function g0() internal pure {} + function g2() internal pure returns (uint, uint) { return (2, 3); } + + function f0() public {} + function f2(uint, uint) public {} + + function h() public view { + abi.encodeCall(this.f0, true ? g0() : g0()); + abi.encodeCall(this.f2, true ? g2() : g2()); + abi.encodeCall(this.f2, true ? (1, 2) : (3, 4)); + } +} +// ---- +// TypeError 9062: (251-269): Expected an inline tuple, not an expression of a tuple type. +// TypeError 9062: (304-322): Expected an inline tuple, not an expression of a tuple type. +// TypeError 9062: (357-379): Expected an inline tuple, not an expression of a tuple type. diff --git a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_error_event.sol b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_error_event.sol new file mode 100644 index 000000000..c96b82909 --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_error_event.sol @@ -0,0 +1,16 @@ +contract C { + event Ev(); + error Er(); + + function f0() public {} + + function h() public view { + abi.encodeCall(this.f0, Ev()); + abi.encodeCall(this.f0, Er()); + abi.encodeCall(this.f0, revert()); + } +} +// ---- +// TypeError 9062: (138-142): Expected an inline tuple, not an expression of a tuple type. +// TypeError 9062: (177-181): Expected an inline tuple, not an expression of a tuple type. +// TypeError 9062: (216-224): Expected an inline tuple, not an expression of a tuple type. diff --git a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_invalid_operator.sol b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_invalid_operator.sol new file mode 100644 index 000000000..cd98edf6c --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_invalid_operator.sol @@ -0,0 +1,23 @@ +contract C { + event Ev(); + error Er(); + + function g0() internal pure {} + function g2() internal pure returns (uint, uint) { return (2, 3); } + + function f0() public {} + function f2(uint, uint) public {} + + function h() public view { + abi.encodeCall(this.f2, (1, 1) + (2, 2)); + abi.encodeCall(this.f0, Ev() / Er()); + abi.encodeCall(this.f0, !()); + } +} +// ---- +// TypeError 2271: (284-299): Operator + not compatible with types tuple(int_const 1,int_const 1) and tuple(int_const 2,int_const 2). +// TypeError 9062: (284-299): Expected an inline tuple, not an expression of a tuple type. +// TypeError 2271: (334-345): Operator / not compatible with types tuple() and tuple(). +// TypeError 9062: (334-345): Expected an inline tuple, not an expression of a tuple type. +// TypeError 4907: (380-383): Unary operator ! cannot be applied to type tuple(). +// TypeError 9062: (380-383): Expected an inline tuple, not an expression of a tuple type. diff --git a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_returned_from_function.sol b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_returned_from_function.sol new file mode 100644 index 000000000..ddb4934c4 --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_returned_from_function.sol @@ -0,0 +1,22 @@ +contract C { + function g0() internal pure {} + function g2() internal pure returns (uint, uint) { return (2, 3); } + + function f0() public {} + function f2(uint, uint) public {} + + function h() public view { + abi.encodeCall(this.f0, g0()); + abi.encodeCall(this.f2, g2()); + + abi.encodeCall(this.f0, (g0())); + abi.encodeCall(this.f2, (g2())); + } +} +// ---- +// TypeError 9062: (251-255): Expected an inline tuple, not an expression of a tuple type. +// TypeError 9062: (290-294): Expected an inline tuple, not an expression of a tuple type. +// TypeError 6473: (331-335): Tuple component cannot be empty. +// TypeError 7788: (306-337): Expected 0 instead of 1 components for the tuple parameter. +// TypeError 7788: (347-378): Expected 2 instead of 1 components for the tuple parameter. +// TypeError 5407: (372-376): Cannot implicitly convert component at position 0 from "tuple(uint256,uint256)" to "uint256". diff --git a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_unitary_tuple_from_assignment_expression.sol b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_unitary_tuple_from_assignment_expression.sol new file mode 100644 index 000000000..06bb65075 --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_unitary_tuple_from_assignment_expression.sol @@ -0,0 +1,13 @@ +contract C { + function g1() internal pure returns (uint) { return (1); } + + function f1(uint) public {} + + function h() public view { + uint a; + + abi.encodeCall(this.f1, (a) = g1()); + abi.encodeCall(this.f1, (a) = (1)); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_unitary_tuple_from_conditional_ternary_expression.sol b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_unitary_tuple_from_conditional_ternary_expression.sol new file mode 100644 index 000000000..518d8d32f --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_unitary_tuple_from_conditional_ternary_expression.sol @@ -0,0 +1,11 @@ +contract C { + function g1() internal pure returns (uint) { return (1); } + + function f1(uint) public {} + + function h() public view { + abi.encodeCall(this.f1, true ? (1) : (2)); + abi.encodeCall(this.f1, true ? g1() : g1()); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_unitary_tuple_returned_from_function.sol b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_unitary_tuple_returned_from_function.sol new file mode 100644 index 000000000..6308ce8f1 --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_unitary_tuple_returned_from_function.sol @@ -0,0 +1,14 @@ +contract C { + function g1() internal pure returns (uint) { return (1); } + function g2() internal pure returns (uint, uint) { return (2, 3); } + + function f1(uint) public {} + function f2(uint, uint) public {} + + function h() public view { + abi.encodeCall(this.f1, g1()); + abi.encodeCall(this.f1, (g1())); + abi.encodeCall(this.f2, (g1(), g1())); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_constructor_accepting_struct.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_constructor_accepting_struct.sol index 8ba00da1a..3ee6f75a1 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_constructor_accepting_struct.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_constructor_accepting_struct.sol @@ -18,4 +18,4 @@ contract Test { } } // ---- -// TypeError 2443: (B:91-100): The type of this parameter, struct C.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. +// TypeError 2443: (B:91-100): The type of this parameter, struct C.Item memory, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_accepting_struct_via_named_argument.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_accepting_struct_via_named_argument.sol index 417f5682f..c02faba18 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_accepting_struct_via_named_argument.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_accepting_struct_via_named_argument.sol @@ -18,4 +18,4 @@ contract Test { } } // ---- -// TypeError 2443: (B:119-129): The type of this parameter, struct C.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. +// TypeError 2443: (B:119-129): The type of this parameter, struct C.Item memory, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_pointer_accepting_struct.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_pointer_accepting_struct.sol index 1b08439cc..674ce4e32 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_pointer_accepting_struct.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_pointer_accepting_struct.sol @@ -20,4 +20,4 @@ contract Test { } } // ---- -// TypeError 2443: (B:166-175): The type of this parameter, struct C.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. +// TypeError 2443: (B:166-175): The type of this parameter, struct C.Item memory, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_dynamic_string_array.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_dynamic_string_array.sol index baadf362e..5379bdb50 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_dynamic_string_array.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_dynamic_string_array.sol @@ -14,4 +14,4 @@ contract D { } } // ---- -// TypeError 2428: (B:85-105): The type of return parameter 1, string[], is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. +// TypeError 2428: (B:85-105): The type of return parameter 1, string[] memory, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct.sol index f84a13d49..d2b0e1ffe 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct.sol @@ -18,4 +18,4 @@ contract Test { } } // ---- -// TypeError 2428: (B:90-112): The type of return parameter 1, struct C.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. +// TypeError 2428: (B:90-112): The type of return parameter 1, struct C.Item memory, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct_with_dynamic_array.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct_with_dynamic_array.sol index a67394e0e..0aa9973aa 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct_with_dynamic_array.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct_with_dynamic_array.sol @@ -18,4 +18,4 @@ contract Test { } } // ---- -// TypeError 2428: (B:90-112): The type of return parameter 1, struct C.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. +// TypeError 2428: (B:90-112): The type of return parameter 1, struct C.Item memory, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_event_accepting_struct.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_event_accepting_struct.sol index 1269a29ee..e86841868 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_event_accepting_struct.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_event_accepting_struct.sol @@ -17,4 +17,4 @@ contract Test { } } // ---- -// TypeError 2443: (B:94-104): The type of this parameter, struct L.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. +// TypeError 2443: (B:94-104): The type of this parameter, struct L.Item memory, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_bound_function_returning_struct.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_bound_function_returning_struct.sol index 149aefa96..bb3651d4f 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_bound_function_returning_struct.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_bound_function_returning_struct.sol @@ -20,4 +20,4 @@ contract D { } } // ---- -// TypeError 2428: (B:106-117): The type of return parameter 1, struct L.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. +// TypeError 2428: (B:106-117): The type of return parameter 1, struct L.Item memory, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_function_returning_struct.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_function_returning_struct.sol index b3d649e2c..c6ba75225 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_function_returning_struct.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_function_returning_struct.sol @@ -18,4 +18,4 @@ contract Test { } } // ---- -// TypeError 2428: (B:90-97): The type of return parameter 1, struct L.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. +// TypeError 2428: (B:90-97): The type of return parameter 1, struct L.Item memory, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v2_accessing_returned_dynamic_array_without_returndata_support.sol b/test/libsolidity/syntaxTests/abiEncoder/v2_accessing_returned_dynamic_array_without_returndata_support.sol index 7e97b98da..096ceea71 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v2_accessing_returned_dynamic_array_without_returndata_support.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v2_accessing_returned_dynamic_array_without_returndata_support.sol @@ -10,4 +10,4 @@ contract C { // ==== // EVMVersion: enum C.E) provided. diff --git a/test/libsolidity/syntaxTests/array/concat/bytes_concat_wrong_type_misc_literals_and_expressions.sol b/test/libsolidity/syntaxTests/array/concat/bytes_concat_wrong_type_misc_literals_and_expressions.sol index bdc451966..8d5374e84 100644 --- a/test/libsolidity/syntaxTests/array/concat/bytes_concat_wrong_type_misc_literals_and_expressions.sol +++ b/test/libsolidity/syntaxTests/array/concat/bytes_concat_wrong_type_misc_literals_and_expressions.sol @@ -46,13 +46,13 @@ contract C { // TypeError 8015: (404-448): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but int_const 2494...(42 digits omitted)...0497 provided. // TypeError 8015: (495-561): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but int_const 3027...(66 digits omitted)...5855 provided. // TypeError 8015: (596-663): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but int_const -1 provided. -// TypeError 8015: (697-782): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but bytes slice provided. +// TypeError 8015: (697-782): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but bytes memory slice provided. // TypeError 8015: (796-797): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but function () provided. // TypeError 8015: (811-813): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but tuple() provided. // TypeError 8015: (827-833): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but tuple(int_const 0,int_const 0) provided. -// TypeError 8015: (847-850): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but uint8[1] provided. -// TypeError 8015: (864-870): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but uint8[1] slice provided. +// TypeError 8015: (847-850): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but uint8[1] memory provided. +// TypeError 8015: (864-870): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but uint8[1] memory slice provided. // TypeError 8015: (884-890): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but uint8 provided. // TypeError 8015: (904-911): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but contract C provided. -// TypeError 8015: (925-929): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but struct C.S provided. +// TypeError 8015: (925-929): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but struct C.S memory provided. // TypeError 8015: (943-946): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but enum C.E provided. diff --git a/test/libsolidity/syntaxTests/array/function_mapping_library.sol b/test/libsolidity/syntaxTests/array/function_mapping_library.sol index f495362c9..2099e0dd1 100644 --- a/test/libsolidity/syntaxTests/array/function_mapping_library.sol +++ b/test/libsolidity/syntaxTests/array/function_mapping_library.sol @@ -3,4 +3,4 @@ library L { function f(mapping(uint => uint)[2] memory a) external pure returns (mapping(uint => uint)[2] memory) {} } // ---- -// TypeError 4061: (61-94): Type mapping(uint256 => uint256)[2] is only valid in storage because it contains a (nested) mapping. +// TypeError 4061: (61-94): Type mapping(uint256 => uint256)[2] memory is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/bytecode_too_large.sol b/test/libsolidity/syntaxTests/bytecode_too_large.sol index 55d637bfb..1b4d02ecb 100644 --- a/test/libsolidity/syntaxTests/bytecode_too_large.sol +++ b/test/libsolidity/syntaxTests/bytecode_too_large.sol @@ -9,4 +9,4 @@ contract test { // ==== // EVMVersion: >byzantium // ---- -// Warning 5574: (21-27154): Contract code size is 27199 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. +// Warning 5574: (21-27154): Contract code size is 27192 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. diff --git a/test/libsolidity/syntaxTests/bytecode_too_large_abiencoder_v1.sol b/test/libsolidity/syntaxTests/bytecode_too_large_abiencoder_v1.sol index 69dc7ebd0..df74ef765 100644 --- a/test/libsolidity/syntaxTests/bytecode_too_large_abiencoder_v1.sol +++ b/test/libsolidity/syntaxTests/bytecode_too_large_abiencoder_v1.sol @@ -9,4 +9,4 @@ contract test { // ==== // EVMVersion: >byzantium // ---- -// Warning 5574: (21-27154): Contract code size is 27209 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. +// Warning 5574: (21-27154): Contract code size is 27209 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. diff --git a/test/libsolidity/syntaxTests/bytecode_too_large_byzantium.sol b/test/libsolidity/syntaxTests/bytecode_too_large_byzantium.sol index a95ed192a..4f3239c22 100644 --- a/test/libsolidity/syntaxTests/bytecode_too_large_byzantium.sol +++ b/test/libsolidity/syntaxTests/bytecode_too_large_byzantium.sol @@ -7,4 +7,4 @@ contract test { // ==== // EVMVersion: =byzantium // ---- -// Warning 5574: (0-27133): Contract code size is 27227 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. +// Warning 5574: (0-27133): Contract code size is 27220 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. diff --git a/test/libsolidity/syntaxTests/constants/constant_variables_as_static_array_length.sol b/test/libsolidity/syntaxTests/constants/constant_variables_as_static_array_length.sol new file mode 100644 index 000000000..19e8bfee2 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/constant_variables_as_static_array_length.sol @@ -0,0 +1,29 @@ +uint256 constant MAX = 1; + +library L1 { + uint256 internal constant INT = 100; +} + +contract C1 { + uint256 internal constant CONST1 = L1.INT; + + uint256[L1.INT] internal arr1; // error, backward reference + uint256[L2.INT] internal arr2; // error, forward reference +} + +contract C2 is C1 { + uint256 internal constant CONST2 = CONST1; + + uint256[CONST1] internal arr3; // error, inherited constants + uint256[CONST2] internal arr4; // error, same contract constant +} + +library L2 { + uint256 internal constant INT = 100; +} + +// ---- +// TypeError 5462: (158-164): Invalid array length, expected integer literal or constant expression. +// TypeError 5462: (222-228): Invalid array length, expected integer literal or constant expression. +// TypeError 5462: (356-362): Invalid array length, expected integer literal or constant expression. +// TypeError 5462: (421-427): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/constants/constant_with_dependencies_as_array_sizes.sol b/test/libsolidity/syntaxTests/constants/constant_with_dependencies_as_array_sizes.sol new file mode 100644 index 000000000..a2a1ce20e --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/constant_with_dependencies_as_array_sizes.sol @@ -0,0 +1,35 @@ +uint256 constant MAX = 1; + +library L1 { + uint256 internal constant INT = 100; +} + +contract C1 { + uint256 internal constant CONST = 20 + L2.INT; // forward reference + uint256 internal constant LIMIT = MAX * L1.INT; // same file & external library constant + uint256 internal constant NESTED = LIMIT + CONST; // nested & same contract constant + + uint256[L1.INT] internal arr1; // error, backward reference + uint256[L2.INT] internal arr2; // error, forward reference +} + +contract C2 is C1 { + uint256 internal constant INHERITED = NESTED + CONST * LIMIT; // inherited constants +} + +contract C3 is C2 { + uint256 internal constant NESTED_INHERITED = INHERITED + NESTED + CONST * LIMIT; // nest-inherited constants + + uint256[CONST] internal arr3; // error, nest-inherited constants + uint256[NESTED_INHERITED] internal arr4; // error, same contract constant +} + +library L2 { + uint256 internal constant INT = 100; +} + +// ---- +// TypeError 5462: (366-372): Invalid array length, expected integer literal or constant expression. +// TypeError 5462: (430-436): Invalid array length, expected integer literal or constant expression. +// TypeError 5462: (742-747): Invalid array length, expected integer literal or constant expression. +// TypeError 5462: (822-838): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/constants/constant_with_dependencies_on_constants.sol b/test/libsolidity/syntaxTests/constants/constant_with_dependencies_on_constants.sol new file mode 100644 index 000000000..964ffb5f2 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/constant_with_dependencies_on_constants.sol @@ -0,0 +1,25 @@ +uint256 constant MAX = 1; + +library L1 { + uint256 internal constant INT = 100; +} + +contract C1 { + uint256 internal constant CONST = 20 + L2.INT; // forward reference + uint256 internal constant LIMIT = MAX * L1.INT; // same file & external library constant + uint256 internal constant NESTED = LIMIT + CONST; // nested & same contract constant +} + +contract C2 is C1 { + uint256 internal constant INHERITED = NESTED + CONST * LIMIT; // inherited constants +} + +contract C3 is C2 { + uint256 internal constant NESTED_INHERITED = INHERITED + NESTED + CONST * LIMIT; // nest-inherited constants +} + +library L2 { + uint256 internal constant INT = 100; +} + +// ---- diff --git a/test/libsolidity/syntaxTests/constants/constant_with_dependencies_on_file_level_constants.sol b/test/libsolidity/syntaxTests/constants/constant_with_dependencies_on_file_level_constants.sol new file mode 100644 index 000000000..9bb1723e7 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/constant_with_dependencies_on_file_level_constants.sol @@ -0,0 +1,11 @@ +==== Source: A.sol ==== +import "B.sol" as B; + +uint constant X = 1; +uint constant Y = B.Y; + +==== Source: B.sol ==== +import "A.sol" as A; + +uint constant X = A.X; +uint constant Y = 2; diff --git a/test/libsolidity/syntaxTests/constants/constants_with_dependencies_on_library_constants_multi_file.sol b/test/libsolidity/syntaxTests/constants/constants_with_dependencies_on_library_constants_multi_file.sol new file mode 100644 index 000000000..4518a510a --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/constants_with_dependencies_on_library_constants_multi_file.sol @@ -0,0 +1,17 @@ +==== Source: A.sol ==== +import "B.sol"; + +library L { + uint constant X = 1; + uint constant Y = K.Y; +} + +==== Source: B.sol ==== +import "A.sol"; + +library K { + uint constant X = L.X; + uint constant Y = 2; +} + +// ==== diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_file_and_library_constants.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_file_and_library_constants.sol new file mode 100644 index 000000000..92f5dfce6 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_file_and_library_constants.sol @@ -0,0 +1,15 @@ +==== Source: A.sol ==== +import "B.sol"; + +uint256 constant A = B.VAL + 1; + +==== Source: B.sol ==== +import "A.sol"; + +library B { + uint256 constant VAL = A + 1; +} + +// ---- +// TypeError 6161: (B.sol:33-61): The value of the constant VAL has a cyclic dependency via A. +// TypeError 6161: (A.sol:17-47): The value of the constant A has a cyclic dependency via VAL. diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_file_constants.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_file_constants.sol new file mode 100644 index 000000000..d874abba7 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_file_constants.sol @@ -0,0 +1,13 @@ +==== Source: A.sol ==== +import "B.sol"; + +uint256 constant A = B + 1; + +==== Source: B.sol ==== +import "A.sol"; + +uint256 constant B = A + 1; + +// ---- +// TypeError 6161: (B.sol:17-43): The value of the constant B has a cyclic dependency via A. +// TypeError 6161: (A.sol:17-43): The value of the constant A has a cyclic dependency via B. diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_library_constants.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_library_constants.sol new file mode 100644 index 000000000..d72ea0a66 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_library_constants.sol @@ -0,0 +1,11 @@ +library A { + uint256 constant VAL = B.VAL + 1; +} + +library B { + uint256 constant VAL = A.VAL + 1; +} + +// ---- +// TypeError 6161: (16-48): The value of the constant VAL has a cyclic dependency via VAL. +// TypeError 6161: (69-101): The value of the constant VAL has a cyclic dependency via VAL. diff --git a/test/libsolidity/syntaxTests/conversion/explicit_conversion_error_to_bytes4.sol b/test/libsolidity/syntaxTests/conversion/explicit_conversion_error_to_bytes4.sol new file mode 100644 index 000000000..309dccabd --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/explicit_conversion_error_to_bytes4.sol @@ -0,0 +1,11 @@ +interface MyInterface { + error MyCustomError(uint256, bool); +} + +contract Test { + function test() public returns(bytes4) { + return bytes4(MyInterface.MyCustomError); + } +} +// ---- +// TypeError 9640: (143-176): Explicit type conversion not allowed from "error MyCustomError(uint256,bool)" to "bytes4". diff --git a/test/libsolidity/syntaxTests/conversion/explicit_conversion_event_to_bytes4.sol b/test/libsolidity/syntaxTests/conversion/explicit_conversion_event_to_bytes4.sol new file mode 100644 index 000000000..dd036791f --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/explicit_conversion_event_to_bytes4.sol @@ -0,0 +1,9 @@ +contract Test { + event MyCustomEvent(uint256); + + function test() public returns(bytes4) { + return bytes4(MyCustomEvent); + } +} +// ---- +// TypeError 9640: (111-132): Explicit type conversion not allowed from "event MyCustomEvent(uint256)" to "bytes4". diff --git a/test/libsolidity/syntaxTests/conversion/explicit_conversion_from_error.sol b/test/libsolidity/syntaxTests/conversion/explicit_conversion_from_error.sol new file mode 100644 index 000000000..b13067e03 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/explicit_conversion_from_error.sol @@ -0,0 +1,28 @@ +interface MyInterface { + enum MyEnum { E1, E2 } + error CustomError1( + uint256, + bool, + bool[], + address payable, + MyInterface, + MyEnum, + function (string memory) external returns (uint) + ); +} + +contract Test { + function testFunction(string memory) external returns (uint) {} + + function test() public { + MyInterface instance = MyInterface(msg.sender); + bool[] calldata arr; + address payable addr; + bytes4(MyInterface.CustomEror1); + bytes4(MyInterface.CustomError1()); + bytes4(MyInterface.CustomError1(1, true, arr, addr, instance, MyInterface.MyEnum.E1, this.testFunction)); + address(MyInterface.CustomError1); + } +} +// ---- +// TypeError 9582: (495-518): Member "CustomEror1" not found or not visible after argument-dependent lookup in type(contract MyInterface). diff --git a/test/libsolidity/syntaxTests/conversion/explicit_conversion_from_event.sol b/test/libsolidity/syntaxTests/conversion/explicit_conversion_from_event.sol new file mode 100644 index 000000000..62edf7de8 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/explicit_conversion_from_event.sol @@ -0,0 +1,34 @@ +interface MyInterface { + enum MyEnum { E1, E2 } +} + +contract Test { + function testFunction(string memory) external returns (uint) {} + + event CustomEvent1( + uint256, + bool, + bool[], + address payable, + MyInterface, + MyInterface.MyEnum, + function (string memory) external returns (uint) + ); + + + function test() public { + MyInterface instance = MyInterface(msg.sender); + bool[] calldata arr; + address payable addr; + bytes4(CustomEvent1); + bytes4(CustomEvent1()); + bytes4(CustomEvent1(1, true, arr, addr, instance, MyInterface.MyEnum.E1, this.testFunction)); + address(CustomEvent1); + } +} +// ---- +// TypeError 9640: (502-522): Explicit type conversion not allowed from "event CustomEvent1(uint256,bool,bool[],address payable,contract MyInterface,enum MyInterface.MyEnum,function (string) external returns (uint256))" to "bytes4". +// TypeError 6160: (539-553): Wrong argument count for function call: 0 arguments given but expected 7. +// TypeError 9640: (532-554): Explicit type conversion not allowed from "tuple()" to "bytes4". +// TypeError 9640: (564-656): Explicit type conversion not allowed from "tuple()" to "bytes4". +// TypeError 9640: (666-687): Explicit type conversion not allowed from "event CustomEvent1(uint256,bool,bool[],address payable,contract MyInterface,enum MyInterface.MyEnum,function (string) external returns (uint256))" to "address". diff --git a/test/libsolidity/syntaxTests/conversion/implicit_conversion_error_to_bytes4_function_argument.sol b/test/libsolidity/syntaxTests/conversion/implicit_conversion_error_to_bytes4_function_argument.sol new file mode 100644 index 000000000..51dce0986 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/implicit_conversion_error_to_bytes4_function_argument.sol @@ -0,0 +1,12 @@ +interface MyInterface { + error MyCustomError(uint256, bool); +} + +contract MyContract { + function f(bytes4 arg) public {} + function test() public { + f(MyInterface.MyCustomError); + } +} +// ---- +// TypeError 9553: (165-190): Invalid type for argument in function call. Invalid implicit conversion from error MyCustomError(uint256,bool) to bytes4 requested. diff --git a/test/libsolidity/syntaxTests/conversion/implicit_conversion_error_to_bytes4_return_value.sol b/test/libsolidity/syntaxTests/conversion/implicit_conversion_error_to_bytes4_return_value.sol new file mode 100644 index 000000000..c3deea881 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/implicit_conversion_error_to_bytes4_return_value.sol @@ -0,0 +1,11 @@ +interface MyInterface { + error MyCustomError(uint256, bool); +} + +contract Test { + function test() public returns(bytes4) { + return (MyInterface.MyCustomError); + } +} +// ---- +// TypeError 6359: (143-170): Return argument type error MyCustomError(uint256,bool) is not implicitly convertible to expected type (type of first return variable) bytes4. diff --git a/test/libsolidity/syntaxTests/conversion/implicit_conversion_event_to_bytes4_function_argument.sol b/test/libsolidity/syntaxTests/conversion/implicit_conversion_event_to_bytes4_function_argument.sol new file mode 100644 index 000000000..96b643a62 --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/implicit_conversion_event_to_bytes4_function_argument.sol @@ -0,0 +1,9 @@ +contract MyContract { + event MyCustomEvent(uint256); + function f(bytes4 arg) public {} + function test() public { + f(MyCustomEvent); + } +} +// ---- +// TypeError 9553: (132-145): Invalid type for argument in function call. Invalid implicit conversion from event MyCustomEvent(uint256) to bytes4 requested. diff --git a/test/libsolidity/syntaxTests/conversion/implicit_conversion_event_to_bytes4_return_value.sol b/test/libsolidity/syntaxTests/conversion/implicit_conversion_event_to_bytes4_return_value.sol new file mode 100644 index 000000000..70523821d --- /dev/null +++ b/test/libsolidity/syntaxTests/conversion/implicit_conversion_event_to_bytes4_return_value.sol @@ -0,0 +1,9 @@ +contract Test { + event MyCustomEvent(uint256); + + function test() public returns(bytes4) { + return (MyCustomEvent); + } +} +// ---- +// TypeError 6359: (111-126): Return argument type event MyCustomEvent(uint256) is not implicitly convertible to expected type (type of first return variable) bytes4. diff --git a/test/libsolidity/syntaxTests/conversion/implicit_conversion_from_array_of_string_literals_to_calldata_string.sol b/test/libsolidity/syntaxTests/conversion/implicit_conversion_from_array_of_string_literals_to_calldata_string.sol index b9f95df66..cd74b985c 100644 --- a/test/libsolidity/syntaxTests/conversion/implicit_conversion_from_array_of_string_literals_to_calldata_string.sol +++ b/test/libsolidity/syntaxTests/conversion/implicit_conversion_from_array_of_string_literals_to_calldata_string.sol @@ -6,4 +6,4 @@ contract C { } } // ---- -// TypeError 6359: (122-147): Return argument type string memory[5] memory is not implicitly convertible to expected type (type of first return variable) string calldata[5] calldata. +// TypeError 6359: (122-147): Return argument type string[5] memory is not implicitly convertible to expected type (type of first return variable) string[5] calldata. diff --git a/test/libsolidity/syntaxTests/conversion/implicit_conversion_of_super_in_comparison.sol b/test/libsolidity/syntaxTests/conversion/implicit_conversion_of_super_in_comparison.sol index d07594b09..8087b6b33 100644 --- a/test/libsolidity/syntaxTests/conversion/implicit_conversion_of_super_in_comparison.sol +++ b/test/libsolidity/syntaxTests/conversion/implicit_conversion_of_super_in_comparison.sol @@ -19,9 +19,9 @@ contract C { } } // ---- -// TypeError 2271: (144-157): Operator != not compatible with types type(contract super C) and contract C -// TypeError 2271: (167-180): Operator != not compatible with types contract C and type(contract super C) -// TypeError 2271: (254-264): Operator != not compatible with types type(contract super C) and contract C -// TypeError 2271: (274-284): Operator != not compatible with types contract C and type(contract super C) -// TypeError 2271: (349-359): Operator != not compatible with types type(contract super C) and contract D -// TypeError 2271: (369-379): Operator != not compatible with types contract D and type(contract super C) +// TypeError 2271: (144-157): Operator != not compatible with types type(contract super C) and contract C. +// TypeError 2271: (167-180): Operator != not compatible with types contract C and type(contract super C). +// TypeError 2271: (254-264): Operator != not compatible with types type(contract super C) and contract C. +// TypeError 2271: (274-284): Operator != not compatible with types contract C and type(contract super C). +// TypeError 2271: (349-359): Operator != not compatible with types type(contract super C) and contract D. +// TypeError 2271: (369-379): Operator != not compatible with types contract D and type(contract super C). diff --git a/test/libsolidity/syntaxTests/conversion/implicit_conversion_of_super_in_operators.sol b/test/libsolidity/syntaxTests/conversion/implicit_conversion_of_super_in_operators.sol index 8a803a233..045611306 100644 --- a/test/libsolidity/syntaxTests/conversion/implicit_conversion_of_super_in_operators.sol +++ b/test/libsolidity/syntaxTests/conversion/implicit_conversion_of_super_in_operators.sol @@ -30,27 +30,27 @@ contract C { } } // ---- -// TypeError 2271: (49-62): Operator << not compatible with types type(contract super C) and contract C -// TypeError 2271: (72-85): Operator >> not compatible with types type(contract super C) and contract C -// TypeError 2271: (95-107): Operator ^ not compatible with types type(contract super C) and contract C -// TypeError 2271: (117-129): Operator | not compatible with types type(contract super C) and contract C -// TypeError 2271: (139-151): Operator & not compatible with types type(contract super C) and contract C -// TypeError 2271: (162-174): Operator * not compatible with types type(contract super C) and contract C -// TypeError 2271: (184-196): Operator / not compatible with types type(contract super C) and contract C -// TypeError 2271: (206-218): Operator % not compatible with types type(contract super C) and contract C -// TypeError 2271: (228-240): Operator - not compatible with types type(contract super C) and contract C -// TypeError 2271: (250-262): Operator + not compatible with types type(contract super C) and contract C -// TypeError 2271: (272-285): Operator ** not compatible with types type(contract super C) and contract C -// TypeError 2271: (296-309): Operator == not compatible with types type(contract super C) and contract C -// TypeError 2271: (319-332): Operator != not compatible with types type(contract super C) and contract C -// TypeError 2271: (342-355): Operator >= not compatible with types type(contract super C) and contract C -// TypeError 2271: (365-378): Operator <= not compatible with types type(contract super C) and contract C -// TypeError 2271: (388-400): Operator < not compatible with types type(contract super C) and contract C -// TypeError 2271: (410-422): Operator > not compatible with types type(contract super C) and contract C -// TypeError 2271: (433-446): Operator || not compatible with types type(contract super C) and contract C -// TypeError 2271: (456-469): Operator && not compatible with types type(contract super C) and contract C +// TypeError 2271: (49-62): Operator << not compatible with types type(contract super C) and contract C. +// TypeError 2271: (72-85): Operator >> not compatible with types type(contract super C) and contract C. +// TypeError 2271: (95-107): Operator ^ not compatible with types type(contract super C) and contract C. +// TypeError 2271: (117-129): Operator | not compatible with types type(contract super C) and contract C. +// TypeError 2271: (139-151): Operator & not compatible with types type(contract super C) and contract C. +// TypeError 2271: (162-174): Operator * not compatible with types type(contract super C) and contract C. +// TypeError 2271: (184-196): Operator / not compatible with types type(contract super C) and contract C. +// TypeError 2271: (206-218): Operator % not compatible with types type(contract super C) and contract C. +// TypeError 2271: (228-240): Operator - not compatible with types type(contract super C) and contract C. +// TypeError 2271: (250-262): Operator + not compatible with types type(contract super C) and contract C. +// TypeError 2271: (272-285): Operator ** not compatible with types type(contract super C) and contract C. +// TypeError 2271: (296-309): Operator == not compatible with types type(contract super C) and contract C. +// TypeError 2271: (319-332): Operator != not compatible with types type(contract super C) and contract C. +// TypeError 2271: (342-355): Operator >= not compatible with types type(contract super C) and contract C. +// TypeError 2271: (365-378): Operator <= not compatible with types type(contract super C) and contract C. +// TypeError 2271: (388-400): Operator < not compatible with types type(contract super C) and contract C. +// TypeError 2271: (410-422): Operator > not compatible with types type(contract super C) and contract C. +// TypeError 2271: (433-446): Operator || not compatible with types type(contract super C) and contract C. +// TypeError 2271: (456-469): Operator && not compatible with types type(contract super C) and contract C. // TypeError 4247: (480-485): Expression has to be an lvalue. -// TypeError 7366: (480-493): Operator -= not compatible with types type(contract super C) and contract C +// TypeError 7366: (480-493): Operator -= not compatible with types type(contract super C) and contract C. // TypeError 4247: (503-508): Expression has to be an lvalue. -// TypeError 7366: (503-516): Operator += not compatible with types type(contract super C) and contract C +// TypeError 7366: (503-516): Operator += not compatible with types type(contract super C) and contract C. // TypeError 1080: (527-546): True expression's type type(contract super C) does not match false expression's type contract C. diff --git a/test/libsolidity/syntaxTests/errors/bytes_concat_on_error_type_info.sol b/test/libsolidity/syntaxTests/errors/bytes_concat_on_error_type_info.sol new file mode 100644 index 000000000..4b8bbd459 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/bytes_concat_on_error_type_info.sol @@ -0,0 +1,9 @@ +error MyCustomError(uint, bool); +contract C { + function f() public { + bytes memory a; + bytes memory b = type(MyCustomError).concat(a); + } +} +// ---- +// TypeError 4259: (126-139): Invalid type for argument in the function call. An enum type, contract type or an integer type is required, but error MyCustomError(uint256,bool) provided. diff --git a/test/libsolidity/syntaxTests/errors/error_abi_decode.sol b/test/libsolidity/syntaxTests/errors/error_abi_decode.sol new file mode 100644 index 000000000..8f9f831dc --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_abi_decode.sol @@ -0,0 +1,8 @@ +error MyCustomError(uint, bool); +contract Test { + function f() public { + abi.decode(MyCustomError, (bool)); + } +} +// ---- +// TypeError 1956: (94-107): The first argument to "abi.decode" must be implicitly convertible to bytes memory or bytes calldata, but is of type error MyCustomError(uint256,bool). diff --git a/test/libsolidity/syntaxTests/errors/error_bytes_concat_wrong_type.sol b/test/libsolidity/syntaxTests/errors/error_bytes_concat_wrong_type.sol new file mode 100644 index 000000000..c26d7230e --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_bytes_concat_wrong_type.sol @@ -0,0 +1,10 @@ +error MyCustomError(uint, bool); + +contract C { + function f() pure public { + bytes.concat(MyCustomError, MyCustomError); + } +} +// ---- +// TypeError 8015: (99-112): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but error MyCustomError(uint256,bool) provided. +// TypeError 8015: (114-127): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but error MyCustomError(uint256,bool) provided. diff --git a/test/libsolidity/syntaxTests/errors/error_encodecall_fail_args.sol b/test/libsolidity/syntaxTests/errors/error_encodecall_fail_args.sol new file mode 100644 index 000000000..b49b4be51 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_encodecall_fail_args.sol @@ -0,0 +1,40 @@ +error MyCustomError(uint, bool); +contract C { + enum testEnum { choice1, choice2, choice3 } + + function f1(uint8, uint8) external {} + function f2(uint32) external {} + function f3(uint) external {} + function g1(bytes memory) external {} + function g2(bytes32) external {} + function h(string memory) external {} + function i(bool) external {} + function j(address) external {} + function k(address payable) external {} + function l(testEnum) external {} + + function f() pure public { + abi.encodeCall(this.f1, (MyCustomError, MyCustomError)); + abi.encodeCall(this.f2, (MyCustomError)); + abi.encodeCall(this.f3, (MyCustomError)); + abi.encodeCall(this.g1, (MyCustomError)); + abi.encodeCall(this.g2, (MyCustomError)); + abi.encodeCall(this.h, (MyCustomError)); + abi.encodeCall(this.i, (MyCustomError)); + abi.encodeCall(this.j, (MyCustomError)); + abi.encodeCall(this.k, (MyCustomError)); + abi.encodeCall(this.l, (MyCustomError)); + } +} +// ---- +// TypeError 5407: (543-556): Cannot implicitly convert component at position 0 from "error MyCustomError(uint256,bool)" to "uint8". +// TypeError 5407: (558-571): Cannot implicitly convert component at position 1 from "error MyCustomError(uint256,bool)" to "uint8". +// TypeError 5407: (607-622): Cannot implicitly convert component at position 0 from "error MyCustomError(uint256,bool)" to "uint32". +// TypeError 5407: (657-672): Cannot implicitly convert component at position 0 from "error MyCustomError(uint256,bool)" to "uint256". +// TypeError 5407: (707-722): Cannot implicitly convert component at position 0 from "error MyCustomError(uint256,bool)" to "bytes memory". +// TypeError 5407: (757-772): Cannot implicitly convert component at position 0 from "error MyCustomError(uint256,bool)" to "bytes32". +// TypeError 5407: (806-821): Cannot implicitly convert component at position 0 from "error MyCustomError(uint256,bool)" to "string memory". +// TypeError 5407: (855-870): Cannot implicitly convert component at position 0 from "error MyCustomError(uint256,bool)" to "bool". +// TypeError 5407: (904-919): Cannot implicitly convert component at position 0 from "error MyCustomError(uint256,bool)" to "address". +// TypeError 5407: (953-968): Cannot implicitly convert component at position 0 from "error MyCustomError(uint256,bool)" to "address payable". +// TypeError 5407: (1002-1017): Cannot implicitly convert component at position 0 from "error MyCustomError(uint256,bool)" to "enum C.testEnum". diff --git a/test/libsolidity/syntaxTests/errors/error_incompatible_binary_ops.sol b/test/libsolidity/syntaxTests/errors/error_incompatible_binary_ops.sol new file mode 100644 index 000000000..3f18bbf19 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_incompatible_binary_ops.sol @@ -0,0 +1,47 @@ +error MyCustomError(uint, bool); + +contract C { + function f() pure public { + MyCustomError << MyCustomError; + MyCustomError >> MyCustomError; + MyCustomError ^ MyCustomError; + MyCustomError | MyCustomError; + MyCustomError & MyCustomError; + + MyCustomError * MyCustomError; + MyCustomError / MyCustomError; + MyCustomError % MyCustomError; + MyCustomError + MyCustomError; + MyCustomError - MyCustomError; + + MyCustomError == MyCustomError; + MyCustomError != MyCustomError; + MyCustomError >= MyCustomError; + MyCustomError <= MyCustomError; + MyCustomError < MyCustomError; + MyCustomError > MyCustomError; + + MyCustomError || MyCustomError; + MyCustomError && MyCustomError; + } +} + +// ---- +// TypeError 2271: (86-116): Operator << not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (126-156): Operator >> not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (166-195): Operator ^ not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (205-234): Operator | not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (244-273): Operator & not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (284-313): Operator * not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (323-352): Operator / not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (362-391): Operator % not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (401-430): Operator + not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (440-469): Operator - not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (480-510): Operator == not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (520-550): Operator != not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (560-590): Operator >= not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (600-630): Operator <= not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (640-669): Operator < not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (679-708): Operator > not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (719-749): Operator || not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). +// TypeError 2271: (759-789): Operator && not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool). diff --git a/test/libsolidity/syntaxTests/errors/error_incompatible_operator_for_type.sol b/test/libsolidity/syntaxTests/errors/error_incompatible_operator_for_type.sol new file mode 100644 index 000000000..61463e587 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_incompatible_operator_for_type.sol @@ -0,0 +1,19 @@ +error MyCustomError(uint, bool); + +contract C { + function f() pure public { + uint a; + MyCustomError += 1; + MyCustomError -= 1; + a += MyCustomError; + a -= MyCustomError; + } +} + +// ---- +// TypeError 4247: (102-115): Expression has to be an lvalue. +// TypeError 7366: (102-120): Operator += not compatible with types error MyCustomError(uint256,bool) and int_const 1. +// TypeError 4247: (130-143): Expression has to be an lvalue. +// TypeError 7366: (130-148): Operator -= not compatible with types error MyCustomError(uint256,bool) and int_const 1. +// TypeError 7366: (158-176): Operator += not compatible with types uint256 and error MyCustomError(uint256,bool). +// TypeError 7366: (186-204): Operator -= not compatible with types uint256 and error MyCustomError(uint256,bool). diff --git a/test/libsolidity/syntaxTests/errors/error_incompatible_unary_operator.sol b/test/libsolidity/syntaxTests/errors/error_incompatible_unary_operator.sol new file mode 100644 index 000000000..f4bc34ca4 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_incompatible_unary_operator.sol @@ -0,0 +1,11 @@ +error MyCustomError(uint, bool); + +contract C { + function f() pure public { + MyCustomError++; + } +} + +// ---- +// TypeError 4247: (86-99): Expression has to be an lvalue. +// TypeError 9767: (86-101): Unary operator ++ cannot be applied to type error MyCustomError(uint256,bool). diff --git a/test/libsolidity/syntaxTests/errors/error_invalid_function_modifier_type.sol b/test/libsolidity/syntaxTests/errors/error_invalid_function_modifier_type.sol new file mode 100644 index 000000000..0f1ce2c77 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_invalid_function_modifier_type.sol @@ -0,0 +1,9 @@ +error MyCustomError(uint, bool); + +contract B { + function f() mod1(MyCustomError) public { } + modifier mod1(uint a) { if (a > 0) _; } +} + +// ---- +// TypeError 4649: (69-82): Invalid type for argument in modifier invocation. Invalid implicit conversion from error MyCustomError(uint256,bool) to uint256 requested. diff --git a/test/libsolidity/syntaxTests/errors/error_return_tuple_not_convertible.sol b/test/libsolidity/syntaxTests/errors/error_return_tuple_not_convertible.sol new file mode 100644 index 000000000..05d9df179 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_return_tuple_not_convertible.sol @@ -0,0 +1,10 @@ +error MyCustomError(uint, bool); + +contract C { + function f() public returns (uint8, uint8, int) { + return ((MyCustomError, 8, MyCustomError)); + } +} + +// ---- +// TypeError 5992: (116-151): Return argument type tuple(error MyCustomError(uint256,bool),int_const 8,error MyCustomError(uint256,bool)) is not implicitly convertible to expected type tuple(uint8,uint8,int256). diff --git a/test/libsolidity/syntaxTests/errors/error_selector_syntax.sol b/test/libsolidity/syntaxTests/errors/error_selector_syntax.sol new file mode 100644 index 000000000..1af3bbcd2 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_selector_syntax.sol @@ -0,0 +1,34 @@ +library L { + error E(bytes4, bool, bytes); +} + +error E(bytes4, bool, bytes); + +interface I { + error E(bytes4, bool, bytes); +} + +contract B { + error E(bytes4, bool, bytes); +} + +contract C is B { + bytes4 public librarySelector = L.E.selector; + bytes4 internal freeSelector = E.selector; + bytes4 internal contractSelector = B.E.selector; + bytes4 private interfaceSelector = I.E.selector; + + function f(bool condition) public view { + assert(librarySelector == L.E.selector); + assert(E.selector == B.E.selector); + + if (condition) + revert E(E.selector, true, "123"); + else + revert L.E((B.E.selector), true, "123"); + } +} +// ---- +// Warning 2519: (16-45): This declaration shadows an existing declaration. +// Warning 2519: (98-127): This declaration shadows an existing declaration. +// Warning 2519: (148-177): This declaration shadows an existing declaration. diff --git a/test/libsolidity/syntaxTests/errors/error_ternary_operator_different_types.sol b/test/libsolidity/syntaxTests/errors/error_ternary_operator_different_types.sol new file mode 100644 index 000000000..680ab8058 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_ternary_operator_different_types.sol @@ -0,0 +1,18 @@ +error MyCustomError(uint, bool); +error MyCustomError2(uint, bool); +error MyCustomError3(uint, bool, bool); + +contract C { + function f() pure public { + true ? MyCustomError : MyCustomError; + true ? MyCustomError : MyCustomError2; + true ? MyCustomError : MyCustomError3; + true ? MyCustomError : true; + true ? true : MyCustomError; + } +} + +// ---- +// TypeError 1080: (253-290): True expression's type error MyCustomError(uint256,bool) does not match false expression's type error MyCustomError3(uint256,bool,bool). +// TypeError 1080: (300-327): True expression's type error MyCustomError(uint256,bool) does not match false expression's type bool. +// TypeError 1080: (337-364): True expression's type bool does not match false expression's type error MyCustomError(uint256,bool). diff --git a/test/libsolidity/syntaxTests/errors/error_to_function_conversion.sol b/test/libsolidity/syntaxTests/errors/error_to_function_conversion.sol new file mode 100644 index 000000000..e37a6892d --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_to_function_conversion.sol @@ -0,0 +1,7 @@ +error E(); + +contract C { + function() internal pure x = E; +} +// ---- +// TypeError 7407: (58-59): Type error E() is not implicitly convertible to expected type function () pure. Special functions can not be converted to function types. diff --git a/test/libsolidity/syntaxTests/errors/error_variable_declaration_implicit_conversion.sol b/test/libsolidity/syntaxTests/errors/error_variable_declaration_implicit_conversion.sol new file mode 100644 index 000000000..bca9acc0b --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_variable_declaration_implicit_conversion.sol @@ -0,0 +1,10 @@ +error MyCustomError(uint, bool); + +contract C { + function f() public { + bytes4 a = MyCustomError; + } +} + +// ---- +// TypeError 9574: (81-105): Type error MyCustomError(uint256,bool) is not implicitly convertible to expected type bytes4. diff --git a/test/libsolidity/syntaxTests/errors/error_wrong_type_base_arg.sol b/test/libsolidity/syntaxTests/errors/error_wrong_type_base_arg.sol new file mode 100644 index 000000000..69fc60735 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/error_wrong_type_base_arg.sol @@ -0,0 +1,10 @@ +error MyCustomError(uint, bool); + +contract Base { + constructor(uint8) {} +} + +contract Derived is Base(MyCustomError) {} + +// ---- +// TypeError 9827: (104-117): Invalid type for argument in constructor call. Invalid implicit conversion from error MyCustomError(uint256,bool) to uint8 requested. diff --git a/test/libsolidity/syntaxTests/errors/using.sol b/test/libsolidity/syntaxTests/errors/using.sol index 388fa52ab..ad5a43f86 100644 --- a/test/libsolidity/syntaxTests/errors/using.sol +++ b/test/libsolidity/syntaxTests/errors/using.sol @@ -9,4 +9,4 @@ contract C { } } // ---- -// TypeError 9582: (133-136): Member "f" not found or not visible after argument-dependent lookup in function (uint256) pure. +// TypeError 9582: (133-136): Member "f" not found or not visible after argument-dependent lookup in error E(uint256). diff --git a/test/libsolidity/syntaxTests/events/bytes_concat_on_event_type_info.sol b/test/libsolidity/syntaxTests/events/bytes_concat_on_event_type_info.sol new file mode 100644 index 000000000..40323830e --- /dev/null +++ b/test/libsolidity/syntaxTests/events/bytes_concat_on_event_type_info.sol @@ -0,0 +1,9 @@ +contract C { + event MyCustomEvent(uint); + function f() public { + bytes memory a; + bytes memory b = type(MyCustomEvent).concat(a); + } +} +// ---- +// TypeError 4259: (124-137): Invalid type for argument in the function call. An enum type, contract type or an integer type is required, but event MyCustomEvent(uint256) provided. diff --git a/test/libsolidity/syntaxTests/events/event_abi_decode.sol b/test/libsolidity/syntaxTests/events/event_abi_decode.sol new file mode 100644 index 000000000..6895d7790 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_abi_decode.sol @@ -0,0 +1,8 @@ +contract Test { + event E(uint); + function f() public { + abi.decode(E, (bool)); + } +} +// ---- +// TypeError 1956: (80-81): The first argument to "abi.decode" must be implicitly convertible to bytes memory or bytes calldata, but is of type event E(uint256). diff --git a/test/libsolidity/syntaxTests/events/event_bytes_concat_wrong_type.sol b/test/libsolidity/syntaxTests/events/event_bytes_concat_wrong_type.sol new file mode 100644 index 000000000..7ec5188cc --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_bytes_concat_wrong_type.sol @@ -0,0 +1,9 @@ +contract C { + event MyCustomEvent(uint); + function f() pure public { + bytes.concat(MyCustomEvent, MyCustomEvent); + } +} +// ---- +// TypeError 8015: (96-109): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but event MyCustomEvent(uint256) provided. +// TypeError 8015: (111-124): Invalid type for argument in the bytes.concat function call. bytes or fixed bytes type is required, but event MyCustomEvent(uint256) provided. diff --git a/test/libsolidity/syntaxTests/events/event_encodecall_fail_args.sol b/test/libsolidity/syntaxTests/events/event_encodecall_fail_args.sol new file mode 100644 index 000000000..9137fd26f --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_encodecall_fail_args.sol @@ -0,0 +1,41 @@ +contract C { + event MyCustomEvent(uint); + + enum testEnum { choice1, choice2, choice3 } + + function f1(uint8, uint8) external {} + function f2(uint32) external {} + function f3(uint) external {} + function g1(bytes memory) external {} + function g2(bytes32) external {} + function h(string memory) external {} + function i(bool) external {} + function j(address) external {} + function k(address payable) external {} + function l(testEnum) external {} + + function f() pure public { + abi.encodeCall(this.f1, (MyCustomEvent, MyCustomEvent)); + abi.encodeCall(this.f2, (MyCustomEvent)); + abi.encodeCall(this.f3, (MyCustomEvent)); + abi.encodeCall(this.g1, (MyCustomEvent)); + abi.encodeCall(this.g2, (MyCustomEvent)); + abi.encodeCall(this.h, (MyCustomEvent)); + abi.encodeCall(this.i, (MyCustomEvent)); + abi.encodeCall(this.j, (MyCustomEvent)); + abi.encodeCall(this.k, (MyCustomEvent)); + abi.encodeCall(this.l, (MyCustomEvent)); + } +} +// ---- +// TypeError 5407: (542-555): Cannot implicitly convert component at position 0 from "event MyCustomEvent(uint256)" to "uint8". +// TypeError 5407: (557-570): Cannot implicitly convert component at position 1 from "event MyCustomEvent(uint256)" to "uint8". +// TypeError 5407: (606-621): Cannot implicitly convert component at position 0 from "event MyCustomEvent(uint256)" to "uint32". +// TypeError 5407: (656-671): Cannot implicitly convert component at position 0 from "event MyCustomEvent(uint256)" to "uint256". +// TypeError 5407: (706-721): Cannot implicitly convert component at position 0 from "event MyCustomEvent(uint256)" to "bytes memory". +// TypeError 5407: (756-771): Cannot implicitly convert component at position 0 from "event MyCustomEvent(uint256)" to "bytes32". +// TypeError 5407: (805-820): Cannot implicitly convert component at position 0 from "event MyCustomEvent(uint256)" to "string memory". +// TypeError 5407: (854-869): Cannot implicitly convert component at position 0 from "event MyCustomEvent(uint256)" to "bool". +// TypeError 5407: (903-918): Cannot implicitly convert component at position 0 from "event MyCustomEvent(uint256)" to "address". +// TypeError 5407: (952-967): Cannot implicitly convert component at position 0 from "event MyCustomEvent(uint256)" to "address payable". +// TypeError 5407: (1001-1016): Cannot implicitly convert component at position 0 from "event MyCustomEvent(uint256)" to "enum C.testEnum". diff --git a/test/libsolidity/syntaxTests/events/event_incompatible_binary_ops.sol b/test/libsolidity/syntaxTests/events/event_incompatible_binary_ops.sol new file mode 100644 index 000000000..1537f8edf --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_incompatible_binary_ops.sol @@ -0,0 +1,46 @@ +contract C { + event MyCustomEvent(uint); + function f() pure public { + MyCustomEvent << MyCustomEvent; + MyCustomEvent >> MyCustomEvent; + MyCustomEvent ^ MyCustomEvent; + MyCustomEvent | MyCustomEvent; + MyCustomEvent & MyCustomEvent; + + MyCustomEvent * MyCustomEvent; + MyCustomEvent / MyCustomEvent; + MyCustomEvent % MyCustomEvent; + MyCustomEvent + MyCustomEvent; + MyCustomEvent - MyCustomEvent; + + MyCustomEvent == MyCustomEvent; + MyCustomEvent != MyCustomEvent; + MyCustomEvent >= MyCustomEvent; + MyCustomEvent <= MyCustomEvent; + MyCustomEvent < MyCustomEvent; + MyCustomEvent > MyCustomEvent; + + MyCustomEvent || MyCustomEvent; + MyCustomEvent && MyCustomEvent; + } +} + +// ---- +// TypeError 2271: (83-113): Operator << not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (123-153): Operator >> not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (163-192): Operator ^ not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (202-231): Operator | not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (241-270): Operator & not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (281-310): Operator * not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (320-349): Operator / not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (359-388): Operator % not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (398-427): Operator + not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (437-466): Operator - not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (477-507): Operator == not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (517-547): Operator != not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (557-587): Operator >= not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (597-627): Operator <= not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (637-666): Operator < not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (676-705): Operator > not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (716-746): Operator || not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). +// TypeError 2271: (756-786): Operator && not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256). diff --git a/test/libsolidity/syntaxTests/events/event_incompatible_operator_for_type.sol b/test/libsolidity/syntaxTests/events/event_incompatible_operator_for_type.sol new file mode 100644 index 000000000..64d629551 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_incompatible_operator_for_type.sol @@ -0,0 +1,18 @@ +contract C { + event MyCustomEvent(uint); + function f() pure public { + uint a; + MyCustomEvent += 1; + MyCustomEvent -= 1; + a += MyCustomEvent; + a -= MyCustomEvent; + } +} + +// ---- +// TypeError 4247: (99-112): Expression has to be an lvalue. +// TypeError 7366: (99-117): Operator += not compatible with types event MyCustomEvent(uint256) and int_const 1. +// TypeError 4247: (127-140): Expression has to be an lvalue. +// TypeError 7366: (127-145): Operator -= not compatible with types event MyCustomEvent(uint256) and int_const 1. +// TypeError 7366: (155-173): Operator += not compatible with types uint256 and event MyCustomEvent(uint256). +// TypeError 7366: (183-201): Operator -= not compatible with types uint256 and event MyCustomEvent(uint256). diff --git a/test/libsolidity/syntaxTests/events/event_incompatible_unary_operator.sol b/test/libsolidity/syntaxTests/events/event_incompatible_unary_operator.sol new file mode 100644 index 000000000..110b8d214 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_incompatible_unary_operator.sol @@ -0,0 +1,10 @@ +contract C { + event MyCustomEvent(uint); + function f() pure public { + MyCustomEvent++; + } +} + +// ---- +// TypeError 4247: (83-96): Expression has to be an lvalue. +// TypeError 9767: (83-98): Unary operator ++ cannot be applied to type event MyCustomEvent(uint256). diff --git a/test/libsolidity/syntaxTests/events/event_invalid_function_modifier_type.sol b/test/libsolidity/syntaxTests/events/event_invalid_function_modifier_type.sol new file mode 100644 index 000000000..b534c3b1e --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_invalid_function_modifier_type.sol @@ -0,0 +1,8 @@ +contract B { + event MyCustomEvent(uint); + function f() mod1(MyCustomEvent) public { } + modifier mod1(uint a) { if (a > 0) _; } +} + +// ---- +// TypeError 4649: (66-79): Invalid type for argument in modifier invocation. Invalid implicit conversion from event MyCustomEvent(uint256) to uint256 requested. diff --git a/test/libsolidity/syntaxTests/events/event_return_tuple_not_convertible.sol b/test/libsolidity/syntaxTests/events/event_return_tuple_not_convertible.sol new file mode 100644 index 000000000..87be3691f --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_return_tuple_not_convertible.sol @@ -0,0 +1,9 @@ +contract C { + event MyCustomEvent(uint); + function f() public returns (uint8, uint8, int) { + return ((MyCustomEvent, 8, MyCustomEvent)); + } +} + +// ---- +// TypeError 5992: (113-148): Return argument type tuple(event MyCustomEvent(uint256),int_const 8,event MyCustomEvent(uint256)) is not implicitly convertible to expected type tuple(uint8,uint8,int256). diff --git a/test/libsolidity/syntaxTests/events/event_selector_access_foreign_contract.sol b/test/libsolidity/syntaxTests/events/event_selector_access_foreign_contract.sol new file mode 100644 index 000000000..b878543fc --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_selector_access_foreign_contract.sol @@ -0,0 +1,11 @@ +contract D { + event E(); +} + +contract C { + function f() external pure returns (bytes32) { + return D.E.selector; + } +} +// ---- +// TypeError 9582: (110-113): Member "E" not found or not visible after argument-dependent lookup in type(contract D). diff --git a/test/libsolidity/syntaxTests/events/event_selector_access_interface.sol b/test/libsolidity/syntaxTests/events/event_selector_access_interface.sol new file mode 100644 index 000000000..2877fee56 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_selector_access_interface.sol @@ -0,0 +1,11 @@ +interface I { + event E(); +} + +contract C { + function f() external pure returns (bytes32) { + return I.E.selector; + } +} +// ---- +// TypeError 9582: (111-114): Member "E" not found or not visible after argument-dependent lookup in type(contract I). diff --git a/test/libsolidity/syntaxTests/events/event_selector_access_library.sol b/test/libsolidity/syntaxTests/events/event_selector_access_library.sol new file mode 100644 index 000000000..2bf248459 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_selector_access_library.sol @@ -0,0 +1,10 @@ +library L { + event E(); +} + +contract C { + function f() external pure returns (bytes32) { + return L.E.selector; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/events/event_selector_library_called_inside_function.sol b/test/libsolidity/syntaxTests/events/event_selector_library_called_inside_function.sol new file mode 100644 index 000000000..e94869732 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_selector_library_called_inside_function.sol @@ -0,0 +1,11 @@ +library Y { + event E() anonymous; +} + +contract D { + function test1() external pure returns (bytes32) { + return Y.E.selector; + } +} +// ---- +// TypeError 9582: (123-135): Member "selector" not found or not visible after argument-dependent lookup in event E(). diff --git a/test/libsolidity/syntaxTests/events/event_selector_library_declared_outside_but_called_inside_function.sol b/test/libsolidity/syntaxTests/events/event_selector_library_declared_outside_but_called_inside_function.sol new file mode 100644 index 000000000..613d4ebcf --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_selector_library_declared_outside_but_called_inside_function.sol @@ -0,0 +1,13 @@ +library Y { + event E() anonymous; +} + +contract C { + bytes32 s5 = Y.E.selector; + + function test2() view external returns (bytes32) { + return s5; + } +} +// ---- +// TypeError 9582: (70-82): Member "selector" not found or not visible after argument-dependent lookup in event E(). diff --git a/test/libsolidity/syntaxTests/events/event_selector_syntax.sol b/test/libsolidity/syntaxTests/events/event_selector_syntax.sol new file mode 100644 index 000000000..ecbfe9bc5 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_selector_syntax.sol @@ -0,0 +1,20 @@ +library L { + event E(bytes32, bool, bytes indexed); +} + +contract B { + event E(bytes32, bool, bytes indexed); +} + +contract C is B { + bytes32 public librarySelector = L.E.selector; + bytes32 inheritedSelector = E.selector; + + function f() public { + assert(librarySelector == L.E.selector); + assert(E.selector == B.E.selector); + + emit E(E.selector, true, "123"); + emit L.E((B.E.selector), true, "123"); + } +} diff --git a/test/libsolidity/syntaxTests/events/event_ternary_operator_different_types.sol b/test/libsolidity/syntaxTests/events/event_ternary_operator_different_types.sol new file mode 100644 index 000000000..ca2f1e1d6 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_ternary_operator_different_types.sol @@ -0,0 +1,17 @@ +contract C { + event MyCustomEvent(uint); + event MyCustomEvent2(uint); + event MyCustomEvent3(uint, bool); + function f() pure public { + true ? MyCustomEvent : MyCustomEvent; + true ? MyCustomEvent : MyCustomEvent2; + true ? MyCustomEvent : MyCustomEvent3; + true ? MyCustomEvent : true; + true ? true : MyCustomEvent; + } +} + +// ---- +// TypeError 1080: (246-283): True expression's type event MyCustomEvent(uint256) does not match false expression's type event MyCustomEvent3(uint256,bool). +// TypeError 1080: (293-320): True expression's type event MyCustomEvent(uint256) does not match false expression's type bool. +// TypeError 1080: (330-357): True expression's type bool does not match false expression's type event MyCustomEvent(uint256). diff --git a/test/libsolidity/syntaxTests/errors/weird1.sol b/test/libsolidity/syntaxTests/events/event_to_function_conversion.sol similarity index 67% rename from test/libsolidity/syntaxTests/errors/weird1.sol rename to test/libsolidity/syntaxTests/events/event_to_function_conversion.sol index b57f34c22..931e485fc 100644 --- a/test/libsolidity/syntaxTests/errors/weird1.sol +++ b/test/libsolidity/syntaxTests/events/event_to_function_conversion.sol @@ -1,7 +1,7 @@ -error E(); contract C { + event E(uint); function() internal pure x = E; } // ---- -// TypeError 7407: (58-59): Type function () pure is not implicitly convertible to expected type function () pure. Special functions can not be converted to function types. +// TypeError 7407: (66-67): Type event E(uint256) is not implicitly convertible to expected type function () pure. Special functions can not be converted to function types. diff --git a/test/libsolidity/syntaxTests/events/event_variable_declaration_implicit_conversion.sol b/test/libsolidity/syntaxTests/events/event_variable_declaration_implicit_conversion.sol new file mode 100644 index 000000000..60cdebddc --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_variable_declaration_implicit_conversion.sol @@ -0,0 +1,9 @@ +contract C { + event MyCustomEvent(uint); + function f() public { + bytes4 a = MyCustomEvent; + } +} + +// ---- +// TypeError 9574: (78-102): Type event MyCustomEvent(uint256) is not implicitly convertible to expected type bytes4. diff --git a/test/libsolidity/syntaxTests/events/event_wrong_type_base_arg.sol b/test/libsolidity/syntaxTests/events/event_wrong_type_base_arg.sol new file mode 100644 index 000000000..adaaf4ccc --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_wrong_type_base_arg.sol @@ -0,0 +1,9 @@ +contract Base { + event MyCustomEvent(uint); + constructor(uint8) {} +} + +contract Derived is Base(Base.MyCustomEvent) {} + +// ---- +// TypeError 9827: (101-119): Invalid type for argument in constructor call. Invalid implicit conversion from event MyCustomEvent(uint256) to uint8 requested. diff --git a/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_gt_1.sol b/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_gt_1.sol index 32fed1f6a..67911852f 100644 --- a/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_gt_1.sol +++ b/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_gt_1.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError 2271: (73-88): Operator > not compatible with types function () external returns (bool) and function () external returns (bool) +// TypeError 2271: (73-88): Operator > not compatible with types function () external returns (bool) and function () external returns (bool). diff --git a/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_gt_2.sol b/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_gt_2.sol index 70a391ed9..bc3882fdd 100644 --- a/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_gt_2.sol +++ b/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_gt_2.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError 2271: (73-78): Operator > not compatible with types function () returns (bool) and function () returns (bool) +// TypeError 2271: (73-78): Operator > not compatible with types function () returns (bool) and function () returns (bool). diff --git a/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_lt_1.sol b/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_lt_1.sol index 8eeaf3697..e924893f0 100644 --- a/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_lt_1.sol +++ b/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_lt_1.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError 2271: (73-88): Operator < not compatible with types function () external returns (bool) and function () external returns (bool) +// TypeError 2271: (73-88): Operator < not compatible with types function () external returns (bool) and function () external returns (bool). diff --git a/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_lt_2.sol b/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_lt_2.sol index 6fa1c281a..16dc981ad 100644 --- a/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_lt_2.sol +++ b/test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_lt_2.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError 2271: (73-78): Operator < not compatible with types function () returns (bool) and function () returns (bool) +// TypeError 2271: (73-78): Operator < not compatible with types function () returns (bool) and function () returns (bool). diff --git a/test/libsolidity/syntaxTests/functionTypes/comparison_operator_for_external_functions_with_extra_gas_slots.sol b/test/libsolidity/syntaxTests/functionTypes/comparison_operator_for_external_functions_with_extra_gas_slots.sol index 7b0713caf..824f2dbf8 100644 --- a/test/libsolidity/syntaxTests/functionTypes/comparison_operator_for_external_functions_with_extra_gas_slots.sol +++ b/test/libsolidity/syntaxTests/functionTypes/comparison_operator_for_external_functions_with_extra_gas_slots.sol @@ -8,5 +8,5 @@ contract C { } } // ---- -// TypeError 2271: (193-259): Operator == not compatible with types function () external and function () external -// TypeError 2271: (277-351): Operator == not compatible with types function () external and function () external +// TypeError 2271: (193-259): Operator == not compatible with types function () external and function () external. +// TypeError 2271: (277-351): Operator == not compatible with types function () external and function () external. diff --git a/test/libsolidity/syntaxTests/functionTypes/comparison_operators_between_internal_and_external_function_pointers.sol b/test/libsolidity/syntaxTests/functionTypes/comparison_operators_between_internal_and_external_function_pointers.sol index 19f44658f..a562b2d3f 100644 --- a/test/libsolidity/syntaxTests/functionTypes/comparison_operators_between_internal_and_external_function_pointers.sol +++ b/test/libsolidity/syntaxTests/functionTypes/comparison_operators_between_internal_and_external_function_pointers.sol @@ -19,5 +19,5 @@ contract C { } } // ---- -// TypeError 2271: (606-672): Operator != not compatible with types function () and function () external -// TypeError 2271: (688-741): Operator != not compatible with types function () and function () external +// TypeError 2271: (606-672): Operator != not compatible with types function () and function () external. +// TypeError 2271: (688-741): Operator != not compatible with types function () and function () external. diff --git a/test/libsolidity/syntaxTests/functionTypes/comparison_operators_external_functions_with_different_parameters.sol b/test/libsolidity/syntaxTests/functionTypes/comparison_operators_external_functions_with_different_parameters.sol index 39381f454..93facedb0 100644 --- a/test/libsolidity/syntaxTests/functionTypes/comparison_operators_external_functions_with_different_parameters.sol +++ b/test/libsolidity/syntaxTests/functionTypes/comparison_operators_external_functions_with_different_parameters.sol @@ -21,6 +21,6 @@ contract C { // ---- // TypeError 9574: (249-333): Type function (uint256) external is not implicitly convertible to expected type function () external. // TypeError 9574: (343-427): Type function (bool) external is not implicitly convertible to expected type function () external. -// TypeError 2271: (458-522): Operator == not compatible with types function (uint256) external and function () external -// TypeError 2271: (538-602): Operator == not compatible with types function (bool) external and function () external -// TypeError 2271: (726-786): Operator != not compatible with types function (bool) external and function (uint256) external +// TypeError 2271: (458-522): Operator == not compatible with types function (uint256) external and function () external. +// TypeError 2271: (538-602): Operator == not compatible with types function (bool) external and function () external. +// TypeError 2271: (726-786): Operator != not compatible with types function (bool) external and function (uint256) external. diff --git a/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_dec_tuple.sol b/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_dec_tuple.sol index 568fe27ff..fa1950d92 100644 --- a/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_dec_tuple.sol +++ b/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_dec_tuple.sol @@ -6,4 +6,4 @@ contract C } } // ---- -// TypeError 9767: (59-64): Unary operator -- cannot be applied to type tuple(,) +// TypeError 9767: (59-64): Unary operator -- cannot be applied to type tuple(,). diff --git a/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_delete_tuple.sol b/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_delete_tuple.sol index 9727e53a5..c73fe7435 100644 --- a/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_delete_tuple.sol +++ b/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_delete_tuple.sol @@ -7,4 +7,4 @@ contract C } // ---- // TypeError 4247: (68-69): Expression has to be an lvalue. -// TypeError 9767: (59-70): Unary operator delete cannot be applied to type tuple(,int_const 0) +// TypeError 9767: (59-70): Unary operator delete cannot be applied to type tuple(,int_const 0). diff --git a/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_inc_tuple.sol b/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_inc_tuple.sol index 487c224be..3cbab1423 100644 --- a/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_inc_tuple.sol +++ b/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_inc_tuple.sol @@ -6,4 +6,4 @@ contract C } } // ---- -// TypeError 9767: (61-66): Unary operator ++ cannot be applied to type tuple(,) +// TypeError 9767: (61-66): Unary operator ++ cannot be applied to type tuple(,). diff --git a/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_unary_tuple.sol b/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_unary_tuple.sol index 2c568a4e7..01056ffe2 100644 --- a/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_unary_tuple.sol +++ b/test/libsolidity/syntaxTests/iceRegressionTests/declarationUnaryTuple/declaration_unary_tuple.sol @@ -10,11 +10,11 @@ contract C } // ---- // SyntaxError 9636: (59-66): Use of unary + is disallowed. -// TypeError 4907: (59-66): Unary operator + cannot be applied to type tuple(int_const 0,int_const 0) +// TypeError 4907: (59-66): Unary operator + cannot be applied to type tuple(int_const 0,int_const 0). // TypeError 7364: (51-66): Different number of components on the left hand side (1) than on the right hand side (2). -// TypeError 4907: (84-91): Unary operator - cannot be applied to type tuple(int_const 0,int_const 0) +// TypeError 4907: (84-91): Unary operator - cannot be applied to type tuple(int_const 0,int_const 0). // TypeError 7364: (76-91): Different number of components on the left hand side (1) than on the right hand side (2). -// TypeError 4907: (111-118): Unary operator ~ cannot be applied to type tuple(int_const 0,int_const 0) +// TypeError 4907: (111-118): Unary operator ~ cannot be applied to type tuple(int_const 0,int_const 0). // TypeError 7364: (101-118): Different number of components on the left hand side (1) than on the right hand side (2). -// TypeError 4907: (138-145): Unary operator ! cannot be applied to type tuple(int_const 0,int_const 0) +// TypeError 4907: (138-145): Unary operator ! cannot be applied to type tuple(int_const 0,int_const 0). // TypeError 7364: (128-145): Different number of components on the left hand side (1) than on the right hand side (2). diff --git a/test/libsolidity/syntaxTests/iceRegressionTests/memory_mapping_array.sol b/test/libsolidity/syntaxTests/iceRegressionTests/memory_mapping_array.sol index aa1f63e4c..d9a4cdd49 100644 --- a/test/libsolidity/syntaxTests/iceRegressionTests/memory_mapping_array.sol +++ b/test/libsolidity/syntaxTests/iceRegressionTests/memory_mapping_array.sol @@ -4,4 +4,4 @@ } } // ---- -// TypeError 4061: (91-136): Type mapping(string => uint24)[1] is only valid in storage because it contains a (nested) mapping. +// TypeError 4061: (91-136): Type mapping(string => uint24)[1] memory is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/iceRegressionTests/recursive_struct_memory.sol b/test/libsolidity/syntaxTests/iceRegressionTests/recursive_struct_memory.sol index 892cfdd8d..9f53b9ed6 100644 --- a/test/libsolidity/syntaxTests/iceRegressionTests/recursive_struct_memory.sol +++ b/test/libsolidity/syntaxTests/iceRegressionTests/recursive_struct_memory.sol @@ -11,4 +11,4 @@ contract Test { } // ---- // DeclarationError 2333: (157-198): Identifier already declared. -// TypeError 4061: (268-300): Type struct Test.RecursiveStruct[1] is only valid in storage because it contains a (nested) mapping. +// TypeError 4061: (268-300): Type struct Test.RecursiveStruct[1] memory is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/immutable/non-value_type_struct.sol b/test/libsolidity/syntaxTests/immutable/non-value_type_struct.sol new file mode 100644 index 000000000..ad01e3b5e --- /dev/null +++ b/test/libsolidity/syntaxTests/immutable/non-value_type_struct.sol @@ -0,0 +1,9 @@ +contract Contract { + struct S { + int k; + } + + S immutable s; +} +// ---- +// TypeError 6377: (61-74): Immutable variables cannot have a non-value type. diff --git a/test/libsolidity/syntaxTests/immutable/non-value_type_struct_with_mapping.sol b/test/libsolidity/syntaxTests/immutable/non-value_type_struct_with_mapping.sol new file mode 100644 index 000000000..b734db30f --- /dev/null +++ b/test/libsolidity/syntaxTests/immutable/non-value_type_struct_with_mapping.sol @@ -0,0 +1,9 @@ +contract Contract { + struct S { + mapping(uint => address) map; + } + + S immutable s; +} +// ---- +// TypeError 6377: (84-97): Immutable variables cannot have a non-value type. diff --git a/test/libsolidity/syntaxTests/indexing/error_type_without_index.sol b/test/libsolidity/syntaxTests/indexing/error_type_without_index.sol new file mode 100644 index 000000000..66658a4c9 --- /dev/null +++ b/test/libsolidity/syntaxTests/indexing/error_type_without_index.sol @@ -0,0 +1,11 @@ +interface MyInterface { + error MyCustomError(uint256, bool); +} + +contract MyContract { + function test() public { + MyInterface.MyCustomError[]; + } +} +// ---- +// TypeError 2614: (126-151): Indexed expression has to be a type, mapping or array (is error MyCustomError(uint256,bool)) diff --git a/test/libsolidity/syntaxTests/indexing/event_type_without_index.sol b/test/libsolidity/syntaxTests/indexing/event_type_without_index.sol new file mode 100644 index 000000000..83d1ecc02 --- /dev/null +++ b/test/libsolidity/syntaxTests/indexing/event_type_without_index.sol @@ -0,0 +1,8 @@ +contract MyContract { + event MyCustomEvent(uint256); + function test() public { + MyCustomEvent[]; + } +} +// ---- +// TypeError 2614: (93-106): Indexed expression has to be a type, mapping or array (is event MyCustomEvent(uint256)) diff --git a/test/libsolidity/syntaxTests/literalOperations/division_by_zero.sol b/test/libsolidity/syntaxTests/literalOperations/division_by_zero.sol index 2b20cec4b..211eabac2 100644 --- a/test/libsolidity/syntaxTests/literalOperations/division_by_zero.sol +++ b/test/libsolidity/syntaxTests/literalOperations/division_by_zero.sol @@ -2,4 +2,4 @@ contract C { uint constant a = 1 / 0; } // ---- -// TypeError 2271: (35-40): Operator / not compatible with types int_const 1 and int_const 0 +// TypeError 2271: (35-40): Operator / not compatible with types int_const 1 and int_const 0. diff --git a/test/libsolidity/syntaxTests/literalOperations/division_by_zero_complex.sol b/test/libsolidity/syntaxTests/literalOperations/division_by_zero_complex.sol index f6b494d3d..afa0896fa 100644 --- a/test/libsolidity/syntaxTests/literalOperations/division_by_zero_complex.sol +++ b/test/libsolidity/syntaxTests/literalOperations/division_by_zero_complex.sol @@ -2,4 +2,4 @@ contract C { uint constant a = 1 / ((1+3)-4); } // ---- -// TypeError 2271: (35-48): Operator / not compatible with types int_const 1 and int_const 0 +// TypeError 2271: (35-48): Operator / not compatible with types int_const 1 and int_const 0. diff --git a/test/libsolidity/syntaxTests/literalOperations/mod_zero.sol b/test/libsolidity/syntaxTests/literalOperations/mod_zero.sol index a7d470b24..28f95e332 100644 --- a/test/libsolidity/syntaxTests/literalOperations/mod_zero.sol +++ b/test/libsolidity/syntaxTests/literalOperations/mod_zero.sol @@ -2,4 +2,4 @@ contract C { uint constant b3 = 1 % 0; } // ---- -// TypeError 2271: (36-41): Operator % not compatible with types int_const 1 and int_const 0 +// TypeError 2271: (36-41): Operator % not compatible with types int_const 1 and int_const 0. diff --git a/test/libsolidity/syntaxTests/literalOperations/mod_zero_complex.sol b/test/libsolidity/syntaxTests/literalOperations/mod_zero_complex.sol index 9aba4dd75..54b6b309b 100644 --- a/test/libsolidity/syntaxTests/literalOperations/mod_zero_complex.sol +++ b/test/libsolidity/syntaxTests/literalOperations/mod_zero_complex.sol @@ -2,4 +2,4 @@ contract C { uint constant b3 = 1 % (-4+((2)*2)); } // ---- -// TypeError 2271: (36-52): Operator % not compatible with types int_const 1 and int_const 0 +// TypeError 2271: (36-52): Operator % not compatible with types int_const 1 and int_const 0. diff --git a/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mapping_array_struct_array.sol b/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mapping_array_struct_array.sol index 164d32ff0..f92e4dbd5 100644 --- a/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mapping_array_struct_array.sol +++ b/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mapping_array_struct_array.sol @@ -9,4 +9,4 @@ contract Test { } } // ---- -// TypeError 4061: (161-172): Type struct Test.S2 is only valid in storage because it contains a (nested) mapping. +// TypeError 4061: (161-172): Type struct Test.S2 memory is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mappings.sol b/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mappings.sol index fd510ed17..0e8512a62 100644 --- a/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mappings.sol +++ b/test/libsolidity/syntaxTests/memberLookup/memory_structs_with_mappings.sol @@ -6,4 +6,4 @@ contract Test { } } // ---- -// TypeError 4061: (104-114): Type struct Test.S is only valid in storage because it contains a (nested) mapping. +// TypeError 4061: (104-114): Type struct Test.S memory is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/metaTypes/integer_err.sol b/test/libsolidity/syntaxTests/metaTypes/integer_err.sol index 0b1fab2e5..b098a8602 100644 --- a/test/libsolidity/syntaxTests/metaTypes/integer_err.sol +++ b/test/libsolidity/syntaxTests/metaTypes/integer_err.sol @@ -12,4 +12,4 @@ contract Test { // ---- // TypeError 9574: (59-89): Type int256 is not implicitly convertible to expected type uint8. // TypeError 9574: (99-127): Type int256 is not implicitly convertible to expected type uint256. -// TypeError 2271: (142-169): Operator == not compatible with types int256 and int_const 1157...(70 digits omitted)...9935 +// TypeError 2271: (142-169): Operator == not compatible with types int256 and int_const 1157...(70 digits omitted)...9935. diff --git a/test/libsolidity/syntaxTests/metaTypes/unsupportedArgForType.sol b/test/libsolidity/syntaxTests/metaTypes/unsupported_arg_for_type.sol similarity index 83% rename from test/libsolidity/syntaxTests/metaTypes/unsupportedArgForType.sol rename to test/libsolidity/syntaxTests/metaTypes/unsupported_arg_for_type.sol index 9ed26dc6f..aa7686ed8 100644 --- a/test/libsolidity/syntaxTests/metaTypes/unsupportedArgForType.sol +++ b/test/libsolidity/syntaxTests/metaTypes/unsupported_arg_for_type.sol @@ -6,4 +6,4 @@ contract Test { } } // ---- -// TypeError 4259: (154-155): Invalid type for argument in the function call. An enum type, contract type or an integer type is required, but type(struct Test.S) provided. +// TypeError 4259: (154-155): Invalid type for argument in the function call. An enum type, contract type or an integer type is required, but type(struct Test.S storage pointer) provided. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/011_type_conversion_for_comparison_invalid.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/011_type_conversion_for_comparison_invalid.sol index ea30647df..528635b98 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/011_type_conversion_for_comparison_invalid.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/011_type_conversion_for_comparison_invalid.sol @@ -2,4 +2,4 @@ contract test { function f() public { int32(2) == uint64(2); } } // ---- -// TypeError 2271: (42-63): Operator == not compatible with types int32 and uint64 +// TypeError 2271: (42-63): Operator == not compatible with types int32 and uint64. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol index 9f50403cb..7849588a4 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol @@ -6,4 +6,4 @@ contract C { } } // ---- -// TypeError 2271: (147-153): Operator == not compatible with types mapping(uint256 => uint256) and mapping(uint256 => uint256) +// TypeError 2271: (147-153): Operator == not compatible with types mapping(uint256 => uint256) and mapping(uint256 => uint256). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/112_exp_operator_exponent_too_big.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/112_exp_operator_exponent_too_big.sol index 49f9877e2..0dfeb892a 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/112_exp_operator_exponent_too_big.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/112_exp_operator_exponent_too_big.sol @@ -2,4 +2,4 @@ contract test { function f() public returns (uint d) { return 2 ** 10000000000; } } // ---- -// TypeError 2271: (66-82): Operator ** not compatible with types int_const 2 and int_const 10000000000 +// TypeError 2271: (66-82): Operator ** not compatible with types int_const 2 and int_const 10000000000. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol index 5b19505f0..24c6ce13c 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol @@ -1,3 +1,3 @@ contract test { fallback() external { uint x = 1; uint y = 2; x || y; } } // ---- -// TypeError 2271: (62-68): Operator || not compatible with types uint256 and uint256 +// TypeError 2271: (62-68): Operator || not compatible with types uint256 and uint256. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol index 8981af1b1..1d1298b05 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol @@ -1,3 +1,3 @@ contract test { fallback() external { uint x = 1; uint y = 2; x && y; } } // ---- -// TypeError 2271: (62-68): Operator && not compatible with types uint256 and uint256 +// TypeError 2271: (62-68): Operator && not compatible with types uint256 and uint256. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol index 3c8fd4fc2..c4fff97b4 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol @@ -1,3 +1,3 @@ contract test { fallback() external { uint x = 1; !x; } } // ---- -// TypeError 4907: (50-52): Unary operator ! cannot be applied to type uint256 +// TypeError 4907: (50-52): Unary operator ! cannot be applied to type uint256. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol index b1f63003f..60dffe643 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol @@ -1,3 +1,3 @@ contract test { bytes a; bytes b; fallback() external { a == b; } } // ---- -// TypeError 2271: (56-62): Operator == not compatible with types bytes storage ref and bytes storage ref +// TypeError 2271: (56-62): Operator == not compatible with types bytes storage ref and bytes storage ref. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol index cdb7aeb01..822db8dd5 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol @@ -7,4 +7,4 @@ contract test { } } // ---- -// TypeError 2271: (79-85): Operator == not compatible with types struct test.s storage ref and struct test.s storage ref +// TypeError 2271: (79-85): Operator == not compatible with types struct test.s storage ref and struct test.s storage ref. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/207_no_mappings_in_memory_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/207_no_mappings_in_memory_array.sol index d9e929da2..1db651f37 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/207_no_mappings_in_memory_array.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/207_no_mappings_in_memory_array.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError 4061: (47-77): Type mapping(uint256 => uint256)[] is only valid in storage because it contains a (nested) mapping. +// TypeError 4061: (47-77): Type mapping(uint256 => uint256)[] memory is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/213_no_delete_on_storage_pointers.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/213_no_delete_on_storage_pointers.sol index b1b43c631..e0db21efa 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/213_no_delete_on_storage_pointers.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/213_no_delete_on_storage_pointers.sol @@ -6,4 +6,4 @@ contract C { } } // ---- -// TypeError 9767: (97-105): Unary operator delete cannot be applied to type uint256[] storage pointer +// TypeError 9767: (97-105): Unary operator delete cannot be applied to type uint256[] storage pointer. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/308_rational_unary_plus_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/308_rational_unary_plus_operation.sol index 276c6533d..eeaa66ebc 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/308_rational_unary_plus_operation.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/308_rational_unary_plus_operation.sol @@ -7,4 +7,4 @@ contract test { } // ---- // SyntaxError 9636: (70-75): Use of unary + is disallowed. -// TypeError 4907: (70-75): Unary operator + cannot be applied to type rational_const 13 / 4 +// TypeError 4907: (70-75): Unary operator + cannot be applied to type rational_const 13 / 4. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/329_rational_as_exponent_value_signed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/329_rational_as_exponent_value_signed.sol index 8aa826009..47a1a617f 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/329_rational_as_exponent_value_signed.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/329_rational_as_exponent_value_signed.sol @@ -4,4 +4,4 @@ contract test { } } // ---- -// TypeError 2271: (60-69): Operator ** not compatible with types int_const 2 and rational_const -11 / 5 +// TypeError 2271: (60-69): Operator ** not compatible with types int_const 2 and rational_const -11 / 5. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/330_rational_as_exponent_value_unsigned.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/330_rational_as_exponent_value_unsigned.sol index 29b6f088d..0f93157ed 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/330_rational_as_exponent_value_unsigned.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/330_rational_as_exponent_value_unsigned.sol @@ -4,4 +4,4 @@ contract test { } } // ---- -// TypeError 2271: (61-69): Operator ** not compatible with types int_const 3 and rational_const 5 / 2 +// TypeError 2271: (61-69): Operator ** not compatible with types int_const 3 and rational_const 5 / 2. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/331_rational_as_exponent_half.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/331_rational_as_exponent_half.sol index 95a8120ba..721ca806e 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/331_rational_as_exponent_half.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/331_rational_as_exponent_half.sol @@ -4,4 +4,4 @@ contract test { } } // ---- -// TypeError 2271: (50-60): Operator ** not compatible with types int_const 2 and rational_const 1 / 2 +// TypeError 2271: (50-60): Operator ** not compatible with types int_const 2 and rational_const 1 / 2. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/332_rational_as_exponent_value_neg_quarter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/332_rational_as_exponent_value_neg_quarter.sol index 15d1f18d6..6408f13c6 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/332_rational_as_exponent_value_neg_quarter.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/332_rational_as_exponent_value_neg_quarter.sol @@ -4,4 +4,4 @@ contract test { } } // ---- -// TypeError 2271: (50-62): Operator ** not compatible with types int_const 42 and rational_const -1 / 4 +// TypeError 2271: (50-62): Operator ** not compatible with types int_const 42 and rational_const -1 / 4. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/338_rational_bitnot_unary_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/338_rational_bitnot_unary_operation.sol index a084756e6..4bf484ff1 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/338_rational_bitnot_unary_operation.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/338_rational_bitnot_unary_operation.sol @@ -4,4 +4,4 @@ contract test { } } // ---- -// TypeError 4907: (50-61): Unary operator ~ cannot be applied to type fixed128x18 +// TypeError 4907: (50-61): Unary operator ~ cannot be applied to type fixed128x18. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/339_rational_bitor_binary_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/339_rational_bitor_binary_operation.sol index 5d5cd6a9b..66f5e620a 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/339_rational_bitor_binary_operation.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/339_rational_bitor_binary_operation.sol @@ -4,4 +4,4 @@ contract test { } } // ---- -// TypeError 2271: (50-64): Operator | not compatible with types fixed128x18 and int_const 3 +// TypeError 2271: (50-64): Operator | not compatible with types fixed128x18 and int_const 3. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/340_rational_bitxor_binary_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/340_rational_bitxor_binary_operation.sol index ee96badae..791e1480c 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/340_rational_bitxor_binary_operation.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/340_rational_bitxor_binary_operation.sol @@ -4,4 +4,4 @@ contract test { } } // ---- -// TypeError 2271: (50-65): Operator ^ not compatible with types fixed128x18 and int_const 3 +// TypeError 2271: (50-65): Operator ^ not compatible with types fixed128x18 and int_const 3. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/341_rational_bitand_binary_operation.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/341_rational_bitand_binary_operation.sol index da836f31a..9e49de99b 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/341_rational_bitand_binary_operation.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/341_rational_bitand_binary_operation.sol @@ -4,4 +4,4 @@ contract test { } } // ---- -// TypeError 2271: (50-65): Operator & not compatible with types fixed128x18 and int_const 3 +// TypeError 2271: (50-65): Operator & not compatible with types fixed128x18 and int_const 3. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/368_shift_constant_left_negative_rvalue.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/368_shift_constant_left_negative_rvalue.sol index fcd56bc0d..aaa0903b6 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/368_shift_constant_left_negative_rvalue.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/368_shift_constant_left_negative_rvalue.sol @@ -2,4 +2,4 @@ contract C { uint public a = 0x42 << -8; } // ---- -// TypeError 2271: (33-43): Operator << not compatible with types int_const 66 and int_const -8 +// TypeError 2271: (33-43): Operator << not compatible with types int_const 66 and int_const -8. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/369_shift_constant_right_negative_rvalue.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/369_shift_constant_right_negative_rvalue.sol index 344dce513..edfb03d3d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/369_shift_constant_right_negative_rvalue.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/369_shift_constant_right_negative_rvalue.sol @@ -2,4 +2,4 @@ contract C { uint public a = 0x42 >> -8; } // ---- -// TypeError 2271: (33-43): Operator >> not compatible with types int_const 66 and int_const -8 +// TypeError 2271: (33-43): Operator >> not compatible with types int_const 66 and int_const -8. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/370_shift_constant_left_excessive_rvalue.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/370_shift_constant_left_excessive_rvalue.sol index 1809a677b..17e7cc719 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/370_shift_constant_left_excessive_rvalue.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/370_shift_constant_left_excessive_rvalue.sol @@ -2,4 +2,4 @@ contract C { uint public a = 0x42 << 0x100000000; } // ---- -// TypeError 2271: (33-52): Operator << not compatible with types int_const 66 and int_const 4294967296 +// TypeError 2271: (33-52): Operator << not compatible with types int_const 66 and int_const 4294967296. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/371_shift_constant_right_excessive_rvalue.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/371_shift_constant_right_excessive_rvalue.sol index 858f547dd..f96eeab2d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/371_shift_constant_right_excessive_rvalue.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/371_shift_constant_right_excessive_rvalue.sol @@ -2,4 +2,4 @@ contract C { uint public a = 0x42 >> 0x100000000; } // ---- -// TypeError 2271: (33-52): Operator >> not compatible with types int_const 66 and int_const 4294967296 +// TypeError 2271: (33-52): Operator >> not compatible with types int_const 66 and int_const 4294967296. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/372_shift_constant_right_fractional.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/372_shift_constant_right_fractional.sol index d377c315a..8f005b9ec 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/372_shift_constant_right_fractional.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/372_shift_constant_right_fractional.sol @@ -2,4 +2,4 @@ contract C { uint public a = 0x42 >> (1 / 2); } // ---- -// TypeError 2271: (33-48): Operator >> not compatible with types int_const 66 and rational_const 1 / 2 +// TypeError 2271: (33-48): Operator >> not compatible with types int_const 66 and rational_const 1 / 2. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/589_error_index_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/589_error_index_access.sol new file mode 100644 index 000000000..fbeae8141 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/589_error_index_access.sol @@ -0,0 +1,9 @@ +error MyCustomError(uint, bool); +contract Test { + function f() public { + uint[] memory a; + a[MyCustomError]; + } +} +// ---- +// TypeError 7407: (110-123): Type error MyCustomError(uint256,bool) is not implicitly convertible to expected type uint256. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/590_event_index_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/590_event_index_access.sol new file mode 100644 index 000000000..9b49f788b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/590_event_index_access.sol @@ -0,0 +1,9 @@ +contract Test { + event MyCustomEvent(uint); + function f() public { + uint[] memory a; + a[MyCustomEvent]; + } +} +// ---- +// TypeError 7407: (108-121): Type event MyCustomEvent(uint256) is not implicitly convertible to expected type uint256. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/compoundAssignment/incomp_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/compoundAssignment/incomp_types.sol index 7b58b870f..6cd7f99c6 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/compoundAssignment/incomp_types.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/compoundAssignment/incomp_types.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError 7366: (72-83): Operator += not compatible with types uint256 and tuple(int_const 1,int_const 1) +// TypeError 7366: (72-83): Operator += not compatible with types uint256 and tuple(int_const 1,int_const 1). diff --git a/test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol b/test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol index 4d1afd7af..7005c8848 100644 --- a/test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol +++ b/test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol @@ -6,4 +6,4 @@ contract test { } // ---- // SyntaxError 9636: (70-72): Use of unary + is disallowed. -// TypeError 4907: (70-72): Unary operator + cannot be applied to type uint256 +// TypeError 4907: (70-72): Unary operator + cannot be applied to type uint256. diff --git a/test/libsolidity/syntaxTests/shifts/shift_singed_rvalue.sol b/test/libsolidity/syntaxTests/shifts/shift_singed_rvalue.sol index adca80cc4..87a2dee81 100644 --- a/test/libsolidity/syntaxTests/shifts/shift_singed_rvalue.sol +++ b/test/libsolidity/syntaxTests/shifts/shift_singed_rvalue.sol @@ -7,5 +7,5 @@ contract C { } } // ---- -// TypeError 2271: (89-95): Operator >> not compatible with types int256 and int256 -// TypeError 2271: (179-193): Operator >> not compatible with types int256 and int256 +// TypeError 2271: (89-95): Operator >> not compatible with types int256 and int256. +// TypeError 2271: (179-193): Operator >> not compatible with types int256 and int256. diff --git a/test/libsolidity/syntaxTests/specialFunctions/abi_encodePacked_tuple_returned_from_function.sol b/test/libsolidity/syntaxTests/specialFunctions/abi_encodePacked_tuple_returned_from_function.sol new file mode 100644 index 000000000..8dc796928 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abi_encodePacked_tuple_returned_from_function.sol @@ -0,0 +1,15 @@ +contract C { + function g0() internal pure {} + function g1() internal pure returns (uint) { return (1); } + function g2() internal pure returns (uint, uint) { return (2, 3); } + + function h() public pure { + abi.encodePacked(g0()); + abi.encodePacked(g2()); + abi.encodePacked((g1(), g1())); + } +} +// ---- +// TypeError 2056: (240-244): This type cannot be encoded. +// TypeError 2056: (272-276): This type cannot be encoded. +// TypeError 2056: (304-316): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/abi_encodePacked_unitary_tuple_returned_from_function.sol b/test/libsolidity/syntaxTests/specialFunctions/abi_encodePacked_unitary_tuple_returned_from_function.sol new file mode 100644 index 000000000..4ac1c1d40 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abi_encodePacked_unitary_tuple_returned_from_function.sol @@ -0,0 +1,8 @@ +contract C { + function g1() internal pure returns (uint) { return (1); } + + function h() public pure { + abi.encodePacked(g1()); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/specialFunctions/abi_encodeWithSelector_tuple_returned_from_function.sol b/test/libsolidity/syntaxTests/specialFunctions/abi_encodeWithSelector_tuple_returned_from_function.sol new file mode 100644 index 000000000..b8d0bcfcb --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abi_encodeWithSelector_tuple_returned_from_function.sol @@ -0,0 +1,19 @@ +contract C { + function g0() internal pure {} + function g1() internal pure returns (uint) { return (1); } + function g2() internal pure returns (uint, uint) { return (2, 3); } + + function f0() public {} + function f1(uint) public {} + function f2(uint, uint) public {} + + function h() public pure { + abi.encodeWithSelector(this.f0.selector, g0()); + abi.encodeWithSelector(this.f0.selector, g2()); + abi.encodeWithSelector(this.f0.selector, (g1(), g1())); + } +} +// ---- +// TypeError 2056: (363-367): This type cannot be encoded. +// TypeError 2056: (419-423): This type cannot be encoded. +// TypeError 2056: (475-487): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/abi_encodeWithSelector_unitary_tuple_returned_from_function.sol b/test/libsolidity/syntaxTests/specialFunctions/abi_encodeWithSelector_unitary_tuple_returned_from_function.sol new file mode 100644 index 000000000..1ef98b078 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abi_encodeWithSelector_unitary_tuple_returned_from_function.sol @@ -0,0 +1,10 @@ +contract C { + function g1() internal pure returns (uint) { return (1); } + + function f0() public {} + + function h() public pure { + abi.encodeWithSelector(this.f0.selector, g1()); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/specialFunctions/abi_encodeWithSignature_tuple_returned_from_function.sol b/test/libsolidity/syntaxTests/specialFunctions/abi_encodeWithSignature_tuple_returned_from_function.sol new file mode 100644 index 000000000..c618ec1b2 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abi_encodeWithSignature_tuple_returned_from_function.sol @@ -0,0 +1,15 @@ +contract C { + function g0() internal pure {} + function g1() internal pure returns (uint) { return (1); } + function g2() internal pure returns (uint, uint) { return (2, 3); } + + function h() public pure { + abi.encodeWithSignature("f0()", g0()); + abi.encodeWithSignature("f()", g2()); + abi.encodeWithSignature("f()", (g1(), g1())); + } +} +// ---- +// TypeError 2056: (255-259): This type cannot be encoded. +// TypeError 2056: (301-305): This type cannot be encoded. +// TypeError 2056: (347-359): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/abi_encodeWithSignature_unitary_tuple_from_function.sol b/test/libsolidity/syntaxTests/specialFunctions/abi_encodeWithSignature_unitary_tuple_from_function.sol new file mode 100644 index 000000000..504871832 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abi_encodeWithSignature_unitary_tuple_from_function.sol @@ -0,0 +1,8 @@ +contract C { + function g1() internal pure returns (uint) { return (1); } + + function h() public pure { + abi.encodeWithSignature("f()", g1()); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/specialFunctions/abi_encode_tuple_returned_from_function.sol b/test/libsolidity/syntaxTests/specialFunctions/abi_encode_tuple_returned_from_function.sol new file mode 100644 index 000000000..747ccdabf --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abi_encode_tuple_returned_from_function.sol @@ -0,0 +1,15 @@ +contract C { + function g0() internal pure {} + function g1() internal pure returns (uint) { return (1); } + function g2() internal pure returns (uint, uint) { return (2, 3); } + + function h() public pure { + abi.encode(g0()); + abi.encode(g2()); + abi.encode((g1(), g1())); + } +} +// ---- +// TypeError 2056: (234-238): This type cannot be encoded. +// TypeError 2056: (260-264): This type cannot be encoded. +// TypeError 2056: (286-298): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/abi_encode_unitary_tuple_returned_from_function.sol b/test/libsolidity/syntaxTests/specialFunctions/abi_encode_unitary_tuple_returned_from_function.sol new file mode 100644 index 000000000..6c3cdf84a --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abi_encode_unitary_tuple_returned_from_function.sol @@ -0,0 +1,8 @@ +contract C { + function g1() internal pure returns (uint) { return (1); } + + function h() public pure { + abi.encode(g1()); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_nested_dynamic_array.sol b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_nested_dynamic_array.sol index c705ab2ec..1981b04bf 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_nested_dynamic_array.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/abidecode/abi_decode_nested_dynamic_array.sol @@ -5,4 +5,4 @@ contract C { } } // ---- -// TypeError 9611: (92-101): Decoding type uint256[] memory[3] memory not supported. +// TypeError 9611: (92-101): Decoding type uint256[][3] memory not supported. diff --git a/test/libsolidity/syntaxTests/specialFunctions/encodeCall_fail_args_internal_function_pointer_for_uint.sol b/test/libsolidity/syntaxTests/specialFunctions/encodeCall_fail_args_internal_function_pointer_for_uint.sol new file mode 100644 index 000000000..e83512222 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/encodeCall_fail_args_internal_function_pointer_for_uint.sol @@ -0,0 +1,10 @@ +contract C { + function f(uint) external {} + + function main() external view { + function () h; + abi.encodeCall(this.f, (h)); + } +} +// ---- +// TypeError 5407: (137-140): Cannot implicitly convert component at position 0 from "function ()" to "uint256". diff --git a/test/libsolidity/syntaxTests/specialFunctions/encodecall_fail_args_internal_struct_for_uint.sol b/test/libsolidity/syntaxTests/specialFunctions/encodecall_fail_args_internal_struct_for_uint.sol new file mode 100644 index 000000000..11b675fb7 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/encodecall_fail_args_internal_struct_for_uint.sol @@ -0,0 +1,43 @@ +struct S { + function () f; +} + +contract C { + enum testEnum { choice1, choice2, choice3 } + + function f1(uint8) external {} + function f2(uint32) external {} + function f3(uint) external {} + function g1(bytes memory) external {} + function g2(bytes32) external {} + function h(string memory) external {} + function i(bool) external {} + function j(address) external {} + function k(address payable) external {} + function l(testEnum) external {} + + function main() external view { + S memory s; + abi.encodeCall(this.f1, (s)); + abi.encodeCall(this.f2, (s)); + abi.encodeCall(this.f3, (s)); + abi.encodeCall(this.g1, (s)); + abi.encodeCall(this.g2, (s)); + abi.encodeCall(this.h, (s)); + abi.encodeCall(this.i, (s)); + abi.encodeCall(this.j, (s)); + abi.encodeCall(this.k, (s)); + abi.encodeCall(this.l, (s)); + } +} +// ---- +// TypeError 5407: (560-563): Cannot implicitly convert component at position 0 from "struct S memory" to "uint8". +// TypeError 5407: (598-601): Cannot implicitly convert component at position 0 from "struct S memory" to "uint32". +// TypeError 5407: (636-639): Cannot implicitly convert component at position 0 from "struct S memory" to "uint256". +// TypeError 5407: (674-677): Cannot implicitly convert component at position 0 from "struct S memory" to "bytes memory". +// TypeError 5407: (712-715): Cannot implicitly convert component at position 0 from "struct S memory" to "bytes32". +// TypeError 5407: (749-752): Cannot implicitly convert component at position 0 from "struct S memory" to "string memory". +// TypeError 5407: (786-789): Cannot implicitly convert component at position 0 from "struct S memory" to "bool". +// TypeError 5407: (823-826): Cannot implicitly convert component at position 0 from "struct S memory" to "address". +// TypeError 5407: (860-863): Cannot implicitly convert component at position 0 from "struct S memory" to "address payable". +// TypeError 5407: (897-900): Cannot implicitly convert component at position 0 from "struct S memory" to "enum C.testEnum". diff --git a/test/libsolidity/syntaxTests/string/control_character_returned_in_string.sol b/test/libsolidity/syntaxTests/string/control_character_returned_in_string.sol new file mode 100644 index 000000000..981f5fdd5 --- /dev/null +++ b/test/libsolidity/syntaxTests/string/control_character_returned_in_string.sol @@ -0,0 +1,7 @@ +contract test { + function f() public pure returns (string memory) { + return "; + } +} +// ---- +// ParserError 8936: (86-88): Invalid character in string. If you are trying to use Unicode characters, use a unicode"..." string literal. diff --git a/test/libsolidity/syntaxTests/string/string_unicode_without_prefix.sol b/test/libsolidity/syntaxTests/string/string_unicode_without_prefix.sol index a204e84e5..581d9dd7d 100644 --- a/test/libsolidity/syntaxTests/string/string_unicode_without_prefix.sol +++ b/test/libsolidity/syntaxTests/string/string_unicode_without_prefix.sol @@ -4,4 +4,4 @@ contract test { } } // ---- -// ParserError 8936: (86-88): Invalid character in string. +// ParserError 8936: (86-88): Invalid character in string. If you are trying to use Unicode characters, use a unicode"..." string literal. diff --git a/test/libsolidity/syntaxTests/tupleAssignments/empty_tuple_assignment.sol b/test/libsolidity/syntaxTests/tupleAssignments/empty_tuple_assignment.sol new file mode 100644 index 000000000..940ef6d04 --- /dev/null +++ b/test/libsolidity/syntaxTests/tupleAssignments/empty_tuple_assignment.sol @@ -0,0 +1,35 @@ +function f() pure { + ((, ())) = (1, 3); +} + +function g() pure { + ((, ((, ())))) = (1, 3); +} + +function t() pure returns (int, int) { + return (4, 5); +} + +function h() pure { + ((, ())) = t(); +} + +function ff() pure { + ((((, ())) , )) = ((1, 2), 3); +} + +function fg() pure { + (((, ())) , ) = ((1, 2), 3); +} + +// ---- +// TypeError 5547: (28-30): Empty tuple on the left hand side. +// TypeError 7407: (35-41): Type tuple(int_const 1,int_const 3) is not implicitly convertible to expected type tuple(,tuple()). +// TypeError 5547: (78-80): Empty tuple on the left hand side. +// TypeError 7407: (87-93): Type tuple(int_const 1,int_const 3) is not implicitly convertible to expected type tuple(,tuple(,tuple())). +// TypeError 5547: (187-189): Empty tuple on the left hand side. +// TypeError 7407: (194-197): Type tuple(int256,int256) is not implicitly convertible to expected type tuple(,tuple()). +// TypeError 5547: (233-235): Empty tuple on the left hand side. +// TypeError 7407: (245-256): Type tuple(tuple(int_const 1,int_const 2),int_const 3) is not implicitly convertible to expected type tuple(tuple(,tuple()),). +// TypeError 5547: (291-293): Empty tuple on the left hand side. +// TypeError 7407: (302-313): Type tuple(tuple(int_const 1,int_const 2),int_const 3) is not implicitly convertible to expected type tuple(tuple(,tuple()),). diff --git a/test/libsolidity/syntaxTests/tupleAssignments/fixed_byte_array_assignment_in_tuple.sol b/test/libsolidity/syntaxTests/tupleAssignments/fixed_byte_array_assignment_in_tuple.sol new file mode 100644 index 000000000..287e09239 --- /dev/null +++ b/test/libsolidity/syntaxTests/tupleAssignments/fixed_byte_array_assignment_in_tuple.sol @@ -0,0 +1,7 @@ +contract A { + function f() pure public { + bytes1 b; + bytes1 a; + (((, , b))) = (1, 2, a); + } +} diff --git a/test/libsolidity/syntaxTests/tupleAssignments/tuple_to_function_assignment.sol b/test/libsolidity/syntaxTests/tupleAssignments/tuple_to_function_assignment.sol new file mode 100644 index 000000000..898c79101 --- /dev/null +++ b/test/libsolidity/syntaxTests/tupleAssignments/tuple_to_function_assignment.sol @@ -0,0 +1,17 @@ +contract C { + function f() internal pure {} + function g() internal pure returns (uint256) {} + function h() internal pure returns (uint256, uint256) {} + function test() public pure { + f() = (); + g() = (uint256(1)); + h() = (uint256(1), uint256(2)); + h() = (); + } +} +// ---- +// TypeError 4247: (184-187): Expression has to be an lvalue. +// TypeError 4247: (196-199): Expression has to be an lvalue. +// TypeError 4247: (218-221): Expression has to be an lvalue. +// TypeError 4247: (252-255): Expression has to be an lvalue. +// TypeError 7407: (258-260): Type tuple() is not implicitly convertible to expected type tuple(uint256,uint256). diff --git a/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies.sol b/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies.sol index 102bbea68..e35d361d2 100644 --- a/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies.sol +++ b/test/libsolidity/syntaxTests/tupleAssignments/warn_multiple_storage_storage_copies.sol @@ -4,6 +4,11 @@ contract C { function f() public { (x, y) = (y, x); } + function g() public { + uint z; + ((x, y), z) = ((y, x), 0); + } } // ---- // Warning 7238: (79-94): This assignment performs two copies to storage. Since storage copies do not first copy to a temporary location, one of them might be overwritten before the second is executed and thus may have unexpected effects. It is safer to perform the copies separately or assign to storage pointers first. +// Warning 7238: (134-159): This assignment performs two copies to storage. Since storage copies do not first copy to a temporary location, one of them might be overwritten before the second is executed and thus may have unexpected effects. It is safer to perform the copies separately or assign to storage pointers first. diff --git a/test/libsolidity/syntaxTests/types/bool_ops.sol b/test/libsolidity/syntaxTests/types/bool_ops.sol index 7aac8729b..b107c979a 100644 --- a/test/libsolidity/syntaxTests/types/bool_ops.sol +++ b/test/libsolidity/syntaxTests/types/bool_ops.sol @@ -32,22 +32,22 @@ contract C { } } // ---- -// TypeError 2271: (231-236): Operator > not compatible with types bool and bool -// TypeError 2271: (250-255): Operator < not compatible with types bool and bool -// TypeError 2271: (269-275): Operator >= not compatible with types bool and bool -// TypeError 2271: (289-295): Operator <= not compatible with types bool and bool -// TypeError 2271: (309-314): Operator & not compatible with types bool and bool -// TypeError 2271: (328-333): Operator | not compatible with types bool and bool -// TypeError 2271: (347-352): Operator ^ not compatible with types bool and bool -// TypeError 4907: (366-368): Unary operator ~ cannot be applied to type bool -// TypeError 4907: (382-384): Unary operator ~ cannot be applied to type bool -// TypeError 2271: (398-403): Operator + not compatible with types bool and bool -// TypeError 2271: (417-422): Operator - not compatible with types bool and bool -// TypeError 4907: (436-438): Unary operator - cannot be applied to type bool -// TypeError 4907: (452-454): Unary operator - cannot be applied to type bool -// TypeError 2271: (468-473): Operator * not compatible with types bool and bool -// TypeError 2271: (487-492): Operator / not compatible with types bool and bool -// TypeError 2271: (506-512): Operator ** not compatible with types bool and bool -// TypeError 2271: (526-531): Operator % not compatible with types bool and bool -// TypeError 2271: (545-551): Operator << not compatible with types bool and bool -// TypeError 2271: (565-571): Operator >> not compatible with types bool and bool +// TypeError 2271: (231-236): Operator > not compatible with types bool and bool. +// TypeError 2271: (250-255): Operator < not compatible with types bool and bool. +// TypeError 2271: (269-275): Operator >= not compatible with types bool and bool. +// TypeError 2271: (289-295): Operator <= not compatible with types bool and bool. +// TypeError 2271: (309-314): Operator & not compatible with types bool and bool. +// TypeError 2271: (328-333): Operator | not compatible with types bool and bool. +// TypeError 2271: (347-352): Operator ^ not compatible with types bool and bool. +// TypeError 4907: (366-368): Unary operator ~ cannot be applied to type bool. +// TypeError 4907: (382-384): Unary operator ~ cannot be applied to type bool. +// TypeError 2271: (398-403): Operator + not compatible with types bool and bool. +// TypeError 2271: (417-422): Operator - not compatible with types bool and bool. +// TypeError 4907: (436-438): Unary operator - cannot be applied to type bool. +// TypeError 4907: (452-454): Unary operator - cannot be applied to type bool. +// TypeError 2271: (468-473): Operator * not compatible with types bool and bool. +// TypeError 2271: (487-492): Operator / not compatible with types bool and bool. +// TypeError 2271: (506-512): Operator ** not compatible with types bool and bool. +// TypeError 2271: (526-531): Operator % not compatible with types bool and bool. +// TypeError 2271: (545-551): Operator << not compatible with types bool and bool. +// TypeError 2271: (565-571): Operator >> not compatible with types bool and bool. diff --git a/test/libsolidity/syntaxTests/types/hex_literal_bitnot.sol b/test/libsolidity/syntaxTests/types/hex_literal_bitnot.sol index 5fbfa919a..b5676f23c 100644 --- a/test/libsolidity/syntaxTests/types/hex_literal_bitnot.sol +++ b/test/libsolidity/syntaxTests/types/hex_literal_bitnot.sol @@ -2,4 +2,4 @@ contract C { bytes32 b = ~hex"00ff11"; } // ---- -// TypeError 4907: (29-41): Unary operator ~ cannot be applied to type literal_string hex"00ff11" +// TypeError 4907: (29-41): Unary operator ~ cannot be applied to type literal_string hex"00ff11". diff --git a/test/libsolidity/syntaxTests/types/mapping/function_type_argument_array.sol b/test/libsolidity/syntaxTests/types/mapping/function_type_argument_array.sol index e7587ad0c..9be0688d5 100644 --- a/test/libsolidity/syntaxTests/types/mapping/function_type_argument_array.sol +++ b/test/libsolidity/syntaxTests/types/mapping/function_type_argument_array.sol @@ -3,4 +3,4 @@ contract test { } } // ---- -// TypeError 4061: (31-64): Type mapping(uint256 => uint256)[2] is only valid in storage because it contains a (nested) mapping. +// TypeError 4061: (31-64): Type mapping(uint256 => uint256)[2] memory is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/library_nested_mapping.sol b/test/libsolidity/syntaxTests/types/mapping/library_nested_mapping.sol index 5eb22d833..4b1d77baa 100644 --- a/test/libsolidity/syntaxTests/types/mapping/library_nested_mapping.sol +++ b/test/libsolidity/syntaxTests/types/mapping/library_nested_mapping.sol @@ -4,4 +4,4 @@ library L { function f(S memory a) external pure returns (S memory) {} } // ---- -// TypeError 4061: (103-113): Type struct L.S is only valid in storage because it contains a (nested) mapping. +// TypeError 4061: (103-113): Type struct L.S memory is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/memory_struct_recursive.sol b/test/libsolidity/syntaxTests/types/mapping/memory_struct_recursive.sol index c6f8f48f3..4da809bd5 100644 --- a/test/libsolidity/syntaxTests/types/mapping/memory_struct_recursive.sol +++ b/test/libsolidity/syntaxTests/types/mapping/memory_struct_recursive.sol @@ -17,4 +17,4 @@ contract Test { } } // ---- -// TypeError 4061: (143-153): Type struct Test.S is only valid in storage because it contains a (nested) mapping. +// TypeError 4061: (143-153): Type struct Test.S memory is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/mapping/memory_structs_with_mappings.sol b/test/libsolidity/syntaxTests/types/mapping/memory_structs_with_mappings.sol index f583b4314..6d6dd65e4 100644 --- a/test/libsolidity/syntaxTests/types/mapping/memory_structs_with_mappings.sol +++ b/test/libsolidity/syntaxTests/types/mapping/memory_structs_with_mappings.sol @@ -12,4 +12,4 @@ contract Test { } // ---- -// TypeError 4061: (172-182): Type struct Test.S is only valid in storage because it contains a (nested) mapping. +// TypeError 4061: (172-182): Type struct Test.S memory is only valid in storage because it contains a (nested) mapping. diff --git a/test/libsolidity/syntaxTests/types/rational_number_bitshift_limit.sol b/test/libsolidity/syntaxTests/types/rational_number_bitshift_limit.sol index 9c59b015c..15146500a 100644 --- a/test/libsolidity/syntaxTests/types/rational_number_bitshift_limit.sol +++ b/test/libsolidity/syntaxTests/types/rational_number_bitshift_limit.sol @@ -8,6 +8,6 @@ contract c { } // ---- // TypeError 7407: (71-80): Type int_const 5221...(1225 digits omitted)...5168 is not implicitly convertible to expected type int256. Literal is too large to fit in int256. -// TypeError 2271: (133-142): Operator << not compatible with types int_const 1 and int_const 4096 -// TypeError 2271: (169-182): Operator << not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 2 +// TypeError 2271: (133-142): Operator << not compatible with types int_const 1 and int_const 4096. +// TypeError 2271: (169-182): Operator << not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 2. // TypeError 7407: (169-182): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. Literal is too large to fit in int256. diff --git a/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fail.sol b/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fail.sol index 2d7fbdfad..3ab4cdae3 100644 --- a/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fail.sol +++ b/test/libsolidity/syntaxTests/types/rational_number_exp_limit_fail.sol @@ -19,29 +19,29 @@ contract c { } } // ---- -// TypeError 2271: (71-112): Operator ** not compatible with types int_const 1797...(301 digits omitted)...7216 and int_const 4 +// TypeError 2271: (71-112): Operator ** not compatible with types int_const 1797...(301 digits omitted)...7216 and int_const 4. // TypeError 7407: (71-112): Type int_const 1797...(301 digits omitted)...7216 is not implicitly convertible to expected type int256. Literal is too large to fit in int256. -// TypeError 2271: (135-151): Operator ** not compatible with types int_const 4 and int_const 1157...(70 digits omitted)...9936 +// TypeError 2271: (135-151): Operator ** not compatible with types int_const 4 and int_const 1157...(70 digits omitted)...9936. // TypeError 7407: (126-169): Type int_const 1340...(147 digits omitted)...4096 is not implicitly convertible to expected type int256. Literal is too large to fit in int256. -// TypeError 2271: (201-217): Operator ** not compatible with types int_const 4 and int_const 1340...(147 digits omitted)...4096 -// TypeError 2271: (183-219): Operator ** not compatible with types int_const 4 and int_const -115...(71 digits omitted)...9936 -// TypeError 2271: (233-244): Operator ** not compatible with types int_const 2 and int_const 1000...(1226 digits omitted)...0000 -// TypeError 2271: (258-270): Operator ** not compatible with types int_const -2 and int_const 1000...(1226 digits omitted)...0000 -// TypeError 2271: (284-296): Operator ** not compatible with types int_const 2 and int_const -100...(1227 digits omitted)...0000 -// TypeError 2271: (310-323): Operator ** not compatible with types int_const -2 and int_const -100...(1227 digits omitted)...0000 -// TypeError 2271: (337-348): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 2 +// TypeError 2271: (201-217): Operator ** not compatible with types int_const 4 and int_const 1340...(147 digits omitted)...4096. +// TypeError 2271: (183-219): Operator ** not compatible with types int_const 4 and int_const -115...(71 digits omitted)...9936. +// TypeError 2271: (233-244): Operator ** not compatible with types int_const 2 and int_const 1000...(1226 digits omitted)...0000. +// TypeError 2271: (258-270): Operator ** not compatible with types int_const -2 and int_const 1000...(1226 digits omitted)...0000. +// TypeError 2271: (284-296): Operator ** not compatible with types int_const 2 and int_const -100...(1227 digits omitted)...0000. +// TypeError 2271: (310-323): Operator ** not compatible with types int_const -2 and int_const -100...(1227 digits omitted)...0000. +// TypeError 2271: (337-348): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 2. // TypeError 7407: (337-348): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. Literal is too large to fit in int256. -// TypeError 2271: (362-374): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 2 +// TypeError 2271: (362-374): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 2. // TypeError 7407: (362-374): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. Literal is too large to fit in int256. -// TypeError 2271: (388-400): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -2 +// TypeError 2271: (388-400): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -2. // TypeError 7407: (388-400): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. Literal is too large to fit in int256. -// TypeError 2271: (414-427): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -2 +// TypeError 2271: (414-427): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -2. // TypeError 7407: (414-427): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. Literal is too large to fit in int256. -// TypeError 2271: (441-457): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 1000...(1226 digits omitted)...0000 +// TypeError 2271: (441-457): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 1000...(1226 digits omitted)...0000. // TypeError 7407: (441-457): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. Literal is too large to fit in int256. -// TypeError 2271: (471-488): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -100...(1227 digits omitted)...0000 +// TypeError 2271: (471-488): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -100...(1227 digits omitted)...0000. // TypeError 7407: (471-488): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. Literal is too large to fit in int256. -// TypeError 2271: (502-519): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 1000...(1226 digits omitted)...0000 +// TypeError 2271: (502-519): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 1000...(1226 digits omitted)...0000. // TypeError 7407: (502-519): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. Literal is too large to fit in int256. -// TypeError 2271: (533-551): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -100...(1227 digits omitted)...0000 +// TypeError 2271: (533-551): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -100...(1227 digits omitted)...0000. // TypeError 7407: (533-551): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. Literal is too large to fit in int256. diff --git a/test/libsolidity/util/ContractABIUtils.cpp b/test/libsolidity/util/ContractABIUtils.cpp index 3ffebbf10..b94de7bec 100644 --- a/test/libsolidity/util/ContractABIUtils.cpp +++ b/test/libsolidity/util/ContractABIUtils.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include @@ -281,26 +281,16 @@ void ContractABIUtils::overwriteParameters( ) { using namespace placeholders; - boost::for_each( - _sourceParameters, - _targetParameters, - std::bind( - [&](Parameter _a, Parameter& _b) -> void + for (auto&& [source, target]: ranges::views::zip(_sourceParameters, _targetParameters)) + if ( + source.abiType.size != target.abiType.size || + source.abiType.type != target.abiType.type || + source.abiType.fractionalDigits != target.abiType.fractionalDigits + ) { - if ( - _a.abiType.size != _b.abiType.size || - _a.abiType.type != _b.abiType.type || - _a.abiType.fractionalDigits != _b.abiType.fractionalDigits - ) - { - _errorReporter.warning("Type or size of parameter(s) does not match."); - _b = _a; - } - }, - _1, - _2 - ) - ); + _errorReporter.warning("Type or size of parameter(s) does not match."); + target = source; + } } solidity::frontend::test::ParameterList ContractABIUtils::preferredParameters( diff --git a/test/libsolidity/util/SoltestTypes.h b/test/libsolidity/util/SoltestTypes.h index bd954f042..b5b746e32 100644 --- a/test/libsolidity/util/SoltestTypes.h +++ b/test/libsolidity/util/SoltestTypes.h @@ -268,6 +268,7 @@ struct FunctionValue struct FunctionCall { /// Signature of the function call, e.g. `f(uint256, uint256)`. + /// For a library deployment, this contains the library name. std::string signature; /// Optional value that can be sent with the call. /// Value is expressed in wei, smallest unit of ether @@ -313,6 +314,8 @@ struct FunctionCall std::vector expectedSideEffects{}; /// A textual representation of the actual side-effect of the function call. std::vector actualSideEffects{}; + /// File name of the library. Always empty, unless this is a library deployment call. + std::string libraryFile{}; }; using Builtin = std::function(FunctionCall const&)>; diff --git a/test/libsolidity/util/TestFileParser.cpp b/test/libsolidity/util/TestFileParser.cpp index 11cfdbb86..915586ad2 100644 --- a/test/libsolidity/util/TestFileParser.cpp +++ b/test/libsolidity/util/TestFileParser.cpp @@ -107,15 +107,15 @@ vector TestFileParser::parseFunctionCall string libraryName; if (accept(Token::String)) { - libraryName = m_scanner.currentLiteral(); + call.libraryFile = m_scanner.currentLiteral(); expect(Token::String); expect(Token::Colon); - libraryName += ':' + m_scanner.currentLiteral(); + libraryName += m_scanner.currentLiteral(); expect(Token::Identifier); } else if (accept(Token::Colon, true)) { - libraryName = ':' + m_scanner.currentLiteral(); + libraryName = m_scanner.currentLiteral(); expect(Token::Identifier); } else @@ -178,7 +178,7 @@ vector TestFileParser::parseFunctionCall accept(Token::Newline, true); call.expectedSideEffects = parseFunctionCallSideEffects(); - calls.emplace_back(move(call)); + calls.emplace_back(std::move(call)); } } catch (TestParserError const& _e) diff --git a/test/libsolidity/util/TestFileParser.h b/test/libsolidity/util/TestFileParser.h index 7e89ff09e..80281126c 100644 --- a/test/libsolidity/util/TestFileParser.h +++ b/test/libsolidity/util/TestFileParser.h @@ -98,7 +98,7 @@ private: void advance(unsigned n = 1) { solAssert(m_char != m_source.end(), "Cannot advance beyond end."); - m_char = std::next(m_char, n); + m_char = std::next(m_char, static_cast(n)); } /// Returns the current character or '\0' if at end of input. diff --git a/test/libsolidity/util/TestFunctionCall.cpp b/test/libsolidity/util/TestFunctionCall.cpp index c51dbec97..7531d8ce5 100644 --- a/test/libsolidity/util/TestFunctionCall.cpp +++ b/test/libsolidity/util/TestFunctionCall.cpp @@ -58,7 +58,10 @@ string TestFunctionCall::format( if (m_call.kind == FunctionCall::Kind::Library) { - stream << _linePrefix << newline << ws << "library:" << ws << m_call.signature; + stream << _linePrefix << newline << ws << "library:" << ws; + if (!m_call.libraryFile.empty()) + stream << "\"" << m_call.libraryFile << "\":"; + stream << m_call.signature; return; } diff --git a/test/libsolutil/StringUtils.cpp b/test/libsolutil/StringUtils.cpp index 0ef61cb0a..db72297e7 100644 --- a/test/libsolutil/StringUtils.cpp +++ b/test/libsolutil/StringUtils.cpp @@ -152,6 +152,64 @@ BOOST_AUTO_TEST_CASE(test_format_number_readable) formatNumberReadable(frontend::IntegerType(256).maxValue()), "2**256 - 1"); } +BOOST_AUTO_TEST_CASE(test_format_number_readable_signed) +{ + BOOST_CHECK_EQUAL(formatNumberReadable((-1) * s256(0x8000000)), "-0x08 * 2**24"); + BOOST_CHECK_EQUAL(formatNumberReadable((-1) * s256(0x80000000)), "-0x80 * 2**24"); + BOOST_CHECK_EQUAL(formatNumberReadable((-1) * s256(0x800000000)), "-0x08 * 2**32"); + BOOST_CHECK_EQUAL(formatNumberReadable((-1) * s256(0x8000000000)), "-0x80 * 2**32"); + BOOST_CHECK_EQUAL(formatNumberReadable((-1) * s256(0x80000000000)), "-0x08 * 2**40"); + + BOOST_CHECK_EQUAL(formatNumberReadable((-1) * s256(0x7ffffff)), "-0x08 * 2**24 - 1"); + BOOST_CHECK_EQUAL(formatNumberReadable((-1) * s256(0x7fffffff)), "-0x80 * 2**24 - 1"); + BOOST_CHECK_EQUAL(formatNumberReadable((-1) * s256(0x7ffffffff)), "-0x08 * 2**32 - 1"); + BOOST_CHECK_EQUAL(formatNumberReadable((-1) * s256(0x7fffffffff)), "-0x80 * 2**32 - 1"); + BOOST_CHECK_EQUAL(formatNumberReadable((-1) * s256(0x7ffffffffff)), "-0x08 * 2**40 - 1"); + + BOOST_CHECK_EQUAL(formatNumberReadable((-1) * s256(0x88000000)), "-0x88 * 2**24"); + BOOST_CHECK_EQUAL(formatNumberReadable((-1) * s256(0x8888888888000000)), "-0x8888888888 * 2**24"); + + s256 b = 0; + for (int i = 0; i < 32; i++) + { + b <<= 8; + b |= 0x55; + } + b = b * (-1); + + s256 c = (-1) * u2s((u256)FixedHash<32>( + fromHex("0x0bcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789") + )); + + s256 d = (-1) * u2s( + u256(0x5555555555555555) << 192 | + u256(0xFFFFffffFFFFffff) << 128 | + u256(0xFFFFffffFFFFffff) << 64 | + u256(0xFFFFffffFFFFffff) + ); + + BOOST_CHECK_EQUAL(formatNumberReadable(b, true), "-0x5555...{+56 more}...5555"); + BOOST_CHECK_EQUAL(formatNumberReadable(c, true), "-0x0BCD...{+56 more}...6789"); + BOOST_CHECK_EQUAL(formatNumberReadable(d, true), "-0x5555555555555556 * 2**192 - 1"); + + BOOST_CHECK_EQUAL(formatNumberReadable(s256(-1)), "-1"); + BOOST_CHECK_EQUAL(formatNumberReadable((-1) * s256(0x10000)), "-65536"); + BOOST_CHECK_EQUAL(formatNumberReadable((-1) * s256(0xFFFF)), "-65535"); + + BOOST_CHECK_EQUAL( + formatNumberReadable( + frontend::IntegerType(256, frontend::IntegerType::Modifier::Signed).minValue() + ), + "-0x80 * 2**248" + ); + BOOST_CHECK_EQUAL( + formatNumberReadable( + frontend::IntegerType(256, frontend::IntegerType::Modifier::Signed).maxValue() + ), + "0x80 * 2**248 - 1" + ); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/libsolutil/Whiskers.cpp b/test/libsolutil/Whiskers.cpp index 3ccaa64da..4f148f101 100644 --- a/test/libsolutil/Whiskers.cpp +++ b/test/libsolutil/Whiskers.cpp @@ -85,6 +85,13 @@ BOOST_AUTO_TEST_CASE(conditional_with_else) BOOST_CHECK_EQUAL(Whiskers(templ)("b", false).render(), "Y"); } +BOOST_AUTO_TEST_CASE(broken_conditional_with_else) +{ + string templ = "X"; + BOOST_CHECK_EQUAL(Whiskers(templ)("b", true).render(), "X_^ - "; diff --git a/test/libyul/ObjectParser.cpp b/test/libyul/ObjectParser.cpp index bee0025af..be3de930d 100644 --- a/test/libyul/ObjectParser.cpp +++ b/test/libyul/ObjectParser.cpp @@ -122,7 +122,7 @@ tuple, ErrorList> tryGetSourceLocationMapping(string _so ErrorReporter reporter(errors); Dialect const& dialect = yul::EVMDialect::strictAssemblyForEVM(EVMVersion::berlin()); ObjectParser objectParser{reporter, dialect}; - CharStream stream(move(source), ""); + CharStream stream(std::move(source), ""); auto object = objectParser.parse(make_shared(stream), false); BOOST_REQUIRE(object && object->debugData); return {object->debugData->sourceNames, std::move(errors)}; diff --git a/test/libyul/Parser.cpp b/test/libyul/Parser.cpp index 49152e7f8..511ed6c19 100644 --- a/test/libyul/Parser.cpp +++ b/test/libyul/Parser.cpp @@ -65,7 +65,7 @@ shared_ptr parse(string const& _source, Dialect const& _dialect, ErrorRep auto parserResult = yul::Parser( errorReporter, _dialect, - move(indicesToSourceNames) + std::move(indicesToSourceNames) ).parse(stream); if (parserResult) { diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_add_and_mod_constant.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_add_and_mod_constant.yul new file mode 100644 index 000000000..f462486ea --- /dev/null +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_add_and_mod_constant.yul @@ -0,0 +1,13 @@ +{ + mstore(0, mod(add(mload(0), mload(1)), 32)) +} +// ---- +// step: expressionSimplifier +// +// { +// { +// let _3 := mload(1) +// let _4 := 0 +// mstore(_4, addmod(mload(_4), _3, 32)) +// } +// } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/combine_mul_and_mod_constant.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_mul_and_mod_constant.yul new file mode 100644 index 000000000..93edb5319 --- /dev/null +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/combine_mul_and_mod_constant.yul @@ -0,0 +1,13 @@ +{ + mstore(0, mod(mul(mload(0), mload(1)), 32)) +} +// ---- +// step: expressionSimplifier +// +// { +// { +// let _3 := mload(1) +// let _4 := 0 +// mstore(_4, mulmod(mload(_4), _3, 32)) +// } +// } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul index bd567a69a..9c3a5c8ba 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul @@ -1,5 +1,5 @@ { - for {} div(create(0, 1, 0), shl(msize(), 1)) {} + for {} div(create(0, 1, 1), shl(msize(), 1)) {} { } } @@ -10,7 +10,7 @@ // // { // { -// for { } div(create(0, 1, 0), shl(msize(), 1)) { } +// for { } div(create(0, 1, 1), shl(msize(), 1)) { } // { } // } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/zero_length_read.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/zero_length_read.yul new file mode 100644 index 000000000..ee7464932 --- /dev/null +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/zero_length_read.yul @@ -0,0 +1,21 @@ +{ + revert(calldataload(0), 0) + revert(call(0,0,0,0,0,0,0), 0) + calldatacopy(calldataload(1), calldataload(2), 0) + return(calldataload(3), 0) + codecopy(calldataload(4), calldataload(5), sub(42,42)) +} +// ---- +// step: expressionSimplifier +// +// { +// { +// let _1 := 0 +// revert(0, _1) +// pop(call(_1, _1, _1, _1, _1, _1, _1)) +// revert(0, _1) +// calldatacopy(0, calldataload(2), _1) +// return(0, _1) +// codecopy(0, calldataload(5), 0) +// } +// } diff --git a/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_function.yul b/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_function.yul index fbc0ca856..d120d0152 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_function.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_function.yul @@ -1,5 +1,5 @@ { - function f(a) -> b { + function f(a) -> b { let x := mload(a) b := sload(x) } @@ -9,6 +9,8 @@ x := f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(2))))))))))))))))))) } } +// ==== +// EVMVersion: >homestead // ---- // step: fullInliner // diff --git a/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_function_homestead.yul b/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_function_homestead.yul new file mode 100644 index 000000000..04a9417d2 --- /dev/null +++ b/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_function_homestead.yul @@ -0,0 +1,64 @@ +{ + function f(a) -> b { + let x := mload(a) + b := sload(x) + } + // This will stop inlining at some point because + // the function gets too big. + function g() -> x { + x := f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(2))))))))))))))))))) + } +} +// ==== +// EVMVersion: <=homestead +// ---- +// step: fullInliner +// +// { +// { } +// function f(a) -> b +// { b := sload(mload(a)) } +// function g() -> x_1 +// { +// let a_20 := 2 +// let b_21 := 0 +// b_21 := sload(mload(a_20)) +// let a_23 := b_21 +// let b_24 := 0 +// b_24 := sload(mload(a_23)) +// let a_26 := b_24 +// let b_27 := 0 +// b_27 := sload(mload(a_26)) +// let a_29 := b_27 +// let b_30 := 0 +// b_30 := sload(mload(a_29)) +// let a_32 := b_30 +// let b_33 := 0 +// b_33 := sload(mload(a_32)) +// let a_35 := b_33 +// let b_36 := 0 +// b_36 := sload(mload(a_35)) +// let a_38 := b_36 +// let b_39 := 0 +// b_39 := sload(mload(a_38)) +// let a_41 := b_39 +// let b_42 := 0 +// b_42 := sload(mload(a_41)) +// let a_44 := b_42 +// let b_45 := 0 +// b_45 := sload(mload(a_44)) +// let a_47 := b_45 +// let b_48 := 0 +// b_48 := sload(mload(a_47)) +// let a_50 := b_48 +// let b_51 := 0 +// b_51 := sload(mload(a_50)) +// let a_53 := b_51 +// let b_54 := 0 +// b_54 := sload(mload(a_53)) +// let a_56 := b_54 +// let b_57 := 0 +// b_57 := sload(mload(a_56)) +// x_1 := f(f(f(f(f(f(b_57)))))) +// } +// } diff --git a/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_global_context.yul b/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_global_context.yul index 10ccc2a37..875d715c5 100644 --- a/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_global_context.yul +++ b/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_global_context.yul @@ -1,5 +1,5 @@ { - function f(a) -> b { + function f(a) -> b { let x := mload(a) b := sload(x) } @@ -7,6 +7,8 @@ // the global context gets too big. let x := f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(2))))))))))))))))))) } +// ==== +// EVMVersion: >homestead // ---- // step: fullInliner // diff --git a/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_global_context_homestead.yul b/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_global_context_homestead.yul new file mode 100644 index 000000000..3d62caa2f --- /dev/null +++ b/test/libyul/yulOptimizerTests/fullInliner/no_inline_into_big_global_context_homestead.yul @@ -0,0 +1,60 @@ +{ + function f(a) -> b { + let x := mload(a) + b := sload(x) + } + // This will stop inlining at some point because + // the global context gets too big. + let x := f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(2))))))))))))))))))) +} +// ==== +// EVMVersion: <=homestead +// ---- +// step: fullInliner +// +// { +// { +// let a_20 := 2 +// let b_21 := 0 +// b_21 := sload(mload(a_20)) +// let a_23 := b_21 +// let b_24 := 0 +// b_24 := sload(mload(a_23)) +// let a_26 := b_24 +// let b_27 := 0 +// b_27 := sload(mload(a_26)) +// let a_29 := b_27 +// let b_30 := 0 +// b_30 := sload(mload(a_29)) +// let a_32 := b_30 +// let b_33 := 0 +// b_33 := sload(mload(a_32)) +// let a_35 := b_33 +// let b_36 := 0 +// b_36 := sload(mload(a_35)) +// let a_38 := b_36 +// let b_39 := 0 +// b_39 := sload(mload(a_38)) +// let a_41 := b_39 +// let b_42 := 0 +// b_42 := sload(mload(a_41)) +// let a_44 := b_42 +// let b_45 := 0 +// b_45 := sload(mload(a_44)) +// let a_47 := b_45 +// let b_48 := 0 +// b_48 := sload(mload(a_47)) +// let a_50 := b_48 +// let b_51 := 0 +// b_51 := sload(mload(a_50)) +// let a_53 := b_51 +// let b_54 := 0 +// b_54 := sload(mload(a_53)) +// let a_56 := b_54 +// let b_57 := 0 +// b_57 := sload(mload(a_56)) +// let x_1 := f(f(f(f(f(f(b_57)))))) +// } +// function f(a) -> b +// { b := sload(mload(a)) } +// } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/returndatacopy_fixed_size.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/returndatacopy_fixed_size.yul new file mode 100644 index 000000000..50c05e826 --- /dev/null +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/returndatacopy_fixed_size.yul @@ -0,0 +1,9 @@ +{ + returndatacopy(0,0,32) +} +// ==== +// EVMVersion: >homestead +// ---- +// step: unusedStoreEliminator +// +// { { returndatacopy(0, 0, 32) } } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/returndatacopy_returndatasize.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/returndatacopy_returndatasize.yul new file mode 100644 index 000000000..e0d5cbf1c --- /dev/null +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/returndatacopy_returndatasize.yul @@ -0,0 +1,15 @@ +{ + returndatacopy(0,0,returndatasize()) +} +// ==== +// EVMVersion: >homestead +// ---- +// step: unusedStoreEliminator +// +// { +// { +// let _1 := returndatasize() +// let _2 := 0 +// let _3 := 0 +// } +// } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/returndatacopy_returndatasize_nonzero_start.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/returndatacopy_returndatasize_nonzero_start.yul new file mode 100644 index 000000000..a40e76955 --- /dev/null +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/returndatacopy_returndatasize_nonzero_start.yul @@ -0,0 +1,13 @@ +{ + returndatacopy(0,1,returndatasize()) +} +// ==== +// EVMVersion: >homestead +// ---- +// step: unusedStoreEliminator +// +// { +// { +// returndatacopy(0, 1, returndatasize()) +// } +// } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/returndatacopy_returndatasize_var.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/returndatacopy_returndatasize_var.yul new file mode 100644 index 000000000..eac2070f7 --- /dev/null +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/returndatacopy_returndatasize_var.yul @@ -0,0 +1,16 @@ +{ + let s := returndatasize() + returndatacopy(0,0,s) +} +// ==== +// EVMVersion: >homestead +// ---- +// step: unusedStoreEliminator +// +// { +// { +// let s := returndatasize() +// let _1 := 0 +// let _2 := 0 +// } +// } diff --git a/test/libyul/yulSyntaxTests/invalid/unicode_string_direction_override.sol b/test/libyul/yulSyntaxTests/invalid/unicode_string_direction_override.yul similarity index 100% rename from test/libyul/yulSyntaxTests/invalid/unicode_string_direction_override.sol rename to test/libyul/yulSyntaxTests/invalid/unicode_string_direction_override.yul diff --git a/test/lsp.py b/test/lsp.py index 9a4335d73..2e097dab0 100755 --- a/test/lsp.py +++ b/test/lsp.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # pragma pylint: disable=too-many-lines # test line 1 +from __future__ import annotations # See: https://github.com/PyCQA/pylint/issues/3320 import argparse import fnmatch import functools @@ -15,7 +16,7 @@ from copy import deepcopy from enum import Enum, auto from itertools import islice from pathlib import PurePath -from typing import Any, List, Optional, Tuple, Union +from typing import Any, List, Optional, Tuple, Union, NewType import colorama # Enables the use of SGR & CUP terminal VT sequences on Windows. from deepdiff import DeepDiff @@ -30,6 +31,13 @@ else: tty.setcbreak(sys.stdin.fileno()) +# Type for the pure test name without .sol suffix or sub directory +TestName = NewType("TestName", str) + +# Type for the test path, e.g. subdir/mytest.sol +RelativeTestPath = NewType("RelativeTestPath", str) + + def escape_string(text: str) -> str: """ Trivially escapes given input string's \r \n and \\. @@ -41,7 +49,7 @@ def escape_string(text: str) -> str: })) -def getCharFromStdin(): +def getCharFromStdin() -> str: """ Gets a single character from stdin without line-buffering. """ @@ -49,7 +57,7 @@ def getCharFromStdin(): # pragma pylint: disable=import-error return msvcrt.getch().decode("utf-8") else: - return sys.stdin.buffer.read(1) + return sys.stdin.read(1) """ @@ -69,7 +77,7 @@ TEST_REGEXES = TestRegexesTuple( re.compile(R'^// -> (?P[\w\/]+) {'), re.compile(R'(?P"@\w+")'), re.compile(R'(?P@\w+)'), - re.compile(R'// (?P\w+):[ ]?(?P[\w @]*)'), + re.compile(R'// (?P\S+):([ ](?P[\w @]*))?'), re.compile(R'(?P@\w+) (?P\d\d\d\d)') ) @@ -86,7 +94,7 @@ def split_path(path): """ Return the test name and the subdir path of the given path. """ - sub_dir_separator = path.find("/") + sub_dir_separator = path.rfind("/") if sub_dir_separator == -1: return (path, None) @@ -105,7 +113,8 @@ def count_index(lines, start=0): def tags_only(lines, start=0): """ - Filter the lines for tag comments and report line number that tags refer to. + Filter the lines for tag comments and report the line number that the tags + _refer_ to (which is not the line they are on!). """ n = start numCommentLines = 0 @@ -147,11 +156,13 @@ class JsonRpcProcess: exe_args: List[str] process: subprocess.Popen trace_io: bool + print_pid: bool - def __init__(self, exe_path: str, exe_args: List[str], trace_io: bool = True): + def __init__(self, exe_path: str, exe_args: List[str], trace_io: bool = True, print_pid = False): self.exe_path = exe_path self.exe_args = exe_args self.trace_io = trace_io + self.print_pid = print_pid def __enter__(self): self.process = subprocess.Popen( @@ -160,6 +171,10 @@ class JsonRpcProcess: stdout=subprocess.PIPE, stderr=subprocess.PIPE ) + + if self.print_pid: + print(f"solc pid: {self.process.pid}. Attach with sudo gdb -p {self.process.pid}") + return self def __exit__(self, exception_type, exception_value, traceback) -> None: @@ -223,8 +238,10 @@ class JsonRpcProcess: self.process.stdin.write(rpc_message.encode("utf-8")) self.process.stdin.flush() - def call_method(self, method_name: str, params: Optional[dict]) -> Any: + def call_method(self, method_name: str, params: Optional[dict], expects_response: bool = True) -> Any: self.send_message(method_name, params) + if not expects_response: + return None return self.receive_message() def send_notification(self, name: str, params: Optional[dict] = None) -> None: @@ -272,27 +289,41 @@ def create_cli_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser(description="Solidity LSP Test suite") parser.set_defaults(fail_fast=False) parser.add_argument( - "-f, --fail-fast", + "-f", "--fail-fast", dest="fail_fast", action="store_true", help="Terminates the running tests on first failure." ) + parser.set_defaults(non_interactive=False) + parser.add_argument( + "-n", "--non-interactive", + dest="non_interactive", + action="store_true", + help="Prevent interactive queries and just fail instead." + ) + parser.set_defaults(print_solc_pid=False) + parser.add_argument( + "-p", "--print-solc-pid", + dest="print_solc_pid", + action="store_true", + help="Print pid of each started solc for debugging purposes." + ) parser.set_defaults(trace_io=False) parser.add_argument( - "-T, --trace-io", + "-T", "--trace-io", dest="trace_io", action="store_true", help="Be more verbose by also printing assertions." ) parser.set_defaults(print_assertions=False) parser.add_argument( - "-v, --print-assertions", + "-v", "--print-assertions", dest="print_assertions", action="store_true", help="Be more verbose by also printing assertions." ) parser.add_argument( - "-t, --test-pattern", + "-t", "--test-pattern", dest="test_pattern", type=str, default="*", @@ -339,10 +370,13 @@ class TestParser: parsed_testcases = TestParser(content).parse() - # First diagnostics are yielded + # First diagnostics are yielded. + # Type is "TestParser.Diagnostics" expected_diagnostics = next(parsed_testcases) + ... # Now each request/response pair in the test definition + # Type is "TestParser.RequestAndResponse" for testcase in self.parsed_testcases: ... """ @@ -385,11 +419,11 @@ class TestParser: yield self.parseDiagnostics() while not self.at_end(): - yield self.RequestAndResponse(**self.parseRequestAndResponse()) + yield self.parseRequestAndResponse() self.next_line() - def parseDiagnostics(self): + def parseDiagnostics(self) -> TestParser.Diagnostics: """ Parse diagnostic expectations specified in the file. Returns a named tuple instance of "Diagnostics" @@ -405,11 +439,13 @@ class TestParser: testDiagnostics = [] - for diagnosticMatch in TEST_REGEXES.diagnostic.finditer(fileDiagMatch.group("diagnostics")): - testDiagnostics.append(self.Diagnostic( - diagnosticMatch.group("tag"), - int(diagnosticMatch.group("code")) - )) + diagnostics_string = fileDiagMatch.group("diagnostics") + if diagnostics_string is not None: + for diagnosticMatch in TEST_REGEXES.diagnostic.finditer(diagnostics_string): + testDiagnostics.append(self.Diagnostic( + diagnosticMatch.group("tag"), + int(diagnosticMatch.group("code")) + )) diagnostics["tests"][fileDiagMatch.group("testname")] = testDiagnostics @@ -419,7 +455,7 @@ class TestParser: return self.Diagnostics(**diagnostics) - def parseRequestAndResponse(self): + def parseRequestAndResponse(self) -> TestParser.RequestAndResponse: RESPONSE_START = "// <- " REQUEST_END = "// }" COMMENT_PREFIX = "// " @@ -451,6 +487,8 @@ class TestParser: if self.at_end(): raise TestParserException(ret, "Request body not found") + if self.at_end(): + return self.RequestAndResponse(**ret) # Parse response header if self.current_line().startswith(RESPONSE_START): @@ -459,8 +497,6 @@ class TestParser: raise TestParserException(ret, "Response header malformed") ret["response"] = self.current_line()[len(RESPONSE_START):] + "\n" ret["responseBegin"] = self.position() - else: - raise TestParserException(ret, "Response header not found") self.next_line() @@ -480,7 +516,7 @@ class TestParser: if self.at_end(): raise TestParserException(ret, "Response footer not found") - return ret + return self.RequestAndResponse(**ret) def next_line(self): self.current_line_tuple = next(self.lines, None) @@ -502,6 +538,11 @@ class TestParser: """ return self.current_line_tuple is None +class FileLoadStrategy(Enum): + Undefined = None + ProjectDirectory = 'project-directory' + DirectlyOpenedAndOnImport = 'directly-opened-and-on-import' + class FileTestRunner: """ Runs all tests in a given file. @@ -522,7 +563,7 @@ class FileTestRunner: self.solc = solc self.open_tests = [] self.content = self.suite.get_test_file_contents(self.test_name, self.sub_dir) - self.markers = self.suite.get_file_tags(self.test_name, self.sub_dir) + self.markers = self.suite.get_test_tags(self.test_name, self.sub_dir) self.parsed_testcases = None self.expected_diagnostics = None @@ -535,13 +576,15 @@ class FileTestRunner: # Process diagnostics first self.expected_diagnostics = next(self.parsed_testcases) - assert isinstance(self.expected_diagnostics, TestParser.Diagnostics) is True + assert isinstance(self.expected_diagnostics, TestParser.Diagnostics) + if not self.expected_diagnostics.has_header: + return - tests = self.expected_diagnostics.tests + expected_diagnostics_per_file = self.expected_diagnostics.tests # Add our own test diagnostics if they didn't exist - if self.test_name not in tests: - tests[self.test_name] = [] + if self.test_name not in expected_diagnostics_per_file: + expected_diagnostics_per_file[self.test_name] = [] published_diagnostics = \ self.suite.open_file_and_wait_for_diagnostics(self.solc, self.test_name, self.sub_dir) @@ -551,25 +594,27 @@ class FileTestRunner: raise Exception( f"'{self.test_name}.sol' imported file outside of test directory: '{diagnostics['uri']}'" ) - self.open_tests.append(diagnostics["uri"].replace(self.suite.project_root_uri + "/", "")[:-len(".sol")]) + self.open_tests.append(self.suite.normalizeUri(diagnostics["uri"])) self.suite.expect_equal( len(published_diagnostics), - len(tests), + len(expected_diagnostics_per_file), description="Amount of reports does not match!") - for diagnostics in published_diagnostics: - testname_and_subdir = diagnostics["uri"].replace(self.suite.project_root_uri + "/", "")[:-len(".sol")] - testname, sub_dir = split_path(testname_and_subdir) + for diagnostics_per_file in published_diagnostics: + testname, sub_dir = split_path(self.suite.normalizeUri(diagnostics_per_file['uri'])) + + # Clear all processed expectations so we can check at the end + # what's missing + expected_diagnostics = expected_diagnostics_per_file.pop(testname, {}) - expected_diagnostics = tests[testname] self.suite.expect_equal( - len(diagnostics["diagnostics"]), + len(diagnostics_per_file["diagnostics"]), len(expected_diagnostics), description="Unexpected amount of diagnostics" ) - markers = self.suite.get_file_tags(testname, sub_dir) - for actual_diagnostic in diagnostics["diagnostics"]: + markers = self.suite.get_test_tags(testname, sub_dir) + for actual_diagnostic in diagnostics_per_file["diagnostics"]: expected_diagnostic = next((diagnostic for diagnostic in expected_diagnostics if actual_diagnostic['range'] == markers[diagnostic.marker]), None) @@ -586,6 +631,12 @@ class FileTestRunner: marker=markers[expected_diagnostic.marker] ) + if len(expected_diagnostics_per_file) > 0: + raise ExpectationFailed( + f"Expected diagnostics but received none for {expected_diagnostics_per_file}", + ExpectationFailed.Part.Diagnostics + ) + except Exception: self.close_all_open_files() raise @@ -625,7 +676,13 @@ class FileTestRunner: finally: self.close_all_open_files() - def user_interaction_failed_method_test(self, testcase, actual, expected): + def user_interaction_failed_method_test( + self, + testcase: TestParser.RequestAndResponse, + actual, + expected + ) -> TestResult: + actual_pretty = self.suite.replace_ranges_with_tags(actual, self.sub_dir) if expected is None: @@ -636,6 +693,9 @@ class FileTestRunner: "\nbut got:\n" + actual_pretty ) + if self.suite.non_interactive: + return self.TestResult.SuccessOrIgnored + while True: print("(u)pdate/(r)etry/(i)gnore?") user_response = getCharFromStdin() @@ -667,16 +727,36 @@ class FileTestRunner: """ Runs the given testcase. """ + requestBodyJson = self.parse_json_with_tags(testcase.request, self.markers) # add textDocument/uri if missing if 'textDocument' not in requestBodyJson: requestBodyJson['textDocument'] = { 'uri': self.suite.get_test_file_uri(self.test_name, self.sub_dir) } - actualResponseJson = self.solc.call_method(testcase.method, requestBodyJson) + + actualResponseJson = self.solc.call_method( + testcase.method, + requestBodyJson, + expects_response=testcase.response is not None + ) + + if testcase.response is None: + return # simplify response - for result in actualResponseJson["result"]: - if "uri" in result: - result["uri"] = result["uri"].replace(self.suite.project_root_uri + "/" + self.sub_dir + "/", "") + if "result" in actualResponseJson: + if isinstance(actualResponseJson["result"], list): + for result in actualResponseJson["result"]: + if "uri" in result: + result["uri"] = result["uri"].replace(self.suite.project_root_uri + "/" + self.sub_dir + "/", "") + + elif isinstance(actualResponseJson["result"], dict): + if "changes" in actualResponseJson["result"]: + changes = actualResponseJson["result"]["changes"] + for key in list(changes.keys()): + new_key = key.replace(self.suite.project_root_uri + "/", "") + changes[new_key] = changes[key] + del changes[key] + if "jsonrpc" in actualResponseJson: actualResponseJson.pop("jsonrpc") @@ -716,21 +796,39 @@ class FileTestRunner: if not isinstance(data, dict): return data + def findMarker(desired_tag): + if not isinstance(desired_tag, str): + return desired_tag + + for tag, tagRange in markers.items(): + if tag == desired_tag: + return tagRange + elif tag.lower() == desired_tag.lower(): + raise Exception(f"Detected lower/upper case mismatch: Requested {desired_tag} but only found {tag}") + + raise Exception(f"Marker {desired_tag} not found in file") + + # Check if we need markers from a specific file # Needs to be done before the loop or it might be called only after # we found "range" or "position" if "uri" in data: - markers = self.suite.get_file_tags(data["uri"][:-len(".sol")], self.sub_dir) + markers = self.suite.get_test_tags(data["uri"][:-len(".sol")], self.sub_dir) for key, val in data.items(): if key == "range": - for tag, tagRange in markers.items(): - if tag == val: - data[key] = tagRange + data[key] = findMarker(val) elif key == "position": - for tag, tagRange in markers.items(): - if tag == val: - data[key] = tagRange["start"] + tag_range = findMarker(val) + if "start" in tag_range: + data[key] = tag_range["start"] + elif key == "changes": + for path, list_of_changes in val.items(): + test_name, file_sub_dir = split_path(path) + markers = self.suite.get_test_tags(test_name[:-len(".sol")], file_sub_dir) + for change in list_of_changes: + if "range" in change: + change["range"] = findMarker(change["range"]) elif isinstance(val, dict): replace_tag(val, markers) elif isinstance(val, list): @@ -759,6 +857,8 @@ class SolidityLSPTestSuite: # {{{ self.trace_io = args.trace_io self.test_pattern = args.test_pattern self.fail_fast = args.fail_fast + self.non_interactive = args.non_interactive + self.print_solc_pid = args.print_solc_pid print(f"{SGR_NOTICE}test pattern: {self.test_pattern}{SGR_RESET}") @@ -773,12 +873,15 @@ class SolidityLSPTestSuite: # {{{ if callable(getattr(SolidityLSPTestSuite, name)) and name.startswith("test_") ]) filtered_tests = fnmatch.filter(all_tests, self.test_pattern) + if filtered_tests.count("generic") == 0: + filtered_tests.append("generic") + for method_name in filtered_tests: test_fn = getattr(self, 'test_' + method_name) title: str = test_fn.__name__[5:] print(f"{SGR_TEST_BEGIN}Testing {title} ...{SGR_RESET}") try: - with JsonRpcProcess(self.solc_path, ["--lsp"], trace_io=self.trace_io) as solc: + with JsonRpcProcess(self.solc_path, ["--lsp"], trace_io=self.trace_io, print_pid=self.print_solc_pid) as solc: test_fn(solc) self.test_counter.passed += 1 except ExpectationFailed: @@ -801,16 +904,27 @@ class SolidityLSPTestSuite: # {{{ return min(max(self.test_counter.failed, self.assertion_counter.failed), 127) - def setup_lsp(self, lsp: JsonRpcProcess, expose_project_root=True): + def setup_lsp( + self, + lsp: JsonRpcProcess, + expose_project_root=True, + file_load_strategy: FileLoadStrategy=FileLoadStrategy.DirectlyOpenedAndOnImport, + custom_include_paths: list[str] = None, + project_root_subdir=None + ): """ Prepares the solc LSP server by calling `initialize`, and `initialized` methods. """ + project_root_uri_with_maybe_subdir = self.project_root_uri + if project_root_subdir is not None: + project_root_uri_with_maybe_subdir = self.project_root_uri + '/' + project_root_subdir params = { 'processId': None, - 'rootUri': self.project_root_uri, - 'trace': 'off', - 'initializationOptions': {}, + 'rootUri': project_root_uri_with_maybe_subdir, + # Enable traces to receive the amount of expected diagnostics before + # actually receiving them. + 'trace': 'messages', 'capabilities': { 'textDocument': { 'publishDiagnostics': {'relatedInformation': True} @@ -824,13 +938,21 @@ class SolidityLSPTestSuite: # {{{ } } } + + if file_load_strategy != FileLoadStrategy.Undefined: + params['initializationOptions'] = {} + params['initializationOptions']['file-load-strategy'] = file_load_strategy.value + + if custom_include_paths is not None and len(custom_include_paths) != 0: + if params['initializationOptions'] is None: + params['initializationOptions'] = {} + params['initializationOptions']['include-paths'] = custom_include_paths + if not expose_project_root: params['rootUri'] = None + lsp.call_method('initialize', params) lsp.send_notification('initialized') - # Enable traces to receive the amount of expected diagnostics before - # actually receiving them. - lsp.send_message("$/setTrace", { 'value': 'messages' }) # {{{ helpers def get_test_file_path(self, test_case_name, sub_dir=None): @@ -889,22 +1011,25 @@ class SolidityLSPTestSuite: # {{{ return sorted(reports, key=lambda x: x['uri']) + def normalizeUri(self, uri): + return uri.replace(self.project_root_uri + "/", "")[:-len(".sol")] + def fetch_and_format_diagnostics(self, solc: JsonRpcProcess, test, sub_dir=None): expectations = "" published_diagnostics = self.open_file_and_wait_for_diagnostics(solc, test, sub_dir) - for diagnostics in published_diagnostics: - testname = diagnostics["uri"].replace(f"{self.project_root_uri}/{sub_dir}/", "")[:-len(".sol")] + for file_diagnostics in published_diagnostics: + testname, local_sub_dir = split_path(self.normalizeUri(file_diagnostics["uri"])) # Skip empty diagnostics within the same file - if len(diagnostics["diagnostics"]) == 0 and testname == test: + if len(file_diagnostics["diagnostics"]) == 0 and testname == test: continue expectations += f"// {testname}:" - for diagnostic in diagnostics["diagnostics"]: - tag = self.find_tag_with_range(testname, sub_dir, diagnostic['range']) + for diagnostic in file_diagnostics["diagnostics"]: + tag = self.find_tag_with_range(testname, local_sub_dir, diagnostic['range']) if tag is None: raise Exception(f"No tag found for diagnostic range {diagnostic['range']}") @@ -960,6 +1085,14 @@ class SolidityLSPTestSuite: # {{{ ) return self.wait_for_diagnostics(solc_process) + def expect_true( + self, + actual, + description="Expected True value", + part=ExpectationFailed.Part.Diagnostics + ) -> None: + self.expect_equal(actual, True, description, part) + def expect_equal( self, actual, @@ -1074,7 +1207,7 @@ class SolidityLSPTestSuite: # {{{ Find and return the tag that represents the requested range otherwise return None. """ - markers = self.get_file_tags(test, sub_dir) + markers = self.get_test_tags(test, sub_dir) for tag, tag_range in markers.items(): if tag_range == target_range: @@ -1085,8 +1218,18 @@ class SolidityLSPTestSuite: # {{{ def replace_ranges_with_tags(self, content, sub_dir): """ Replace matching ranges with "@". + + Recognized patterns: + { "changes": { "": { "range": "" } } } + { "uri": "", "range": " } + """ + def replace_range(item: dict, markers): + for tag, tagRange in markers.items(): + if "range" in item and tagRange == item["range"]: + item["range"] = str(tag) + def recursive_iter(obj): if isinstance(obj, dict): yield obj @@ -1098,10 +1241,27 @@ class SolidityLSPTestSuite: # {{{ for item in recursive_iter(content): if "uri" in item and "range" in item: - markers = self.get_file_tags(item["uri"][:-len(".sol")], sub_dir) - for tag, tagRange in markers.items(): - if tagRange == item["range"]: - item["range"] = str(tag) + try: + markers = self.get_test_tags(item["uri"][:-len(".sol")], sub_dir) + replace_range(item, markers) + except FileNotFoundError: + # Skip over errors as this is user provided input that can + # point to non-existing files + pass + elif "changes" in item: + for file, changes_for_file in item["changes"].items(): + test_name, file_sub_dir = split_path(file) + try: + markers = self.get_test_tags(test_name[:-len(".sol")], file_sub_dir) + for change in changes_for_file: + replace_range(change, markers) + + except FileNotFoundError: + # Skip over errors as this is user provided input that can + # point to non-existing files + pass + + # Convert JSON to string and split it at the quoted tags split_by_tag = TEST_REGEXES.findQuotedTag.split(json.dumps(content, indent=4, sort_keys=True)) @@ -1121,6 +1281,11 @@ class SolidityLSPTestSuite: # {{{ Asks the user how to proceed after an error. Returns True if the test/file should be ignored, otherwise False """ + + # Prevent user interaction when in non-interactive mode + if self.non_interactive: + return False + while True: print("(u)pdate/(r)etry/(s)kip file?") user_response = getCharFromStdin() @@ -1145,7 +1310,7 @@ class SolidityLSPTestSuite: # {{{ if user_response == "r": print("retrying...") # pragma pylint: disable=no-member - self.get_file_tags.cache_clear() + self.get_test_tags.cache_clear() return False if user_response == "e": editor = os.environ.get('VISUAL', os.environ.get('EDITOR', 'vi')) @@ -1155,7 +1320,7 @@ class SolidityLSPTestSuite: # {{{ check=True ) # pragma pylint: disable=no-member - self.get_file_tags.cache_clear() + self.get_test_tags.cache_clear() elif user_response == "s": print("skipping...") @@ -1164,6 +1329,98 @@ class SolidityLSPTestSuite: # {{{ # }}} # {{{ actual tests + def test_analyze_all_project_files_flat(self, solc: JsonRpcProcess) -> None: + """ + Tests the option (default) to analyze all .sol project files even when they have not been actively + opened yet. This is how other LSPs (at least for C++) work too and it makes cross-unit tasks + actually correct (e.g. symbolic rename, find all references, ...). + + In this test, we simply open up a custom project and ensure we're receiving the diagnostics + for all existing files in that project (while having none of these files opened). + """ + SUBDIR = 'analyze-full-project' + self.setup_lsp( + solc, + file_load_strategy=FileLoadStrategy.ProjectDirectory, + project_root_subdir=SUBDIR + ) + published_diagnostics = self.wait_for_diagnostics(solc) + self.expect_equal(len(published_diagnostics), 3, "Diagnostic reports for 3 files") + + # C.sol + report = published_diagnostics[0] + self.expect_equal(report['uri'], self.get_test_file_uri('C', SUBDIR), "Correct file URI") + self.expect_equal(len(report['diagnostics']), 0, "no diagnostics") + + # D.sol + report = published_diagnostics[1] + self.expect_equal(report['uri'], self.get_test_file_uri('D', SUBDIR), "Correct file URI") + self.expect_equal(len(report['diagnostics']), 0, "no diagnostics") + + # E.sol + report = published_diagnostics[2] + self.expect_equal(report['uri'], self.get_test_file_uri('E', SUBDIR), "Correct file URI") + self.expect_equal(len(report['diagnostics']), 0, "no diagnostics") + + def test_analyze_all_project_files_nested(self, solc: JsonRpcProcess) -> None: + """ + Same as first test on that matter but with deeper nesting levels. + """ + SUBDIR = 'include-paths-nested' + EXPECTED_FILES = { + "A/B/C/foo", + "A/B/foo", + "A/foo", + "foo", + } + EXPECTED_URIS = {self.get_test_file_uri(x, SUBDIR) for x in EXPECTED_FILES} + self.setup_lsp( + solc, + file_load_strategy=FileLoadStrategy.ProjectDirectory, + project_root_subdir=SUBDIR + ) + published_diagnostics = self.wait_for_diagnostics(solc) + self.expect_equal(len(published_diagnostics), len(EXPECTED_FILES), "Test number of files analyzed.") + self.expect_equal({report['uri'] for report in published_diagnostics}, EXPECTED_URIS) + self.expect_equal([len(report['diagnostics']) for report in published_diagnostics], [0] * len(EXPECTED_URIS)) + + def test_analyze_all_project_files_nested_with_include_paths(self, solc: JsonRpcProcess) -> None: + """ + Same as first test on that matter but with deeper nesting levels. + """ + SUBDIR = 'include-paths-nested-2' + EXPECTED_FILES = { + "A/B/C/foo", + "A/B/foo", + "A/foo", + "foo", + } + IMPLICITLY_LOADED_FILE_COUNT = 1 + EXPECTED_URIS = {self.get_test_file_uri(x, SUBDIR) for x in EXPECTED_FILES} + self.setup_lsp( + solc, + file_load_strategy=FileLoadStrategy.ProjectDirectory, + project_root_subdir=SUBDIR, + custom_include_paths=[f"{self.project_root_dir}/other-include-dir"] + ) + published_diagnostics = self.wait_for_diagnostics(solc) + self.expect_equal( + len(published_diagnostics), + len(EXPECTED_FILES) + IMPLICITLY_LOADED_FILE_COUNT, + "Test number of files analyzed." + ) + + # All but the last report should be from expected files + for report in published_diagnostics[:-IMPLICITLY_LOADED_FILE_COUNT]: + self.expect_true(report['uri'] in EXPECTED_URIS, "Correct file URI") + self.expect_equal(len(report['diagnostics']), 0, "no diagnostics") + + # Check last report (should be the custom imported lib). + # This file is analyzed because it was imported via "A/B/C/foo.sol". + last_report = published_diagnostics[len(EXPECTED_URIS)] + self.expect_equal(last_report['uri'], self.get_test_file_uri('second', 'other-include-dir/otherlib'), "Correct file URI") + self.expect_equal(len(last_report['diagnostics']), 0, "no diagnostics") + def test_publish_diagnostics_errors_multiline(self, solc: JsonRpcProcess) -> None: self.setup_lsp(solc) @@ -1203,11 +1460,11 @@ class SolidityLSPTestSuite: # {{{ report = published_diagnostics[1] self.expect_equal(report['uri'], self.get_test_file_uri('lib', 'goto'), "Correct file URI") self.expect_equal(len(report['diagnostics']), 1, "one diagnostic") - marker = self.get_file_tags("lib", "goto")["@diagnostics"] + marker = self.get_test_tags("lib", "goto")["@diagnostics"] self.expect_diagnostic(report['diagnostics'][0], code=2072, marker=marker) @functools.lru_cache() # pragma pylint: disable=lru-cache-decorating-method - def get_file_tags(self, test_name: str, sub_dir=None, verbose=False): + def get_test_tags(self, test_name: TestName, sub_dir=None, verbose=False): """ Finds all tags (e.g. @tagname) in the given test and returns them as a dictionary having the following structure: { @@ -1249,10 +1506,75 @@ class SolidityLSPTestSuite: # {{{ return markers + def test_custom_includes(self, solc: JsonRpcProcess) -> None: + self.setup_lsp(solc, expose_project_root=False) + solc.send_notification( + 'workspace/didChangeConfiguration', { + 'settings': { + 'include-paths': [ + f"{self.project_root_dir}/other-include-dir" + ] + } + } + ) + published_diagnostics = self.open_file_and_wait_for_diagnostics(solc, 'include-paths/using-custom-includes') + + self.expect_equal(len(published_diagnostics), 2, "Diagnostic reports for 2 files") + + # test file + report = published_diagnostics[0] + self.expect_equal(report['uri'], self.get_test_file_uri('using-custom-includes', 'include-paths')) + diagnostics = report['diagnostics'] + self.expect_equal(len(diagnostics), 0, "no diagnostics") + + # imported file + report = published_diagnostics[1] + self.expect_equal(report['uri'], f"{self.project_root_uri}/other-include-dir/otherlib/otherlib.sol") + diagnostics = report['diagnostics'] + self.expect_equal(len(diagnostics), 1, "no diagnostics") + self.expect_diagnostic(diagnostics[0], code=2018, lineNo=5, startEndColumns=(4, 62)) + + def test_custom_includes_with_full_project(self, solc: JsonRpcProcess) -> None: + """ + Tests loading all project files while having custom include directories configured. + In such a scenario, all project files should be analyzed and those being included via search path + but not those include files that are not directly nor indirectly included. + """ + self.setup_lsp( + solc, + expose_project_root=True, + project_root_subdir='' + ) + solc.send_notification( + 'workspace/didChangeConfiguration', { + 'settings': { + 'include-paths': [ + f"{self.project_root_dir}/other-include-dir" + ] + } + } + ) + published_diagnostics = self.open_file_and_wait_for_diagnostics(solc, 'include-paths/using-custom-includes') + + self.expect_equal(len(published_diagnostics), 2, "Diagnostic reports for 2 files") + + # test file + report = published_diagnostics[0] + self.expect_equal(report['uri'], self.get_test_file_uri('using-custom-includes', 'include-paths')) + diagnostics = report['diagnostics'] + self.expect_equal(len(diagnostics), 0, "no diagnostics") + + # imported file + report = published_diagnostics[1] + self.expect_equal(report['uri'], f"{self.project_root_uri}/other-include-dir/otherlib/otherlib.sol") + diagnostics = report['diagnostics'] + self.expect_equal(len(diagnostics), 1) + self.expect_diagnostic(diagnostics[0], code=2018, lineNo=5, startEndColumns=(4, 62)) + def test_didChange_in_A_causing_error_in_B(self, solc: JsonRpcProcess) -> None: # Reusing another test but now change some file that generates an error in the other. self.test_textDocument_didOpen_with_relative_import(solc) - marker = self.get_file_tags("lib", "goto")["@addFunction"] + marker = self.get_test_tags("lib", "goto")["@addFunction"] self.open_file_and_wait_for_diagnostics(solc, 'lib', "goto") solc.send_message( 'textDocument/didChange', @@ -1277,7 +1599,7 @@ class SolidityLSPTestSuite: # {{{ report = published_diagnostics[0] self.expect_equal(report['uri'], self.get_test_file_uri('didOpen_with_import')) diagnostics = report['diagnostics'] - marker = self.get_file_tags("didOpen_with_import")["@diagnostics"] + marker = self.get_test_tags("didOpen_with_import")["@diagnostics"] self.expect_equal(len(diagnostics), 1, "now, no diagnostics") self.expect_diagnostic(diagnostics[0], code=9582, marker=marker) @@ -1310,7 +1632,7 @@ class SolidityLSPTestSuite: # {{{ self.expect_equal(report['uri'], self.get_test_file_uri('lib', 'goto'), "Correct file URI") self.expect_equal(len(report['diagnostics']), 1, "one diagnostic") - markers = self.get_file_tags('lib', 'goto') + markers = self.get_test_tags('lib', 'goto') marker = markers["@diagnostics"] self.expect_diagnostic(report['diagnostics'][0], code=2072, marker=marker) @@ -1318,14 +1640,22 @@ class SolidityLSPTestSuite: # {{{ self.setup_lsp(solc) sub_dirs = filter( - lambda filepath: filepath.is_dir(), + lambda filepath: filepath.is_dir() and filepath.name != 'node_modules', os.scandir(self.project_root_dir) ) for sub_dir in map(lambda filepath: filepath.name, sub_dirs): tests = map( - lambda filename: filename[:-len(".sol")], - os.listdir(f"{self.project_root_dir}/{sub_dir}") + lambda file_object, sd=sub_dir: sd + "/" + file_object.name[:-len(".sol")], + filter( + lambda filepath: filepath.is_file() and filepath.name.endswith('.sol'), + os.scandir(f"{self.project_root_dir}/{sub_dir}") + ) + ) + + tests = map( + lambda path, sd=sub_dir: path[len(sd)+1:], + fnmatch.filter(tests, self.test_pattern) ) print(f"Running tests in subdirectory '{sub_dir}'...") @@ -1362,7 +1692,7 @@ class SolidityLSPTestSuite: # {{{ self.expect_equal(report['uri'], self.get_test_file_uri(TEST_NAME, "goto"), "Correct file URI") diagnostics = report['diagnostics'] self.expect_equal(len(diagnostics), 3, "3 diagnostic messages") - markers = self.get_file_tags(TEST_NAME, "goto") + markers = self.get_test_tags(TEST_NAME, "goto") self.expect_diagnostic(diagnostics[0], code=6321, marker=markers["@unusedReturnVariable"]) self.expect_diagnostic(diagnostics[1], code=2072, marker=markers["@unusedVariable"]) self.expect_diagnostic(diagnostics[2], code=2072, marker=markers["@unusedContractVariable"]) @@ -1395,7 +1725,7 @@ class SolidityLSPTestSuite: # {{{ self.test_textDocument_didOpen_with_relative_import(solc) self.open_file_and_wait_for_diagnostics(solc, 'lib', 'goto') - marker = self.get_file_tags('lib', 'goto')["@diagnostics"] + marker = self.get_test_tags('lib', 'goto')["@diagnostics"] # lib.sol: Fix the unused variable message by removing it. solc.send_message( @@ -1525,7 +1855,7 @@ class SolidityLSPTestSuite: # {{{ self.expect_equal(len(reports), 2, '') self.expect_equal(len(reports[0]['diagnostics']), 0, "should not contain diagnostics") - marker = self.get_file_tags("lib", 'goto')["@diagnostics"] + marker = self.get_test_tags("lib", 'goto')["@diagnostics"] # unused variable in lib.sol self.expect_diagnostic(reports[1]['diagnostics'][0], code=2072, marker=marker) diff --git a/test/scripts/test_externalTests_benchmark_downloader.py b/test/scripts/test_externalTests_benchmark_downloader.py new file mode 100644 index 000000000..aead61847 --- /dev/null +++ b/test/scripts/test_externalTests_benchmark_downloader.py @@ -0,0 +1,259 @@ +#!/usr/bin/env python3 + +from pathlib import Path +from unittest import TestCase +from unittest.mock import call, Mock, patch + +# NOTE: This test file file only works with scripts/ added to PYTHONPATH so pylint can't find the imports +# pragma pylint: disable=import-error +from externalTests.download_benchmarks import download_benchmarks +# pragma pylint: enable=import-error + + +def _git_run_command_mock(command): + if command == ['git', 'symbolic-ref', 'HEAD', '--short']: + return 'benchmark-downloader' + + if len(command) == 4 and command[:3] == ['git', 'rev-parse', '--verify']: + ref = command[3] + if ref == 'HEAD': + ref = 'benchmark-downloader' + + if ref == 'benchmark-downloader': + return 'fa1ddc6f412100d531f6d3a77008c73b474692d6' + + if ref == 'develop': + return '43f29c00da02e19ff10d43f7eb6955d627c57728' + + raise RuntimeError( + "The test tried to run an unexpected git command.\n" + f"command: {command}\n" + "If you have updated the code, please remember to add matching command fixtures above." + ) + +def _requests_get_mock(url, params, timeout): + response_mock = Mock() + + if url == 'https://api.github.com/repos/ethereum/solidity/pulls/12818': + response_mock.json.return_value = { + "head": { + "ref": "benchmark-downloader", + "sha": "fa1ddc6f412100d531f6d3a77008c73b474692d6", + }, + "base": { + "ref": "develop", + "sha": "43f29c00da02e19ff10d43f7eb6955d627c57728", + }, + } + return response_mock + + if ( + url == 'https://circleci.com/api/v2/project/gh/ethereum/solidity/pipeline' and + params.get('branch') == 'develop' + ): + response_mock.json.return_value = { + "next_page_token": None, + "items": [ + { + "id": "3b15a41f-6933-4a35-9823-08ebb1ff9336", + "created_at": "2022-03-23T00:10:31.659Z", + "trigger": {"type": "schedule"}, + "vcs": { + "revision": "43f29c00da02e19ff10d43f7eb6955d627c57728", + "branch": "develop" + }, + }, + { + "id": "f9036a2d-be2b-4315-bd57-4d35b87502d2", + "created_at": "2022-03-22T00:10:30.304Z", + "trigger": {"type": "webhook"}, + "vcs": { + "revision": "43f29c00da02e19ff10d43f7eb6955d627c57728", + "branch": "develop" + }, + }, + { + "id": "1d389e7c-b7dc-4d4d-9e58-c21ae48901a5", + "created_at": "2022-03-21T00:10:30.579Z", + "trigger": {"type": "schedule"}, + "vcs": { + "revision": "430ecb6e16c346005315dbdd3edf3c3e64e9b1d8", + "branch": "develop" + }, + }, + { + "id": "7185a3f6-6338-4c2c-952d-4c30e7561e61", + "created_at": "2022-03-21T12:54:41.817Z", + "trigger": {"type": "webhook"}, + "vcs": { + "revision": "43f29c00da02e19ff10d43f7eb6955d627c57728", + "branch": "develop" + } + }, + ] + } + return response_mock + + if ( + url == 'https://circleci.com/api/v2/project/gh/ethereum/solidity/pipeline' and + params.get('branch') == 'benchmark-downloader' + ): + response_mock.json.return_value = { + "next_page_token": None, + "items": [ + { + "id": "9af60346-a6b9-41b9-8a16-16ccf8996373", + "created_at": "2022-03-23T10:11:34.683Z", + "trigger": {"type": "webhook"}, + "vcs": { + "revision": "fa1ddc6f412100d531f6d3a77008c73b474692d6", + "branch": "benchmark-downloader" + } + } + ] + } + return response_mock + + if (url in [ + # To reduce the number of fixtures, let's use this workflow for multiple pipelines. + # This would not be the case in practice. + 'https://circleci.com/api/v2/pipeline/f9036a2d-be2b-4315-bd57-4d35b87502d2/workflow', + 'https://circleci.com/api/v2/pipeline/9af60346-a6b9-41b9-8a16-16ccf8996373/workflow' + ]): + response_mock.json.return_value = { + "next_page_token": None, + "items": [ + { + "id": "7a54e9cc-513d-4134-afdb-db62ab8146e5", + "created_at": "2022-03-21T12:54:42Z", + } + ] + } + return response_mock + + if url == 'https://circleci.com/api/v2/workflow/7a54e9cc-513d-4134-afdb-db62ab8146e5/job': + response_mock.json.return_value = { + "next_page_token": None, + "items": [ + { + "job_number": 1017975, + "name": "chk_coding_style", + "status": "success", + }, + { + "job_number": 1017969, + "name": "b_ubu", + "status": "success", + }, + { + "job_number": 1018023, + "name": "c_ext_benchmarks", + "status": "success", + }, + ] + } + return response_mock + + if url == 'https://circleci.com/api/v2/project/gh/ethereum/solidity/1018023/artifacts': + response_mock.json.return_value = { + "next_page_token": None, + "items": [ + { + "path": "reports/externalTests/all-benchmarks.json", + "url": "https://circle-artifacts.com/0/reports/externalTests/all-benchmarks.json" + }, + { + "path": "reports/externalTests/summarized-benchmarks.json", + "url": "https://circle-artifacts.com/0/reports/externalTests/summarized-benchmarks.json" + } + ] + } + return response_mock + + raise RuntimeError( + "The test tried to perform an unexpected GET request.\n" + f"URL: {url}\n" + + (f"query: {params}\n" if len(params) > 0 else "") + + f"timeout: {timeout}\n" + + "If you have updated the code, please remember to add matching response fixtures above." + ) + +class TestBenchmarkDownloader(TestCase): + def setUp(self): + self.maxDiff = 10000 + + @staticmethod + @patch('externalTests.download_benchmarks.download_file') + @patch('requests.get', _requests_get_mock) + @patch('common.git_helpers.run_git_command',_git_run_command_mock) + def test_download_benchmarks(download_file_mock): + download_benchmarks(None, None, None, silent=True) + download_file_mock.assert_has_calls([ + call( + 'https://circle-artifacts.com/0/reports/externalTests/summarized-benchmarks.json', + Path('summarized-benchmarks-benchmark-downloader-fa1ddc6f.json'), + False + ), + call( + 'https://circle-artifacts.com/0/reports/externalTests/all-benchmarks.json', + Path('all-benchmarks-benchmark-downloader-fa1ddc6f.json'), + False + ), + ]) + + @staticmethod + @patch('externalTests.download_benchmarks.download_file') + @patch('requests.get', _requests_get_mock) + @patch('common.git_helpers.run_git_command',_git_run_command_mock) + def test_download_benchmarks_branch(download_file_mock): + download_benchmarks('develop', None, None, silent=True) + download_file_mock.assert_has_calls([ + call( + 'https://circle-artifacts.com/0/reports/externalTests/summarized-benchmarks.json', + Path('summarized-benchmarks-develop-43f29c00.json'), + False + ), + call( + 'https://circle-artifacts.com/0/reports/externalTests/all-benchmarks.json', + Path('all-benchmarks-develop-43f29c00.json'), + False + ), + ]) + + @staticmethod + @patch('externalTests.download_benchmarks.download_file') + @patch('requests.get', _requests_get_mock) + @patch('common.git_helpers.run_git_command',_git_run_command_mock) + def test_download_benchmarks_pr(download_file_mock): + download_benchmarks(None, 12818, None, silent=True) + download_file_mock.assert_has_calls([ + call( + 'https://circle-artifacts.com/0/reports/externalTests/summarized-benchmarks.json', + Path('summarized-benchmarks-benchmark-downloader-fa1ddc6f.json'), + False + ), + call( + 'https://circle-artifacts.com/0/reports/externalTests/all-benchmarks.json', + Path('all-benchmarks-benchmark-downloader-fa1ddc6f.json'), + False + ), + ]) + + @staticmethod + @patch('externalTests.download_benchmarks.download_file') + @patch('requests.get', _requests_get_mock) + @patch('common.git_helpers.run_git_command',_git_run_command_mock) + def test_download_benchmarks_base_of_pr(download_file_mock): + download_benchmarks(None, None, 12818, silent=True) + download_file_mock.assert_has_calls([ + call( + 'https://circle-artifacts.com/0/reports/externalTests/summarized-benchmarks.json', + Path('summarized-benchmarks-develop-43f29c00.json'), + False + ), + call( + 'https://circle-artifacts.com/0/reports/externalTests/all-benchmarks.json', + Path('all-benchmarks-develop-43f29c00.json'), + False + ), + ]) diff --git a/test/solc/CommandLineParser.cpp b/test/solc/CommandLineParser.cpp index 9e900cdc7..5bb3e0d15 100644 --- a/test/solc/CommandLineParser.cpp +++ b/test/solc/CommandLineParser.cpp @@ -281,20 +281,6 @@ BOOST_AUTO_TEST_CASE(assembly_mode_options) "--libraries=" "dir1/file1.sol:L=0x1234567890123456789012345678901234567890," "dir2/file2.sol:L=0x1111122222333334444455555666667777788888", - "--metadata-hash=swarm", // Ignored in assembly mode - "--metadata-literal", // Ignored in assembly mode - "--model-checker-contracts=" // Ignored in assembly mode - "contract1.yul:A," - "contract2.yul:B", - "--model-checker-div-mod-no-slacks", // Ignored in assembly mode - "--model-checker-engine=bmc", // Ignored in assembly mode - "--model-checker-invariants=contract,reentrancy", // Ignored in assembly mode - "--model-checker-show-unproved", // Ignored in assembly mode - "--model-checker-solvers=z3,smtlib2", // Ignored in assembly mode - "--model-checker-targets=" // Ignored in assembly mode - "underflow," - "divByZero", - "--model-checker-timeout=5", // Ignored in assembly mode "--asm", "--bin", "--ir-optimized", @@ -378,20 +364,6 @@ BOOST_AUTO_TEST_CASE(standard_json_mode_options) "dir2/file2.sol:L=0x1111122222333334444455555666667777788888", "--gas", // Accepted but has no effect in Standard JSON mode "--combined-json=abi,bin", // Accepted but has no effect in Standard JSON mode - "--metadata-hash=swarm", // Ignored in Standard JSON mode - "--metadata-literal", // Ignored in Standard JSON mode - "--model-checker-contracts=" // Ignored in Standard JSON mode - "contract1.yul:A," - "contract2.yul:B", - "--model-checker-div-mod-no-slacks", // Ignored in Standard JSON mode - "--model-checker-engine=bmc", // Ignored in Standard JSON mode - "--model-checker-invariants=contract,reentrancy", // Ignored in Standard JSON mode - "--model-checker-show-unproved", // Ignored in Standard JSON mode - "--model-checker-solvers=z3,smtlib2", // Ignored in Standard JSON mode - "--model-checker-targets=" // Ignored in Standard JSON mode - "underflow," - "divByZero", - "--model-checker-timeout=5", // Ignored in Standard JSON mode }; CommandLineOptions expectedOptions; @@ -424,16 +396,30 @@ BOOST_AUTO_TEST_CASE(invalid_options_input_modes_combinations) // TODO: This should eventually contain all options. {"--error-recovery", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}}, {"--experimental-via-ir", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}}, - {"--via-ir", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}} + {"--via-ir", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}}, + {"--metadata-literal", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}}, + {"--metadata-hash=swarm", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-show-unproved", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-div-mod-no-slacks", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-engine=bmc", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-invariants=contract,reentrancy", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-solvers=z3,smtlib2", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-timeout=5", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-contracts=contract1.yul:A,contract2.yul:B", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-targets=underflow,divByZero", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}} }; for (auto const& [optionName, inputModes]: invalidOptionInputModeCombinations) for (string const& inputMode: inputModes) { stringstream serr; + size_t separatorPosition = optionName.find("="); + string optionNameWithoutValue = optionName.substr(0, separatorPosition); + soltestAssert(!optionNameWithoutValue.empty()); + vector commandLine = {"solc", optionName, "file", inputMode}; - string expectedMessage = "The following options are not supported in the current input mode: " + optionName; + string expectedMessage = "The following options are not supported in the current input mode: " + optionNameWithoutValue; auto hasCorrectMessage = [&](CommandLineValidationError const& _exception) { return _exception.what() == expectedMessage; }; BOOST_CHECK_EXCEPTION(parseCommandLine(commandLine), CommandLineValidationError, hasCorrectMessage); diff --git a/test/solc/Common.cpp b/test/solc/Common.cpp index ead9b798d..8e2e329e4 100644 --- a/test/solc/Common.cpp +++ b/test/solc/Common.cpp @@ -91,5 +91,5 @@ string test::stripPreReleaseWarning(string const& _stderrContent) }; string output = regex_replace(_stderrContent, preReleaseWarningRegex, ""); - return regex_replace(move(output), noOutputRegex, ""); + return regex_replace(std::move(output), noOutputRegex, ""); } diff --git a/test/boostTest.cpp b/test/soltest.cpp similarity index 99% rename from test/boostTest.cpp rename to test/soltest.cpp index b7a4c80f0..c104cd8b4 100644 --- a/test/boostTest.cpp +++ b/test/soltest.cpp @@ -133,7 +133,6 @@ int registerTests( boost::unit_test::test_suite& _suite, boost::filesystem::path const& _basepath, boost::filesystem::path const& _path, - bool _enforceViaYul, bool _enforceCompileToEwasm, vector const& _labels, TestCase::TestCaseCreator _testCaseCreator, @@ -146,7 +145,6 @@ int registerTests( fullpath.string(), solidity::test::CommonOptions::get().evmVersion(), solidity::test::CommonOptions::get().vmPaths, - _enforceViaYul, _enforceCompileToEwasm, solidity::test::CommonOptions::get().enforceGasTest, solidity::test::CommonOptions::get().enforceGasTestMinValue, @@ -165,7 +163,6 @@ int registerTests( numTestsAdded += registerTests( *sub_suite, _basepath, _path / entry.path().filename(), - _enforceViaYul, _enforceCompileToEwasm, _labels, _testCaseCreator, @@ -271,7 +268,6 @@ test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[]) master, options.testPath / ts.path, ts.subpath, - options.enforceViaYul, options.enforceCompileToEwasm, ts.labels, ts.testCaseCreator, diff --git a/test/tools/IsolTestOptions.cpp b/test/tools/IsolTestOptions.cpp index ca7761d74..0994b63a8 100644 --- a/test/tools/IsolTestOptions.cpp +++ b/test/tools/IsolTestOptions.cpp @@ -59,7 +59,6 @@ std::string editorPath() IsolTestOptions::IsolTestOptions(): CommonOptions(description) { - enforceViaYul = true; } void IsolTestOptions::addOptions() diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp index ce45819b8..cb7ab1eb5 100644 --- a/test/tools/isoltest.cpp +++ b/test/tools/isoltest.cpp @@ -160,7 +160,6 @@ TestTool::Result TestTool::process() m_path.string(), m_options.evmVersion(), m_options.vmPaths, - m_options.enforceViaYul, m_options.enforceCompileToEwasm, m_options.enforceGasTest, m_options.enforceGasTestMinValue @@ -510,6 +509,11 @@ int main(int argc, char const *argv[]) cerr << exception.what() << endl; return EXIT_FAILURE; } + catch (solidity::test::ConfigException const& exception) + { + cerr << exception.what() << endl; + return EXIT_FAILURE; + } catch (...) { cerr << "Unhandled exception caught." << endl; diff --git a/test/tools/ossfuzz/AbiV2IsabelleFuzzer.cpp b/test/tools/ossfuzz/AbiV2IsabelleFuzzer.cpp index 6a12878e1..78697a9dd 100644 --- a/test/tools/ossfuzz/AbiV2IsabelleFuzzer.cpp +++ b/test/tools/ossfuzz/AbiV2IsabelleFuzzer.cpp @@ -36,7 +36,7 @@ static evmc::VM evmone = evmc::VM{evmc_create_evmone()}; DEFINE_PROTO_FUZZER(Contract const& _contract) { - ProtoConverter converter; + ProtoConverter converter(_contract.seed()); string contractSource = converter.contractToString(_contract); if (const char* dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) @@ -69,14 +69,11 @@ DEFINE_PROTO_FUZZER(Contract const& _contract) {} ); auto result = evmoneUtil.compileDeployAndExecute(encodedData); - if (result.has_value()) - { - solAssert(result->status_code != EVMC_REVERT, "Proto ABIv2 fuzzer: EVM One reverted."); - if (result->status_code == EVMC_SUCCESS) - solAssert( - EvmoneUtility::zeroWord(result->output_data, result->output_size), - "Proto ABIv2 fuzzer: ABIv2 coding failure found." - ); - } + solAssert(result.status_code != EVMC_REVERT, "Proto ABIv2 fuzzer: EVM One reverted."); + if (result.status_code == EVMC_SUCCESS) + solAssert( + EvmoneUtility::zeroWord(result.output_data, result.output_size), + "Proto ABIv2 fuzzer: ABIv2 coding failure found." + ); } } diff --git a/test/tools/ossfuzz/SolidityEvmoneInterface.cpp b/test/tools/ossfuzz/SolidityEvmoneInterface.cpp index ff9fcf2d8..884e35a8c 100644 --- a/test/tools/ossfuzz/SolidityEvmoneInterface.cpp +++ b/test/tools/ossfuzz/SolidityEvmoneInterface.cpp @@ -128,7 +128,7 @@ evmc::result EvmoneUtility::deployAndExecute( return callResult; } -optional EvmoneUtility::compileDeployAndExecute(string _fuzzIsabelle) +evmc::result EvmoneUtility::compileDeployAndExecute(string _fuzzIsabelle) { map libraryAddressMap; // Stage 1: Compile and deploy library if present. @@ -136,51 +136,43 @@ optional EvmoneUtility::compileDeployAndExecute(string _fuzzIsabel { m_compilationFramework.contractName(m_libraryName); auto compilationOutput = m_compilationFramework.compileContract(); - if (compilationOutput.has_value()) - { - CompilerOutput cOutput = compilationOutput.value(); - // Deploy contract and signal failure if deploy failed - evmc::result createResult = deployContract(cOutput.byteCode); - solAssert( - createResult.status_code == EVMC_SUCCESS, - "SolidityEvmoneInterface: Library deployment failed" - ); - libraryAddressMap[m_libraryName] = EVMHost::convertFromEVMC(createResult.create_address); - m_compilationFramework.libraryAddresses(libraryAddressMap); - } - else - return {}; + solAssert(compilationOutput.has_value(), "Compiling library failed"); + CompilerOutput cOutput = compilationOutput.value(); + // Deploy contract and signal failure if deploy failed + evmc::result createResult = deployContract(cOutput.byteCode); + solAssert( + createResult.status_code == EVMC_SUCCESS, + "SolidityEvmoneInterface: Library deployment failed" + ); + libraryAddressMap[m_libraryName] = EVMHost::convertFromEVMC(createResult.create_address); + m_compilationFramework.libraryAddresses(libraryAddressMap); } // Stage 2: Compile, deploy, and execute contract, optionally using library // address map. m_compilationFramework.contractName(m_contractName); auto cOutput = m_compilationFramework.compileContract(); - if (cOutput.has_value()) - { - solAssert( - !cOutput->byteCode.empty() && !cOutput->methodIdentifiersInContract.empty(), - "SolidityEvmoneInterface: Invalid compilation output." - ); + solAssert(cOutput.has_value(), "Compiling contract failed"); + solAssert( + !cOutput->byteCode.empty() && !cOutput->methodIdentifiersInContract.empty(), + "SolidityEvmoneInterface: Invalid compilation output." + ); - string methodName; - if (!_fuzzIsabelle.empty()) - // TODO: Remove this once a cleaner solution is found for querying - // isabelle test entry point. At the moment, we are sure that the - // entry point is the second method in the contract (hence the ++) - // but not its name. - methodName = (++cOutput->methodIdentifiersInContract.begin())->asString() + - _fuzzIsabelle.substr(2, _fuzzIsabelle.size()); - else - methodName = cOutput->methodIdentifiersInContract[m_methodName].asString(); - - return deployAndExecute( - cOutput->byteCode, - methodName - ); - } + string methodName; + if (!_fuzzIsabelle.empty()) + // TODO: Remove this once a cleaner solution is found for querying + // isabelle test entry point. At the moment, we are sure that the + // entry point is the second method in the contract (hence the ++) + // but not its name. + methodName = (++cOutput->methodIdentifiersInContract.begin())->asString() + + _fuzzIsabelle.substr(2, _fuzzIsabelle.size()); else - return {}; + methodName = cOutput->methodIdentifiersInContract[m_methodName].asString(); + + return deployAndExecute( + cOutput->byteCode, + methodName + ); } optional EvmoneUtility::compileContract() diff --git a/test/tools/ossfuzz/SolidityEvmoneInterface.h b/test/tools/ossfuzz/SolidityEvmoneInterface.h index 734caf560..d6826cb89 100644 --- a/test/tools/ossfuzz/SolidityEvmoneInterface.h +++ b/test/tools/ossfuzz/SolidityEvmoneInterface.h @@ -122,7 +122,7 @@ public: /// and executing test configuration. /// @param _isabelleData contains encoding data to be passed to the /// isabelle test entry point. - std::optional compileDeployAndExecute(std::string _isabelleData = {}); + evmc::result compileDeployAndExecute(std::string _isabelleData = {}); /// Compares the contents of the memory address pointed to /// by `_result` of `_length` bytes to u256 zero. /// @returns true if `_result` is zero, false diff --git a/test/tools/ossfuzz/abiV2Proto.proto b/test/tools/ossfuzz/abiV2Proto.proto index 1afc03176..ec6fe1d55 100644 --- a/test/tools/ossfuzz/abiV2Proto.proto +++ b/test/tools/ossfuzz/abiV2Proto.proto @@ -92,6 +92,7 @@ message Contract { required VarDecl state_vars = 1; required TestFunction testfunction = 2; required Test test = 3; + required uint32 seed = 4; } package solidity.test.abiv2fuzzer; diff --git a/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp b/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp index f24d4f12d..6d792a70c 100644 --- a/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp +++ b/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp @@ -35,7 +35,7 @@ static evmc::VM evmone = evmc::VM{evmc_create_evmone()}; DEFINE_PROTO_FUZZER(Contract const& _input) { - string contract_source = ProtoConverter{}.contractToString(_input); + string contract_source = ProtoConverter{_input.seed()}.contractToString(_input); if (const char* dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) { @@ -61,14 +61,18 @@ DEFINE_PROTO_FUZZER(Contract const& _input) ); // Invoke test function auto result = evmoneUtil.compileDeployAndExecute(); - if (result.has_value()) - { - // We don't care about EVM One failures other than EVMC_REVERT - solAssert(result->status_code != EVMC_REVERT, "Proto ABIv2 fuzzer: EVM One reverted"); - if (result->status_code == EVMC_SUCCESS) + // We don't care about EVM One failures other than EVMC_REVERT + solAssert(result.status_code != EVMC_REVERT, "Proto ABIv2 fuzzer: EVM One reverted"); + if (result.status_code == EVMC_SUCCESS) + if (!EvmoneUtility::zeroWord(result.output_data, result.output_size)) + { + solidity::bytes res; + for (size_t i = 0; i < result.output_size; i++) + res.push_back(result.output_data[i]); + cout << solidity::util::toHex(res) << endl; solAssert( - EvmoneUtility::zeroWord(result->output_data, result->output_size), + false, "Proto ABIv2 fuzzer: ABIv2 coding failure found" ); - } + } } diff --git a/test/tools/ossfuzz/protoToAbiV2.cpp b/test/tools/ossfuzz/protoToAbiV2.cpp index 47d3942bb..f20c0482c 100644 --- a/test/tools/ossfuzz/protoToAbiV2.cpp +++ b/test/tools/ossfuzz/protoToAbiV2.cpp @@ -416,14 +416,9 @@ void ProtoConverter::appendTypedParamsExternal( Delimiter _delimiter ) { - std::string qualifiedTypeString = ( - _isValueType ? - _typeString : - _typeString + " calldata" - ); - m_typedParamsExternal << Whiskers(R"( )") + m_externalParamsRep.push_back({_delimiter, _isValueType, _typeString, _varName}); + m_untypedParamsExternal << Whiskers(R"()") ("delimiter", delimiterToString(_delimiter)) - ("type", qualifiedTypeString) ("varName", _varName) .render(); } @@ -471,7 +466,25 @@ std::string ProtoConverter::typedParametersAsString(CalleeType _calleeType) case CalleeType::PUBLIC: return m_typedParamsPublic.str(); case CalleeType::EXTERNAL: - return m_typedParamsExternal.str(); + { + ostringstream typedParamsExternal; + for (auto const& i: m_externalParamsRep) + { + Delimiter del = get<0>(i); + bool valueType = get<1>(i); + string typeString = get<2>(i); + string varName = get<3>(i); + bool isCalldata = randomBool(/*probability=*/0.5); + string location = (isCalldata ? "calldata" : "memory"); + string qualifiedTypeString = (valueType ? typeString : typeString + " " + location); + typedParamsExternal << Whiskers(R"( )") + ("delimiter", delimiterToString(del)) + ("type", qualifiedTypeString) + ("varName", varName) + .render(); + } + return typedParamsExternal.str(); + } } } @@ -662,6 +675,33 @@ string ProtoConverter::calldataHelperFunctions() return 0; })"; + /// These are indirections to test memory-calldata codings more robustly. + stringstream indirections; + unsigned numIndirections = randomNumberOneToN(s_maxIndirections); + for (unsigned i = 1; i <= numIndirections; i++) + { + bool finalIndirection = i == numIndirections; + string mutability = (finalIndirection ? "pure" : "view"); + indirections << Whiskers(R"( + function coder_calldata_external_i() external returns (uint) { + + + return 0; + + return this.coder_calldata_external_i(); + + } + )") + ("N", to_string(i)) + ("parameters", typedParametersAsString(CalleeType::EXTERNAL)) + ("mutability", mutability) + ("finalIndirection", finalIndirection) + ("equality_checks", equalityChecksAsString()) + ("NPlusOne", to_string(i + 1)) + ("untyped_parameters", m_untypedParamsExternal.str()) + .render(); + } + // These are callee functions that encode from storage, decode to // memory/calldata and check if decoded value matches storage value // return true on successful match, false otherwise @@ -671,14 +711,16 @@ string ProtoConverter::calldataHelperFunctions() return 0; } - function coder_calldata_external() external pure returns (uint) { - - return 0; + function coder_calldata_external() external view returns (uint) { + return this.coder_calldata_external_i1(); } + )") ("parameters_memory", typedParametersAsString(CalleeType::PUBLIC)) ("equality_checks", equalityChecksAsString()) ("parameters_calldata", typedParametersAsString(CalleeType::EXTERNAL)) + ("untyped_parameters", m_untypedParamsExternal.str()) + ("indirections", indirections.str()) .render(); return calldataHelperFuncs.str(); diff --git a/test/tools/ossfuzz/protoToAbiV2.h b/test/tools/ossfuzz/protoToAbiV2.h index 83246ac53..d54911353 100644 --- a/test/tools/ossfuzz/protoToAbiV2.h +++ b/test/tools/ossfuzz/protoToAbiV2.h @@ -15,6 +15,7 @@ #include #include +#include #include /** @@ -134,13 +135,16 @@ namespace solidity::test::abiv2fuzzer { +using RandomEngine = std::mt19937_64; +using Distribution = std::uniform_int_distribution; +using Bernoulli = std::bernoulli_distribution; /// Converts a protobuf input into a Solidity program that tests /// abi coding. class ProtoConverter { public: - ProtoConverter(): + ProtoConverter(unsigned _seed): m_isStateVar(true), m_counter(0), m_varCounter(0), @@ -148,7 +152,9 @@ public: m_isLastDynParamRightPadded(false), m_structCounter(0), m_numStructsAdded(0) - {} + { + m_random = std::make_unique(_seed); + } ProtoConverter(ProtoConverter const&) = delete; ProtoConverter(ProtoConverter&&) = delete; @@ -173,6 +179,13 @@ private: EXTERNAL }; + /// Each external parameter representation contains the following: + /// - Delimiter prefix + /// - Boolean that is true if value type, false otherwise + /// - String representation of type + /// - Parameter name + using ParameterPack = std::tuple; + /// Visitors for various Protobuf types /// Visit top-level contract specification void visit(Contract const&); @@ -381,6 +394,16 @@ private: /// Convert delimter to a comma or null string. static std::string delimiterToString(Delimiter _delimiter, bool _space = true); + /// Generates number in the range [1, @param _n] uniformly at random. + unsigned randomNumberOneToN(unsigned _n) + { + return Distribution(1, _n)(*m_random); + } + /// Generates boolean that has a bernoulli distribution defined by @param _p. + bool randomBool(double _p) + { + return Bernoulli{_p}(*m_random); + } /// Contains the test program std::ostringstream m_output; @@ -388,8 +411,9 @@ private: /// checks to be encoded in the test program std::ostringstream m_checks; /// Contains typed parameter list to be passed to callee functions - std::ostringstream m_typedParamsExternal; std::ostringstream m_typedParamsPublic; + /// Contains parameter list to be passed to callee functions + std::ostringstream m_untypedParamsExternal; /// Contains type string to be passed to Isabelle API std::ostringstream m_isabelleTypeString; /// Contains values to be encoded in the format accepted @@ -416,10 +440,16 @@ private: unsigned m_numStructsAdded; /// Enum stating abiv2 coder to be tested Contract_Test m_test; + /// Representation of external parameters + std::vector m_externalParamsRep; + /// Random number generator + std::unique_ptr m_random; /// Prefixes for declared and parameterized variable names static auto constexpr s_localVarNamePrefix = "lv_"; static auto constexpr s_stateVarNamePrefix = "sv_"; static auto constexpr s_paramNamePrefix = "p_"; + /// Maximum number of indirections to test calldata coding + static unsigned constexpr s_maxIndirections = 5; }; /// Visitor interface for Solidity protobuf types. diff --git a/test/tools/ossfuzz/solProtoFuzzer.cpp b/test/tools/ossfuzz/solProtoFuzzer.cpp index a752e2119..f7acc6c10 100644 --- a/test/tools/ossfuzz/solProtoFuzzer.cpp +++ b/test/tools/ossfuzz/solProtoFuzzer.cpp @@ -79,13 +79,10 @@ DEFINE_PROTO_FUZZER(Program const& _input) methodName ); auto minimalResult = evmoneUtil.compileDeployAndExecute(); - if (minimalResult.has_value()) - { - solAssert(minimalResult->status_code != EVMC_REVERT, "Sol proto fuzzer: Evmone reverted."); - if (minimalResult->status_code == EVMC_SUCCESS) + solAssert(minimalResult.status_code != EVMC_REVERT, "Sol proto fuzzer: Evmone reverted."); + if (minimalResult.status_code == EVMC_SUCCESS) solAssert( - EvmoneUtility::zeroWord(minimalResult->output_data, minimalResult->output_size), + EvmoneUtility::zeroWord(minimalResult.output_data, minimalResult.output_size), "Proto solc fuzzer: Output incorrect" ); - } } diff --git a/test/yulPhaser/AlgorithmRunner.cpp b/test/yulPhaser/AlgorithmRunner.cpp index c0c1aabd2..c8a9f40e6 100644 --- a/test/yulPhaser/AlgorithmRunner.cpp +++ b/test/yulPhaser/AlgorithmRunner.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include diff --git a/test/yulPhaser/FitnessMetrics.cpp b/test/yulPhaser/FitnessMetrics.cpp index bd063bf1f..bde15a537 100644 --- a/test/yulPhaser/FitnessMetrics.cpp +++ b/test/yulPhaser/FitnessMetrics.cpp @@ -64,7 +64,7 @@ protected: Program optimisedProgram(Program _program) const { [[maybe_unused]] size_t originalSize = _program.codeSize(m_weights); - Program result = move(_program); + Program result = std::move(_program); result.optimise(m_chromosome.optimisationSteps()); // Make sure that the program and the chromosome we have chosen are suitable for the test diff --git a/test/yulPhaser/Phaser.cpp b/test/yulPhaser/Phaser.cpp index d5d5dac59..60e980522 100644 --- a/test/yulPhaser/Phaser.cpp +++ b/test/yulPhaser/Phaser.cpp @@ -30,6 +30,7 @@ #include #include +#include using namespace std; using namespace solidity::test; diff --git a/test/yulPhaser/ProgramCache.cpp b/test/yulPhaser/ProgramCache.cpp index 3a84aad67..2dab86fcd 100644 --- a/test/yulPhaser/ProgramCache.cpp +++ b/test/yulPhaser/ProgramCache.cpp @@ -52,7 +52,7 @@ protected: Program optimisedProgram(Program _program, string _abbreviatedOptimisationSteps) const { - Program result = move(_program); + Program result = std::move(_program); result.optimise(Chromosome::genesToSteps(_abbreviatedOptimisationSteps)); return result; } diff --git a/test/yulPhaser/TestHelpers.cpp b/test/yulPhaser/TestHelpers.cpp index 1df5c4e54..50afd70a3 100644 --- a/test/yulPhaser/TestHelpers.cpp +++ b/test/yulPhaser/TestHelpers.cpp @@ -30,7 +30,7 @@ using namespace solidity::phaser::test; function phaser::test::wholeChromosomeReplacement(Chromosome _newChromosome) { - return [_newChromosome = move(_newChromosome)](Chromosome const&) { return _newChromosome; }; + return [_newChromosome = std::move(_newChromosome)](Chromosome const&) { return _newChromosome; }; } function phaser::test::geneSubstitution(size_t _geneIndex, string _geneValue) diff --git a/tools/solidityUpgrade/SourceUpgrade.cpp b/tools/solidityUpgrade/SourceUpgrade.cpp index 7c70b1d16..b98b050d6 100644 --- a/tools/solidityUpgrade/SourceUpgrade.cpp +++ b/tools/solidityUpgrade/SourceUpgrade.cpp @@ -26,6 +26,8 @@ #include #include +#include + #ifdef _WIN32 // windows #include #define isatty _isatty diff --git a/tools/yulPhaser/Chromosome.cpp b/tools/yulPhaser/Chromosome.cpp index 687c669da..6e8d3544e 100644 --- a/tools/yulPhaser/Chromosome.cpp +++ b/tools/yulPhaser/Chromosome.cpp @@ -43,7 +43,7 @@ Chromosome Chromosome::makeRandom(size_t _length) for (size_t i = 0; i < _length; ++i) steps.push_back(randomOptimisationStep()); - return Chromosome(move(steps)); + return Chromosome(std::move(steps)); } ostream& phaser::operator<<(ostream& _stream, Chromosome const& _chromosome) diff --git a/tools/yulPhaser/GeneticAlgorithms.cpp b/tools/yulPhaser/GeneticAlgorithms.cpp index 907703738..ff40d222a 100644 --- a/tools/yulPhaser/GeneticAlgorithms.cpp +++ b/tools/yulPhaser/GeneticAlgorithms.cpp @@ -71,7 +71,7 @@ Population RandomAlgorithm::runNextRound(Population _population) size_t replacementCount = _population.individuals().size() - elitePopulation.individuals().size(); return - move(elitePopulation) + + std::move(elitePopulation) + Population::makeRandom( _population.fitnessMetric(), replacementCount, diff --git a/tools/yulPhaser/Mutations.cpp b/tools/yulPhaser/Mutations.cpp index 69ec7fc49..873fbbb9b 100644 --- a/tools/yulPhaser/Mutations.cpp +++ b/tools/yulPhaser/Mutations.cpp @@ -44,7 +44,7 @@ function phaser::geneRandomisation(double _chance) gene ); - return Chromosome(move(genes)); + return Chromosome(std::move(genes)); }; } @@ -57,7 +57,7 @@ function phaser::geneDeletion(double _chance) if (!SimulationRNG::bernoulliTrial(_chance)) genes.push_back(gene); - return Chromosome(move(genes)); + return Chromosome(std::move(genes)); }; } @@ -77,7 +77,7 @@ function phaser::geneAddition(double _chance) genes.push_back(Chromosome::randomGene()); } - return Chromosome(move(genes)); + return Chromosome(std::move(genes)); }; } @@ -102,7 +102,7 @@ function phaser::mutationSequence(vector> _mutation { Chromosome mutatedChromosome = _chromosome; for (size_t i = 0; i < _mutations.size(); ++i) - mutatedChromosome = _mutations[i](move(mutatedChromosome)); + mutatedChromosome = _mutations[i](std::move(mutatedChromosome)); return mutatedChromosome; }; diff --git a/tools/yulPhaser/PairSelections.h b/tools/yulPhaser/PairSelections.h index 2bdc62a24..12532c76a 100644 --- a/tools/yulPhaser/PairSelections.h +++ b/tools/yulPhaser/PairSelections.h @@ -107,7 +107,7 @@ class PairMosaicSelection: public PairSelection { public: explicit PairMosaicSelection(std::vector> _pattern, double _selectionSize = 1.0): - m_pattern(move(_pattern)), + m_pattern(std::move(_pattern)), m_selectionSize(_selectionSize) { assert(m_pattern.size() > 0 || _selectionSize == 0.0); diff --git a/tools/yulPhaser/Phaser.cpp b/tools/yulPhaser/Phaser.cpp index ffcbd1d5e..db5ec35ce 100644 --- a/tools/yulPhaser/Phaser.cpp +++ b/tools/yulPhaser/Phaser.cpp @@ -239,8 +239,8 @@ unique_ptr FitnessMetricFactory::build( { for (size_t i = 0; i < _programs.size(); ++i) metrics.push_back(make_unique( - _programCaches[i] != nullptr ? optional{} : move(_programs[i]), - move(_programCaches[i]), + _programCaches[i] != nullptr ? optional{} : std::move(_programs[i]), + std::move(_programCaches[i]), _weights, _options.chromosomeRepetitions )); @@ -251,8 +251,8 @@ unique_ptr FitnessMetricFactory::build( { for (size_t i = 0; i < _programs.size(); ++i) metrics.push_back(make_unique( - _programCaches[i] != nullptr ? optional{} : move(_programs[i]), - move(_programCaches[i]), + _programCaches[i] != nullptr ? optional{} : std::move(_programs[i]), + std::move(_programCaches[i]), _options.relativeMetricScale, _weights, _options.chromosomeRepetitions @@ -266,16 +266,19 @@ unique_ptr FitnessMetricFactory::build( switch (_options.metricAggregator) { case MetricAggregatorChoice::Average: - return make_unique(move(metrics)); + return make_unique(std::move(metrics)); case MetricAggregatorChoice::Sum: - return make_unique(move(metrics)); + return make_unique(std::move(metrics)); case MetricAggregatorChoice::Maximum: - return make_unique(move(metrics)); + return make_unique(std::move(metrics)); case MetricAggregatorChoice::Minimum: - return make_unique(move(metrics)); + return make_unique(std::move(metrics)); default: assertThrow(false, solidity::util::Exception, "Invalid MetricAggregatorChoice value."); } + + // FIXME: Workaround for spurious GCC 12.1 warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105794) + util::unreachable(); } PopulationFactory::Options PopulationFactory::Options::fromCommandLine(po::variables_map const& _arguments) @@ -306,7 +309,7 @@ Population PopulationFactory::build( for (size_t populationSize: _options.randomPopulation) combinedSize += populationSize; - population = move(population) + buildRandom( + population = std::move(population) + buildRandom( combinedSize, _options.minChromosomeLength, _options.maxChromosomeLength, @@ -314,7 +317,7 @@ Population PopulationFactory::build( ); for (string const& populationFilePath: _options.populationFromFile) - population = move(population) + buildFromFile(populationFilePath, _fitnessMetric); + population = std::move(population) + buildFromFile(populationFilePath, _fitnessMetric); return population; } @@ -328,7 +331,7 @@ Population PopulationFactory::buildFromStrings( for (string const& geneSequence: _geneSequences) chromosomes.emplace_back(geneSequence); - return Population(move(_fitnessMetric), move(chromosomes)); + return Population(std::move(_fitnessMetric), std::move(chromosomes)); } Population PopulationFactory::buildRandom( @@ -339,7 +342,7 @@ Population PopulationFactory::buildRandom( ) { return Population::makeRandom( - move(_fitnessMetric), + std::move(_fitnessMetric), _populationSize, _minChromosomeLength, _maxChromosomeLength @@ -351,7 +354,7 @@ Population PopulationFactory::buildFromFile( shared_ptr _fitnessMetric ) { - return buildFromStrings(readLinesFromFile(_filePath), move(_fitnessMetric)); + return buildFromStrings(readLinesFromFile(_filePath), std::move(_fitnessMetric)); } ProgramCacheFactory::Options ProgramCacheFactory::Options::fromCommandLine(po::variables_map const& _arguments) @@ -368,7 +371,7 @@ vector> ProgramCacheFactory::build( { vector> programCaches; for (Program& program: _programs) - programCaches.push_back(_options.programCacheEnabled ? make_shared(move(program)) : nullptr); + programCaches.push_back(_options.programCacheEnabled ? make_shared(std::move(program)) : nullptr); return programCaches; } @@ -397,7 +400,7 @@ vector ProgramFactory::build(Options const& _options) } get(programOrErrors).optimise(Chromosome(_options.prefix).optimisationSteps()); - inputPrograms.push_back(move(get(programOrErrors))); + inputPrograms.push_back(std::move(get(programOrErrors))); } return inputPrograms; @@ -820,12 +823,12 @@ void Phaser::runPhaser(po::variables_map const& _arguments) programCaches, codeWeights ); - Population population = PopulationFactory::build(populationOptions, move(fitnessMetric)); + Population population = PopulationFactory::build(populationOptions, std::move(fitnessMetric)); if (_arguments["mode"].as() == PhaserMode::RunAlgorithm) - runAlgorithm(_arguments, move(population), move(programCaches)); + runAlgorithm(_arguments, std::move(population), std::move(programCaches)); else - printOptimisedProgramsOrASTs(_arguments, population, move(programs), _arguments["mode"].as()); + printOptimisedProgramsOrASTs(_arguments, population, std::move(programs), _arguments["mode"].as()); } void Phaser::runAlgorithm( @@ -841,7 +844,7 @@ void Phaser::runAlgorithm( _population.individuals().size() ); - AlgorithmRunner algorithmRunner(move(_population), move(_programCaches), buildAlgorithmRunnerOptions(_arguments), cout); + AlgorithmRunner algorithmRunner(std::move(_population), std::move(_programCaches), buildAlgorithmRunnerOptions(_arguments), cout); algorithmRunner.run(*geneticAlgorithm); } diff --git a/tools/yulPhaser/Population.cpp b/tools/yulPhaser/Population.cpp index 1dba2e2fd..d4fe1f0bd 100644 --- a/tools/yulPhaser/Population.cpp +++ b/tools/yulPhaser/Population.cpp @@ -68,7 +68,7 @@ Population Population::makeRandom( for (size_t i = 0; i < _size; ++i) chromosomes.push_back(Chromosome::makeRandom(_chromosomeLengthGenerator())); - return Population(move(_fitnessMetric), move(chromosomes)); + return Population(std::move(_fitnessMetric), std::move(chromosomes)); } Population Population::makeRandom( @@ -79,7 +79,7 @@ Population Population::makeRandom( ) { return makeRandom( - move(_fitnessMetric), + std::move(_fitnessMetric), _size, std::bind(uniformChromosomeLength, _minChromosomeLength, _maxChromosomeLength) ); @@ -112,7 +112,7 @@ Population Population::crossover(PairSelection const& _selection, function Population::symmetricCrossoverWithRemainder( m_individuals[i].chromosome, m_individuals[j].chromosome ); - crossedIndividuals.emplace_back(move(get<0>(children)), *m_fitnessMetric); - crossedIndividuals.emplace_back(move(get<1>(children)), *m_fitnessMetric); + crossedIndividuals.emplace_back(std::move(get<0>(children)), *m_fitnessMetric); + crossedIndividuals.emplace_back(std::move(get<1>(children)), *m_fitnessMetric); indexSelected[i] = true; indexSelected[j] = true; } @@ -159,7 +159,7 @@ Population operator+(Population _a, Population _b) assert(_a.m_fitnessMetric == _b.m_fitnessMetric); using ::operator+; // Import the std::vector concat operator from CommonData.h - return Population(_a.m_fitnessMetric, move(_a.m_individuals) + move(_b.m_individuals)); + return Population(_a.m_fitnessMetric, std::move(_a.m_individuals) + std::move(_b.m_individuals)); } } @@ -193,7 +193,7 @@ vector Population::chromosomesToIndividuals( { vector individuals; for (auto& chromosome: _chromosomes) - individuals.emplace_back(move(chromosome), _fitnessMetric); + individuals.emplace_back(std::move(chromosome), _fitnessMetric); return individuals; } diff --git a/tools/yulPhaser/Program.cpp b/tools/yulPhaser/Program.cpp index 5c61701d8..c62b8e130 100644 --- a/tools/yulPhaser/Program.cpp +++ b/tools/yulPhaser/Program.cpp @@ -102,7 +102,7 @@ variant Program::load(CharStream& _sourceCode) void Program::optimise(vector const& _optimisationSteps) { - m_ast = applyOptimisationSteps(m_dialect, m_nameDispenser, move(m_ast), _optimisationSteps); + m_ast = applyOptimisationSteps(m_dialect, m_nameDispenser, std::move(m_ast), _optimisationSteps); } ostream& phaser::operator<<(ostream& _stream, Program const& _program) @@ -153,7 +153,7 @@ variant, ErrorList> Program::parseObject(Dialect const& _diale // to refactor ObjectParser and Object to use unique_ptr instead). auto astCopy = make_unique(get(ASTCopier{}(*selectedObject->code))); - return variant, ErrorList>(move(astCopy)); + return variant, ErrorList>(std::move(astCopy)); } variant, ErrorList> Program::analyzeAST(Dialect const& _dialect, Block const& _ast) @@ -168,7 +168,7 @@ variant, ErrorList> Program::analyzeAST(Dialect cons return errors; assert(errorReporter.errors().empty()); - return variant, ErrorList>(move(analysisInfo)); + return variant, ErrorList>(std::move(analysisInfo)); } unique_ptr Program::disambiguateAST( diff --git a/tools/yulPhaser/Selections.h b/tools/yulPhaser/Selections.h index 88264e25a..bd51cfe78 100644 --- a/tools/yulPhaser/Selections.h +++ b/tools/yulPhaser/Selections.h @@ -86,7 +86,7 @@ class MosaicSelection: public Selection { public: explicit MosaicSelection(std::vector _pattern, double _selectionSize = 1.0): - m_pattern(move(_pattern)), + m_pattern(std::move(_pattern)), m_selectionSize(_selectionSize) { assert(m_pattern.size() > 0 || _selectionSize == 0.0);