Skip to content

Commit

Permalink
Prevent error on empty file
Browse files Browse the repository at this point in the history
  • Loading branch information
bgk- committed Mar 17, 2024
1 parent e0020c8 commit 1b58e96
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/compiler.zig
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,10 @@ pub const Compiler = struct {

try self.replaceDiverts();
// Add one final fin at the end of file to grab the initial jump_request
try self.chunk.token_lines.append(self.chunk.token_lines.items[self.chunk.instructions.items.len - 1]);
try self.chunk.instructions.append(@intFromEnum(OpCode.fin));
if (self.chunk.token_lines.items.len > 0) {
try self.chunk.token_lines.append(self.chunk.token_lines.items[self.chunk.instructions.items.len - 1]);
try self.chunk.instructions.append(@intFromEnum(OpCode.fin));
}
}

fn enterChunk(self: *Compiler) !void {
Expand Down

0 comments on commit 1b58e96

Please sign in to comment.