diff --git a/Changelog.md b/Changelog.md index ed752bf35361..823d346c768b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,10 @@ Language Features: Compiler Features: +* Commandline Interface: Introduce `--experimental` flag required for enabling the experimental mode. +* General: Restrict the existing experimental features (`generic-solidity`, `lsp`, `ethdebug`, `eof`, `evm`, `ast-import`, `evmasm-import`, `ir-ast`, `ssa-cfg`) to experimental mode. +* Metadata: Store the state of the experimental mode in JSON and CBOR metadata. In CBOR this broadens the meaning of the existing `experimental` field, which used to indicate only the presence of certain experimental pragmas in the source. +* Standard JSON Interface: Introduce `settings.experimental` setting required for enabling the experimental mode. Bugfixes: diff --git a/docs/metadata.rst b/docs/metadata.rst index 90513ee326de..b4a8d7cfc611 100644 --- a/docs/metadata.rst +++ b/docs/metadata.rst @@ -136,6 +136,12 @@ explanatory purposes. "compilationTarget": { "myDirectory/myFile.sol": "MyContract" }, + // Optional (false if omitted): Indicates whether experimental mode has been enabled. + // Always matches the value of the `experimental` flag in CBOR metadata. + // Note that experimental mode being enabled does not necessarily mean that any + // experimental features were actually used, or if they were, that those features + // affected the bytecode. + "experimental": true, // Required for Solidity: Addresses for libraries used. // Note that metadata has a different format for "libraries" field than the standard JSON input. // metadata format = { "MyLib.sol:MyLib": "0x123123..." } @@ -197,12 +203,14 @@ Below are all the possible fields: .. code-block:: javascript { + // Present if "bytecodeHash" was "ipfs" in compiler settings "ipfs": "", - // If "bytecodeHash" was "bzzr1" in compiler settings not "ipfs" but "bzzr1" + // Present if "bytecodeHash" was "bzzr1" in compiler settings "bzzr1": "", // Previous versions were using "bzzr0" instead of "bzzr1" "bzzr0": "", - // If any experimental features that affect code generation are used + // Present if experimental mode has been enabled either via "--experimental" flag or + // "settings.experimental" option in Standard JSON "experimental": true, "solc": "" } diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index dbc797079454..ce82aa077817 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -281,6 +281,10 @@ Input Description "stopAfter": "parsing", // Optional: List of remappings "remappings": [ ":g=/dir" ], + // Optional: Experimental mode toggle (Default: false) + // Makes it possible to use experimental features (but does not enable any such feature by itself). + // The use of this mode is recorded in contract metadata. + "experimental": true, // Optional: Optimizer settings "optimizer": { // Turn on the optimizer. Optional. Default: false. @@ -383,8 +387,11 @@ Input Description // - `` is the index of the first byte after that location. // - `snippet`: A single-line code snippet from the location indicated by `@src`. // The snippet is quoted and follows the corresponding `@src` annotation. - // - `*`: Wildcard value that can be used to request everything. - "debugInfo": ["location", "snippet"] + // - `ast-id`: Annotations of the form `@ast-id ` over elements that can be mapped back to a definition in the original Solidity file. + // `` is a node ID in the Solidity AST ('ast' output). + // - `ethdebug`: Ethdebug annotations (experimental). + // - `*`: Wildcard value that can be used to request all non-experimental components. + "debugInfo": ["location", "snippet", "ast-id", "ethdebug"] }, // Metadata settings (optional) "metadata": { @@ -435,13 +442,15 @@ Input Description // userdoc - User documentation (natspec) // metadata - Metadata // ir - Yul intermediate representation of the code before optimization - // irAst - AST of Yul intermediate representation of the code before optimization + // irAst - AST of Yul intermediate representation of the code before optimization (experimental) // irOptimized - Intermediate representation after optimization - // irOptimizedAst - AST of intermediate representation after optimization - // storageLayout - Slots, offsets and types of the contract's state variables in storage. - // transientStorageLayout - Slots, offsets and types of the contract's state variables in transient storage. + // irOptimizedAst - AST of intermediate representation after optimization (experimental) + // storageLayout - Slots, offsets and types of the contract's state variables in storage + // transientStorageLayout - Slots, offsets and types of the contract's state variables in transient storage // evm.assembly - New assembly format // evm.legacyAssembly - Old-style assembly format in JSON + // evm.bytecode.ethdebug - Debug information in ethdebug format (ethdebug/format/program schema). Can only be requested when compiling via IR. (experimental) + // evm.deployedBytecode.ethdebug - Like evm.bytecode.ethdebug, but for the runtime part of the contract (experimental) // evm.bytecode.functionDebugData - Debugging information at function level // evm.bytecode.object - Bytecode object // evm.bytecode.opcodes - Opcodes list @@ -452,6 +461,7 @@ Input Description // evm.deployedBytecode.immutableReferences - Map from AST ids to bytecode ranges that reference immutables // evm.methodIdentifiers - The list of function hashes // evm.gasEstimates - Function gas estimates + // yulCFGJson - Control Flow Graph (CFG) of the Single Static Assignment (SSA) form of the contract (experimental) // // Note that using `evm`, `evm.bytecode`, etc. will select every // target part of that output. Additionally, `*` can be used as a wildcard to request everything. @@ -604,6 +614,8 @@ Output Description "legacyAssembly": {}, // Bytecode and related details. "bytecode": { + // Ethdebug output (experimental) + "ethdebug": {/* ... */}, // Debugging data at the level of functions. "functionDebugData": { // Now follows a set of functions including compiler-internal and @@ -646,6 +658,8 @@ Output Description } }, "deployedBytecode": { + // Ethdebug output (experimental) + "ethdebug": {/* ... */}, /* ..., */ // The same layout as above. "immutableReferences": { // There are two references to the immutable with AST ID 3, both 32 bytes long. One is @@ -670,11 +684,15 @@ Output Description "internal": { "heavyLifting()": "infinite" } - } + }, + // Yul CFG representation of the SSA form (experimental) + "yulCFGJson": {/* ... */} } } } - } + }, + // Global Ethdebug output (experimental) + "ethdebug": {/* ... */ } } @@ -696,3 +714,57 @@ Error Types 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. + +.. index:: ! Experimental mode, ! --experimental +.. _experimental-mode: + +Experimental Mode +***************** + +Some language and compiler features included in stable releases are not themselves considered stable. +They are sparsely documented, if at all, often not adequately tested, and thus not yet intended for production use. +In many cases it is possible to develop a big feature incrementally, with each iteration being already stable. +Sometimes, however, it is preferable to start with a prototype and stabilize it over multiple releases, while receiving feedback from users. +To prevent accidental use, such features can be only accessed by enabling the experimental mode. + +There are no backwards compatibility guarantees for experimental features. +They are subject to change in breaking ways in non-breaking releases of the compiler. +Only major changes affecting them are recorded in the changelog. + +To enable the experimental mode, use the ``--experimental`` flag on the command line, +or the analogous ``settings.experimental`` boolean setting in the Standard JSON input. + +Note that the use of this mode is recorded in the metadata: + +- ``experimental`` flag in CBOR metadata is set to ``true``, +- ``settings.experimental`` in JSON metadata is set to ``true``, + +.. note:: + Prior to version 0.8.34, most of the experimental features were usable without any extra safeguards. + Some were gated behind ``pragma experimental``, but this was not done consistently. + The information about them was also only recorded in CBOR metadata and even then not always. + The main goal of the experimental mode is to systematize this and make users fully aware when relying on features which are unfinished or not production-ready. + +The table below details all currently available experimental features. + ++-----------------------+--------------------------+------------------+-------------------------------------------------------------------+ +| Feature | ID | Affects bytecode | Flag/pragma | ++=======================+==========================+==================+===================================================================+ +| AST import | ``ast-import`` | yes | ``--import-ast`` | ++-----------------------+--------------------------+------------------+-------------------------------------------------------------------+ +| LSP | ``lsp`` | no | ``--lsp`` | ++-----------------------+--------------------------+------------------+-------------------------------------------------------------------+ +| EVM Assembly import | ``evmasm-import`` | yes | ``--import-asm-json`` | ++-----------------------+--------------------------+------------------+-------------------------------------------------------------------+ +| Generic Solidity | ``generic-solidity`` | yes | ``pragma experimental solidity`` | ++-----------------------+--------------------------+------------------+-------------------------------------------------------------------+ +| IR AST | ``ir-ast`` | no | ``--ir-ast-json``, ``--ir-optimized-ast-json`` | ++-----------------------+--------------------------+------------------+-------------------------------------------------------------------+ +| EOF | ``eof`` | yes | ``--experimental-eof-version`` | ++-----------------------+--------------------------+------------------+-------------------------------------------------------------------+ +| Non-mainnet EVMs | ``evm`` | yes | ``--evm-version `` | ++-----------------------+--------------------------+------------------+-------------------------------------------------------------------+ +| Ethdebug | ``ethdebug`` | no | ``--ethdebug``, ``--ethdebug-runtime``, ``--debug-info ethdebug`` | ++-----------------------+--------------------------+------------------+-------------------------------------------------------------------+ +| Yul SSA CFG exporter | ``ssa-cfg`` | no | ``--yul-cfg-json`` | ++-----------------------+--------------------------+------------------+-------------------------------------------------------------------+ diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index 9bf784b36573..e8777069f7ad 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -110,7 +110,16 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma) auto feature = ExperimentalFeatureNames.at(literal); m_sourceUnit->annotation().experimentalFeatures.insert(feature); if (!ExperimentalFeatureWithoutWarning.count(feature)) - m_errorReporter.warning(2264_error, _pragma.location(), "Experimental features are turned on. Do not use experimental features on live deployments."); + { + if (!m_experimental) + m_errorReporter.syntaxError( + 2816_error, + _pragma.location(), + "Experimental pragmas can only be used if experimental mode is enabled. To enable experimental mode, use the --experimental flag." + ); + else + m_errorReporter.warning(2264_error, _pragma.location(), "Experimental features are turned on. Do not use experimental features on live deployments."); + } if (feature == ExperimentalFeature::ABIEncoderV2) { diff --git a/libsolidity/analysis/SyntaxChecker.h b/libsolidity/analysis/SyntaxChecker.h index 69bda229f701..8a6e27cb1132 100644 --- a/libsolidity/analysis/SyntaxChecker.h +++ b/libsolidity/analysis/SyntaxChecker.h @@ -45,9 +45,12 @@ class SyntaxChecker: private ASTConstVisitor { public: /// @param _errorReporter provides the error logging functionality. - SyntaxChecker(langutil::ErrorReporter& _errorReporter, bool _useYulOptimizer): + /// @param _useYulOptimizer indicates whether Yul optimizer is enabled. + /// @param _experimental indicates whether the experimental mode is enabled. + SyntaxChecker(langutil::ErrorReporter& _errorReporter, bool _useYulOptimizer, bool _experimental): m_errorReporter(_errorReporter), - m_useYulOptimizer(_useYulOptimizer) + m_useYulOptimizer(_useYulOptimizer), + m_experimental(_experimental) {} bool checkSyntax(ASTNode const& _astRoot); @@ -112,6 +115,9 @@ class SyntaxChecker: private ASTConstVisitor /// Flag that indicates whether we are inside an unchecked block. bool m_uncheckedArithmetic = false; + /// Flag that indicates whether the experimental mode is enabled. + bool m_experimental = false; + int m_inLoopDepth = 0; std::optional m_currentContractKind; diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 975ed3c1982d..3583ae5356fd 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -229,6 +229,12 @@ void CompilerStack::setViaIR(bool _viaIR) m_viaIR = _viaIR; } +void CompilerStack::setExperimental(bool _experimental) +{ + solAssert(m_stackState < ParsedAndImported, "Must set experimental before parsing."); + m_experimental = _experimental; +} + void CompilerStack::setEVMVersion(langutil::EVMVersion _version) { solAssert(m_stackState < ParsedAndImported, "Must set EVM version before parsing."); @@ -450,6 +456,19 @@ void CompilerStack::importASTs(std::map const& _sources) storeContractDefinitions(); } +namespace +{ + +bool onlySafeExperimentalFeaturesActivated(std::set const& _features) +{ + for (auto const feature: _features) + if (!ExperimentalFeatureWithoutWarning.contains(feature)) + return false; + return true; +} + +} + bool CompilerStack::analyze() { solAssert(m_stackState == ParsedAndImported, "Must call analyze only after parsing was successful."); @@ -467,7 +486,7 @@ bool CompilerStack::analyze() { bool experimentalSolidity = isExperimentalSolidity(); - SyntaxChecker syntaxChecker(m_errorReporter, m_optimiserSettings.runYulOptimiser); + SyntaxChecker syntaxChecker(m_errorReporter, m_optimiserSettings.runYulOptimiser, m_experimental); for (Source const* source: m_sourceOrder) if (source->ast && !syntaxChecker.checkSyntax(*source->ast)) noErrors = false; @@ -527,6 +546,10 @@ bool CompilerStack::analyze() if (!noErrors) return false; + for (Source const* source: m_sourceOrder) + if (source->ast && !m_experimental) + solAssert(onlySafeExperimentalFeaturesActivated(source->ast->annotation().experimentalFeatures)); + m_stackState = AnalysisSuccessful; return true; } @@ -1446,17 +1469,6 @@ void CompilerStack::annotateInternalFunctionIDs() } } -namespace -{ -bool onlySafeExperimentalFeaturesActivated(std::set const& features) -{ - for (auto const feature: features) - if (!ExperimentalFeatureWithoutWarning.count(feature)) - return false; - return true; -} -} - void CompilerStack::assembleYul( ContractDefinition const& _contract, std::shared_ptr _assembly, @@ -1816,6 +1828,8 @@ std::string CompilerStack::createMetadata(Contract const& _contract, bool _forIR if (_forIR) meta["settings"]["viaIR"] = _forIR; meta["settings"]["evmVersion"] = m_evmVersion.name(); + if (m_experimental) + meta["settings"]["experimental"] = m_experimental; if (m_eofVersion.has_value()) meta["settings"]["eofVersion"] = *m_eofVersion; meta["settings"]["compilationTarget"][_contract.contract->sourceUnitName()] = @@ -1927,10 +1941,14 @@ bytes CompilerStack::createCBORMetadata(Contract const& _contract, bool _forIR) if (m_metadataFormat == MetadataFormat::NoMetadata) return bytes{}; - bool const experimentalMode = !onlySafeExperimentalFeaturesActivated( + bool const usesExperimentalSyntax = !_contract.contract->sourceUnit().annotation().experimentalFeatures.empty(); + bool const onlySafeExperimentalFeatures = onlySafeExperimentalFeaturesActivated( _contract.contract->sourceUnit().annotation().experimentalFeatures ); + if (m_eofVersion.has_value() || (usesExperimentalSyntax && !onlySafeExperimentalFeatures)) + solAssert(m_experimental, "Experimental mode not enabled"); + std::string meta = (_forIR == m_viaIR ? metadata(_contract) : createMetadata(_contract, _forIR)); MetadataCBOREncoder encoder; @@ -1942,7 +1960,7 @@ bytes CompilerStack::createCBORMetadata(Contract const& _contract, bool _forIR) else solAssert(m_metadataHash == MetadataHash::None, "Invalid metadata hash"); - if (experimentalMode || m_eofVersion.has_value()) + if (m_experimental) encoder.pushBool("experimental", true); if (m_metadataFormat == MetadataFormat::WithReleaseVersionTag) encoder.pushBytes("solc", VersionCompactBytes); diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index 2731787a4b88..eb765d3c666b 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -223,6 +223,9 @@ class CompilerStack: public langutil::CharStreamProvider, public evmasm::Abstrac /// Must be set before parsing. void setViaIR(bool _viaIR); + /// Sets the experimental toggle to allow usage of experimental features. + void setExperimental(bool _experimental); + /// Set the EVM version used before running compile. /// When called without an argument it will revert to the default version. /// Must be set before parsing. @@ -607,6 +610,7 @@ class CompilerStack: public langutil::CharStreamProvider, public evmasm::Abstrac RevertStrings m_revertStrings = RevertStrings::Default; State m_stopAfter = State::CompilationSuccessful; bool m_viaIR = false; + bool m_experimental = false; langutil::EVMVersion m_evmVersion; std::optional m_eofVersion; ModelCheckerSettings m_modelCheckerSettings; diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index d5502228bda4..74307bbc059c 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -46,6 +46,8 @@ #include #include +#include + using namespace solidity; using namespace solidity::yul; using namespace solidity::frontend; @@ -298,10 +300,28 @@ bool isEthdebugRequested(Json const& _outputSelection) if (!_outputSelection.is_object()) return false; + static std::array const ethdebugArtifacts{"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"}; + + for (auto const& fileRequests: _outputSelection) + for (auto const& requests: fileRequests) + for (auto const& request: requests) + if (ranges::contains(ethdebugArtifacts, request.get())) + return true; + + return false; +} + +bool isExperimentalArtifactRequested(Json const& _outputSelection) +{ + static std::array const experimentalArtifacts{"irAst", "irOptimizedAst", "yulCFGJson"}; + + if (isEthdebugRequested(_outputSelection)) + return true; + for (auto const& fileRequests: _outputSelection) for (auto const& requests: fileRequests) for (auto const& request: requests) - if (request == "evm.bytecode.ethdebug" || request == "evm.deployedBytecode.ethdebug") + if (ranges::contains(experimentalArtifacts, request.get())) return true; return false; @@ -430,7 +450,7 @@ std::optional checkAuxiliaryInputKeys(Json const& _input) std::optional checkSettingsKeys(Json const& _input) { - static std::set keys{"debug", "evmVersion", "eofVersion", "libraries", "metadata", "modelChecker", "optimizer", "outputSelection", "remappings", "stopAfter", "viaIR"}; + static std::set keys{"debug", "evmVersion", "experimental", "eofVersion", "libraries", "metadata", "modelChecker", "optimizer", "outputSelection", "remappings", "stopAfter", "viaIR"}; return checkKeys(_input, keys, "settings"); } @@ -803,6 +823,13 @@ std::variant StandardCompiler::parseI if (auto result = checkSettingsKeys(settings)) return *result; + if (settings.contains("experimental")) + { + if (!settings["experimental"].is_boolean()) + return formatFatalError(Error::Type::JSONError, "'settings.experimental' must be a Boolean."); + ret.experimental = settings["experimental"].get(); + } + if (settings.contains("stopAfter")) { if (!settings["stopAfter"].is_string()) @@ -1203,16 +1230,34 @@ std::variant StandardCompiler::parseI } } - if ( - ret.debugInfoSelection.has_value() && ret.debugInfoSelection->ethdebug && (ret.language == "Solidity" || ret.language == "Yul") && - !pipelineConfig(ret.outputSelection)[""][""].irCodegen && !isEthdebugRequested(ret.outputSelection) - ) - return formatFatalError(Error::Type::FatalError, "'settings.debug.debugInfo' can only include 'ethdebug', if output 'ir', 'irOptimized', 'evm.bytecode.ethdebug', or 'evm.deployedBytecode.ethdebug' was selected."); + if (ret.debugInfoSelection.has_value() && ret.debugInfoSelection->ethdebug) + { + if (!ret.experimental) + return formatFatalError(Error::Type::FatalError, "Ethdebug annotations are experimental and can only be included in 'settings.debug.debugInfo' by enabling the 'settings.experimental' option."); + if (!pipelineConfig(ret.outputSelection)[""][""].irCodegen && !isEthdebugRequested(ret.outputSelection)) + return formatFatalError(Error::Type::FatalError, "'settings.debug.debugInfo' can only include 'ethdebug', if output 'ir', 'irOptimized', 'evm.bytecode.ethdebug', or 'evm.deployedBytecode.ethdebug' was selected."); + } if (isEthdebugRequested(ret.outputSelection)) if (ret.optimiserSettings.runYulOptimiser) solUnimplemented("Optimization is not yet supported with ethdebug."); + if (!ret.experimental) + { + if (ret.language == "SolidityAST" || ret.language == "EVMAssembly") + return formatFatalError(Error::Type::FatalError, "'SolidityAST' and 'EVMAssembly' inputs are experimental and can only be used with the 'settings.experimental' option enabled."); + + if (ret.evmVersion.isExperimental()) + // TODO: Cover with test when the Amsterdam version is introduced + return formatFatalError(Error::Type::FatalError, fmt::format("EVM version '{}' is experimental and can only be used with the 'settings.experimental' option enabled.", ret.evmVersion.name())); + + if (isExperimentalArtifactRequested(ret.outputSelection)) + return formatFatalError(Error::Type::FatalError, "'irAst', 'irOptimizedAst', 'yulCFGJson', and 'ethdebug' outputs are experimental and can only be used with the 'settings.experimental' option enabled."); + + if (ret.eofVersion.has_value()) + return formatFatalError(Error::Type::FatalError, "'eofVersion' setting is experimental and can only be used with the 'settings.experimental' option enabled."); + } + return {std::move(ret)}; } @@ -1238,6 +1283,7 @@ Json StandardCompiler::importEVMAssembly(StandardCompiler::InputsAndSettings _in solAssert(_inputsAndSettings.language == "EVMAssembly"); solAssert(_inputsAndSettings.sources.empty()); solAssert(_inputsAndSettings.jsonSources.size() == 1); + solAssert(_inputsAndSettings.experimental); if (!isBinaryRequested(_inputsAndSettings.outputSelection)) return Json::object(); @@ -1373,6 +1419,7 @@ Json StandardCompiler::compileSolidity(StandardCompiler::InputsAndSettings _inpu compilerStack.setMetadataHash(_inputsAndSettings.metadataHash); compilerStack.selectContracts(pipelineConfig(_inputsAndSettings.outputSelection)); compilerStack.setModelCheckerSettings(_inputsAndSettings.modelCheckerSettings); + compilerStack.setExperimental(_inputsAndSettings.experimental); Json errors = std::move(_inputsAndSettings.errors); @@ -1772,7 +1819,10 @@ Json StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) if (evmArtifactRequested(kind, "linkReferences")) bytecodeJSON["linkReferences"] = formatLinkReferences(selectedObject.bytecode->linkReferences); if (evmArtifactRequested(kind, "ethdebug")) + { + solAssert(_inputsAndSettings.experimental); bytecodeJSON["ethdebug"] = selectedObject.ethdebug; + } if (isDeployed && evmArtifactRequested(kind, "immutableReferences")) bytecodeJSON["immutableReferences"] = formatImmutableReferences(selectedObject.bytecode->immutableReferences); output["contracts"][sourceName][contractName]["evm"][kind] = bytecodeJSON; @@ -1784,11 +1834,16 @@ Json StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) if (isArtifactRequested(_inputsAndSettings.outputSelection, sourceName, contractName, "evm.assembly", wildcardMatchesExperimental)) output["contracts"][sourceName][contractName]["evm"]["assembly"] = object.assembly->assemblyString(stack.debugInfoSelection()); if (isArtifactRequested(_inputsAndSettings.outputSelection, sourceName, contractName, "yulCFGJson", wildcardMatchesExperimental)) + { + solAssert(_inputsAndSettings.experimental, ""); output["contracts"][sourceName][contractName]["yulCFGJson"] = stack.cfgJson(); + } if (isEthdebugRequested(_inputsAndSettings.outputSelection)) + { + solAssert(_inputsAndSettings.experimental, ""); output["ethdebug"] = evmasm::ethdebug::resources({sourceName}, VersionString); - + } return output; } diff --git a/libsolidity/interface/StandardCompiler.h b/libsolidity/interface/StandardCompiler.h index 665e8b487158..493e637cd64b 100644 --- a/libsolidity/interface/StandardCompiler.h +++ b/libsolidity/interface/StandardCompiler.h @@ -89,6 +89,7 @@ class StandardCompiler Json outputSelection; ModelCheckerSettings modelCheckerSettings = ModelCheckerSettings{}; bool viaIR = false; + bool experimental = false; }; /// Parses the input json (and potentially invokes the read callback) and either returns diff --git a/scripts/ASTImportTest.sh b/scripts/ASTImportTest.sh index c7f504087c96..3eff30562401 100755 --- a/scripts/ASTImportTest.sh +++ b/scripts/ASTImportTest.sh @@ -117,7 +117,7 @@ function test_ast_import_export_equivalence local input_files=( "${@:2}" ) local export_command=("$SOLC" --combined-json ast --pretty-json --json-indent 4 "${input_files[@]}") - local import_command=("$SOLC" --import-ast --combined-json ast --pretty-json --json-indent 4 expected.json) + local import_command=("$SOLC" --experimental --import-ast --combined-json ast --pretty-json --json-indent 4 expected.json) local import_via_standard_json_command=("$SOLC" --combined-json ast --pretty-json --json-indent 4 --standard-json standard_json_input.json) # export ast - save ast json as expected result (silently) @@ -139,7 +139,7 @@ function test_ast_import_export_equivalence echo ". += {\"sources\":" > _ast_json.json jq .sources expected.json >> _ast_json.json echo "}" >> _ast_json.json - echo "{\"language\": \"SolidityAST\", \"settings\": {\"outputSelection\": {\"*\": {\"\": [\"ast\"]}}}}" > standard_json.json + echo "{\"language\": \"SolidityAST\", \"settings\": {\"experimental\": true, \"outputSelection\": {\"*\": {\"\": [\"ast\"]}}}}" > standard_json.json jq --from-file _ast_json.json standard_json.json > standard_json_input.json # (re)import ast via standard json - and export it again as obtained result (silently) @@ -228,7 +228,7 @@ function test_evmjson_import_export_equivalence local bin_file_from_asm_import bin_file_from_asm_import="import/$(basename "${asm_json_file}" .json).bin" - local import_options=(--bin --import-asm-json "${asm_json_file}") + local import_options=(--experimental --bin --import-asm-json "${asm_json_file}") run_solc_store_stdout "${bin_file_from_asm_import}" "${import_options[@]}" stripCLIDecorations < "$bin_file_from_asm_import" > tmpfile diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 4a7f34561fbe..90c67868d55f 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -927,6 +927,7 @@ void CommandLineInterface::compile() try { + m_compiler->setExperimental(m_options.experimental); if (m_options.metadata.literalSources) m_compiler->useMetadataLiteralSources(true); m_compiler->setMetadataFormat(m_options.metadata.format); diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index 534eb57d1095..7f143695d53d 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -50,6 +50,7 @@ static std::string const g_strEVMVersion = "evm-version"; static std::string const g_strEOFVersion = "experimental-eof-version"; static std::string const g_strViaIR = "via-ir"; static std::string const g_strExperimentalViaIR = "experimental-via-ir"; +static std::string const g_strExperimental = "experimental"; static std::string const g_strGas = "gas"; static std::string const g_strHelp = "help"; static std::string const g_strImportAst = "import-ast"; @@ -157,6 +158,40 @@ void CommandLineParser::checkMutuallyExclusive(std::vector const& _ } } +void CommandLineParser::checkExperimental(std::vector const& _optionNames) const +{ + if (!m_args.contains(g_strExperimental) && countEnabledOptions(_optionNames) > 0) + { + solThrow( + CommandLineValidationError, + fmt::format( + "The following options are only available in experimental mode: {}. " + "To enable experimental mode, use the --{} flag.", + joinOptionNames(enabledOptions(_optionNames)), + g_strExperimental + ) + ); + } + + if (m_args.contains(g_strEVMVersion)) + { + std::string versionOptionStr = m_args[g_strEVMVersion].as(); + std::optional versionOption = langutil::EVMVersion::fromString(versionOptionStr); + + if (versionOption.has_value() && versionOption->isExperimental()) + // TODO: Cover with test when the Amsterdam version is introduced + solThrow( + CommandLineValidationError, + fmt::format( + "EVM version '{}' is experimental and can only be selected in experimental mode. " + "To enable experimental mode, use the --{} flag", + m_options.output.evmVersion.name(), + g_strExperimental + ) + ); + } +} + std::ostream& operator<<(std::ostream& _out, CompilerOutputs const& _selection) { std::vector serializedSelection; @@ -401,6 +436,12 @@ void CommandLineParser::parseLibraryOption(std::string const& _input) } } +std::vector CommandLineParser::enabledOptions(std::vector const& _optionList) const +{ + auto optionEnabled = [&](std::string const& _option) { return m_args.contains(_option); }; + return _optionList | ranges::views::filter(optionEnabled) | ranges::to_vector; +} + void CommandLineParser::parseOutputSelection() { static auto outputSupported = [](InputMode _mode, std::string_view _outputName) @@ -475,7 +516,7 @@ void CommandLineParser::parseOutputSelection() // TODO: restrict EOF version to correct EVM version. } -po::options_description CommandLineParser::optionsDescription(bool _forHelp) +po::options_description CommandLineParser::optionsDescription() { // Declare the supported options. po::options_description desc((R"(solc, the Solidity commandline compiler. @@ -543,7 +584,7 @@ General Information)").c_str(), std::string annotatedEVMVersions = util::joinHumanReadable( allEVMVersions | ranges::views::transform(annotateEVMVersion), ", ", - " or " + ", or " ); po::options_description outputOptions("Output Options"); @@ -563,20 +604,19 @@ General Information)").c_str(), ("Select desired EVM version: " + annotatedEVMVersions + ".").c_str() ) ; - if (!_forHelp) // Note: We intentionally keep this undocumented for now. - outputOptions.add_options() - ( - g_strEOFVersion.c_str(), - // Declared as uint64_t, since uint8_t will be parsed as character by boost. - po::value()->value_name("version")->implicit_value(1), - "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() + ( + g_strEOFVersion.c_str(), + // Declared as uint64_t, since uint8_t will be parsed as character by boost. + po::value()->value_name("version")->implicit_value(1), + "(experimental) Select desired EOF version. Currently the only valid value is 1. " + "If not specified, non-EOF bytecode will be generated." + ) + ( + g_strYul.c_str(), + "(disabled) Switch to typed Yul mode. The typed Yul dialect is no longer supported. " + "For regular Yul compilation use --strict-assembly instead." + ) ( g_strExperimentalViaIR.c_str(), "Deprecated synonym of --via-ir." @@ -594,8 +634,10 @@ General Information)").c_str(), g_strDebugInfo.c_str(), po::value()->default_value(util::toString(DebugInfoSelection::Default())), ("Debug info components to be included in the produced EVM assembly and Yul code. " - "Value can be all, none or a comma-separated list containing one or more of the " - "following components: " + util::joinHumanReadable(DebugInfoSelection::Default().selectedNames()) + ".").c_str() + "Value can be 'all', 'none' or a comma-separated list containing one or more of the " + "following components: " + util::joinHumanReadable(DebugInfoSelection::AllExceptExperimental().selectedNames()) + + ", or ethdebug (experimental). " + "Note that 'all' does not include experimental components.").c_str() ) ( g_strStopAfter.c_str(), @@ -627,21 +669,25 @@ General Information)").c_str(), ) ( g_strImportAst.c_str(), - ("Import ASTs to be compiled, assumes input holds the AST in compact JSON format. " - "Supported Inputs is the output of the --" + g_strStandardJSON + " or the one produced by " - "--" + g_strCombinedJson + " " + CombinedJsonRequests::componentName(&CombinedJsonRequests::ast)).c_str() + ("(experimental) Resume compilation from an abstract syntax tree (AST) representing already parsed and analyzed Solidity code. " + "In this mode the compiler expects exactly one input file, containing an AST in compact JSON format, as produced by" + " --" + CompilerOutputs::componentName(&CompilerOutputs::astCompactJson) + ", --" + + CombinedJsonRequests::componentName(&CombinedJsonRequests::ast) + " ast or the 'ast' output in Standard JSON.").c_str() ) ( g_strImportEvmAssemblerJson.c_str(), - ("Import EVM assembly in JSON format produced by --asm-json. " - "WARNING: --asm-json output is already optimized according to settings stored in metadata. " + ("(experimental) Resume compilation from EVM assembly. " + "In this mode the compiler expects exactly one input file, containing assembly in JSON format, " + "as produced by --" + g_strImportEvmAssemblerJson + "or the 'evm.legacyAssembly' output in Standard JSON. " + "WARNING: --" + g_strImportEvmAssemblerJson + " output is already optimized according to settings stored in metadata. " "Using --" + g_strOptimize + " in this mode is allowed, but not necessary under normal circumstances. " - "It forces the optimizer to run again and can produce bytecode that is not reproducible from metadata.").c_str() + "--" + g_strOptimize + " forces the optimizer to run again and can produce bytecode that is not reproducible from metadata.").c_str() ) ( g_strLSP.c_str(), - "Switch to language server mode (\"LSP\"). Allows the compiler to be used as an analysis backend " - "for your favourite IDE." + "(experimental) Switch to the language server mode. " + "Allows the compiler to be used as an analysis backend for your favourite IDE. " + "In this mode no input files are accepted and the compiler expects language server protocol (LSP) messages on standard input." ) ; desc.add(alternativeInputModes); @@ -709,34 +755,28 @@ General Information)").c_str(), (CompilerOutputs::componentName(&CompilerOutputs::binaryRuntime).c_str(), "Binary of the runtime part of the contracts in hex.") (CompilerOutputs::componentName(&CompilerOutputs::abi).c_str(), "ABI specification of the contracts.") (CompilerOutputs::componentName(&CompilerOutputs::ir).c_str(), "Intermediate Representation (IR) of all contracts.") - (CompilerOutputs::componentName(&CompilerOutputs::irAstJson).c_str(), "AST of Intermediate Representation (IR) of all contracts in a compact JSON format.") + (CompilerOutputs::componentName(&CompilerOutputs::irAstJson).c_str(), "(experimental) AST of Intermediate Representation (IR) of all contracts in a compact JSON format.") (CompilerOutputs::componentName(&CompilerOutputs::irOptimized).c_str(), "Optimized Intermediate Representation (IR) of all contracts.") - (CompilerOutputs::componentName(&CompilerOutputs::irOptimizedAstJson).c_str(), "AST of optimized Intermediate Representation (IR) of all contracts in a compact JSON format.") + (CompilerOutputs::componentName(&CompilerOutputs::irOptimizedAstJson).c_str(), "(experimental) AST of optimized Intermediate Representation (IR) of all contracts in a compact JSON format.") (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 IPFS hash is stored on-chain.") (CompilerOutputs::componentName(&CompilerOutputs::storageLayout).c_str(), "Slots, offsets and types of the contract's state variables located in storage.") (CompilerOutputs::componentName(&CompilerOutputs::transientStorageLayout).c_str(), "Slots, offsets and types of the contract's state variables located in transient storage.") - ; - if (!_forHelp) // Note: We intentionally keep this undocumented for now. - { - outputComponents.add_options() - ( - CompilerOutputs::componentName(&CompilerOutputs::yulCFGJson).c_str(), - "Control Flow Graph (CFG) of Yul code in JSON format." - ); - outputComponents.add_options() - ( - CompilerOutputs::componentName(&CompilerOutputs::ethdebug).c_str(), - "Ethdebug output of all contracts." - ); - outputComponents.add_options() - ( - CompilerOutputs::componentName(&CompilerOutputs::ethdebugRuntime).c_str(), - "Ethdebug output of the runtime part of all contracts." - ); - } + ( + CompilerOutputs::componentName(&CompilerOutputs::yulCFGJson).c_str(), + "(experimental) Control Flow Graph (CFG) of Yul code in Static Single Assignment (SSA) form in JSON format." + ) + ( + CompilerOutputs::componentName(&CompilerOutputs::ethdebug).c_str(), + "(experimental) Debug information in ethdebug format for all contracts (ethdebug/format/program schema). " + "When enabled, an extra global output containing the ethdebug/format/info/resources schema with information shared by all contracts is automatically enabled as well." + ) + ( + CompilerOutputs::componentName(&CompilerOutputs::ethdebugRuntime).c_str(), + ("(experimental) Like --" + CompilerOutputs::componentName(&CompilerOutputs::ethdebug) + ", but for the runtime part of the contracts.").c_str() + ); desc.add(outputComponents); po::options_description extraOutput("Extra Output"); @@ -879,6 +919,17 @@ General Information)").c_str(), ; desc.add(smtCheckerOptions); + po::options_description experimentalOptions("Experimental options"); + experimentalOptions.add_options() + ( + g_strExperimental.c_str(), + "Enable experimental mode. " + "This flag does not activate any experimental features on its own - " + "it unlocks the ability to use them through the usual flags and pragmas." + ) + ; + desc.add(experimentalOptions); + desc.add_options()(g_strInputFile.c_str(), po::value>(), "input file"); return desc; } @@ -922,6 +973,9 @@ void CommandLineParser::processArgs() else if (m_args.count(g_strColor) > 0) m_options.formatting.coloredOutput = true; + if (m_args.contains(g_strExperimental)) + m_options.experimental = true; + checkMutuallyExclusive({ g_strHelp, g_strLicense, @@ -935,6 +989,18 @@ void CommandLineParser::processArgs() g_strImportEvmAssemblerJson, }); + checkExperimental({ + g_strLSP, + g_strImportAst, + g_strImportEvmAssemblerJson, + "ir-ast-json", + "ir-optimized-ast-json", + "yul-cfg-json", + "ethdebug", + "ethdebug-runtime", + g_strEOFVersion, + }); + if (m_args.count(g_strHelp) > 0) m_options.input.mode = InputMode::Help; else if (m_args.count(g_strLicense) > 0) @@ -963,6 +1029,14 @@ void CommandLineParser::processArgs() ) return; + if (m_options.experimental && m_options.input.mode == InputMode::StandardJson) + solThrow( + CommandLineValidationError, + "Standard JSON input mode is incompatible with the --" + g_strExperimental + " flag. " + "Instead, please use the 'settings.experimental' setting in your Standard JSON input file to " + "enable experimental mode." + ); + if (m_args.count(g_strYul) > 0) solThrow( CommandLineValidationError, @@ -1035,6 +1109,7 @@ void CommandLineParser::processArgs() g_strPrettyJson, "srcmap", "srcmap-runtime", + g_strExperimental, }; for (auto const& [optionName, optionValue]: m_args) @@ -1102,6 +1177,16 @@ void CommandLineParser::processArgs() if (!m_options.output.debugInfoSelection.has_value()) solThrow(CommandLineValidationError, "Invalid value for --" + g_strDebugInfo + " option: " + optionValue); + if (!m_options.experimental && m_options.output.debugInfoSelection->ethdebug) + solThrow( + CommandLineValidationError, + fmt::format( + "Ethdebug annotations are experimental and can only be included in --{} in experimental mode. To enable experimental mode, use the --{} flag.", + g_strDebugInfo, + g_strExperimental + ) + ); + if (m_options.output.debugInfoSelection->snippet && !m_options.output.debugInfoSelection->location) solThrow(CommandLineValidationError, "To use 'snippet' with --" + g_strDebugInfo + " you must select also 'location'."); } diff --git a/solc/CommandLineParser.h b/solc/CommandLineParser.h index 46743232b468..9d9dc28b6ada 100644 --- a/solc/CommandLineParser.h +++ b/solc/CommandLineParser.h @@ -272,6 +272,8 @@ struct CommandLineOptions bool initialize = false; ModelCheckerSettings settings; } modelChecker; + + bool experimental = false; }; /// Parses the command-line arguments and produces a filled-out CommandLineOptions structure. @@ -286,12 +288,12 @@ class CommandLineParser CommandLineOptions const& options() const { return m_options; } - static void printHelp(std::ostream& _out) { _out << optionsDescription(true /* _forHelp */); } + static void printHelp(std::ostream& _out) { _out << optionsDescription(); } private: /// @returns a specification of all named command-line options accepted by the compiler. /// The object can be used to parse command-line arguments or to generate the help screen. - static boost::program_options::options_description optionsDescription(bool _forHelp = false); + static boost::program_options::options_description optionsDescription(); /// @returns a specification of all positional command-line arguments accepted by the compiler. /// The object can be used to parse command-line arguments or to generate the help screen. @@ -322,7 +324,11 @@ class CommandLineParser void parseOutputSelection(); + /// Returns a list of enabled options from @_optionList + std::vector enabledOptions(std::vector const& _optionList) const; + void checkMutuallyExclusive(std::vector const& _optionNames); + void checkExperimental(std::vector const& _optionNames) const; size_t countEnabledOptions(std::vector const& _optionNames) const; static std::string joinOptionNames(std::vector const& _optionNames, std::string _separator = ", "); diff --git a/test/cmdlineTests/asm_json_import_sourcelist_with_null_elements/args b/test/cmdlineTests/asm_json_import_sourcelist_with_null_elements/args index c1bc80dabfcd..5634b014ddbf 100644 --- a/test/cmdlineTests/asm_json_import_sourcelist_with_null_elements/args +++ b/test/cmdlineTests/asm_json_import_sourcelist_with_null_elements/args @@ -1 +1 @@ ---pretty-json --json-indent 4 --import-asm-json - +--pretty-json --json-indent 4 --experimental --import-asm-json - diff --git a/test/cmdlineTests/asm_json_yul_export_evm_asm_import/args b/test/cmdlineTests/asm_json_yul_export_evm_asm_import/args index 15c962831667..7000d519f726 100644 --- a/test/cmdlineTests/asm_json_yul_export_evm_asm_import/args +++ b/test/cmdlineTests/asm_json_yul_export_evm_asm_import/args @@ -1 +1 @@ ---import-asm-json - --opcodes --asm --bin --asm-json --pretty-json --json-indent 4 +--experimental --import-asm-json - --opcodes --asm --bin --asm-json --pretty-json --json-indent 4 diff --git a/test/cmdlineTests/ast_ir/args b/test/cmdlineTests/ast_ir/args index d254bff83d54..ab35cc76b38f 100644 --- a/test/cmdlineTests/ast_ir/args +++ b/test/cmdlineTests/ast_ir/args @@ -1 +1 @@ ---ir-ast-json --ir-optimized-ast-json --optimize --pretty-json --json-indent 4 +--experimental --ir-ast-json --ir-optimized-ast-json --optimize --pretty-json --json-indent 4 diff --git a/test/cmdlineTests/ast_json_import_wrong_evmVersion/args b/test/cmdlineTests/ast_json_import_wrong_evmVersion/args index d8fddfec65db..d6692d825c6b 100644 --- a/test/cmdlineTests/ast_json_import_wrong_evmVersion/args +++ b/test/cmdlineTests/ast_json_import_wrong_evmVersion/args @@ -1 +1 @@ ---evm-version=homestead --import-ast --combined-json ast --pretty-json +--experimental --evm-version=homestead --import-ast --combined-json ast --pretty-json diff --git a/test/cmdlineTests/eof_unavailable_before_osaka/args b/test/cmdlineTests/eof_unavailable_before_osaka/args index 90e7e00e2552..7e9b7ee93624 100644 --- a/test/cmdlineTests/eof_unavailable_before_osaka/args +++ b/test/cmdlineTests/eof_unavailable_before_osaka/args @@ -1 +1 @@ ---optimize --experimental-eof-version 1 --evm-version cancun +--experimental --optimize --experimental-eof-version 1 --evm-version cancun diff --git a/test/cmdlineTests/ethdebug_debuginfo_without_experimental_flag/args b/test/cmdlineTests/ethdebug_debuginfo_without_experimental_flag/args new file mode 100644 index 000000000000..7b4e521b02b8 --- /dev/null +++ b/test/cmdlineTests/ethdebug_debuginfo_without_experimental_flag/args @@ -0,0 +1 @@ +--debug-info ethdebug diff --git a/test/cmdlineTests/ethdebug_debuginfo_without_experimental_flag/err b/test/cmdlineTests/ethdebug_debuginfo_without_experimental_flag/err new file mode 100644 index 000000000000..a7b9ca900b59 --- /dev/null +++ b/test/cmdlineTests/ethdebug_debuginfo_without_experimental_flag/err @@ -0,0 +1 @@ +Error: Ethdebug annotations are experimental and can only be included in --debug-info in experimental mode. To enable experimental mode, use the --experimental flag. diff --git a/test/cmdlineTests/ethdebug_debuginfo_without_experimental_flag/exit b/test/cmdlineTests/ethdebug_debuginfo_without_experimental_flag/exit new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/test/cmdlineTests/ethdebug_debuginfo_without_experimental_flag/exit @@ -0,0 +1 @@ +1 diff --git a/test/cmdlineTests/ethdebug_debuginfo_without_experimental_flag/input.sol b/test/cmdlineTests/ethdebug_debuginfo_without_experimental_flag/input.sol new file mode 100644 index 000000000000..415509ef9aef --- /dev/null +++ b/test/cmdlineTests/ethdebug_debuginfo_without_experimental_flag/input.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +pragma solidity >=0.0; + +contract C { + function f() public {} +} diff --git a/test/cmdlineTests/ethdebug_eof_container_osaka/args b/test/cmdlineTests/ethdebug_eof_container_osaka/args index 16466b842d0e..49c5bc838258 100644 --- a/test/cmdlineTests/ethdebug_eof_container_osaka/args +++ b/test/cmdlineTests/ethdebug_eof_container_osaka/args @@ -1 +1 @@ - --experimental-eof-version 1 --evm-version osaka --ethdebug --via-ir --pretty-json --json-indent 4 +--experimental --experimental-eof-version 1 --evm-version osaka --ethdebug --via-ir --pretty-json --json-indent 4 diff --git a/test/cmdlineTests/ethdebug_on_abstract/args b/test/cmdlineTests/ethdebug_on_abstract/args index c6018b329a67..c345d483a32a 100644 --- a/test/cmdlineTests/ethdebug_on_abstract/args +++ b/test/cmdlineTests/ethdebug_on_abstract/args @@ -1 +1 @@ ---ethdebug --via-ir --pretty-json --json-indent 4 +--experimental --ethdebug --via-ir --pretty-json --json-indent 4 diff --git a/test/cmdlineTests/ethdebug_on_interface/args b/test/cmdlineTests/ethdebug_on_interface/args index c6018b329a67..c345d483a32a 100644 --- a/test/cmdlineTests/ethdebug_on_interface/args +++ b/test/cmdlineTests/ethdebug_on_interface/args @@ -1 +1 @@ ---ethdebug --via-ir --pretty-json --json-indent 4 +--experimental --ethdebug --via-ir --pretty-json --json-indent 4 diff --git a/test/cmdlineTests/experimental_feature_without_experimental_flag/args b/test/cmdlineTests/experimental_feature_without_experimental_flag/args new file mode 100644 index 000000000000..a5ec4617b5f8 --- /dev/null +++ b/test/cmdlineTests/experimental_feature_without_experimental_flag/args @@ -0,0 +1 @@ +--ir-ast-json diff --git a/test/cmdlineTests/experimental_feature_without_experimental_flag/err b/test/cmdlineTests/experimental_feature_without_experimental_flag/err new file mode 100644 index 000000000000..b21b7318e1d2 --- /dev/null +++ b/test/cmdlineTests/experimental_feature_without_experimental_flag/err @@ -0,0 +1 @@ +Error: The following options are only available in experimental mode: --ir-ast-json. To enable experimental mode, use the --experimental flag. diff --git a/test/cmdlineTests/experimental_feature_without_experimental_flag/exit b/test/cmdlineTests/experimental_feature_without_experimental_flag/exit new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/test/cmdlineTests/experimental_feature_without_experimental_flag/exit @@ -0,0 +1 @@ +1 diff --git a/test/cmdlineTests/experimental_feature_without_experimental_flag/input.sol b/test/cmdlineTests/experimental_feature_without_experimental_flag/input.sol new file mode 100644 index 000000000000..0bea95d1ef4e --- /dev/null +++ b/test/cmdlineTests/experimental_feature_without_experimental_flag/input.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +pragma solidity >=0.0; + +contract C { + function f() public {} +} diff --git a/test/cmdlineTests/experimental_flag_with_standard_json/args b/test/cmdlineTests/experimental_flag_with_standard_json/args new file mode 100644 index 000000000000..1c31d6967ecd --- /dev/null +++ b/test/cmdlineTests/experimental_flag_with_standard_json/args @@ -0,0 +1 @@ +--experimental diff --git a/test/cmdlineTests/experimental_flag_with_standard_json/err b/test/cmdlineTests/experimental_flag_with_standard_json/err new file mode 100644 index 000000000000..81d8411e5a04 --- /dev/null +++ b/test/cmdlineTests/experimental_flag_with_standard_json/err @@ -0,0 +1 @@ +Error: Standard JSON input mode is incompatible with the --experimental flag. Instead, please use the 'settings.experimental' setting in your Standard JSON input file to enable experimental mode. diff --git a/test/cmdlineTests/experimental_flag_with_standard_json/exit b/test/cmdlineTests/experimental_flag_with_standard_json/exit new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/test/cmdlineTests/experimental_flag_with_standard_json/exit @@ -0,0 +1 @@ +1 diff --git a/test/cmdlineTests/experimental_flag_with_standard_json/input.json b/test/cmdlineTests/experimental_flag_with_standard_json/input.json new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/import_asm_json_all_valid_flags/args b/test/cmdlineTests/import_asm_json_all_valid_flags/args index e6010eac3b05..a1e89d7ae47a 100644 --- a/test/cmdlineTests/import_asm_json_all_valid_flags/args +++ b/test/cmdlineTests/import_asm_json_all_valid_flags/args @@ -1 +1 @@ ---pretty-json --json-indent 4 --combined-json bin,bin-runtime,opcodes,asm,srcmap,srcmap-runtime --asm --bin --bin-runtime --asm-json --import-asm-json - +--experimental --pretty-json --json-indent 4 --combined-json bin,bin-runtime,opcodes,asm,srcmap,srcmap-runtime --asm --bin --bin-runtime --asm-json --import-asm-json - diff --git a/test/cmdlineTests/import_asm_json_difficulty_prevrandao/args b/test/cmdlineTests/import_asm_json_difficulty_prevrandao/args index 2b4b3a1534b7..a31c9320b0af 100644 --- a/test/cmdlineTests/import_asm_json_difficulty_prevrandao/args +++ b/test/cmdlineTests/import_asm_json_difficulty_prevrandao/args @@ -1 +1 @@ ---import-asm-json - --opcodes --asm +--experimental --import-asm-json - --opcodes --asm diff --git a/test/cmdlineTests/import_asm_json_eof_unavailable_before_osaka/args b/test/cmdlineTests/import_asm_json_eof_unavailable_before_osaka/args index b5d6267fa5b0..7293bf52ab49 100644 --- a/test/cmdlineTests/import_asm_json_eof_unavailable_before_osaka/args +++ b/test/cmdlineTests/import_asm_json_eof_unavailable_before_osaka/args @@ -1 +1 @@ ---import-asm-json --experimental-eof-version 1 --evm-version cancun +--experimental --import-asm-json --experimental-eof-version 1 --evm-version cancun diff --git a/test/cmdlineTests/import_asm_json_hex_subassembly_indices/args b/test/cmdlineTests/import_asm_json_hex_subassembly_indices/args index 2b4b3a1534b7..a31c9320b0af 100644 --- a/test/cmdlineTests/import_asm_json_hex_subassembly_indices/args +++ b/test/cmdlineTests/import_asm_json_hex_subassembly_indices/args @@ -1 +1 @@ ---import-asm-json - --opcodes --asm +--experimental --import-asm-json - --opcodes --asm diff --git a/test/cmdlineTests/import_asm_json_invalid_data_not_hex/args b/test/cmdlineTests/import_asm_json_invalid_data_not_hex/args index 2b4b3a1534b7..a31c9320b0af 100644 --- a/test/cmdlineTests/import_asm_json_invalid_data_not_hex/args +++ b/test/cmdlineTests/import_asm_json_invalid_data_not_hex/args @@ -1 +1 @@ ---import-asm-json - --opcodes --asm +--experimental --import-asm-json - --opcodes --asm diff --git a/test/cmdlineTests/import_asm_json_invalid_data_not_object/args b/test/cmdlineTests/import_asm_json_invalid_data_not_object/args index 2b4b3a1534b7..a31c9320b0af 100644 --- a/test/cmdlineTests/import_asm_json_invalid_data_not_object/args +++ b/test/cmdlineTests/import_asm_json_invalid_data_not_object/args @@ -1 +1 @@ ---import-asm-json - --opcodes --asm +--experimental --import-asm-json - --opcodes --asm diff --git a/test/cmdlineTests/import_asm_json_invalid_jumptype_instruction/args b/test/cmdlineTests/import_asm_json_invalid_jumptype_instruction/args index 2b4b3a1534b7..a31c9320b0af 100644 --- a/test/cmdlineTests/import_asm_json_invalid_jumptype_instruction/args +++ b/test/cmdlineTests/import_asm_json_invalid_jumptype_instruction/args @@ -1 +1 @@ ---import-asm-json - --opcodes --asm +--experimental --import-asm-json - --opcodes --asm diff --git a/test/cmdlineTests/import_asm_json_invalid_value/args b/test/cmdlineTests/import_asm_json_invalid_value/args index 2b4b3a1534b7..a31c9320b0af 100644 --- a/test/cmdlineTests/import_asm_json_invalid_value/args +++ b/test/cmdlineTests/import_asm_json_invalid_value/args @@ -1 +1 @@ ---import-asm-json - --opcodes --asm +--experimental --import-asm-json - --opcodes --asm diff --git a/test/cmdlineTests/import_asm_json_missing_subobject_indices/args b/test/cmdlineTests/import_asm_json_missing_subobject_indices/args index 2b4b3a1534b7..a31c9320b0af 100644 --- a/test/cmdlineTests/import_asm_json_missing_subobject_indices/args +++ b/test/cmdlineTests/import_asm_json_missing_subobject_indices/args @@ -1 +1 @@ ---import-asm-json - --opcodes --asm +--experimental --import-asm-json - --opcodes --asm diff --git a/test/cmdlineTests/import_asm_json_no_optimize/args b/test/cmdlineTests/import_asm_json_no_optimize/args index 0af885908f1e..9dcc671fb0d4 100644 --- a/test/cmdlineTests/import_asm_json_no_optimize/args +++ b/test/cmdlineTests/import_asm_json_no_optimize/args @@ -1 +1 @@ ---import-asm-json - --asm +--experimental --import-asm-json - --asm diff --git a/test/cmdlineTests/import_asm_json_no_value/args b/test/cmdlineTests/import_asm_json_no_value/args index 2b4b3a1534b7..a31c9320b0af 100644 --- a/test/cmdlineTests/import_asm_json_no_value/args +++ b/test/cmdlineTests/import_asm_json_no_value/args @@ -1 +1 @@ ---import-asm-json - --opcodes --asm +--experimental --import-asm-json - --opcodes --asm diff --git a/test/cmdlineTests/import_asm_json_non_unique_sources/args b/test/cmdlineTests/import_asm_json_non_unique_sources/args index d27cc7bb214e..772c307ada1f 100644 --- a/test/cmdlineTests/import_asm_json_non_unique_sources/args +++ b/test/cmdlineTests/import_asm_json_non_unique_sources/args @@ -1 +1 @@ ---asm-json --import-asm-json - +--experimental --asm-json --import-asm-json - diff --git a/test/cmdlineTests/import_asm_json_optimize/args b/test/cmdlineTests/import_asm_json_optimize/args index b9370e6e4f11..1a7274261028 100644 --- a/test/cmdlineTests/import_asm_json_optimize/args +++ b/test/cmdlineTests/import_asm_json_optimize/args @@ -1 +1 @@ ---optimize --import-asm-json - --asm +--experimental --optimize --import-asm-json - --asm diff --git a/test/cmdlineTests/import_asm_json_out_of_range_data_index/args b/test/cmdlineTests/import_asm_json_out_of_range_data_index/args index 2b4b3a1534b7..a31c9320b0af 100644 --- a/test/cmdlineTests/import_asm_json_out_of_range_data_index/args +++ b/test/cmdlineTests/import_asm_json_out_of_range_data_index/args @@ -1 +1 @@ ---import-asm-json - --opcodes --asm +--experimental --import-asm-json - --opcodes --asm diff --git a/test/cmdlineTests/import_asm_json_random_order_data_index/args b/test/cmdlineTests/import_asm_json_random_order_data_index/args index 2b4b3a1534b7..a31c9320b0af 100644 --- a/test/cmdlineTests/import_asm_json_random_order_data_index/args +++ b/test/cmdlineTests/import_asm_json_random_order_data_index/args @@ -1 +1 @@ ---import-asm-json - --opcodes --asm +--experimental --import-asm-json - --opcodes --asm diff --git a/test/cmdlineTests/import_asm_json_unrecognized_field/args b/test/cmdlineTests/import_asm_json_unrecognized_field/args index 2b4b3a1534b7..a31c9320b0af 100644 --- a/test/cmdlineTests/import_asm_json_unrecognized_field/args +++ b/test/cmdlineTests/import_asm_json_unrecognized_field/args @@ -1 +1 @@ ---import-asm-json - --opcodes --asm +--experimental --import-asm-json - --opcodes --asm diff --git a/test/cmdlineTests/import_asm_json_untagged_jumpdest/args b/test/cmdlineTests/import_asm_json_untagged_jumpdest/args index 2b4b3a1534b7..a31c9320b0af 100644 --- a/test/cmdlineTests/import_asm_json_untagged_jumpdest/args +++ b/test/cmdlineTests/import_asm_json_untagged_jumpdest/args @@ -1 +1 @@ ---import-asm-json - --opcodes --asm +--experimental --import-asm-json - --opcodes --asm diff --git a/test/cmdlineTests/import_asm_json_verbatim/args b/test/cmdlineTests/import_asm_json_verbatim/args index 2b4b3a1534b7..a31c9320b0af 100644 --- a/test/cmdlineTests/import_asm_json_verbatim/args +++ b/test/cmdlineTests/import_asm_json_verbatim/args @@ -1 +1 @@ ---import-asm-json - --opcodes --asm +--experimental --import-asm-json - --opcodes --asm diff --git a/test/cmdlineTests/import_asm_json_yul_more_subobjects/args b/test/cmdlineTests/import_asm_json_yul_more_subobjects/args index 58dfc8cc7348..7de136d4bdc0 100644 --- a/test/cmdlineTests/import_asm_json_yul_more_subobjects/args +++ b/test/cmdlineTests/import_asm_json_yul_more_subobjects/args @@ -1 +1 @@ ---import-asm-json - --opcodes +--experimental --import-asm-json - --opcodes diff --git a/test/cmdlineTests/import_asm_json_yul_subobjects/args b/test/cmdlineTests/import_asm_json_yul_subobjects/args index 58dfc8cc7348..7de136d4bdc0 100644 --- a/test/cmdlineTests/import_asm_json_yul_subobjects/args +++ b/test/cmdlineTests/import_asm_json_yul_subobjects/args @@ -1 +1 @@ ---import-asm-json - --opcodes +--experimental --import-asm-json - --opcodes diff --git a/test/cmdlineTests/metadata_experimental/args b/test/cmdlineTests/metadata_experimental/args new file mode 100644 index 000000000000..4a834e560df6 --- /dev/null +++ b/test/cmdlineTests/metadata_experimental/args @@ -0,0 +1 @@ +--metadata --experimental --via-ir --ethdebug --no-cbor-metadata --pretty-json --json-indent 4 diff --git a/test/cmdlineTests/metadata_experimental/input.sol b/test/cmdlineTests/metadata_experimental/input.sol new file mode 100644 index 000000000000..a3a86cc8d317 --- /dev/null +++ b/test/cmdlineTests/metadata_experimental/input.sol @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity *; + +contract C {} diff --git a/test/cmdlineTests/metadata_experimental/output b/test/cmdlineTests/metadata_experimental/output new file mode 100644 index 000000000000..dc9145d5e812 --- /dev/null +++ b/test/cmdlineTests/metadata_experimental/output @@ -0,0 +1,556 @@ +======= Debug Data (ethdebug/format/info/resources) ======= +{ + "compilation": { + "compiler": { + "name": "solc", + "version": "" + }, + "sources": [ + { + "id": 0, + "path": "input.sol" + } + ] + } +} + +======= input.sol:C ======= +Metadata: +{"compiler":{"version": ""},"language":"Solidity","output":{"abi":[],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"input.sol":"C"},"evmVersion":"osaka","experimental":true,"libraries":{},"metadata":{"appendCBOR":false,"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[],"viaIR":true},"sources":{"input.sol":{"keccak256":"0x5cf617b1707a484e3c4bd59643013dec76ab7d75900b46855214729ae3e0ceb0","license":"GPL-3.0","urls":["bzz-raw://ac418a02dfadf87234150d3568f33269e3f49460345cb39300e017a6d755eff2","dweb:/ipfs/QmQq3owBu25x2WV46HB1WyKzJpxiAPecU7eMKqtXCF7eeS"]}},"version":1} +Debug Data (ethdebug/format/program): +{ + "contract": { + "definition": { + "source": { + "id": 0 + } + }, + "name": "C" + }, + "environment": "create", + "instructions": [ + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 0, + "operation": { + "arguments": [ + "0x80" + ], + "mnemonic": "PUSH1" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 2, + "operation": { + "arguments": [ + "0x40" + ], + "mnemonic": "PUSH1" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 4, + "operation": { + "mnemonic": "MSTORE" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 5, + "operation": { + "mnemonic": "CALLVALUE" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 6, + "operation": { + "arguments": [ + "0x19" + ], + "mnemonic": "PUSH1" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 8, + "operation": { + "mnemonic": "JUMPI" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 9, + "operation": { + "arguments": [ + "0x0e" + ], + "mnemonic": "PUSH1" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 11, + "operation": { + "arguments": [ + "0x1d" + ], + "mnemonic": "PUSH1" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 13, + "operation": { + "mnemonic": "JUMP" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 14, + "operation": { + "mnemonic": "JUMPDEST" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 15, + "operation": { + "arguments": [ + "0x08" + ], + "mnemonic": "PUSH1" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 17, + "operation": { + "arguments": [ + "0x28" + ], + "mnemonic": "PUSH1" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 19, + "operation": { + "mnemonic": "DUP3" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 20, + "operation": { + "mnemonic": "CODECOPY" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 21, + "operation": { + "arguments": [ + "0x08" + ], + "mnemonic": "PUSH1" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 23, + "operation": { + "mnemonic": "SWAP1" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 24, + "operation": { + "mnemonic": "RETURN" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 25, + "operation": { + "mnemonic": "JUMPDEST" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 26, + "operation": { + "arguments": [ + "0x23" + ], + "mnemonic": "PUSH1" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 28, + "operation": { + "mnemonic": "JUMP" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 29, + "operation": { + "mnemonic": "JUMPDEST" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 30, + "operation": { + "arguments": [ + "0x40" + ], + "mnemonic": "PUSH1" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 32, + "operation": { + "mnemonic": "MLOAD" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 33, + "operation": { + "mnemonic": "SWAP1" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 34, + "operation": { + "mnemonic": "JUMP" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 35, + "operation": { + "mnemonic": "JUMPDEST" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 36, + "operation": { + "mnemonic": "PUSH0" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 37, + "operation": { + "mnemonic": "DUP1" + } + }, + { + "context": { + "code": { + "range": { + "length": 13, + "offset": 56 + }, + "source": { + "id": 0 + } + } + }, + "offset": 38, + "operation": { + "mnemonic": "REVERT" + } + } + ] +} diff --git a/test/cmdlineTests/standard_cli_import_ast_storage_layout_specifier_missing_expression/args b/test/cmdlineTests/standard_cli_import_ast_storage_layout_specifier_missing_expression/args index f0b85640bd48..811190e2ad5a 100644 --- a/test/cmdlineTests/standard_cli_import_ast_storage_layout_specifier_missing_expression/args +++ b/test/cmdlineTests/standard_cli_import_ast_storage_layout_specifier_missing_expression/args @@ -1 +1 @@ ---import-ast - \ No newline at end of file +--experimental --import-ast - diff --git a/test/cmdlineTests/standard_eof_no_experimental/input.json b/test/cmdlineTests/standard_eof_no_experimental/input.json new file mode 100644 index 000000000000..6ba6f727b9a3 --- /dev/null +++ b/test/cmdlineTests/standard_eof_no_experimental/input.json @@ -0,0 +1,12 @@ +{ + "language": "Solidity", + "sources": { + "A.sol": { + "content": "contract A { constructor() { uint x = 2; { uint y = 3; } } }" + } + }, + "settings": { + "eofVersion": 1, + "evmVersion": "osaka" + } +} diff --git a/test/cmdlineTests/standard_eof_no_experimental/output.json b/test/cmdlineTests/standard_eof_no_experimental/output.json new file mode 100644 index 000000000000..22be8bde1234 --- /dev/null +++ b/test/cmdlineTests/standard_eof_no_experimental/output.json @@ -0,0 +1,11 @@ +{ + "errors": [ + { + "component": "general", + "formattedMessage": "'eofVersion' setting is experimental and can only be used with the 'settings.experimental' option enabled.", + "message": "'eofVersion' setting is experimental and can only be used with the 'settings.experimental' option enabled.", + "severity": "error", + "type": "FatalError" + } + ] +} diff --git a/test/cmdlineTests/standard_import_asm_json/input.json b/test/cmdlineTests/standard_import_asm_json/input.json index 112f480459af..a457d48e2f91 100644 --- a/test/cmdlineTests/standard_import_asm_json/input.json +++ b/test/cmdlineTests/standard_import_asm_json/input.json @@ -19,6 +19,7 @@ } }, "settings": { + "experimental": true, "outputSelection": { "*": { "": ["*"] diff --git a/test/cmdlineTests/standard_import_asm_json_immutable_references/input.json b/test/cmdlineTests/standard_import_asm_json_immutable_references/input.json index 0619f8d03d19..d193ff8a21fc 100644 --- a/test/cmdlineTests/standard_import_asm_json_immutable_references/input.json +++ b/test/cmdlineTests/standard_import_asm_json_immutable_references/input.json @@ -34,6 +34,7 @@ } }, "settings": { + "experimental": true, "outputSelection": { "*": { "": [ diff --git a/test/cmdlineTests/standard_import_asm_json_invalid_opcode/input.json b/test/cmdlineTests/standard_import_asm_json_invalid_opcode/input.json index 2e3e22cc410c..732b05fd8cac 100644 --- a/test/cmdlineTests/standard_import_asm_json_invalid_opcode/input.json +++ b/test/cmdlineTests/standard_import_asm_json_invalid_opcode/input.json @@ -19,6 +19,7 @@ } }, "settings": { + "experimental": true, "outputSelection": { "*": { "": ["evm.bytecode"] diff --git a/test/cmdlineTests/standard_import_asm_json_link_references/input.json b/test/cmdlineTests/standard_import_asm_json_link_references/input.json index 47693fa14838..4c5b45c14891 100644 --- a/test/cmdlineTests/standard_import_asm_json_link_references/input.json +++ b/test/cmdlineTests/standard_import_asm_json_link_references/input.json @@ -26,6 +26,7 @@ } }, "settings": { + "experimental": true, "outputSelection": { "*": { "": [ diff --git a/test/cmdlineTests/import_asm_json_standard_json_optimize/input.json b/test/cmdlineTests/standard_import_asm_json_no_optimize/input.json similarity index 97% rename from test/cmdlineTests/import_asm_json_standard_json_optimize/input.json rename to test/cmdlineTests/standard_import_asm_json_no_optimize/input.json index d1d45825952d..6cb30f6f5c4b 100644 --- a/test/cmdlineTests/import_asm_json_standard_json_optimize/input.json +++ b/test/cmdlineTests/standard_import_asm_json_no_optimize/input.json @@ -28,6 +28,7 @@ } }, "settings": { + "experimental": true, "outputSelection": { "*": { "": ["evm.assembly"] diff --git a/test/cmdlineTests/import_asm_json_standard_json_optimize/output.json b/test/cmdlineTests/standard_import_asm_json_no_optimize/output.json similarity index 100% rename from test/cmdlineTests/import_asm_json_standard_json_optimize/output.json rename to test/cmdlineTests/standard_import_asm_json_no_optimize/output.json diff --git a/test/cmdlineTests/standard_import_asm_json_no_output_selection/input.json b/test/cmdlineTests/standard_import_asm_json_no_output_selection/input.json index 1cd9c3c7d575..ce746eb20023 100644 --- a/test/cmdlineTests/standard_import_asm_json_no_output_selection/input.json +++ b/test/cmdlineTests/standard_import_asm_json_no_output_selection/input.json @@ -19,6 +19,7 @@ } }, "settings": { + "experimental": true, "outputSelection": { "*": { "": [ diff --git a/test/cmdlineTests/import_asm_json_standard_json_no_optimize/input.json b/test/cmdlineTests/standard_import_asm_json_optimize/input.json similarity index 97% rename from test/cmdlineTests/import_asm_json_standard_json_no_optimize/input.json rename to test/cmdlineTests/standard_import_asm_json_optimize/input.json index d2ba25938f7d..c21bbe63f890 100644 --- a/test/cmdlineTests/import_asm_json_standard_json_no_optimize/input.json +++ b/test/cmdlineTests/standard_import_asm_json_optimize/input.json @@ -28,6 +28,7 @@ } }, "settings": { + "experimental": true, "outputSelection": { "*": { "": ["evm.assembly"] diff --git a/test/cmdlineTests/import_asm_json_standard_json_no_optimize/output.json b/test/cmdlineTests/standard_import_asm_json_optimize/output.json similarity index 100% rename from test/cmdlineTests/import_asm_json_standard_json_no_optimize/output.json rename to test/cmdlineTests/standard_import_asm_json_optimize/output.json diff --git a/test/cmdlineTests/standard_import_ast/input.json b/test/cmdlineTests/standard_import_ast/input.json index 5ae7a5297d29..b33dcb57e326 100644 --- a/test/cmdlineTests/standard_import_ast/input.json +++ b/test/cmdlineTests/standard_import_ast/input.json @@ -83,6 +83,7 @@ } }, "settings": { + "experimental": true, "outputSelection": { "*": { "": [ diff --git a/test/cmdlineTests/standard_import_ast_no_experimental/input.json b/test/cmdlineTests/standard_import_ast_no_experimental/input.json new file mode 100644 index 000000000000..8ddd5ef8befa --- /dev/null +++ b/test/cmdlineTests/standard_import_ast_no_experimental/input.json @@ -0,0 +1,8 @@ +{ + "language": "SolidityAST", + "sources": { + "A.sol": { + "content": "contract A { constructor() { uint x = 2; { uint y = 3; } } }" + } + } +} diff --git a/test/cmdlineTests/standard_import_ast_no_experimental/output.json b/test/cmdlineTests/standard_import_ast_no_experimental/output.json new file mode 100644 index 000000000000..d9e6d8cac0f2 --- /dev/null +++ b/test/cmdlineTests/standard_import_ast_no_experimental/output.json @@ -0,0 +1,11 @@ +{ + "errors": [ + { + "component": "general", + "formattedMessage": "'SolidityAST' and 'EVMAssembly' inputs are experimental and can only be used with the 'settings.experimental' option enabled.", + "message": "'SolidityAST' and 'EVMAssembly' inputs are experimental and can only be used with the 'settings.experimental' option enabled.", + "severity": "error", + "type": "FatalError" + } + ] +} diff --git a/test/cmdlineTests/standard_import_ast_select_bytecode/input.json b/test/cmdlineTests/standard_import_ast_select_bytecode/input.json index 6458cb7e151e..2bddcea9eca0 100644 --- a/test/cmdlineTests/standard_import_ast_select_bytecode/input.json +++ b/test/cmdlineTests/standard_import_ast_select_bytecode/input.json @@ -38,6 +38,7 @@ } }, "settings": { + "experimental": true, "outputSelection": { "*": { "*": [ diff --git a/test/cmdlineTests/standard_import_with_comments/input.json b/test/cmdlineTests/standard_import_with_comments/input.json index 4ed88177cf1f..ef43cc0e1145 100644 --- a/test/cmdlineTests/standard_import_with_comments/input.json +++ b/test/cmdlineTests/standard_import_with_comments/input.json @@ -84,6 +84,7 @@ } }, "settings": { + "experimental": true, "outputSelection": { "*": { "": [ diff --git a/test/cmdlineTests/standard_import_with_comments_simple/input.json b/test/cmdlineTests/standard_import_with_comments_simple/input.json index 21faca8c624e..3ff3afc65fff 100644 --- a/test/cmdlineTests/standard_import_with_comments_simple/input.json +++ b/test/cmdlineTests/standard_import_with_comments_simple/input.json @@ -76,6 +76,7 @@ } }, "settings": { + "experimental": true, "outputSelection": { "*": { "": ["ast"] diff --git a/test/cmdlineTests/standard_irOptimized_ast_requested/input.json b/test/cmdlineTests/standard_irOptimized_ast_requested/input.json index 23f17f4ae40d..128724c849fa 100644 --- a/test/cmdlineTests/standard_irOptimized_ast_requested/input.json +++ b/test/cmdlineTests/standard_irOptimized_ast_requested/input.json @@ -4,6 +4,7 @@ "C": {"urls": ["in.sol"]} }, "settings": { + "experimental": true, "outputSelection": {"*": {"*": ["irOptimizedAst"]}} } } diff --git a/test/cmdlineTests/standard_ir_ast_requested/input.json b/test/cmdlineTests/standard_ir_ast_requested/input.json index 07cfc13edee7..829099045319 100644 --- a/test/cmdlineTests/standard_ir_ast_requested/input.json +++ b/test/cmdlineTests/standard_ir_ast_requested/input.json @@ -4,6 +4,7 @@ "C": {"urls": ["in.sol"]} }, "settings": { + "experimental": true, "outputSelection": {"*": {"*": ["irAst"]}} } } diff --git a/test/cmdlineTests/standard_metadata_experimental/args b/test/cmdlineTests/standard_metadata_experimental/args new file mode 100644 index 000000000000..18532c5a6d3f --- /dev/null +++ b/test/cmdlineTests/standard_metadata_experimental/args @@ -0,0 +1 @@ +--allow-paths . diff --git a/test/cmdlineTests/standard_metadata_experimental/in.sol b/test/cmdlineTests/standard_metadata_experimental/in.sol new file mode 100644 index 000000000000..a3a86cc8d317 --- /dev/null +++ b/test/cmdlineTests/standard_metadata_experimental/in.sol @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity *; + +contract C {} diff --git a/test/cmdlineTests/standard_metadata_experimental/input.json b/test/cmdlineTests/standard_metadata_experimental/input.json new file mode 100644 index 000000000000..fddbca92eb2f --- /dev/null +++ b/test/cmdlineTests/standard_metadata_experimental/input.json @@ -0,0 +1,18 @@ +{ + "language": "Solidity", + "sources": { + "C": {"urls": ["in.sol"]} + }, + "settings": { + "experimental": true, + "viaIR": true, + "debug": { + "debugInfo": [ + "ethdebug" + ] + }, + "outputSelection": { + "*": {"*": ["metadata", "ir"]} + } + } +} diff --git a/test/cmdlineTests/standard_metadata_experimental/output.json b/test/cmdlineTests/standard_metadata_experimental/output.json new file mode 100644 index 000000000000..755a59486808 --- /dev/null +++ b/test/cmdlineTests/standard_metadata_experimental/output.json @@ -0,0 +1,77 @@ +{ + "contracts": { + "C": { + "C": { + "ir": "/// ethdebug: enabled +/// @use-src 0:\"C\" +object \"C_2\" { + code { + /// @src 0:56:69 + mstore(64, memoryguard(128)) + if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } + + constructor_C_2() + + let _1 := allocate_unbounded() + codecopy(_1, dataoffset(\"C_2_deployed\"), datasize(\"C_2_deployed\")) + + return(_1, datasize(\"C_2_deployed\")) + + function allocate_unbounded() -> memPtr { + memPtr := mload(64) + } + + function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { + revert(0, 0) + } + + /// @src 0:56:69 + function constructor_C_2() { + + /// @src 0:56:69 + + } + /// @src 0:56:69 + + } + /// @use-src 0:\"C\" + object \"C_2_deployed\" { + code { + /// @src 0:56:69 + mstore(64, memoryguard(128)) + + revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() + + function shift_right_224_unsigned(value) -> newValue { + newValue := + + shr(224, value) + + } + + function allocate_unbounded() -> memPtr { + memPtr := mload(64) + } + + function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { + revert(0, 0) + } + + } + + data \".metadata\" hex\"\" + } + +} + +", + "metadata": "{\"compiler\":{\"version\":\"\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"C\":\"C\"},\"evmVersion\":\"osaka\",\"experimental\":true,\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[],\"viaIR\":true},\"sources\":{\"C\":{\"keccak256\":\"0x5cf617b1707a484e3c4bd59643013dec76ab7d75900b46855214729ae3e0ceb0\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://ac418a02dfadf87234150d3568f33269e3f49460345cb39300e017a6d755eff2\",\"dweb:/ipfs/QmQq3owBu25x2WV46HB1WyKzJpxiAPecU7eMKqtXCF7eeS\"]}},\"version\":1}" + } + } + }, + "sources": { + "C": { + "id": 0 + } + } +} diff --git a/test/cmdlineTests/standard_output_debuginfo_ethdebug_compatible/input.json b/test/cmdlineTests/standard_output_debuginfo_ethdebug_compatible/input.json index 422a54f90d9f..72f16c0ea32f 100644 --- a/test/cmdlineTests/standard_output_debuginfo_ethdebug_compatible/input.json +++ b/test/cmdlineTests/standard_output_debuginfo_ethdebug_compatible/input.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "viaIR": true, "debug": { "debugInfo": [ diff --git a/test/cmdlineTests/standard_output_debuginfo_ethdebug_incompatible/output.json b/test/cmdlineTests/standard_output_debuginfo_ethdebug_incompatible/output.json index 963bcd8d7d68..ab744acc1dd6 100644 --- a/test/cmdlineTests/standard_output_debuginfo_ethdebug_incompatible/output.json +++ b/test/cmdlineTests/standard_output_debuginfo_ethdebug_incompatible/output.json @@ -2,8 +2,8 @@ "errors": [ { "component": "general", - "formattedMessage": "'settings.debug.debugInfo' can only include 'ethdebug', if output 'ir', 'irOptimized', 'evm.bytecode.ethdebug', or 'evm.deployedBytecode.ethdebug' was selected.", - "message": "'settings.debug.debugInfo' can only include 'ethdebug', if output 'ir', 'irOptimized', 'evm.bytecode.ethdebug', or 'evm.deployedBytecode.ethdebug' was selected.", + "formattedMessage": "Ethdebug annotations are experimental and can only be included in 'settings.debug.debugInfo' by enabling the 'settings.experimental' option.", + "message": "Ethdebug annotations are experimental and can only be included in 'settings.debug.debugInfo' by enabling the 'settings.experimental' option.", "severity": "error", "type": "FatalError" } diff --git a/test/cmdlineTests/standard_output_debuginfo_ethdebug_with_interfaces_and_abstracts/input.json b/test/cmdlineTests/standard_output_debuginfo_ethdebug_with_interfaces_and_abstracts/input.json index 06b2d86e96f6..8d85b0ffa1ff 100644 --- a/test/cmdlineTests/standard_output_debuginfo_ethdebug_with_interfaces_and_abstracts/input.json +++ b/test/cmdlineTests/standard_output_debuginfo_ethdebug_with_interfaces_and_abstracts/input.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "viaIR": true, "debug": { "debugInfo": [ diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_ir/input.json b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_ir/input.json index 8ed44ca05de2..2fd0aecf8fc3 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_ir/input.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_ir/input.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "viaIR": true, "optimizer": { "enabled": false diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_iroptimized/input.json b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_iroptimized/input.json index 27c400f9e946..58fb7b42fb87 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_iroptimized/input.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_iroptimized/input.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "viaIR": true, "optimizer": { "enabled": false diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_optimizer_ir/input.json b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_optimizer_ir/input.json index ad74649f5d1d..514012ee7c20 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_optimizer_ir/input.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_optimizer_ir/input.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "viaIR": true, "optimizer": { "enabled": true diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_optimizer_iroptimized/input.json b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_optimizer_iroptimized/input.json index ad74649f5d1d..514012ee7c20 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_optimizer_iroptimized/input.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_optimizer_iroptimized/input.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "viaIR": true, "optimizer": { "enabled": true diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_ir/input.json b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_ir/input.json index 35c8f940e82d..292c86e37542 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_ir/input.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_ir/input.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "viaIR": true, "optimizer": { "enabled": false diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_iroptimized/input.json b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_iroptimized/input.json index e4681967f7db..2e4bb8ec920d 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_iroptimized/input.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_iroptimized/input.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "viaIR": true, "optimizer": { "enabled": false diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_ir/input.json b/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_ir/input.json index 6239a7275e4d..cd6a3d15bb77 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_ir/input.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_ir/input.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "viaIR": true, "optimizer": { "enabled": false diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_iroptimized/input.json b/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_iroptimized/input.json index fdb6c95b813e..d9a5104f46ac 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_iroptimized/input.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_iroptimized/input.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "viaIR": true, "optimizer": { "enabled": false diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_ir/input.json b/test/cmdlineTests/standard_output_selection_ethdebug_ir/input.json index 5bc9d5467345..f601332693cd 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_ir/input.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_ir/input.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "viaIR": true, "outputSelection": { "*": { diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_iroptimized/input.json b/test/cmdlineTests/standard_output_selection_ethdebug_iroptimized/input.json index 8952a241f6e7..fb1e11bbcb0c 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_iroptimized/input.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_iroptimized/input.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "viaIR": true, "outputSelection": { "*": { diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_no_experimental/input.json b/test/cmdlineTests/standard_output_selection_ethdebug_no_experimental/input.json new file mode 100644 index 000000000000..5fca11155a92 --- /dev/null +++ b/test/cmdlineTests/standard_output_selection_ethdebug_no_experimental/input.json @@ -0,0 +1,19 @@ +{ + "language": "Solidity", + "sources": { + "A.sol": { + "content": "contract A { constructor() { uint x = 2; { uint y = 3; } } }" + } + }, + "settings": { + "viaIR": true, + "debug": { + "debugInfo": ["ethdebug"] + }, + "outputSelection": { + "A.sol": { + "A": ["evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"] + } + } + } +} diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_no_experimental/output.json b/test/cmdlineTests/standard_output_selection_ethdebug_no_experimental/output.json new file mode 100644 index 000000000000..ab744acc1dd6 --- /dev/null +++ b/test/cmdlineTests/standard_output_selection_ethdebug_no_experimental/output.json @@ -0,0 +1,11 @@ +{ + "errors": [ + { + "component": "general", + "formattedMessage": "Ethdebug annotations are experimental and can only be included in 'settings.debug.debugInfo' by enabling the 'settings.experimental' option.", + "message": "Ethdebug annotations are experimental and can only be included in 'settings.debug.debugInfo' by enabling the 'settings.experimental' option.", + "severity": "error", + "type": "FatalError" + } + ] +} diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_optimize_ir/input.json b/test/cmdlineTests/standard_output_selection_ethdebug_optimize_ir/input.json index a684e0dc073b..e1084799b98f 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_optimize_ir/input.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_optimize_ir/input.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "viaIR": true, "optimizer": { "enabled": true diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_optimize_iroptimized/input.json b/test/cmdlineTests/standard_output_selection_ethdebug_optimize_iroptimized/input.json index 1f09e3a70253..235e3c855fe6 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_optimize_iroptimized/input.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_optimize_iroptimized/input.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "viaIR": true, "optimizer": { "enabled": true diff --git a/test/cmdlineTests/standard_output_selection_ir_ast_no_experimental/input.json b/test/cmdlineTests/standard_output_selection_ir_ast_no_experimental/input.json new file mode 100644 index 000000000000..4b6c7776ef36 --- /dev/null +++ b/test/cmdlineTests/standard_output_selection_ir_ast_no_experimental/input.json @@ -0,0 +1,15 @@ +{ + "language": "Solidity", + "sources": { + "A.sol": { + "content": "contract A { constructor() { uint x = 2; { uint y = 3; } } }" + } + }, + "settings": { + "outputSelection": { + "A.sol": { + "A": ["irAst"] + } + } + } +} diff --git a/test/cmdlineTests/standard_output_selection_ir_ast_no_experimental/output.json b/test/cmdlineTests/standard_output_selection_ir_ast_no_experimental/output.json new file mode 100644 index 000000000000..c85e0af01816 --- /dev/null +++ b/test/cmdlineTests/standard_output_selection_ir_ast_no_experimental/output.json @@ -0,0 +1,11 @@ +{ + "errors": [ + { + "component": "general", + "formattedMessage": "'irAst', 'irOptimizedAst', 'yulCFGJson', and 'ethdebug' outputs are experimental and can only be used with the 'settings.experimental' option enabled.", + "message": "'irAst', 'irOptimizedAst', 'yulCFGJson', and 'ethdebug' outputs are experimental and can only be used with the 'settings.experimental' option enabled.", + "severity": "error", + "type": "FatalError" + } + ] +} diff --git a/test/cmdlineTests/standard_output_selection_yul_cfg_json_no_experimental/input.json b/test/cmdlineTests/standard_output_selection_yul_cfg_json_no_experimental/input.json new file mode 100644 index 000000000000..6944eacb7e9c --- /dev/null +++ b/test/cmdlineTests/standard_output_selection_yul_cfg_json_no_experimental/input.json @@ -0,0 +1,17 @@ +{ + "language": "Yul", + "sources": + { + "A": + { + "content": "{ let x := mload(0) sstore(add(x, 0), 0) }" + } + }, + "settings": { + "optimizer": { + "enabled": true + }, + "viaIR": true, + "outputSelection": {"*": {"*": ["yulCFGJson"]}} + } +} diff --git a/test/cmdlineTests/standard_output_selection_yul_cfg_json_no_experimental/output.json b/test/cmdlineTests/standard_output_selection_yul_cfg_json_no_experimental/output.json new file mode 100644 index 000000000000..c85e0af01816 --- /dev/null +++ b/test/cmdlineTests/standard_output_selection_yul_cfg_json_no_experimental/output.json @@ -0,0 +1,11 @@ +{ + "errors": [ + { + "component": "general", + "formattedMessage": "'irAst', 'irOptimizedAst', 'yulCFGJson', and 'ethdebug' outputs are experimental and can only be used with the 'settings.experimental' option enabled.", + "message": "'irAst', 'irOptimizedAst', 'yulCFGJson', and 'ethdebug' outputs are experimental and can only be used with the 'settings.experimental' option enabled.", + "severity": "error", + "type": "FatalError" + } + ] +} diff --git a/test/cmdlineTests/standard_undeployable_contract_all_outputs/input.json b/test/cmdlineTests/standard_undeployable_contract_all_outputs/input.json index ecb97bef2c3a..7c56ed8517cd 100644 --- a/test/cmdlineTests/standard_undeployable_contract_all_outputs/input.json +++ b/test/cmdlineTests/standard_undeployable_contract_all_outputs/input.json @@ -4,6 +4,7 @@ "C": {"urls": ["in.sol"]} }, "settings": { + "experimental": true, "outputSelection": { "*": { "*": ["*", "ir", "irAst", "irOptimized", "irOptimizedAst"] diff --git a/test/cmdlineTests/standard_undeployable_contract_all_outputs/output.json b/test/cmdlineTests/standard_undeployable_contract_all_outputs/output.json index 9dec9899a7e4..16239faf196f 100644 --- a/test/cmdlineTests/standard_undeployable_contract_all_outputs/output.json +++ b/test/cmdlineTests/standard_undeployable_contract_all_outputs/output.json @@ -35,7 +35,7 @@ "irAst": null, "irOptimized": "", "irOptimizedAst": null, - "metadata": "{\"compiler\":{\"version\":\"\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"C\":\"C\"},\"evmVersion\":\"osaka\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"C\":{\"keccak256\":\"0xa8b7bfe5eff9112e6573d2860721faef28e8920ee251acb458303a05c1ec7df2\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://a2333e25b5034de4f98729e0a737309ba8e0db4371016f312e8f991f6f01613f\",\"dweb:/ipfs/QmVLwS2grVYV6qiDvNmeEYWzb6WDne9Ze47NXERSLPM4fJ\"]}},\"version\":1}", + "metadata": "{\"compiler\":{\"version\":\"\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"C\":\"C\"},\"evmVersion\":\"osaka\",\"experimental\":true,\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"C\":{\"keccak256\":\"0xa8b7bfe5eff9112e6573d2860721faef28e8920ee251acb458303a05c1ec7df2\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://a2333e25b5034de4f98729e0a737309ba8e0db4371016f312e8f991f6f01613f\",\"dweb:/ipfs/QmVLwS2grVYV6qiDvNmeEYWzb6WDne9Ze47NXERSLPM4fJ\"]}},\"version\":1}", "storageLayout": { "storage": [], "types": null @@ -84,7 +84,7 @@ "irAst": null, "irOptimized": "", "irOptimizedAst": null, - "metadata": "{\"compiler\":{\"version\":\"\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"C\":\"I\"},\"evmVersion\":\"osaka\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"C\":{\"keccak256\":\"0xa8b7bfe5eff9112e6573d2860721faef28e8920ee251acb458303a05c1ec7df2\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://a2333e25b5034de4f98729e0a737309ba8e0db4371016f312e8f991f6f01613f\",\"dweb:/ipfs/QmVLwS2grVYV6qiDvNmeEYWzb6WDne9Ze47NXERSLPM4fJ\"]}},\"version\":1}", + "metadata": "{\"compiler\":{\"version\":\"\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"C\":\"I\"},\"evmVersion\":\"osaka\",\"experimental\":true,\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"C\":{\"keccak256\":\"0xa8b7bfe5eff9112e6573d2860721faef28e8920ee251acb458303a05c1ec7df2\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://a2333e25b5034de4f98729e0a737309ba8e0db4371016f312e8f991f6f01613f\",\"dweb:/ipfs/QmVLwS2grVYV6qiDvNmeEYWzb6WDne9Ze47NXERSLPM4fJ\"]}},\"version\":1}", "storageLayout": { "storage": [], "types": null diff --git a/test/cmdlineTests/standard_yul_cfg_json_export/input.json b/test/cmdlineTests/standard_yul_cfg_json_export/input.json index b5353721ee09..24c3126a3d72 100644 --- a/test/cmdlineTests/standard_yul_cfg_json_export/input.json +++ b/test/cmdlineTests/standard_yul_cfg_json_export/input.json @@ -4,6 +4,7 @@ "C": {"urls": ["in.sol"]} }, "settings": { + "experimental": true, "optimizer": { "enabled": true }, diff --git a/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output/input.json b/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output/input.json index e52867fa329d..755d770fe63b 100644 --- a/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output/input.json +++ b/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output/input.json @@ -8,6 +8,7 @@ } }, "settings": { + "experimental": true, "debug": {"debugInfo": ["ethdebug"]}, "outputSelection": { "*": {"*": ["ir", "irOptimized", "evm.bytecode.ethdebug"]} diff --git a/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output_eof/input.json b/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output_eof/input.json index a8c3436c1a0f..b83ec361c14e 100644 --- a/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output_eof/input.json +++ b/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output_eof/input.json @@ -8,6 +8,7 @@ } }, "settings": { + "experimental": true, "eofVersion": 1, "evmVersion": "osaka", "debug": {"debugInfo": ["ethdebug"]}, diff --git a/test/cmdlineTests/standard_yul_debug_info_ethdebug_incompatible_output/input.json b/test/cmdlineTests/standard_yul_debug_info_ethdebug_incompatible_output/input.json index c2c501c96616..e4c9d17e5a87 100644 --- a/test/cmdlineTests/standard_yul_debug_info_ethdebug_incompatible_output/input.json +++ b/test/cmdlineTests/standard_yul_debug_info_ethdebug_incompatible_output/input.json @@ -8,6 +8,7 @@ } }, "settings": { + "experimental": true, "debug": {"debugInfo": ["ethdebug"]}, "outputSelection": { "*": {"*": ["evm.assembly"]} diff --git a/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/input.json b/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/input.json index 16ef6ef33f74..eac38e3db63d 100644 --- a/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/input.json +++ b/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/input.json @@ -8,6 +8,7 @@ } }, "settings": { + "experimental": true, "debug": {"debugInfo": ["ethdebug"]}, "outputSelection": { "*": {"*": ["evm.bytecode.ethdebug"]} diff --git a/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/input.json b/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/input.json index 652620bedd51..89127b977c35 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/input.json +++ b/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/input.json @@ -4,6 +4,7 @@ "C": {"urls": ["in.yul"]} }, "settings": { + "experimental": true, "outputSelection": { "*": {"*": ["evm.bytecode.ethdebug"]} } diff --git a/test/cmdlineTests/standard_yul_ethdebug_bytecode_ir/input.json b/test/cmdlineTests/standard_yul_ethdebug_bytecode_ir/input.json index 67c5fedc7fd0..9d5829df07ea 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_bytecode_ir/input.json +++ b/test/cmdlineTests/standard_yul_ethdebug_bytecode_ir/input.json @@ -4,6 +4,7 @@ "C": {"urls": ["in.yul"]} }, "settings": { + "experimental": true, "outputSelection": { "*": {"*": ["evm.bytecode.ethdebug", "ir"]} } diff --git a/test/cmdlineTests/standard_yul_ethdebug_bytecode_iroptimized/input.json b/test/cmdlineTests/standard_yul_ethdebug_bytecode_iroptimized/input.json index 17949761f0f2..da8378a8b6ae 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_bytecode_iroptimized/input.json +++ b/test/cmdlineTests/standard_yul_ethdebug_bytecode_iroptimized/input.json @@ -4,6 +4,7 @@ "C": {"urls": ["in.yul"]} }, "settings": { + "experimental": true, "outputSelection": { "*": {"*": ["evm.bytecode.ethdebug", "irOptimized"]} } diff --git a/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode/input.json b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode/input.json index 5c5e9c5f76e1..fcfcaf3bd9ee 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode/input.json +++ b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode/input.json @@ -4,6 +4,7 @@ "C": {"urls": ["in.yul"]} }, "settings": { + "experimental": true, "outputSelection": { "*": {"*": ["evm.deployedBytecode.ethdebug"]} } diff --git a/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/input.json b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/input.json index 655def5c1abf..2bedd407b3e5 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/input.json +++ b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/input.json @@ -4,6 +4,7 @@ "C": {"urls": ["in.yul"]} }, "settings": { + "experimental": true, "outputSelection": { "*": {"*": ["evm.deployedBytecode.ethdebug", "evm.bytecode.ethdebug"]} } diff --git a/test/cmdlineTests/standard_yul_ethdebug_eof/input.json b/test/cmdlineTests/standard_yul_ethdebug_eof/input.json index 4e33c42670a6..3455e61d7c9e 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_eof/input.json +++ b/test/cmdlineTests/standard_yul_ethdebug_eof/input.json @@ -4,6 +4,7 @@ "C": {"urls": ["in.yul"]} }, "settings": { + "experimental": true, "eofVersion": 1, "evmVersion": "osaka", "outputSelection": { diff --git a/test/cmdlineTests/standard_yul_ethdebug_ir/input.json b/test/cmdlineTests/standard_yul_ethdebug_ir/input.json index 67c5fedc7fd0..9d5829df07ea 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_ir/input.json +++ b/test/cmdlineTests/standard_yul_ethdebug_ir/input.json @@ -4,6 +4,7 @@ "C": {"urls": ["in.yul"]} }, "settings": { + "experimental": true, "outputSelection": { "*": {"*": ["evm.bytecode.ethdebug", "ir"]} } diff --git a/test/cmdlineTests/standard_yul_ethdebug_iroptimize/input.json b/test/cmdlineTests/standard_yul_ethdebug_iroptimize/input.json index b08c9dcd7286..2d3610908ac3 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_iroptimize/input.json +++ b/test/cmdlineTests/standard_yul_ethdebug_iroptimize/input.json @@ -4,6 +4,7 @@ "C": {"urls": ["in.yul"]} }, "settings": { + "experimental": true, "outputSelection": { "*": {"*": ["evm.bytecode.ethdebug", "irOptimize"]} } diff --git a/test/cmdlineTests/standard_yul_ethdebug_no_experimental/input.json b/test/cmdlineTests/standard_yul_ethdebug_no_experimental/input.json new file mode 100644 index 000000000000..9754b3d060f1 --- /dev/null +++ b/test/cmdlineTests/standard_yul_ethdebug_no_experimental/input.json @@ -0,0 +1,23 @@ +{ + "language": "Yul", + "sources": + { + "A": + { + "content": "{ let x := mload(0) sstore(add(x, 0), 0) }" + } + }, + "settings": + { + "viaIR": true, + "debug": { + "debugInfo": [ + "ethdebug" + ] + }, + "outputSelection": + { + "*": { "*": ["evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"], "": [ "*" ] } + } + } +} diff --git a/test/cmdlineTests/standard_yul_ethdebug_no_experimental/output.json b/test/cmdlineTests/standard_yul_ethdebug_no_experimental/output.json new file mode 100644 index 000000000000..ab744acc1dd6 --- /dev/null +++ b/test/cmdlineTests/standard_yul_ethdebug_no_experimental/output.json @@ -0,0 +1,11 @@ +{ + "errors": [ + { + "component": "general", + "formattedMessage": "Ethdebug annotations are experimental and can only be included in 'settings.debug.debugInfo' by enabling the 'settings.experimental' option.", + "message": "Ethdebug annotations are experimental and can only be included in 'settings.debug.debugInfo' by enabling the 'settings.experimental' option.", + "severity": "error", + "type": "FatalError" + } + ] +} diff --git a/test/cmdlineTests/standard_yul_ethdebug_optimize_ir/input.json b/test/cmdlineTests/standard_yul_ethdebug_optimize_ir/input.json index d7aec1f0889c..8074135b4f3b 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_optimize_ir/input.json +++ b/test/cmdlineTests/standard_yul_ethdebug_optimize_ir/input.json @@ -4,6 +4,7 @@ "C": {"urls": ["in.yul"]} }, "settings": { + "experimental": true, "optimizer": { "enabled": true }, diff --git a/test/cmdlineTests/standard_yul_ethdebug_optimize_iroptimized/input.json b/test/cmdlineTests/standard_yul_ethdebug_optimize_iroptimized/input.json index eeabdbcb9845..417a42a31177 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_optimize_iroptimized/input.json +++ b/test/cmdlineTests/standard_yul_ethdebug_optimize_iroptimized/input.json @@ -4,6 +4,7 @@ "C": {"urls": ["in.yul"]} }, "settings": { + "experimental": true, "optimizer": { "enabled": true }, diff --git a/test/cmdlineTests/standard_yul_ir_ast_no_experimental/input.json b/test/cmdlineTests/standard_yul_ir_ast_no_experimental/input.json new file mode 100644 index 000000000000..ea91a74ebbac --- /dev/null +++ b/test/cmdlineTests/standard_yul_ir_ast_no_experimental/input.json @@ -0,0 +1,12 @@ +{ + "language": "Yul", + "sources": { + "A": + { + "content": "{ let x := mload(0) sstore(add(x, 0), 0) }" + } + }, + "settings": { + "outputSelection": {"*": {"*": ["irAst"]}} + } +} diff --git a/test/cmdlineTests/standard_yul_ir_ast_no_experimental/output.json b/test/cmdlineTests/standard_yul_ir_ast_no_experimental/output.json new file mode 100644 index 000000000000..c85e0af01816 --- /dev/null +++ b/test/cmdlineTests/standard_yul_ir_ast_no_experimental/output.json @@ -0,0 +1,11 @@ +{ + "errors": [ + { + "component": "general", + "formattedMessage": "'irAst', 'irOptimizedAst', 'yulCFGJson', and 'ethdebug' outputs are experimental and can only be used with the 'settings.experimental' option enabled.", + "message": "'irAst', 'irOptimizedAst', 'yulCFGJson', and 'ethdebug' outputs are experimental and can only be used with the 'settings.experimental' option enabled.", + "severity": "error", + "type": "FatalError" + } + ] +} diff --git a/test/cmdlineTests/strict_asm_eof_container_osaka/args b/test/cmdlineTests/strict_asm_eof_container_osaka/args index 60abde356339..1a99e4be6832 100644 --- a/test/cmdlineTests/strict_asm_eof_container_osaka/args +++ b/test/cmdlineTests/strict_asm_eof_container_osaka/args @@ -1 +1 @@ - --strict-assembly --experimental-eof-version 1 --evm-version osaka --asm --ir-optimized --bin --debug-info none +--experimental --strict-assembly --experimental-eof-version 1 --evm-version osaka --asm --ir-optimized --bin --debug-info none diff --git a/test/cmdlineTests/strict_asm_eof_dataloadn_osaka/args b/test/cmdlineTests/strict_asm_eof_dataloadn_osaka/args index 60abde356339..1a99e4be6832 100644 --- a/test/cmdlineTests/strict_asm_eof_dataloadn_osaka/args +++ b/test/cmdlineTests/strict_asm_eof_dataloadn_osaka/args @@ -1 +1 @@ - --strict-assembly --experimental-eof-version 1 --evm-version osaka --asm --ir-optimized --bin --debug-info none +--experimental --strict-assembly --experimental-eof-version 1 --evm-version osaka --asm --ir-optimized --bin --debug-info none diff --git a/test/cmdlineTests/strict_asm_eof_unavailable_before_osaka/args b/test/cmdlineTests/strict_asm_eof_unavailable_before_osaka/args index 7ec243fdeb21..c7b8a5a6ac2a 100644 --- a/test/cmdlineTests/strict_asm_eof_unavailable_before_osaka/args +++ b/test/cmdlineTests/strict_asm_eof_unavailable_before_osaka/args @@ -1 +1 @@ ---strict-assembly --experimental-eof-version 1 --evm-version cancun +--experimental --strict-assembly --experimental-eof-version 1 --evm-version cancun diff --git a/test/cmdlineTests/strict_asm_yul_cfg_json_export/args b/test/cmdlineTests/strict_asm_yul_cfg_json_export/args index 1147466b54ef..ecd27ca32a81 100644 --- a/test/cmdlineTests/strict_asm_yul_cfg_json_export/args +++ b/test/cmdlineTests/strict_asm_yul_cfg_json_export/args @@ -1 +1 @@ ---strict-assembly --optimize --yul-cfg-json --pretty-json --json-indent 4 +--experimental --strict-assembly --optimize --yul-cfg-json --pretty-json --json-indent 4 diff --git a/test/cmdlineTests/undeployable_contract_empty_outputs/args b/test/cmdlineTests/undeployable_contract_empty_outputs/args index 74c8e867fc91..17068d35dda4 100644 --- a/test/cmdlineTests/undeployable_contract_empty_outputs/args +++ b/test/cmdlineTests/undeployable_contract_empty_outputs/args @@ -1 +1 @@ ---bin --bin-runtime --opcodes --asm --ir --ir-ast-json --ir-optimized --ir-optimized-ast-json --gas --asm-json --abi --hashes --optimize --pretty-json --json-indent 4 +--experimental --bin --bin-runtime --opcodes --asm --ir --ir-ast-json --ir-optimized --ir-optimized-ast-json --gas --asm-json --abi --hashes --optimize --pretty-json --json-indent 4 diff --git a/test/cmdlineTests/yul_cfg_json_export/args b/test/cmdlineTests/yul_cfg_json_export/args index 4af41df671fb..b03ca0ef51f0 100644 --- a/test/cmdlineTests/yul_cfg_json_export/args +++ b/test/cmdlineTests/yul_cfg_json_export/args @@ -1 +1 @@ ---via-ir --optimize --yul-cfg-json --pretty-json --json-indent 4 +--experimental --via-ir --optimize --yul-cfg-json --pretty-json --json-indent 4 diff --git a/test/ethdebugSchemaTests/input_file.json b/test/ethdebugSchemaTests/input_file.json index 7daf7afd6852..31c06ba8bfe7 100644 --- a/test/ethdebugSchemaTests/input_file.json +++ b/test/ethdebugSchemaTests/input_file.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "viaIR": true, "debug": { "debugInfo": [ diff --git a/test/ethdebugSchemaTests/input_file_eof.json b/test/ethdebugSchemaTests/input_file_eof.json index 0462065327f8..df0c734c1035 100644 --- a/test/ethdebugSchemaTests/input_file_eof.json +++ b/test/ethdebugSchemaTests/input_file_eof.json @@ -9,6 +9,7 @@ } }, "settings": { + "experimental": true, "eofVersion": 1, "evmVersion": "osaka", "viaIR": true, diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp index bf9c6b16afb9..107865054194 100644 --- a/test/libsolidity/Assembly.cpp +++ b/test/libsolidity/Assembly.cpp @@ -66,7 +66,7 @@ evmasm::AssemblyItems compileContract(std::shared_ptr _sourceCode) BOOST_CHECK(!!sourceUnit); Scoper::assignScopes(*sourceUnit); - BOOST_REQUIRE(SyntaxChecker(errorReporter, false).checkSyntax(*sourceUnit)); + BOOST_REQUIRE(SyntaxChecker(errorReporter, false /* _useYulOptimizer */, false /* _experimental */).checkSyntax(*sourceUnit)); GlobalContext globalContext(solidity::test::CommonOptions::get().evmVersion()); NameAndTypeResolver resolver(globalContext, solidity::test::CommonOptions::get().evmVersion(), errorReporter, false); DeclarationTypeChecker declarationTypeChecker(errorReporter, solidity::test::CommonOptions::get().evmVersion()); diff --git a/test/libsolidity/FunctionDependencyGraphTest.cpp b/test/libsolidity/FunctionDependencyGraphTest.cpp index c7992d2a2c36..ba03d6f11bc7 100644 --- a/test/libsolidity/FunctionDependencyGraphTest.cpp +++ b/test/libsolidity/FunctionDependencyGraphTest.cpp @@ -42,6 +42,8 @@ TestCase::TestResult FunctionDependencyGraphTest::run(std::ostream& _stream, std compiler().setSources(StringMap{{"", m_source}}); compiler().setViaIR(true); compiler().setOptimiserSettings(OptimiserSettings::none()); + // Experimental on by default as function dependency analysis is a part of Generic Solidity implementation + compiler().setExperimental(true); if (!compiler().compile(CompilerStack::AnalysisSuccessful)) { printPrefixed(_stream, formatErrors(filteredErrors(), _formatted), _linePrefix); diff --git a/test/libsolidity/FunctionDependencyGraphTest.h b/test/libsolidity/FunctionDependencyGraphTest.h index 83f3eb0ab394..4b6b78a97088 100644 --- a/test/libsolidity/FunctionDependencyGraphTest.h +++ b/test/libsolidity/FunctionDependencyGraphTest.h @@ -24,8 +24,6 @@ #include #include -#include -#include namespace solidity::frontend::test { diff --git a/test/libsolidity/Metadata.cpp b/test/libsolidity/Metadata.cpp index 3b7d101d5948..683522693c3c 100644 --- a/test/libsolidity/Metadata.cpp +++ b/test/libsolidity/Metadata.cpp @@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE(metadata_stamp) } if (metadataFormat == CompilerStack::MetadataFormat::NoMetadata) - BOOST_CHECK(cborMetadata.count("solc") == 0); + BOOST_CHECK(cborMetadata.empty()); else { BOOST_CHECK(cborMetadata.count("solc") == 1); @@ -146,6 +146,7 @@ BOOST_AUTO_TEST_CASE(metadata_stamp) BOOST_CHECK(cborMetadata.at("solc") == util::toHex(VersionCompactBytes)); else BOOST_CHECK(cborMetadata.at("solc") == VersionStringStrict); + BOOST_CHECK(!cborMetadata.contains("experimental")); } } } @@ -177,6 +178,7 @@ BOOST_AUTO_TEST_CASE(metadata_stamp_experimental) compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize); compilerStack.setMetadataHash(metadataHash); + compilerStack.setExperimental(true); // Experimental pragma requires it BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); bytes const& bytecode = compilerStack.runtimeObject("test").bytecode; std::string const& metadata = compilerStack.metadata("test"); @@ -211,7 +213,7 @@ BOOST_AUTO_TEST_CASE(metadata_stamp_experimental) } if (metadataFormat == CompilerStack::MetadataFormat::NoMetadata) - BOOST_CHECK(cborMetadata.count("solc") == 0); + BOOST_CHECK(cborMetadata.empty()); else { BOOST_CHECK(cborMetadata.count("solc") == 1); @@ -219,7 +221,7 @@ BOOST_AUTO_TEST_CASE(metadata_stamp_experimental) BOOST_CHECK(cborMetadata.at("solc") == util::toHex(VersionCompactBytes)); else BOOST_CHECK(cborMetadata.at("solc") == VersionStringStrict); - BOOST_CHECK(cborMetadata.count("experimental") == 1); + BOOST_CHECK(cborMetadata.contains("experimental")); BOOST_CHECK(cborMetadata.at("experimental") == "true"); } } diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index 890a51596af8..296467ae2006 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -112,6 +112,7 @@ SemanticTest::SemanticTest( m_revertStrings = revertStrings.value(); m_allowNonExistingFunctions = m_reader.boolSetting("allowNonExistingFunctions", false); + m_compiler.setExperimental(m_reader.boolSetting("experimental", false)); parseExpectations(m_reader.stream()); soltestAssert(!m_tests.empty(), "No tests specified in " + _filename); diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index b6d40eed029a..103732b98771 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -126,7 +126,7 @@ bytes compileFirstExpression( ErrorReporter errorReporter(errors); GlobalContext globalContext(solidity::test::CommonOptions::get().evmVersion()); Scoper::assignScopes(*sourceUnit); - BOOST_REQUIRE(SyntaxChecker(errorReporter, false).checkSyntax(*sourceUnit)); + BOOST_REQUIRE(SyntaxChecker(errorReporter, false /* _useYulOptimizer */, false /* _experimental */).checkSyntax(*sourceUnit)); NameAndTypeResolver resolver(globalContext, solidity::test::CommonOptions::get().evmVersion(), errorReporter, false); resolver.registerDeclarations(*sourceUnit); BOOST_REQUIRE_MESSAGE(resolver.resolveNamesAndTypes(*sourceUnit), "Resolving names failed"); diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index 7be21863abac..43b68223bea7 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -297,6 +297,13 @@ Json generateStandardJson(bool _viaIr, Json const& _debugInfoSelection, Json con return result; } +Json generateExperimentalStandardJson(bool _viaIR, Json const& _debugInfoSelection, Json const& _outputSelection, Code const& _code = SolidityCode(), bool _advancedOutputSelection = false) +{ + Json result = generateStandardJson(_viaIR, _debugInfoSelection, _outputSelection, _code, _advancedOutputSelection); + result["settings"]["experimental"] = true; + return result; +} + } // end anonymous namespace BOOST_AUTO_TEST_SUITE(StandardCompiler) @@ -1926,97 +1933,97 @@ BOOST_AUTO_TEST_CASE(ethdebug_debug_info_ethdebug) { static std::vector>>> tests{ { - generateStandardJson(false, Json::array({"ethdebug"}), Json::array({"*"})), + generateExperimentalStandardJson(false, Json::array({"ethdebug"}), Json::array({"*"})), std::nullopt, }, { - generateStandardJson(true, Json::array({"ethdebug"}), Json::array({"*"})), + generateExperimentalStandardJson(true, Json::array({"ethdebug"}), Json::array({"*"})), std::nullopt, }, { - generateStandardJson(false, Json::array({"ethdebug"}), Json::array({"evm.bytecode.ethdebug"})), + generateExperimentalStandardJson(false, Json::array({"ethdebug"}), Json::array({"evm.bytecode.ethdebug"})), std::nullopt, }, { - generateStandardJson(false, Json::array({"ethdebug"}), Json::array({"evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(false, Json::array({"ethdebug"}), Json::array({"evm.deployedBytecode.ethdebug"})), std::nullopt, }, { - generateStandardJson(false, Json::array({"ethdebug"}), Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(false, Json::array({"ethdebug"}), Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), std::nullopt, }, { - generateStandardJson(false, Json::array({"ethdebug"}), Json::array({"irOptimized"})), + generateExperimentalStandardJson(false, Json::array({"ethdebug"}), Json::array({"irOptimized"})), [](const Json& result) { return result.dump().find("/// ethdebug: enabled") != std::string::npos; } }, { - generateStandardJson(false, Json::array({"ethdebug"}), Json::array({"irOptimized"})), + generateExperimentalStandardJson(false, Json::array({"ethdebug"}), Json::array({"irOptimized"})), [](const Json& result) { return result.dump().find("/// ethdebug: enabled") != std::string::npos; } }, { - generateStandardJson(true, {}, Json::array({"irOptimized", "evm.bytecode.ethdebug"})), + generateExperimentalStandardJson(true, {}, Json::array({"irOptimized", "evm.bytecode.ethdebug"})), [](const Json& result) { return result.dump().find("/// ethdebug: enabled") != std::string::npos; } }, { - generateStandardJson(true, {}, Json::array({"irOptimized", "evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(true, {}, Json::array({"irOptimized", "evm.deployedBytecode.ethdebug"})), [](const Json& result) { return result.dump().find("/// ethdebug: enabled") != std::string::npos; } }, { - generateStandardJson(true, {}, Json::array({"irOptimized", "evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(true, {}, Json::array({"irOptimized", "evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), [](const Json& result) { return result.dump().find("/// ethdebug: enabled") != std::string::npos; } }, { - generateStandardJson(true, {}, Json::array({"irOptimized", "evm.bytecode.ethdebug"})), + generateExperimentalStandardJson(true, {}, Json::array({"irOptimized", "evm.bytecode.ethdebug"})), [](const Json& result) { return result.dump().find("/// ethdebug: enabled") != std::string::npos; } }, { - generateStandardJson(true, {}, Json::array({"irOptimized", "evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(true, {}, Json::array({"irOptimized", "evm.deployedBytecode.ethdebug"})), [](const Json& result) { return result.dump().find("/// ethdebug: enabled") != std::string::npos; } }, { - generateStandardJson(true, {}, Json::array({"irOptimized", "evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(true, {}, Json::array({"irOptimized", "evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), [](const Json& result) { return result.dump().find("/// ethdebug: enabled") != std::string::npos; } }, { - generateStandardJson(true, Json::array({"ethdebug"}), Json::array({"irOptimized"}), YulCode()), + generateExperimentalStandardJson(true, Json::array({"ethdebug"}), Json::array({"irOptimized"}), YulCode()), [](const Json& result) { return result.dump().find("/// ethdebug: enabled") != std::string::npos; } }, { - generateStandardJson(true, Json::array({"ethdebug"}), Json::array({"irOptimized"}), YulCode()), + generateExperimentalStandardJson(true, Json::array({"ethdebug"}), Json::array({"irOptimized"}), YulCode()), {} }, { - generateStandardJson(true, Json::array({"ethdebugs"}), Json::array({"irOptimized"}), YulCode()), {} + generateExperimentalStandardJson(true, Json::array({"ethdebugs"}), Json::array({"irOptimized"}), YulCode()), {} }, { - generateStandardJson( + generateExperimentalStandardJson( true, Json::array({"ethdebug"}), { {"fileA", {{"contractA", Json::array({"evm.deployedBytecode.bin"})}}}, {"fileB", {{"contractB", Json::array({"evm.bytecode.bin"})}}} @@ -2029,11 +2036,11 @@ BOOST_AUTO_TEST_CASE(ethdebug_debug_info_ethdebug) std::nullopt, }, { - generateStandardJson(true, Json::array({"ethdebug"}), Json::array({"*"}), EvmAssemblyCode()), + generateExperimentalStandardJson(true, Json::array({"ethdebug"}), Json::array({"*"}), EvmAssemblyCode()), std::nullopt, }, { - generateStandardJson(true, Json::array({"ethdebug"}), Json::array({"*"}), SolidityAstCode()), + generateExperimentalStandardJson(true, Json::array({"ethdebug"}), Json::array({"*"}), SolidityAstCode()), std::nullopt, }, }; @@ -2050,57 +2057,57 @@ BOOST_AUTO_TEST_CASE(ethdebug_ethdebug_output) { static std::vector>>> tests{ { - generateStandardJson(false, Json::array({"ethdebug"}), Json::array({"evm.bytecode.ethdebug"})), + generateExperimentalStandardJson(false, Json::array({"ethdebug"}), Json::array({"evm.bytecode.ethdebug"})), std::nullopt }, { - generateStandardJson(false, {}, Json::array({"evm.bytecode.ethdebug"})), + generateExperimentalStandardJson(false, {}, Json::array({"evm.bytecode.ethdebug"})), std::nullopt }, { - generateStandardJson(false, Json::array({"ethdebug"}), Json::array({"evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(false, Json::array({"ethdebug"}), Json::array({"evm.deployedBytecode.ethdebug"})), std::nullopt }, { - generateStandardJson(false, {}, Json::array({"evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(false, {}, Json::array({"evm.deployedBytecode.ethdebug"})), std::nullopt }, { - generateStandardJson(false, Json::array({"ethdebug"}), Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(false, Json::array({"ethdebug"}), Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), std::nullopt }, { - generateStandardJson(false, {}, Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(false, {}, Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), std::nullopt }, { - generateStandardJson(true, Json::array({"location"}), Json::array({"evm.bytecode.ethdebug"})), + generateExperimentalStandardJson(true, Json::array({"location"}), Json::array({"evm.bytecode.ethdebug"})), std::nullopt }, { - generateStandardJson(true, Json::array({"location"}), Json::array({"evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(true, Json::array({"location"}), Json::array({"evm.deployedBytecode.ethdebug"})), std::nullopt }, { - generateStandardJson(true, Json::array({"location"}), Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(true, Json::array({"location"}), Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), std::nullopt }, { - generateStandardJson(true, Json::array({"ethdebug"}), Json::array({"evm.bytecode.ethdebug"})), + generateExperimentalStandardJson(true, Json::array({"ethdebug"}), Json::array({"evm.bytecode.ethdebug"})), [](const Json& result) { return result.contains("ethdebug") && result["contracts"]["fileA"]["C"]["evm"]["bytecode"].contains("ethdebug"); } }, { - generateStandardJson(true, Json::array({"ethdebug"}), Json::array({"evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(true, Json::array({"ethdebug"}), Json::array({"evm.deployedBytecode.ethdebug"})), [](const Json& result) { return result.contains("ethdebug") && result["contracts"]["fileA"]["C"]["evm"]["deployedBytecode"].contains("ethdebug"); } }, { - generateStandardJson(true, Json::array({"ethdebug"}), Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(true, Json::array({"ethdebug"}), Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), [](const Json& result) { return result.contains("ethdebug") && result["contracts"]["fileA"]["C"]["evm"]["deployedBytecode"].contains("ethdebug") && @@ -2108,21 +2115,21 @@ BOOST_AUTO_TEST_CASE(ethdebug_ethdebug_output) } }, { - generateStandardJson(true, {}, Json::array({"evm.bytecode.ethdebug"})), + generateExperimentalStandardJson(true, {}, Json::array({"evm.bytecode.ethdebug"})), [](const Json& result) { return result.contains("ethdebug") && result["contracts"]["fileA"]["C"]["evm"]["bytecode"].contains("ethdebug"); } }, { - generateStandardJson(true, {}, Json::array({"evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(true, {}, Json::array({"evm.deployedBytecode.ethdebug"})), [](const Json& result) { return result.contains("ethdebug") && result["contracts"]["fileA"]["C"]["evm"]["deployedBytecode"].contains("ethdebug"); } }, { - generateStandardJson(true, {}, Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), + generateExperimentalStandardJson(true, {}, Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug"})), [](const Json& result) { return result.contains("ethdebug") && result["contracts"]["fileA"]["C"]["evm"]["deployedBytecode"].contains("ethdebug") && @@ -2130,29 +2137,29 @@ BOOST_AUTO_TEST_CASE(ethdebug_ethdebug_output) } }, { - generateStandardJson(true, {}, Json::array({"evm.bytecode.ethdebug", "ir"})), + generateExperimentalStandardJson(true, {}, Json::array({"evm.bytecode.ethdebug", "ir"})), [](const Json& result) { return result.dump().find("/// ethdebug: enabled") != std::string::npos && result.contains("ethdebug") && result["contracts"]["fileA"]["C"]["evm"]["bytecode"].contains("ethdebug"); } }, { - generateStandardJson(true, {}, Json::array({"evm.deployedBytecode.ethdebug", "ir"})), + generateExperimentalStandardJson(true, {}, Json::array({"evm.deployedBytecode.ethdebug", "ir"})), [](const Json& result) { return result.dump().find("/// ethdebug: enabled") != std::string::npos && result.contains("ethdebug") && result["contracts"]["fileA"]["C"]["evm"]["deployedBytecode"].contains("ethdebug"); } }, { - generateStandardJson(true, {}, Json::array({"evm.bytecode.ethdebugs"})), + generateExperimentalStandardJson(true, {}, Json::array({"evm.bytecode.ethdebugs"})), std::nullopt }, { - generateStandardJson(true, {}, Json::array({"evm.deployedBytecode.ethdebugs"})), + generateExperimentalStandardJson(true, {}, Json::array({"evm.deployedBytecode.ethdebugs"})), std::nullopt }, { - generateStandardJson(true, {}, Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug", "ir"})), + generateExperimentalStandardJson(true, {}, Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug", "ir"})), [](const Json& result) { return result.dump().find("/// ethdebug: enabled") != std::string::npos && result.contains("ethdebug") && result["contracts"]["fileA"]["C"]["evm"]["deployedBytecode"].contains("ethdebug") && @@ -2160,36 +2167,36 @@ BOOST_AUTO_TEST_CASE(ethdebug_ethdebug_output) } }, { - generateStandardJson(true, {}, Json::array({"evm.bytecode.ethdebug", "ir"}), YulCode()), + generateExperimentalStandardJson(true, {}, Json::array({"evm.bytecode.ethdebug", "ir"}), YulCode()), [](const Json& result) { return result.dump().find("/// ethdebug: enabled") != std::string::npos && result["contracts"]["fileA"]["object"]["evm"]["bytecode"].contains("ethdebug"); } }, { - generateStandardJson(true, {}, Json::array({"evm.deployedBytecode.ethdebug", "ir"}), YulCode()), + generateExperimentalStandardJson(true, {}, Json::array({"evm.deployedBytecode.ethdebug", "ir"}), YulCode()), std::nullopt }, { - generateStandardJson(true, {}, Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug", "ir"}), YulCode()), + generateExperimentalStandardJson(true, {}, Json::array({"evm.bytecode.ethdebug", "evm.deployedBytecode.ethdebug", "ir"}), YulCode()), std::nullopt }, { - generateStandardJson(true, {}, Json::array({"evm.bytecode"})), + generateExperimentalStandardJson(true, {}, Json::array({"evm.bytecode"})), [](const Json& result) { return result.dump().find("ethdebug") == std::string::npos; } }, { - generateStandardJson(true, {}, Json::array({"evm.deployedBytecode"})), + generateExperimentalStandardJson(true, {}, Json::array({"evm.deployedBytecode"})), [](const Json& result) { return result.dump().find("ethdebug") == std::string::npos; } }, { - generateStandardJson( + generateExperimentalStandardJson( true, {}, { {"fileA", {{"contractA", Json::array({"evm.deployedBytecode.ethdebug"})}}}, {"fileB", {{"contractB", Json::array({"evm.bytecode.ethdebug"})}}} @@ -2219,7 +2226,7 @@ BOOST_AUTO_TEST_CASE(ethdebug_ethdebug_output) BOOST_DATA_TEST_CASE(ethdebug_output_instructions_smoketest, boost::unit_test::data::make({"deployedBytecode", "bytecode"}), bytecodeType) { frontend::StandardCompiler compiler; - Json result = compiler.compile(generateStandardJson(true, {}, Json::array({std::string("evm.") + bytecodeType + ".ethdebug"}))); + Json result = compiler.compile(generateExperimentalStandardJson(true, {}, Json::array({std::string("evm.") + bytecodeType + ".ethdebug"}))); BOOST_REQUIRE(result["contracts"]["fileA"]["C"]["evm"][bytecodeType].contains("ethdebug")); bool creation = std::string(bytecodeType) == "bytecode"; Json ethdebugInstructionsToCheck = result["contracts"]["fileA"]["C"]["evm"][bytecodeType]["ethdebug"]; @@ -2259,6 +2266,87 @@ BOOST_DATA_TEST_CASE(ethdebug_output_instructions_smoketest, boost::unit_test::d } } +BOOST_AUTO_TEST_CASE(no_experimental_import_ast_solidity_evmasm) +{ + frontend::StandardCompiler compiler; + { + char const* input = R"( + { + "language": "SolidityAST", + "sources": { + "A": { + "assemblyJson": { + ".code": [ + { "name": "PUSH", "value": "0" } + ] + } + } + } + } + )"; + + Json parsedInput; + BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); + Json result = compiler.compile(parsedInput); + BOOST_CHECK(containsError(result, "FatalError", "'SolidityAST' and 'EVMAssembly' inputs are experimental and can only be used with the 'settings.experimental' option enabled.")); + } +} + +BOOST_AUTO_TEST_CASE(no_experimental_invalid_output_selection) +{ + frontend::StandardCompiler compiler; + char const* input = R"( + { + "language": "Solidity", + "sources": { + "A.sol": { + "content": "contract A { constructor() { uint x = 2; { uint y = 3; } } }" + } + }, + "settings": { + "outputSelection": { + "A.sol": { + "A": ["irOptimizedAst"] + } + } + } + } + )"; + + Json parsedInput; + BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); + Json result = compiler.compile(parsedInput); + BOOST_CHECK( + containsError( + result, + "FatalError", "'irAst', 'irOptimizedAst', 'yulCFGJson', and 'ethdebug' outputs are experimental and can only be used with the 'settings.experimental' option enabled." + ) + ); +} + +BOOST_AUTO_TEST_CASE(experimental_non_boolean) +{ + frontend::StandardCompiler compiler; + char const* input = R"( + { + "language": "Solidity", + "sources": { + "A.sol": { + "content": "contract A { constructor() { uint x = 2; { uint y = 3; } } }" + } + }, + "settings": { + "experimental": 1 + } + } + )"; + + Json parsedInput; + BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); + Json result = compiler.compile(parsedInput); + BOOST_CHECK(containsError(result, "JSONError", "'settings.experimental' must be a Boolean.")); +} + BOOST_AUTO_TEST_SUITE_END() } // end namespaces diff --git a/test/libsolidity/SyntaxTest.cpp b/test/libsolidity/SyntaxTest.cpp index 8944710542a5..23b92bcb1d51 100644 --- a/test/libsolidity/SyntaxTest.cpp +++ b/test/libsolidity/SyntaxTest.cpp @@ -51,13 +51,14 @@ SyntaxTest::SyntaxTest( auto const eofEnabled = solidity::test::CommonOptions::get().eofVersion().has_value(); m_compileViaYul = m_reader.stringSetting("compileViaYul", eofEnabled ? "true" : "false"); - if (!util::contains(compileViaYulAllowedValues, m_compileViaYul)) + if (!compileViaYulAllowedValues.contains(m_compileViaYul)) BOOST_THROW_EXCEPTION(std::runtime_error("Invalid compileViaYul value: " + m_compileViaYul + ".")); if (m_compileViaYul == "false" && eofEnabled) m_shouldRun = false; m_optimiseYul = m_reader.boolSetting("optimize-yul", true); + m_experimental = m_reader.boolSetting("experimental", false); static std::map const pipelineStages = { {"parsing", PipelineStage::Parsing}, @@ -81,6 +82,7 @@ void SyntaxTest::setupCompiler(CompilerStack& _compiler) OptimiserSettings::minimal() ); _compiler.setViaIR(m_compileViaYul == "true"); + _compiler.setExperimental(m_experimental); _compiler.setMetadataFormat(CompilerStack::MetadataFormat::NoMetadata); _compiler.setMetadataHash(CompilerStack::MetadataHash::None); } diff --git a/test/libsolidity/SyntaxTest.h b/test/libsolidity/SyntaxTest.h index 085a32f944ea..946ada94c294 100644 --- a/test/libsolidity/SyntaxTest.h +++ b/test/libsolidity/SyntaxTest.h @@ -53,6 +53,7 @@ class SyntaxTest: public AnalysisFramework, public solidity::test::CommonSyntaxT virtual void filterObtainedErrors(); bool m_optimiseYul{}; + bool m_experimental{}; std::string m_compileViaYul{}; langutil::Error::Severity m_minSeverity{}; PipelineStage m_stopAfter; diff --git a/test/libsolidity/semanticTests/experimental/stub.sol b/test/libsolidity/semanticTests/experimental/stub.sol index d2d0999bfb76..7cc1c3033400 100644 --- a/test/libsolidity/semanticTests/experimental/stub.sol +++ b/test/libsolidity/semanticTests/experimental/stub.sol @@ -89,6 +89,7 @@ contract C { } } // ==== +// experimental: true // EVMVersion: >=constantinople // ==== // compileViaYul: true diff --git a/test/libsolidity/semanticTests/experimental/type_class.sol b/test/libsolidity/semanticTests/experimental/type_class.sol index 7331c0dbd73c..4f101a147476 100644 --- a/test/libsolidity/semanticTests/experimental/type_class.sol +++ b/test/libsolidity/semanticTests/experimental/type_class.sol @@ -61,6 +61,7 @@ contract C { } // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // bytecodeFormat: legacy diff --git a/test/libsolidity/smtCheckerTests/types/struct/struct_constructor_fixed_bytes_from_string_1.sol b/test/libsolidity/smtCheckerTests/types/struct/struct_constructor_fixed_bytes_from_string_1.sol index 30d6da4a468e..aa031795994f 100644 --- a/test/libsolidity/smtCheckerTests/types/struct/struct_constructor_fixed_bytes_from_string_1.sol +++ b/test/libsolidity/smtCheckerTests/types/struct/struct_constructor_fixed_bytes_from_string_1.sol @@ -1,4 +1,3 @@ -pragma experimental SMTChecker; contract C { struct S { int a; @@ -10,6 +9,5 @@ contract C { } } // ---- -// Warning 5523: (0-31): The SMTChecker pragma has been deprecated and will be removed in the future. Please use the "model checker engine" compiler setting to activate the SMTChecker instead. If the pragma is enabled, all engines will be used. -// Warning 6328: (178-207): CHC: Assertion violation happens here. +// Warning 6328: (146-175): CHC: Assertion violation happens here. // Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition.sol b/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition.sol index 74a659cd8b83..f4d53061f127 100644 --- a/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition.sol +++ b/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition.sol @@ -30,6 +30,7 @@ contract C { } } // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // bytecodeFormat: legacy diff --git a/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition_duplicate.sol b/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition_duplicate.sol index 28f6c39fd754..720bb8c2724c 100644 --- a/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition_duplicate.sol +++ b/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition_duplicate.sol @@ -9,6 +9,7 @@ type word2 = __builtin("word"); type fun1(T, U) = __builtin("fun"); type fun2(T, U) = __builtin("fun"); // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition_unknown.sol b/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition_unknown.sol index 90072f19838f..0dc19b7f8470 100644 --- a/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition_unknown.sol +++ b/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition_unknown.sol @@ -2,6 +2,7 @@ pragma experimental solidity; type someUnknownType = __builtin("someUnknownType"); // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/experimental/forall/undeclared_type_variable_in_function.sol b/test/libsolidity/syntaxTests/experimental/forall/undeclared_type_variable_in_function.sol index da1169969143..ef6331740ea4 100644 --- a/test/libsolidity/syntaxTests/experimental/forall/undeclared_type_variable_in_function.sol +++ b/test/libsolidity/syntaxTests/experimental/forall/undeclared_type_variable_in_function.sol @@ -7,6 +7,7 @@ function f(p: P, q: T(Q)) { let s: S; } // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/experimental/forall/undeclared_type_variable_in_quantified_function.sol b/test/libsolidity/syntaxTests/experimental/forall/undeclared_type_variable_in_quantified_function.sol index 91b734569372..5113860bdc8a 100644 --- a/test/libsolidity/syntaxTests/experimental/forall/undeclared_type_variable_in_quantified_function.sol +++ b/test/libsolidity/syntaxTests/experimental/forall/undeclared_type_variable_in_quantified_function.sol @@ -5,6 +5,7 @@ function f(b: B) { let c: C; } // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/experimental/forall/undeclared_type_variable_in_type_class.sol b/test/libsolidity/syntaxTests/experimental/forall/undeclared_type_variable_in_type_class.sol index 8af0cce82699..c78603516580 100644 --- a/test/libsolidity/syntaxTests/experimental/forall/undeclared_type_variable_in_type_class.sol +++ b/test/libsolidity/syntaxTests/experimental/forall/undeclared_type_variable_in_type_class.sol @@ -10,6 +10,7 @@ instantiation T(Y): C { function f(self: T(Z)) {} } // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/experimental/import/experimental_solidity.sol b/test/libsolidity/syntaxTests/experimental/import/experimental_solidity.sol index a84ac0e759ab..011043f66fea 100644 --- a/test/libsolidity/syntaxTests/experimental/import/experimental_solidity.sol +++ b/test/libsolidity/syntaxTests/experimental/import/experimental_solidity.sol @@ -1,5 +1,6 @@ pragma experimental solidity; // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // ---- diff --git a/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_multisource_not_all_enable.sol b/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_multisource_not_all_enable.sol index fe4125e84303..79f226535ee8 100644 --- a/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_multisource_not_all_enable.sol +++ b/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_multisource_not_all_enable.sol @@ -19,6 +19,7 @@ contract D { A a; } // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // ParserError 2141: (B.sol:0-29): File declares "pragma experimental solidity". If you want to enable the experimental mode, all source units must include the pragma. diff --git a/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_out_of_order_1.sol b/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_out_of_order_1.sol index d6741b0d3a99..1ceecba27e4f 100644 --- a/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_out_of_order_1.sol +++ b/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_out_of_order_1.sol @@ -2,6 +2,7 @@ contract A {} pragma experimental solidity; // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // ParserError 8185: (45-45): Experimental pragma "solidity" can only be set at the beginning of the source unit. diff --git a/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_out_of_order_2.sol b/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_out_of_order_2.sol index 940bd3fbb369..6d1ba15e2b50 100644 --- a/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_out_of_order_2.sol +++ b/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_out_of_order_2.sol @@ -10,6 +10,7 @@ struct A uint256 x; } // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // ParserError 8185: (83-89): Experimental pragma "solidity" can only be set at the beginning of the source unit. diff --git a/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_wrong_evm_version.sol b/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_wrong_evm_version.sol index 3e070535b03d..be5a30d528da 100644 --- a/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_wrong_evm_version.sol +++ b/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_wrong_evm_version.sol @@ -3,6 +3,7 @@ pragma experimental solidity; contract C {} // ==== +// experimental: true // EVMVersion: =constantinople // compileViaYul: true // ---- diff --git a/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_2.sol b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_2.sol index bdc66e4ad393..cc3146664cdd 100644 --- a/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_2.sol +++ b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_2.sol @@ -2,6 +2,7 @@ pragma experimental solidity; import std.stub as stub; // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // ---- diff --git a/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_3.sol b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_3.sol index 1bb340536c11..26b9589d0fce 100644 --- a/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_3.sol +++ b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_3.sol @@ -2,6 +2,7 @@ pragma experimental solidity; import { identity } from std.stub; // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // ---- diff --git a/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_4.sol b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_4.sol index 64a67fe6c96d..36df8c7c16aa 100644 --- a/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_4.sol +++ b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_4.sol @@ -2,6 +2,7 @@ pragma experimental solidity; import * as stub from std.stub; // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // ---- diff --git a/test/libsolidity/syntaxTests/experimental/inference/import_and_call_stdlib_function.sol b/test/libsolidity/syntaxTests/experimental/inference/import_and_call_stdlib_function.sol index 72af2133f206..bbb255568d62 100644 --- a/test/libsolidity/syntaxTests/experimental/inference/import_and_call_stdlib_function.sol +++ b/test/libsolidity/syntaxTests/experimental/inference/import_and_call_stdlib_function.sol @@ -11,6 +11,7 @@ contract C } // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // bytecodeFormat: legacy diff --git a/test/libsolidity/syntaxTests/experimental/inference/instantiation_invalid_type_constructor.sol b/test/libsolidity/syntaxTests/experimental/inference/instantiation_invalid_type_constructor.sol index 0245deb1f401..15c40093265b 100644 --- a/test/libsolidity/syntaxTests/experimental/inference/instantiation_invalid_type_constructor.sol +++ b/test/libsolidity/syntaxTests/experimental/inference/instantiation_invalid_type_constructor.sol @@ -6,6 +6,7 @@ function f() {} instantiation f: C {} // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // ---- diff --git a/test/libsolidity/syntaxTests/experimental/inference/instantiation_member_type_does_not_match_declaration.sol b/test/libsolidity/syntaxTests/experimental/inference/instantiation_member_type_does_not_match_declaration.sol index 1c845b8eeece..47d282a1a23f 100644 --- a/test/libsolidity/syntaxTests/experimental/inference/instantiation_member_type_does_not_match_declaration.sol +++ b/test/libsolidity/syntaxTests/experimental/inference/instantiation_member_type_does_not_match_declaration.sol @@ -11,6 +11,7 @@ instantiation T: C { function f(self: U) {} } // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // ---- diff --git a/test/libsolidity/syntaxTests/experimental/inference/instantiation_not_for_class.sol b/test/libsolidity/syntaxTests/experimental/inference/instantiation_not_for_class.sol index c48fff74f94e..89217a56d89d 100644 --- a/test/libsolidity/syntaxTests/experimental/inference/instantiation_not_for_class.sol +++ b/test/libsolidity/syntaxTests/experimental/inference/instantiation_not_for_class.sol @@ -5,6 +5,7 @@ type U; instantiation T: U {} // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // ---- diff --git a/test/libsolidity/syntaxTests/experimental/inference/invalid_type_referenced.sol b/test/libsolidity/syntaxTests/experimental/inference/invalid_type_referenced.sol index ac097bf3927f..98bd7890ce81 100644 --- a/test/libsolidity/syntaxTests/experimental/inference/invalid_type_referenced.sol +++ b/test/libsolidity/syntaxTests/experimental/inference/invalid_type_referenced.sol @@ -7,6 +7,7 @@ class Self: C function g(self: Self, x: f); } // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/experimental/inference/monomorphic_function_call_type_mismatch.sol b/test/libsolidity/syntaxTests/experimental/inference/monomorphic_function_call_type_mismatch.sol index e7af573aeed6..d32b2ba0ed2c 100644 --- a/test/libsolidity/syntaxTests/experimental/inference/monomorphic_function_call_type_mismatch.sol +++ b/test/libsolidity/syntaxTests/experimental/inference/monomorphic_function_call_type_mismatch.sol @@ -9,6 +9,7 @@ function run(a: U, b: T) { f(a, b); } // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/experimental/inference/polymorphic_function_call.sol b/test/libsolidity/syntaxTests/experimental/inference/polymorphic_function_call.sol index c9c7e01109e7..a6c44c0f31ec 100644 --- a/test/libsolidity/syntaxTests/experimental/inference/polymorphic_function_call.sol +++ b/test/libsolidity/syntaxTests/experimental/inference/polymorphic_function_call.sol @@ -11,6 +11,7 @@ function run(a: T, b: U(T), c: U(U(T))) { f(b, b, c); } // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // ---- diff --git a/test/libsolidity/syntaxTests/experimental/inference/polymorphic_function_call_let_polymorphism.sol b/test/libsolidity/syntaxTests/experimental/inference/polymorphic_function_call_let_polymorphism.sol index 1a43d0807ac2..159796a2bef7 100644 --- a/test/libsolidity/syntaxTests/experimental/inference/polymorphic_function_call_let_polymorphism.sol +++ b/test/libsolidity/syntaxTests/experimental/inference/polymorphic_function_call_let_polymorphism.sol @@ -13,6 +13,7 @@ function run(a: T, b: U) { g(b); } // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/experimental/inference/polymorphic_function_call_type_mismatch.sol b/test/libsolidity/syntaxTests/experimental/inference/polymorphic_function_call_type_mismatch.sol index 74f102a88183..433a74c4b9d8 100644 --- a/test/libsolidity/syntaxTests/experimental/inference/polymorphic_function_call_type_mismatch.sol +++ b/test/libsolidity/syntaxTests/experimental/inference/polymorphic_function_call_type_mismatch.sol @@ -10,6 +10,7 @@ function run(a: T(V)) { f(a); } // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/experimental/inference/polymorphic_type.sol b/test/libsolidity/syntaxTests/experimental/inference/polymorphic_type.sol index 85f810a9dc0d..88e0da7de34f 100644 --- a/test/libsolidity/syntaxTests/experimental/inference/polymorphic_type.sol +++ b/test/libsolidity/syntaxTests/experimental/inference/polymorphic_type.sol @@ -13,6 +13,7 @@ function run() { let y: T(V, Y, Z: D); } // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // ---- diff --git a/test/libsolidity/syntaxTests/experimental/inference/polymorphic_type_abs_and_rep.sol b/test/libsolidity/syntaxTests/experimental/inference/polymorphic_type_abs_and_rep.sol index ebebf6dafc3c..b5311bd1b8e9 100644 --- a/test/libsolidity/syntaxTests/experimental/inference/polymorphic_type_abs_and_rep.sol +++ b/test/libsolidity/syntaxTests/experimental/inference/polymorphic_type_abs_and_rep.sol @@ -18,6 +18,7 @@ function fun() { U.abs(t); } // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // ---- diff --git a/test/libsolidity/syntaxTests/experimental/inference/polymorphic_type_instantiation_and_operators.sol b/test/libsolidity/syntaxTests/experimental/inference/polymorphic_type_instantiation_and_operators.sol index c26436e06cca..93323dee03b9 100644 --- a/test/libsolidity/syntaxTests/experimental/inference/polymorphic_type_instantiation_and_operators.sol +++ b/test/libsolidity/syntaxTests/experimental/inference/polymorphic_type_instantiation_and_operators.sol @@ -46,6 +46,7 @@ function fun(a: T(int: P3), b: T(str: P4)) { C.foo(b, b); } // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // ---- diff --git a/test/libsolidity/syntaxTests/experimental/inference/type_variable_multi_use_function_parameter_and_return.sol b/test/libsolidity/syntaxTests/experimental/inference/type_variable_multi_use_function_parameter_and_return.sol index 00cd7b1207df..1fe995332fe6 100644 --- a/test/libsolidity/syntaxTests/experimental/inference/type_variable_multi_use_function_parameter_and_return.sol +++ b/test/libsolidity/syntaxTests/experimental/inference/type_variable_multi_use_function_parameter_and_return.sol @@ -10,6 +10,7 @@ function test(t: T, u: U) { t = f(u); } // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/experimental/inference/type_variable_multi_use_function_parameters.sol b/test/libsolidity/syntaxTests/experimental/inference/type_variable_multi_use_function_parameters.sol index 7122cdd9efce..47ccc6754d03 100644 --- a/test/libsolidity/syntaxTests/experimental/inference/type_variable_multi_use_function_parameters.sol +++ b/test/libsolidity/syntaxTests/experimental/inference/type_variable_multi_use_function_parameters.sol @@ -10,6 +10,7 @@ function test(t: T, u: U) { f(t, u); } // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/experimental/parsing/forall_free_function.sol b/test/libsolidity/syntaxTests/experimental/parsing/forall_free_function.sol index ba22a9fae4b4..2b5236f790e5 100644 --- a/test/libsolidity/syntaxTests/experimental/parsing/forall_free_function.sol +++ b/test/libsolidity/syntaxTests/experimental/parsing/forall_free_function.sol @@ -6,6 +6,7 @@ function f(a: A) {} forall (A, B) function g(a: A, b: B) {} // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // ---- diff --git a/test/libsolidity/syntaxTests/experimental/parsing/forall_free_function_no_type_var.sol b/test/libsolidity/syntaxTests/experimental/parsing/forall_free_function_no_type_var.sol index 66753fdd0f68..a6f5dd61fbae 100644 --- a/test/libsolidity/syntaxTests/experimental/parsing/forall_free_function_no_type_var.sol +++ b/test/libsolidity/syntaxTests/experimental/parsing/forall_free_function_no_type_var.sol @@ -3,6 +3,7 @@ pragma experimental solidity; forall () function f(x: ()) {} // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // ---- diff --git a/test/libsolidity/syntaxTests/experimental/parsing/forall_free_function_with_sorts.sol b/test/libsolidity/syntaxTests/experimental/parsing/forall_free_function_with_sorts.sol index 1ab09fd2bd24..0e69f79b3310 100644 --- a/test/libsolidity/syntaxTests/experimental/parsing/forall_free_function_with_sorts.sol +++ b/test/libsolidity/syntaxTests/experimental/parsing/forall_free_function_with_sorts.sol @@ -9,6 +9,7 @@ function f(a: A: Class1, b: B: Class1) {} forall A: Class1 function g(a: A) {} // ==== +// experimental: true // EVMVersion: >=constantinople // compileViaYul: true // ---- diff --git a/test/libsolidity/syntaxTests/experimental/parsing/forall_type_class.sol b/test/libsolidity/syntaxTests/experimental/parsing/forall_type_class.sol index aa0012eac16f..0dd5b74b5efe 100644 --- a/test/libsolidity/syntaxTests/experimental/parsing/forall_type_class.sol +++ b/test/libsolidity/syntaxTests/experimental/parsing/forall_type_class.sol @@ -3,6 +3,7 @@ pragma experimental solidity; forall (A, B) class Self: C {} // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // ParserError 5709: (45-50): Expected a function definition. diff --git a/test/libsolidity/syntaxTests/experimental/parsing/forall_type_class_instantiation.sol b/test/libsolidity/syntaxTests/experimental/parsing/forall_type_class_instantiation.sol index 31573447a369..5d90e0e32edd 100644 --- a/test/libsolidity/syntaxTests/experimental/parsing/forall_type_class_instantiation.sol +++ b/test/libsolidity/syntaxTests/experimental/parsing/forall_type_class_instantiation.sol @@ -7,6 +7,7 @@ class Self: C {} forall (A, B) instantiation T: C {} // ==== +// experimental: true // EVMVersion: >=constantinople // ---- // ParserError 5709: (72-85): Expected a function definition. diff --git a/test/libsolidity/syntaxTests/pragma/experimental_pragma_duplicate.sol b/test/libsolidity/syntaxTests/pragma/experimental_pragma_duplicate.sol index 042b5464ce96..caebd64479dd 100644 --- a/test/libsolidity/syntaxTests/pragma/experimental_pragma_duplicate.sol +++ b/test/libsolidity/syntaxTests/pragma/experimental_pragma_duplicate.sol @@ -1,5 +1,7 @@ pragma experimental __test; pragma experimental __test; +// ==== +// experimental: true // ---- // Warning 2264: (0-27): Experimental features are turned on. Do not use experimental features on live deployments. // SyntaxError 1231: (28-55): Duplicate experimental feature name. diff --git a/test/libsolidity/syntaxTests/pragma/experimental_pragma_without_experimental_mode.sol b/test/libsolidity/syntaxTests/pragma/experimental_pragma_without_experimental_mode.sol new file mode 100644 index 000000000000..1d5e0595e7ea --- /dev/null +++ b/test/libsolidity/syntaxTests/pragma/experimental_pragma_without_experimental_mode.sol @@ -0,0 +1,7 @@ +pragma experimental __test; +pragma experimental solidity; +// ==== +// EVMVersion: >=constantinople +// ---- +// SyntaxError 2816: (0-27): Experimental pragmas can only be used if experimental mode is enabled. To enable experimental mode, use the --experimental flag. +// SyntaxError 2816: (28-57): Experimental pragmas can only be used if experimental mode is enabled. To enable experimental mode, use the --experimental flag. diff --git a/test/libsolidity/syntaxTests/pragma/experimental_test_warning.sol b/test/libsolidity/syntaxTests/pragma/experimental_test_warning.sol index 31f46fbb8f4c..2706c2f31522 100644 --- a/test/libsolidity/syntaxTests/pragma/experimental_test_warning.sol +++ b/test/libsolidity/syntaxTests/pragma/experimental_test_warning.sol @@ -1,3 +1,5 @@ pragma experimental __test; +// ==== +// experimental: true // ---- // Warning 2264: (0-27): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/lsp.py b/test/lsp.py index 11007ae822ec..d5bff2132f4c 100755 --- a/test/lsp.py +++ b/test/lsp.py @@ -882,7 +882,12 @@ def main(self) -> int: 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, print_pid=self.print_solc_pid) as solc: + with JsonRpcProcess( + self.solc_path, + ["--experimental", "--lsp"], + trace_io=self.trace_io, + print_pid=self.print_solc_pid + ) as solc: test_fn(solc) self.test_counter.passed += 1 except ExpectationFailed: diff --git a/test/solc/CommandLineInterface.cpp b/test/solc/CommandLineInterface.cpp index adfd24b02b26..2141b9e63443 100644 --- a/test/solc/CommandLineInterface.cpp +++ b/test/solc/CommandLineInterface.cpp @@ -1412,14 +1412,6 @@ BOOST_AUTO_TEST_CASE(cli_include_paths_ambiguous_import) BOOST_REQUIRE(!result.success); } -BOOST_AUTO_TEST_CASE(cli_ethdebug_no_ethdebug_in_help) -{ - OptionsReaderAndMessages result = runCLI({"solc", "--help"}); - BOOST_REQUIRE(result.stdoutContent.find("ethdebug") == std::string::npos); - // just in case - BOOST_REQUIRE(result.stderrContent.find("ethdebug") == std::string::npos); -} - BOOST_AUTO_TEST_CASE(cli_ethdebug_incompatible_outputs) { TemporaryDirectory tempDir(TEST_CASE_NAME); @@ -1534,61 +1526,62 @@ BOOST_AUTO_TEST_CASE(cli_ethdebug_debug_info_ethdebug) createFilesWithParentDirs({tempDir.path() / "input.yul"}, "{}"); static std::vector> erroneousCLIFlagCombinations{ { - {"solc", "--debug-info", "ethdebug", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--debug-info", "ethdebug", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--debug-info", "ethdebug", "--ir-optimized", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--debug-info", "ethdebug", "--ir-optimized", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--debug-info", "ethdebug", "--optimize", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--debug-info", "ethdebug", "--optimize", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--debug-info", "ethdebug", "--ethdebug", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--debug-info", "ethdebug", "--ethdebug", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--ethdebug-runtime", "--strict-assembly", tempDir.path().string() + "/input.yul"}, + {"solc", "--experimental", "--ethdebug-runtime", "--strict-assembly", tempDir.path().string() + "/input.yul"}, }, { - {"solc", "--ethdebug", "--ethdebug-runtime", "--strict-assembly", tempDir.path().string() + "/input.yul"}, + {"solc", "--experimental", "--ethdebug", "--ethdebug-runtime", "--strict-assembly", tempDir.path().string() + "/input.yul"}, }, { - {"solc", "--debug-info", "ethdebug", "--ethdebug", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--debug-info", "ethdebug", "--ethdebug", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--debug-info", "ethdebug", "--ethdebug-runtime", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--debug-info", "ethdebug", "--ethdebug-runtime", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--debug-info", "ethdebug", "--ethdebug", "--ethdebug-runtime", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--debug-info", "ethdebug", "--ethdebug", "--ethdebug-runtime", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--debug-info", "location", "--ethdebug", "--via-ir", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--debug-info", "location", "--ethdebug", "--via-ir", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--debug-info", "location", "--ethdebug-runtime", "--via-ir", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--debug-info", "location", "--ethdebug-runtime", "--via-ir", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--debug-info", "location", "--ethdebug", "--ethdebug-runtime", "--via-ir", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--debug-info", "location", "--ethdebug", "--ethdebug-runtime", "--via-ir", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--debug-info", "all", "--ethdebug", "--via-ir", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--debug-info", "all", "--ethdebug", "--via-ir", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--debug-info", "all", "--ethdebug-runtime", "--via-ir", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--debug-info", "all", "--ethdebug-runtime", "--via-ir", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--debug-info", "all", "--ethdebug", "--ethdebug-runtime", "--via-ir", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--debug-info", "all", "--ethdebug", "--ethdebug-runtime", "--via-ir", tempDir.path().string() + "/input.sol"}, }, }; static std::vector> supportedCLIFlagCombinations{ { - {"solc", "--debug-info", "ethdebug", "--ir", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--debug-info", "ethdebug", "--ir", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--debug-info", "ethdebug", "--ethdebug", "--via-ir", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--debug-info", "ethdebug", "--ethdebug", "--via-ir", tempDir.path().string() + "/input.sol"}, }, { { "solc", + "--experimental", "--debug-info", "ethdebug", "--ethdebug-runtime", @@ -1597,14 +1590,15 @@ BOOST_AUTO_TEST_CASE(cli_ethdebug_debug_info_ethdebug) }, }, { - {"solc", "--debug-info", "ethdebug", "--strict-assembly", tempDir.path().string() + "/input.yul"}, + {"solc", "--experimental", "--debug-info", "ethdebug", "--strict-assembly", tempDir.path().string() + "/input.yul"}, }, { - {"solc", "--ethdebug", "--strict-assembly", tempDir.path().string() + "/input.yul"}, + {"solc", "--experimental", "--ethdebug", "--strict-assembly", tempDir.path().string() + "/input.yul"}, }, { { "solc", + "--experimental", "--debug-info", "ethdebug", "--ethdebug", @@ -1633,11 +1627,12 @@ BOOST_AUTO_TEST_CASE(cli_ethdebug_ethdebug_output) createFilesWithParentDirs({tempDir.path() / "input.sol"}, "pragma solidity >=0.0; contract C { function f() public pure {} }"); static std::vector> erroneousCLIFlagCombinations{ { - {"solc", "--ethdebug", "--ethdebug-runtime", "--via-ir", "--ir-optimized", "--optimize", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--ethdebug", "--ethdebug-runtime", "--via-ir", "--ir-optimized", "--optimize", tempDir.path().string() + "/input.sol"}, }, { { "solc", + "--experimental", "--ethdebug-runtime", "--via-ir", "--ir-optimized", @@ -1646,42 +1641,42 @@ BOOST_AUTO_TEST_CASE(cli_ethdebug_ethdebug_output) }, }, { - {"solc", "--ethdebug", "--via-ir", "--ir-optimized", "--optimize", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--ethdebug", "--via-ir", "--ir-optimized", "--optimize", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--ethdebug", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--ethdebug", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--ethdebug", "--ethdebug-runtime", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--ethdebug", "--ethdebug-runtime", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--ethdebug-runtime", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--ethdebug-runtime", tempDir.path().string() + "/input.sol"}, }, }; static std::vector> supportedCLIFlagCombinations{ { - {"solc", "--ethdebug", "--via-ir", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--ethdebug", "--via-ir", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--ethdebug-runtime", "--via-ir", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--ethdebug-runtime", "--via-ir", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--ethdebug", "--ethdebug-runtime", "--via-ir", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--ethdebug", "--ethdebug-runtime", "--via-ir", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--ethdebug", "--via-ir", "--ir", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--ethdebug", "--via-ir", "--ir", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--ethdebug-runtime", "--via-ir", "--ir", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--ethdebug-runtime", "--via-ir", "--ir", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--ethdebug", "--ethdebug-runtime", "--via-ir", "--ir", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--ethdebug", "--ethdebug-runtime", "--via-ir", "--ir", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--ethdebug", "--via-ir", "--ir-optimized", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--ethdebug", "--via-ir", "--ir-optimized", tempDir.path().string() + "/input.sol"}, }, { - {"solc", "--ethdebug-runtime", "--via-ir", "--ir-optimized", tempDir.path().string() + "/input.sol"}, + {"solc", "--experimental", "--ethdebug-runtime", "--via-ir", "--ir-optimized", tempDir.path().string() + "/input.sol"}, }, }; diff --git a/test/solc/CommandLineParser.cpp b/test/solc/CommandLineParser.cpp index 85eeaebe31a8..6d9153381633 100644 --- a/test/solc/CommandLineParser.cpp +++ b/test/solc/CommandLineParser.cpp @@ -110,6 +110,7 @@ BOOST_AUTO_TEST_CASE(cli_mode_options) "/tmp=/usr/lib/", "a:b=c/d", ":contract.sol=", + "--experimental", "--base-path=/home/user/", "--include-path=/usr/lib/include/", "--include-path=/home/user/include", @@ -163,6 +164,7 @@ BOOST_AUTO_TEST_CASE(cli_mode_options) }; CommandLineOptions expectedOptions; + expectedOptions.experimental = true; expectedOptions.input.mode = inputMode; expectedOptions.input.paths = {"contract.sol", "/tmp/projects/token.sol", "/home/user/lib/dex.sol", "file", "input.json"}; expectedOptions.input.remappings = { @@ -249,7 +251,7 @@ BOOST_AUTO_TEST_CASE(no_import_callback) {"solc", "--standard-json", "--no-import-callback", "input.json"}, {"solc", "--assemble", "--no-import-callback", "input.yul"}, {"solc", "--strict-assembly", "--no-import-callback", "input.yul"}, - {"solc", "--import-ast", "--no-import-callback", "ast.json"}, + {"solc", "--experimental", "--import-ast", "--no-import-callback", "ast.json"}, {"solc", "--link", "--no-import-callback", "input.bin"}, }; @@ -482,6 +484,8 @@ BOOST_AUTO_TEST_CASE(optimizer_flags) for (auto const& [optimizerFlags, expectedOptimizerSettings]: settingsMap) { std::vector commandLine = {"solc", inputModeFlag, "file"}; + if (inputMode == InputMode::CompilerWithASTImport) + commandLine.emplace_back("--experimental"); commandLine += optimizerFlags; BOOST_CHECK(parseCommandLine(commandLine).optimiserSettings() == expectedOptimizerSettings); } @@ -630,34 +634,34 @@ BOOST_AUTO_TEST_CASE(invalid_optimizer_sequence_without_optimize) BOOST_AUTO_TEST_CASE(ethdebug) { - CommandLineOptions commandLineOptions = parseCommandLine({"solc", "contract.sol", "--debug-info", "ethdebug", "--ethdebug", "--via-ir"}); + CommandLineOptions commandLineOptions = parseCommandLine({"solc", "contract.sol", "--experimental", "--debug-info", "ethdebug", "--ethdebug", "--via-ir"}); BOOST_CHECK_EQUAL(commandLineOptions.compiler.outputs.ethdebug, true); BOOST_CHECK_EQUAL(commandLineOptions.compiler.outputs.ethdebugRuntime, false); BOOST_CHECK_EQUAL(commandLineOptions.output.debugInfoSelection.has_value(), true); BOOST_CHECK_EQUAL(commandLineOptions.output.debugInfoSelection->ethdebug, true); - commandLineOptions = parseCommandLine({"solc", "contract.sol", "--debug-info", "ethdebug", "--ethdebug-runtime", "--via-ir"}); + commandLineOptions = parseCommandLine({"solc", "contract.sol", "--experimental", "--debug-info", "ethdebug", "--ethdebug-runtime", "--via-ir"}); BOOST_CHECK_EQUAL(commandLineOptions.compiler.outputs.ethdebug, false); BOOST_CHECK_EQUAL(commandLineOptions.compiler.outputs.ethdebugRuntime, true); BOOST_CHECK_EQUAL(commandLineOptions.output.debugInfoSelection.has_value(), true); BOOST_CHECK_EQUAL(commandLineOptions.output.debugInfoSelection->ethdebug, true); - commandLineOptions = parseCommandLine({"solc", "contract.sol", "--ethdebug", "--via-ir"}); + commandLineOptions = parseCommandLine({"solc", "contract.sol", "--experimental", "--ethdebug", "--via-ir"}); BOOST_CHECK_EQUAL(commandLineOptions.compiler.outputs.ethdebug, true); BOOST_CHECK_EQUAL(commandLineOptions.compiler.outputs.ethdebugRuntime, false); // debug-info "ethdebug" selected implicitly, // if compiled with --ethdebug or --ethdebug-runtime and no debug-info was selected. BOOST_CHECK_EQUAL(commandLineOptions.output.debugInfoSelection.has_value(), true); BOOST_CHECK_EQUAL(commandLineOptions.output.debugInfoSelection->ethdebug, true); - commandLineOptions = parseCommandLine({"solc", "contract.sol", "--ethdebug-runtime", "--via-ir"}); + commandLineOptions = parseCommandLine({"solc", "contract.sol", "--experimental", "--ethdebug-runtime", "--via-ir"}); BOOST_CHECK_EQUAL(commandLineOptions.compiler.outputs.ethdebug, false); BOOST_CHECK_EQUAL(commandLineOptions.compiler.outputs.ethdebugRuntime, true); BOOST_CHECK_EQUAL(commandLineOptions.output.debugInfoSelection.has_value(), true); BOOST_CHECK_EQUAL(commandLineOptions.output.debugInfoSelection->ethdebug, true); - commandLineOptions = parseCommandLine({"solc", "contract.sol", "--ethdebug", "--ethdebug-runtime", "--via-ir"}); + commandLineOptions = parseCommandLine({"solc", "contract.sol", "--experimental", "--ethdebug", "--ethdebug-runtime", "--via-ir"}); BOOST_CHECK_EQUAL(commandLineOptions.compiler.outputs.ethdebug, true); BOOST_CHECK_EQUAL(commandLineOptions.compiler.outputs.ethdebugRuntime, true); BOOST_CHECK_EQUAL(commandLineOptions.output.debugInfoSelection.has_value(), true); BOOST_CHECK_EQUAL(commandLineOptions.output.debugInfoSelection->ethdebug, true); - commandLineOptions = parseCommandLine({"solc", "contract.sol", "--debug-info", "ethdebug", "--ir"}); + commandLineOptions = parseCommandLine({"solc", "contract.sol", "--experimental", "--debug-info", "ethdebug", "--ir"}); BOOST_CHECK_EQUAL(commandLineOptions.compiler.outputs.ethdebug, false); BOOST_CHECK_EQUAL(commandLineOptions.compiler.outputs.ethdebugRuntime, false); BOOST_CHECK_EQUAL(commandLineOptions.compiler.outputs.ir, true); @@ -665,6 +669,64 @@ BOOST_AUTO_TEST_CASE(ethdebug) BOOST_CHECK_EQUAL(commandLineOptions.output.debugInfoSelection->ethdebug, true); } +BOOST_AUTO_TEST_CASE(experimental_features_without_experimental_flag) +{ + std::vector const experimentalFeatures { + "--lsp", + "--import-ast", + "--import-asm-json", + "--ir-ast-json", + "--ir-optimized-ast-json", + "--yul-cfg-json", + "--ethdebug", + "--ethdebug-runtime" + }; + + std::string expectedErrorMessage; + auto hasCorrectMessage = [&](CommandLineValidationError const& _exception) { return _exception.what() == expectedErrorMessage; }; + + for (auto const& experimentalFeature: experimentalFeatures) + { + expectedErrorMessage = + fmt::format( + "The following options are only available in experimental mode: {}. " + "To enable experimental mode, use the --experimental flag.", + experimentalFeature + ); + + std::vector const commandLineOptions{"solc", experimentalFeature, "contract.sol"}; + BOOST_CHECK_EXCEPTION(parseCommandLine(commandLineOptions), CommandLineValidationError, hasCorrectMessage); + } + + std::vector const commandLineOptions{"solc", "--experimental-eof-version", "1", "contract.sol"}; + expectedErrorMessage = "The following options are only available in experimental mode: --experimental-eof-version. To enable experimental mode, use the --experimental flag."; + BOOST_CHECK_EXCEPTION(parseCommandLine(commandLineOptions), CommandLineValidationError, hasCorrectMessage); +} + +BOOST_AUTO_TEST_CASE(debug_info_ethdebug_without_experimental_flag) +{ + std::string const expectedErrorMessage = + "Ethdebug annotations are experimental and can only be included in --debug-info in experimental mode. " + "To enable experimental mode, use the --experimental flag."; + + auto hasCorrectMessage = [&](CommandLineValidationError const& _exception) { return _exception.what() == expectedErrorMessage; }; + + std::vector const commandLineOptions{"solc", "--debug-info", "ethdebug", "contract.sol"}; + BOOST_CHECK_EXCEPTION(parseCommandLine(commandLineOptions), CommandLineValidationError, hasCorrectMessage); +} + +BOOST_AUTO_TEST_CASE(experimental_flag_with_standard_json) +{ + std::string const expectedErrorMessage = + "Standard JSON input mode is incompatible with the --experimental flag. " + "Instead, please use the 'settings.experimental' setting in your Standard JSON input file to enable experimental mode."; + + auto hasCorrectMessage = [&](CommandLineValidationError const& _exception) { return _exception.what() == expectedErrorMessage; }; + + std::vector const commandLineOptions{"solc", "--experimental", "--standard-json", "input.json"}; + BOOST_CHECK_EXCEPTION(parseCommandLine(commandLineOptions), CommandLineValidationError, hasCorrectMessage); +} + BOOST_AUTO_TEST_SUITE_END() } // namespace solidity::frontend::test