diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-03-04 13:32:47 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-03-04 13:32:47 +0100 |
commit | b392ab5ff4ecaf8834ce22801ac8856b2e5f8293 (patch) | |
tree | 016f4bf858e9eaeb3793e633536964751ba8d212 /modules/gdscript/tests/scripts/parser | |
parent | 8eb08522b3a1826f78f5d732fc10421d61f7ed27 (diff) | |
parent | 24181d10552e3bedca05f1f0a470eb29a2d93975 (diff) | |
download | redot-engine-b392ab5ff4ecaf8834ce22801ac8856b2e5f8293.tar.gz |
Merge pull request #85918 from 20kdc/tnj-static-called-on-instance-fix-confusion
GDScript: Adjust `STATIC_CALLED_ON_INSTANCE` warning to not force native type
Diffstat (limited to 'modules/gdscript/tests/scripts/parser')
-rw-r--r-- | modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.gd | 28 | ||||
-rw-r--r-- | modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out | 10 |
2 files changed, 29 insertions, 9 deletions
diff --git a/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.gd b/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.gd index 29d8501b78..193faab5d0 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.gd +++ b/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.gd @@ -1,11 +1,23 @@ -class Player: - var x = 3 +class_name TestStaticCalledOnInstance + +class Inner: + static func static_func(): + pass + +static func static_func(): + pass func test(): - # These should not emit a warning. - var _player = Player.new() - print(String.num_uint64(8589934592)) # 2 ^ 33 + print(String.num_uint64(8589934592)) + var some_string := String() + print(some_string.num_uint64(8589934592)) # Warning. + + TestStaticCalledOnInstance.static_func() + static_func() + self.static_func() + var other := TestStaticCalledOnInstance.new() + other.static_func() # Warning. - # This should emit a warning. - var some_string = String() - print(some_string.num_uint64(8589934592)) # 2 ^ 33 + Inner.static_func() + var inner := Inner.new() + inner.static_func() # Warning. diff --git a/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out b/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out index 77994ce9ba..c00f3d093a 100644 --- a/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out +++ b/modules/gdscript/tests/scripts/parser/warnings/static_called_on_instance.out @@ -1,7 +1,15 @@ GDTEST_OK >> WARNING ->> Line: 11 +>> Line: 13 >> STATIC_CALLED_ON_INSTANCE >> The function "num_uint64()" is a static function but was called from an instance. Instead, it should be directly called from the type: "String.num_uint64()". +>> WARNING +>> Line: 19 +>> STATIC_CALLED_ON_INSTANCE +>> The function "static_func()" is a static function but was called from an instance. Instead, it should be directly called from the type: "TestStaticCalledOnInstance.static_func()". +>> WARNING +>> Line: 23 +>> STATIC_CALLED_ON_INSTANCE +>> The function "static_func()" is a static function but was called from an instance. Instead, it should be directly called from the type: "Inner.static_func()". 8589934592 8589934592 |