Fix intentional discarding of return value in topN#5925
Fix intentional discarding of return value in topN#5925wilzbach merged 2 commits intodlang:masterfrom
Conversation
This fixes a warning one gets when compiling with warnings enabled:
"phobos/std/algorithm/sorting.d(3122): Warning: calling testcase.foo.__lambda1 without side effects discards return value of type bool, prepend a cast(void) if intentional"
Testcase that fails compilation with `-w`:
```
import std.algorithm.sorting;
auto foo() {
int[] v = [ 25, 7, 9, 2, 0, 5, 21 ];
return topN!((a, b) => a > b)(v, 100);
}
```
Passing the comparison operation as string "a < b" is tested a few lines up. This adds a test for passing a lambda function.
|
Thanks for your pull request, @JohanEngelen! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up:
Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
Yes. FYI you can easily check this yourself: |
| // Safety checks: enumerate all potentially unsafe generic primitives | ||
| // then use a @trusted implementation. | ||
| binaryFun!less(r[0], r[r.length - 1]); | ||
| cast(void) binaryFun!less(r[0], r[r.length - 1]); |
There was a problem hiding this comment.
FWIW this looks like unfinished work. This is in an if (false) block ...
|
Can one of you retrigger the failed testers so this is merged? Thanks. |
|
Sure, done. Ping again if you need help. |
|
Thanks. What's wrong on CircleCI: Dscanner crashes on this code?? |
|
Dscanner has random chance of crashing on any PR. We're running it under DScanner in order to try to narrow down the problem, as it doesn't reproduce locally... |
|
Thanks. |
Hehe, I'm aware and you shouldn't see any for Phobos since this summer: #5546 (we now build with There's a similar PR for druntime, but I haven't figured out yet how to fix the deprecations for Martin's new |
|
Force-merging this due to our CircleCi/DScanner SEGFAULT issue. We should probably go with #5546 for now :/ |
This fixes a warning one gets when compiling with warnings enabled:
"phobos/std/algorithm/sorting.d(3122): Warning: calling testcase.foo.__lambda1 without side effects discards return value of type bool, prepend a cast(void) if intentional"
Testcase that fails compilation with
-w:Phobos unittests are compiled with
-wright? In that case, the expanded testcase takes care of testing this fix.