{"record":{"id":"e6d6d2c81bc94436","repo":"krahets/hello-algo","slug":"error-e6d6d2","errorCode":null,"errorMessage":"両端キューが空です","messagePattern":"両端キューが空です","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ja/codes/zig/chapter_stack_and_queue/linkedlist_deque.zig","lineNumber":100,"sourceCode":"                node.prev = self.rear;\n                self.rear = node;   // 末尾ノードを更新する\n            }\n            self.que_size += 1;      // キューの長さを更新\n        } \n\n        // キュー先頭にエンキュー\n        pub fn pushFirst(self: *Self, num: T) !void {\n            try self.push(num, true);\n        } \n\n        // キュー末尾にエンキュー\n        pub fn pushLast(self: *Self, num: T) !void {\n            try self.push(num, false);\n        } \n        \n        // デキュー操作\n        pub fn pop(self: *Self, is_front: bool) T {\n            if (self.isEmpty()) @panic(\"両端キューが空です\");\n            var val: T = undefined;\n            // キュー先頭からの取り出し\n            if (is_front) {\n                val = self.front.?.val;     // 先頭ノードの値を一時保存\n                // 先頭ノードを削除\n                var fNext = self.front.?.next;\n                if (fNext != null) {\n                    fNext.?.prev = null;\n                    self.front.?.next = null;\n                }\n                self.front = fNext;         // 先頭ノードを更新する\n            // キュー末尾からの取り出し\n            } else {\n                val = self.rear.?.val;      // 末尾ノードの値を一時保存\n                // 末尾ノードを削除\n                var rPrev = self.rear.?.prev;\n                if (rPrev != null) {\n                    rPrev.?.next = null;","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/krahets/hello-algo/blob/69932aed1891a7b7f6a0de88cd116d3fe13e7032/ja/codes/zig/chapter_stack_and_queue/linkedlist_deque.zig#L82-L118","documentation":"This panic is raised by the internal pop(is_front) method of a doubly-linked-list deque (Japanese localization). It fires when dequeuing (popFirst or popLast) from an empty deque. Because the method dereferences front.?.val / rear.?.val, skipping the guard would be unsafe, so the library aborts instead. @panic is uncatchable.","triggerScenarios":"Calling deque.popFirst() or deque.popLast() when the deque is empty; or any code that calls pop(true)/pop(false) with zero elements.","commonSituations":"Deque-based sliding window that pops after the window empties; palindrome/stepping algorithms that pop from both ends and overshoot; producer/consumer mismatch where pops exceed pushes.","solutions":["Check deque.isEmpty() before popFirst()/popLast().","Track counts so the two-ended pops never exceed total pushes.","Guard at the call site: if (!d.isEmpty()) _ = d.popFirst();","Refactor pop to return ?T if you need recoverable empty-pops."],"exampleFix":"// before\nvar v = deque.popFirst(); // @panics when empty\n\n// after\nif (deque.isEmpty()) return;\nvar v = deque.popFirst();","handlingStrategy":"validation","validationCode":"// Validate non-empty before dequeuing either end\nif (!deque.isEmpty()) {\n    var v = deque.popFirst();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Both popFirst() and popLast() route through pop(is_front) — guard both.","Track total pushes vs pops so two-ended drains never overshoot.","Wrap pop in a helper returning ?T if recoverable semantics are needed."],"tags":["zig","deque","panic","precondition","data-structure","i18n-ja"],"backgroundTag":null,"analyzedSha":"69932aed1891a7b7f6a0de88cd116d3fe13e7032","analyzedAt":"2026-08-13T23:02:37.581Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}