From b924ada2ecb793422d3c7655cbf257583de53aa7 Mon Sep 17 00:00:00 2001 From: Arctis-Fireblight <6182060+Arctis-Fireblight@users.noreply.github.com> Date: Sun, 27 Sep 2026 12:25:52 -0500 Subject: [PATCH 1/3] Add support for GDScript trait typing in arrays, dictionaries, and export properties - Extend GDScript and runtime type system to allow trait-typed arrays and dictionaries. - Introduce `is_trait` and `has_trait` methods in `ScriptLanguage` for trait validation. - Update property hints and runtime checks to handle traits as valid types. - Add tests for trait-typed exports and runtime validations, including serialization and deserialization. - Ensure compatibility with existing scripts and improve error messaging for unsupported types. --- core/object/script_language.h | 4 + core/variant/array.cpp | 5 +- core/variant/container_type_validate.h | 6 +- core/variant/variant_parser.cpp | 17 ++++- editor/editor_node.cpp | 3 + .../editor_properties_array_dict.cpp | 19 +++++ modules/gdscript/gdscript.h | 3 +- modules/gdscript/gdscript_analyzer.cpp | 58 ++++++++------ modules/gdscript/gdscript_compiler.cpp | 2 + modules/gdscript/gdscript_function.cpp | 6 +- modules/gdscript/gdscript_parser.cpp | 8 ++ .../tests/gdscript_test_runner_suite.h | 75 +++++++++++++++++++ .../trait_exported_array_scene.notest.gd | 11 +++ .../features/trait_runtime_type_checks.gd | 7 ++ 14 files changed, 189 insertions(+), 35 deletions(-) create mode 100644 modules/gdscript/tests/scripts/Traits/analyzer/features/trait_exported_array_scene.notest.gd diff --git a/core/object/script_language.h b/core/object/script_language.h index 40159eb8fe8..66a5422879b 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -170,6 +170,10 @@ class Script : public Resource { virtual Ref