Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkl:semver sortorder (isLessThan) failure? #772

Closed
kuehl opened this issue Nov 2, 2024 · 1 comment · Fixed by #773
Closed

pkl:semver sortorder (isLessThan) failure? #772

kuehl opened this issue Nov 2, 2024 · 1 comment · Fixed by #773
Labels
bug Something isn't working

Comments

@kuehl
Copy link

kuehl commented Nov 2, 2024

hello,

sorting by using semver's isLessThan() produces unexpected results.

pkl --version
Pkl 0.26.3 (Linux 5.15.0-1057-aws, native)

a simple test_semver.pkl

amends "pkl:test"
import "pkl:semver"
facts {
  ["shall_be_true"] {
    semver.Version("6.0.417").isLessThan(semver.Version("8.0.100"))
  }
  ["shall_be_false"] {
    semver.Version("6.0.417").isGreaterThan(semver.Version("8.0.100"))
  }
}
pkl test test_semver.pkl
  shall_be_true ✅
  shall_be_false ✅

doesn't fail?

i think semver's isLessThan

...
function isLessThan(other: Version): Boolean =
    major < other.major ||
    minor < other.minor ||
    patch < other.patch
...

should be something like

...
function isLessThan(other: Version): Boolean =
    major < other.major ||
    major == other.major && minor < other.minor ||
    major == other.major && minor == other.minor && patch < other.patch
...

?

@bioball
Copy link
Contributor

bioball commented Nov 2, 2024

You're totally right! This is incorrect; thanks for pointing this out.

@bioball bioball added the bug Something isn't working label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants