In Elixir, SemVer version requirements may use the ~> operator.
Examples (naive translation):
~> 0.1 → >= 0.1.0, < 1.0.0
~> 0.1.5 → >= 0.1.5, < 0.2.0
Ref: https://hexdocs.pm/elixir/Version.html#module-requirements
However, because pre-release versions (e.g. -alpha, -beta, etc.) are ordered before their corresponding release version, these translations are not accurate.
Example:
iex> Version.match?("0.2.0-alpha.7", "~> 0.1.5")
false
iex> Version.match?("0.2.0-alpha.7", ">= 0.1.5 and <= 0.2.0")
true
iex> Version.compare("0.2.0-alpha.7", "0.2.0")
:lt
Therefore:
~> 0.1.5 ≠ >= 0.1.5, < 0.2.0
How should ~> be represented in vers, considering pre-release ordering semantics?
I believe this also affects the ^ operator in NPM:
|
{ |
|
"description": "Construct VERS range from native npm range.", |
|
"test_group": "advanced", |
|
"test_type": "from_native", |
|
"input": { |
|
"native_range": "^2.0.18 || ^3.0.16 || ^3.1.6 || ^4.0.8 || ^5.0.0-beta.5", |
|
"scheme": "npm" |
|
}, |
|
"expected_output": "vers:npm/>=2.0.18|<3.0.0|>=3.0.16|>=3.1.6|<4.0.0|<4.0.0|>=4.0.8|>=5.0.0-beta.5|<5.0.0|<6.0.0" |
|
}, |
In Elixir, SemVer version requirements may use the
~>operator.Examples (naive translation):
~> 0.1→>= 0.1.0, < 1.0.0~> 0.1.5→>= 0.1.5, < 0.2.0Ref: https://hexdocs.pm/elixir/Version.html#module-requirements
However, because pre-release versions (e.g.
-alpha,-beta, etc.) are ordered before their corresponding release version, these translations are not accurate.Example:
Therefore:
How should
~>be represented invers, considering pre-release ordering semantics?I believe this also affects the
^operator in NPM:vers-spec/tests/npm_range_from_native_test.json
Lines 1874 to 1883 in 470128d