From 3bb145cb5ee111317ce774e15a2705bd49893cd5 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 4 Jan 2024 11:40:31 -0600 Subject: [PATCH] bugfix: `slice.group_by` with empty array --- core/container/slice.onyx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/container/slice.onyx b/core/container/slice.onyx index 169d5172..4eb7ba7c 100644 --- a/core/container/slice.onyx +++ b/core/container/slice.onyx @@ -637,6 +637,8 @@ group_by :: macro (arr: [] $T, comp: (T, T) -> bool, allocator := context.alloca #overload group_by :: macro (arr_: [] $T, comp: Code, allocator := context.allocator) -> [..] [] T { out := make([..] [] T, allocator); + if arr_.count == 0 do return out; + start := 0; arr := arr_; for i: 1 .. arr.count { -- 2.25.1