diff options
-rw-r--r-- | Changelog.md | 1 | ||||
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 2 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 15 |
3 files changed, 17 insertions, 1 deletions
diff --git a/Changelog.md b/Changelog.md index 49d92eb5..3574455b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -13,6 +13,7 @@ Bugfixes: * Assembly Parser: Be more strict about number literals. * Parser: Enforce commas between array and tuple elements. * Parser: Limit maximum recursion depth. + * Type Checker: Crash fix related to ``using``. * Type Checker: Disallow constructors in libraries. ### 0.4.15 (2017-08-08) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index e5660cde..32d078fd 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -463,7 +463,7 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor) _usingFor.libraryName().annotation().referencedDeclaration ); if (!library || !library->isLibrary()) - m_errorReporter.typeError(_usingFor.libraryName().location(), "Library name expected."); + m_errorReporter.fatalTypeError(_usingFor.libraryName().location(), "Library name expected."); } bool TypeChecker::visit(StructDefinition const& _struct) diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index fad1ca61..e349bf83 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -6657,6 +6657,21 @@ BOOST_AUTO_TEST_CASE(library_function_without_implementation) CHECK_ERROR(text, TypeError, "Internal library function must be implemented if declared."); } +BOOST_AUTO_TEST_CASE(using_for_with_non_library) +{ + // This tests a crash that was resolved by making the first error fatal. + char const* text = R"( + library L { + struct S { uint d; } + using S for S; + function f(S _s) internal { + _s.d = 1; + } + } + )"; + CHECK_ERROR(text, TypeError, "Library name expected."); +} + BOOST_AUTO_TEST_CASE(experimental_pragma) { char const* text = R"( |