Prevent encoding of weird types and support packed encoding of external function types.

This commit is contained in:
chriseth
2018-03-29 09:57:11 +01:00
committed by Alex Beregszaszi
parent c2ae33f806
commit 5c8a6aac69
11 changed files with 110 additions and 4 deletions
+11
View File
@@ -1644,9 +1644,20 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
auto const& argType = type(*arguments[i]);
if (functionType->takesArbitraryParameters())
{
bool errored = false;
if (auto t = dynamic_cast<RationalNumberType const*>(argType.get()))
if (!t->mobileType())
{
m_errorReporter.typeError(arguments[i]->location(), "Invalid rational number (too large or division by zero).");
errored = true;
}
if (!errored && !(
argType->mobileType() &&
argType->mobileType()->interfaceType(false) &&
argType->mobileType()->interfaceType(false)->encodingType() &&
!(dynamic_cast<StructType const*>(argType->mobileType()->interfaceType(false)->encodingType().get()))
))
m_errorReporter.typeError(arguments[i]->location(), "This type cannot be encoded.");
}
else if (!type(*arguments[i])->isImplicitlyConvertibleTo(*parameterTypes[i]))
m_errorReporter.typeError(