From 5e2ac1a31ee34842438a3a76c54f6a15df77bb95 Mon Sep 17 00:00:00 2001 From: Dmitrii Maganov Date: Sun, 8 Jan 2023 05:41:06 +0200 Subject: GDScript: Begin making constants deep, not shallow or flat --- .../tests/scripts/analyzer/errors/constant_array_index_assign.gd | 5 +++++ .../tests/scripts/analyzer/errors/constant_array_index_assign.out | 2 ++ .../scripts/analyzer/errors/constant_dictionary_index_assign.gd | 5 +++++ .../scripts/analyzer/errors/constant_dictionary_index_assign.out | 2 ++ 4 files changed, 14 insertions(+) create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.out (limited to 'modules/gdscript/tests/scripts/analyzer/errors') diff --git a/modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.gd b/modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.gd new file mode 100644 index 0000000000..b8603dd4ca --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.gd @@ -0,0 +1,5 @@ +const array: Array = [0] + +func test(): + var key: int = 0 + array[key] = 0 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.out b/modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.out new file mode 100644 index 0000000000..5275183da2 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Cannot assign a new value to a constant. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.gd b/modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.gd new file mode 100644 index 0000000000..9b5112b788 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.gd @@ -0,0 +1,5 @@ +const dictionary := {} + +func test(): + var key: int = 0 + dictionary[key] = 0 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.out b/modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.out new file mode 100644 index 0000000000..5275183da2 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Cannot assign a new value to a constant. -- cgit v1.2.3