Merge pull request #71051 from vonagam/consts-are-deep-start

GDScript: Begin making constants deep, not shallow or flat
This commit is contained in:
Rémi Verschelde
2023-01-09 23:22:59 +01:00
committed by GitHub
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'