godotengine / godotengine/godot

Inconsistent setter invocation in inherited scene without changed script and with overridden script

Open
#97,003 0 comments 0 reactions 0 assignees View on GitHub
confirmed topic:gdscript
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

v4.3.stable.official [77dcf97d8]

### System information

Macos Sonoma 14.6.1 (23G93)

### Issue description

Instantiating the inherited scene (Test3), which inherits from the base scene (Test1), triggers the setter for an exported variable, even though it is not triggered in the inherited scene that doesn’t override the script (Test2). In the base scene (Test1), there is an exported variable with a setter that accesses a property of an object (e.g., val.name). When the script is overridden in the inherited scene (Test3), the setter is triggered, but in the inherited scene without the script override (Test2), the setter is not triggered. This leads to inconsistent behavior.

Expected result: The behavior should be the same in both inherited scenes (Test2 and Test3).

Actual result: In the inherited scene (Test3), the setter is triggered, whereas in the inherited scene without the script override (Test2), the setter is not triggered. This leads to inconsistent behavior in how setters are invoked across inherited scenes.

### Steps to reproduce

Create a base scene (Test1) with a class extending Node2D and a script:
```
extends Node2D
class_name Test1

@export var my_export_var: Resource set = _my_setter

func _my_setter(val):
my_export_var = val
print(val.name)
```
Create an inherited scene (Test2) that inherits from the base scene (Test1) without changing the script.
Create another inherited scene (Test3), also inheriting from the base scene (Test1), but with an overridden script:

`extends Test1`

Instantiate the inherited scene (Test3).

### Minimal reproduction project (MRP)

[godotbuginstantiateexportsetter.zip](https://github.com/user-attachments/files/17002963/godotbuginstantiateexportsetter.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.