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 regression 13393: cartesianProduct + joiner = runtime assertion failure #2473

Merged
merged 2 commits into from Aug 29, 2014

Conversation

quickfur
Copy link
Member

Fixes: https://issues.dlang.org/show_bug.cgi?id=13393

Caused by .save failing to save entire range state (it's missing .empty), causing inconsistency in .saved objects.

Caused by .save failing to save entire state, causing inconsistency in
.save'd objects.
@quickfur quickfur changed the title Fix regression 13393. Fix regression 13393: cartesianProduct + joiner = runtime assertion failure Aug 28, 2014
@Safety0ff
Copy link
Contributor

LGTM, though the test can be reduced to:

assert(!cartesianProduct([0],[0],[0]).save.empty);

@quickfur
Copy link
Member Author

Good idea, done.

@monarchdodra
Copy link
Collaborator

Often, save is implemented in terms of copy + saved range overwrite, eg:

             Result copy = this;
             foreach (i, _; RR)
             {
                 copy.ranges[i] = ranges[i].save;
                 copy.current[i] = current[i].save;
             }

It adds a some extra dead assignments, but the compiler should take care of these. It is more robust, since anything not explicitly processed is still implicitly copied. The overall code is more "generic" in terms of copy paste too.

The fact that the variable was named copy and not ret makes me wonder if that wasn't the original intent?

At this point, it's mostly style, so whatever you think is best.

That said, I'm not a huge fan of the foreach (i, r; ranges) declaration, which arbitrarily "binds" one of the 4 indexed range to a (by-copy) variable. I think the code I posted above is better.

But whatever. Nitpicks. I'll merge when you say it's good to go, or in 24h, whichever comes first.

@quickfur
Copy link
Member Author

Agreed, but I was aiming for the "minimal change to fix the bug".

@monarchdodra
Copy link
Collaborator

OK, works for me.

@monarchdodra
Copy link
Collaborator

Auto-merge toggled on

monarchdodra added a commit that referenced this pull request Aug 29, 2014
Fix regression 13393: cartesianProduct + joiner = runtime assertion failure
@monarchdodra monarchdodra merged commit dd4b204 into dlang:master Aug 29, 2014
@quickfur quickfur deleted the issue13393 branch August 30, 2014 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants