Skip to content

Commit b863c1b

Browse files
committed
Merge branch 'develop'
* develop: specify next release fix Sequence->snap()->toSet() being lazy
2 parents 9b356ed + 2db4729 commit b863c1b

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 5.14.3 - 2025-05-02
4+
5+
### Fixed
6+
7+
- `Sequence->snap()->toSet()` wasn't properly keeping values in memory (transformations were lazy)
8+
39
## 5.14.2 - 2025-05-02
410

511
### Fixed

proofs/sequence.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,4 +1002,22 @@ static function($assert, $values) {
10021002
$assert->same($values, $sequence->toList());
10031003
},
10041004
);
1005+
1006+
yield proof(
1007+
'Sequence::lazy()->snap()->toSet() should keep values in memory',
1008+
given(
1009+
Set\Sequence::of(Set\Integers::any()),
1010+
),
1011+
static function($assert, $values) {
1012+
$set = Sequence::lazy(static fn() => yield from $values)
1013+
->snap()
1014+
->toSet()
1015+
->map(static fn() => new stdClass);
1016+
1017+
$assert->same(
1018+
$set->toList(),
1019+
$set->toList(),
1020+
);
1021+
},
1022+
);
10051023
};

src/Sequence/Snap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ public function toSet(): Set
452452
// already loaded data.
453453
return Set::lazy(static function() use ($self) {
454454
yield from $self->iterator();
455-
});
455+
})->snap();
456456
}
457457

458458
#[\Override]

0 commit comments

Comments
 (0)