[GDScript] Correctly report invalid read-only access
This commit is contained in:
parent
26738ea20d
commit
c4e24d2b3b
6 changed files with 64 additions and 36 deletions
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -349,6 +349,7 @@ public:
|
|||
bool is_zero() const;
|
||||
bool is_one() const;
|
||||
bool is_null() const;
|
||||
bool is_read_only() const;
|
||||
|
||||
// Make sure Variant is not implicitly cast when accessing it with bracket notation (GH-49469).
|
||||
Variant &operator[](const Variant &p_key) = delete;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue