Dont allow exporting Nodes from Custom Resources (par with gdscript)
Par with gdscript per https://github.com/godotengine/godot/pull/82843
It would be nice if this could be allowed for built-in resources. I left a comment here https://github.com/godotengine/godot/issues/80538
Oh and maybe I should mention that the current behavior is that it allows you to select a node from the scene to use in the exported field like normal, but instead of adding the node to the scene as a node path (which would be nice for built in resources) it creates an a duplicate of that node that ends up being an orphaned object.
What exactly needs changing in gdext?
Im not sure how it would want to be shown - like as a compile error or a warning or something else when using the #[export] attribute.
The gdscript behavior is that when you try to
extends Resource
@export var x: Node
you are given an error like:
Currently in Rust (or before this was fixed in gdscript) this leads to some unsuspected user bugs when it lets you set nodes in the editor, but then the nodes are duplicated orphaned objects instead of references as expected.
But I am still curious if this behavior should be allowed (but fixed in Godot - to use node paths and not duplicate the node) for built-in resources, which I asked here. In which case the solution for disallowing this in #[export] attribute would probably not be a viable solution, and I think things would have to be fixed on the Godot side because at that point the behavior is dependent on what the .tscn file looks like.
So to answer the question - maybe the solution is to wait until that question is answered, and if the behavior is to remain the same then add some sort of checks to #[export]?
here's one way we could disallow it that lives entirely in the type system https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=834bb7d13150904d471eef57e73d1b66
I implemented this via runtime validation at startup. Parametrizing Export for this one little check is too heavy.
It would be nice if this could be allowed for built-in resources.
This hasn't been accepted in Godot, so no...
This hasn't been accepted in Godot, so no...
Right, I should have been more clear. I meant "it would be nice if Godot allowed for builtin resources", and then that would need to be considered here