bmx-ng / bcc

A next-generation bcc parser for BlitzMax
zlib License
33 stars 12 forks source link

[SCT] Auto array element has no type (function pointer array) #562

Open GWRon opened 3 years ago

GWRon commented 3 years ago

language/framework/fp_arrays_01.bmx:

'
' Test function pointer arrays
'
SuperStrict

Framework brl.standardio

Local t:TType = New TType
t.funcArray = [func1, func2, Null]

Print t.funcArray[0]("1", 1, 1.0)
Print t.funcArray[1]("2", 2, 2.0)

t.update(2, func3)

Print t.funcArray[2]("3", 3, 3.0)

Type TType

    Field funcArray:String(param1:String, param2:Int, param3:Double)[]

    Method update(pos:Int, func_:String(param1:String, param2:Int, param3:Double))
        funcArray[pos] = func_
    End Method

End Type

Function func1:String(param1:String, param2:Int, param3:Double)
    Return "func1 " + param1 + " " + param2 + " " + param3
End Function

Function func2:String(param1:String, param2:Int, param3:Double)
    Return "func2 " + param1 + " " + param2 + " " + param3
End Function

Function func3:String(param1:String, param2:Int, param3:Double)
    Return "func3 " + param1 + " " + param2 + " " + param3
End Function
[ 81%] Processing:fp_arrays_01.bmx
Compile Error: Auto array element has no type
[/tests/framework/language/fp_arrays_01.bmx;9;0]
Build Error: failed to compile (65280) //tests/framework/language/fp_arrays_01.bmx

If you remove the Null from the array:

Compile Error: Expression of type 'String' cannot be invoked.
[/tests/framework/language/fp_arrays_01.bmx;11;0]