enforce buff channel size > 0 (#2952)

* fix(stdlib): enforce BufferedChannel size > 0 and add regression test

* chore(repo): ignore cmake/test artifacts

* Formatting

---------

Co-authored-by: Christoffer Lerno <christoffer.lerno@gmail.com>
This commit is contained in:
Fernando López Guevara
2026-02-18 10:34:41 -03:00
committed by GitHub
parent 143fa70f87
commit 9fbf6bc213
3 changed files with 16 additions and 3 deletions

View File

@@ -21,6 +21,9 @@ struct BufferedChannelImpl @private
Type[*] buf;
}
<*
@require size > 0: "channel size must be > 0"
*>
fn void? BufferedChannel.init(&self, Allocator allocator, usz size = 1)
{
BufferedChannelImpl* channel = allocator::new_with_padding(allocator, BufferedChannelImpl, Type.sizeof * size)!;
@@ -155,4 +158,3 @@ fn void? BufferedChannel.close(self) @maydiscard // Remove optional in 0.8.0
channel.mu.unlock();
}