summaryrefslogtreecommitdiff
path: root/modules/gdscript/tests/scripts/parser/features
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2021-09-15 09:56:24 -0300
committerGeorge Marques <george@gmarqu.es>2021-09-15 09:56:24 -0300
commit5d31ce4b161553e85bbd8397f2ce62cbd213095f (patch)
tree8c9e186efdd9667bf3c223b29b73dddeca3036f8 /modules/gdscript/tests/scripts/parser/features
parent32f8f74d8345049e41d1abb7239fcee40ecb2c53 (diff)
GDScript: Allow string keys on Lua-style dictionaries
Which is useful when the key isn't a valid identifier, such as keys with spaces or numeric keys.
Diffstat (limited to 'modules/gdscript/tests/scripts/parser/features')
-rw-r--r--modules/gdscript/tests/scripts/parser/features/dictionary_lua_style.gd9
-rw-r--r--modules/gdscript/tests/scripts/parser/features/dictionary_lua_style.out2
2 files changed, 11 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/parser/features/dictionary_lua_style.gd b/modules/gdscript/tests/scripts/parser/features/dictionary_lua_style.gd
new file mode 100644
index 0000000000..fdd6de2348
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/features/dictionary_lua_style.gd
@@ -0,0 +1,9 @@
+func test():
+ var lua_dict = {
+ a = 1,
+ "b" = 2, # Using strings are allowed too.
+ "with spaces" = 3, # Especially useful when key has spaces...
+ "2" = 4, # ... or invalid identifiers.
+ }
+
+ print(lua_dict)
diff --git a/modules/gdscript/tests/scripts/parser/features/dictionary_lua_style.out b/modules/gdscript/tests/scripts/parser/features/dictionary_lua_style.out
new file mode 100644
index 0000000000..447d7e223c
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/features/dictionary_lua_style.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+{2:4, a:1, b:2, with spaces:3}