Skip to content

GDScript: Fix get_dependencies by deferring resolution#113791

Closed
cpl-s-matsuyama wants to merge 2 commits intogodotengine:masterfrom
cpl-s-matsuyama:gdscript-get-dependencies-deferred
Closed

GDScript: Fix get_dependencies by deferring resolution#113791
cpl-s-matsuyama wants to merge 2 commits intogodotengine:masterfrom
cpl-s-matsuyama:gdscript-get-dependencies-deferred

Conversation

@cpl-s-matsuyama
Copy link
Copy Markdown
Contributor

This PR fixes the issue where get_dependencies() would return an empty list in certain cases, as reported in #90643.

This is a re-implementation of the fix attempted in #90860, which was subsequently reverted in #91908 due to a regression reported in #91726 (import errors).

Unlike the previous attempt, this implementation avoids the regression by deferring the dependency resolution. The previous attempt resolved dependencies immediately, which led to the reported import errors. This approach ensures that dependencies are handled safely without interfering with the parsing process.

I have verified that this solution fixes the original issue (#90643) without causing the regression reported in #91726.

Fixes #90643

vnen and others added 2 commits December 9, 2025 15:51
The parser and analyzer now track the dependencies of the script and
return the list when the resource loader ask for them.

What is considered a dependency:

- Any `preload()` call.
- The base script this one extends.
- Any identifier, including types, that refers to global scripts.
- Any autoload singleton reference.
Delay the resolution of script dependencies until after the pending
updates are processed to avoid issues with initialization order.
@cpl-s-matsuyama cpl-s-matsuyama requested a review from a team as a code owner December 9, 2025 08:35
@cpl-s-matsuyama cpl-s-matsuyama requested a review from a team December 9, 2025 08:35
@dalexeev
Copy link
Copy Markdown
Member

dalexeev commented Dec 9, 2025

Thanks for the PR! However, I'm not sure this is even possible if we want to provide a full dependency graph. The resource system doesn't support circular dependencies, unlike GDScript. The concern is that this will cause issues on the resource system side, not to implement on the GDScript side.

@dalexeev dalexeev added this to the 4.x milestone Dec 9, 2025
@Repiteo Repiteo requested a review from a team as a code owner February 17, 2026 20:09
@HolonProduction
Copy link
Copy Markdown
Member

Even when putting concerns about cyclic dependency support aside, I don't think this is an approach that's compatible with current established behaviour. See #116673 (comment)

@cpl-s-matsuyama
Copy link
Copy Markdown
Contributor Author

Thanks for checking. I looked into #116673 and agree — having a dedicated method like get_cyclic_dependencies seems like the right approach. Closing this PR.

@KoBeWi KoBeWi removed this from the 4.x milestone Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ResourceFormatLoaderGDScript::get_dependencies always returns an empty list

5 participants