diff --git a/Changelog.md b/Changelog.md index c8a91b238..a691203c2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -23,7 +23,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) diff --git a/liblangutil/SemVerHandler.cpp b/liblangutil/SemVerHandler.cpp index 378923420..611f058ae 100644 --- a/liblangutil/SemVerHandler.cpp +++ b/liblangutil/SemVerHandler.cpp @@ -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) { diff --git a/test/libsolidity/SemVerMatcher.cpp b/test/libsolidity/SemVerMatcher.cpp index 4a6c123ef..7dae613a8 100644 --- a/test/libsolidity/SemVerMatcher.cpp +++ b/test/libsolidity/SemVerMatcher.cpp @@ -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> 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"},