summaryrefslogtreecommitdiff
path: root/modules/gdscript/tests/scripts/parser/warnings/incompatible_ternary.gd
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/tests/scripts/parser/warnings/incompatible_ternary.gd')
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/incompatible_ternary.gd8
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/parser/warnings/incompatible_ternary.gd b/modules/gdscript/tests/scripts/parser/warnings/incompatible_ternary.gd
new file mode 100644
index 0000000000..a93ecb66b1
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/warnings/incompatible_ternary.gd
@@ -0,0 +1,8 @@
+func test():
+ # The ternary operator below returns values of different types and the
+ # result is assigned to a typed variable. This will cause a run-time error
+ # if the branch with the incompatible type is picked. Here, it won't happen
+ # since the `false` condition never evaluates to `true`. Instead, a warning
+ # will be emitted.
+ var __: int = 25
+ __ = "hello" if false else -2