From bd90139f62f5e8a2e29a53b0ddbea1bc3ec6d401 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Sun, 23 Aug 2026 20:05:38 -0500 Subject: [PATCH] fix iterators copy-pasted from ThreadsIterator MessagesIterator.next called notmuch_threads_status on a notmuch_messages_t, which is a type error, so any caller failed to compile. FilenamesIterator.next used the notmuch_threads_* functions throughout and returned a struct literal where a string was expected. All three iterators also had their validity check inverted: a non-zero notmuch_*_valid means an item is available, so testing "!= 0" ended iteration immediately and every search yielded nothing. The unit tests missed all of this because refAllDecls does not analyze function bodies, and refAllDeclsRecursive no longer exists in Zig 0.16. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01QUkL1WZxTCYKWEo6acapsE --- src/FilenamesIterator.zig | 8 +++----- src/MessagesIterator.zig | 4 ++-- src/ThreadsIterator.zig | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/FilenamesIterator.zig b/src/FilenamesIterator.zig index c46e847..c8afc06 100644 --- a/src/FilenamesIterator.zig +++ b/src/FilenamesIterator.zig @@ -16,11 +16,9 @@ filenames: ?*c.notmuch_filenames_t, /// identical to it (and the object to which it ultimately belongs). pub fn next(self: *FilenamesIterator) ?[:0]const u8 { const filenames = self.filenames orelse return null; - if (c.notmuch_threads_valid(filenames) != 0) return null; - defer c.notmuch_threads_move_to_next(filenames); - return .{ - .thread = std.mem.span(c.notmuch_threads_get(filenames) orelse unreachable), - }; + if (c.notmuch_filenames_valid(filenames) == 0) return null; + defer c.notmuch_filenames_move_to_next(filenames); + return std.mem.span(c.notmuch_filenames_get(filenames) orelse unreachable); } /// Deinitialize a `FilenamesIterator` object. diff --git a/src/MessagesIterator.zig b/src/MessagesIterator.zig index 514a221..2deac45 100644 --- a/src/MessagesIterator.zig +++ b/src/MessagesIterator.zig @@ -40,9 +40,9 @@ pub fn collectTags(self: *const MessagesIterator) ?TagsIterator { pub fn next(self: *const MessagesIterator) NextError!?Message { const messages = self.messages orelse return null; - return switch (status(c.notmuch_threads_status(messages))) { + return switch (status(c.notmuch_messages_status(messages))) { .success => message: { - if (c.notmuch_messages_valid(messages) != 0) break :message null; + if (c.notmuch_messages_valid(messages) == 0) break :message null; defer c.notmuch_messages_move_to_next(messages); break :message .{ .message = c.notmuch_messages_get(messages) orelse unreachable, diff --git a/src/ThreadsIterator.zig b/src/ThreadsIterator.zig index 8a52219..1a49153 100644 --- a/src/ThreadsIterator.zig +++ b/src/ThreadsIterator.zig @@ -24,7 +24,7 @@ pub fn next(self: *ThreadsIterator) NextError!?Thread { const threads = self.threads orelse return null; return switch (status(c.notmuch_threads_status(threads))) { .success => thread: { - if (c.notmuch_threads_valid(threads) != 0) break :thread null; + if (c.notmuch_threads_valid(threads) == 0) break :thread null; defer c.notmuch_threads_move_to_next(threads); break :thread .{ .thread = c.notmuch_threads_get(threads) orelse unreachable, -- 2.51.2