Version Checker: 0.5.x-prerelease will match pragma solidity ^0.5

Basically, the pre-release rule is only applied when all remaining
version numbers equal to 0.
This commit is contained in:
Henry Lee 2019-10-29 11:46:04 +11:00
parent 2a1b6f55af
commit 628d219c94
3 changed files with 22 additions and 1 deletions

View File

@ -22,7 +22,7 @@ Bugfixes:
* SMTChecker: Fix internal error when using arrays or mappings of functions.
* SMTChecker: Fix internal error in array of structs type.
* Yul: Consider infinite loops and recursion to be not removable.
* Version Checker: 0.5.x-prerelease will match `pragma solidity ^0.5`.
### 0.5.13 (2019-11-14)

View File

@ -105,8 +105,19 @@ bool SemVerMatchExpression::MatchComponent::matches(SemVerVersion const& _versio
didCompare = true;
cmp = _version.numbers[i] - version.numbers[i];
}
if (cmp == 0 && !_version.prerelease.empty() && didCompare)
{
cmp = -1;
for (unsigned i = levelsPresent; i < 3; i++)
{
if (_version.numbers[i] > 0)
{
cmp = 0;
break;
}
}
}
switch (prefix)
{

View File

@ -70,6 +70,8 @@ BOOST_AUTO_TEST_CASE(positive_range)
{"*", "1.2.3-foo"},
{"1.0.0 - 2.0.0", "1.2.3"},
{"1.0.0", "1.0.0"},
{"1.0", "1.0.0"},
{"1", "1.0.0"},
{">=*", "0.2.4"},
{"*", "1.2.3"},
{">=1.0.0", "1.0.0"},
@ -82,6 +84,8 @@ BOOST_AUTO_TEST_CASE(positive_range)
{"<=2.0.0", "0.2.9"},
{"<2.0.0", "1.9999.9999"},
{"<2.0.0", "0.2.9"},
{"<1.0", "1.0.0-pre"},
{"<1", "1.0.0-pre"},
{">= 1.0.0", "1.0.0"},
{">= 1.0.0", "1.0.1"},
{">= 1.0.0", "1.1.0"},
@ -137,6 +141,10 @@ BOOST_AUTO_TEST_CASE(positive_range)
{"^0.1.2", "0.1.2"},
{"^0.1", "0.1.2"},
{"^1.2", "1.4.2"},
{"^1.2", "1.2.1-pre"},
{"^1.2", "1.2.0"},
{"^1", "1.2.0-pre"},
{"^1", "1.2.0"},
{"<=1.2.3", "1.2.3-beta"},
{">1.2", "1.3.0-beta"},
{"<1.2.3", "1.2.3-beta"},
@ -158,6 +166,8 @@ BOOST_AUTO_TEST_CASE(negative_range)
// Positive range tests
vector<pair<string, string>> tests = {
{"1.0.0 - 2.0.0", "2.2.3"},
{"1.0", "1.0.0-pre"},
{"1", "1.0.0-pre"},
{"^1.2.3", "1.2.3-pre"},
{"^1.2", "1.2.0-pre"},
{"^1.2.3", "1.2.3-beta"},