-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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 #91412 from dalexeev/gds-fix-non-static-access-in-…
…static-context GDScript: Fix access non-static members in static context
- Loading branch information
Showing
18 changed files
with
182 additions
and
13 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
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
10 changes: 10 additions & 0 deletions
10
modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static.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,10 @@ | ||
# GH-91403 | ||
|
||
static func static_func(): | ||
print(non_static_func) | ||
|
||
func non_static_func(): | ||
pass | ||
|
||
func test(): | ||
pass |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static.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,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot access non-static function "non_static_func" from the static function "static_func()". |
15 changes: 15 additions & 0 deletions
15
...s/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static_in_lambda_param.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,15 @@ | ||
# GH-91403 | ||
|
||
func non_static_func(): | ||
pass | ||
|
||
static func static_func( | ||
f := func (): | ||
var g := func (): | ||
print(non_static_func) | ||
g.call() | ||
): | ||
f.call() | ||
|
||
func test(): | ||
pass |
2 changes: 2 additions & 0 deletions
2
.../gdscript/tests/scripts/analyzer/errors/static_func_access_non_static_in_lambda_param.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,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot access non-static function "non_static_func" from the static function "static_func()". |
2 changes: 1 addition & 1 deletion
2
modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static.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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot call non-static function "non_static_func()" from static function "static_func()". | ||
Cannot call non-static function "non_static_func()" from the static function "static_func()". |
2 changes: 1 addition & 1 deletion
2
modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda.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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot call non-static function "non_static_func()" from static function "static_func()". | ||
Cannot call non-static function "non_static_func()" from the static function "static_func()". |
2 changes: 1 addition & 1 deletion
2
...es/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda_param.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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot call non-static function "non_static_func()" from static function "static_func()". | ||
Cannot call non-static function "non_static_func()" from the static function "static_func()". |
14 changes: 14 additions & 0 deletions
14
...les/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda.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,14 @@ | ||
# GH-91403 | ||
|
||
func non_static_func(): | ||
pass | ||
|
||
static var static_var = func (): | ||
var f := func (): | ||
var g := func (): | ||
print(non_static_func) | ||
g.call() | ||
f.call() | ||
|
||
func test(): | ||
pass |
2 changes: 2 additions & 0 deletions
2
...es/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda.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,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot access non-static function "non_static_func" from a static variable initializer. |
15 changes: 15 additions & 0 deletions
15
...cript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda_setter.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,15 @@ | ||
# GH-91403 | ||
|
||
func non_static_func(): | ||
pass | ||
|
||
static var static_var: | ||
set(_value): | ||
var f := func (): | ||
var g := func (): | ||
print(non_static_func) | ||
g.call() | ||
f.call() | ||
|
||
func test(): | ||
pass |
2 changes: 2 additions & 0 deletions
2
...ript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda_setter.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,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot access non-static function "non_static_func" from the static function "@static_var_setter()". |
2 changes: 1 addition & 1 deletion
2
...script/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda_setter.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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot call non-static function "non_static_func()" from static function "@static_var_setter()". | ||
Cannot call non-static function "non_static_func()" from the static function "@static_var_setter()". |
11 changes: 11 additions & 0 deletions
11
modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_access.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,11 @@ | ||
# GH-91403 | ||
|
||
@static_unload | ||
|
||
func non_static(): | ||
return "non static" | ||
|
||
static var static_var = Callable(non_static) | ||
|
||
func test(): | ||
print("does not run") |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_access.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,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot access non-static function "non_static" from a static variable initializer. |
75 changes: 75 additions & 0 deletions
75
modules/gdscript/tests/scripts/analyzer/features/static_non_static_access.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,75 @@ | ||
@static_unload | ||
|
||
static var static_var | ||
var non_static_var | ||
|
||
signal my_signal() | ||
|
||
static func static_func(): | ||
pass | ||
|
||
func non_static_func(): | ||
pass | ||
|
||
static var test_static_var_lambda = func (): | ||
static_func() | ||
print(static_func) | ||
static_var = 1 | ||
print(static_var) | ||
|
||
var test_non_static_var_lambda = func (): | ||
static_func() | ||
print(static_func) | ||
static_var = 1 | ||
print(static_var) | ||
|
||
non_static_func() | ||
print(non_static_func) | ||
non_static_var = 1 | ||
print(non_static_var) | ||
my_signal.emit() | ||
print(my_signal) | ||
|
||
static var test_static_var_setter: | ||
set(_value): | ||
static_func() | ||
print(static_func) | ||
static_var = 1 | ||
print(static_var) | ||
|
||
var test_non_static_var_setter: | ||
set(_value): | ||
static_func() | ||
print(static_func) | ||
static_var = 1 | ||
print(static_var) | ||
|
||
non_static_func() | ||
print(non_static_func) | ||
non_static_var = 1 | ||
print(non_static_var) | ||
my_signal.emit() | ||
print(my_signal) | ||
|
||
static func test_static_func(): | ||
static_func() | ||
print(static_func) | ||
static_var = 1 | ||
print(static_var) | ||
|
||
func test_non_static_func(): | ||
static_func() | ||
print(static_func) | ||
static_var = 1 | ||
print(static_var) | ||
|
||
non_static_func() | ||
print(non_static_func) | ||
non_static_var = 1 | ||
print(non_static_var) | ||
my_signal.emit() | ||
print(my_signal) | ||
|
||
func test(): | ||
test_static_var_lambda = null | ||
test_non_static_var_lambda = null |
1 change: 1 addition & 0 deletions
1
modules/gdscript/tests/scripts/analyzer/features/static_non_static_access.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 @@ | ||
GDTEST_OK |