From 5fc79185943e0d3eeb5645ca6d44457170abe809 Mon Sep 17 00:00:00 2001 From: George Marques Date: Mon, 30 Jan 2023 14:50:08 -0300 Subject: 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. --- .../tests/scripts/analyzer/errors/assign_to_read_only_property.gd | 4 ++++ .../tests/scripts/analyzer/errors/assign_to_read_only_property.out | 2 ++ .../analyzer/errors/assign_to_read_only_property_indirectly.gd | 4 ++++ .../analyzer/errors/assign_to_read_only_property_indirectly.out | 2 ++ 4 files changed, 12 insertions(+) create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.out (limited to 'modules/gdscript/tests/scripts/analyzer') diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.gd b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.gd new file mode 100644 index 0000000000..2b1c4c9594 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.gd @@ -0,0 +1,4 @@ +func test(): + var tree := SceneTree.new() + tree.root = Window.new() + tree.free() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.out b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.out new file mode 100644 index 0000000000..b236d70ec8 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Cannot assign a new value to a read-only property. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.gd b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.gd new file mode 100644 index 0000000000..c97ee0ea69 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.gd @@ -0,0 +1,4 @@ +func test(): + var state := PhysicsDirectBodyState3DExtension.new() + state.center_of_mass.x += 1.0 + state.free() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.out b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.out new file mode 100644 index 0000000000..b236d70ec8 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Cannot assign a new value to a read-only property. -- cgit v1.2.3