Fix preload cyclic references#65672
Conversation
97c07a5 to
402c3a1
Compare
402c3a1 to
b04a70f
Compare
There was a problem hiding this comment.
I know that I need to add a check to see if the preloaded path is a script or not before using GDScriptCache.
bf9d8c1 to
8c9a65c
Compare
There was a problem hiding this comment.
This is where it gets weird. There's two behaviors, depending on the code on this line.
- With
GDScriptCache::get_shallow_script()as is:- my minimal reproduction project ✔️ ;
- the new test cases ❌ ;
modules/gdscript/tests/scripts/analyzer/features/preload_constant_types_are_inferred.gd❌ ;- build does not fail due to memory leaks ✔️ .
- With
ResourceLoader::load()and thenGDScriptCache::get_shallow_script()ifp_preload->resource.is_null():- my minimal reproduction project ❌ ;
- the new test cases ✔️ ;
modules/gdscript/tests/scripts/analyzer/features/preload_constant_types_are_inferred.gd✔️ ;- build fails due to memory leaks
⚠️
8c9a65c to
98ce4b2
Compare
98ce4b2 to
22a09fe
Compare
|
@Calinou Could you reopen my PR? I messed up my rebases and erased my code, even force pushed it. I recovered it, but I cannot reopen my PR myself. |
|
It can't be reopened because at some time the contents of your branch were identical to the That's actually a bug because I see you did fix the branch already and there's now a commit, but GitHub doesn't notice. So you'll have to open a new PR. |
|
#67714 This is the current PR with this. |

Edit: This PR has been replaced with #67714
Edit: Currently not working as intended. Will post updates.This simple PR makes it possible to use cyclic references with preloaded scripts.
After trying to load completely a script using
ResourceLoader::load()(that calls down the lineResourceFormatLoaderGDScript::load()then right afterGDScriptCache::get_full_script()), if the reference is null (which means that the script is not yet compiled), then we use instead theGDScriptCache::get_shallow_script().The beauty of
GDScriptCache::get_shallow_script()is that it gives back the result ofGDScriptCache::get_full_script()if it has been fully loaded once.So, this code works with this PR, which returns this error on
master:Constant value uses script from "res://b.gd" which is loaded but not compiled.:Minimal reproduction project:
cyclic3.zip
Fixes #58181, fixes #61043, fixes #32165