From 069ea38916a96dfb194cf8d2a0f5e07f9a586bf3 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 20 Apr 2018 01:31:30 +0100 Subject: Make literals an error for tight packing (experimental 0.5.0) --- libsolidity/analysis/TypeChecker.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'libsolidity/analysis') 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(returnTypes); + bool const v050 = m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050); + if (auto functionName = dynamic_cast(&_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." + ); + } } } } -- cgit v1.2.3