Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type inference for autoload scenes while they are being loaded #98313

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions modules/gdscript/gdscript_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4469,6 +4469,25 @@ void GDScriptAnalyzer::reduce_identifier(GDScriptParser::IdentifierNode *p_ident
}
}
}
} else {
// Singleton name exists but does not yet have a node assigned, assume that is because we
// are currently in the process of loading it. If this is the first script loaded in the scene,
// temporarily write its path as a value for the singleton so other scripts loaded as
// dependencies can use it to resolve the type of the singleton identifier.
String autoload_script_path;
if (constant.is_string()) {
autoload_script_path = static_cast<String>(constant);
} else {
autoload_script_path = parser->script_path;
GDScriptLanguage::get_singleton()->add_named_global_constant(name, autoload_script_path);
}
Ref<GDScriptParserRef> singl_parser = parser->get_depended_parser_for(autoload_script_path);
if (singl_parser.is_valid()) {
Error err = singl_parser->raise_status(GDScriptParserRef::INHERITANCE_SOLVED);
if (err == OK) {
result = type_from_metatype(singl_parser->get_parser()->head->get_datatype());
}
}
}
}
}
Expand Down
Loading