GDScript: Fix test for read-only state of constants
This commit is contained in:
parent
d1e5903c67
commit
abe6d67232
14 changed files with 43 additions and 52 deletions
|
|
@ -879,7 +879,7 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
|
|||
|
||||
current_enum = prev_enum;
|
||||
|
||||
dictionary.set_read_only(true);
|
||||
dictionary.make_read_only();
|
||||
member.m_enum->set_datatype(enum_type);
|
||||
member.m_enum->dictionary = dictionary;
|
||||
|
||||
|
|
@ -3892,7 +3892,7 @@ void GDScriptAnalyzer::const_fold_array(GDScriptParser::ArrayNode *p_array, bool
|
|||
array[i] = p_array->elements[i]->reduced_value;
|
||||
}
|
||||
if (p_is_const) {
|
||||
array.set_read_only(true);
|
||||
array.make_read_only();
|
||||
}
|
||||
p_array->is_constant = true;
|
||||
p_array->reduced_value = array;
|
||||
|
|
@ -3919,7 +3919,7 @@ void GDScriptAnalyzer::const_fold_dictionary(GDScriptParser::DictionaryNode *p_d
|
|||
dict[element.key->reduced_value] = element.value->reduced_value;
|
||||
}
|
||||
if (p_is_const) {
|
||||
dict.set_read_only(true);
|
||||
dict.make_read_only();
|
||||
}
|
||||
p_dictionary->is_constant = true;
|
||||
p_dictionary->reduced_value = dict;
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
const array: Array = [0]
|
||||
|
||||
func test():
|
||||
array.push_back(0)
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
GDTEST_RUNTIME_ERROR
|
||||
>> ERROR
|
||||
>> on function: push_back()
|
||||
>> core/variant/array.cpp
|
||||
>> 253
|
||||
>> Condition "_p->read_only" is true.
|
||||
>> Array is in read-only state.
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
const dictionary := {}
|
||||
|
||||
func test():
|
||||
dictionary.erase(0)
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
GDTEST_RUNTIME_ERROR
|
||||
>> ERROR
|
||||
>> on function: erase()
|
||||
>> core/variant/dictionary.cpp
|
||||
>> 177
|
||||
>> Condition "_p->read_only" is true. Returning: false
|
||||
>> Dictionary is in read-only state.
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
const array: Array = [0]
|
||||
const dictionary := {1: 2}
|
||||
|
||||
@warning_ignore("assert_always_true")
|
||||
func test():
|
||||
assert(array.is_read_only() == true)
|
||||
assert(str(array) == '[0]')
|
||||
assert(dictionary.is_read_only() == true)
|
||||
assert(str(dictionary) == '{ 1: 2 }')
|
||||
print('ok')
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_OK
|
||||
ok
|
||||
Loading…
Add table
Add a link
Reference in a new issue