GDScript: Add support for variadic functions

This commit is contained in:
Danil Alexeev
2025-03-30 12:59:05 +03:00
parent 3b963ab8b6
commit ee121ef80e
33 changed files with 416 additions and 65 deletions

View File

@@ -0,0 +1,22 @@
class A:
func f1(x: int, ...args: Array) -> void:
prints(x, args)
func f2(x: int, ...args: Array) -> void:
prints(x, args)
class B extends A:
func f1(x: int, y: int, ...args: Array) -> void:
prints(x, y, args)
func f2(x: int) -> void:
print(x)
func g(...args: int):
pass
func h(...args: Array[int]):
pass
func test():
pass

View File

@@ -0,0 +1,5 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 15: The rest parameter type must be "Array", but "int" is specified.
>> ERROR at line 18: Typed arrays are currently not supported for the rest parameter.
>> ERROR at line 9: The function signature doesn't match the parent. Parent signature is "f1(int, ...) -> void".
>> ERROR at line 12: The function signature doesn't match the parent. Parent signature is "f2(int, ...) -> void".