mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-23 08:48:03 +00:00
Make a bounds check be a std.debug.assert
This commit is contained in:
parent
81388bce44
commit
be98f4a503
2 changed files with 0 additions and 24 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue