GDScript: Improve usability of setter chains
- Consider PackedArrays non-shared since they are copied on C++/script boundaries. - Add error messages in the analyzer when assigning to read-only properties. - Add specific error message at runtime when assignment fails because the property is read-only.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
func test():
|
||||
var tree := SceneTree.new()
|
||||
tree.root = Window.new()
|
||||
tree.free()
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Cannot assign a new value to a read-only property.
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
func test():
|
||||
var state := PhysicsDirectBodyState3DExtension.new()
|
||||
state.center_of_mass.x += 1.0
|
||||
state.free()
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Cannot assign a new value to a read-only property.
|
||||
@@ -0,0 +1,7 @@
|
||||
func test():
|
||||
var state = PhysicsDirectBodyState3DExtension.new()
|
||||
assign(state)
|
||||
state.free()
|
||||
|
||||
func assign(state):
|
||||
state.center_of_mass.x -= 1.0
|
||||
@@ -0,0 +1,6 @@
|
||||
GDTEST_RUNTIME_ERROR
|
||||
>> SCRIPT ERROR
|
||||
>> on function: assign()
|
||||
>> runtime/assign_to_read_only_property.gd
|
||||
>> 7
|
||||
>> Cannot set value into property "center_of_mass" (on base "PhysicsDirectBodyState3DExtension") because it is read-only.
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
func test():
|
||||
var state = PhysicsDirectBodyState3DExtension.new()
|
||||
var prop = &"center_of_mass"
|
||||
assign(state, prop)
|
||||
state.free()
|
||||
|
||||
func assign(state, prop):
|
||||
state[prop].x = 1.0
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
GDTEST_RUNTIME_ERROR
|
||||
>> SCRIPT ERROR
|
||||
>> on function: assign()
|
||||
>> runtime/assign_to_read_only_property_with_variable_index.gd
|
||||
>> 8
|
||||
>> Cannot set value into property "center_of_mass" (on base "PhysicsDirectBodyState3DExtension") because it is read-only.
|
||||
Reference in New Issue
Block a user