summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/tests/scripts
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2024-04-09 15:49:44 -0300
committerGeorge Marques <george@gmarqu.es>2024-04-10 11:49:30 -0300
commit4bdba718c5fcb2bd58827b8ede3ea7d0c4251fbd (patch)
tree3e305305c2b3506d486322a4521ff3dd7943348d /modules/gdscript/tests/scripts
parenta7b860250f305f6cbaf61c30f232ff3bbdfdda0b (diff)
downloadredot-engine-4bdba718c5fcb2bd58827b8ede3ea7d0c4251fbd.tar.gz
GDScript: Infer type with string format operator
If the left value type is known to be String, assume the format operator (`%`) will return a string, since it works with any type in the right hand side. This is also used by type inference even if the right hand type is unknown at compile time.
Diffstat (limited to 'modules/gdscript/tests/scripts')
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.gd6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.out2
2 files changed, 8 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.gd b/modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.gd
new file mode 100644
index 0000000000..c83a3a8a14
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.gd
@@ -0,0 +1,6 @@
+# GH-88082
+
+func test():
+ var x = 1
+ var message := "value: %s" % x
+ print(message)
diff --git a/modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.out b/modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.out
new file mode 100644
index 0000000000..cf6464a4c3
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+value: 1