diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 86514cf01..e4be3470c 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -629,6 +629,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly) bool requiresStorage = ref->second.isSlot || ref->second.isOffset; if (auto var = dynamic_cast(declaration)) { + solAssert(var->type(), "Expected variable type!"); if (var->isConstant()) { m_errorReporter.typeError(_identifier.location, "Constant variables not supported by inline assembly."); @@ -1009,6 +1010,14 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) } } + if (valueTypes.size() != variables.size()) + { + solAssert(m_errorReporter.hasErrors(), "Should have errors!"); + for (auto const& var: variables) + if (var && !var->annotation().type) + BOOST_THROW_EXCEPTION(FatalError()); + } + if (autoTypeDeductionNeeded) { if (!typeCanBeExpressed(variables)) diff --git a/test/libsolidity/syntaxTests/types/var_decl_val_mismatch.sol b/test/libsolidity/syntaxTests/types/var_decl_val_mismatch.sol new file mode 100644 index 000000000..d8cc51d83 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_decl_val_mismatch.sol @@ -0,0 +1,17 @@ +contract n +{ + function() + { + // Used to cause a segfault + var (x,y) = (1); + var (z) = (); + + assembly { + mstore(y, z) + } + } +} +// ---- +// SyntaxError: (14-129): No visibility specified. Did you intend to add "external"? +// TypeError: (14-129): Fallback function must be defined as "external". +// TypeError: (60-75): Different number of components on the left hand side (2) than on the right hand side (1). diff --git a/test/libsolidity/syntaxTests/types/var_type_suggest.sol b/test/libsolidity/syntaxTests/types/var_type_suggest.sol index 2de893cb7..392d7bc83 100644 --- a/test/libsolidity/syntaxTests/types/var_type_suggest.sol +++ b/test/libsolidity/syntaxTests/types/var_type_suggest.sol @@ -28,10 +28,3 @@ contract C { // SyntaxError: (360-384): Use of the "var" keyword is disallowed. Use explicit declaration `(uint8 a, string memory b) = ...´ instead. // SyntaxError: (394-411): Use of the "var" keyword is disallowed. Use explicit declaration `(uint256 x, , uint256 z) = ...´ instead. // TypeError: (421-438): Different number of components on the left hand side (2) than on the right hand side (1). -// SyntaxError: (421-438): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. -// TypeError: (448-464): Different number of components on the left hand side (2) than on the right hand side (1). -// SyntaxError: (448-464): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. -// TypeError: (474-488): Different number of components on the left hand side (2) than on the right hand side (1). -// SyntaxError: (474-488): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. -// TypeError: (498-513): Different number of components on the left hand side (2) than on the right hand side (1). -// SyntaxError: (498-513): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.