mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
Merge pull request #6803 from edi33416/issue_19213
Fix Issue 19213 - goto skips declaration of variable in std.algorithm…
This commit is contained in:
commit
07ea0e0201
1 changed files with 44 additions and 28 deletions
|
@ -2706,21 +2706,24 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR))
|
|||
|
||||
private enum popFrontEmptyElements = q{
|
||||
// Skip over empty subranges.
|
||||
if (_items.empty) goto end;
|
||||
while (_items.front.empty)
|
||||
while (!_items.empty && _items.front.empty)
|
||||
{
|
||||
_items.popFront();
|
||||
if (_items.empty) goto end;
|
||||
}
|
||||
// We cannot export .save method unless we ensure subranges are not
|
||||
// consumed when a .save'd copy of ourselves is iterated over. So
|
||||
// we need to .save each subrange we traverse.
|
||||
static if (isForwardRange!RoR && isForwardRange!(ElementType!RoR))
|
||||
_current = _items.front.save;
|
||||
if (!_items.empty)
|
||||
{
|
||||
// We cannot export .save method unless we ensure subranges are not
|
||||
// consumed when a .save'd copy of ourselves is iterated over. So
|
||||
// we need to .save each subrange we traverse.
|
||||
static if (isForwardRange!RoR && isForwardRange!(ElementType!RoR))
|
||||
_current = _items.front.save;
|
||||
else
|
||||
_current = _items.front;
|
||||
}
|
||||
else
|
||||
_current = _items.front;
|
||||
end:
|
||||
assert(1); // required to avoid 'EOF instead of statement' error
|
||||
{
|
||||
_current = typeof(_current).init;
|
||||
}
|
||||
};
|
||||
|
||||
static if (isForwardRange!RoR && isForwardRange!(ElementType!RoR))
|
||||
|
@ -2800,32 +2803,36 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR))
|
|||
|
||||
private enum popBackEmptyElements = q{
|
||||
// Skip over empty subranges.
|
||||
if (_items.empty) goto end2;
|
||||
while (_items.back.empty)
|
||||
while (!_items.empty && _items.back.empty)
|
||||
{
|
||||
_items.popBack();
|
||||
if (_items.empty) goto end2;
|
||||
}
|
||||
checkFinalElement;
|
||||
// We cannot export .save method unless we ensure subranges are not
|
||||
// consumed when a .save'd copy of ourselves is iterated over. So
|
||||
// we need to .save each subrange we traverse.
|
||||
static if (isForwardRange!RoR && isForwardRange!(ElementType!RoR))
|
||||
if (!_items.empty)
|
||||
{
|
||||
if (reachedFinalElement)
|
||||
_current = _items.back.save;
|
||||
checkFinalElement;
|
||||
// We cannot export .save method unless we ensure subranges are not
|
||||
// consumed when a .save'd copy of ourselves is iterated over. So
|
||||
// we need to .save each subrange we traverse.
|
||||
static if (isForwardRange!RoR && isForwardRange!(ElementType!RoR))
|
||||
{
|
||||
if (reachedFinalElement)
|
||||
_current = _items.back.save;
|
||||
else
|
||||
_currentBack = _items.back.save;
|
||||
}
|
||||
else
|
||||
_currentBack = _items.back.save;
|
||||
{
|
||||
if (reachedFinalElement)
|
||||
_current = _items.back;
|
||||
else
|
||||
_currentBack = _items.back;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reachedFinalElement)
|
||||
_current = _items.back;
|
||||
else
|
||||
_currentBack = _items.back;
|
||||
_current = typeof(_current).init;
|
||||
_currentBack = typeof(_currentBack).init;
|
||||
}
|
||||
end2:
|
||||
assert(1);
|
||||
};
|
||||
|
||||
static if (hasAssignableElements!(ElementType!RoR))
|
||||
|
@ -2948,6 +2955,15 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR))
|
|||
assert(!equal(js2, js));
|
||||
}
|
||||
|
||||
// https://issues.dlang.org/show_bug.cgi?id=19213
|
||||
@system unittest
|
||||
{
|
||||
auto results = [[1,2], [3,4]].map!(q => q.chunkBy!"a").joiner;
|
||||
int i = 1;
|
||||
foreach (ref e; results)
|
||||
assert(e[0] == i++);
|
||||
}
|
||||
|
||||
/// joiner can be bidirectional
|
||||
@safe unittest
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue