MCPcopy Create free account
hub / github.com/argotorg/solidity / checkReceiveFunction

Method checkReceiveFunction

libsolidity/analysis/ContractLevelChecker.cpp:203–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201}
202
203void ContractLevelChecker::checkReceiveFunction(ContractDefinition const& _contract)
204{
205 for (FunctionDefinition const* function: _contract.definedFunctions())
206 {
207 solAssert(function, "");
208 if (function->isReceive())
209 {
210 if (function->libraryFunction())
211 m_errorReporter.declarationError(4549_error, function->location(), "Libraries cannot have receive ether functions.");
212
213 if (function->stateMutability() != StateMutability::Payable)
214 m_errorReporter.declarationError(
215 7793_error,
216 function->location(),
217 "Receive ether function must be payable, but is \"" +
218 stateMutabilityToString(function->stateMutability()) +
219 "\"."
220 );
221 if (function->visibility() != Visibility::External)
222 m_errorReporter.declarationError(4095_error, function->location(), "Receive ether function must be defined as \"external\".");
223
224 if (!function->returnParameters().empty())
225 m_errorReporter.fatalDeclarationError(6899_error, function->returnParameterList()->location(), "Receive ether function cannot return values.");
226 if (!function->parameters().empty())
227 m_errorReporter.fatalDeclarationError(6857_error, function->parameterList().location(), "Receive ether function cannot take parameters.");
228 }
229 }
230}
231
232template <class T>
233void ContractLevelChecker::findDuplicateDefinitions(std::map<std::string, std::vector<T>> const& _definitions)

Callers

nothing calls this directly

Calls 11

stateMutabilityToStringFunction · 0.85
definedFunctionsMethod · 0.80
isReceiveMethod · 0.80
libraryFunctionMethod · 0.80
declarationErrorMethod · 0.80
fatalDeclarationErrorMethod · 0.80
parametersMethod · 0.80
locationMethod · 0.45
stateMutabilityMethod · 0.45
visibilityMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected