Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a223166

Browse files
fix: 🐛 continue if no func_def is found (#511)
If a parent class contains a method that is absent in a child class, it is possible for the script_method_list to include a method that is missing from the current script's source code. This fix prevents errors due to the missing `func_def`.
1 parent 29d352a commit a223166

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎addons/mod_loader/internal/mod_hook_preprocessor.gd‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,14 @@ func process_script(path: String, enable_hook_check := false) -> String:
101101
while not is_top_level_func(source_code, func_def.get_start(), is_static): # indent before "func"
102102
func_def = match_func_with_whitespace(method.name, source_code, func_def.get_end())
103103
if not func_def or max_loop <= 0: # Couldn't match any func like before
104-
break # Means invalid Script, should never happen
104+
break # Means invalid Script, unless it's a child script.
105+
# In such cases, the method name might be listed in the script_method_list
106+
# but absent in the actual source_code.
105107
max_loop -= 1
106108

109+
if not func_def: # If no valid function definition is found after processing.
110+
continue # Skip to the next iteration.
111+
107112
var func_body_start_index := get_func_body_start_index(func_def.get_end(), source_code)
108113
if func_body_start_index == -1: # The function is malformed, opening ( was not closed by )
109114
continue # Means invalid Script, should never happen

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /