Fix a checked mode bug. (#14)
I missed this because I was running a version of test that relied on pub
to turn on checked mode 😩.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3ba6f6e..6d54692 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 1.3.2
+
+* Fix a checked-mode error in `VersionRange.difference()`.
+
# 1.3.1
* Fix a new strong mode error.
diff --git a/lib/src/version_range.dart b/lib/src/version_range.dart
index 861ae46..580f3fe 100644
--- a/lib/src/version_range.dart
+++ b/lib/src/version_range.dart
@@ -323,7 +323,7 @@
VersionRange before;
if (!allowsLower(this, other)) {
- before = VersionConstraint.empty;
+ before = null;
} else if (min == other.min) {
assert(includeMin && !other.includeMin);
assert(min != null);
@@ -336,7 +336,7 @@
VersionRange after;
if (!allowsHigher(this, other)) {
- after = VersionConstraint.empty;
+ after = null;
} else if (max == other.max) {
assert(includeMax && !other.includeMax);
assert(max != null);
@@ -347,8 +347,9 @@
includeMin: !other.includeMax, includeMax: includeMax);
}
- if (before == VersionConstraint.empty) return after;
- if (after == VersionConstraint.empty) return before;
+ if (before == null && after == null) return VersionConstraint.empty;
+ if (before == null) return after;
+ if (after == null) return before;
return new VersionUnion.fromRanges([before, after]);
} else if (other is VersionUnion) {
var ranges = <VersionRange>[];
diff --git a/pubspec.yaml b/pubspec.yaml
index 1712f6e..2fe68a1 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: pub_semver
-version: 1.3.1
+version: 1.3.2
author: Dart Team <misc@dartlang.org>
description: >
Versions and version constraints implementing pub's versioning policy. This