Skip to content

Commit 2cf1b55

Browse files
committed
Fix board while loop being detected as an infinite loop in L16
1 parent ff518cf commit 2cf1b55

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

script_checking/MiniGDScriptTokenizer.gd

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ func _is_while_loop_infinite(while_token: Dictionary) -> bool:
235235
if condition_vars.size() > 0:
236236
var modified_vars := _get_modified_variables(while_token.body)
237237
for var_name in condition_vars:
238-
if not modified_vars.has(var_name):
239-
return true
238+
if modified_vars.has(var_name):
239+
return false
240240

241-
return false
241+
return true
242242

243243

244244
# Extracts variable names from a condition string
@@ -268,6 +268,10 @@ func _get_modified_variables(body: Array) -> Array:
268268
var var_name: String = token.get("var_name", "")
269269
if var_name != "" and not modified.has(var_name):
270270
modified.append(var_name)
271+
# Also extract the base variable name (before dot) for property assignments
272+
var base_var := var_name.split(".")[0]
273+
if base_var != var_name and not modified.has(base_var):
274+
modified.append(base_var)
271275

272276
if token.has("body"):
273277
var nested_modified := _get_modified_variables(token.body)

0 commit comments

Comments
 (0)