aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-02-12 17:40:18 +0800
committerGitHub <noreply@github.com>2018-02-12 17:40:18 +0800
commit49d867d27bba1f380e33749804eaa948623efa23 (patch)
tree435af7721119cf12f952890e280e48d380a5510f
parent2095e7a32dce04f6142074bf96f14b6c7046137a (diff)
parent75a3a707a243ccb6135c7931bb32ac7b44551082 (diff)
downloaddexon-solidity-49d867d27bba1f380e33749804eaa948623efa23.tar
dexon-solidity-49d867d27bba1f380e33749804eaa948623efa23.tar.gz
dexon-solidity-49d867d27bba1f380e33749804eaa948623efa23.tar.bz2
dexon-solidity-49d867d27bba1f380e33749804eaa948623efa23.tar.lz
dexon-solidity-49d867d27bba1f380e33749804eaa948623efa23.tar.xz
dexon-solidity-49d867d27bba1f380e33749804eaa948623efa23.tar.zst
dexon-solidity-49d867d27bba1f380e33749804eaa948623efa23.zip
Merge pull request #3484 from federicobond/fix-segfault
Fix segfault with undeclared array types
-rw-r--r--libsolidity/analysis/ReferencesResolver.cpp5
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp10
2 files changed, 15 insertions, 0 deletions
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp
index 30b06615..451d6c93 100644
--- a/libsolidity/analysis/ReferencesResolver.cpp
+++ b/libsolidity/analysis/ReferencesResolver.cpp
@@ -153,6 +153,11 @@ void ReferencesResolver::endVisit(Mapping const& _typeName)
void ReferencesResolver::endVisit(ArrayTypeName const& _typeName)
{
TypePointer baseType = _typeName.baseType().annotation().type;
+ if (!baseType)
+ {
+ solAssert(!m_errorReporter.errors().empty(), "");
+ return;
+ }
if (baseType->storageBytes() == 0)
fatalTypeError(_typeName.baseType().location(), "Illegal base type of storage size zero for array.");
if (Expression const* length = _typeName.length())
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index e8405281..ee6a0633 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -2196,6 +2196,16 @@ BOOST_AUTO_TEST_CASE(array_copy_with_different_types_dynamic_static)
CHECK_ERROR(text, TypeError, "Type uint256[] storage ref is not implicitly convertible to expected type uint256[80] storage ref.");
}
+BOOST_AUTO_TEST_CASE(array_of_undeclared_type)
+{
+ char const* text = R"(
+ contract c {
+ a[] public foo;
+ }
+ )";
+ CHECK_ERROR(text, DeclarationError, "Identifier not found or not unique.");
+}
+
BOOST_AUTO_TEST_CASE(storage_variable_initialization_with_incorrect_type_int)
{
char const* text = R"(