From 031fd568cc753c2ac21e651eaadf2381b2585191 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 15 Sep 2016 18:01:13 +0200 Subject: [PATCH] Fix crash for TypeName[k]. --- Changelog.md | 8 ++++++++ libsolidity/analysis/TypeChecker.cpp | 2 +- test/libsolidity/SolidityNameAndTypeResolution.cpp | 10 ++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 1ae186581..d61ac7c83 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,11 @@ +### 0.4.2 + + * Type Checker: Fixed a crash about invalid array types. + +### 0.4.1 (2016-09-09) + + * Build System: Fixes to allow library compilation. + ### 0.4.0 (2016-09-08) This release deliberately breaks backwards compatibility mostly to diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index d9c54f755..ae7c13c88 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1438,7 +1438,7 @@ bool TypeChecker::visit(IndexAccess const& _access) length->literalValue(nullptr) )); else - typeError(index->location(), "Integer constant expected."); + fatalTypeError(index->location(), "Integer constant expected."); } break; } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 58736025b..b8c643360 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -4009,6 +4009,16 @@ BOOST_AUTO_TEST_CASE(external_constructor) BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); } +BOOST_AUTO_TEST_CASE(invalid_array_as_statement) +{ + char const* text = R"( + contract test { + struct S { uint x; } + function test(uint k) { S[k]; } + } + )"; + BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); +} BOOST_AUTO_TEST_SUITE_END()