aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen
diff options
context:
space:
mode:
authorDaniel Kirchner <daniel@ekpyron.org>2018-07-05 00:34:24 +0800
committerDaniel Kirchner <daniel@ekpyron.org>2018-07-13 02:33:51 +0800
commitfc370591f02d2bcfe52b62776a871b33e933bd34 (patch)
tree08101656cd0bef2da7a93fea9e3806e235a2acbd /libsolidity/codegen
parent5d8a8f726555361a78dac05a5413558f3f63f7f1 (diff)
downloaddexon-solidity-fc370591f02d2bcfe52b62776a871b33e933bd34.tar.gz
dexon-solidity-fc370591f02d2bcfe52b62776a871b33e933bd34.tar.zst
dexon-solidity-fc370591f02d2bcfe52b62776a871b33e933bd34.zip
Disallow multi variable declarations with mismatching number of values.
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp
index 93f698bc..bbb3db3d 100644
--- a/libsolidity/codegen/ContractCompiler.cpp
+++ b/libsolidity/codegen/ContractCompiler.cpp
@@ -833,20 +833,19 @@ bool ContractCompiler::visit(VariableDeclarationStatement const& _variableDeclar
valueTypes = tupleType->components();
else
valueTypes = TypePointers{expression->annotation().type};
- auto const& assignments = _variableDeclarationStatement.annotation().assignments;
- solAssert(assignments.size() == valueTypes.size(), "");
- for (size_t i = 0; i < assignments.size(); ++i)
+ auto const& declarations = _variableDeclarationStatement.declarations();
+ solAssert(declarations.size() == valueTypes.size(), "");
+ for (size_t i = 0; i < declarations.size(); ++i)
{
- size_t j = assignments.size() - i - 1;
+ size_t j = declarations.size() - i - 1;
solAssert(!!valueTypes[j], "");
- VariableDeclaration const* varDecl = assignments[j];
- if (!varDecl)
- utils.popStackElement(*valueTypes[j]);
- else
+ if (VariableDeclaration const* varDecl = declarations[j].get())
{
utils.convertType(*valueTypes[j], *varDecl->annotation().type);
utils.moveToStackVariable(*varDecl);
}
+ else
+ utils.popStackElement(*valueTypes[j]);
}
}
checker.check();