Skip to content

Commit

Permalink
Make foreach targets lvalues
Browse files Browse the repository at this point in the history
  • Loading branch information
atilaneves committed Sep 22, 2023
1 parent a89ed6f commit 2174a51
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/ut/vector.d
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,9 @@ private void consumeVec(T)(auto ref T vec) {

@("foreach")
@safe unittest {
foreach(e; vector(7, 7, 7).range) {
// can't be inline in the foreach otherwise disappears before anything happens
scope v = vector(7, 7, 7);
foreach(e; v.range) {
e.should == 7;
}
}
Expand Down Expand Up @@ -482,7 +484,9 @@ private void consumeVec(T)(auto ref T vec) {

@("String")
@safe unittest {
foreach(c; String("oooooo").range)
// can't be inline in the foreach otherwise disappears
auto s = String("oooooo");
foreach(c; s.range)
c.should == 'o';
}

Expand Down

0 comments on commit 2174a51

Please sign in to comment.