-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81332 from dalexeev/gds-fix-update-array-literal-…
…in-weak-context GDScript: Don't make array literal typed in weak type context
- Loading branch information
Showing
3 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...ipt/tests/scripts/analyzer/features/typed_array_dont_make_literal_typed_with_weak_type.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
var _typed_array: Array[int] | ||
|
||
func weak_param_func(weak_param = _typed_array): | ||
weak_param = [11] # Don't treat the literal as typed! | ||
return weak_param | ||
|
||
func hard_param_func(hard_param := _typed_array): | ||
hard_param = [12] | ||
return hard_param | ||
|
||
func test(): | ||
var weak_var = _typed_array | ||
print(weak_var.is_typed()) | ||
weak_var = [21] # Don't treat the literal as typed! | ||
print(weak_var.is_typed()) | ||
print(weak_param_func().is_typed()) | ||
|
||
var hard_var := _typed_array | ||
print(hard_var.is_typed()) | ||
hard_var = [22] | ||
print(hard_var.is_typed()) | ||
print(hard_param_func().is_typed()) |
7 changes: 7 additions & 0 deletions
7
...pt/tests/scripts/analyzer/features/typed_array_dont_make_literal_typed_with_weak_type.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
GDTEST_OK | ||
true | ||
false | ||
false | ||
true | ||
true | ||
true |