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

Method typeCheckFallbackFunction

libsolidity/analysis/TypeChecker.cpp:2012–2043  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2010}
2011
2012void 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
2045void TypeChecker::typeCheckConstructor(FunctionDefinition const& _function)
2046{

Callers

nothing calls this directly

Calls 11

stateMutabilityToStringFunction · 0.85
typeFunction · 0.85
isFallbackMethod · 0.80
libraryFunctionMethod · 0.80
typeErrorMethod · 0.80
parametersMethod · 0.80
locationMethod · 0.45
stateMutabilityMethod · 0.45
visibilityMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected