Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler warnings and deprecations emitted by latest dmd #10

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions source/semver.d
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ struct SemVer

string semVer = "%(%s.%)".format(ids);
if (!prerelease.empty)
semVer ~= "-" ~ "%-(%s.%)".format(prerelease);
semVer ~= "-" ~ "%-(%s.%)".format(cast(const char[]) prerelease);
if (!build.empty)
semVer ~= "+" ~ "%-(%s.%)".format(build);
semVer ~= "+" ~ "%-(%s.%)".format(cast(const char[]) build);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, with the error message I see the issue. std.format is not accepting its parameter by scope.
So casting the scope away is indeed the "best" solution here, because scope on toString is the right thing. The problem is in std.format.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. So format() needs to be changed as the real fix?

Copy link
Collaborator

@Geod24 Geod24 Nov 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. That's where DIP1000 shows its limitations. If you change format to accept its parameter by scope, you will break users that have non-scope toString implementations. That includes classes. Oops.

return semVer;
}

Expand Down Expand Up @@ -185,7 +185,7 @@ struct SemVer
return result;
}

private SemVer appendPrerelease0() scope @safe pure nothrow
private SemVer appendPrerelease0() return scope @safe pure nothrow
{
if (prerelease.empty)
prerelease ~= "0";
Expand Down Expand Up @@ -311,7 +311,7 @@ struct SemVer
return ids[i] < other.ids[i] ? -1 : 1;
}

int compareSufix(const string[] suffix, const string[] anotherSuffix) @safe pure
int compareSufix(scope const string[] suffix, const string[] anotherSuffix) @safe pure
{
import std.conv : to;
import std.string : isNumeric;
Expand Down Expand Up @@ -372,7 +372,7 @@ struct SemVer
/**
* Compare two $(B different) versions and return the parte they differ on.
*/
VersionPart differAt(ref const SemVer other) const scope @safe pure nothrow
VersionPart differAt(ref const SemVer other) const scope @safe pure
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the error message, it's obvious what is wrong: assert is nothrow, because throwing an Error is nothrow, but this != other calls opEquals which I am pretty sure is not nothrow.

in
{
assert(this != other);
Expand All @@ -395,7 +395,7 @@ struct SemVer
}

/// ditto
VersionPart differAt(const SemVer other) const scope @safe pure nothrow
VersionPart differAt(const SemVer other) const scope @safe pure
{
return this.differAt(other);
}
Expand Down