diff --git a/test/libsolidity/util/TestFileParser.cpp b/test/libsolidity/util/TestFileParser.cpp index 8782fe01d..397550e5d 100644 --- a/test/libsolidity/util/TestFileParser.cpp +++ b/test/libsolidity/util/TestFileParser.cpp @@ -550,6 +550,11 @@ void TestFileParser::Scanner::scanNextToken() token = selectToken(Token::Whitespace); else if (isEndOfLine()) token = selectToken(Token::EOS); + else + throw Error( + Error::Type::ParserError, + "Unexpected character: '" + string{current()} + "'" + ); break; } } diff --git a/test/libsolidity/util/TestFileParserTests.cpp b/test/libsolidity/util/TestFileParserTests.cpp index 03325dea2..38e29968c 100644 --- a/test/libsolidity/util/TestFileParserTests.cpp +++ b/test/libsolidity/util/TestFileParserTests.cpp @@ -775,6 +775,14 @@ BOOST_AUTO_TEST_CASE(call_arrow_missing) BOOST_REQUIRE_THROW(parse(source), langutil::Error); } +BOOST_AUTO_TEST_CASE(call_unexpected_character) +{ + char const* source = R"( + // f() -> ?? + )"; + BOOST_REQUIRE_THROW(parse(source), langutil::Error); +} + BOOST_AUTO_TEST_SUITE_END() }