diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-28 15:40:19 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-28 15:40:19 +0100 |
commit | cc6e8379d48442c9886520813bee573c43733979 (patch) | |
tree | 8229a0ee91a15229140ec88399a440a074bfb38d /modules/gdscript/tests/scripts/analyzer | |
parent | 2afa175195d0fc885badb60441bef1b31e5e6d05 (diff) | |
parent | ef81b344be72346dcdc11ebbde575dbc965bd732 (diff) |
Merge pull request #69163 from vonagam/variant-safe-lines
GDScript: Fix wrong marking of some lines related to Variant as unsafe
Diffstat (limited to 'modules/gdscript/tests/scripts/analyzer')
-rw-r--r-- | modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd | 32 | ||||
-rw-r--r-- | modules/gdscript/tests/scripts/analyzer/features/hard_variants.out | 5 |
2 files changed, 37 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd b/modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd new file mode 100644 index 0000000000..211115d9cb --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/hard_variants.gd @@ -0,0 +1,32 @@ +func variant() -> Variant: return null + +var member_weak = variant() +var member_typed: Variant = variant() +var member_inferred := variant() + +func param_weak(param = variant()) -> void: print(param) +func param_typed(param: Variant = variant()) -> void: print(param) +func param_inferred(param := variant()) -> void: print(param) + +func return_untyped(): return variant() +func return_typed() -> Variant: return variant() + +@warning_ignore(unused_variable) +func test() -> void: + var weak = variant() + var typed: Variant = variant() + var inferred := variant() + + weak = variant() + typed = variant() + inferred = variant() + + param_weak(typed) + param_typed(typed) + param_inferred(typed) + + if typed == null: pass + if typed != null: pass + if typed is Node: pass + + print('ok') diff --git a/modules/gdscript/tests/scripts/analyzer/features/hard_variants.out b/modules/gdscript/tests/scripts/analyzer/features/hard_variants.out new file mode 100644 index 0000000000..08491efa07 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/hard_variants.out @@ -0,0 +1,5 @@ +GDTEST_OK +<null> +<null> +<null> +ok |