-
Notifications
You must be signed in to change notification settings - Fork 5
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
Fix compiler warnings and deprecations emitted by latest dmd #10
Conversation
Codecov Report
@@ Coverage Diff @@
## master #10 +/- ##
=======================================
Coverage 92.88% 92.88%
=======================================
Files 1 1
Lines 478 478
=======================================
Hits 444 444
Misses 34 34
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
41848be
to
78a821c
Compare
if (!build.empty) | ||
semVer ~= "+" ~ "%-(%s.%)".format(build); | ||
semVer ~= "+" ~ "%-(%s.%)".format(cast(const char[]) build); |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
source/semver.d
Outdated
@@ -185,7 +185,7 @@ struct SemVer | |||
return result; | |||
} | |||
|
|||
private SemVer appendPrerelease0() scope @safe pure nothrow | |||
private SemVer appendPrerelease0() @safe pure nothrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, in short:
scope
as function attribute means that the function may be called with ascope
parameter;return scope
allows you to call it with ascope
parameter and returns a reference that is linked tothis
;
Hence why I suggested return scope
. What does the compiler say ?
@@ -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 |
There was a problem hiding this comment.
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 throw
ing an Error
is nothrow
, but this != other
calls opEquals
which I am pretty sure is not nothrow
.
Thanks for taking care of this! |
…thod Latest DMD beta reports: source/semver.d(144,47): Deprecation: scope variable `this` assigned to non-scope parameter `_param_1` calling `format` source/semver.d(146,47): Deprecation: scope variable `this` assigned to non-scope parameter `_param_1` calling `format` Can be fixed by removing 'scope' or by adding two casts. The problem seems to be related to format() not accepting 'scope' parameters. Casting away the 'scope' removes the problem.
Latest DMD reports: source/semver.d(192,16): Deprecation: scope parameter `this` may not be returned Can be fixed by using 'return scope'.
Latest DMD reports: source/semver.d(342,57): Deprecation: scope variable `this` assigned to non-scope parameter `suffix` calling `compareSufix` source/semver.d(346,54): Deprecation: scope variable `this` assigned to non-scope parameter `suffix` calling `compareSufix` Can be reasonably fixed by adding scope to suffix parameter.
Latest DMD reports: source/semver.d(375,17): Deprecation: `semver.SemVer.differAt`: `in` contract may throw but function is marked as `nothrow` Can be reasonably fixed by removing the in{} contract with the assert(), or by removing 'nothrow' from these methods.
78a821c
to
7f6fa19
Compare
Note: The correct fix for the last commit is to make |
I tried to make
and adding
|
$ dmd-beta --version Der wording of the deprecation messages changed changed slightly for 'master' branch. With the changes in this PR all compilers (gdc, ldc2, dmd & dmd-beta) compile without any warnings or deprecations. Any open issues? Any other ways to fix compilation? |
The latest DMD emits now warnings for
This PR proposes some possible solutions for these warnings and deprecations..