diff --git a/lib/std/io/stream/buffer.c3 b/lib/std/io/stream/buffer.c3 index 1c106bf46..eb44bc3c8 100644 --- a/lib/std/io/stream/buffer.c3 +++ b/lib/std/io/stream/buffer.c3 @@ -120,14 +120,17 @@ fn usz! WriteBuffer.write(&self, char[] bytes) @dynamic fn void! WriteBuffer.write_byte(&self, char c) @dynamic { - usz n = self.bytes.len - self.index; - if (n == 0) self.write_pending()!; - self.bytes[0] = c; - self.index = 1; + usz n = self.bytes.len - self.index - 1; + if (n == 0) + { + self.write_pending()!; + } + self.bytes[self.index] = c; + self.index += 1; } fn void! WriteBuffer.write_pending(&self) @local { self.index -= self.wrapped_stream.write(self.bytes[:self.index])!; if (self.index != 0) return IoError.INCOMPLETE_WRITE?; -} \ No newline at end of file +} diff --git a/releasenotes.md b/releasenotes.md index 5aae05569..e5718f2ad 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -9,6 +9,7 @@ ### Fixes - Fix bug where `a > 0 ? f() : g()` could cause a compiler crash if both returned `void!`. - `@builtin` was not respected for generic modules #1617. +- Fix issue writing a single byte in the WriteBuffer ### Stdlib changes