Tested versions
26.3.alpha 1
System information
Redot v26.3.alpha.1 (957fda4) - CachyOS Linux
Issue description
I saw #1311 addressed the freed object issue with containers that has been reported in #1310 and godotengine/godot#110511. So I was wondering if we plan to address a similar issue in godotengine/godot#85947 when assigning a Variant with value freed object to non-Variant. There is a PR godotengine/godot#87296 to address it but it is not merged.
I am not familiar with the Godot or Redot codebase (nor I have written a line of CPP before) but I saw this proposal completed a few days ago: godotengine/godot-proposals#12323 (comment)
var node2d: Node2D = Node2D.new()
node2d.free()
var node: Node = node2d # OK
var variant: Variant = node2d # OK
node = variant # Trying to assign invalid previously freed instance.
var node := Node.new()
var dict := { "node": node }
node.free()
node = dict["node"] # Trying to assign invalid previously freed instance.
The following cases are not the same but they have a similar issue.
var node := Node.new()
node.free()
typed(node) # Invalid type in function 'typed' in base 'Node2D (main.gd)'. The Object-derived class of argument 1 (previously freed) is not a subclass of the expected argument class.
func typed(node: Node) -> void:
pass
var obj := Object.new()
print(obj is Object)
obj.free()
print(obj is Object) # Left operand of 'is' is a previously freed instance.
This case doesn't halt execution but it does emit an error.
var node := Node.new()
var lambda = func(): print(node)
node.free()
lambda.call() # Prints `<null>` but has error "Lambda capture at index 0 was freed. Passed "null" instead."
I think this one is just similar to typed function case.
var node := Node.new()
var lambda = func(node: Node): print(node)
node.free()
lambda.call(node) # Invalid type in function '<anonymous lambda>(lambda) (Callable)'. The Object-derived class of argument 1 (previously freed) is not a subclass of the expected argument class.
lambda.bind(node).call() # Invalid type in function '<anonymous lambda>(lambda) (Callable)'. The Object-derived class of argument 1 (previously freed) is not a subclass of the expected argument class.
Steps to reproduce
Same as provided codeblock
Minimal reproduction project (MRP)
Same as provided codeblock
Tested versions
26.3.alpha 1
System information
Redot v26.3.alpha.1 (957fda4) - CachyOS Linux
Issue description
I saw #1311 addressed the freed object issue with containers that has been reported in #1310 and godotengine/godot#110511. So I was wondering if we plan to address a similar issue in godotengine/godot#85947 when assigning a Variant with value freed object to non-Variant. There is a PR godotengine/godot#87296 to address it but it is not merged.
I am not familiar with the Godot or Redot codebase (nor I have written a line of CPP before) but I saw this proposal completed a few days ago: godotengine/godot-proposals#12323 (comment)
The following cases are not the same but they have a similar issue.
This case doesn't halt execution but it does emit an error.
I think this one is just similar to
typedfunction case.Steps to reproduce
Same as provided codeblock
Minimal reproduction project (MRP)
Same as provided codeblock