hashicorp / hashicorp/go-version
Bug: Constraints::Check(...) function mistakenly returns false, expected true
- Dominant language
- Go
- Stars
- 1.8k
- Forks
- 165
- Avg merge
- 23h 42m
- Merged PRs (30d)
- 2
Description
Hey,
the following example shows an unexpected behavior of the constraints' check function:
```golang
v1 := MustVersion("1.7.3")
v2 := MustVersion("1.7.4~pre.0")
v3 := MustVersion("1.7.4")
if !v1.LessThan(v2) {
panic("v1 not less than v2")
}
if !v2.LessThan(v3) {
panic("v2 not less than v3")
}
if !v1.LessThan(v3) {
panic("v1 not less than v3")
}
c := MustConstraint(">= 1.7.3")
if !c.Check(v1) {
panic("constraint failed for v1")
}
if !c.Check(v3) {
panic("constraint failed for v3")
}
if !c.Check(v2) {
panic("constraint failed for v2")
}
```
My output is `constraint failed for v2`. The above code shows, that `1.7.3` is less than `1.7.4~pre.0` but `1.7.4~pre.0` does not match constraint `>= 1.7.3`.
Tested commit: *v1.1.0* `d40cf49b3a77bba84a7afdbd7f1dc295d114efb1`
Thanks,
Marcel Gebhardt
Contributor guide
Assessment
This issue has not been assessed yet.