"[Pre-release] Numeric identifiers MUST NOT include leading zeroes" #121

Closed
opened 2026-02-17 11:18:35 -06:00 by GiteaMirror · 12 comments
Owner

Originally created by @damianpowell on GitHub (Feb 13, 2014).

I can read this two ways:

  1. A pre-release identifier which consists entirely of decimal digits, MUST begin with a digit other than zero, or it MUST be the single digit zero, or,
  2. A pre-release identifier which consists entirely of decimal digits, but begins with a zero, MUST be considered to be alphanumeric.

The distinction is important because it changes how we validate a SemVer string. Under the first approach, we would consider 1.2.3-alpha.012.2 to be invalid, but under the second approach, we would not. However, the sorting applied in approach 2 would consider the second identifier "012" to be an alphanumeric string.

Which is the correct approach, please?

Originally created by @damianpowell on GitHub (Feb 13, 2014). I can read this two ways: 1. A pre-release identifier which consists entirely of decimal digits, MUST begin with a digit other than zero, or it MUST be the single digit zero, or, 2. A pre-release identifier which consists entirely of decimal digits, but begins with a zero, MUST be considered to be alphanumeric. The distinction is important because it changes how we validate a SemVer string. Under the first approach, we would consider 1.2.3-alpha.012.2 to be invalid, but under the second approach, we would not. However, the sorting applied in approach 2 would consider the second identifier "012" to be an alphanumeric string. Which is the correct approach, please?
GiteaMirror added the questionstaled labels 2026-02-17 11:18:35 -06:00
Author
Owner

@zafarkhaja commented on GitHub (Feb 13, 2014):

As per the BNF grammar, alphanumeric identifiers must contain at least one non-digit character

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

Hence, 012 cannot be considered as an alphanumeric identifier.

@zafarkhaja commented on GitHub (Feb 13, 2014): As per the BNF grammar, alphanumeric identifiers must contain at least one non-digit character ``` <alphanumeric identifier> ::= <non-digit> | <non-digit> <identifier characters> | <identifier characters> <non-digit> | <identifier characters> <non-digit> <identifier characters> ``` Hence, `012` cannot be considered as an alphanumeric identifier.
Author
Owner

@damianpowell commented on GitHub (Feb 13, 2014):

Thanks, @zafarkhaja. The BNF is useful but it's not published on SemVer.org yet so I must assume it's either not finished or intended for a later release of the SemVer specification.

@damianpowell commented on GitHub (Feb 13, 2014): Thanks, @zafarkhaja. The BNF is useful but it's not published on SemVer.org yet so I must assume it's either not finished or intended for a later release of the SemVer specification.
Author
Owner

@haacked commented on GitHub (Feb 13, 2014):

It's probably time to update semver.org. But we might want to clarify the text so it's clearer too. Mind submitting PRs?

@haacked commented on GitHub (Feb 13, 2014): It's probably time to update semver.org. But we might want to clarify the text so it's clearer too. Mind submitting PRs?
Author
Owner

@tbull commented on GitHub (Feb 14, 2014):

The BNF is a derived work from the spec and (at this time) not normative
by itself.

@tbull commented on GitHub (Feb 14, 2014): The BNF is a derived work from the spec and (at this time) not normative by itself.
Author
Owner

@FichteFoll commented on GitHub (Aug 28, 2015):

push

This is still an issue with the spec as it's unclear in this regard.

@FichteFoll commented on GitHub (Aug 28, 2015): *push* This is still an issue with the spec as it's unclear in this regard.
Author
Owner

@mkllnk commented on GitHub (Oct 24, 2015):

Just got confused about this as well. You could include a negative example to clarify this.

@mkllnk commented on GitHub (Oct 24, 2015): Just got confused about this as well. You could include a negative example to clarify this.
Author
Owner

@FichteFoll commented on GitHub (Nov 3, 2015):

Revisiting this again.

  1. [...] Numeric identifiers MUST NOT include leading zeroes. [...]
  2. [...] identifiers consisting of only digits are compared numerically and identifiers with letters or hyphens are compared lexically in ASCII sort order. [...]

Following the points 9. and 11., the spec seems to indicate that only identifiers with a letter or a hyphen are considered alphanumeric identifiers, leaving numeric identifiers to consist only of numbers. Since 9. prohibits usage of leading zeroes, they are not valid numeric identifiers, thus declaring 1.0.1-alpha.012 not to be a semantic version.

Case closed, I suppose.

@FichteFoll commented on GitHub (Nov 3, 2015): Revisiting this again. > 9) [...] Numeric identifiers MUST NOT include leading zeroes. [...] > 11) [...] identifiers consisting of only digits are compared numerically and identifiers with letters or hyphens are compared lexically in ASCII sort order. [...] Following the points 9. and 11., the spec seems to indicate that only identifiers with a letter or a hyphen are considered alphanumeric identifiers, leaving numeric identifiers to consist only of numbers. Since 9. prohibits usage of leading zeroes, they are not valid numeric identifiers, thus declaring `1.0.1-alpha.012` not to be a semantic version. Case closed, I suppose.
Author
Owner

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

@damianpowell, if you have no further questions regarding this issue, please close it at your earliest possible convenience.

@jwdonahue commented on GitHub (Dec 5, 2017): @damianpowell, if you have no further questions regarding this issue, please close it at your earliest possible convenience.
Author
Owner

@purplexa commented on GitHub (Apr 16, 2018):

Rule 9 should probably explicitly state that a numeric identifier is an identifier which consists of only digits, similar to how rule 10 is explicit about it, since rule 9 comes first.

@purplexa commented on GitHub (Apr 16, 2018): Rule 9 should probably explicitly state that a numeric identifier is an identifier which consists of only digits, similar to how rule 10 is explicit about it, since rule 9 comes first.
Author
Owner

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

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

Thank you.

@jwdonahue commented on GitHub (Jan 17, 2020): @damianpowell, unless you intend to issue a PR or have further questions, please close this issue at your earliest possible convenience. Thank you.
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 🎆

@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:
Author
Owner

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

👻 👻 👻
Closed as staled

@alexandrtovmach commented on GitHub (Jun 19, 2020): 👻 👻 👻 Closed as staled
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/semver#121