aboutsummaryrefslogtreecommitdiff
path: root/src/stack.zig
diff options
context:
space:
mode:
authorJulien Dessaux2022-08-15 19:24:34 +0200
committerJulien Dessaux2022-08-16 19:24:34 +0200
commit357c54663c332aff82f539a838a930842192e5ba (patch)
tree9a7bd759aaa9c3741a14f5ee5e3d6f21807d1ce1 /src/stack.zig
parentImplemented the y command (diff)
downloadzigfunge98-357c54663c332aff82f539a838a930842192e5ba.tar.gz
zigfunge98-357c54663c332aff82f539a838a930842192e5ba.tar.bz2
zigfunge98-357c54663c332aff82f539a838a930842192e5ba.zip
Fixed bugs reported by the mycology test suite
Diffstat (limited to '')
-rw-r--r--src/stack.zig5
1 files changed, 2 insertions, 3 deletions
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);