Nested typed list does not compile

Why would the following code raise a TypingError: Failed in nopython mode pipeline (step: nopython frontend). list indices must be integers or slices

int_list_type = ListType(int64)
@njit
def f():    
    groups = List.empty_list(int_list_type)
    group_id_to_index_map = Dict.empty(key_type=int64, value_type=int64)
    next_index = 0
    for groud_id, item in [(4, 42), (2, 23), (4, 15)]:
        index = group_id_to_index_map.get(groud_id, -1)
        if index == -1:
            group_id_to_index_map[groud_id] = next_index
            groups.append(List([item]))
            next_index += 1
        else:            
            groups[index].append(item)

    return groups

Can you post a complete minimal sample of what you’re trying to do?

The code I gave is the essence of what I am trying to do. The expected result is a nested typed list of the form [[42, 15], [23]]. This code with the required imports fails to compile. Interestingly, changing the first line to

groups = []

causes no issue.

This nested list works for me, perhaps you can adapt it to your code.

int_list_type = numba.typeof(numba.typed.List.empty_list(numba.int64))
nested_list_type = numba.typeof(numba.typed.List.empty_list(int_list_type))

@numba.njit
def append(nested, *args):
    res = numba.typed.List.empty_list(numba.int64)
    for arg in args:
        res.append(arg)
    nested.append(res)

nested_list = numba.typed.List.empty_list(int_list_type)
append(nested_list, 42, 43, 44)
append(nested_list, 1)

print(nested_list)

```