Skip to content

Commit

Permalink
fix WriteBuffer.write_byte
Browse files Browse the repository at this point in the history
  • Loading branch information
hwchen authored and lerno committed Nov 13, 2024
1 parent 7b516e6 commit 800eda1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/std/io/stream/buffer.c3
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
}
}
1 change: 1 addition & 0 deletions releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 800eda1

Please sign in to comment.