| 2010 | } |
| 2011 | |
| 2012 | void TypeChecker::typeCheckFallbackFunction(FunctionDefinition const& _function) |
| 2013 | { |
| 2014 | solAssert(_function.isFallback(), ""); |
| 2015 | |
| 2016 | if (_function.libraryFunction()) |
| 2017 | m_errorReporter.typeError(5982_error, _function.location(), "Libraries cannot have fallback functions."); |
| 2018 | if (_function.stateMutability() != StateMutability::NonPayable && _function.stateMutability() != StateMutability::Payable) |
| 2019 | m_errorReporter.typeError( |
| 2020 | 4575_error, |
| 2021 | _function.location(), |
| 2022 | "Fallback function must be payable or non-payable, but is \"" + |
| 2023 | stateMutabilityToString(_function.stateMutability()) + |
| 2024 | "\"." |
| 2025 | ); |
| 2026 | if (_function.visibility() != Visibility::External) |
| 2027 | m_errorReporter.typeError(1159_error, _function.location(), "Fallback function must be defined as \"external\"."); |
| 2028 | |
| 2029 | if (!_function.returnParameters().empty() || !_function.parameters().empty()) |
| 2030 | { |
| 2031 | if ( |
| 2032 | _function.returnParameters().size() != 1 || |
| 2033 | *type(*_function.returnParameters().front()) != *TypeProvider::bytesMemory() || |
| 2034 | _function.parameters().size() != 1 || |
| 2035 | *type(*_function.parameters().front()) != *TypeProvider::bytesCalldata() |
| 2036 | ) |
| 2037 | m_errorReporter.typeError( |
| 2038 | 5570_error, |
| 2039 | _function.returnParameterList()->location(), |
| 2040 | "Fallback function either has to have the signature \"fallback()\" or \"fallback(bytes calldata) returns (bytes memory)\"." |
| 2041 | ); |
| 2042 | } |
| 2043 | } |
| 2044 | |
| 2045 | void TypeChecker::typeCheckConstructor(FunctionDefinition const& _function) |
| 2046 | { |
nothing calls this directly
no test coverage detected