Skip to content

Commit 2c55214

Browse files
authored
Merge pull request #79205 from anvilfolk/populate-class-members
GDScript: Solve `_populate_class_members()` cyclic dependency problem
2 parents 5954c58 + 7d29ac0 commit 2c55214

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

modules/gdscript/gdscript.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,11 @@ Error GDScript::reload(bool p_keep_state) {
787787
err = compiler.compile(&parser, this, p_keep_state);
788788

789789
if (err) {
790+
_err_print_error("GDScript::reload", path.is_empty() ? "built-in" : (const char *)path.utf8().get_data(), compiler.get_error_line(), ("Compile Error: " + compiler.get_error()).utf8().get_data(), false, ERR_HANDLER_SCRIPT);
790791
if (can_run) {
791792
if (EngineDebugger::is_active()) {
792793
GDScriptLanguage::get_singleton()->debug_break_parse(_get_debug_path(), compiler.get_error_line(), "Parser Error: " + compiler.get_error());
793794
}
794-
_err_print_error("GDScript::reload", path.is_empty() ? "built-in" : (const char *)path.utf8().get_data(), compiler.get_error_line(), ("Compile Error: " + compiler.get_error()).utf8().get_data(), false, ERR_HANDLER_SCRIPT);
795795
reloading = false;
796796
return ERR_COMPILATION_FAILED;
797797
} else {

modules/gdscript/gdscript_compiler.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2579,9 +2579,9 @@ Error GDScriptCompiler::_populate_class_members(GDScript *p_script, const GDScri
25792579
}
25802580
} else if (!base->is_valid()) {
25812581
Error err = OK;
2582-
Ref<GDScript> base_root = GDScriptCache::get_full_script(base->path, err, p_script->path);
2582+
Ref<GDScript> base_root = GDScriptCache::get_shallow_script(base->path, err, p_script->path);
25832583
if (err) {
2584-
_set_error(vformat(R"(Could not compile base class "%s" from "%s": %s)", base->fully_qualified_name, base->path, error_names[err]), nullptr);
2584+
_set_error(vformat(R"(Could not parse base class "%s" from "%s": %s)", base->fully_qualified_name, base->path, error_names[err]), nullptr);
25852585
return err;
25862586
}
25872587
if (base_root.is_valid()) {
@@ -2591,7 +2591,12 @@ Error GDScriptCompiler::_populate_class_members(GDScript *p_script, const GDScri
25912591
_set_error(vformat(R"(Could not find class "%s" in "%s".)", base->fully_qualified_name, base->path), nullptr);
25922592
return ERR_COMPILATION_FAILED;
25932593
}
2594-
ERR_FAIL_COND_V(!base->is_valid() && !base->reloading, ERR_BUG);
2594+
2595+
err = _populate_class_members(base.ptr(), p_class->base_type.class_type, p_keep_state);
2596+
if (err) {
2597+
_set_error(vformat(R"(Could not populate class members of base class "%s" in "%s".)", base->fully_qualified_name, base->path), nullptr);
2598+
return err;
2599+
}
25952600
}
25962601

25972602
p_script->base = base;
@@ -2968,7 +2973,7 @@ Error GDScriptCompiler::compile(const GDScriptParser *p_parser, GDScript *p_scri
29682973
GDScriptCache::add_static_script(p_script);
29692974
}
29702975

2971-
return GDScriptCache::finish_compiling(main_script->get_path());
2976+
return GDScriptCache::finish_compiling(main_script->path);
29722977
}
29732978

29742979
String GDScriptCompiler::get_error() const {

0 commit comments

Comments
 (0)