pkl:semver sortorder (isLessThan) failure? #240

Closed
opened 2025-12-30 01:22:36 +01:00 by adam · 1 comment
Owner

Originally created by @kuehl on GitHub (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
...

?

Originally created by @kuehl on GitHub (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 ... ``` ?
adam added the bug label 2025-12-30 01:22:36 +01:00
adam closed this issue 2025-12-30 01:22:37 +01:00
Author
Owner

@bioball commented on GitHub (Nov 2, 2024):

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

@bioball commented on GitHub (Nov 2, 2024): You're totally right! This is incorrect; thanks for pointing this out.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#240