A UDT does not work correctly with a dynamic 'String * N' array as field.
This works with a dynamic 'Zstring * N' array as field.
This obviously works with a static 'String * N' array as field.
Precise bug
When called, the implicit let-operator (and the implicit copy-constructor) of the UDT crashes.
No more problem when an explicit let-operator is properly defined by the user (with this explicit let-operator, the copy-construction works too).
I think this bug dates back to support for dynamic arrays in UDTs (fbc 1.00.0).
Examples
- Example with the implicit let-operator => crashing :
Code: Select all
Type UDT
Dim As String * 1 array(Any)
End Type
Dim As UDT u1
Redim u1.array(3)
u1.array(0) = "a"
u1.array(1) = "b"
u1.array(2) = "c"
u1.array(3) = "d"
For I As Integer = Lbound(u1.array) To Ubound(u1.array)
Print "'" & u1.array(I) & "'",
Next I
Print
Dim As UDT u2
u2 = u1
For I As Integer = Lbound(u2.array) To Ubound(u2.array)
Print "'" & u2.array(I) & "'",
Next I
Print
Sleep
Code: Select all
Type UDT
Dim As String * 1 array(Any)
Declare Operator Let(Byref u As UDT)
End Type
Operator UDT.Let(Byref u As UDT)
If Ubound(u.array) >= Lbound(u.array) Then
Redim This.array(Lbound(u.array) To Ubound(u.array))
For I As Integer = Lbound(u.array) To Ubound(u.array)
This.array(I) = u.array(I)
Next I
Else
Erase This.array
End If
End operator
Dim As UDT u1
Redim u1.array(3)
u1.array(0) = "a"
u1.array(1) = "b"
u1.array(2) = "c"
u1.array(3) = "d"
For I As Integer = Lbound(u1.array) To Ubound(u1.array)
Print "'" & u1.array(I) & "'",
Next I
Print
Dim As UDT u2
u2 = u1
For I As Integer = Lbound(u2.array) To Ubound(u2.array)
Print "'" & u2.array(I) & "'",
Next I
Print
Sleep