From 834da7be9022612b2b78e5b6c2708b1072cb41e9 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 22 Oct 2020 19:19:14 +0200 Subject: [PATCH 1/3] Introduce abicoder pragma. --- libsolidity/analysis/ContractLevelChecker.cpp | 4 +- libsolidity/analysis/SyntaxChecker.cpp | 39 +++++++++++++++++++ libsolidity/analysis/SyntaxChecker.h | 1 + libsolidity/analysis/TypeChecker.cpp | 17 ++++---- libsolidity/analysis/TypeChecker.h | 2 +- libsolidity/ast/ASTAnnotations.h | 1 + libsolidity/codegen/ArrayUtils.cpp | 2 +- libsolidity/codegen/CompilerContext.h | 10 ++--- libsolidity/codegen/CompilerUtils.cpp | 4 +- libsolidity/codegen/ContractCompiler.cpp | 8 ++-- libsolidity/codegen/ExpressionCompiler.cpp | 4 +- test/libsolidity/Assembly.cpp | 2 + .../SolidityExpressionCompiler.cpp | 34 +++++++++------- .../abiEncoder/conflicting_settings.sol | 4 ++ .../conflicting_settings_reverse.sol | 4 ++ .../abiEncoder/invalid_pragma_value.sol | 3 ++ .../abiEncoder/same_setting_twice.sol | 4 ++ .../syntaxTests/abiEncoder/select_v1.sol | 1 + .../syntaxTests/abiEncoder/selected_twice.sol | 4 ++ .../abiEncoder/selected_twice_v2.sol | 2 + 20 files changed, 108 insertions(+), 42 deletions(-) create mode 100644 test/libsolidity/syntaxTests/abiEncoder/conflicting_settings.sol create mode 100644 test/libsolidity/syntaxTests/abiEncoder/conflicting_settings_reverse.sol create mode 100644 test/libsolidity/syntaxTests/abiEncoder/invalid_pragma_value.sol create mode 100644 test/libsolidity/syntaxTests/abiEncoder/same_setting_twice.sol create mode 100644 test/libsolidity/syntaxTests/abiEncoder/select_v1.sol create mode 100644 test/libsolidity/syntaxTests/abiEncoder/selected_twice.sol create mode 100644 test/libsolidity/syntaxTests/abiEncoder/selected_twice_v2.sol diff --git a/libsolidity/analysis/ContractLevelChecker.cpp b/libsolidity/analysis/ContractLevelChecker.cpp index 97f3fdc98..a541a58a2 100644 --- a/libsolidity/analysis/ContractLevelChecker.cpp +++ b/libsolidity/analysis/ContractLevelChecker.cpp @@ -450,7 +450,7 @@ void ContractLevelChecker::checkLibraryRequirements(ContractDefinition const& _c void ContractLevelChecker::checkBaseABICompatibility(ContractDefinition const& _contract) { - if (_contract.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::ABIEncoderV2)) + if (*_contract.sourceUnit().annotation().useABICoderV2) return; if (_contract.isLibrary()) @@ -469,7 +469,7 @@ void ContractLevelChecker::checkBaseABICompatibility(ContractDefinition const& _ { solAssert(func.second->hasDeclaration(), "Function has no declaration?!"); - if (!func.second->declaration().sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::ABIEncoderV2)) + if (!*func.second->declaration().sourceUnit().annotation().useABICoderV2) continue; auto const& currentLoc = func.second->declaration().location(); diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index 076592053..d8b8c3017 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -73,6 +73,8 @@ void SyntaxChecker::endVisit(SourceUnit const& _sourceUnit) // when reporting the warning, print the source name only m_errorReporter.warning(3420_error, {-1, -1, _sourceUnit.location().source}, errorString); } + if (!m_sourceUnit->annotation().useABICoderV2.set()) + m_sourceUnit->annotation().useABICoderV2 = false; m_sourceUnit = nullptr; } @@ -113,9 +115,45 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma) 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 (feature == ExperimentalFeature::ABIEncoderV2) + { + if (m_sourceUnit->annotation().useABICoderV2.set()) + { + if (!*m_sourceUnit->annotation().useABICoderV2) + m_errorReporter.syntaxError( + 8273_error, + _pragma.location(), + "ABI coder V1 has already been selected through \"pragma abicoder v1\"." + ); + } + else + m_sourceUnit->annotation().useABICoderV2 = true; + } } } } + else if (_pragma.literals()[0] == "abicoder") + { + solAssert(m_sourceUnit, ""); + if ( + _pragma.literals().size() != 2 || + !set{"v1", "v2"}.count(_pragma.literals()[1]) + ) + m_errorReporter.syntaxError( + 2745_error, + _pragma.location(), + "Expected either \"pragma abicoder v1\" or \"pragma abicoder v2\"." + ); + else if (m_sourceUnit->annotation().useABICoderV2.set()) + m_errorReporter.syntaxError( + 3845_error, + _pragma.location(), + "ABI coder has already been selected for this source unit." + ); + else + m_sourceUnit->annotation().useABICoderV2 = (_pragma.literals()[1] == "v2"); + } else if (_pragma.literals()[0] == "solidity") { vector tokens(_pragma.tokens().begin() + 1, _pragma.tokens().end()); @@ -135,6 +173,7 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma) } else m_errorReporter.syntaxError(4936_error, _pragma.location(), "Unknown pragma \"" + _pragma.literals()[0] + "\""); + return true; } diff --git a/libsolidity/analysis/SyntaxChecker.h b/libsolidity/analysis/SyntaxChecker.h index 52c82ff6e..d59bb89ba 100644 --- a/libsolidity/analysis/SyntaxChecker.h +++ b/libsolidity/analysis/SyntaxChecker.h @@ -39,6 +39,7 @@ namespace solidity::frontend * - issues deprecation warnings for unary '+' * - issues deprecation warning for throw * - whether the msize instruction is used and the Yul optimizer is enabled at the same time. + * - selection of the ABI coder through pragmas. */ class SyntaxChecker: private ASTConstVisitor { diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index ff31eb8bc..edcf74405 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -395,7 +395,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function) m_errorReporter.typeError(4103_error, _var.location(), message); } else if ( - !experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2) && + !useABICoderV2() && !typeSupportedByOldABIEncoder(*type(_var), _function.libraryFunction()) ) { @@ -567,7 +567,7 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) else if (_variable.visibility() >= Visibility::Public) { FunctionType getter(_variable); - if (!experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2)) + if (!useABICoderV2()) { vector unsupportedTypes; for (auto const& param: getter.parameterTypes() + getter.returnParameterTypes()) @@ -692,7 +692,7 @@ bool TypeChecker::visit(EventDefinition const& _eventDef) if (!type(*var)->interfaceType(false)) m_errorReporter.typeError(3417_error, var->location(), "Internal or recursive type is not allowed as event parameter type."); if ( - !experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2) && + !useABICoderV2() && !typeSupportedByOldABIEncoder(*type(*var), false /* isLibrary */) ) m_errorReporter.typeError( @@ -1897,7 +1897,7 @@ void TypeChecker::typeCheckABIEncodeFunctions( bool const isPacked = _functionType->kind() == FunctionType::Kind::ABIEncodePacked; solAssert(_functionType->padArguments() != isPacked, "ABI function with unexpected padding"); - bool const abiEncoderV2 = experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2); + bool const abiEncoderV2 = useABICoderV2(); // Check for named arguments if (!_functionCall.names().empty()) @@ -2189,7 +2189,7 @@ void TypeChecker::typeCheckFunctionGeneralChecks( _functionType->kind() == FunctionType::Kind::Creation || _functionType->kind() == FunctionType::Kind::Event; - if (callRequiresABIEncoding && !experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2)) + if (callRequiresABIEncoding && !useABICoderV2()) { solAssert(!isVariadic, ""); solAssert(parameterTypes.size() == arguments.size(), ""); @@ -2337,7 +2337,7 @@ bool TypeChecker::visit(FunctionCall const& _functionCall) { returnTypes = typeCheckABIDecodeAndRetrieveReturnType( _functionCall, - experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2) + useABICoderV2() ); break; } @@ -3384,10 +3384,11 @@ void TypeChecker::requireLValue(Expression const& _expression, bool _ordinaryAss m_errorReporter.typeError(errorId, _expression.location(), description); } -bool TypeChecker::experimentalFeatureActive(ExperimentalFeature _feature) const +bool TypeChecker::useABICoderV2() const { solAssert(m_currentSourceUnit, ""); if (m_currentContract) solAssert(m_currentSourceUnit == &m_currentContract->sourceUnit(), ""); - return m_currentSourceUnit->annotation().experimentalFeatures.count(_feature); + return *m_currentSourceUnit->annotation().useABICoderV2; + } diff --git a/libsolidity/analysis/TypeChecker.h b/libsolidity/analysis/TypeChecker.h index 70041766d..b86a19522 100644 --- a/libsolidity/analysis/TypeChecker.h +++ b/libsolidity/analysis/TypeChecker.h @@ -166,7 +166,7 @@ private: /// Runs type checks on @a _expression to infer its type and then checks that it is an LValue. void requireLValue(Expression const& _expression, bool _ordinaryAssignment); - bool experimentalFeatureActive(ExperimentalFeature _feature) const; + bool useABICoderV2() const; /// @returns the current scope that can have function or type definitions. /// This is either a contract or a source unit. diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index 25fec855f..dbb77aafc 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -94,6 +94,7 @@ struct SourceUnitAnnotation: ASTAnnotation SetOnce>> exportedSymbols; /// Experimental features. std::set experimentalFeatures; + SetOnce useABICoderV2; }; struct ScopableAnnotation diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp index 14e302bc9..64f92f183 100644 --- a/libsolidity/codegen/ArrayUtils.cpp +++ b/libsolidity/codegen/ArrayUtils.cpp @@ -1162,7 +1162,7 @@ void ArrayUtils::accessCallDataArrayElement(ArrayType const& _arrayType, bool _d if ( !_arrayType.isByteArray() && _arrayType.baseType()->storageBytes() < 32 && - m_context.experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2) + m_context.useABICoderV2() ) { m_context << u256(32); diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index bd37c3686..d32349e89 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -76,11 +76,8 @@ public: langutil::EVMVersion const& evmVersion() const { return m_evmVersion; } - /// Update currently enabled set of experimental features. - void setExperimentalFeatures(std::set const& _features) { m_experimentalFeatures = _features; } - std::set const& experimentalFeaturesActive() const { return m_experimentalFeatures; } - /// @returns true if the given feature is enabled. - bool experimentalFeatureActive(ExperimentalFeature _feature) const { return m_experimentalFeatures.count(_feature); } + void setUseABICoderV2(bool _value) { m_useABICoderV2 = _value; } + bool useABICoderV2() const { return m_useABICoderV2; } void addStateVariable(VariableDeclaration const& _declaration, u256 const& _storageOffset, unsigned _byteOffset); void addImmutable(VariableDeclaration const& _declaration); @@ -361,8 +358,7 @@ private: /// Version of the EVM to compile against. langutil::EVMVersion m_evmVersion; RevertStrings const m_revertStrings; - /// Activated experimental features. - std::set m_experimentalFeatures; + bool m_useABICoderV2 = false; /// Other already compiled contracts to be used in contract creation calls. std::map> m_otherCompilers; /// Storage offsets of state variables diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index f9be04c6e..f64b54d8e 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -230,7 +230,7 @@ void CompilerUtils::storeInMemoryDynamic(Type const& _type, bool _padToWordBound void CompilerUtils::abiDecode(TypePointers const& _typeParameters, bool _fromMemory) { /// Stack: - if (m_context.experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2)) + if (m_context.useABICoderV2()) { // Use the new Yul-based decoding function auto stackHeightBefore = m_context.stackHeight(); @@ -412,7 +412,7 @@ void CompilerUtils::encodeToMemory( ) { // stack: ... - bool const encoderV2 = m_context.experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2); + bool const encoderV2 = m_context.useABICoderV2(); TypePointers targetTypes = _targetTypes.empty() ? _givenTypes : _targetTypes; solAssert(targetTypes.size() == _givenTypes.size(), ""); for (TypePointer& t: targetTypes) diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index f76613095..14193962b 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -126,7 +126,7 @@ void ContractCompiler::initializeContext( map> const& _otherCompilers ) { - m_context.setExperimentalFeatures(_contract.sourceUnit().annotation().experimentalFeatures); + m_context.setUseABICoderV2(*_contract.sourceUnit().annotation().useABICoderV2); m_context.setOtherCompilers(_otherCompilers); m_context.setMostDerivedContract(_contract); if (m_runtimeCompiler) @@ -1324,13 +1324,13 @@ void ContractCompiler::appendModifierOrFunctionCode() if (codeBlock) { - std::set experimentalFeaturesOutside = m_context.experimentalFeaturesActive(); - m_context.setExperimentalFeatures(codeBlock->sourceUnit().annotation().experimentalFeatures); + bool coderV2Outside = m_context.useABICoderV2(); + m_context.setUseABICoderV2(*codeBlock->sourceUnit().annotation().useABICoderV2); m_returnTags.emplace_back(m_context.newTag(), m_context.stackHeight()); codeBlock->accept(*this); - m_context.setExperimentalFeatures(experimentalFeaturesOutside); + m_context.setUseABICoderV2(coderV2Outside); solAssert(!m_returnTags.empty(), ""); m_context << m_returnTags.back().first; diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 9dff56afc..444e312ad 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1682,7 +1682,7 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) { solAssert(memberType->calldataEncodedSize() > 0, ""); solAssert(memberType->storageBytes() <= 32, ""); - if (memberType->storageBytes() < 32 && m_context.experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2)) + if (memberType->storageBytes() < 32 && m_context.useABICoderV2()) { m_context << u256(32); CompilerUtils(m_context).abiDecodeV2({memberType}, false); @@ -2490,7 +2490,7 @@ void ExpressionCompiler::appendExternalFunctionCall( // memory pointer), but kept references to the return data for // (statically-sized) arrays bool needToUpdateFreeMemoryPtr = false; - if (dynamicReturnSize || m_context.experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2)) + if (dynamicReturnSize || m_context.useABICoderV2()) needToUpdateFreeMemoryPtr = true; else for (auto const& retType: returnTypes) diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp index a10604aee..4b599da68 100644 --- a/test/libsolidity/Assembly.cpp +++ b/test/libsolidity/Assembly.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -61,6 +62,7 @@ evmasm::AssemblyItems compileContract(std::shared_ptr _sourceCode) BOOST_CHECK(!!sourceUnit); Scoper::assignScopes(*sourceUnit); + BOOST_REQUIRE(SyntaxChecker(errorReporter, false).checkSyntax(*sourceUnit)); GlobalContext globalContext; NameAndTypeResolver resolver(globalContext, solidity::test::CommonOptions::get().evmVersion(), errorReporter); DeclarationTypeChecker declarationTypeChecker(errorReporter, solidity::test::CommonOptions::get().evmVersion()); diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 8c0ce780d..4f442919c 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -93,18 +94,20 @@ Declaration const& resolveDeclaration( } bytes compileFirstExpression( - const string& _sourceCode, + string const& _sourceCode, vector> _functions = {}, vector> _localVariables = {} ) { + string sourceCode = "pragma solidity >=0.0; // SPDX-License-Identifier: GPL-3\n" + _sourceCode; + ASTPointer sourceUnit; try { ErrorList errors; ErrorReporter errorReporter(errors); sourceUnit = Parser(errorReporter, solidity::test::CommonOptions::get().evmVersion()).parse( - make_shared(CharStream(_sourceCode, "")) + make_shared(CharStream(sourceCode, "")) ); if (!sourceUnit) return bytes(); @@ -119,6 +122,7 @@ bytes compileFirstExpression( ErrorReporter errorReporter(errors); GlobalContext globalContext; Scoper::assignScopes(*sourceUnit); + BOOST_REQUIRE(SyntaxChecker(errorReporter, false).checkSyntax(*sourceUnit)); NameAndTypeResolver resolver(globalContext, solidity::test::CommonOptions::get().evmVersion(), errorReporter); resolver.registerDeclarations(*sourceUnit); BOOST_REQUIRE_MESSAGE(resolver.resolveNamesAndTypes(*sourceUnit), "Resolving names failed"); @@ -186,7 +190,7 @@ BOOST_AUTO_TEST_CASE(literal_false) { char const* sourceCode = R"( contract test { - function f() { bool x = false; } + function f() public { bool x = false; } } )"; bytes code = compileFirstExpression(sourceCode); @@ -199,7 +203,7 @@ BOOST_AUTO_TEST_CASE(int_literal) { char const* sourceCode = R"( contract test { - function f() { uint x = 0x12345678901234567890; } + function f() public { uint x = 0x12345678901234567890; } } )"; bytes code = compileFirstExpression(sourceCode); @@ -228,7 +232,7 @@ BOOST_AUTO_TEST_CASE(int_with_gwei_ether_subdenomination) { char const* sourceCode = R"( contract test { - function test () { + function f() public { uint x = 1 gwei; } } @@ -258,7 +262,7 @@ BOOST_AUTO_TEST_CASE(comparison) { char const* sourceCode = R"( contract test { - function f() { bool x = (0x10aa < 0x11aa) != true; } + function f() public { bool x = (0x10aa < 0x11aa) != true; } } )"; bytes code = compileFirstExpression(sourceCode); @@ -290,7 +294,7 @@ BOOST_AUTO_TEST_CASE(short_circuiting) { char const* sourceCode = R"( contract test { - function f() { bool x = true != (4 <= 8 + 10 || 9 != 2); } + function f() public { bool x = true != (4 <= 8 + 10 || 9 != 2); } } )"; bytes code = compileFirstExpression(sourceCode); @@ -321,7 +325,7 @@ BOOST_AUTO_TEST_CASE(arithmetic) { char const* sourceCode = R"( contract test { - function f(uint y) { ((((((((y ^ 8) & 7) | 6) - 5) + 4) % 3) / 2) * 1); } + function f(uint y) public { ((((((((y ^ 8) & 7) | 6) - 5) + 4) % 3) / 2) * 1); } } )"; bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}}); @@ -402,7 +406,7 @@ BOOST_AUTO_TEST_CASE(unary_operators) { char const* sourceCode = R"( contract test { - function f(int y) { !(~- y == 2); } + function f(int y) public { !(~- y == 2); } } )"; bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}}); @@ -492,7 +496,7 @@ BOOST_AUTO_TEST_CASE(assignment) { char const* sourceCode = R"( contract test { - function f(uint a, uint b) { (a += b) * 2; } + function f(uint a, uint b) public { (a += b) * 2; } } )"; bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "b"}}); @@ -530,7 +534,7 @@ BOOST_AUTO_TEST_CASE(negative_literals_8bits) { char const* sourceCode = R"( contract test { - function f() { int8 x = -0x80; } + function f() public { int8 x = -0x80; } } )"; bytes code = compileFirstExpression(sourceCode); @@ -543,7 +547,7 @@ BOOST_AUTO_TEST_CASE(negative_literals_16bits) { char const* sourceCode = R"( contract test { - function f() { int64 x = ~0xabc; } + function f() public { int64 x = ~0xabc; } } )"; bytes code = compileFirstExpression(sourceCode); @@ -558,7 +562,7 @@ BOOST_AUTO_TEST_CASE(intermediately_overflowing_literals) // have been applied char const* sourceCode = R"( contract test { - function f() { uint8 x = (0x00ffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; } + function f() public { uint8 x = (0x00ffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; } } )"; bytes code = compileFirstExpression(sourceCode); @@ -571,7 +575,7 @@ BOOST_AUTO_TEST_CASE(blockhash) { char const* sourceCode = R"( contract test { - function f() { + function f() public { blockhash(3); } } @@ -603,7 +607,7 @@ BOOST_AUTO_TEST_CASE(selfbalance) { char const* sourceCode = R"( contract test { - function f() returns (uint) { + function f() public returns (uint) { return address(this).balance; } } diff --git a/test/libsolidity/syntaxTests/abiEncoder/conflicting_settings.sol b/test/libsolidity/syntaxTests/abiEncoder/conflicting_settings.sol new file mode 100644 index 000000000..29488de12 --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/conflicting_settings.sol @@ -0,0 +1,4 @@ +pragma experimental ABIEncoderV2; +pragma abicoder v1; +// ---- +// SyntaxError 3845: (34-53): ABI coder has already been selected for this source unit. diff --git a/test/libsolidity/syntaxTests/abiEncoder/conflicting_settings_reverse.sol b/test/libsolidity/syntaxTests/abiEncoder/conflicting_settings_reverse.sol new file mode 100644 index 000000000..dbdd0392f --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/conflicting_settings_reverse.sol @@ -0,0 +1,4 @@ +pragma abicoder v1; +pragma experimental ABIEncoderV2; +// ---- +// SyntaxError 8273: (20-53): ABI coder V1 has already been selected through "pragma abicoder v1". diff --git a/test/libsolidity/syntaxTests/abiEncoder/invalid_pragma_value.sol b/test/libsolidity/syntaxTests/abiEncoder/invalid_pragma_value.sol new file mode 100644 index 000000000..cbfa03b3f --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/invalid_pragma_value.sol @@ -0,0 +1,3 @@ +pragma abicoder something; +// ---- +// SyntaxError 2745: (0-26): Expected either "pragma abicoder v1" or "pragma abicoder v2". diff --git a/test/libsolidity/syntaxTests/abiEncoder/same_setting_twice.sol b/test/libsolidity/syntaxTests/abiEncoder/same_setting_twice.sol new file mode 100644 index 000000000..0303bcb14 --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/same_setting_twice.sol @@ -0,0 +1,4 @@ +pragma experimental ABIEncoderV2; +pragma abicoder v2; +// ---- +// SyntaxError 3845: (34-53): ABI coder has already been selected for this source unit. diff --git a/test/libsolidity/syntaxTests/abiEncoder/select_v1.sol b/test/libsolidity/syntaxTests/abiEncoder/select_v1.sol new file mode 100644 index 000000000..ecae09ad6 --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/select_v1.sol @@ -0,0 +1 @@ +pragma abicoder v1; \ No newline at end of file diff --git a/test/libsolidity/syntaxTests/abiEncoder/selected_twice.sol b/test/libsolidity/syntaxTests/abiEncoder/selected_twice.sol new file mode 100644 index 000000000..424c2c7f2 --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/selected_twice.sol @@ -0,0 +1,4 @@ +pragma abicoder v1; +pragma abicoder v1; +// ---- +// SyntaxError 3845: (20-39): ABI coder has already been selected for this source unit. diff --git a/test/libsolidity/syntaxTests/abiEncoder/selected_twice_v2.sol b/test/libsolidity/syntaxTests/abiEncoder/selected_twice_v2.sol new file mode 100644 index 000000000..a0d0cf2d8 --- /dev/null +++ b/test/libsolidity/syntaxTests/abiEncoder/selected_twice_v2.sol @@ -0,0 +1,2 @@ +pragma abicoder v2; +pragma experimental ABIEncoderV2; \ No newline at end of file From 631570c547d459d78b11c65494dd7d04d8f56adc Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 29 Oct 2020 19:40:09 +0100 Subject: [PATCH 2/3] Documentation. --- Changelog.md | 3 ++ docs/060-breaking-changes.rst | 2 +- docs/abi-spec.rst | 4 +-- docs/contracts/functions.rst | 8 ++--- docs/layout-of-source-files.rst | 60 +++++++++++++++++++++------------ docs/types/reference-types.rst | 2 +- docs/using-the-compiler.rst | 2 +- 7 files changed, 50 insertions(+), 31 deletions(-) diff --git a/Changelog.md b/Changelog.md index 0ced53d8d..8e36a636e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ ### 0.7.5 (unreleased) +Language Features: + * Ability to select the abi coder using ``pragma abicoder v1`` and ``pragma abicoder v2``. + Compiler Features: * SMTChecker: Add division by zero checks in the CHC engine. * SMTChecker: Support ``selector`` for expressions with value known at compile-time. diff --git a/docs/060-breaking-changes.rst b/docs/060-breaking-changes.rst index 3173bca69..32397677c 100644 --- a/docs/060-breaking-changes.rst +++ b/docs/060-breaking-changes.rst @@ -132,7 +132,7 @@ Yul Optimizer Together with the legacy bytecode optimizer, the :doc:`Yul ` optimizer is now enabled by default when you call the compiler with ``--optimize``. It can be disabled by calling the compiler with ``--no-optimize-yul``. -This mostly affects code that uses ABIEncoderV2. +This mostly affects code that uses ABI coder v2. C API Changes ~~~~~~~~~~~~~ diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst index a93a63747..bf5c0dbaf 100644 --- a/docs/abi-spec.rst +++ b/docs/abi-spec.rst @@ -589,8 +589,8 @@ As an example, the code :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.19 <0.8.0; - pragma experimental ABIEncoderV2; + pragma solidity >0.7.4; + pragma abicoder v2; contract Test { struct S { uint a; uint[] b; T[] c; } diff --git a/docs/contracts/functions.rst b/docs/contracts/functions.rst index 81f1b6792..8d6507f32 100644 --- a/docs/contracts/functions.rst +++ b/docs/contracts/functions.rst @@ -67,8 +67,8 @@ Function parameters can be used as any other local variable and they can also be An :ref:`external function` cannot accept a multi-dimensional array as an input - parameter. This functionality is possible if you enable the new - ``ABIEncoderV2`` feature by adding ``pragma experimental ABIEncoderV2;`` to your source file. + parameter. This functionality is possible if you enable the ABI coder v2 + by adding ``pragma abicoder v2;`` to your source file. An :ref:`internal function` can accept a multi-dimensional array without enabling the feature. @@ -128,8 +128,8 @@ you must provide return values together with the return statement. .. note:: You cannot return some types from non-internal functions, notably multi-dimensional dynamic arrays and structs. If you enable the - new ``ABIEncoderV2`` feature by adding ``pragma experimental - ABIEncoderV2;`` to your source file then more types are available, but + ABI coder v2 by adding ``pragma abicoder v2;`` + to your source file then more types are available, but ``mapping`` types are still limited to inside a single contract and you cannot transfer them. diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index 08f3bb4fe..cf1a6f83d 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -88,6 +88,41 @@ these follow the same syntax used by `npm `_ required by the pragma. If it does not match, the compiler issues an error. +ABI Coder Pragma +---------------- + +By using ``pragma abicoder v1`` or ``pragma abicoder v2`` you can +select between the two implementations of the ABI encoder and decoder. + +The new ABI coder (v2) is able to encode and decode arbitrarily nested +arrays and structs. It might produce less optimal code and has not +received as much testing as the old encoder, but is considered +non-experimental as of Solidity 0.6.0. You still have to explicitly +activate it using ``pragma abicoder v2;``. Since it will be +activated by default starting from Solidity 0.8.0, there is the option to select +the old coder using ``pragma abicoder v1;``. + +The set of types supported by the new encoder is a strict superset of +the ones supported by the old one. Contracts that use it can interact with ones +that do not without limitations. The reverse is possible only as long as the +non-``abicoder v2`` contract does not try to make calls that would require +decoding types only supported by the new encoder. The compiler can detect this +and will issue an error. Simply enabling ``abicoder v2`` for your contract is +enough to make the error go away. + +.. note:: + This pragma applies to all the code defined in the file where it is activated, + regardless of where that code ends up eventually. This means that a contract + whose source file is selected to compile with ABI coder v1 + can still contain code that uses the new encoder + by inheriting it from another contract. This is allowed if the new types are only + used internally and not in external function signatures. + +.. note:: + Up to Solidity 0.7.4, it was possible to select the ABI coder v2 + by using ``pragma experimental ABIEncoderV2``, but it was not possible + to explicitly select coder v1 because it was the default. + .. index:: ! pragma, experimental .. _experimental_pragma: @@ -103,28 +138,9 @@ The following experimental pragmas are currently supported: ABIEncoderV2 ~~~~~~~~~~~~ -The new ABI encoder is able to encode and decode arbitrarily nested -arrays and structs. It might produce less optimal code and has not -received as much testing as the old encoder, but is considered -non-experimental as of Solidity 0.6.0. You still have to explicitly -activate it using ``pragma experimental ABIEncoderV2;`` - we kept -the same pragma, even though it is not considered experimental -anymore. - -The set of types supported by the new encoder is a strict superset of -the ones supported by the old one. Contracts that use it can interact with ones -that do not without limitations. The reverse is possible only as long as the -non-``ABIEncoderV2`` contract does not try to make calls that would require -decoding types only supported by the new encoder. The compiler can detect this -and will issue an error. Simply enabling ``ABIEncoderV2`` for your contract is -enough to make the error go away. - -.. note:: - This pragma applies to all the code defined in the file where it is activated, - regardless of where that code ends up eventually. This means that a contract - without the ``ABIEncoderV2`` pragma can still contain code that uses the new encoder - by inheriting it from another contract. This is allowed if the new types are only - used internally and not in external function signatures. +Because the ABI coder v2 is not considered experimental anymore, +it can be selected via ``pragma abicoder v2`` (please see above) +since Solidity 0.7.4. .. _smt_checker: diff --git a/docs/types/reference-types.rst b/docs/types/reference-types.rst index 6eb4c01bf..0d3880113 100644 --- a/docs/types/reference-types.rst +++ b/docs/types/reference-types.rst @@ -290,7 +290,7 @@ Array Members .. note:: To use arrays of arrays in external (instead of public) functions, you need to - activate ABIEncoderV2. + activate ABI coder v2. .. note:: In EVM versions before Byzantium, it was not possible to access diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index 95a563688..a007cbf28 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -231,7 +231,7 @@ Input Description "cse": false, // Optimize representation of literal numbers and strings in code. "constantOptimizer": false, - // The new Yul optimizer. Mostly operates on the code of ABIEncoderV2 + // The new Yul optimizer. Mostly operates on the code of ABI coder v2 // and inline assembly. // It is activated together with the global optimizer setting // and can be deactivated here. From e27a1b786ba0db8c734a97bb90948faf57d0fe70 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 29 Oct 2020 19:40:17 +0100 Subject: [PATCH 3/3] Wording in error messages. --- libsolidity/analysis/ContractLevelChecker.cpp | 4 ++-- libsolidity/analysis/SyntaxChecker.cpp | 2 +- libsolidity/analysis/TypeChecker.cpp | 20 +++++++++---------- .../conflicting_settings_reverse.sol | 2 +- ...all_to_v2_constructor_accepting_struct.sol | 2 +- ...on_accepting_struct_via_named_argument.sol | 2 +- ...ract_function_pointer_accepting_struct.sol | 2 +- ...unction_returning_dynamic_string_array.sol | 2 +- ..._v2_contract_function_returning_struct.sol | 2 +- ...on_returning_struct_with_dynamic_array.sol | 2 +- .../v1_call_to_v2_event_accepting_struct.sol | 2 +- ...ibrary_bound_function_returning_struct.sol | 2 +- ...o_v2_library_function_returning_struct.sol | 2 +- ..._defining_v2_function_accepting_struct.sol | 2 +- ..._defining_v2_function_returning_struct.sol | 2 +- .../abiEncoder/v2_v1_v1_modifier_sandwich.sol | 2 +- .../abiEncoder/v2_v1_v2_modifier_sandwich.sol | 2 +- .../array/calldata_multi_dynamic_V1.sol | 4 ++-- .../syntaxTests/constructor/nonabiv2_type.sol | 2 +- .../syntaxTests/events/event_nested_array.sol | 2 +- .../events/event_nested_array_in_struct.sol | 2 +- .../syntaxTests/events/event_struct.sol | 2 +- .../events/event_struct_indexed.sol | 2 +- .../syntaxTests/getter/nested_structs.sol | 2 +- .../inheritance_abi_encoder_mismatch_1.sol | 2 +- .../inheritance_abi_encoder_mismatch_2.sol | 2 +- ...045_returning_multi_dimensional_arrays.sol | 2 +- ...urning_multi_dimensional_static_arrays.sol | 2 +- ...048_returning_arrays_in_structs_arrays.sol | 2 +- 29 files changed, 40 insertions(+), 40 deletions(-) diff --git a/libsolidity/analysis/ContractLevelChecker.cpp b/libsolidity/analysis/ContractLevelChecker.cpp index a541a58a2..56c834468 100644 --- a/libsolidity/analysis/ContractLevelChecker.cpp +++ b/libsolidity/analysis/ContractLevelChecker.cpp @@ -489,9 +489,9 @@ void ContractLevelChecker::checkBaseABICompatibility(ContractDefinition const& _ errors, std::string("Contract \"") + _contract.name() + - "\" does not use ABIEncoderV2 but wants to inherit from a contract " + + "\" does not use ABI coder v2 but wants to inherit from a contract " + "which uses types that require it. " + - "Use \"pragma experimental ABIEncoderV2;\" for the inheriting contract as well to enable the feature." + "Use \"pragma abicoder v2;\" for the inheriting contract as well to enable the feature." ); } diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index d8b8c3017..e6c5daeca 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -124,7 +124,7 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma) m_errorReporter.syntaxError( 8273_error, _pragma.location(), - "ABI coder V1 has already been selected through \"pragma abicoder v1\"." + "ABI coder v1 has already been selected through \"pragma abicoder v1\"." ); } else diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index edcf74405..eee6dbaa4 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -400,8 +400,8 @@ bool TypeChecker::visit(FunctionDefinition const& _function) ) { string message = - "This type is only supported in ABIEncoderV2. " - "Use \"pragma experimental ABIEncoderV2;\" to enable the feature."; + "This type is only supported in ABI coder v2. " + "Use \"pragma abicoder v2;\" to enable the feature."; if (_function.isConstructor()) message += " Alternatively, make the contract abstract and supply the " @@ -577,9 +577,9 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) m_errorReporter.typeError( 2763_error, _variable.location(), - "The following types are only supported for getters in ABIEncoderV2: " + + "The following types are only supported for getters in ABI coder v2: " + joinHumanReadable(unsupportedTypes) + - ". Either remove \"public\" or use \"pragma experimental ABIEncoderV2;\" to enable the feature." + ". Either remove \"public\" or use \"pragma abicoder v2;\" to enable the feature." ); } if (!getter.interfaceFunctionType()) @@ -698,8 +698,8 @@ bool TypeChecker::visit(EventDefinition const& _eventDef) m_errorReporter.typeError( 3061_error, var->location(), - "This type is only supported in ABIEncoderV2. " - "Use \"pragma experimental ABIEncoderV2;\" to enable the feature." + "This type is only supported in ABI coder v2. " + "Use \"pragma abicoder v2;\" to enable the feature." ); } if (_eventDef.isAnonymous() && numIndexed > 4) @@ -2205,8 +2205,8 @@ void TypeChecker::typeCheckFunctionGeneralChecks( 2443_error, paramArgMap[i]->location(), "The type of this parameter, " + parameterTypes[i]->toString(true) + ", " - "is only supported in ABIEncoderV2. " - "Use \"pragma experimental ABIEncoderV2;\" to enable the feature." + "is only supported in ABI coder v2. " + "Use \"pragma abicoder v2;\" to enable the feature." ); } @@ -2219,8 +2219,8 @@ void TypeChecker::typeCheckFunctionGeneralChecks( 2428_error, _functionCall.location(), "The type of return parameter " + toString(i + 1) + ", " + returnParameterTypes[i]->toString(true) + ", " - "is only supported in ABIEncoderV2. " - "Use \"pragma experimental ABIEncoderV2;\" to enable the feature." + "is only supported in ABI coder v2. " + "Use \"pragma abicoder v2;\" to enable the feature." ); } } diff --git a/test/libsolidity/syntaxTests/abiEncoder/conflicting_settings_reverse.sol b/test/libsolidity/syntaxTests/abiEncoder/conflicting_settings_reverse.sol index dbdd0392f..855378e9e 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/conflicting_settings_reverse.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/conflicting_settings_reverse.sol @@ -1,4 +1,4 @@ pragma abicoder v1; pragma experimental ABIEncoderV2; // ---- -// SyntaxError 8273: (20-53): ABI coder V1 has already been selected through "pragma abicoder v1". +// SyntaxError 8273: (20-53): ABI coder v1 has already been selected through "pragma abicoder v1". diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_constructor_accepting_struct.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_constructor_accepting_struct.sol index 17dfee2c3..c7ecbfff7 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_constructor_accepting_struct.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_constructor_accepting_struct.sol @@ -17,4 +17,4 @@ contract Test { } } // ---- -// TypeError 2443: (B:71-80): The type of this parameter, struct C.Item, is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 2443: (B:71-80): The type of this parameter, struct C.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_accepting_struct_via_named_argument.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_accepting_struct_via_named_argument.sol index bf8663071..220fc1b29 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_accepting_struct_via_named_argument.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_accepting_struct_via_named_argument.sol @@ -17,4 +17,4 @@ contract Test { } } // ---- -// TypeError 2443: (B:90-100): The type of this parameter, struct C.Item, is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 2443: (B:90-100): The type of this parameter, struct C.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_pointer_accepting_struct.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_pointer_accepting_struct.sol index db6180ff6..be9517f40 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_pointer_accepting_struct.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_pointer_accepting_struct.sol @@ -19,4 +19,4 @@ contract Test { } } // ---- -// TypeError 2443: (B:146-155): The type of this parameter, struct C.Item, is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 2443: (B:146-155): The type of this parameter, struct C.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_dynamic_string_array.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_dynamic_string_array.sol index 11cdbaefb..24254e5f4 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_dynamic_string_array.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_dynamic_string_array.sol @@ -13,4 +13,4 @@ contract D { } } // ---- -// TypeError 2428: (B:65-76): The type of return parameter 1, string[], is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 2428: (B:65-76): The type of return parameter 1, string[], is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct.sol index 123073cb0..d62452ab8 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct.sol @@ -17,4 +17,4 @@ contract Test { } } // ---- -// TypeError 2428: (B:70-83): The type of return parameter 1, struct C.Item, is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 2428: (B:70-83): The type of return parameter 1, struct C.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct_with_dynamic_array.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct_with_dynamic_array.sol index 35faaaf15..881ebd954 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct_with_dynamic_array.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_contract_function_returning_struct_with_dynamic_array.sol @@ -17,4 +17,4 @@ contract Test { } } // ---- -// TypeError 2428: (B:70-83): The type of return parameter 1, struct C.Item, is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 2428: (B:70-83): The type of return parameter 1, struct C.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_event_accepting_struct.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_event_accepting_struct.sol index 4a02a2fa1..87498d206 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_event_accepting_struct.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_event_accepting_struct.sol @@ -16,4 +16,4 @@ contract Test { } } // ---- -// TypeError 2443: (B:74-84): The type of this parameter, struct L.Item, is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 2443: (B:74-84): The type of this parameter, struct L.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_bound_function_returning_struct.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_bound_function_returning_struct.sol index eeaa6ac58..7804240ad 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_bound_function_returning_struct.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_bound_function_returning_struct.sol @@ -19,4 +19,4 @@ contract D { } } // ---- -// TypeError 2428: (B:86-97): The type of return parameter 1, struct L.Item, is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 2428: (B:86-97): The type of return parameter 1, struct L.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_function_returning_struct.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_function_returning_struct.sol index 983ce189f..86be448f7 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_function_returning_struct.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_function_returning_struct.sol @@ -17,4 +17,4 @@ contract Test { } } // ---- -// TypeError 2428: (B:70-77): The type of return parameter 1, struct L.Item, is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 2428: (B:70-77): The type of return parameter 1, struct L.Item, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_inheritance_from_contract_defining_v2_function_accepting_struct.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_inheritance_from_contract_defining_v2_function_accepting_struct.sol index 23535eafc..3665e22f6 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_inheritance_from_contract_defining_v2_function_accepting_struct.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_inheritance_from_contract_defining_v2_function_accepting_struct.sol @@ -13,4 +13,4 @@ import "A"; contract D is C {} // ---- -// TypeError 6594: (B:13-31): Contract "D" does not use ABIEncoderV2 but wants to inherit from a contract which uses types that require it. Use "pragma experimental ABIEncoderV2;" for the inheriting contract as well to enable the feature. +// TypeError 6594: (B:13-31): Contract "D" does not use ABI coder v2 but wants to inherit from a contract which uses types that require it. Use "pragma abicoder v2;" for the inheriting contract as well to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v1_inheritance_from_contract_defining_v2_function_returning_struct.sol b/test/libsolidity/syntaxTests/abiEncoder/v1_inheritance_from_contract_defining_v2_function_returning_struct.sol index ba568504e..febb3d3d7 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v1_inheritance_from_contract_defining_v2_function_returning_struct.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v1_inheritance_from_contract_defining_v2_function_returning_struct.sol @@ -13,4 +13,4 @@ import "A"; contract D is C {} // ---- -// TypeError 6594: (B:13-31): Contract "D" does not use ABIEncoderV2 but wants to inherit from a contract which uses types that require it. Use "pragma experimental ABIEncoderV2;" for the inheriting contract as well to enable the feature. +// TypeError 6594: (B:13-31): Contract "D" does not use ABI coder v2 but wants to inherit from a contract which uses types that require it. Use "pragma abicoder v2;" for the inheriting contract as well to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v2_v1_v1_modifier_sandwich.sol b/test/libsolidity/syntaxTests/abiEncoder/v2_v1_v1_modifier_sandwich.sol index a90b3385f..ea64c5c6f 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v2_v1_v1_modifier_sandwich.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v2_v1_v1_modifier_sandwich.sol @@ -27,4 +27,4 @@ contract C is B { {} } // ---- -// TypeError 2428: (B:60-73): The type of return parameter 1, struct Data, is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 2428: (B:60-73): The type of return parameter 1, struct Data, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/abiEncoder/v2_v1_v2_modifier_sandwich.sol b/test/libsolidity/syntaxTests/abiEncoder/v2_v1_v2_modifier_sandwich.sol index 01c0d0840..df1c4ed3c 100644 --- a/test/libsolidity/syntaxTests/abiEncoder/v2_v1_v2_modifier_sandwich.sol +++ b/test/libsolidity/syntaxTests/abiEncoder/v2_v1_v2_modifier_sandwich.sol @@ -29,4 +29,4 @@ contract C is B { {} } // ---- -// TypeError 2428: (B:60-73): The type of return parameter 1, struct Data, is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 2428: (B:60-73): The type of return parameter 1, struct Data, is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/array/calldata_multi_dynamic_V1.sol b/test/libsolidity/syntaxTests/array/calldata_multi_dynamic_V1.sol index c6dab54cf..00bd4208c 100644 --- a/test/libsolidity/syntaxTests/array/calldata_multi_dynamic_V1.sol +++ b/test/libsolidity/syntaxTests/array/calldata_multi_dynamic_V1.sol @@ -3,5 +3,5 @@ contract Test { function g(uint[][1] calldata) external { } } // ---- -// TypeError 4957: (31-48): This type is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. -// TypeError 4957: (78-96): This type is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 4957: (31-48): This type is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. +// TypeError 4957: (78-96): This type is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/constructor/nonabiv2_type.sol b/test/libsolidity/syntaxTests/constructor/nonabiv2_type.sol index 13b0d02af..3487c67f3 100644 --- a/test/libsolidity/syntaxTests/constructor/nonabiv2_type.sol +++ b/test/libsolidity/syntaxTests/constructor/nonabiv2_type.sol @@ -2,4 +2,4 @@ contract C { constructor(uint[][][] memory t) {} } // ---- -// TypeError 4957: (26-45): This type is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. Alternatively, make the contract abstract and supply the constructor arguments from a derived contract. +// TypeError 4957: (26-45): This type is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. Alternatively, make the contract abstract and supply the constructor arguments from a derived contract. diff --git a/test/libsolidity/syntaxTests/events/event_nested_array.sol b/test/libsolidity/syntaxTests/events/event_nested_array.sol index 6d76a6dcd..09ae580f6 100644 --- a/test/libsolidity/syntaxTests/events/event_nested_array.sol +++ b/test/libsolidity/syntaxTests/events/event_nested_array.sol @@ -2,4 +2,4 @@ contract c { event E(uint[][]); } // ---- -// TypeError 3061: (25-33): This type is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 3061: (25-33): This type is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol b/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol index 4e6f10d2a..b06f4990f 100644 --- a/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol +++ b/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol @@ -3,4 +3,4 @@ contract c { event E(S); } // ---- -// TypeError 3061: (61-62): This type is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 3061: (61-62): This type is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/events/event_struct.sol b/test/libsolidity/syntaxTests/events/event_struct.sol index 52a01c5e9..fad75f5a5 100644 --- a/test/libsolidity/syntaxTests/events/event_struct.sol +++ b/test/libsolidity/syntaxTests/events/event_struct.sol @@ -3,4 +3,4 @@ contract c { event E(S); } // ---- -// TypeError 3061: (51-52): This type is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 3061: (51-52): This type is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/events/event_struct_indexed.sol b/test/libsolidity/syntaxTests/events/event_struct_indexed.sol index 19676b5cc..1425ca9b9 100644 --- a/test/libsolidity/syntaxTests/events/event_struct_indexed.sol +++ b/test/libsolidity/syntaxTests/events/event_struct_indexed.sol @@ -3,4 +3,4 @@ contract c { event E(S indexed); } // ---- -// TypeError 3061: (51-60): This type is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 3061: (51-60): This type is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/getter/nested_structs.sol b/test/libsolidity/syntaxTests/getter/nested_structs.sol index 457ddb87d..6e901b438 100644 --- a/test/libsolidity/syntaxTests/getter/nested_structs.sol +++ b/test/libsolidity/syntaxTests/getter/nested_structs.sol @@ -8,4 +8,4 @@ contract C { mapping(uint256 => X) public m; } // ---- -// TypeError 2763: (88-118): The following types are only supported for getters in ABIEncoderV2: struct C.Y memory. Either remove "public" or use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 2763: (88-118): The following types are only supported for getters in ABI coder v2: struct C.Y memory. Either remove "public" or use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/imports/inheritance_abi_encoder_mismatch_1.sol b/test/libsolidity/syntaxTests/imports/inheritance_abi_encoder_mismatch_1.sol index 214de78d1..6e90f7d49 100644 --- a/test/libsolidity/syntaxTests/imports/inheritance_abi_encoder_mismatch_1.sol +++ b/test/libsolidity/syntaxTests/imports/inheritance_abi_encoder_mismatch_1.sol @@ -16,4 +16,4 @@ contract B is A { } import "./B.sol"; contract C is B { } // ---- -// TypeError 6594: (C.sol:18-37): Contract "C" does not use ABIEncoderV2 but wants to inherit from a contract which uses types that require it. Use "pragma experimental ABIEncoderV2;" for the inheriting contract as well to enable the feature. +// TypeError 6594: (C.sol:18-37): Contract "C" does not use ABI coder v2 but wants to inherit from a contract which uses types that require it. Use "pragma abicoder v2;" for the inheriting contract as well to enable the feature. diff --git a/test/libsolidity/syntaxTests/imports/inheritance_abi_encoder_mismatch_2.sol b/test/libsolidity/syntaxTests/imports/inheritance_abi_encoder_mismatch_2.sol index 07b9cdefe..7e5cfc7fd 100644 --- a/test/libsolidity/syntaxTests/imports/inheritance_abi_encoder_mismatch_2.sol +++ b/test/libsolidity/syntaxTests/imports/inheritance_abi_encoder_mismatch_2.sol @@ -14,4 +14,4 @@ contract B is A { } import "./B.sol"; contract C is B { } // ---- -// TypeError 6594: (B.sol:18-37): Contract "B" does not use ABIEncoderV2 but wants to inherit from a contract which uses types that require it. Use "pragma experimental ABIEncoderV2;" for the inheriting contract as well to enable the feature. +// TypeError 6594: (B.sol:18-37): Contract "B" does not use ABI coder v2 but wants to inherit from a contract which uses types that require it. Use "pragma abicoder v2;" for the inheriting contract as well to enable the feature. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/045_returning_multi_dimensional_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/045_returning_multi_dimensional_arrays.sol index bc92882a2..a0a2e0408 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/045_returning_multi_dimensional_arrays.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/045_returning_multi_dimensional_arrays.sol @@ -2,4 +2,4 @@ contract C { function f() public pure returns (string[][] memory) {} } // ---- -// TypeError 4957: (51-68): This type is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 4957: (51-68): This type is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/046_returning_multi_dimensional_static_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/046_returning_multi_dimensional_static_arrays.sol index d0e6ec0b6..a643aec01 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/046_returning_multi_dimensional_static_arrays.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/046_returning_multi_dimensional_static_arrays.sol @@ -2,4 +2,4 @@ contract C { function f() public pure returns (uint[][2] memory) {} } // ---- -// TypeError 4957: (51-67): This type is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 4957: (51-67): This type is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/048_returning_arrays_in_structs_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/048_returning_arrays_in_structs_arrays.sol index 7670da2b0..46e495217 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/048_returning_arrays_in_structs_arrays.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/048_returning_arrays_in_structs_arrays.sol @@ -3,4 +3,4 @@ contract C { function f() public pure returns (S memory x) {} } // ---- -// TypeError 4957: (80-90): This type is only supported in ABIEncoderV2. Use "pragma experimental ABIEncoderV2;" to enable the feature. +// TypeError 4957: (80-90): This type is only supported in ABI coder v2. Use "pragma abicoder v2;" to enable the feature.