The problem concerns any member array passed as an argument to a procedure:
Example for the case (1):
Type UDT
Dim As Integer array(10)
End Type
Sub test(array() As Integer)
Print array(5)
End Sub
Dim As UDT u
u.array(5) = 1234
Dim As Integer array(10)
array(5) = 5678
test(u.array()) '' 1234 : OK
test(u.array(0)) '' 1234 : but should be NOK because Type mismatch
test(u.array(5)) '' 0 : but should be NOK because Type mismatch
test(array()) '' 5678 : OK
'test(array(1)) '' Type mismatch : OK
'test(array(5)) '' Type mismatch : OK
Sleep
Example for the case (2):
sub test(inParam() as sub (byval x as integer))
inParam(0)(3)
end sub
sub thing(byval x as integer)
print x
end sub
type udt
dim arr(10) as sub (byval as integer)
end type
dim udtPtr as udt ptr
udtPtr = new udt
udtPtr->arr(0) = @thing
dim udtInst as udt
udtInst.arr(0) = @thing
'Basic array
dim arr(10) as sub (byval as integer)
arr(0) = @thing
test(arr()) '' 3 : OK
'test(udtInst.arr()) '' NOK : syntax error but should work
'test(udtPtr->arr()) '' NOK : syntax error but should works
test(udtInst.arr(0)) '' 3 : works but should be NOK because type mismatch
test(udtPtr->arr(0)) '' 3 : works but should be NOK because type mismatch
sleep
delete udtPtr
This bug report is issued from forum:
https://www.freebasic.net/forum/viewtopic.php?t=32304
If the member array is static, the wrong syntax is no more allowed:
Last edit: fxm (freebasic.net) 2023-07-14
fixed in fbc 1.20
commit [8ee7cd4e50906b90f9091518d2c29c50dd91d19e]
Related
Commit: [8ee7cd]