From 357c54663c332aff82f539a838a930842192e5ba Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Mon, 15 Aug 2022 19:24:34 +0200 Subject: Fixed bugs reported by the mycology test suite --- src/stack.zig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/stack.zig') diff --git a/src/stack.zig b/src/stack.zig index 09edd2e..c1f8696 100644 --- a/src/stack.zig +++ b/src/stack.zig @@ -12,9 +12,8 @@ pub const Stack = struct { self.allocator.destroy(self); } pub fn duplicate(self: *Stack) !void { - if (self.data.items.len > 0) { - try self.push(self.data.items[self.data.items.len - 1]); - } + const v = self.pop(); + try self.pushVector([2]i64{ v, v }); } test "duplicate" { var s = try Stack.init(std.testing.allocator); -- cgit v1.2.3