DzLox

:)
git clone https://git.sr.ht/~ashymad/DzLox
Log | Files | Refs | Submodules | LICENSE

commit 12d371f7a7dd8ea745a82a2dd028acec049f2d25
parent 80a74f80476e5f8fee826829d9fc44d688794cf3
Author: Szymon Mikulicz <szymon.mikulicz@aptiv.com>
Date:   Sun, 18 Aug 2024 18:37:39 +0200

List removal

Diffstat:
Mzlox/src/vm.zig | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/zlox/src/vm.zig b/zlox/src/vm.zig @@ -320,6 +320,13 @@ pub const VM = struct { var m = obj.obj.cast(.List) catch unreachable; if (val.is(Value.nil) and key.eql(Value.init(@as(f64, @floatFromInt(m.len - 1))))) { _ = m.pop(self.vm.allocator); + while(m.tip) |t| { + if (t.val.is(Value.nil)) { + _ = m.pop(self.vm.allocator); + } else { + break; + } + } } else { m.set(key, val, self.vm.allocator) catch { self.runtimeError("Invalid index for a list, has to be a number greater than 0", .{});