diff --git a/Changelog.md b/Changelog.md index 5e8a7bef8432..71cff3e1f37d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -18,6 +18,7 @@ Compiler Features: * SMTChecker: Replace CVC4 as a possible BMC backend with cvc5. * Standard JSON Interface: Do not perform IR optimization when only unoptimized IR is requested. * Standard JSON Interface: Add ``transientStorageLayout`` output. + * Yul: Drop the deprecated typed Yul dialect that was only accessible via ``--yul`` in the CLI. * Yul Optimizer: The optimizer now treats some previously unrecognized identical literals as identical. * Commandline Interface: Allow the use of ``--asm-json`` output option in assembler mode to export EVM assembly of the contracts in JSON format. diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index 97c6901400d7..19089d885ae8 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -618,6 +618,9 @@ General Information)").c_str(), "Select desired EOF version. Currently the only valid value is 1. " "If not specified, legacy non-EOF bytecode will be generated." ) + ( + g_strYul.c_str(), "The typed Yul dialect is no longer supported. For regular Yul compilation use --strict-assembly instead." + ) ; outputOptions.add_options() ( @@ -664,10 +667,6 @@ General Information)").c_str(), g_strAssemble.c_str(), "Switch to assembly mode and assume input is assembly." ) - ( - g_strYul.c_str(), - "Switch to Yul mode and assume input is Yul." - ) ( g_strStrictAssembly.c_str(), "Switch to strict assembly mode and assume input is strict assembly." @@ -956,7 +955,6 @@ void CommandLineParser::processArgs() g_strLink, g_strAssemble, g_strStrictAssembly, - g_strYul, g_strImportAst, g_strLSP, g_strImportEvmAssemblerJson, @@ -972,7 +970,7 @@ void CommandLineParser::processArgs() m_options.input.mode = InputMode::StandardJson; else if (m_args.count(g_strLSP)) m_options.input.mode = InputMode::LanguageServer; - else if (m_args.count(g_strAssemble) > 0 || m_args.count(g_strStrictAssembly) > 0 || m_args.count(g_strYul) > 0) + else if (m_args.count(g_strAssemble) > 0 || m_args.count(g_strStrictAssembly) > 0) m_options.input.mode = InputMode::Assembler; else if (m_args.count(g_strLink) > 0) m_options.input.mode = InputMode::Linker; @@ -990,6 +988,13 @@ void CommandLineParser::processArgs() ) return; + if (m_args.count(g_strYul) > 0) + solThrow( + CommandLineValidationError, + "The typed Yul dialect formerly accessible via --yul is no longer supported, " + "please use --strict-assembly instead." + ); + std::map> validOptionInputModeCombinations = { // TODO: This should eventually contain all options. {g_strExperimentalViaIR, {InputMode::Compiler, InputMode::CompilerWithASTImport}}, @@ -1276,7 +1281,7 @@ void CommandLineParser::processArgs() // switch to assembly mode using Input = yul::YulStack::Language; using Machine = yul::YulStack::Machine; - m_options.assembly.inputLanguage = m_args.count(g_strYul) ? Input::Yul : (m_args.count(g_strStrictAssembly) ? Input::StrictAssembly : Input::Assembly); + m_options.assembly.inputLanguage = m_args.count(g_strStrictAssembly) ? Input::StrictAssembly : Input::Assembly; if (m_args.count(g_strMachine)) { diff --git a/test/cmdlineTests/yul_optimize_runs/args b/test/cmdlineTests/yul_optimize_runs/args index 033abe3bbbfd..3a8567e92458 100644 --- a/test/cmdlineTests/yul_optimize_runs/args +++ b/test/cmdlineTests/yul_optimize_runs/args @@ -1 +1 @@ ---yul --yul-dialect evm --optimize --optimize-runs 10000 +--strict-assembly --yul-dialect evm --optimize --optimize-runs 10000 diff --git a/test/cmdlineTests/~assembler_modes/test.sh b/test/cmdlineTests/~assembler_modes/test.sh index 5ca1bb40f82b..708c76395787 100755 --- a/test/cmdlineTests/~assembler_modes/test.sh +++ b/test/cmdlineTests/~assembler_modes/test.sh @@ -25,19 +25,24 @@ function test_solc_assembly_output } echo '{}' | msg_on_error --silent "$SOLC" - --assemble -echo '{}' | msg_on_error --silent "$SOLC" - --yul echo '{}' | msg_on_error --silent "$SOLC" - --strict-assembly -# Test options above in conjunction with --optimize. -# Using both, --assemble and --optimize should fail. +# Test in conjunction with --optimize. Using both, --assemble and --optimize should fail. echo '{}' | "$SOLC" - --assemble --optimize &>/dev/null && fail "solc --assemble --optimize did not fail as expected." -echo '{}' | "$SOLC" - --yul --optimize &>/dev/null && fail "solc --yul --optimize did not fail as expected." -# Test yul and strict assembly output +# Test strict assembly output # Non-empty code results in non-empty binary representation with optimizations turned off, # while it results in empty binary representation with optimizations turned on. -test_solc_assembly_output "{ let x:u256 := 0:u256 mstore(0, x) }" "{ { let x := 0 mstore(0, x) } }" "--yul" -test_solc_assembly_output "{ let x:u256 := bitnot(7:u256) mstore(0, x) }" "{ { let x := bitnot(7) mstore(0, x) } }" "--yul" -test_solc_assembly_output "{ let t:bool := not(true) if t { mstore(0, 1) } }" "{ { let t:bool := not(true) if t { mstore(0, 1) } } }" "--yul" test_solc_assembly_output "{ let x := 0 mstore(0, x) }" "{ { let x := 0 mstore(0, x) } }" "--strict-assembly" test_solc_assembly_output "{ let x := 0 mstore(0, x) }" "{ { } }" "--strict-assembly --optimize" + +# Test that --yul triggers an error +set +e +output=$(echo '{}' | "$SOLC" - --yul 2>&1) +failed=$? +expected="Error: The typed Yul dialect formerly accessible via --yul is no longer supported, please use --strict-assembly instead." +set -e +if [[ $output != "${expected}" ]] || (( failed == 0 )) +then + fail "Incorrect error response to --yul flag: $output" +fi diff --git a/test/solc/CommandLineInterface.cpp b/test/solc/CommandLineInterface.cpp index b3b93cb3aa11..6d19df01b3f8 100644 --- a/test/solc/CommandLineInterface.cpp +++ b/test/solc/CommandLineInterface.cpp @@ -148,7 +148,7 @@ BOOST_AUTO_TEST_CASE(version) BOOST_AUTO_TEST_CASE(multiple_input_modes) { - std::array inputModeOptions = { + std::array inputModeOptions { "--help", "--license", "--version", @@ -156,17 +156,16 @@ BOOST_AUTO_TEST_CASE(multiple_input_modes) "--link", "--assemble", "--strict-assembly", - "--yul", "--import-ast", "--import-asm-json", }; std::string expectedMessage = "The following options are mutually exclusive: " - "--help, --license, --version, --standard-json, --link, --assemble, --strict-assembly, --yul, --import-ast, --lsp, --import-asm-json. " + "--help, --license, --version, --standard-json, --link, --assemble, --strict-assembly, --import-ast, --lsp, --import-asm-json. " "Select at most one."; - for (std::string const& mode1: inputModeOptions) - for (std::string const& mode2: inputModeOptions) + for (auto const& mode1: inputModeOptions) + for (auto const& mode2: inputModeOptions) if (mode1 != mode2) BOOST_CHECK_EXCEPTION( parseCommandLineAndReadInputFiles({"solc", mode1, mode2}), diff --git a/test/solc/CommandLineParser.cpp b/test/solc/CommandLineParser.cpp index 37c638a3bbba..e0347a18c4b5 100644 --- a/test/solc/CommandLineParser.cpp +++ b/test/solc/CommandLineParser.cpp @@ -250,7 +250,6 @@ BOOST_AUTO_TEST_CASE(no_import_callback) {"solc", "--strict-assembly", "--no-import-callback", "input.yul"}, {"solc", "--import-ast", "--no-import-callback", "ast.json"}, {"solc", "--link", "--no-import-callback", "input.bin"}, - {"solc", "--yul", "--no-import-callback", "input.yul"}, }; for (auto const& commandLine: commandLinePerInputMode) @@ -271,13 +270,10 @@ BOOST_AUTO_TEST_CASE(assembly_mode_options) { static std::vector, YulStack::Machine, YulStack::Language>> const allowedCombinations = { {{"--machine=evm", "--yul-dialect=evm", "--assemble"}, YulStack::Machine::EVM, YulStack::Language::StrictAssembly}, - {{"--machine=evm", "--yul-dialect=evm", "--yul"}, YulStack::Machine::EVM, YulStack::Language::StrictAssembly}, {{"--machine=evm", "--yul-dialect=evm", "--strict-assembly"}, YulStack::Machine::EVM, YulStack::Language::StrictAssembly}, {{"--machine=evm", "--assemble"}, YulStack::Machine::EVM, YulStack::Language::Assembly}, - {{"--machine=evm", "--yul"}, YulStack::Machine::EVM, YulStack::Language::Yul}, {{"--machine=evm", "--strict-assembly"}, YulStack::Machine::EVM, YulStack::Language::StrictAssembly}, {{"--assemble"}, YulStack::Machine::EVM, YulStack::Language::Assembly}, - {{"--yul"}, YulStack::Machine::EVM, YulStack::Language::Yul}, {{"--strict-assembly"}, YulStack::Machine::EVM, YulStack::Language::StrictAssembly}, }; @@ -424,20 +420,20 @@ BOOST_AUTO_TEST_CASE(invalid_options_input_modes_combinations) { std::map> invalidOptionInputModeCombinations = { // TODO: This should eventually contain all options. - {"--experimental-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-proved-safe", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}}, - {"--model-checker-show-unproved", {"--assemble", "--yul", "--strict-assembly", "--standard-json", "--link"}}, - {"--model-checker-show-unsupported", {"--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"}} + {"--experimental-via-ir", {"--assemble", "--strict-assembly", "--standard-json", "--link"}}, + {"--via-ir", {"--assemble", "--strict-assembly", "--standard-json", "--link"}}, + {"--metadata-literal", {"--assemble", "--strict-assembly", "--standard-json", "--link"}}, + {"--metadata-hash=swarm", {"--assemble", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-show-proved-safe", {"--assemble", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-show-unproved", {"--assemble", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-show-unsupported", {"--assemble", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-div-mod-no-slacks", {"--assemble", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-engine=bmc", {"--assemble", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-invariants=contract,reentrancy", {"--assemble", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-solvers=z3,smtlib2", {"--assemble", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-timeout=5", {"--assemble", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-contracts=contract1.yul:A,contract2.yul:B", {"--assemble", "--strict-assembly", "--standard-json", "--link"}}, + {"--model-checker-targets=underflow,divByZero", {"--assemble", "--strict-assembly", "--standard-json", "--link"}} }; for (auto const& [optionName, inputModes]: invalidOptionInputModeCombinations)