@@ -229,57 +229,7 @@ func _is_while_loop_infinite(while_token: Dictionary) -> bool:
229229 if stripped in ["true" , "1" ] or stripped in ["not false" , "!false" ]:
230230 return true
231231
232- # Here we check if it is a condition based on variables that are never modified,
233- # like a count variable that never changes in the loop body
234- var condition_vars := _extract_variables_from_condition (condition )
235- if condition_vars .size () > 0 :
236- var modified_vars := _get_modified_variables (while_token .body )
237- for var_name in condition_vars :
238- if modified_vars .has (var_name ):
239- return false
240-
241- return true
242-
243-
244- # Extracts variable names from a condition string
245- func _extract_variables_from_condition (condition : String ) -> Array :
246- var variables := []
247- var var_regex := RegEx .new ()
248- # This captures variables including dot access like position.x
249- var_regex .compile ("([a-zA-Z_][a-zA-Z0-9_]*)(?:\\ .[a-zA-Z_][a-zA-Z0-9_]*)*" )
250-
251- var matches := var_regex .search_all (condition )
252- for regex_match in matches :
253- var var_name : String = regex_match .get_string (1 )
254- # Ignore keywords
255- if not var_name in ["true" , "false" , "and" , "or" , "not" ]:
256- if not variables .has (var_name ):
257- variables .append (var_name )
258-
259- return variables
260-
261-
262- # Returns all the variables that are modified (assigned to) in a token body
263- func _get_modified_variables (body : Array ) -> Array :
264- var modified := []
265-
266- for token in body :
267- if token .type == TOKEN_ASSIGNMENT :
268- var var_name : String = token .get ("var_name" , "" )
269- if var_name != "" and not modified .has (var_name ):
270- 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 )
275-
276- if token .has ("body" ):
277- var nested_modified := _get_modified_variables (token .body )
278- for var_name in nested_modified :
279- if not modified .has (var_name ):
280- modified .append (var_name )
281-
282- return modified
232+ return false
283233
284234
285235# Checks if a token body contains a break statement
0 commit comments