Godot crashes on seemingly simple for loop without error

Godot Version

Godot 4.6.1

Question

Hi I followed Godot Game Lab tutorial for slay the spire map, godot crashes on for loop on Array of Arrays when trying to setup floor types

Array:
var map_data: Array[Array]

used cons:
FLOOR: int = 15
MAP_WIFTH: int = 7

populating this array

func _generate_initial_grid() -> Array[Array]:
	var result : Array[Array] = []

	for i in FLOORS:
		var adjacent_rooms: Array[Room] = []
		
		for j in MAP_WIDTH:
			var current_room := Room.new()
			var offset := Vector2(randf(), randf()) * PLACEMENT_RANDOMNESS
			current_room.position = Vector2(j * X_DIST, i * -Y_DIST) + offset
			current_room.row = i
			current_room.column = j
			current_room.next_rooms = []
			
			if i == FLOORS - 1: 
				current_room.position.y = (i + 1) * -Y_DIST

			adjacent_rooms.append(current_room)
		result.append(adjacent_rooms)

	return result

It uses resource of a Room:

extends Resource
class_name Room

enum room_list {NOT_ASSIGNED, start, weapon, ability, upgrade, rest_site, fight, boss}

@export var type: room_list
@export var row: int
@export var column: int
@export var position: Vector2
@export var next_rooms: Array[Room]
@export var selected: bool = false

Here’s the problem, Now I try to override type of each room according to some rules, but Godot freezes:

func _setup_room_types() -> void:
	for room: Room in map_data[0]:
		if room.next_rooms.size() > 0:
			room.type = Room.room_list.fight

from what I managed to debug is that it goes through loop 7 times (which is equal to map width and correct behavior). It managed to change type of those rooms to “fight” and then never gets out of it. If I add breakpoint after loop it never reaches it. can anyone help with it?

Like I said, the bit issue is I don’t have any error, it just froze.

I use latest version, win 11 updated, gforce graphics updated and tried to restart godot, reload project, checked other places of the code and restarted pc. Also it’s seperate node from rest of the projects. There are more lines to this code of course, but it seems like those don’t change much to generate this issue

Is it a crash or a freeze?

What do you mean by that? How did you determine that in never goes out of the loop? Where exactly did you put that breakpoint? Put print statements inside the loop body, directly after the loop and on function exit. Which of those get printed?

How you described it, is what I made to get this debug initially. Now that you said it, I added another print statement after for loop, and breakpoint line after that. engine froze, never got breakpoint notification

func _setup_room_types() -> void:
	#make first room always a fight
	var number:= 1
	for room: Room in map_data[0]:
		print("for loop no.: ", number)
		if room.next_rooms.size() > 0:
			print("if statement loop no.: ", number)
			room.type = Room.room_list.fight
			print("room type: ", room.type)
		number += 1
	print("exited for loop")

and output (it makes sense that not all for loops trigger if statement, that’s why it’s there), and it does change the type as intended as well.

for loop no.: 1
for loop no.: 2
if statement loop no.: 2
room type: 6
for loop no.: 3
if statement loop no.: 3
room type: 6
for loop no.: 4
for loop no.: 5
for loop no.: 6
for loop no.: 7
if statement loop no.: 7
room type: 6
exited for loop

Ok seems like the issue was actually somewhere else. I used while loop on another part of the code that seemingly never got fired but actually was just never breaking. Sorry to bother closing the topic