Skip to content

Commit

Permalink
Update semver.er
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Oct 16, 2023
1 parent 0fea05a commit 0c6c5e3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/erg_compiler/lib/std/semver.er
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
.Identifier::__new__ { .name; .num = num_ }
_ -> panic "invalid identifier string: \{s}"
@Override
__repr__ ref self = "Identifier(\{self.name}.\{self.num})"
__repr__ ref self = "Identifier(\{self.__str__()})"

.SemVer = Class { .major = Nat; .minor = Nat; .patch = Nat; .pre = .Identifier or NoneType }
.SemVer|<: Show|.
__str__ ref self =
if self.pre != None:
do: "SemVer(\{self.major}.\{self.minor}.\{self.patch}-\{self.pre})"
do: "SemVer(\{self.major}.\{self.minor}.\{self.patch})"
do: "\{self.major}.\{self.minor}.\{self.patch}-\{self.pre}"
do: "\{self.major}.\{self.minor}.\{self.patch}"
.SemVer.
new major, minor, patch, pre := None =
.SemVer::__new__ { .major; .minor; .patch; .pre }
Expand All @@ -33,7 +33,7 @@
.SemVer.new(nat(major), nat(minor), nat(patch), .Identifier.from_str(pre))
_ -> panic "invalid semver string: \{s}"
@Override
__repr__ ref self = self.__str__()
__repr__ ref self = "SemVer(\{self.__str__()})"
#[
greater self, other: .Version =
match [self.major > other.major, self.major >= other.major, self.minor > other.minor, self.minor >= other.minor, self.patch > other.patch]:
Expand Down

0 comments on commit 0c6c5e3

Please sign in to comment.