From be98f4a5030d32a3ea484253ece9e456aa522752 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Wed, 26 Nov 2025 18:57:25 -0500 Subject: [PATCH] Make a bounds check be a std.debug.assert --- src/check/copy_import.zig | 17 ----------------- src/layout/store.zig | 7 ------- 2 files changed, 24 deletions(-) diff --git a/src/check/copy_import.zig b/src/check/copy_import.zig index de984508a2..e1f817d00d 100644 --- a/src/check/copy_import.zig +++ b/src/check/copy_import.zig @@ -245,23 +245,6 @@ fn copyFunc( dest_idents: *base.Ident.Store, allocator: std.mem.Allocator, ) std.mem.Allocator.Error!Func { - const start_idx: usize = @intFromEnum(func.args.start); - const end_idx: usize = start_idx + func.args.count; - - // Validate the range before slicing - if (end_idx > source_store.vars.items.items.len) { - // The function's arg range is invalid - this can happen if the function - // type was created with a range from a different store or the store was modified - // For now, handle gracefully by returning an empty args function - // Return a function with no args for now to avoid the crash - // TODO: Investigate why this happens and fix the root cause - return Func{ - .args = try dest_store.appendVars(&.{}), - .ret = try copyVar(source_store, dest_store, func.ret, var_mapping, source_idents, dest_idents, allocator), - .needs_instantiation = func.needs_instantiation, - }; - } - const args_slice = source_store.sliceVars(func.args); var dest_args = std.ArrayList(Var).empty; diff --git a/src/layout/store.zig b/src/layout/store.zig index 314ff3b0c8..b50f348956 100644 --- a/src/layout/store.zig +++ b/src/layout/store.zig @@ -207,13 +207,6 @@ pub const Store = struct { if (constraints.isEmpty()) { return false; } - // Check bounds before slicing - at runtime, constraints may not be available - const start: usize = @intFromEnum(constraints.start); - const end: usize = start + constraints.count; - if (end > self.types_store.static_dispatch_constraints.len()) { - // Constraints not available in this types store (e.g., runtime context) - return false; - } for (self.types_store.sliceStaticDispatchConstraints(constraints)) |constraint| { if (constraint.origin == .from_numeral) { return true;