| 201 | } |
| 202 | |
| 203 | void 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 | |
| 232 | template <class T> |
| 233 | void ContractLevelChecker::findDuplicateDefinitions(std::map<std::string, std::vector<T>> const& _definitions) |
nothing calls this directly
no test coverage detected