aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-04-20 08:31:30 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-04-20 18:58:16 +0800
commit069ea38916a96dfb194cf8d2a0f5e07f9a586bf3 (patch)
treecfea4a296c46b053466efad84c71dffda7f800f4 /libsolidity/analysis
parent676732776eaf087a17b79bc97213c84746dabd09 (diff)
downloaddexon-solidity-069ea38916a96dfb194cf8d2a0f5e07f9a586bf3.tar.gz
dexon-solidity-069ea38916a96dfb194cf8d2a0f5e07f9a586bf3.tar.zst
dexon-solidity-069ea38916a96dfb194cf8d2a0f5e07f9a586bf3.zip
Make literals an error for tight packing (experimental 0.5.0)
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 72d29762..66b0af58 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1648,6 +1648,8 @@ 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)
@@ -1674,14 +1676,22 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
{
/* If no mobile type is available an error will be raised elsewhere. */
if (literal->mobileType())
- 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 (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."
+ );
+ }
}
}
}