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

Typed containers fail to load untyped data at runtime #96872

Closed
KoBeWi opened this issue Sep 11, 2024 · 5 comments
Closed

Typed containers fail to load untyped data at runtime #96872

KoBeWi opened this issue Sep 11, 2024 · 5 comments

Comments

@KoBeWi
Copy link
Member

KoBeWi commented Sep 11, 2024

Tested versions

4.4 dev2
And probably earlier.

System information

Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 (NVIDIA; 31.0.15.4633) - Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 Threads)

Issue description

When you have a resource with some exported properties of type Array and Dictionary, but later you decide that you want to add type to your Array/Dictionary, old instances of the resource will load with these variables empty, but only at runtime.

EDIT:
Apparently the containers loaded in editor are untyped. Re-saving the resource won't fix them.

Steps to reproduce

  1. Open MRP
  2. See that Array and Dictionary are printed with content
  3. Run the scene
  4. Compare the results

Minimal reproduction project (MRP)

tybug.zip

@dalexeev
Copy link
Member

I think it's because PROPERTY_HINT_TYPE_STRING is used for exporting typed arrays/dictionaries (for the Inspector), while PROPERTY_HINT_ARRAY_TYPE and PROPERTY_HINT_DICTIONARY_TYPE are intended to represent the type information for GDScript/C#/GDExtension.

It would be ideal if we separated the type information from the metadata like hint and usage. But that's probably too breaking.

As a workaround, we could make all parts of the engine (core, GDScript, C#, GDExtension, inspector, ResourceFormatText, ResourceFormatBinary, etc.) understand both hints.

We also need to somehow differentiate typed collections from untyped ones, since PROPERTY_HINT_TYPE_STRING can be used with both options. Or we could use the fact that untyped arrays/dictionaries can reference typed ones, although this is unsafe and essentially a hole in the type system.

@Repiteo
Copy link
Contributor

Repiteo commented Sep 11, 2024

It would be ideal if we separated the type information from the metadata like hint and usage. But that's probably too breaking.

Breaking typing changes are honestly an inevitability. If we wanna eventually support even a fraction of the other typing-related requests (structs, nested types, actual enums, unions, nullable types, etc.), something is gonna have to give.

@DanielSnd
Copy link
Contributor

I think I just ran into this error. I just opened in 4.4dev a project that I had fully working in 4.3. A resource with typed arrays in the editor when I try playing the game initializes the resource with the typed arrays completely empty.

If this is the same error it was working fine in 4.3 and the problem started at some point in 4.4

@dalexeev dalexeev added this to the 4.4 milestone Sep 27, 2024
@DanielSnd
Copy link
Contributor

DanielSnd commented Oct 14, 2024

Did a git bisect on it. It started with the commit 3009073 from this PR: #96780

Haven't read the code in the commit or investigated further.

  • Edit -

Upon further investigation this might have been already reverted, seems to be the same issue as #97788 that has been closed. Will try the MRP again with the current latest master and confirm if this has been solved.

@DanielSnd
Copy link
Contributor

I have now confirmed that this issue has been solved by #97817 that has already been merged. I confirmed using the MRP and my own project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Unassessed
Development

No branches or pull requests

4 participants