Warn on using literals in tight packing

This commit is contained in:
Alex Beregszaszi
2017-08-25 14:16:50 +01:00
parent 1437521df0
commit f6dba97fe1
3 changed files with 67 additions and 0 deletions
+22
View File
@@ -1446,6 +1446,28 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
_functionCall.annotation().type = make_shared<TupleType>(functionType->returnParameterTypes());
TypePointers parameterTypes = functionType->parameterTypes();
if (!functionType->padArguments())
{
for (size_t i = 0; i < arguments.size(); ++i)
{
auto const& argType = type(*arguments[i]);
if (auto literal = dynamic_cast<RationalNumberType const*>(argType.get()))
{
/* If no mobile type is available an error will be raised elsewhere. */
if (literal->mobileType())
m_errorReporter.warning(
_functionCall.location(),
"The type of \"" +
argType->toString() +
"\" was inferred as " +
literal->mobileType()->toString() +
". This is probably not desired. Use an explicit type to silence this warning."
);
}
}
}
if (!functionType->takesArbitraryParameters() && parameterTypes.size() != arguments.size())
{
string msg =