Browse Source

Fix `assign_at_elems` to match the same logic as `assign_at_elem_string`

gingerBill 1 year ago
parent
commit
829e4cc67e
1 changed files with 7 additions and 2 deletions
  1. 7 2
      core/runtime/core_builtin.odin

+ 7 - 2
core/runtime/core_builtin.odin

@@ -234,6 +234,8 @@ delete :: proc{
 	delete_dynamic_array,
 	delete_slice,
 	delete_map,
+	delete_soa_slice,
+	delete_soa_dynamic_array,
 }
 
 
@@ -587,11 +589,14 @@ assign_at_elem :: proc(array: ^$T/[dynamic]$E, index: int, arg: E, loc := #calle
 
 @builtin
 assign_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, args: ..E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error {
-	if index+len(args) < len(array) {
+	new_size := index + len(arg)
+	if len(args) == 0 {
+		ok = true
+	} else if new_size < len(array) {
 		copy(array[index:], args)
 		ok = true
 	} else {
-		resize(array, index+1+len(args), loc) or_return
+		resize(array, new_size, loc) or_return
 		copy(array[index:], args)
 		ok = true
 	}