aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-08-25 19:17:44 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-08-25 21:16:50 +0800
commitf6dba97fe174c95f9dd5defdd8f443c121f73956 (patch)
tree88685e47c9a7ee058ed124badc66241e9e50dc81 /libsolidity
parent1437521df0136fc3654dd74c816d724c50a125ee (diff)
downloaddexon-solidity-f6dba97fe174c95f9dd5defdd8f443c121f73956.tar.gz
dexon-solidity-f6dba97fe174c95f9dd5defdd8f443c121f73956.tar.zst
dexon-solidity-f6dba97fe174c95f9dd5defdd8f443c121f73956.zip
Warn on using literals in tight packing
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 99f3c64c..d594a060 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -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 =