Skip to content
This repository was archived by the owner on Jun 28, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ END TEMPLATE-->
### Bugfixes

* Fix ValueList TryPop not clearing element references.
* Fix ValueList Peek always throwing by referencing the wrong index.

### Other

Expand Down
21 changes: 21 additions & 0 deletions Robust.Shared.Tests/Collections/ValueListTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@ namespace Robust.Shared.Tests.Collections;
[TestFixture, TestOf(typeof(ValueList<>))]
internal sealed class ValueListTest
{
[Test]
public void PeekCorrectReference()
{
var list = new ValueList<bool>(2)
{
false,
true,
};

Assert.That(list.TryPeek(out var popped), Is.True);
Assert.That(popped, Is.True);

list.TryPop(out _);

Assert.That(list.TryPeek(out popped), Is.True);
Assert.That(popped, Is.False);

list.TryPop(out _);
Assert.That(list.TryPeek(out popped), Is.False);
}

[Test]
public void TryPopClearsRemovedReference()
{
Expand Down
2 changes: 1 addition & 1 deletion Robust.Shared/Collections/ValueList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ public bool TryPeek([MaybeNullWhen(false)] out T value)
return false;
}

value = _items![Count];
value = _items![Count - 1];
return true;
}
}
Loading