-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GDScript: Fix access non-static members in static context #91412
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
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()". |
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 |
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()". |
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()". |
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()". |
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()". |
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 |
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. |
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 |
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()". |
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()". |
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") |
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. |
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 | ||
Comment on lines
+74
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fixes memory leaks in CI. I'm not sure if this is a bug, but it's probably unrelated to the changes since I've noticed this problem before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a reference cycle. Lambda contains a reference to |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
GDTEST_OK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an "unrelated" change, but I guess it makes sense? At least the tests did not detect regressions, but this is not always a reliable criterion.