Disallow packed encoding of literals.

This commit is contained in:
chriseth
2018-07-03 01:02:00 +02:00
parent 4649f9202a
commit f7a9c4203e
6 changed files with 20 additions and 32 deletions
+7 -17
View File
@@ -1702,8 +1702,6 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
else
_functionCall.annotation().type = make_shared<TupleType>(returnTypes);
bool const v050 = m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050);
if (auto functionName = dynamic_cast<Identifier const*>(&_functionCall.expression()))
{
if (functionName->name() == "sha3" && functionType->kind() == FunctionType::Kind::SHA3)
@@ -1723,23 +1721,15 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
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.typeError(
arguments[i]->location(),
"Cannot perform packed encoding for a literal. Please convert it to an explicit type first."
);
else
{
if (v050)
m_errorReporter.typeError(
arguments[i]->location(),
"Cannot perform packed encoding for a literal. Please convert it to an explicit type first."
);
else
m_errorReporter.warning(
arguments[i]->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 no mobile type is available an error will be raised elsewhere. */
solAssert(m_errorReporter.hasErrors(), "");
}
}
}