SemanticVersion last update problem

Hi, recently I tried my software with the last version of Crystal.

But now, if I try to load a Semantic version with that form: 0.0.0-+20210222

It doesn’t work anymore, I have an error complaining about it’s not a SemanticVersion.

How can I fix that ? Because I need to version some softwares only by dates, because there developers do in that way

This is a short example:

require "semantic_version"

value = SemanticVersion.parse("2.0.0")

puts value

value2 = SemanticVersion.parse("0.0.0-+20210222")

puts value2

The error:

zohran@alienware-m17-r3 ~/Downloads $ crystal Test.cr 
2.0.0
Unhandled exception: Not a semantic version: "0.0.0-+20210222" (ArgumentError)
  from /usr/lib64/crystal/semantic_version.cr:43:7 in 'parse'
  from Test.cr:7:10 in '__crystal_main'
  from /usr/lib64/crystal/crystal/main.cr:129:5 in 'main_user_code'
  from /usr/lib64/crystal/crystal/main.cr:115:7 in 'main'
  from /usr/lib64/crystal/crystal/main.cr:141:3 in 'main'
  from /lib64/libc.so.6 in '??'
  from /lib64/libc.so.6 in '__libc_start_main'
  from /home/zohran/.cache/crystal/crystal-run-Test.tmp in '_start'
  from ???

Are you sure this worked before? There haven’t been any changes to semantic_version recently. It fails even on crystal 1.0.0

FWIW, -+ does not follow semver AFAIK, maybe the developer messed up?

Hmm probably one of my mistake I guess when I made my packages, it work if I remove the +.

Sorry about that

I remember a PR of mine that fixed issues in the parser, basically just replacing a split call for the same regex found in the semantic version website, so if this worked before was in a version older than 1.0

$ docker run --rm -it crystallang/crystal:0.35.1-alpine \
             crystal eval 'require "semantic_version";puts SemanticVersion.parse("2.0.0");puts SemanticVersion.parse("0.0.0-+20210222")'
2.0.0
Unhandled exception: Not a semantic version: "0.0.0-+20210222" (ArgumentError)
  from usr/share/crystal/src/semantic_version.cr:33:22 in 'parse'
  from eval:1:69 in '__crystal_main'
  from usr/share/crystal/src/crystal/main.cr:105:5 in 'main_user_code'
  from usr/share/crystal/src/crystal/main.cr:91:7 in 'main'
  from usr/share/crystal/src/crystal/main.cr:114:3 in 'main'
  from ???

If the “0.0.0-+20210222” semver was set automatically, it feels like it was trying to follow the <version core> "-" <pre-release> "+" <build> format but without a <pre-release> version (0.0.0 "-" "+" 20210222)

Looking at the semver grammar, 0.0.0-+20210222 isn’t a valid version, is not possible to have a - followed by a +. And if didn’t work on 0.35 I have my doubts if it really worked in any other version.