1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-23 15:16:17 +00:00

GDScript: Begin making constants deep, not shallow or flat

This commit is contained in:
Dmitrii Maganov
2023-01-08 05:41:06 +02:00
parent fcba87e696
commit 5e2ac1a31e
16 changed files with 82 additions and 36 deletions

View File

@@ -0,0 +1,6 @@
const array: Array = [{}]
func test():
var dictionary := array[0]
var key: int = 0
dictionary[key] = 0

View File

@@ -0,0 +1,6 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR
>> on function: test()
>> runtime/errors/constant_array_is_deep.gd
>> 6
>> Invalid set index '0' (on base: 'Dictionary') with value of type 'int'

View File

@@ -0,0 +1,4 @@
const array: Array = [0]
func test():
array.push_back(0)

View File

@@ -0,0 +1,7 @@
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.

View File

@@ -0,0 +1,4 @@
const dictionary := {}
func test():
dictionary.erase(0)

View File

@@ -0,0 +1,7 @@
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.

View File

@@ -0,0 +1,6 @@
const dictionary := {0: [0]}
func test():
var array := dictionary[0]
var key: int = 0
array[key] = 0

View File

@@ -0,0 +1,6 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR
>> on function: test()
>> runtime/errors/constant_dictionary_is_deep.gd
>> 6
>> Invalid set index '0' (on base: 'Array') with value of type 'int'