-
-
Notifications
You must be signed in to change notification settings - Fork 741
fix Issue 13441 - joiner asserts with only(x) separator #2499
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
Conversation
I doubt so. At least I don't see why it can't be a method relying on run-time data - imagine some range wrapping I/O operations. While conceptually |
Should I wrap the check in a Edit: All this trouble for an assert, I think at this point it's easier to replace it with a comment. |
For what it's worth, I think it's much more reasonable to assume (and expect) that (if its valid) When all that is said and done though, arguably, calling anything on a |
bdc20cf
to
4c6baf6
Compare
Makes sense. Replaced with an |
I don't think changing edit: Although I think it's tangential, non-empty default initialized ranges aren't that uncommon, |
My initial patch called No new field is needed for |
Nevermind, I'm not quite used to the new split diff-view on Github yet :) |
Could you also make the change in the "higher than 1 arity" version of |
Agreed, but I think it is a correct change for
The field is already there. At worst, it adds a dead initialization in the constructor, which should optimized away anyways. |
4c6baf6
to
c506b03
Compare
Right, didn't realize it needed a fix too. Done. |
Technically, if you replace the code with: import std.algorithm;
import std.range;
import std.stdio;
void main()
{
int[][] lines = [[1], [2], [3]];
lines
.joiner(only(7)).writeln();
} You'd see the output: |
Ah, good catch. Didn't think |
Though it doesn't completely fix the issue, I is still think it's a valid change, so LGTM. Also pinging @Poita: Afaik, both you and @JakobOvrum wrote |
Yeah, looking again, I think the change to |
Yeah I like the new diff too |
Auto-merge toggled on |
fix Issue 13441 - joiner asserts with only(x) separator
https://issues.dlang.org/show_bug.cgi?id=13441
This patch could use review. Is there a better way to do this? Can we expect
_currentSep.init.empty
to be a valid expression that can be evaluated at compile-time?Ping @quickfur