GDScript: Fix access non-static members in static context

This commit is contained in:
Danil Alexeev
2024-05-01 16:49:12 +03:00
parent 26738ea20d
commit 8122a27eac
18 changed files with 182 additions and 13 deletions
@@ -0,0 +1,10 @@
# GH-91403
static func static_func():
print(non_static_func)
func non_static_func():
pass
func test():
pass
@@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot access non-static function "non_static_func" from the static function "static_func()".
@@ -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
@@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot access non-static function "non_static_func" from the static function "static_func()".
@@ -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()".
@@ -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()".
@@ -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()".
@@ -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
@@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot access non-static function "non_static_func" from a static variable initializer.
@@ -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
@@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot access non-static function "non_static_func" from the static function "@static_var_setter()".
@@ -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()".
@@ -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")
@@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot access non-static function "non_static" from a static variable initializer.