godotengine / godotengine/godot
set_deferred does not throw error with invalid arguments
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
v4.3.stable.mono.official [77dcf97d8]
v4.3.stable.official [77dcf97d8]
v4.0.stable.mono.official [92bee43ad]
v4.4.dev.custom_build [dc5f1b7a2]
### System information
Godot v4.3.stable.mono - Ubuntu 22.04.5 LTS 22.04 - X11 - GLES3 (Compatibility) - RENOIR (renoir, LLVM 15.0.7, DRM 3.57, 6.8.0-49-generic) - AMD Ryzen 5 5500U with Radeon Graphics (12 Threads)
### Issue description
When using `set_deferred` with an non-existent property, or with an invalid value no error message gets thrown.
For example calling `set_deferred("Disabled", true)` in a CollisionShape2D will not make the shape disabled, due to property names not being capitalized, and thus the correct name being `"disabled"`. However this will not throw an error during runtime, making the issue needlessly hard to debug.
Similarly using an invalid value on a property, like `set_deferred("position", "abc")` also doesn't throw an error, while also not affecting the provided property.
This issue is especially annoying when coding in C#, due to C# Properites using PascalCase, making it more likely to accidentally misspell a Property.
### Steps to reproduce
create a Sprite2D Node, add a Texture and add the following script
```gdscript
extends Sprite2D
func _process(delta: float) -> void:
if (Input.is_action_just_pressed("ui_accept")):
# doesn't change the visibility of the node
# due to the property name being "visible" (not capitalized) and not "Visible" (capitalized)
set_deferred("Visible", !visible)
# uncommenting the following line toggles the Visibility as expected
# set_deferred("visible", !visible)
# doesn't do anything due to the Property 'asdf' not existing
set_deferred("asdf", true)
# doesn't do anything, due to material not accepting floats
set_deferred("material", 1.0)
```
Pressing 'Enter' does effectively nothing, and no error will be thrown during runtime or in the editor.
----
The provided MRP contains 2 Sprite2Ds, the one on the left has the script above attached, while the one on the right has a functioning script, which toggles the visibility as expected, attached.
### Minimal reproduction project (MRP)
[set_deferred_problem_MRP.zip](https://github.com/user-attachments/files/18136450/set_deferred_problem_MRP.zip)
Contributor guide
Research direction
Start by running the supplied minimal reproduction project and tracing the set_deferred entry point for invalid property names and values. Check existing property-setting behavior and tests around deferred assignment if available. Done means invalid calls report an error while valid deferred assignments continue to work, including the C# naming scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100