mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Complete error coverage of Parser and SyntaxChecker
This commit is contained in:
parent
2037b7d6b8
commit
3698cd54a5
@ -223,8 +223,8 @@ def examine_id_coverage(top_dir, source_id_to_file_names, new_ids_only=False):
|
|||||||
"1123", "1133", "1220", "1584", "1823", "1950",
|
"1123", "1133", "1220", "1584", "1823", "1950",
|
||||||
"1988", "2418", "2461", "2512", "2592", "2657", "2800", "2842", "2856",
|
"1988", "2418", "2461", "2512", "2592", "2657", "2800", "2842", "2856",
|
||||||
"3263", "3356", "3441", "3682", "3876",
|
"3263", "3356", "3441", "3682", "3876",
|
||||||
"3893", "3997", "4010", "4281", "4802", "4805", "4828",
|
"3893", "4010", "4281", "4802", "4805", "4828",
|
||||||
"4904", "4990", "5052", "5073", "5170", "5188", "5272", "5333", "5347", "5473",
|
"4904", "4990", "5052", "5073", "5170", "5188", "5272", "5347", "5473",
|
||||||
"5622", "6041", "6052", "6272", "6708", "6792", "6931", "7110", "7128", "7186",
|
"5622", "6041", "6052", "6272", "6708", "6792", "6931", "7110", "7128", "7186",
|
||||||
"7589", "7593", "7653", "7812", "7885", "8065", "8084", "8140",
|
"7589", "7593", "7653", "7812", "7885", "8065", "8084", "8140",
|
||||||
"8261", "8312", "8592", "8758", "9011",
|
"8261", "8312", "8592", "8758", "9011",
|
||||||
|
@ -114,7 +114,7 @@ do
|
|||||||
SOL_FILES+=("$line")
|
SOL_FILES+=("$line")
|
||||||
done < <(
|
done < <(
|
||||||
grep -riL -E \
|
grep -riL -E \
|
||||||
"^\/\/ (Syntax|Type|Declaration)Error|^\/\/ ParserError (6275|3716|6281|2837|6933)|^==== Source:" \
|
"^\/\/ (Syntax|Type|Declaration)Error|^\/\/ ParserError (2837|3716|3997|5333|6275|6281|6933)|^==== Source:" \
|
||||||
"${ROOT_DIR}/test/libsolidity/syntaxTests" \
|
"${ROOT_DIR}/test/libsolidity/syntaxTests" \
|
||||||
"${ROOT_DIR}/test/libsolidity/semanticTests" \
|
"${ROOT_DIR}/test/libsolidity/semanticTests" \
|
||||||
)
|
)
|
||||||
|
@ -94,7 +94,22 @@ ErrorList AnalysisFramework::filterErrors(ErrorList const& _errorList, bool _inc
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
errors.emplace_back(currentError);
|
std::shared_ptr<Error const> newError = currentError;
|
||||||
|
for (auto const& messagePrefix: m_messagesToCut)
|
||||||
|
if (currentError->comment()->find(messagePrefix) == 0)
|
||||||
|
{
|
||||||
|
SourceLocation const* location = boost::get_error_info<errinfo_sourceLocation>(*currentError);
|
||||||
|
// sufficient for now, but in future we might clone the error completely, including the secondary location
|
||||||
|
newError = make_shared<Error>(
|
||||||
|
currentError->errorId(),
|
||||||
|
currentError->type(),
|
||||||
|
location ? *location : SourceLocation(),
|
||||||
|
messagePrefix + " ...."
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
errors.emplace_back(newError);
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors;
|
return errors;
|
||||||
|
@ -71,6 +71,7 @@ protected:
|
|||||||
langutil::ErrorList filterErrors(langutil::ErrorList const& _errorList, bool _includeWarnings) const;
|
langutil::ErrorList filterErrors(langutil::ErrorList const& _errorList, bool _includeWarnings) const;
|
||||||
|
|
||||||
std::vector<std::string> m_warningsToFilter = {"This is a pre-release compiler version"};
|
std::vector<std::string> m_warningsToFilter = {"This is a pre-release compiler version"};
|
||||||
|
std::vector<std::string> m_messagesToCut = {"Source file requires different compiler version (current compiler is"};
|
||||||
|
|
||||||
/// @returns reference to lazy-instanciated CompilerStack.
|
/// @returns reference to lazy-instanciated CompilerStack.
|
||||||
solidity::frontend::CompilerStack& compiler()
|
solidity::frontend::CompilerStack& compiler()
|
||||||
|
@ -124,35 +124,6 @@ BOOST_AUTO_TEST_CASE(reserved_keywords)
|
|||||||
BOOST_CHECK(!TokenTraits::isReservedKeyword(Token::Illegal));
|
BOOST_CHECK(!TokenTraits::isReservedKeyword(Token::Illegal));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(unsatisfied_version)
|
|
||||||
{
|
|
||||||
char const* text = R"(
|
|
||||||
pragma solidity ^99.99.0;
|
|
||||||
)";
|
|
||||||
CHECK_PARSE_ERROR(text, "Source file requires different compiler version");
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(unsatisfied_version_followed_by_invalid_syntax)
|
|
||||||
{
|
|
||||||
char const* text = R"(
|
|
||||||
pragma solidity ^99.99.0;
|
|
||||||
this is surely invalid
|
|
||||||
)";
|
|
||||||
CHECK_PARSE_ERROR(text, "Source file requires different compiler version");
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(unsatisfied_version_with_recovery)
|
|
||||||
{
|
|
||||||
char const* text = R"(
|
|
||||||
pragma solidity ^99.99.0;
|
|
||||||
contract test {
|
|
||||||
uint ;
|
|
||||||
}
|
|
||||||
)";
|
|
||||||
Error err = getError(text, true);
|
|
||||||
BOOST_CHECK(searchErrorMessage(err, "Expected identifier but got ';'"));
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(function_natspec_documentation)
|
BOOST_AUTO_TEST_CASE(function_natspec_documentation)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
pragma solidity ^99.99.0;
|
||||||
|
// ----
|
||||||
|
// SyntaxError 3997: (0-25): Source file requires different compiler version (current compiler is ....
|
@ -0,0 +1,4 @@
|
|||||||
|
pragma solidity ^99.99.0;
|
||||||
|
this is surely invalid
|
||||||
|
// ----
|
||||||
|
// ParserError 7858: (26-30): Expected pragma, import directive or contract/interface/library/struct/enum/function definition.
|
@ -0,0 +1,7 @@
|
|||||||
|
pragma solidity ^99.99.0;
|
||||||
|
contract C {
|
||||||
|
uint ;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 6635: (48-49): Expected identifier but got ';'
|
||||||
|
// ParserError 6635: (50-51): Expected ';' but got '}'
|
@ -0,0 +1,7 @@
|
|||||||
|
pragma solidity ^99.99.0;
|
||||||
|
contract C {
|
||||||
|
function f() {}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// SyntaxError 3997: (0-25): Source file requires different compiler version (current compiler is ....
|
||||||
|
// SyntaxError 4937: (43-58): No visibility specified. Did you intend to add "public"?
|
@ -0,0 +1,3 @@
|
|||||||
|
pragma solidity ^99.99.0;
|
||||||
|
// ----
|
||||||
|
// ParserError 5333: (0-25): Source file requires different compiler version (current compiler is ....
|
@ -0,0 +1,4 @@
|
|||||||
|
pragma solidity ^99.99.0;
|
||||||
|
this is surely invalid
|
||||||
|
// ----
|
||||||
|
// ParserError 5333: (0-25): Source file requires different compiler version (current compiler is ....
|
@ -0,0 +1,6 @@
|
|||||||
|
pragma solidity ^99.99.0;
|
||||||
|
contract C {
|
||||||
|
uint ;
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 5333: (0-25): Source file requires different compiler version (current compiler is ....
|
@ -0,0 +1,6 @@
|
|||||||
|
pragma solidity ^99.99.0;
|
||||||
|
contract C {
|
||||||
|
function f() {}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 5333: (0-25): Source file requires different compiler version (current compiler is ....
|
Loading…
Reference in New Issue
Block a user