| 2084 | } |
| 2085 | |
| 2086 | void TypeChecker::typeCheckABIEncodeFunctions( |
| 2087 | FunctionCall const& _functionCall, |
| 2088 | FunctionTypePointer _functionType |
| 2089 | ) |
| 2090 | { |
| 2091 | solAssert(!!_functionType, ""); |
| 2092 | solAssert( |
| 2093 | _functionType->kind() == FunctionType::Kind::ABIEncode || |
| 2094 | _functionType->kind() == FunctionType::Kind::ABIEncodePacked || |
| 2095 | _functionType->kind() == FunctionType::Kind::ABIEncodeWithSelector || |
| 2096 | _functionType->kind() == FunctionType::Kind::ABIEncodeCall || |
| 2097 | _functionType->kind() == FunctionType::Kind::ABIEncodeWithSignature, |
| 2098 | "ABI function has unexpected FunctionType::Kind." |
| 2099 | ); |
| 2100 | solAssert(_functionType->takesArbitraryParameters(), "ABI functions should be variadic."); |
| 2101 | |
| 2102 | bool const isPacked = _functionType->kind() == FunctionType::Kind::ABIEncodePacked; |
| 2103 | solAssert(_functionType->padArguments() != isPacked, "ABI function with unexpected padding"); |
| 2104 | |
| 2105 | bool const abiEncoderV2 = useABICoderV2(); |
| 2106 | |
| 2107 | // Check for named arguments |
| 2108 | if (!_functionCall.names().empty()) |
| 2109 | { |
| 2110 | m_errorReporter.typeError( |
| 2111 | 2627_error, |
| 2112 | _functionCall.location(), |
| 2113 | "Named arguments cannot be used for functions that take arbitrary parameters." |
| 2114 | ); |
| 2115 | return; |
| 2116 | } |
| 2117 | |
| 2118 | // Perform standard function call type checking |
| 2119 | typeCheckFunctionGeneralChecks(_functionCall, _functionType); |
| 2120 | |
| 2121 | // No further generic checks needed as we do a precise check for ABIEncodeCall |
| 2122 | if (_functionType->kind() == FunctionType::Kind::ABIEncodeCall) |
| 2123 | { |
| 2124 | typeCheckABIEncodeCallFunction(_functionCall); |
| 2125 | return; |
| 2126 | } |
| 2127 | |
| 2128 | // Check additional arguments for variadic functions |
| 2129 | std::vector<ASTPointer<Expression const>> const& arguments = _functionCall.arguments(); |
| 2130 | for (size_t i = 0; i < arguments.size(); ++i) |
| 2131 | { |
| 2132 | auto const& argType = type(*arguments[i]); |
| 2133 | |
| 2134 | if (argType->category() == Type::Category::RationalNumber) |
| 2135 | { |
| 2136 | auto const& rationalType = dynamic_cast<RationalNumberType const&>(*argType); |
| 2137 | if (rationalType.isFractional()) |
| 2138 | { |
| 2139 | m_errorReporter.typeError( |
| 2140 | 6090_error, |
| 2141 | arguments[i]->location(), |
| 2142 | "Fractional numbers cannot yet be encoded." |
| 2143 | ); |
nothing calls this directly
no test coverage detected