Task
In src/tri/tri_query_commands.zig there are 5 instances of catch unreachable on allocator calls:
- Line 1043:
result.trits = self.allocator.alloc(i8, self.trits.len) catch unreachable;
- Line 1068:
inversed.trits = self.allocator.alloc(i8, key.trits.len) catch unreachable;
- Line 1087:
result.trits = self.allocator.alloc(i8, self.trits.len) catch unreachable;
- Line 1122:
result.trits = self.allocator.alloc(i8, self.trits.len) catch unreachable;
- Line 1502:
entities[i] = BipolarBigInt.semanticRandom(std.heap.page_allocator, dim, seed, category_id) catch unreachable;
Allocation can fail. Use try instead.
Fix
Replace each catch unreachable with try. Ensure enclosing functions return error unions.
File
src/tri/tri_query_commands.zig — lines 1043, 1068, 1087, 1122, 1502
Acceptance
zig build compiles without errors
zig fmt passes
- No
catch unreachable on allocator calls in this file
Task
In
src/tri/tri_query_commands.zigthere are 5 instances ofcatch unreachableon allocator calls:result.trits = self.allocator.alloc(i8, self.trits.len) catch unreachable;inversed.trits = self.allocator.alloc(i8, key.trits.len) catch unreachable;result.trits = self.allocator.alloc(i8, self.trits.len) catch unreachable;result.trits = self.allocator.alloc(i8, self.trits.len) catch unreachable;entities[i] = BipolarBigInt.semanticRandom(std.heap.page_allocator, dim, seed, category_id) catch unreachable;Allocation can fail. Use
tryinstead.Fix
Replace each
catch unreachablewithtry. Ensure enclosing functions return error unions.File
src/tri/tri_query_commands.zig— lines 1043, 1068, 1087, 1122, 1502Acceptance
zig buildcompiles without errorszig fmtpassescatch unreachableon allocator calls in this file