Skip to content

Commit 51b9362

Browse files
committed
Switch a check to a debug assert
1 parent d89f5ee commit 51b9362

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/canonicalize/NodeStore.zig

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,14 +2626,9 @@ pub fn clearScratchDefsFrom(store: *NodeStore, start: u32) void {
26262626
}
26272627

26282628
/// Creates a slice corresponding to a span.
2629-
/// Returns an empty slice if the span is out of bounds (can happen with corrupted malformed code).
26302629
pub fn sliceFromSpan(store: *const NodeStore, comptime T: type, span: base.DataSpan) []T {
26312630
const extra_data_len = store.extra_data.items.items.len;
2632-
// Bounds check: ensure the span doesn't exceed the extra_data length
2633-
if (span.start >= extra_data_len or span.start + span.len > extra_data_len) {
2634-
// Return empty slice for corrupted spans
2635-
return &[_]T{};
2636-
}
2631+
std.debug.assert(span.start + span.len <= extra_data_len);
26372632
return @ptrCast(store.extra_data.items.items[span.start..][0..span.len]);
26382633
}
26392634

0 commit comments

Comments
 (0)