diff --git a/Changelog.md b/Changelog.md index c316e891f..a53c6a858 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,6 +10,7 @@ Compiler Features: Bugfixes: + * Parser: Fix an internal error for ``abstract`` without ``contract``. diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 6072ef6bb..9f165c75c 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -278,7 +278,8 @@ std::pair Parser::parseContractKind() kind = ContractKind::Library; break; default: - solAssert(false, "Invalid contract kind."); + parserError("Expected keyword \"contract\", \"interface\" or \"library\"."); + return std::make_pair(ContractKind::Contract, abstract); } m_scanner->next(); return std::make_pair(kind, abstract); diff --git a/test/libsolidity/syntaxTests/abstract/abstract_only.sol b/test/libsolidity/syntaxTests/abstract/abstract_only.sol new file mode 100644 index 000000000..1445324a2 --- /dev/null +++ b/test/libsolidity/syntaxTests/abstract/abstract_only.sol @@ -0,0 +1,4 @@ +abstract +// ---- +// ParserError: (9-9): Expected keyword "contract", "interface" or "library". +// ParserError: (9-9): Expected identifier but got end of source diff --git a/test/libsolidity/syntaxTests/abstract/abstract_without_contract.sol b/test/libsolidity/syntaxTests/abstract/abstract_without_contract.sol new file mode 100644 index 000000000..5e5e25bbe --- /dev/null +++ b/test/libsolidity/syntaxTests/abstract/abstract_without_contract.sol @@ -0,0 +1,3 @@ +abstract A { } +// ---- +// ParserError: (9-10): Expected keyword "contract", "interface" or "library".