[GH-ISSUE #258] Some comments about semver #7156

Closed
opened 2026-06-20 16:59:34 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @Vampire on GitHub (Jun 12, 2015).
Original GitHub issue: https://github.com/semver/semver/issues/258

I just read the spec at 255bc951da and I have some notes for you.
I hope it is ok to have them in one issue.

Text

Questionable versions

Here some examples of versions that are valid according to the spec, but I'm not 100% sure this is intended:

Version Comment
1.0.0---+123 is a valid version? There the pre-release identifier is "--"
1.0.0-0.-.-.-+123 is also a valid version with "0", "-", "-" and "-" as pre-release identifiers
1.0.0-001foo should this be allowed? according to the text it is
1.0.0-001-foo how about this?
1.0.0+000001 how about this?

Sorting

The spec describes what to compare when if comparing semvers and how to interpret it. But it is missing about case-sensitivity. I'd like to suggest adding that identifier comparison has to be done case-insensitively.

BNF form

Use EBNF

I'd like to suggest using EBNF according to ISO 14977 instead of a non-standard modified BNF like currently, it is much more readable and makes the result much more concise, e. g. by eliminating the need for recursion and introducing optionals.

E. g.

<pre-release> ::= <dot-separated pre-release identifiers>
<dot-separated pre-release identifiers> ::= <pre-release identifier> | <pre-release identifier> "." <dot-separated pre-release identifiers>

could be written as

pre_release = pre_release_identifier, { ".", pre_release_identifier };

Reuse nonterminals where possible

<numeric identifier> ::= "0"
                       | <positive digit>
                       | <positive digit> <digits>

should be

<numeric identifier> ::= <digit>
                       | <positive digit> <digits>

Simplify the BNF form, even if not using EBNF

e. g. if

<identifier characters> ::= <identifier character>
                          | <identifier character> <identifier characters>

is changed to

<identifier characters> ::= | <identifier character> <identifier characters>

you can simplify

<alphanumeric identifier> ::= <non-digit>
                            | <non-digit> <identifier characters>
                            | <identifier characters> <non-digit>
                            | <identifier characters> <non-digit> <identifier characters>

to

<alphanumeric identifier> ::= <identifier characters> <non-digit> <identifier characters>

as now <identifier characters> can be empty

SVG

The pre-release and build parts can be simplified.
The part before and after the dot are identical in both cases.
So you can simply loop back to the beginning of the respective cluster start after the dots

Originally created by @Vampire on GitHub (Jun 12, 2015). Original GitHub issue: https://github.com/semver/semver/issues/258 I just read the spec at 255bc951da97e1642050d56170b969c702094f10 and I have some notes for you. I hope it is ok to have them in one issue. # Text ## Questionable versions Here some examples of versions that are valid according to the spec, but I'm not 100% sure this is intended: | Version | Comment | | --- | --- | | `1.0.0---+123` | is a valid version? There the pre-release identifier is "--" | | `1.0.0-0.-.-.-+123` | is also a valid version with "0", "-", "-" and "-" as pre-release identifiers | | `1.0.0-001foo` | should this be allowed? according to the text it is | | `1.0.0-001-foo` | how about this? | | `1.0.0+000001` | how about this? | ## Sorting The spec describes what to compare when if comparing semvers and how to interpret it. But it is missing about case-sensitivity. I'd like to suggest adding that identifier comparison has to be done case-insensitively. # BNF form ## Use EBNF I'd like to suggest using EBNF according to ISO 14977 instead of a non-standard modified BNF like currently, it is much more readable and makes the result much more concise, e. g. by eliminating the need for recursion and introducing optionals. E. g. ``` <pre-release> ::= <dot-separated pre-release identifiers> <dot-separated pre-release identifiers> ::= <pre-release identifier> | <pre-release identifier> "." <dot-separated pre-release identifiers> ``` could be written as ``` pre_release = pre_release_identifier, { ".", pre_release_identifier }; ``` ## Reuse nonterminals where possible ``` <numeric identifier> ::= "0" | <positive digit> | <positive digit> <digits> ``` should be ``` <numeric identifier> ::= <digit> | <positive digit> <digits> ``` ## Simplify the BNF form, even if not using EBNF e. g. if ``` <identifier characters> ::= <identifier character> | <identifier character> <identifier characters> ``` is changed to ``` <identifier characters> ::= | <identifier character> <identifier characters> ``` you can simplify ``` <alphanumeric identifier> ::= <non-digit> | <non-digit> <identifier characters> | <identifier characters> <non-digit> | <identifier characters> <non-digit> <identifier characters> ``` to ``` <alphanumeric identifier> ::= <identifier characters> <non-digit> <identifier characters> ``` as now `<identifier characters>` can be empty # SVG The pre-release and build parts can be simplified. The part before and after the dot are identical in both cases. So you can simply loop back to the beginning of the respective cluster start after the dots
GiteaMirror added the questionstaled labels 2026-06-20 16:59:34 -05:00
Author
Owner

@jwdonahue commented on GitHub (Dec 8, 2017):

@Vampire

Questionable versions

All are expected to be legal SemVer strings. Such string may result when automation finds empty data fields, or might even have some meaning to somebody. Disallowing them while retaining the usefulness of the current spec would just complicate the spec and make it harder to implement.

Sorting

Case sensitivity has been covered in other issues, can't be changed in the 2.x.x series and there is no current initiative to get SemVer 3.x.x off the ground.

BNF

Interesting points, please open a separate issue if you're willing to do the work and issue a PR.

SVG

Same as for BNF, separate issue and present a PR.

In any case, please close this old issue at your earliest possible convenience.

<!-- gh-comment-id:350177332 --> @jwdonahue commented on GitHub (Dec 8, 2017): @Vampire ## Questionable versions All are expected to be legal SemVer strings. Such string may result when automation finds empty data fields, or might even have some meaning to somebody. Disallowing them while retaining the usefulness of the current spec would just complicate the spec and make it harder to implement. ## Sorting Case sensitivity has been covered in other issues, can't be changed in the 2.x.x series and there is no current initiative to get SemVer 3.x.x off the ground. ## BNF Interesting points, please open a separate issue if you're willing to do the work and issue a PR. ## SVG Same as for BNF, separate issue and present a PR. In any case, please close this old issue at your earliest possible convenience.
Author
Owner

@jwdonahue commented on GitHub (Jan 17, 2020):

@Vampire, unless you intend to issue a PR or have further questions, please close this issue at your earliest possible convenience.

<!-- gh-comment-id:575512104 --> @jwdonahue commented on GitHub (Jan 17, 2020): @Vampire, unless you intend to issue a PR or have further questions, please close this issue at your earliest possible convenience.
Author
Owner

@alexandrtovmach commented on GitHub (Jun 10, 2020):

This issue looks staled and will be closed in 10 days if there are no objections. Thanks everyone for contributions, you're amazing 🎆

<!-- gh-comment-id:642141070 --> @alexandrtovmach commented on GitHub (Jun 10, 2020): This issue looks staled and will be closed in 10 days if there are no objections. Thanks everyone for contributions, you're amazing :fireworks:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/semver#7156