Skip to content

Conversation

quickfur
Copy link
Member

current[i] = r.save;
if (!current[i].empty)
empty = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should start with empty = false and set empty to true upon encountering an empty range, otherwise as long as there's one non-empty range you'll get undefined behaviour in front and popFront.

Choose a reason for hiding this comment

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

Agreed. Otherwise you will also have a non-empty Range.init which feels rather error-prone to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

You guys are totally right. As long as one of the arguments is empty, the entire product by definition is empty. I don't know what I was thinking when I wrote that code... must've been past my bed time and I wasn't thinking straight. :P Anyway, I redid the fix, should be better now.

@Safety0ff
Copy link
Contributor

EDIT: Is there an issue with non-empty Range.init that Dicebot mentioned? Otherwise lgtm.

@mihails-strasuns
Copy link

Well it is not something that @quickfur has introduced so not a blocker but I'd appreciate to see it fixed so that default-initialized range will be empty ;)

@quickfur
Copy link
Member Author

That make you happy? ;-)

@mihails-strasuns
Copy link

Yay ^_^

@mihails-strasuns
Copy link

Auto-merge toggled on

mihails-strasuns pushed a commit that referenced this pull request Jul 14, 2014
Fix range violation for cartesianProduct of empty ranges.
@mihails-strasuns mihails-strasuns merged commit 04dee6b into dlang:master Jul 14, 2014
@quickfur quickfur deleted the issue10693 branch July 16, 2014 05:05
@quickfur
Copy link
Member Author

This PR caused a regression: https://issues.dlang.org/show_bug.cgi?id=13393 :-(

@Safety0ff
Copy link
Contributor

This PR caused a regression: https://issues.dlang.org/show_bug.cgi?id=13393 :-(

I think it just exposed the bug that save doesn't copy the state of empty

@quickfur
Copy link
Member Author

Well, yes, I figured that out. :-P
Fix: #2473

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants