aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis/TypeChecker.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-07-11 04:20:10 +0800
committerchriseth <chris@ethereum.org>2018-07-11 04:29:53 +0800
commit458a4c8aa5dc88aed46ad1ab1494fa035af09e31 (patch)
treef63016ab57d28a53cfef43e4fbf13ff37bc81366 /libsolidity/analysis/TypeChecker.cpp
parent1505e28b56c3a90abdb606ed1389394d7918d7eb (diff)
downloaddexon-solidity-458a4c8aa5dc88aed46ad1ab1494fa035af09e31.tar
dexon-solidity-458a4c8aa5dc88aed46ad1ab1494fa035af09e31.tar.gz
dexon-solidity-458a4c8aa5dc88aed46ad1ab1494fa035af09e31.tar.bz2
dexon-solidity-458a4c8aa5dc88aed46ad1ab1494fa035af09e31.tar.lz
dexon-solidity-458a4c8aa5dc88aed46ad1ab1494fa035af09e31.tar.xz
dexon-solidity-458a4c8aa5dc88aed46ad1ab1494fa035af09e31.tar.zst
dexon-solidity-458a4c8aa5dc88aed46ad1ab1494fa035af09e31.zip
Coding style.
Diffstat (limited to 'libsolidity/analysis/TypeChecker.cpp')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp41
1 files changed, 18 insertions, 23 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 9de7829c..e036719a 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1052,48 +1052,46 @@ void TypeChecker::endVisit(EmitStatement const& _emit)
m_insideEmitStatement = false;
}
+namespace
+{
/**
- * Creates a tuple declaration syntax from a vector of variable declarations.
- *
- * @param decls a tuple of variables
- *
- * @returns a Solidity language confirming string of a tuple variable declaration.
+ * @returns a suggested left-hand-side of a multi-variable declaration contairing
+ * the variable declarations given in @a _decls.
*/
-static string createTupleDecl(vector<VariableDeclaration const*> const & decls)
+string createTupleDecl(vector<VariableDeclaration const*> const& _decls)
{
vector<string> components;
- for (VariableDeclaration const* decl : decls)
+ for (VariableDeclaration const* decl: _decls)
if (decl)
components.emplace_back(decl->annotation().type->toString(false) + " " + decl->name());
else
components.emplace_back();
- if (decls.size() == 1)
+ if (_decls.size() == 1)
return components.front();
else
return "(" + boost::algorithm::join(components, ", ") + ")";
}
-static bool typeCanBeExpressed(vector<VariableDeclaration const*> const & decls)
+bool typeCanBeExpressed(vector<VariableDeclaration const*> const& decls)
{
- for (VariableDeclaration const* decl : decls)
+ for (VariableDeclaration const* decl: decls)
{
// skip empty tuples (they can be expressed of course)
if (!decl)
continue;
if (auto functionType = dynamic_cast<FunctionType const*>(decl->annotation().type.get()))
- {
if (
functionType->kind() != FunctionType::Kind::Internal &&
functionType->kind() != FunctionType::Kind::External
)
return false;
- }
}
return true;
}
+}
bool TypeChecker::visit(VariableDeclarationStatement const& _statement)
{
@@ -1302,20 +1300,17 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement)
if (autoTypeDeductionNeeded)
{
if (!typeCanBeExpressed(assignments))
- {
- m_errorReporter.syntaxError(_statement.location(),
+ m_errorReporter.syntaxError(
+ _statement.location(),
"Use of the \"var\" keyword is disallowed. "
- "Type cannot be expressed in syntax.");
- }
+ "Type cannot be expressed in syntax."
+ );
else
- {
- // report with trivial snipped `uint i = ...`
- string const typeName = createTupleDecl(assignments);
-
- m_errorReporter.syntaxError(_statement.location(),
+ m_errorReporter.syntaxError(
+ _statement.location(),
"Use of the \"var\" keyword is disallowed. "
- "Use explicit declaration `" + typeName + " = ...´ instead.");
- }
+ "Use explicit declaration `" + createTupleDecl(assignments) + " = ...´ instead."
+ );
}
return false;