diff options
author | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-03-18 14:42:42 +0100 |
---|---|---|
committer | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-05-01 12:28:47 +0200 |
commit | c4e24d2b3bcfefc8cd4a3ec0d44802a24ef7ef79 (patch) | |
tree | 1847142a6225dfc1fdce90d7f14fa490374034b5 /core/variant/variant.cpp | |
parent | 26738ea20dc5d80be0eba6bb83af73fb996759d6 (diff) | |
download | redot-engine-c4e24d2b3bcfefc8cd4a3ec0d44802a24ef7ef79.tar.gz |
[GDScript] Correctly report invalid read-only access
Diffstat (limited to 'core/variant/variant.cpp')
-rw-r--r-- | core/variant/variant.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index fcbfdd4741..37eb16f9b2 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -3515,6 +3515,17 @@ bool Variant::is_shared() const { return is_type_shared(type); } +bool Variant::is_read_only() const { + switch (type) { + case ARRAY: + return reinterpret_cast<const Array *>(_data._mem)->is_read_only(); + case DICTIONARY: + return reinterpret_cast<const Dictionary *>(_data._mem)->is_read_only(); + default: + return false; + } +} + void Variant::_variant_call_error(const String &p_method, Callable::CallError &error) { switch (error.error) { case Callable::CallError::CALL_ERROR_INVALID_ARGUMENT: { |