From 9324fb4f20a848609ea417299869ece0044c44f5 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 4 May 2020 18:38:00 +0200 Subject: [PATCH 1/5] Free functions. --- libsolidity/analysis/GlobalContext.cpp | 17 +++- libsolidity/analysis/GlobalContext.h | 1 + libsolidity/analysis/NameAndTypeResolver.cpp | 10 ++ libsolidity/analysis/StaticAnalyzer.cpp | 1 + libsolidity/analysis/SyntaxChecker.cpp | 30 +++++- libsolidity/analysis/SyntaxChecker.h | 3 +- libsolidity/analysis/TypeChecker.cpp | 95 +++++++++++++------ libsolidity/analysis/TypeChecker.h | 10 ++ libsolidity/analysis/ViewPureChecker.cpp | 36 +++---- libsolidity/analysis/ViewPureChecker.h | 1 + libsolidity/ast/AST.cpp | 11 ++- libsolidity/ast/AST.h | 8 ++ libsolidity/ast/ASTAnnotations.h | 3 - libsolidity/ast/ASTJsonConverter.cpp | 2 +- libsolidity/ast/ASTJsonImporter.cpp | 16 +++- libsolidity/ast/Types.cpp | 16 ++-- libsolidity/codegen/ExpressionCompiler.cpp | 10 +- libsolidity/parsing/Parser.cpp | 8 +- libsolidity/parsing/Parser.h | 2 +- .../semanticTests/freeFunctions/easy.sol | 13 +++ .../freeFunctions/free_runtimecode.sol | 15 +++ .../semanticTests/freeFunctions/import.sol | 18 ++++ .../freeFunctions/libraries_from_free.sol | 21 ++++ .../freeFunctions/new_operator.sol | 15 +++ .../semanticTests/freeFunctions/overloads.sol | 16 ++++ .../semanticTests/freeFunctions/recursion.sol | 23 +++++ .../freeFunctions/storage_calldata_refs.sol | 17 ++++ .../free_call_via_contract_type.sol | 8 ++ .../freeFunctions/free_constructor.sol | 3 + .../freeFunctions/free_fallback.sol | 3 + .../freeFunctions/free_function_modifier.sol | 4 + .../free_function_qualified_modifier.sol | 9 ++ .../freeFunctions/free_function_shadowing.sol | 9 ++ .../free_function_visibility.sol | 5 + .../free_function_without_body.sol | 3 + .../freeFunctions/free_functions.sol | 4 + .../freeFunctions/free_mutability.sol | 8 ++ .../freeFunctions/free_overload.sol | 9 ++ .../freeFunctions/free_override.sol | 4 + .../freeFunctions/free_payable.sol | 4 + .../freeFunctions/free_receive.sol | 3 + .../freeFunctions/free_storage.sol | 4 + .../freeFunctions/free_virtual.sol | 4 + .../function_same_name_as_contract.sol | 4 + .../function_using_struct_after_contract.sol | 6 ++ .../syntaxTests/freeFunctions/gas_value.sol | 6 ++ .../freeFunctions/qualified_struct_access.sol | 7 ++ .../freeFunctions/struct_after_function.sol | 3 + .../freeFunctions/super_in_free_function.sol | 6 ++ .../freeFunctions/this_in_free_function.sol | 6 ++ .../imports/importing_free_functions.sol | 14 +++ 51 files changed, 481 insertions(+), 73 deletions(-) create mode 100644 test/libsolidity/semanticTests/freeFunctions/easy.sol create mode 100644 test/libsolidity/semanticTests/freeFunctions/free_runtimecode.sol create mode 100644 test/libsolidity/semanticTests/freeFunctions/import.sol create mode 100644 test/libsolidity/semanticTests/freeFunctions/libraries_from_free.sol create mode 100644 test/libsolidity/semanticTests/freeFunctions/new_operator.sol create mode 100644 test/libsolidity/semanticTests/freeFunctions/overloads.sol create mode 100644 test/libsolidity/semanticTests/freeFunctions/recursion.sol create mode 100644 test/libsolidity/semanticTests/freeFunctions/storage_calldata_refs.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_call_via_contract_type.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_constructor.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_fallback.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_function_modifier.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_function_qualified_modifier.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_function_shadowing.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_function_visibility.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_function_without_body.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_functions.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_mutability.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_overload.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_override.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_payable.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_receive.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_storage.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/free_virtual.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/function_same_name_as_contract.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/function_using_struct_after_contract.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/gas_value.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/qualified_struct_access.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/struct_after_function.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/super_in_free_function.sol create mode 100644 test/libsolidity/syntaxTests/freeFunctions/this_in_free_function.sol create mode 100644 test/libsolidity/syntaxTests/imports/importing_free_functions.sol diff --git a/libsolidity/analysis/GlobalContext.cpp b/libsolidity/analysis/GlobalContext.cpp index 885ae49a7..dee7e8220 100644 --- a/libsolidity/analysis/GlobalContext.cpp +++ b/libsolidity/analysis/GlobalContext.cpp @@ -134,15 +134,26 @@ vector GlobalContext::declarations() const MagicVariableDeclaration const* GlobalContext::currentThis() const { if (!m_thisPointer[m_currentContract]) - m_thisPointer[m_currentContract] = make_shared(magicVariableToID("this"), "this", TypeProvider::contract(*m_currentContract)); + { + Type const* type = TypeProvider::emptyTuple(); + if (m_currentContract) + type = TypeProvider::contract(*m_currentContract); + m_thisPointer[m_currentContract] = + make_shared(magicVariableToID("this"), "this", type); + } return m_thisPointer[m_currentContract].get(); - } MagicVariableDeclaration const* GlobalContext::currentSuper() const { if (!m_superPointer[m_currentContract]) - m_superPointer[m_currentContract] = make_shared(magicVariableToID("super"), "super", TypeProvider::contract(*m_currentContract, true)); + { + Type const* type = TypeProvider::emptyTuple(); + if (m_currentContract) + type = TypeProvider::contract(*m_currentContract, true); + m_superPointer[m_currentContract] = + make_shared(magicVariableToID("super"), "super", type); + } return m_superPointer[m_currentContract].get(); } diff --git a/libsolidity/analysis/GlobalContext.h b/libsolidity/analysis/GlobalContext.h index b84e3a026..191359c60 100644 --- a/libsolidity/analysis/GlobalContext.h +++ b/libsolidity/analysis/GlobalContext.h @@ -46,6 +46,7 @@ class GlobalContext: private boost::noncopyable public: GlobalContext(); void setCurrentContract(ContractDefinition const& _contract); + void resetCurrentContract() { m_currentContract = nullptr; } MagicVariableDeclaration const* currentThis() const; MagicVariableDeclaration const* currentSuper() const; diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index c7be364a3..957046810 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -275,6 +275,12 @@ bool NameAndTypeResolver::resolveNamesAndTypesInternal(ASTNode& _node, bool _res if (!resolveNamesAndTypesInternal(*node, true)) success = false; } + + // make "this" and "super" invisible. + m_scopes[nullptr]->registerDeclaration(*m_globalContext.currentThis(), nullptr, true, true); + m_scopes[nullptr]->registerDeclaration(*m_globalContext.currentSuper(), nullptr, true, true); + m_globalContext.resetCurrentContract(); + return success; } else @@ -548,6 +554,10 @@ bool DeclarationRegistrationHelper::visit(ContractDefinition& _contract) void DeclarationRegistrationHelper::endVisit(ContractDefinition&) { + // make "this" and "super" invisible. + m_scopes[nullptr]->registerDeclaration(*m_globalContext.currentThis(), nullptr, true, true); + m_scopes[nullptr]->registerDeclaration(*m_globalContext.currentSuper(), nullptr, true, true); + m_globalContext.resetCurrentContract(); m_currentContract = nullptr; closeCurrentScope(); } diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp index cd932cf6d..a6d797910 100644 --- a/libsolidity/analysis/StaticAnalyzer.cpp +++ b/libsolidity/analysis/StaticAnalyzer.cpp @@ -311,6 +311,7 @@ bool StaticAnalyzer::visit(FunctionCall const& _functionCall) ); } if ( + m_currentContract && m_currentContract->isLibrary() && functionType->kind() == FunctionType::Kind::DelegateCall && functionType->declaration().scope() == m_currentContract diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index c0380ffe5..a47d522d9 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -295,7 +295,7 @@ bool SyntaxChecker::visit(PlaceholderStatement const&) bool SyntaxChecker::visit(ContractDefinition const& _contract) { - m_isInterface = _contract.isInterface(); + m_currentContractKind = _contract.contractKind(); ASTString const& contractName = _contract.name(); for (FunctionDefinition const* function: _contract.definedFunctions()) @@ -309,19 +309,41 @@ bool SyntaxChecker::visit(ContractDefinition const& _contract) return true; } +void SyntaxChecker::endVisit(ContractDefinition const&) +{ + m_currentContractKind = std::nullopt; +} + bool SyntaxChecker::visit(FunctionDefinition const& _function) { - if (!_function.isConstructor() && _function.noVisibilitySpecified()) + solAssert(_function.isFree() == (m_currentContractKind == std::nullopt), ""); + + if (!_function.isFree() && !_function.isConstructor() && _function.noVisibilitySpecified()) { - string suggestedVisibility = _function.isFallback() || _function.isReceive() || m_isInterface ? "external" : "public"; + string suggestedVisibility = + _function.isFallback() || + _function.isReceive() || + m_currentContractKind == ContractKind::Interface + ? "external" : "public"; m_errorReporter.syntaxError( 4937_error, _function.location(), "No visibility specified. Did you intend to add \"" + suggestedVisibility + "\"?" ); } + else if (_function.isFree()) + { + if (!_function.noVisibilitySpecified()) + m_errorReporter.syntaxError( + 4126_error, + _function.location(), + "Free functions cannot have visibility." + ); + if (!_function.isImplemented()) + m_errorReporter.typeError(4668_error, _function.location(), "Free functions must be implemented."); + } - if (m_isInterface && !_function.modifiers().empty()) + if (m_currentContractKind == ContractKind::Interface && !_function.modifiers().empty()) m_errorReporter.syntaxError(5842_error, _function.location(), "Functions in interfaces cannot have modifiers."); else if (!_function.isImplemented() && !_function.modifiers().empty()) m_errorReporter.syntaxError(2668_error, _function.location(), "Functions without implementation cannot have modifiers."); diff --git a/libsolidity/analysis/SyntaxChecker.h b/libsolidity/analysis/SyntaxChecker.h index 1ace2f36a..a5b786e34 100644 --- a/libsolidity/analysis/SyntaxChecker.h +++ b/libsolidity/analysis/SyntaxChecker.h @@ -83,6 +83,7 @@ private: bool visit(PlaceholderStatement const& _placeholderStatement) override; bool visit(ContractDefinition const& _contract) override; + void endVisit(ContractDefinition const& _contract) override; bool visit(FunctionDefinition const& _function) override; bool visit(FunctionTypeName const& _node) override; @@ -102,7 +103,7 @@ private: bool m_versionPragmaFound = false; int m_inLoopDepth = 0; - bool m_isInterface = false; + std::optional m_currentContractKind; SourceUnit const* m_sourceUnit = nullptr; }; diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 8ebc76291..28f2b4152 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -271,6 +271,7 @@ void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance) { auto base = dynamic_cast(&dereference(_inheritance.name())); solAssert(base, "Base contract not available."); + solAssert(m_currentContract, ""); if (m_currentContract->isInterface() && !base->isInterface()) m_errorReporter.typeError(6536_error, _inheritance.location(), "Interfaces can only inherit from other interfaces."); @@ -327,7 +328,9 @@ bool TypeChecker::visit(FunctionDefinition const& _function) { if (_function.markedVirtual()) { - if (_function.isConstructor()) + if (_function.isFree()) + m_errorReporter.syntaxError(4493_error, _function.location(), "Free functions cannot be virtual."); + else if (_function.isConstructor()) m_errorReporter.typeError(7001_error, _function.location(), "Constructors cannot be virtual."); else if (_function.annotation().contract->isInterface()) m_errorReporter.warning(5815_error, _function.location(), "Interface functions are implicitly \"virtual\""); @@ -336,12 +339,16 @@ bool TypeChecker::visit(FunctionDefinition const& _function) else if (_function.libraryFunction()) m_errorReporter.typeError(7801_error, _function.location(), "Library functions cannot be \"virtual\"."); } + if (_function.overrides() && _function.isFree()) + m_errorReporter.syntaxError(1750_error, _function.location(), "Free functions cannot override."); if (_function.isPayable()) { if (_function.libraryFunction()) m_errorReporter.typeError(7708_error, _function.location(), "Library functions cannot be payable."); - if (_function.isOrdinary() && !_function.isPartOfExternalInterface()) + else if (_function.isFree()) + m_errorReporter.typeError(9559_error, _function.location(), "Free functions cannot be payable."); + else if (_function.isOrdinary() && !_function.isPartOfExternalInterface()) m_errorReporter.typeError(5587_error, _function.location(), "\"internal\" and \"private\" functions cannot be payable."); } @@ -415,9 +422,13 @@ bool TypeChecker::visit(FunctionDefinition const& _function) set modifiers; for (ASTPointer const& modifier: _function.modifiers()) { - auto baseContracts = dynamic_cast(*_function.scope()).annotation().linearizedBaseContracts; - // Delete first base which is just the main contract itself - baseContracts.erase(baseContracts.begin()); + vector baseContracts; + if (auto contract = dynamic_cast(_function.scope())) + { + baseContracts = contract->annotation().linearizedBaseContracts; + // Delete first base which is just the main contract itself + baseContracts.erase(baseContracts.begin()); + } visitManually( *modifier, @@ -432,7 +443,15 @@ bool TypeChecker::visit(FunctionDefinition const& _function) else modifiers.insert(decl); } - if (m_currentContract->isInterface()) + + solAssert(_function.isFree() == !m_currentContract, ""); + if (!m_currentContract) + { + solAssert(!_function.isConstructor(), ""); + solAssert(!_function.isFallback(), ""); + solAssert(!_function.isReceive(), ""); + } + else if (m_currentContract->isInterface()) { if (_function.isImplemented()) m_errorReporter.typeError(4726_error, _function.location(), "Functions in interfaces cannot have an implementation."); @@ -445,6 +464,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function) else if (m_currentContract->contractKind() == ContractKind::Library) if (_function.isConstructor()) m_errorReporter.typeError(7634_error, _function.location(), "Constructor cannot be defined in libraries."); + if (_function.isImplemented()) _function.body().accept(*this); else if (_function.isConstructor()) @@ -452,7 +472,12 @@ bool TypeChecker::visit(FunctionDefinition const& _function) else if (_function.libraryFunction()) m_errorReporter.typeError(9231_error, _function.location(), "Library functions must be implemented if declared."); else if (!_function.virtualSemantics()) - m_errorReporter.typeError(5424_error, _function.location(), "Functions without implementation must be marked virtual."); + { + if (_function.isFree()) + solAssert(m_errorReporter.hasErrors(), ""); + else + m_errorReporter.typeError(5424_error, _function.location(), "Functions without implementation must be marked virtual."); + } if (_function.isFallback()) @@ -1726,7 +1751,9 @@ void TypeChecker::typeCheckFunctionCall( if (_functionType->kind() == FunctionType::Kind::Declaration) { + solAssert(_functionType->declaration().annotation().contract, ""); if ( + m_currentContract && m_currentContract->derivesFrom(*_functionType->declaration().annotation().contract) && !dynamic_cast(_functionType->declaration()).isImplemented() ) @@ -2454,18 +2481,23 @@ void TypeChecker::endVisit(NewExpression const& _newExpression) if (contract->abstract()) m_errorReporter.typeError(4614_error, _newExpression.location(), "Cannot instantiate an abstract contract."); - solAssert(!!m_currentContract, ""); - m_currentContract->annotation().contractDependencies.insert(contract); - solAssert( - !contract->annotation().linearizedBaseContracts.empty(), - "Linearized base contracts not yet available." - ); - if (contractDependenciesAreCyclic(*m_currentContract)) - m_errorReporter.typeError( - 4579_error, - _newExpression.location(), - "Circular reference for contract creation (cannot create instance of derived or same contract)." + if (m_currentContract) + { + // TODO this is not properly detecting creation-cycles if they go through + // internal library functions or free functions. It will be caught at + // code generation time, but it would of course be better to catch it here. + m_currentContract->annotation().contractDependencies.insert(contract); + solAssert( + !contract->annotation().linearizedBaseContracts.empty(), + "Linearized base contracts not yet available." ); + if (contractDependenciesAreCyclic(*m_currentContract)) + m_errorReporter.typeError( + 4579_error, + _newExpression.location(), + "Circular reference for contract creation (cannot create instance of derived or same contract)." + ); + } _newExpression.annotation().type = FunctionType::newExpressionType(*contract); } @@ -2507,7 +2539,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) // Retrieve the types of the arguments if this is used to call a function. auto const& arguments = _memberAccess.annotation().arguments; - MemberList::MemberMap possibleMembers = exprType->members(m_currentContract).membersByName(memberName); + MemberList::MemberMap possibleMembers = exprType->members(currentDefinitionScope()).membersByName(memberName); size_t const initialMemberCount = possibleMembers.size(); if (initialMemberCount > 1 && arguments) { @@ -2533,7 +2565,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) DataLocation::Storage, exprType ); - if (!storageType->members(m_currentContract).membersByName(memberName).empty()) + if (!storageType->members(currentDefinitionScope()).membersByName(memberName).empty()) m_errorReporter.fatalTypeError( 4994_error, _memberAccess.location(), @@ -2691,8 +2723,6 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) { annotation.isPure = true; ContractType const& accessedContractType = dynamic_cast(*magicType->typeArgument()); - m_currentContract->annotation().contractDependencies.insert(&accessedContractType.contractDefinition()); - if ( memberName == "runtimeCode" && !accessedContractType.immutableVariables().empty() @@ -2703,12 +2733,21 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) "\"runtimeCode\" is not available for contracts containing immutable variables." ); - if (contractDependenciesAreCyclic(*m_currentContract)) - m_errorReporter.typeError( - 4224_error, - _memberAccess.location(), - "Circular reference for contract code access." - ); + if (m_currentContract) + { + // TODO in the same way as with ``new``, + // this is not properly detecting creation-cycles if they go through + // internal library functions or free functions. It will be caught at + // code generation time, but it would of course be better to catch it here. + + m_currentContract->annotation().contractDependencies.insert(&accessedContractType.contractDefinition()); + if (contractDependenciesAreCyclic(*m_currentContract)) + m_errorReporter.typeError( + 4224_error, + _memberAccess.location(), + "Circular reference for contract code access." + ); + } } else if (magicType->kind() == MagicType::Kind::MetaType && memberName == "name") annotation.isPure = true; diff --git a/libsolidity/analysis/TypeChecker.h b/libsolidity/analysis/TypeChecker.h index e34c9e9d0..87ae1d83c 100644 --- a/libsolidity/analysis/TypeChecker.h +++ b/libsolidity/analysis/TypeChecker.h @@ -167,6 +167,16 @@ private: bool experimentalFeatureActive(ExperimentalFeature _feature) const; + /// @returns the current scope that can have function or type definitions. + /// This is either a contract or a source unit. + ASTNode const* currentDefinitionScope() const + { + if (m_currentContract) + return m_currentContract; + else + return m_currentSourceUnit; + } + SourceUnit const* m_currentSourceUnit = nullptr; ContractDefinition const* m_currentContract = nullptr; diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp index a1bf31d77..1bf6028e5 100644 --- a/libsolidity/analysis/ViewPureChecker.cpp +++ b/libsolidity/analysis/ViewPureChecker.cpp @@ -128,30 +128,23 @@ private: bool ViewPureChecker::check() { - vector contracts; + // Process modifiers first to infer their state mutability. + m_checkModifiers = true; + for (auto const& source: m_ast) + source->accept(*this); - for (auto const& node: m_ast) - { - SourceUnit const* source = dynamic_cast(node.get()); - solAssert(source, ""); - contracts += source->filteredNodes(source->nodes()); - } - - // Check modifiers first to infer their state mutability. - for (auto const& contract: contracts) - for (ModifierDefinition const* mod: contract->functionModifiers()) - mod->accept(*this); - - for (auto const& contract: contracts) - contract->accept(*this); + m_checkModifiers = false; + for (auto const& source: m_ast) + source->accept(*this); return !m_errors; } - - bool ViewPureChecker::visit(FunctionDefinition const& _funDef) { + if (m_checkModifiers) + return false; + solAssert(!m_currentFunction, ""); m_currentFunction = &_funDef; m_bestMutabilityAndLocation = {StateMutability::Pure, _funDef.location()}; @@ -160,6 +153,9 @@ bool ViewPureChecker::visit(FunctionDefinition const& _funDef) void ViewPureChecker::endVisit(FunctionDefinition const& _funDef) { + if (m_checkModifiers) + return; + solAssert(m_currentFunction == &_funDef, ""); if ( m_bestMutabilityAndLocation.mutability < _funDef.stateMutability() && @@ -181,6 +177,9 @@ void ViewPureChecker::endVisit(FunctionDefinition const& _funDef) bool ViewPureChecker::visit(ModifierDefinition const& _modifier) { + if (!m_checkModifiers) + return false; + solAssert(m_currentFunction == nullptr, ""); m_bestMutabilityAndLocation = {StateMutability::Pure, _modifier.location()}; return true; @@ -188,6 +187,9 @@ bool ViewPureChecker::visit(ModifierDefinition const& _modifier) void ViewPureChecker::endVisit(ModifierDefinition const& _modifierDef) { + if (!m_checkModifiers) + return; + solAssert(m_currentFunction == nullptr, ""); m_inferredMutability[&_modifierDef] = std::move(m_bestMutabilityAndLocation); } diff --git a/libsolidity/analysis/ViewPureChecker.h b/libsolidity/analysis/ViewPureChecker.h index 87135b4f7..62444e086 100644 --- a/libsolidity/analysis/ViewPureChecker.h +++ b/libsolidity/analysis/ViewPureChecker.h @@ -75,6 +75,7 @@ private: langutil::ErrorReporter& m_errorReporter; bool m_errors = false; + bool m_checkModifiers = false; MutabilityAndLocation m_bestMutabilityAndLocation = MutabilityAndLocation{StateMutability::Payable, langutil::SourceLocation()}; FunctionDefinition const* m_currentFunction = nullptr; std::map m_inferredMutability; diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 662ea81d3..621fb3936 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -338,7 +338,7 @@ TypePointer FunctionDefinition::type() const TypePointer FunctionDefinition::typeViaContractName() const { - if (annotation().contract->isLibrary()) + if (libraryFunction()) { if (isPublic()) return FunctionType(*this).asExternallyCallableFunction(true); @@ -374,7 +374,9 @@ FunctionDefinition const& FunctionDefinition::resolveVirtual( if (_searchStart == nullptr && !virtualSemantics()) return *this; - solAssert(!dynamic_cast(*scope()).isLibrary(), ""); + solAssert(!isFree(), ""); + solAssert(isOrdinary(), ""); + solAssert(!libraryFunction(), ""); FunctionType const* functionType = TypeProvider::function(*this)->asExternallyCallableFunction(false); @@ -603,9 +605,8 @@ bool VariableDeclaration::isLibraryFunctionParameter() const if (!isCallableOrCatchParameter()) return false; if (auto const* funDef = dynamic_cast(scope())) - return dynamic_cast(*funDef->scope()).isLibrary(); - else - return false; + return funDef->libraryFunction(); + return false; } bool VariableDeclaration::isEventParameter() const diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 28d71c2b7..8b4025a45 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -774,6 +774,7 @@ public: ASTPointer const& _name, Visibility _visibility, StateMutability _stateMutability, + bool _free, Token _kind, bool _isVirtual, ASTPointer const& _overrides, @@ -787,6 +788,7 @@ public: StructurallyDocumented(_documentation), ImplementationOptional(_body != nullptr), m_stateMutability(_stateMutability), + m_free(_free), m_kind(_kind), m_functionModifiers(std::move(_modifiers)), m_body(_body) @@ -804,6 +806,7 @@ public: bool isConstructor() const { return m_kind == Token::Constructor; } bool isFallback() const { return m_kind == Token::Fallback; } bool isReceive() const { return m_kind == Token::Receive; } + bool isFree() const { return m_free; } Token kind() const { return m_kind; } bool isPayable() const { return m_stateMutability == StateMutability::Payable; } std::vector> const& modifiers() const { return m_functionModifiers; } @@ -815,6 +818,7 @@ public: } bool isVisibleViaContractTypeAccess() const override { + solAssert(!isFree(), ""); return isOrdinary() && visibility() >= Visibility::Public; } bool isPartOfExternalInterface() const override { return isOrdinary() && isPublic(); } @@ -848,8 +852,12 @@ public: ContractDefinition const* _searchStart = nullptr ) const override; +protected: + Visibility defaultVisibility() const override { return isFree() ? Visibility::Internal : Visibility::Public; } + private: StateMutability m_stateMutability; + bool m_free; Token const m_kind; std::vector> m_functionModifiers; ASTPointer m_body; diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index 1f6e039e3..2aac79837 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -236,9 +236,6 @@ struct UserDefinedTypeNameAnnotation: TypeNameAnnotation { /// Referenced declaration, set during reference resolution stage. Declaration const* referencedDeclaration = nullptr; - /// Stores a reference to the current contract. - /// This is needed because types of base contracts change depending on the context. - ContractDefinition const* contractScope = nullptr; }; struct ExpressionAnnotation: ASTAnnotation diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index 064068005..15ac0c620 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -361,6 +361,7 @@ bool ASTJsonConverter::visit(FunctionDefinition const& _node) make_pair("name", _node.name()), make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json::nullValue), make_pair("kind", TokenTraits::toString(_node.kind())), + make_pair("freeFunction", _node.isFree()), make_pair("stateMutability", stateMutabilityToString(_node.stateMutability())), make_pair("visibility", Declaration::visibilityToString(visibility)), make_pair("virtual", _node.markedVirtual()), @@ -467,7 +468,6 @@ bool ASTJsonConverter::visit(UserDefinedTypeName const& _node) setJsonNode(_node, "UserDefinedTypeName", { make_pair("name", namePathToString(_node.namePath())), make_pair("referencedDeclaration", idOrNull(_node.annotation().referencedDeclaration)), - make_pair("contractScope", idOrNull(_node.annotation().contractScope)), make_pair("typeDescriptions", typePointerToJson(_node.annotation().type, true)) }); return false; diff --git a/libsolidity/ast/ASTJsonImporter.cpp b/libsolidity/ast/ASTJsonImporter.cpp index 2d1fda322..8bc657abf 100644 --- a/libsolidity/ast/ASTJsonImporter.cpp +++ b/libsolidity/ast/ASTJsonImporter.cpp @@ -397,11 +397,25 @@ ASTPointer ASTJsonImporter::createFunctionDefinition(Json::V std::vector> modifiers; for (auto& mod: member(_node, "modifiers")) modifiers.push_back(createModifierInvocation(mod)); + + Visibility vis = Visibility::Default; + bool const freeFunction = _node.isMember("freeFunction") ? _node["freeFunction"].asBool() : false; + if (kind == Token::Constructor) + { + } + else if (freeFunction) + astAssert( + vis == Visibility::Internal || vis == Visibility::Default, + "Expected internal or default visibility for free function." + ); + else + vis = visibility(_node); return createASTNode( _node, memberAsASTString(_node, "name"), - kind == Token::Constructor ? Visibility::Default : visibility(_node), + vis, stateMutability(_node), + freeFunction, kind, memberAsBool(_node, "virtual"), _node["overrides"].isNull() ? nullptr : createOverrideSpecifier(member(_node, "overrides")), diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index a87ae4c3f..956412425 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -3151,10 +3151,8 @@ string FunctionType::toString(bool _short) const { auto const* functionDefinition = dynamic_cast(m_declaration); solAssert(functionDefinition, ""); - auto const* contract = dynamic_cast(functionDefinition->scope()); - solAssert(contract, ""); - name += contract->annotation().canonicalName; - name += '.'; + if (auto const* contract = dynamic_cast(functionDefinition->scope())) + name += contract->annotation().canonicalName + "."; name += functionDefinition->name(); } name += '('; @@ -3275,7 +3273,10 @@ FunctionTypePointer FunctionType::interfaceFunctionType() const { // Note that m_declaration might also be a state variable! solAssert(m_declaration, "Declaration needed to determine interface function type."); - bool isLibraryFunction = kind() != Kind::Event && dynamic_cast(*m_declaration->scope()).isLibrary(); + bool isLibraryFunction = false; + if (kind() != Kind::Event) + if (auto const* contract = dynamic_cast(m_declaration->scope())) + isLibraryFunction = contract->isLibrary(); util::Result paramTypes = transformParametersToExternal(m_parameterTypes, isLibraryFunction); @@ -3569,7 +3570,10 @@ string FunctionType::externalSignature() const } // "inLibrary" is only relevant if this is not an event. - bool const inLibrary = kind() != Kind::Event && dynamic_cast(*m_declaration->scope()).isLibrary(); + bool inLibrary = false; + if (kind() != Kind::Event) + if (auto const* contract = dynamic_cast(m_declaration->scope())) + inLibrary = contract->isLibrary(); auto extParams = transformParametersToExternal(m_parameterTypes, inLibrary); diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 8b834031f..d4f70691f 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1736,9 +1736,17 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) Type::Category category = _memberAccess.annotation().type->category(); solAssert( category == Type::Category::TypeType || - category == Type::Category::Module, + category == Type::Category::Module || + category == Type::Category::Function, "" ); + if (auto funType = dynamic_cast(_memberAccess.annotation().type)) + { + auto const* funDef = dynamic_cast(_memberAccess.annotation().referencedDeclaration); + solAssert(funDef && funDef->isFree(), ""); + solAssert(funType->kind() == FunctionType::Kind::Internal, ""); + utils().pushCombinedFunctionEntryLabel(*funDef); + } break; } default: diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index cfb7de46e..47be4039a 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -107,8 +107,11 @@ ASTPointer Parser::parse(shared_ptr const& _scanner) case Token::Enum: nodes.push_back(parseEnumDefinition()); break; + case Token::Function: + nodes.push_back(parseFunctionDefinition(true)); + break; default: - fatalParserError(7858_error, "Expected pragma, import directive or contract/interface/library/struct/enum definition."); + fatalParserError(7858_error, "Expected pragma, import directive or contract/interface/library/struct/enum/function definition."); } } solAssert(m_recursionDepth == 0, ""); @@ -548,7 +551,7 @@ Parser::FunctionHeaderParserResult Parser::parseFunctionHeader(bool _isStateVari return result; } -ASTPointer Parser::parseFunctionDefinition() +ASTPointer Parser::parseFunctionDefinition(bool _freeFunction) { RecursionGuard recursionGuard(*this); ASTNodeFactory nodeFactory(*this); @@ -607,6 +610,7 @@ ASTPointer Parser::parseFunctionDefinition() name, header.visibility, header.stateMutability, + _freeFunction, kind, header.isVirtual, header.overrides, diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h index b769545da..0047ed6e4 100644 --- a/libsolidity/parsing/Parser.h +++ b/libsolidity/parsing/Parser.h @@ -92,7 +92,7 @@ private: ASTPointer parseOverrideSpecifier(); StateMutability parseStateMutability(); FunctionHeaderParserResult parseFunctionHeader(bool _isStateVariable); - ASTPointer parseFunctionDefinition(); + ASTPointer parseFunctionDefinition(bool _freeFunction = false); ASTPointer parseStructDefinition(); ASTPointer parseEnumDefinition(); ASTPointer parseEnumValue(); diff --git a/test/libsolidity/semanticTests/freeFunctions/easy.sol b/test/libsolidity/semanticTests/freeFunctions/easy.sol new file mode 100644 index 000000000..04b023d52 --- /dev/null +++ b/test/libsolidity/semanticTests/freeFunctions/easy.sol @@ -0,0 +1,13 @@ +function add(uint a, uint b) pure returns (uint) { + return a + b; +} + +contract C { + function f(uint x) public pure returns (uint) { + return add(x, 2); + } +} +// ==== +// compileViaYul: also +// ---- +// f(uint256): 7 -> 9 diff --git a/test/libsolidity/semanticTests/freeFunctions/free_runtimecode.sol b/test/libsolidity/semanticTests/freeFunctions/free_runtimecode.sol new file mode 100644 index 000000000..7a05ff5d0 --- /dev/null +++ b/test/libsolidity/semanticTests/freeFunctions/free_runtimecode.sol @@ -0,0 +1,15 @@ +contract C { + uint public x = 2; +} + +function test() returns (bool) { + return type(C).runtimeCode.length > 20; +} + +contract D { + function f() public returns (bool) { + return test(); + } +} +// ---- +// f() -> true diff --git a/test/libsolidity/semanticTests/freeFunctions/import.sol b/test/libsolidity/semanticTests/freeFunctions/import.sol new file mode 100644 index 000000000..edd44de49 --- /dev/null +++ b/test/libsolidity/semanticTests/freeFunctions/import.sol @@ -0,0 +1,18 @@ +==== Source: A ==== +struct S { uint x; } +function set(S storage a, uint v) { a.x = v; } + +==== Source: B ==== +import "A"; +import "A" as A; +contract C { + A.S data; + function f(uint v) public returns (uint one, uint two) { + A.set(data, v); + one = data.x; + set(data, v + 1); + two = data.x; + } +} +// ---- +// f(uint256): 7 -> 7, 8 diff --git a/test/libsolidity/semanticTests/freeFunctions/libraries_from_free.sol b/test/libsolidity/semanticTests/freeFunctions/libraries_from_free.sol new file mode 100644 index 000000000..3632f6a6a --- /dev/null +++ b/test/libsolidity/semanticTests/freeFunctions/libraries_from_free.sol @@ -0,0 +1,21 @@ +library L { + function pub() public pure returns (uint) { + return 7; + } + function inter() internal pure returns (uint) { + return 8; + } +} + +function fu() pure returns (uint, uint) { + return (L.pub(), L.inter()); +} + +contract C { + function f() public pure returns (uint, uint) { + return fu(); + } +} +// ---- +// library: L +// f() -> 7, 8 \ No newline at end of file diff --git a/test/libsolidity/semanticTests/freeFunctions/new_operator.sol b/test/libsolidity/semanticTests/freeFunctions/new_operator.sol new file mode 100644 index 000000000..e35f1c9ea --- /dev/null +++ b/test/libsolidity/semanticTests/freeFunctions/new_operator.sol @@ -0,0 +1,15 @@ +contract C { + uint public x = 2; +} + +function test() returns (uint) { + return (new C()).x(); +} + +contract D { + function f() public returns (uint) { + return test(); + } +} +// ---- +// f() -> 2 diff --git a/test/libsolidity/semanticTests/freeFunctions/overloads.sol b/test/libsolidity/semanticTests/freeFunctions/overloads.sol new file mode 100644 index 000000000..9b2a914eb --- /dev/null +++ b/test/libsolidity/semanticTests/freeFunctions/overloads.sol @@ -0,0 +1,16 @@ +function f(uint) returns (uint) { + return 2; +} +function f(string memory) returns (uint) { + return 3; +} + +contract C { + function g() public returns (uint, uint) { + return (f(2), f("abc")); + } +} +// ==== +// compileViaYul: also +// ---- +// g() -> 2, 3 diff --git a/test/libsolidity/semanticTests/freeFunctions/recursion.sol b/test/libsolidity/semanticTests/freeFunctions/recursion.sol new file mode 100644 index 000000000..fd21fe097 --- /dev/null +++ b/test/libsolidity/semanticTests/freeFunctions/recursion.sol @@ -0,0 +1,23 @@ +function exp(uint base, uint exponent) pure returns (uint power) { + if (exponent == 0) + return 1; + power = exp(base, exponent / 2); + power *= power; + if (exponent & 1 == 1) + power *= base; +} + +contract C { + function g(uint base, uint exponent) public pure returns (uint) { + return exp(base, exponent); + } +} +// ==== +// compileViaYul: also +// ---- +// g(uint256,uint256): 0, 0 -> 1 +// g(uint256,uint256): 0, 1 -> 0x00 +// g(uint256,uint256): 1, 0 -> 1 +// g(uint256,uint256): 2, 3 -> 8 +// g(uint256,uint256): 3, 10 -> 59049 +// g(uint256,uint256): 2, 255 -> -57896044618658097711785492504343953926634992332820282019728792003956564819968 \ No newline at end of file diff --git a/test/libsolidity/semanticTests/freeFunctions/storage_calldata_refs.sol b/test/libsolidity/semanticTests/freeFunctions/storage_calldata_refs.sol new file mode 100644 index 000000000..3b94b06fc --- /dev/null +++ b/test/libsolidity/semanticTests/freeFunctions/storage_calldata_refs.sol @@ -0,0 +1,17 @@ +contract C { + uint[] data; + function f(uint x, uint[] calldata input) public returns (uint, uint) { + data.push(x); + (uint a, uint[] calldata b) = fun(input, data); + return (a, b[1]); + + } +} + +function fun(uint[] calldata _x, uint[] storage _y) view returns (uint, uint[] calldata) { + return (_y[0], _x); +} +// ==== +// compileViaYul: also +// ---- +// f(uint256,uint256[]): 7, 0x40, 3, 8, 9, 10 -> 7, 9 diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_call_via_contract_type.sol b/test/libsolidity/syntaxTests/freeFunctions/free_call_via_contract_type.sol new file mode 100644 index 000000000..749a98d48 --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_call_via_contract_type.sol @@ -0,0 +1,8 @@ +contract C { + function f() public pure {} +} +function fun() { + C.f(); +} +// ---- +// TypeError 3419: (68-73): Cannot call function via contract type name. diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_constructor.sol b/test/libsolidity/syntaxTests/freeFunctions/free_constructor.sol new file mode 100644 index 000000000..afb375ca0 --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_constructor.sol @@ -0,0 +1,3 @@ +constructor() {} +// ---- +// ParserError 7858: (0-11): Expected pragma, import directive or contract/interface/library/struct/enum/function definition. diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_fallback.sol b/test/libsolidity/syntaxTests/freeFunctions/free_fallback.sol new file mode 100644 index 000000000..31b410211 --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_fallback.sol @@ -0,0 +1,3 @@ +fallback(){} +// ---- +// ParserError 7858: (0-8): Expected pragma, import directive or contract/interface/library/struct/enum/function definition. diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_function_modifier.sol b/test/libsolidity/syntaxTests/freeFunctions/free_function_modifier.sol new file mode 100644 index 000000000..dd702853a --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_function_modifier.sol @@ -0,0 +1,4 @@ +function fun() someModifier { +} +// ---- +// DeclarationError 7576: (15-27): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_function_qualified_modifier.sol b/test/libsolidity/syntaxTests/freeFunctions/free_function_qualified_modifier.sol new file mode 100644 index 000000000..779d44c72 --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_function_qualified_modifier.sol @@ -0,0 +1,9 @@ +contract C { + modifier someModifier() { _; } +} + +function fun() C.someModifier { + +} +// ---- +// ParserError 2314: (65-66): Expected '{' but got '.' diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_function_shadowing.sol b/test/libsolidity/syntaxTests/freeFunctions/free_function_shadowing.sol new file mode 100644 index 000000000..bd1b2bd87 --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_function_shadowing.sol @@ -0,0 +1,9 @@ +function f() {} +contract C { + function f() public {} + function g() public { + f(); + } +} +// ---- +// Warning 2519: (31-53): This declaration shadows an existing declaration. diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_function_visibility.sol b/test/libsolidity/syntaxTests/freeFunctions/free_function_visibility.sol new file mode 100644 index 000000000..36a0e0e0c --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_function_visibility.sol @@ -0,0 +1,5 @@ +function fun1() public { } +function fun2() internal { } +// ---- +// SyntaxError 4126: (0-26): Free functions cannot have visibility. +// SyntaxError 4126: (27-55): Free functions cannot have visibility. diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_function_without_body.sol b/test/libsolidity/syntaxTests/freeFunctions/free_function_without_body.sol new file mode 100644 index 000000000..2fec9db1d --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_function_without_body.sol @@ -0,0 +1,3 @@ +function f(); +// ---- +// TypeError 4668: (0-13): Free functions must be implemented. diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_functions.sol b/test/libsolidity/syntaxTests/freeFunctions/free_functions.sol new file mode 100644 index 000000000..4862e8e63 --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_functions.sol @@ -0,0 +1,4 @@ +function fun(uint256, uint[] calldata _x, uint[] storage _y) view returns (uint, uint[] calldata) { + return (_y[0], _x); +} +// ---- diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_mutability.sol b/test/libsolidity/syntaxTests/freeFunctions/free_mutability.sol new file mode 100644 index 000000000..dafa91ccb --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_mutability.sol @@ -0,0 +1,8 @@ +function f() { + uint x = 2; + x; +} +function g(uint[] storage x) pure { x[0] = 1; } +// ---- +// Warning 2018: (0-39): Function state mutability can be restricted to pure +// TypeError 8961: (76-80): Function declared as pure, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_overload.sol b/test/libsolidity/syntaxTests/freeFunctions/free_overload.sol new file mode 100644 index 000000000..440b9449f --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_overload.sol @@ -0,0 +1,9 @@ +function f(uint) returns (bytes memory) {} +function f(uint[] memory x) returns (bytes memory) { return f(x[0]); } +function g(uint8) {} +function g(uint16) {} +function t() { + g(2); +} +// ---- +// TypeError 4487: (176-177): No unique declaration found after argument-dependent lookup. diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_override.sol b/test/libsolidity/syntaxTests/freeFunctions/free_override.sol new file mode 100644 index 000000000..da54a2fa6 --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_override.sol @@ -0,0 +1,4 @@ +function fun() override { +} +// ---- +// SyntaxError 1750: (0-27): Free functions cannot override. diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_payable.sol b/test/libsolidity/syntaxTests/freeFunctions/free_payable.sol new file mode 100644 index 000000000..563c118f0 --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_payable.sol @@ -0,0 +1,4 @@ +function fun() payable { +} +// ---- +// TypeError 9559: (0-26): Free functions cannot be payable. diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_receive.sol b/test/libsolidity/syntaxTests/freeFunctions/free_receive.sol new file mode 100644 index 000000000..5801b9e9e --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_receive.sol @@ -0,0 +1,3 @@ +receive() {} +// ---- +// ParserError 7858: (0-7): Expected pragma, import directive or contract/interface/library/struct/enum/function definition. diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_storage.sol b/test/libsolidity/syntaxTests/freeFunctions/free_storage.sol new file mode 100644 index 000000000..7d356a9a7 --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_storage.sol @@ -0,0 +1,4 @@ +struct S { uint x; } +function fun(S storage) { +} +// ---- diff --git a/test/libsolidity/syntaxTests/freeFunctions/free_virtual.sol b/test/libsolidity/syntaxTests/freeFunctions/free_virtual.sol new file mode 100644 index 000000000..a4261be1f --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/free_virtual.sol @@ -0,0 +1,4 @@ +function fun() virtual { +} +// ---- +// SyntaxError 4493: (0-26): Free functions cannot be virtual. diff --git a/test/libsolidity/syntaxTests/freeFunctions/function_same_name_as_contract.sol b/test/libsolidity/syntaxTests/freeFunctions/function_same_name_as_contract.sol new file mode 100644 index 000000000..3b16749ae --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/function_same_name_as_contract.sol @@ -0,0 +1,4 @@ +contract C {} +function C() {} +// ---- +// DeclarationError 2333: (14-29): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/freeFunctions/function_using_struct_after_contract.sol b/test/libsolidity/syntaxTests/freeFunctions/function_using_struct_after_contract.sol new file mode 100644 index 000000000..b029c0d90 --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/function_using_struct_after_contract.sol @@ -0,0 +1,6 @@ +contract C { + struct S { uint x; } +} +function f() returns (uint) { S storage t; } +// ---- +// DeclarationError 7920: (70-71): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/freeFunctions/gas_value.sol b/test/libsolidity/syntaxTests/freeFunctions/gas_value.sol new file mode 100644 index 000000000..7e2dafe8a --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/gas_value.sol @@ -0,0 +1,6 @@ +function fun() { + fun{gas: 1}(); + fun{value: 1}(); +} +// ---- +// TypeError 2193: (21-32): Function call options can only be set on external function calls or contract creations. diff --git a/test/libsolidity/syntaxTests/freeFunctions/qualified_struct_access.sol b/test/libsolidity/syntaxTests/freeFunctions/qualified_struct_access.sol new file mode 100644 index 000000000..ab027e21d --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/qualified_struct_access.sol @@ -0,0 +1,7 @@ +function f() returns (uint) { C.S storage t; t.x; } + +contract C { + struct S { uint x; } +} +// ---- +// TypeError 3464: (45-46): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour. diff --git a/test/libsolidity/syntaxTests/freeFunctions/struct_after_function.sol b/test/libsolidity/syntaxTests/freeFunctions/struct_after_function.sol new file mode 100644 index 000000000..c41693e97 --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/struct_after_function.sol @@ -0,0 +1,3 @@ +function f(S storage g) view returns (uint) { S storage t = g; return t.x; } +struct S { uint x; } +// ---- diff --git a/test/libsolidity/syntaxTests/freeFunctions/super_in_free_function.sol b/test/libsolidity/syntaxTests/freeFunctions/super_in_free_function.sol new file mode 100644 index 000000000..ff6061c65 --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/super_in_free_function.sol @@ -0,0 +1,6 @@ +contract C {} +function f() { + super; +} +// ---- +// DeclarationError 7576: (33-38): Undeclared identifier. "super" is not (or not yet) visible at this point. diff --git a/test/libsolidity/syntaxTests/freeFunctions/this_in_free_function.sol b/test/libsolidity/syntaxTests/freeFunctions/this_in_free_function.sol new file mode 100644 index 000000000..cdea708d4 --- /dev/null +++ b/test/libsolidity/syntaxTests/freeFunctions/this_in_free_function.sol @@ -0,0 +1,6 @@ +contract C {} +function f() { + this; +} +// ---- +// DeclarationError 7576: (33-37): Undeclared identifier. "this" is not (or not yet) visible at this point. diff --git a/test/libsolidity/syntaxTests/imports/importing_free_functions.sol b/test/libsolidity/syntaxTests/imports/importing_free_functions.sol new file mode 100644 index 000000000..02bc3673e --- /dev/null +++ b/test/libsolidity/syntaxTests/imports/importing_free_functions.sol @@ -0,0 +1,14 @@ +==== Source: a ==== +function f(uint x) pure returns (uint) { return x * 3; } +==== Source: b ==== +import "a" as A; +function g(uint x) pure returns (uint) { return A.f(x) * 3; } +==== Source: c ==== +import "b" as B; +contract C { + function f() public pure { + B.g(2); + B.A.f(3); + } +} +// ---- From e9f91edc4b6d1298a9ed3506c11362a714bde21f Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 16 Jun 2020 03:35:09 +0200 Subject: [PATCH 2/5] Update existing tests. --- libsolidity/ast/AST.cpp | 2 +- libsolidity/ast/AST.h | 3 --- test/cmdlineTests/recovery_ast_constructor/output | 2 ++ test/cmdlineTests/recovery_ast_empty_contract/err | 2 +- test/cmdlineTests/standard_only_ast_requested/output.json | 2 +- test/libsolidity/ASTJSON/abstract_contract.json | 1 + test/libsolidity/ASTJSON/abstract_contract_legacy.json | 1 + test/libsolidity/ASTJSON/address_payable.json | 1 + test/libsolidity/ASTJSON/address_payable_legacy.json | 1 + test/libsolidity/ASTJSON/assembly/call.json | 1 + test/libsolidity/ASTJSON/assembly/call_legacy.json | 1 + test/libsolidity/ASTJSON/assembly/empty_block.json | 1 + test/libsolidity/ASTJSON/assembly/empty_block_legacy.json | 1 + test/libsolidity/ASTJSON/assembly/function.json | 1 + test/libsolidity/ASTJSON/assembly/function_legacy.json | 1 + test/libsolidity/ASTJSON/assembly/leave.json | 1 + test/libsolidity/ASTJSON/assembly/leave_legacy.json | 1 + test/libsolidity/ASTJSON/assembly/loop.json | 1 + test/libsolidity/ASTJSON/assembly/loop_legacy.json | 1 + test/libsolidity/ASTJSON/assembly/nested_functions.json | 1 + .../ASTJSON/assembly/nested_functions_legacy.json | 1 + test/libsolidity/ASTJSON/assembly/slot_offset.json | 1 + test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json | 1 + test/libsolidity/ASTJSON/assembly/stringlit.json | 1 + test/libsolidity/ASTJSON/assembly/stringlit_legacy.json | 1 + test/libsolidity/ASTJSON/assembly/switch.json | 1 + test/libsolidity/ASTJSON/assembly/switch_default.json | 1 + test/libsolidity/ASTJSON/assembly/switch_default_legacy.json | 1 + test/libsolidity/ASTJSON/assembly/switch_legacy.json | 1 + test/libsolidity/ASTJSON/assembly/var_access.json | 1 + test/libsolidity/ASTJSON/assembly/var_access_legacy.json | 1 + test/libsolidity/ASTJSON/constructor.json | 1 + test/libsolidity/ASTJSON/constructor_legacy.json | 1 + test/libsolidity/ASTJSON/documentation.json | 1 + test/libsolidity/ASTJSON/documentation_legacy.json | 1 + test/libsolidity/ASTJSON/fallback.json | 1 + test/libsolidity/ASTJSON/fallback_and_reveice_ether.json | 2 ++ .../ASTJSON/fallback_and_reveice_ether_legacy.json | 2 ++ test/libsolidity/ASTJSON/fallback_legacy.json | 1 + test/libsolidity/ASTJSON/fallback_payable.json | 1 + test/libsolidity/ASTJSON/fallback_payable_legacy.json | 1 + test/libsolidity/ASTJSON/function_type.json | 1 + test/libsolidity/ASTJSON/function_type_legacy.json | 1 + .../libsolidity/ASTJSON/long_type_name_binary_operation.json | 1 + .../ASTJSON/long_type_name_binary_operation_legacy.json | 1 + test/libsolidity/ASTJSON/long_type_name_identifier.json | 1 + .../ASTJSON/long_type_name_identifier_legacy.json | 1 + test/libsolidity/ASTJSON/modifier_definition.json | 1 + test/libsolidity/ASTJSON/modifier_definition_legacy.json | 1 + test/libsolidity/ASTJSON/modifier_invocation.json | 1 + test/libsolidity/ASTJSON/modifier_invocation_legacy.json | 1 + test/libsolidity/ASTJSON/non_utf8.json | 1 + test/libsolidity/ASTJSON/non_utf8_legacy.json | 1 + test/libsolidity/ASTJSON/override.json | 5 +++++ test/libsolidity/ASTJSON/override_legacy.json | 5 +++++ test/libsolidity/ASTJSON/receive_ether.json | 1 + test/libsolidity/ASTJSON/receive_ether_legacy.json | 1 + test/libsolidity/ASTJSON/short_type_name.json | 1 + test/libsolidity/ASTJSON/short_type_name_legacy.json | 1 + test/libsolidity/ASTJSON/short_type_name_ref.json | 1 + test/libsolidity/ASTJSON/short_type_name_ref_legacy.json | 1 + test/libsolidity/ASTJSON/source_location.json | 1 + test/libsolidity/ASTJSON/source_location_legacy.json | 1 + test/libsolidity/ASTJSON/string.json | 1 + test/libsolidity/ASTJSON/string_legacy.json | 1 + test/libsolidity/ASTJSON/two_base_functions.json | 3 +++ test/libsolidity/ASTJSON/two_base_functions_legacy.json | 3 +++ test/libsolidity/ASTJSON/unicode.json | 1 + test/libsolidity/ASTJSON/unicode_legacy.json | 1 + test/libsolidity/syntaxTests/unexpected.sol | 2 +- 70 files changed, 84 insertions(+), 7 deletions(-) diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 621fb3936..cac28eac0 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -292,7 +292,7 @@ bool FunctionDefinition::libraryFunction() const Visibility FunctionDefinition::defaultVisibility() const { solAssert(!isConstructor(), ""); - return Declaration::defaultVisibility(); + return isFree() ? Visibility::Internal : Declaration::defaultVisibility(); } FunctionTypePointer FunctionDefinition::functionType(bool _internal) const diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 8b4025a45..cfa438ce5 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -852,9 +852,6 @@ public: ContractDefinition const* _searchStart = nullptr ) const override; -protected: - Visibility defaultVisibility() const override { return isFree() ? Visibility::Internal : Visibility::Public; } - private: StateMutability m_stateMutability; bool m_free; diff --git a/test/cmdlineTests/recovery_ast_constructor/output b/test/cmdlineTests/recovery_ast_constructor/output index d4a7d0288..319fb3c88 100644 --- a/test/cmdlineTests/recovery_ast_constructor/output +++ b/test/cmdlineTests/recovery_ast_constructor/output @@ -58,6 +58,7 @@ JSON AST: { "attributes": { + "freeFunction": false, "implemented": true, "isConstructor": true, "kind": "constructor", @@ -120,6 +121,7 @@ JSON AST: { "attributes": { + "freeFunction": false, "functionSelector": "af11c34c", "implemented": true, "isConstructor": false, diff --git a/test/cmdlineTests/recovery_ast_empty_contract/err b/test/cmdlineTests/recovery_ast_empty_contract/err index 588067877..ab976c155 100644 --- a/test/cmdlineTests/recovery_ast_empty_contract/err +++ b/test/cmdlineTests/recovery_ast_empty_contract/err @@ -1,4 +1,4 @@ -Error: Expected pragma, import directive or contract/interface/library/struct/enum definition. +Error: Expected pragma, import directive or contract/interface/library/struct/enum/function definition. --> recovery_ast_empty_contract/input.sol:3:1: | 3 | c diff --git a/test/cmdlineTests/standard_only_ast_requested/output.json b/test/cmdlineTests/standard_only_ast_requested/output.json index c1ffe5892..c164153ca 100644 --- a/test/cmdlineTests/standard_only_ast_requested/output.json +++ b/test/cmdlineTests/standard_only_ast_requested/output.json @@ -1 +1 @@ -{"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"C":[6]},"id":7,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:0"},{"abstract":false,"baseContracts":[],"contractDependencies":[],"contractKind":"contract","documentation":null,"fullyImplemented":true,"id":6,"linearizedBaseContracts":[6],"name":"C","nodeType":"ContractDefinition","nodes":[{"body":{"id":4,"nodeType":"Block","src":"97:2:0","statements":[]},"documentation":null,"functionSelector":"26121ff0","id":5,"implemented":true,"kind":"function","modifiers":[],"name":"f","nodeType":"FunctionDefinition","overrides":null,"parameters":{"id":2,"nodeType":"ParameterList","parameters":[],"src":"82:2:0"},"returnParameters":{"id":3,"nodeType":"ParameterList","parameters":[],"src":"97:0:0"},"scope":6,"src":"72:27:0","stateMutability":"pure","virtual":false,"visibility":"public"}],"scope":7,"src":"59:42:0"}],"src":"36:65:0"},"id":0}}} +{"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"C":[6]},"id":7,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:0"},{"abstract":false,"baseContracts":[],"contractDependencies":[],"contractKind":"contract","documentation":null,"fullyImplemented":true,"id":6,"linearizedBaseContracts":[6],"name":"C","nodeType":"ContractDefinition","nodes":[{"body":{"id":4,"nodeType":"Block","src":"97:2:0","statements":[]},"documentation":null,"freeFunction":false,"functionSelector":"26121ff0","id":5,"implemented":true,"kind":"function","modifiers":[],"name":"f","nodeType":"FunctionDefinition","overrides":null,"parameters":{"id":2,"nodeType":"ParameterList","parameters":[],"src":"82:2:0"},"returnParameters":{"id":3,"nodeType":"ParameterList","parameters":[],"src":"97:0:0"},"scope":6,"src":"72:27:0","stateMutability":"pure","virtual":false,"visibility":"public"}],"scope":7,"src":"59:42:0"}],"src":"36:65:0"},"id":0}}} diff --git a/test/libsolidity/ASTJSON/abstract_contract.json b/test/libsolidity/ASTJSON/abstract_contract.json index 08b1e6d95..41cd1330f 100644 --- a/test/libsolidity/ASTJSON/abstract_contract.json +++ b/test/libsolidity/ASTJSON/abstract_contract.json @@ -34,6 +34,7 @@ "src": "37:4:1", "statements": [] }, + "freeFunction": false, "id": 4, "implemented": true, "kind": "constructor", diff --git a/test/libsolidity/ASTJSON/abstract_contract_legacy.json b/test/libsolidity/ASTJSON/abstract_contract_legacy.json index c13abca7f..f8da2425b 100644 --- a/test/libsolidity/ASTJSON/abstract_contract_legacy.json +++ b/test/libsolidity/ASTJSON/abstract_contract_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "implemented": true, "isConstructor": true, "kind": "constructor", diff --git a/test/libsolidity/ASTJSON/address_payable.json b/test/libsolidity/ASTJSON/address_payable.json index 3365ec436..8f7ca12be 100644 --- a/test/libsolidity/ASTJSON/address_payable.json +++ b/test/libsolidity/ASTJSON/address_payable.json @@ -462,6 +462,7 @@ } ] }, + "freeFunction": false, "functionSelector": "fc68521a", "id": 38, "implemented": true, diff --git a/test/libsolidity/ASTJSON/address_payable_legacy.json b/test/libsolidity/ASTJSON/address_payable_legacy.json index bda50fc57..15567b5e5 100644 --- a/test/libsolidity/ASTJSON/address_payable_legacy.json +++ b/test/libsolidity/ASTJSON/address_payable_legacy.json @@ -91,6 +91,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "fc68521a", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/call.json b/test/libsolidity/ASTJSON/assembly/call.json index 9538fe5cc..5fe3e3f20 100644 --- a/test/libsolidity/ASTJSON/assembly/call.json +++ b/test/libsolidity/ASTJSON/assembly/call.json @@ -131,6 +131,7 @@ } ] }, + "freeFunction": false, "functionSelector": "b582ec5f", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/call_legacy.json b/test/libsolidity/ASTJSON/assembly/call_legacy.json index 2902873fa..fa9a9830b 100644 --- a/test/libsolidity/ASTJSON/assembly/call_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/call_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "b582ec5f", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/empty_block.json b/test/libsolidity/ASTJSON/assembly/empty_block.json index 2d22cc035..18180e76b 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_block.json +++ b/test/libsolidity/ASTJSON/assembly/empty_block.json @@ -56,6 +56,7 @@ } ] }, + "freeFunction": false, "functionSelector": "e2179b8e", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json b/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json index 54811bf1a..8ab74c144 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "e2179b8e", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/function.json b/test/libsolidity/ASTJSON/assembly/function.json index ccbf3d853..0fc33c271 100644 --- a/test/libsolidity/ASTJSON/assembly/function.json +++ b/test/libsolidity/ASTJSON/assembly/function.json @@ -118,6 +118,7 @@ } ] }, + "freeFunction": false, "functionSelector": "b8c9d365", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/function_legacy.json b/test/libsolidity/ASTJSON/assembly/function_legacy.json index 940a4b6ac..c7a928b54 100644 --- a/test/libsolidity/ASTJSON/assembly/function_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/function_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "b8c9d365", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/leave.json b/test/libsolidity/ASTJSON/assembly/leave.json index ba765146f..7edbfe11f 100644 --- a/test/libsolidity/ASTJSON/assembly/leave.json +++ b/test/libsolidity/ASTJSON/assembly/leave.json @@ -68,6 +68,7 @@ } ] }, + "freeFunction": false, "functionSelector": "ece866b9", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/leave_legacy.json b/test/libsolidity/ASTJSON/assembly/leave_legacy.json index fa71bcba0..02fba96c7 100644 --- a/test/libsolidity/ASTJSON/assembly/leave_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/leave_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "ece866b9", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/loop.json b/test/libsolidity/ASTJSON/assembly/loop.json index 9c99cf491..f565915e8 100644 --- a/test/libsolidity/ASTJSON/assembly/loop.json +++ b/test/libsolidity/ASTJSON/assembly/loop.json @@ -131,6 +131,7 @@ } ] }, + "freeFunction": false, "functionSelector": "e2179b8e", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/loop_legacy.json b/test/libsolidity/ASTJSON/assembly/loop_legacy.json index 84890475f..4f1051e03 100644 --- a/test/libsolidity/ASTJSON/assembly/loop_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/loop_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "e2179b8e", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions.json b/test/libsolidity/ASTJSON/assembly/nested_functions.json index f945494ba..8f9acb56f 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions.json +++ b/test/libsolidity/ASTJSON/assembly/nested_functions.json @@ -95,6 +95,7 @@ } ] }, + "freeFunction": false, "functionSelector": "26121ff0", "id": 7, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json b/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json index 393646221..2dd973e84 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset.json b/test/libsolidity/ASTJSON/assembly/slot_offset.json index 0858fe617..5a9b1489f 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset.json +++ b/test/libsolidity/ASTJSON/assembly/slot_offset.json @@ -196,6 +196,7 @@ } ] }, + "freeFunction": false, "functionSelector": "ffae15ba", "id": 10, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json b/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json index 50747baaa..d84497d1a 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json @@ -112,6 +112,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "ffae15ba", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/stringlit.json b/test/libsolidity/ASTJSON/assembly/stringlit.json index 08e0ea4f6..872e953ee 100644 --- a/test/libsolidity/ASTJSON/assembly/stringlit.json +++ b/test/libsolidity/ASTJSON/assembly/stringlit.json @@ -72,6 +72,7 @@ } ] }, + "freeFunction": false, "functionSelector": "5a2ee019", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json b/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json index 325d25274..87c79d107 100644 --- a/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "5a2ee019", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/switch.json b/test/libsolidity/ASTJSON/assembly/switch.json index 9ae71f15c..7380897a0 100644 --- a/test/libsolidity/ASTJSON/assembly/switch.json +++ b/test/libsolidity/ASTJSON/assembly/switch.json @@ -180,6 +180,7 @@ } ] }, + "freeFunction": false, "functionSelector": "26121ff0", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/switch_default.json b/test/libsolidity/ASTJSON/assembly/switch_default.json index 4226a8ea3..2eb2cd9dc 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_default.json +++ b/test/libsolidity/ASTJSON/assembly/switch_default.json @@ -95,6 +95,7 @@ } ] }, + "freeFunction": false, "functionSelector": "e2179b8e", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json b/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json index 324330f86..5f0d10dfc 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "e2179b8e", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/switch_legacy.json b/test/libsolidity/ASTJSON/assembly/switch_legacy.json index 92e2e2c61..9f907e633 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/switch_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/var_access.json b/test/libsolidity/ASTJSON/assembly/var_access.json index f10c45cc4..bc0a9a3c7 100644 --- a/test/libsolidity/ASTJSON/assembly/var_access.json +++ b/test/libsolidity/ASTJSON/assembly/var_access.json @@ -121,6 +121,7 @@ } ] }, + "freeFunction": false, "functionSelector": "26121ff0", "id": 8, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/var_access_legacy.json b/test/libsolidity/ASTJSON/assembly/var_access_legacy.json index fcd798ad9..2052a8aed 100644 --- a/test/libsolidity/ASTJSON/assembly/var_access_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/var_access_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/constructor.json b/test/libsolidity/ASTJSON/constructor.json index 31747901e..c4b7e9f87 100644 --- a/test/libsolidity/ASTJSON/constructor.json +++ b/test/libsolidity/ASTJSON/constructor.json @@ -34,6 +34,7 @@ "src": "28:4:1", "statements": [] }, + "freeFunction": false, "id": 4, "implemented": true, "kind": "constructor", diff --git a/test/libsolidity/ASTJSON/constructor_legacy.json b/test/libsolidity/ASTJSON/constructor_legacy.json index 68a648bc9..ade4e5629 100644 --- a/test/libsolidity/ASTJSON/constructor_legacy.json +++ b/test/libsolidity/ASTJSON/constructor_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "implemented": true, "isConstructor": true, "kind": "constructor", diff --git a/test/libsolidity/ASTJSON/documentation.json b/test/libsolidity/ASTJSON/documentation.json index f0beba98f..8cf35a71e 100644 --- a/test/libsolidity/ASTJSON/documentation.json +++ b/test/libsolidity/ASTJSON/documentation.json @@ -216,6 +216,7 @@ "src": "162:25:3", "text": "Some comment on fn." }, + "freeFunction": false, "functionSelector": "a4a2c40b", "id": 22, "implemented": true, diff --git a/test/libsolidity/ASTJSON/documentation_legacy.json b/test/libsolidity/ASTJSON/documentation_legacy.json index 4284c4f8f..014b70fe9 100644 --- a/test/libsolidity/ASTJSON/documentation_legacy.json +++ b/test/libsolidity/ASTJSON/documentation_legacy.json @@ -161,6 +161,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "a4a2c40b", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/fallback.json b/test/libsolidity/ASTJSON/fallback.json index 7037b960a..cf706e4fe 100644 --- a/test/libsolidity/ASTJSON/fallback.json +++ b/test/libsolidity/ASTJSON/fallback.json @@ -34,6 +34,7 @@ "src": "43:5:1", "statements": [] }, + "freeFunction": false, "id": 4, "implemented": true, "kind": "fallback", diff --git a/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json b/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json index 009363e98..e8219b6db 100644 --- a/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json +++ b/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json @@ -34,6 +34,7 @@ "src": "42:5:1", "statements": [] }, + "freeFunction": false, "id": 4, "implemented": true, "kind": "receive", @@ -68,6 +69,7 @@ "src": "78:5:1", "statements": [] }, + "freeFunction": false, "id": 8, "implemented": true, "kind": "fallback", diff --git a/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json b/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json index 8ac17607e..1fa662d64 100644 --- a/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json +++ b/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "implemented": true, "isConstructor": false, "kind": "receive", @@ -100,6 +101,7 @@ { "attributes": { + "freeFunction": false, "implemented": true, "isConstructor": false, "kind": "fallback", diff --git a/test/libsolidity/ASTJSON/fallback_legacy.json b/test/libsolidity/ASTJSON/fallback_legacy.json index 1ee8bf6b3..9f31a225e 100644 --- a/test/libsolidity/ASTJSON/fallback_legacy.json +++ b/test/libsolidity/ASTJSON/fallback_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "implemented": true, "isConstructor": false, "kind": "fallback", diff --git a/test/libsolidity/ASTJSON/fallback_payable.json b/test/libsolidity/ASTJSON/fallback_payable.json index 2391f57bb..883ba1bfd 100644 --- a/test/libsolidity/ASTJSON/fallback_payable.json +++ b/test/libsolidity/ASTJSON/fallback_payable.json @@ -34,6 +34,7 @@ "src": "34:2:1", "statements": [] }, + "freeFunction": false, "id": 4, "implemented": true, "kind": "fallback", diff --git a/test/libsolidity/ASTJSON/fallback_payable_legacy.json b/test/libsolidity/ASTJSON/fallback_payable_legacy.json index 69e25ab6e..2e4a69077 100644 --- a/test/libsolidity/ASTJSON/fallback_payable_legacy.json +++ b/test/libsolidity/ASTJSON/fallback_payable_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "implemented": true, "isConstructor": false, "kind": "fallback", diff --git a/test/libsolidity/ASTJSON/function_type.json b/test/libsolidity/ASTJSON/function_type.json index c0d2efc68..fb706e5e8 100644 --- a/test/libsolidity/ASTJSON/function_type.json +++ b/test/libsolidity/ASTJSON/function_type.json @@ -34,6 +34,7 @@ "src": "120:2:1", "statements": [] }, + "freeFunction": false, "functionSelector": "d6cd4974", "id": 16, "implemented": true, diff --git a/test/libsolidity/ASTJSON/function_type_legacy.json b/test/libsolidity/ASTJSON/function_type_legacy.json index 627ce45f0..cc02a7dd9 100644 --- a/test/libsolidity/ASTJSON/function_type_legacy.json +++ b/test/libsolidity/ASTJSON/function_type_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "d6cd4974", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json index 7b598093b..dd9210e5f 100644 --- a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json +++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json @@ -134,6 +134,7 @@ } ] }, + "freeFunction": false, "functionSelector": "26121ff0", "id": 10, "implemented": true, diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json index 46e5b0417..319b1e022 100644 --- a/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json +++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier.json b/test/libsolidity/ASTJSON/long_type_name_identifier.json index 4293f6df4..6df967ea9 100644 --- a/test/libsolidity/ASTJSON/long_type_name_identifier.json +++ b/test/libsolidity/ASTJSON/long_type_name_identifier.json @@ -142,6 +142,7 @@ } ] }, + "freeFunction": false, "functionSelector": "26121ff0", "id": 14, "implemented": true, diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json index ced331a6d..f6ee2b948 100644 --- a/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json +++ b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json @@ -79,6 +79,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/modifier_definition.json b/test/libsolidity/ASTJSON/modifier_definition.json index 198afe454..d1355a51f 100644 --- a/test/libsolidity/ASTJSON/modifier_definition.json +++ b/test/libsolidity/ASTJSON/modifier_definition.json @@ -94,6 +94,7 @@ "src": "64:2:1", "statements": [] }, + "freeFunction": false, "functionSelector": "28811f59", "id": 13, "implemented": true, diff --git a/test/libsolidity/ASTJSON/modifier_definition_legacy.json b/test/libsolidity/ASTJSON/modifier_definition_legacy.json index cc3089395..a48e02104 100644 --- a/test/libsolidity/ASTJSON/modifier_definition_legacy.json +++ b/test/libsolidity/ASTJSON/modifier_definition_legacy.json @@ -102,6 +102,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "28811f59", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/modifier_invocation.json b/test/libsolidity/ASTJSON/modifier_invocation.json index 198afe454..d1355a51f 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation.json +++ b/test/libsolidity/ASTJSON/modifier_invocation.json @@ -94,6 +94,7 @@ "src": "64:2:1", "statements": [] }, + "freeFunction": false, "functionSelector": "28811f59", "id": 13, "implemented": true, diff --git a/test/libsolidity/ASTJSON/modifier_invocation_legacy.json b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json index cc3089395..a48e02104 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation_legacy.json +++ b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json @@ -102,6 +102,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "28811f59", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/non_utf8.json b/test/libsolidity/ASTJSON/non_utf8.json index 98db4273f..22d95bf28 100644 --- a/test/libsolidity/ASTJSON/non_utf8.json +++ b/test/libsolidity/ASTJSON/non_utf8.json @@ -94,6 +94,7 @@ } ] }, + "freeFunction": false, "functionSelector": "26121ff0", "id": 8, "implemented": true, diff --git a/test/libsolidity/ASTJSON/non_utf8_legacy.json b/test/libsolidity/ASTJSON/non_utf8_legacy.json index d9430c82d..c8d5c312f 100644 --- a/test/libsolidity/ASTJSON/non_utf8_legacy.json +++ b/test/libsolidity/ASTJSON/non_utf8_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/override.json b/test/libsolidity/ASTJSON/override.json index 49f85144e..e38305bf1 100644 --- a/test/libsolidity/ASTJSON/override.json +++ b/test/libsolidity/ASTJSON/override.json @@ -42,6 +42,7 @@ "src": "36:2:1", "statements": [] }, + "freeFunction": false, "functionSelector": "a399b6a2", "id": 4, "implemented": true, @@ -113,6 +114,7 @@ "nodes": [ { + "freeFunction": false, "functionSelector": "c2985578", "id": 10, "implemented": false, @@ -152,6 +154,7 @@ "src": "115:2:1", "statements": [] }, + "freeFunction": false, "functionSelector": "a399b6a2", "id": 15, "implemented": true, @@ -243,6 +246,7 @@ "src": "170:3:1", "statements": [] }, + "freeFunction": false, "functionSelector": "c2985578", "id": 23, "implemented": true, @@ -289,6 +293,7 @@ "src": "212:2:1", "statements": [] }, + "freeFunction": false, "functionSelector": "a399b6a2", "id": 30, "implemented": true, diff --git a/test/libsolidity/ASTJSON/override_legacy.json b/test/libsolidity/ASTJSON/override_legacy.json index 5cdc2f364..bbd03937f 100644 --- a/test/libsolidity/ASTJSON/override_legacy.json +++ b/test/libsolidity/ASTJSON/override_legacy.json @@ -46,6 +46,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "a399b6a2", "implemented": true, "isConstructor": false, @@ -154,6 +155,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "c2985578", "implemented": false, "isConstructor": false, @@ -208,6 +210,7 @@ [ 4 ], + "freeFunction": false, "functionSelector": "a399b6a2", "implemented": true, "isConstructor": false, @@ -334,6 +337,7 @@ [ 10 ], + "freeFunction": false, "functionSelector": "c2985578", "implemented": true, "isConstructor": false, @@ -413,6 +417,7 @@ [ 15 ], + "freeFunction": false, "functionSelector": "a399b6a2", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/receive_ether.json b/test/libsolidity/ASTJSON/receive_ether.json index 8a1f0ac9a..8b678a593 100644 --- a/test/libsolidity/ASTJSON/receive_ether.json +++ b/test/libsolidity/ASTJSON/receive_ether.json @@ -34,6 +34,7 @@ "src": "42:5:1", "statements": [] }, + "freeFunction": false, "id": 4, "implemented": true, "kind": "receive", diff --git a/test/libsolidity/ASTJSON/receive_ether_legacy.json b/test/libsolidity/ASTJSON/receive_ether_legacy.json index d9544f138..1155129d4 100644 --- a/test/libsolidity/ASTJSON/receive_ether_legacy.json +++ b/test/libsolidity/ASTJSON/receive_ether_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "implemented": true, "isConstructor": false, "kind": "receive", diff --git a/test/libsolidity/ASTJSON/short_type_name.json b/test/libsolidity/ASTJSON/short_type_name.json index 882fcfe24..f569f59af 100644 --- a/test/libsolidity/ASTJSON/short_type_name.json +++ b/test/libsolidity/ASTJSON/short_type_name.json @@ -88,6 +88,7 @@ } ] }, + "freeFunction": false, "functionSelector": "26121ff0", "id": 10, "implemented": true, diff --git a/test/libsolidity/ASTJSON/short_type_name_legacy.json b/test/libsolidity/ASTJSON/short_type_name_legacy.json index 8e255954d..b7912f585 100644 --- a/test/libsolidity/ASTJSON/short_type_name_legacy.json +++ b/test/libsolidity/ASTJSON/short_type_name_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/short_type_name_ref.json b/test/libsolidity/ASTJSON/short_type_name_ref.json index 2d07a9c60..e8845981f 100644 --- a/test/libsolidity/ASTJSON/short_type_name_ref.json +++ b/test/libsolidity/ASTJSON/short_type_name_ref.json @@ -99,6 +99,7 @@ } ] }, + "freeFunction": false, "functionSelector": "26121ff0", "id": 11, "implemented": true, diff --git a/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json index 5316c56ac..f6cd04ed3 100644 --- a/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json +++ b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/source_location.json b/test/libsolidity/ASTJSON/source_location.json index f56231ed7..fa95c0e4a 100644 --- a/test/libsolidity/ASTJSON/source_location.json +++ b/test/libsolidity/ASTJSON/source_location.json @@ -131,6 +131,7 @@ } ] }, + "freeFunction": false, "functionSelector": "26121ff0", "id": 11, "implemented": true, diff --git a/test/libsolidity/ASTJSON/source_location_legacy.json b/test/libsolidity/ASTJSON/source_location_legacy.json index bf3dfaedd..529ca4444 100644 --- a/test/libsolidity/ASTJSON/source_location_legacy.json +++ b/test/libsolidity/ASTJSON/source_location_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/string.json b/test/libsolidity/ASTJSON/string.json index f47b41e47..41fe9fa00 100644 --- a/test/libsolidity/ASTJSON/string.json +++ b/test/libsolidity/ASTJSON/string.json @@ -95,6 +95,7 @@ } ] }, + "freeFunction": false, "functionSelector": "26121ff0", "id": 8, "implemented": true, diff --git a/test/libsolidity/ASTJSON/string_legacy.json b/test/libsolidity/ASTJSON/string_legacy.json index 96c984209..89c9a5e55 100644 --- a/test/libsolidity/ASTJSON/string_legacy.json +++ b/test/libsolidity/ASTJSON/string_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/two_base_functions.json b/test/libsolidity/ASTJSON/two_base_functions.json index 769e5c3f8..7e6526316 100644 --- a/test/libsolidity/ASTJSON/two_base_functions.json +++ b/test/libsolidity/ASTJSON/two_base_functions.json @@ -42,6 +42,7 @@ "src": "45:2:1", "statements": [] }, + "freeFunction": false, "functionSelector": "26121ff0", "id": 4, "implemented": true, @@ -96,6 +97,7 @@ "src": "95:2:1", "statements": [] }, + "freeFunction": false, "functionSelector": "26121ff0", "id": 9, "implemented": true, @@ -199,6 +201,7 @@ "src": "160:2:1", "statements": [] }, + "freeFunction": false, "functionSelector": "26121ff0", "id": 21, "implemented": true, diff --git a/test/libsolidity/ASTJSON/two_base_functions_legacy.json b/test/libsolidity/ASTJSON/two_base_functions_legacy.json index a5bd2d725..405576ab6 100644 --- a/test/libsolidity/ASTJSON/two_base_functions_legacy.json +++ b/test/libsolidity/ASTJSON/two_base_functions_legacy.json @@ -46,6 +46,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -137,6 +138,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -272,6 +274,7 @@ 4, 9 ], + "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/unicode.json b/test/libsolidity/ASTJSON/unicode.json index 81c8ad0da..99f9eb619 100644 --- a/test/libsolidity/ASTJSON/unicode.json +++ b/test/libsolidity/ASTJSON/unicode.json @@ -95,6 +95,7 @@ } ] }, + "freeFunction": false, "functionSelector": "26121ff0", "id": 8, "implemented": true, diff --git a/test/libsolidity/ASTJSON/unicode_legacy.json b/test/libsolidity/ASTJSON/unicode_legacy.json index 22976f6f9..826c3ce44 100644 --- a/test/libsolidity/ASTJSON/unicode_legacy.json +++ b/test/libsolidity/ASTJSON/unicode_legacy.json @@ -38,6 +38,7 @@ { "attributes": { + "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/syntaxTests/unexpected.sol b/test/libsolidity/syntaxTests/unexpected.sol index 79ee1b6cb..971c78000 100644 --- a/test/libsolidity/syntaxTests/unexpected.sol +++ b/test/libsolidity/syntaxTests/unexpected.sol @@ -1,3 +1,3 @@ unexpected // ---- -// ParserError 7858: (0-10): Expected pragma, import directive or contract/interface/library/struct/enum definition. +// ParserError 7858: (0-10): Expected pragma, import directive or contract/interface/library/struct/enum/function definition. From cf5aa450bdbf2188a83e80221eb4a9f67b630bda Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 16 Jun 2020 18:20:37 +0200 Subject: [PATCH 3/5] Documentation. --- Changelog.md | 1 + docs/Solidity.g4 | 2 +- docs/contracts/function-modifiers.rst | 2 +- docs/contracts/functions.rst | 28 +++++++++++++++++++++++++++ docs/layout-of-source-files.rst | 2 +- docs/structure-of-a-contract.rst | 11 +++++++++-- 6 files changed, 41 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index 9235faf6e..4b47af706 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ ### 0.7.1 (unreleased) Language Features: + * Allow function definitions outside of contracts, behaving much like internal library functions. Compiler Features: diff --git a/docs/Solidity.g4 b/docs/Solidity.g4 index 91f59d78c..dee054492 100644 --- a/docs/Solidity.g4 +++ b/docs/Solidity.g4 @@ -8,7 +8,7 @@ grammar Solidity; sourceUnit - : (pragmaDirective | importDirective | structDefinition | enumDefinition | contractDefinition)* EOF ; + : (pragmaDirective | importDirective | structDefinition | enumDefinition | functionDefinition | contractDefinition)* EOF ; pragmaDirective : 'pragma' pragmaName ( ~';' )* ';' ; diff --git a/docs/contracts/function-modifiers.rst b/docs/contracts/function-modifiers.rst index 823e6e6ac..881b8f787 100644 --- a/docs/contracts/function-modifiers.rst +++ b/docs/contracts/function-modifiers.rst @@ -18,7 +18,7 @@ if they are marked ``virtual``. For details, please see :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >0.6.99 <0.8.0; + pragma solidity >0.7.0 <0.8.0; contract owned { constructor() { owner = msg.sender; } diff --git a/docs/contracts/functions.rst b/docs/contracts/functions.rst index 41174c958..e7c97c33d 100644 --- a/docs/contracts/functions.rst +++ b/docs/contracts/functions.rst @@ -6,6 +6,34 @@ Functions ********* +Functions can be defined inside and outside of contracts. + +Functions outside of a contract, also called "free functions", always have implicit ``internal`` +:ref:`visibility`. Their code is included in all contracts +that call them, similar to internal library functions. + +:: + + // SPDX-License-Identifier: GPL-3.0 + pragma solidity >0.7.0 <0.8.0; + + function sum(uint[] memory _arr) pure returns (uint s) { + for (uint i = 0; i < _arr.length; i++) + s += _arr[i]; + } + + contract ArrayExample { + bool found; + function f(uint[] memory _arr) public { + // This calls the free function internally. + // The compiler will add its code to the contract. + uint s = sum(_arr); + require(s >= 10); + found = true; + } + } + + .. _function-parameters-return-variables: Function Parameters and Return Variables diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index d50ea06a3..d80af49f7 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -5,7 +5,7 @@ Layout of a Solidity Source File Source files can contain an arbitrary number of :ref:`contract definitions`, import_ directives, :ref:`pragma directives` and -:ref:`struct` and :ref:`enum` definitions. +:ref:`struct`, :ref:`enum` and :ref:`function` definitions. .. index:: ! license, spdx diff --git a/docs/structure-of-a-contract.rst b/docs/structure-of-a-contract.rst index 016130730..80cd5f617 100644 --- a/docs/structure-of-a-contract.rst +++ b/docs/structure-of-a-contract.rst @@ -43,12 +43,14 @@ visibility. Functions ========= -Functions are the executable units of code within a contract. +Functions are the executable units of code. Functions are usually +defined inside a contract, but they can also be defined outside of +contracts. :: // SPDX-License-Identifier: GPL-3.0 - pragma solidity >=0.4.0 <0.8.0; + pragma solidity >0.7.0 <0.8.0; contract SimpleAuction { function bid() public payable { // Function @@ -56,6 +58,11 @@ Functions are the executable units of code within a contract. } } + // Helper function defined outside of a contract + function helper(uint x) pure returns (uint) { + return x * 2; + } + :ref:`function-calls` can happen internally or externally and have different levels of :ref:`visibility` towards other contracts. :ref:`Functions` accept :ref:`parameters and return variables` to pass parameters From 8d92fd1c041f850d6a8f5a8c00570ea73e9a81f1 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 4 Aug 2020 10:38:31 +0200 Subject: [PATCH 4/5] Use opportunistic visiting order for modifiers. --- libsolidity/analysis/ViewPureChecker.cpp | 42 ++++++++++++------------ libsolidity/analysis/ViewPureChecker.h | 4 ++- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp index 1bf6028e5..b75b4a240 100644 --- a/libsolidity/analysis/ViewPureChecker.cpp +++ b/libsolidity/analysis/ViewPureChecker.cpp @@ -128,12 +128,6 @@ private: bool ViewPureChecker::check() { - // Process modifiers first to infer their state mutability. - m_checkModifiers = true; - for (auto const& source: m_ast) - source->accept(*this); - - m_checkModifiers = false; for (auto const& source: m_ast) source->accept(*this); @@ -142,9 +136,6 @@ bool ViewPureChecker::check() bool ViewPureChecker::visit(FunctionDefinition const& _funDef) { - if (m_checkModifiers) - return false; - solAssert(!m_currentFunction, ""); m_currentFunction = &_funDef; m_bestMutabilityAndLocation = {StateMutability::Pure, _funDef.location()}; @@ -153,9 +144,6 @@ bool ViewPureChecker::visit(FunctionDefinition const& _funDef) void ViewPureChecker::endVisit(FunctionDefinition const& _funDef) { - if (m_checkModifiers) - return; - solAssert(m_currentFunction == &_funDef, ""); if ( m_bestMutabilityAndLocation.mutability < _funDef.stateMutability() && @@ -177,9 +165,6 @@ void ViewPureChecker::endVisit(FunctionDefinition const& _funDef) bool ViewPureChecker::visit(ModifierDefinition const& _modifier) { - if (!m_checkModifiers) - return false; - solAssert(m_currentFunction == nullptr, ""); m_bestMutabilityAndLocation = {StateMutability::Pure, _modifier.location()}; return true; @@ -187,9 +172,6 @@ bool ViewPureChecker::visit(ModifierDefinition const& _modifier) void ViewPureChecker::endVisit(ModifierDefinition const& _modifierDef) { - if (!m_checkModifiers) - return; - solAssert(m_currentFunction == nullptr, ""); m_inferredMutability[&_modifierDef] = std::move(m_bestMutabilityAndLocation); } @@ -306,7 +288,26 @@ void ViewPureChecker::reportMutability( m_currentFunction->stateMutability() == StateMutability::Pure || m_currentFunction->stateMutability() == StateMutability::NonPayable, "" - ); + ); +} + +ViewPureChecker::MutabilityAndLocation const& ViewPureChecker::modifierMutability( + ModifierDefinition const& _modifier +) +{ + if (!m_inferredMutability.count(&_modifier)) + { + MutabilityAndLocation bestMutabilityAndLocation{}; + FunctionDefinition const* currentFunction = nullptr; + swap(bestMutabilityAndLocation, m_bestMutabilityAndLocation); + swap(currentFunction, m_currentFunction); + + _modifier.accept(*this); + + swap(bestMutabilityAndLocation, m_bestMutabilityAndLocation); + swap(currentFunction, m_currentFunction); + } + return m_inferredMutability.at(&_modifier); } void ViewPureChecker::endVisit(FunctionCall const& _functionCall) @@ -431,8 +432,7 @@ void ViewPureChecker::endVisit(ModifierInvocation const& _modifier) solAssert(_modifier.name(), ""); if (ModifierDefinition const* mod = dynamic_cast(_modifier.name()->annotation().referencedDeclaration)) { - solAssert(m_inferredMutability.count(mod), ""); - auto const& mutAndLocation = m_inferredMutability.at(mod); + MutabilityAndLocation const& mutAndLocation = modifierMutability(*mod); reportMutability(mutAndLocation.mutability, _modifier.location(), mutAndLocation.location); } else diff --git a/libsolidity/analysis/ViewPureChecker.h b/libsolidity/analysis/ViewPureChecker.h index 62444e086..dfbb2f747 100644 --- a/libsolidity/analysis/ViewPureChecker.h +++ b/libsolidity/analysis/ViewPureChecker.h @@ -71,11 +71,13 @@ private: std::optional const& _nestedLocation = {} ); + /// Determines the mutability of modifier if not already cached. + MutabilityAndLocation const& modifierMutability(ModifierDefinition const& _modifier); + std::vector> const& m_ast; langutil::ErrorReporter& m_errorReporter; bool m_errors = false; - bool m_checkModifiers = false; MutabilityAndLocation m_bestMutabilityAndLocation = MutabilityAndLocation{StateMutability::Payable, langutil::SourceLocation()}; FunctionDefinition const* m_currentFunction = nullptr; std::map m_inferredMutability; From 2ff954ec2dd00adfe511e5e9951ce230335355d4 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 6 Aug 2020 14:10:42 +0200 Subject: [PATCH 5/5] Use kind in json AST for free function. --- libsolidity/ast/ASTJsonConverter.cpp | 3 +-- libsolidity/ast/ASTJsonImporter.cpp | 17 +++++++---------- .../recovery_ast_constructor/output | 2 -- .../standard_only_ast_requested/output.json | 2 +- test/libsolidity/ASTJSON/abstract_contract.json | 1 - .../ASTJSON/abstract_contract_legacy.json | 1 - test/libsolidity/ASTJSON/address_payable.json | 1 - .../ASTJSON/address_payable_legacy.json | 1 - test/libsolidity/ASTJSON/assembly/call.json | 1 - .../ASTJSON/assembly/call_legacy.json | 1 - .../ASTJSON/assembly/empty_block.json | 1 - .../ASTJSON/assembly/empty_block_legacy.json | 1 - test/libsolidity/ASTJSON/assembly/function.json | 1 - .../ASTJSON/assembly/function_legacy.json | 1 - test/libsolidity/ASTJSON/assembly/leave.json | 1 - .../ASTJSON/assembly/leave_legacy.json | 1 - test/libsolidity/ASTJSON/assembly/loop.json | 1 - .../ASTJSON/assembly/loop_legacy.json | 1 - .../ASTJSON/assembly/nested_functions.json | 1 - .../assembly/nested_functions_legacy.json | 1 - .../ASTJSON/assembly/slot_offset.json | 1 - .../ASTJSON/assembly/slot_offset_legacy.json | 1 - .../libsolidity/ASTJSON/assembly/stringlit.json | 1 - .../ASTJSON/assembly/stringlit_legacy.json | 1 - test/libsolidity/ASTJSON/assembly/switch.json | 1 - .../ASTJSON/assembly/switch_default.json | 1 - .../ASTJSON/assembly/switch_default_legacy.json | 1 - .../ASTJSON/assembly/switch_legacy.json | 1 - .../ASTJSON/assembly/var_access.json | 1 - .../ASTJSON/assembly/var_access_legacy.json | 1 - test/libsolidity/ASTJSON/constructor.json | 1 - .../libsolidity/ASTJSON/constructor_legacy.json | 1 - test/libsolidity/ASTJSON/documentation.json | 1 - .../ASTJSON/documentation_legacy.json | 1 - test/libsolidity/ASTJSON/fallback.json | 1 - .../ASTJSON/fallback_and_reveice_ether.json | 2 -- .../fallback_and_reveice_ether_legacy.json | 2 -- test/libsolidity/ASTJSON/fallback_legacy.json | 1 - test/libsolidity/ASTJSON/fallback_payable.json | 1 - .../ASTJSON/fallback_payable_legacy.json | 1 - test/libsolidity/ASTJSON/function_type.json | 1 - .../ASTJSON/function_type_legacy.json | 1 - .../long_type_name_binary_operation.json | 1 - .../long_type_name_binary_operation_legacy.json | 1 - .../ASTJSON/long_type_name_identifier.json | 1 - .../long_type_name_identifier_legacy.json | 1 - .../ASTJSON/modifier_definition.json | 1 - .../ASTJSON/modifier_definition_legacy.json | 1 - .../ASTJSON/modifier_invocation.json | 1 - .../ASTJSON/modifier_invocation_legacy.json | 1 - test/libsolidity/ASTJSON/non_utf8.json | 1 - test/libsolidity/ASTJSON/non_utf8_legacy.json | 1 - test/libsolidity/ASTJSON/override.json | 5 ----- test/libsolidity/ASTJSON/override_legacy.json | 5 ----- test/libsolidity/ASTJSON/receive_ether.json | 1 - .../ASTJSON/receive_ether_legacy.json | 1 - test/libsolidity/ASTJSON/short_type_name.json | 1 - .../ASTJSON/short_type_name_legacy.json | 1 - .../ASTJSON/short_type_name_ref.json | 1 - .../ASTJSON/short_type_name_ref_legacy.json | 1 - test/libsolidity/ASTJSON/source_location.json | 1 - .../ASTJSON/source_location_legacy.json | 1 - test/libsolidity/ASTJSON/string.json | 1 - test/libsolidity/ASTJSON/string_legacy.json | 1 - .../libsolidity/ASTJSON/two_base_functions.json | 3 --- .../ASTJSON/two_base_functions_legacy.json | 3 --- test/libsolidity/ASTJSON/unicode.json | 1 - test/libsolidity/ASTJSON/unicode_legacy.json | 1 - 68 files changed, 9 insertions(+), 93 deletions(-) diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index 15ac0c620..04283cc34 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -360,8 +360,7 @@ bool ASTJsonConverter::visit(FunctionDefinition const& _node) std::vector> attributes = { make_pair("name", _node.name()), make_pair("documentation", _node.documentation() ? toJson(*_node.documentation()) : Json::nullValue), - make_pair("kind", TokenTraits::toString(_node.kind())), - make_pair("freeFunction", _node.isFree()), + make_pair("kind", _node.isFree() ? "freeFunction" : TokenTraits::toString(_node.kind())), make_pair("stateMutability", stateMutabilityToString(_node.stateMutability())), make_pair("visibility", Declaration::visibilityToString(visibility)), make_pair("virtual", _node.markedVirtual()), diff --git a/libsolidity/ast/ASTJsonImporter.cpp b/libsolidity/ast/ASTJsonImporter.cpp index 8bc657abf..5e44b8616 100644 --- a/libsolidity/ast/ASTJsonImporter.cpp +++ b/libsolidity/ast/ASTJsonImporter.cpp @@ -381,6 +381,7 @@ ASTPointer ASTJsonImporter::createFunctionDefinition(Json::V astAssert(_node["kind"].isString(), "Expected 'kind' to be a string!"); Token kind; + bool freeFunction = false; string kindStr = member(_node, "kind").asString(); if (kindStr == "constructor") @@ -391,6 +392,11 @@ ASTPointer ASTJsonImporter::createFunctionDefinition(Json::V kind = Token::Fallback; else if (kindStr == "receive") kind = Token::Receive; + else if (kindStr == "freeFunction") + { + kind = Token::Function; + freeFunction = true; + } else astAssert(false, "Expected 'kind' to be one of [constructor, function, fallback, receive]"); @@ -399,16 +405,7 @@ ASTPointer ASTJsonImporter::createFunctionDefinition(Json::V modifiers.push_back(createModifierInvocation(mod)); Visibility vis = Visibility::Default; - bool const freeFunction = _node.isMember("freeFunction") ? _node["freeFunction"].asBool() : false; - if (kind == Token::Constructor) - { - } - else if (freeFunction) - astAssert( - vis == Visibility::Internal || vis == Visibility::Default, - "Expected internal or default visibility for free function." - ); - else + if (!freeFunction) vis = visibility(_node); return createASTNode( _node, diff --git a/test/cmdlineTests/recovery_ast_constructor/output b/test/cmdlineTests/recovery_ast_constructor/output index 319fb3c88..d4a7d0288 100644 --- a/test/cmdlineTests/recovery_ast_constructor/output +++ b/test/cmdlineTests/recovery_ast_constructor/output @@ -58,7 +58,6 @@ JSON AST: { "attributes": { - "freeFunction": false, "implemented": true, "isConstructor": true, "kind": "constructor", @@ -121,7 +120,6 @@ JSON AST: { "attributes": { - "freeFunction": false, "functionSelector": "af11c34c", "implemented": true, "isConstructor": false, diff --git a/test/cmdlineTests/standard_only_ast_requested/output.json b/test/cmdlineTests/standard_only_ast_requested/output.json index c164153ca..c1ffe5892 100644 --- a/test/cmdlineTests/standard_only_ast_requested/output.json +++ b/test/cmdlineTests/standard_only_ast_requested/output.json @@ -1 +1 @@ -{"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"C":[6]},"id":7,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:0"},{"abstract":false,"baseContracts":[],"contractDependencies":[],"contractKind":"contract","documentation":null,"fullyImplemented":true,"id":6,"linearizedBaseContracts":[6],"name":"C","nodeType":"ContractDefinition","nodes":[{"body":{"id":4,"nodeType":"Block","src":"97:2:0","statements":[]},"documentation":null,"freeFunction":false,"functionSelector":"26121ff0","id":5,"implemented":true,"kind":"function","modifiers":[],"name":"f","nodeType":"FunctionDefinition","overrides":null,"parameters":{"id":2,"nodeType":"ParameterList","parameters":[],"src":"82:2:0"},"returnParameters":{"id":3,"nodeType":"ParameterList","parameters":[],"src":"97:0:0"},"scope":6,"src":"72:27:0","stateMutability":"pure","virtual":false,"visibility":"public"}],"scope":7,"src":"59:42:0"}],"src":"36:65:0"},"id":0}}} +{"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"C":[6]},"id":7,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:0"},{"abstract":false,"baseContracts":[],"contractDependencies":[],"contractKind":"contract","documentation":null,"fullyImplemented":true,"id":6,"linearizedBaseContracts":[6],"name":"C","nodeType":"ContractDefinition","nodes":[{"body":{"id":4,"nodeType":"Block","src":"97:2:0","statements":[]},"documentation":null,"functionSelector":"26121ff0","id":5,"implemented":true,"kind":"function","modifiers":[],"name":"f","nodeType":"FunctionDefinition","overrides":null,"parameters":{"id":2,"nodeType":"ParameterList","parameters":[],"src":"82:2:0"},"returnParameters":{"id":3,"nodeType":"ParameterList","parameters":[],"src":"97:0:0"},"scope":6,"src":"72:27:0","stateMutability":"pure","virtual":false,"visibility":"public"}],"scope":7,"src":"59:42:0"}],"src":"36:65:0"},"id":0}}} diff --git a/test/libsolidity/ASTJSON/abstract_contract.json b/test/libsolidity/ASTJSON/abstract_contract.json index 41cd1330f..08b1e6d95 100644 --- a/test/libsolidity/ASTJSON/abstract_contract.json +++ b/test/libsolidity/ASTJSON/abstract_contract.json @@ -34,7 +34,6 @@ "src": "37:4:1", "statements": [] }, - "freeFunction": false, "id": 4, "implemented": true, "kind": "constructor", diff --git a/test/libsolidity/ASTJSON/abstract_contract_legacy.json b/test/libsolidity/ASTJSON/abstract_contract_legacy.json index f8da2425b..c13abca7f 100644 --- a/test/libsolidity/ASTJSON/abstract_contract_legacy.json +++ b/test/libsolidity/ASTJSON/abstract_contract_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "implemented": true, "isConstructor": true, "kind": "constructor", diff --git a/test/libsolidity/ASTJSON/address_payable.json b/test/libsolidity/ASTJSON/address_payable.json index 8f7ca12be..3365ec436 100644 --- a/test/libsolidity/ASTJSON/address_payable.json +++ b/test/libsolidity/ASTJSON/address_payable.json @@ -462,7 +462,6 @@ } ] }, - "freeFunction": false, "functionSelector": "fc68521a", "id": 38, "implemented": true, diff --git a/test/libsolidity/ASTJSON/address_payable_legacy.json b/test/libsolidity/ASTJSON/address_payable_legacy.json index 15567b5e5..bda50fc57 100644 --- a/test/libsolidity/ASTJSON/address_payable_legacy.json +++ b/test/libsolidity/ASTJSON/address_payable_legacy.json @@ -91,7 +91,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "fc68521a", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/call.json b/test/libsolidity/ASTJSON/assembly/call.json index 5fe3e3f20..9538fe5cc 100644 --- a/test/libsolidity/ASTJSON/assembly/call.json +++ b/test/libsolidity/ASTJSON/assembly/call.json @@ -131,7 +131,6 @@ } ] }, - "freeFunction": false, "functionSelector": "b582ec5f", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/call_legacy.json b/test/libsolidity/ASTJSON/assembly/call_legacy.json index fa9a9830b..2902873fa 100644 --- a/test/libsolidity/ASTJSON/assembly/call_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/call_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "b582ec5f", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/empty_block.json b/test/libsolidity/ASTJSON/assembly/empty_block.json index 18180e76b..2d22cc035 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_block.json +++ b/test/libsolidity/ASTJSON/assembly/empty_block.json @@ -56,7 +56,6 @@ } ] }, - "freeFunction": false, "functionSelector": "e2179b8e", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json b/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json index 8ab74c144..54811bf1a 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "e2179b8e", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/function.json b/test/libsolidity/ASTJSON/assembly/function.json index 0fc33c271..ccbf3d853 100644 --- a/test/libsolidity/ASTJSON/assembly/function.json +++ b/test/libsolidity/ASTJSON/assembly/function.json @@ -118,7 +118,6 @@ } ] }, - "freeFunction": false, "functionSelector": "b8c9d365", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/function_legacy.json b/test/libsolidity/ASTJSON/assembly/function_legacy.json index c7a928b54..940a4b6ac 100644 --- a/test/libsolidity/ASTJSON/assembly/function_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/function_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "b8c9d365", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/leave.json b/test/libsolidity/ASTJSON/assembly/leave.json index 7edbfe11f..ba765146f 100644 --- a/test/libsolidity/ASTJSON/assembly/leave.json +++ b/test/libsolidity/ASTJSON/assembly/leave.json @@ -68,7 +68,6 @@ } ] }, - "freeFunction": false, "functionSelector": "ece866b9", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/leave_legacy.json b/test/libsolidity/ASTJSON/assembly/leave_legacy.json index 02fba96c7..fa71bcba0 100644 --- a/test/libsolidity/ASTJSON/assembly/leave_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/leave_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "ece866b9", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/loop.json b/test/libsolidity/ASTJSON/assembly/loop.json index f565915e8..9c99cf491 100644 --- a/test/libsolidity/ASTJSON/assembly/loop.json +++ b/test/libsolidity/ASTJSON/assembly/loop.json @@ -131,7 +131,6 @@ } ] }, - "freeFunction": false, "functionSelector": "e2179b8e", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/loop_legacy.json b/test/libsolidity/ASTJSON/assembly/loop_legacy.json index 4f1051e03..84890475f 100644 --- a/test/libsolidity/ASTJSON/assembly/loop_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/loop_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "e2179b8e", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions.json b/test/libsolidity/ASTJSON/assembly/nested_functions.json index 8f9acb56f..f945494ba 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions.json +++ b/test/libsolidity/ASTJSON/assembly/nested_functions.json @@ -95,7 +95,6 @@ } ] }, - "freeFunction": false, "functionSelector": "26121ff0", "id": 7, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json b/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json index 2dd973e84..393646221 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset.json b/test/libsolidity/ASTJSON/assembly/slot_offset.json index 5a9b1489f..0858fe617 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset.json +++ b/test/libsolidity/ASTJSON/assembly/slot_offset.json @@ -196,7 +196,6 @@ } ] }, - "freeFunction": false, "functionSelector": "ffae15ba", "id": 10, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json b/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json index d84497d1a..50747baaa 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json @@ -112,7 +112,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "ffae15ba", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/stringlit.json b/test/libsolidity/ASTJSON/assembly/stringlit.json index 872e953ee..08e0ea4f6 100644 --- a/test/libsolidity/ASTJSON/assembly/stringlit.json +++ b/test/libsolidity/ASTJSON/assembly/stringlit.json @@ -72,7 +72,6 @@ } ] }, - "freeFunction": false, "functionSelector": "5a2ee019", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json b/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json index 87c79d107..325d25274 100644 --- a/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "5a2ee019", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/switch.json b/test/libsolidity/ASTJSON/assembly/switch.json index 7380897a0..9ae71f15c 100644 --- a/test/libsolidity/ASTJSON/assembly/switch.json +++ b/test/libsolidity/ASTJSON/assembly/switch.json @@ -180,7 +180,6 @@ } ] }, - "freeFunction": false, "functionSelector": "26121ff0", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/switch_default.json b/test/libsolidity/ASTJSON/assembly/switch_default.json index 2eb2cd9dc..4226a8ea3 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_default.json +++ b/test/libsolidity/ASTJSON/assembly/switch_default.json @@ -95,7 +95,6 @@ } ] }, - "freeFunction": false, "functionSelector": "e2179b8e", "id": 5, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json b/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json index 5f0d10dfc..324330f86 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "e2179b8e", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/switch_legacy.json b/test/libsolidity/ASTJSON/assembly/switch_legacy.json index 9f907e633..92e2e2c61 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/switch_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/assembly/var_access.json b/test/libsolidity/ASTJSON/assembly/var_access.json index bc0a9a3c7..f10c45cc4 100644 --- a/test/libsolidity/ASTJSON/assembly/var_access.json +++ b/test/libsolidity/ASTJSON/assembly/var_access.json @@ -121,7 +121,6 @@ } ] }, - "freeFunction": false, "functionSelector": "26121ff0", "id": 8, "implemented": true, diff --git a/test/libsolidity/ASTJSON/assembly/var_access_legacy.json b/test/libsolidity/ASTJSON/assembly/var_access_legacy.json index 2052a8aed..fcd798ad9 100644 --- a/test/libsolidity/ASTJSON/assembly/var_access_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/var_access_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/constructor.json b/test/libsolidity/ASTJSON/constructor.json index c4b7e9f87..31747901e 100644 --- a/test/libsolidity/ASTJSON/constructor.json +++ b/test/libsolidity/ASTJSON/constructor.json @@ -34,7 +34,6 @@ "src": "28:4:1", "statements": [] }, - "freeFunction": false, "id": 4, "implemented": true, "kind": "constructor", diff --git a/test/libsolidity/ASTJSON/constructor_legacy.json b/test/libsolidity/ASTJSON/constructor_legacy.json index ade4e5629..68a648bc9 100644 --- a/test/libsolidity/ASTJSON/constructor_legacy.json +++ b/test/libsolidity/ASTJSON/constructor_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "implemented": true, "isConstructor": true, "kind": "constructor", diff --git a/test/libsolidity/ASTJSON/documentation.json b/test/libsolidity/ASTJSON/documentation.json index 8cf35a71e..f0beba98f 100644 --- a/test/libsolidity/ASTJSON/documentation.json +++ b/test/libsolidity/ASTJSON/documentation.json @@ -216,7 +216,6 @@ "src": "162:25:3", "text": "Some comment on fn." }, - "freeFunction": false, "functionSelector": "a4a2c40b", "id": 22, "implemented": true, diff --git a/test/libsolidity/ASTJSON/documentation_legacy.json b/test/libsolidity/ASTJSON/documentation_legacy.json index 014b70fe9..4284c4f8f 100644 --- a/test/libsolidity/ASTJSON/documentation_legacy.json +++ b/test/libsolidity/ASTJSON/documentation_legacy.json @@ -161,7 +161,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "a4a2c40b", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/fallback.json b/test/libsolidity/ASTJSON/fallback.json index cf706e4fe..7037b960a 100644 --- a/test/libsolidity/ASTJSON/fallback.json +++ b/test/libsolidity/ASTJSON/fallback.json @@ -34,7 +34,6 @@ "src": "43:5:1", "statements": [] }, - "freeFunction": false, "id": 4, "implemented": true, "kind": "fallback", diff --git a/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json b/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json index e8219b6db..009363e98 100644 --- a/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json +++ b/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json @@ -34,7 +34,6 @@ "src": "42:5:1", "statements": [] }, - "freeFunction": false, "id": 4, "implemented": true, "kind": "receive", @@ -69,7 +68,6 @@ "src": "78:5:1", "statements": [] }, - "freeFunction": false, "id": 8, "implemented": true, "kind": "fallback", diff --git a/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json b/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json index 1fa662d64..8ac17607e 100644 --- a/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json +++ b/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "implemented": true, "isConstructor": false, "kind": "receive", @@ -101,7 +100,6 @@ { "attributes": { - "freeFunction": false, "implemented": true, "isConstructor": false, "kind": "fallback", diff --git a/test/libsolidity/ASTJSON/fallback_legacy.json b/test/libsolidity/ASTJSON/fallback_legacy.json index 9f31a225e..1ee8bf6b3 100644 --- a/test/libsolidity/ASTJSON/fallback_legacy.json +++ b/test/libsolidity/ASTJSON/fallback_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "implemented": true, "isConstructor": false, "kind": "fallback", diff --git a/test/libsolidity/ASTJSON/fallback_payable.json b/test/libsolidity/ASTJSON/fallback_payable.json index 883ba1bfd..2391f57bb 100644 --- a/test/libsolidity/ASTJSON/fallback_payable.json +++ b/test/libsolidity/ASTJSON/fallback_payable.json @@ -34,7 +34,6 @@ "src": "34:2:1", "statements": [] }, - "freeFunction": false, "id": 4, "implemented": true, "kind": "fallback", diff --git a/test/libsolidity/ASTJSON/fallback_payable_legacy.json b/test/libsolidity/ASTJSON/fallback_payable_legacy.json index 2e4a69077..69e25ab6e 100644 --- a/test/libsolidity/ASTJSON/fallback_payable_legacy.json +++ b/test/libsolidity/ASTJSON/fallback_payable_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "implemented": true, "isConstructor": false, "kind": "fallback", diff --git a/test/libsolidity/ASTJSON/function_type.json b/test/libsolidity/ASTJSON/function_type.json index fb706e5e8..c0d2efc68 100644 --- a/test/libsolidity/ASTJSON/function_type.json +++ b/test/libsolidity/ASTJSON/function_type.json @@ -34,7 +34,6 @@ "src": "120:2:1", "statements": [] }, - "freeFunction": false, "functionSelector": "d6cd4974", "id": 16, "implemented": true, diff --git a/test/libsolidity/ASTJSON/function_type_legacy.json b/test/libsolidity/ASTJSON/function_type_legacy.json index cc02a7dd9..627ce45f0 100644 --- a/test/libsolidity/ASTJSON/function_type_legacy.json +++ b/test/libsolidity/ASTJSON/function_type_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "d6cd4974", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json index dd9210e5f..7b598093b 100644 --- a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json +++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json @@ -134,7 +134,6 @@ } ] }, - "freeFunction": false, "functionSelector": "26121ff0", "id": 10, "implemented": true, diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json index 319b1e022..46e5b0417 100644 --- a/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json +++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier.json b/test/libsolidity/ASTJSON/long_type_name_identifier.json index 6df967ea9..4293f6df4 100644 --- a/test/libsolidity/ASTJSON/long_type_name_identifier.json +++ b/test/libsolidity/ASTJSON/long_type_name_identifier.json @@ -142,7 +142,6 @@ } ] }, - "freeFunction": false, "functionSelector": "26121ff0", "id": 14, "implemented": true, diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json index f6ee2b948..ced331a6d 100644 --- a/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json +++ b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json @@ -79,7 +79,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/modifier_definition.json b/test/libsolidity/ASTJSON/modifier_definition.json index d1355a51f..198afe454 100644 --- a/test/libsolidity/ASTJSON/modifier_definition.json +++ b/test/libsolidity/ASTJSON/modifier_definition.json @@ -94,7 +94,6 @@ "src": "64:2:1", "statements": [] }, - "freeFunction": false, "functionSelector": "28811f59", "id": 13, "implemented": true, diff --git a/test/libsolidity/ASTJSON/modifier_definition_legacy.json b/test/libsolidity/ASTJSON/modifier_definition_legacy.json index a48e02104..cc3089395 100644 --- a/test/libsolidity/ASTJSON/modifier_definition_legacy.json +++ b/test/libsolidity/ASTJSON/modifier_definition_legacy.json @@ -102,7 +102,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "28811f59", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/modifier_invocation.json b/test/libsolidity/ASTJSON/modifier_invocation.json index d1355a51f..198afe454 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation.json +++ b/test/libsolidity/ASTJSON/modifier_invocation.json @@ -94,7 +94,6 @@ "src": "64:2:1", "statements": [] }, - "freeFunction": false, "functionSelector": "28811f59", "id": 13, "implemented": true, diff --git a/test/libsolidity/ASTJSON/modifier_invocation_legacy.json b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json index a48e02104..cc3089395 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation_legacy.json +++ b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json @@ -102,7 +102,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "28811f59", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/non_utf8.json b/test/libsolidity/ASTJSON/non_utf8.json index 22d95bf28..98db4273f 100644 --- a/test/libsolidity/ASTJSON/non_utf8.json +++ b/test/libsolidity/ASTJSON/non_utf8.json @@ -94,7 +94,6 @@ } ] }, - "freeFunction": false, "functionSelector": "26121ff0", "id": 8, "implemented": true, diff --git a/test/libsolidity/ASTJSON/non_utf8_legacy.json b/test/libsolidity/ASTJSON/non_utf8_legacy.json index c8d5c312f..d9430c82d 100644 --- a/test/libsolidity/ASTJSON/non_utf8_legacy.json +++ b/test/libsolidity/ASTJSON/non_utf8_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/override.json b/test/libsolidity/ASTJSON/override.json index e38305bf1..49f85144e 100644 --- a/test/libsolidity/ASTJSON/override.json +++ b/test/libsolidity/ASTJSON/override.json @@ -42,7 +42,6 @@ "src": "36:2:1", "statements": [] }, - "freeFunction": false, "functionSelector": "a399b6a2", "id": 4, "implemented": true, @@ -114,7 +113,6 @@ "nodes": [ { - "freeFunction": false, "functionSelector": "c2985578", "id": 10, "implemented": false, @@ -154,7 +152,6 @@ "src": "115:2:1", "statements": [] }, - "freeFunction": false, "functionSelector": "a399b6a2", "id": 15, "implemented": true, @@ -246,7 +243,6 @@ "src": "170:3:1", "statements": [] }, - "freeFunction": false, "functionSelector": "c2985578", "id": 23, "implemented": true, @@ -293,7 +289,6 @@ "src": "212:2:1", "statements": [] }, - "freeFunction": false, "functionSelector": "a399b6a2", "id": 30, "implemented": true, diff --git a/test/libsolidity/ASTJSON/override_legacy.json b/test/libsolidity/ASTJSON/override_legacy.json index bbd03937f..5cdc2f364 100644 --- a/test/libsolidity/ASTJSON/override_legacy.json +++ b/test/libsolidity/ASTJSON/override_legacy.json @@ -46,7 +46,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "a399b6a2", "implemented": true, "isConstructor": false, @@ -155,7 +154,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "c2985578", "implemented": false, "isConstructor": false, @@ -210,7 +208,6 @@ [ 4 ], - "freeFunction": false, "functionSelector": "a399b6a2", "implemented": true, "isConstructor": false, @@ -337,7 +334,6 @@ [ 10 ], - "freeFunction": false, "functionSelector": "c2985578", "implemented": true, "isConstructor": false, @@ -417,7 +413,6 @@ [ 15 ], - "freeFunction": false, "functionSelector": "a399b6a2", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/receive_ether.json b/test/libsolidity/ASTJSON/receive_ether.json index 8b678a593..8a1f0ac9a 100644 --- a/test/libsolidity/ASTJSON/receive_ether.json +++ b/test/libsolidity/ASTJSON/receive_ether.json @@ -34,7 +34,6 @@ "src": "42:5:1", "statements": [] }, - "freeFunction": false, "id": 4, "implemented": true, "kind": "receive", diff --git a/test/libsolidity/ASTJSON/receive_ether_legacy.json b/test/libsolidity/ASTJSON/receive_ether_legacy.json index 1155129d4..d9544f138 100644 --- a/test/libsolidity/ASTJSON/receive_ether_legacy.json +++ b/test/libsolidity/ASTJSON/receive_ether_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "implemented": true, "isConstructor": false, "kind": "receive", diff --git a/test/libsolidity/ASTJSON/short_type_name.json b/test/libsolidity/ASTJSON/short_type_name.json index f569f59af..882fcfe24 100644 --- a/test/libsolidity/ASTJSON/short_type_name.json +++ b/test/libsolidity/ASTJSON/short_type_name.json @@ -88,7 +88,6 @@ } ] }, - "freeFunction": false, "functionSelector": "26121ff0", "id": 10, "implemented": true, diff --git a/test/libsolidity/ASTJSON/short_type_name_legacy.json b/test/libsolidity/ASTJSON/short_type_name_legacy.json index b7912f585..8e255954d 100644 --- a/test/libsolidity/ASTJSON/short_type_name_legacy.json +++ b/test/libsolidity/ASTJSON/short_type_name_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/short_type_name_ref.json b/test/libsolidity/ASTJSON/short_type_name_ref.json index e8845981f..2d07a9c60 100644 --- a/test/libsolidity/ASTJSON/short_type_name_ref.json +++ b/test/libsolidity/ASTJSON/short_type_name_ref.json @@ -99,7 +99,6 @@ } ] }, - "freeFunction": false, "functionSelector": "26121ff0", "id": 11, "implemented": true, diff --git a/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json index f6cd04ed3..5316c56ac 100644 --- a/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json +++ b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/source_location.json b/test/libsolidity/ASTJSON/source_location.json index fa95c0e4a..f56231ed7 100644 --- a/test/libsolidity/ASTJSON/source_location.json +++ b/test/libsolidity/ASTJSON/source_location.json @@ -131,7 +131,6 @@ } ] }, - "freeFunction": false, "functionSelector": "26121ff0", "id": 11, "implemented": true, diff --git a/test/libsolidity/ASTJSON/source_location_legacy.json b/test/libsolidity/ASTJSON/source_location_legacy.json index 529ca4444..bf3dfaedd 100644 --- a/test/libsolidity/ASTJSON/source_location_legacy.json +++ b/test/libsolidity/ASTJSON/source_location_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/string.json b/test/libsolidity/ASTJSON/string.json index 41fe9fa00..f47b41e47 100644 --- a/test/libsolidity/ASTJSON/string.json +++ b/test/libsolidity/ASTJSON/string.json @@ -95,7 +95,6 @@ } ] }, - "freeFunction": false, "functionSelector": "26121ff0", "id": 8, "implemented": true, diff --git a/test/libsolidity/ASTJSON/string_legacy.json b/test/libsolidity/ASTJSON/string_legacy.json index 89c9a5e55..96c984209 100644 --- a/test/libsolidity/ASTJSON/string_legacy.json +++ b/test/libsolidity/ASTJSON/string_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/two_base_functions.json b/test/libsolidity/ASTJSON/two_base_functions.json index 7e6526316..769e5c3f8 100644 --- a/test/libsolidity/ASTJSON/two_base_functions.json +++ b/test/libsolidity/ASTJSON/two_base_functions.json @@ -42,7 +42,6 @@ "src": "45:2:1", "statements": [] }, - "freeFunction": false, "functionSelector": "26121ff0", "id": 4, "implemented": true, @@ -97,7 +96,6 @@ "src": "95:2:1", "statements": [] }, - "freeFunction": false, "functionSelector": "26121ff0", "id": 9, "implemented": true, @@ -201,7 +199,6 @@ "src": "160:2:1", "statements": [] }, - "freeFunction": false, "functionSelector": "26121ff0", "id": 21, "implemented": true, diff --git a/test/libsolidity/ASTJSON/two_base_functions_legacy.json b/test/libsolidity/ASTJSON/two_base_functions_legacy.json index 405576ab6..a5bd2d725 100644 --- a/test/libsolidity/ASTJSON/two_base_functions_legacy.json +++ b/test/libsolidity/ASTJSON/two_base_functions_legacy.json @@ -46,7 +46,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -138,7 +137,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, @@ -274,7 +272,6 @@ 4, 9 ], - "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false, diff --git a/test/libsolidity/ASTJSON/unicode.json b/test/libsolidity/ASTJSON/unicode.json index 99f9eb619..81c8ad0da 100644 --- a/test/libsolidity/ASTJSON/unicode.json +++ b/test/libsolidity/ASTJSON/unicode.json @@ -95,7 +95,6 @@ } ] }, - "freeFunction": false, "functionSelector": "26121ff0", "id": 8, "implemented": true, diff --git a/test/libsolidity/ASTJSON/unicode_legacy.json b/test/libsolidity/ASTJSON/unicode_legacy.json index 826c3ce44..22976f6f9 100644 --- a/test/libsolidity/ASTJSON/unicode_legacy.json +++ b/test/libsolidity/ASTJSON/unicode_legacy.json @@ -38,7 +38,6 @@ { "attributes": { - "freeFunction": false, "functionSelector": "26121ff0", "implemented": true, "isConstructor": false,