Description: Dear devs, Based on the discussion (https://ask.libreoffice.org/t/redim-on-custom-type-containing-dynamic-array/78402/2) I was advised to report the following bug. The folowing code works in Excel VBA: Option VBASupport 1 Type MyTyp a() as String End Type Sub Main Dim typ as New MyTyp ReDim typ.a(0) typ.a(0) = "Hello" Print(typ.a(0)) End Sub But it gives me the following error: "BASIC syntax error. Expected: ,." on the line with the ReDim statement. The following also works in Excel VBA: Option VBASupport 1 Type MyTyp a() as String End Type Sub Main Dim typ as New MyTyp With typ ReDim .a(0) .a(0) = "Hello" End With Print(typ.a(0)) End Sub But this gives me the following error: "BASIC syntax error. Symbol expected." on the line with the ReDim statement. In both cases it should print "Hello". I have not tried this on other versions but I found posts related to this going back to earlier Open Office versions. Steps to Reproduce: 1. Type either of the two snippets in the post in a Libreoffice Calc macro 2. Run the macro. Actual Results: The first macro gives me an error: "BASIC syntax error. Expected: ,." The second macro gives me an error: "BASIC syntax error. Symbol expected." Expected Results: Both should print "Hello" Reproducible: Always User Profile Reset: Yes OpenGL enabled: Yes Additional Info: Version: 7.3.3.2 / LibreOffice Community Build ID: 30(Build:2) CPU threads: 8; OS: Linux 5.18; UI render: default; VCL: gtk3 Locale: en-US (en_US.UTF-8); UI: en-US 7.3.3-3 Calc: threaded
I ran a few tests and there seems to be something wrong here indeed. First of all, I made a few corrections to the first example so it would run in Excel VBA as well. So I used the following code: Option VBASupport 1 Type MyTyp a() As String End Type Sub Main() Dim typ As MyTyp ReDim typ.a(0) typ.a(0) = "Hello" MsgBox typ.a(0) End Sub The code above runs fine in Excel VBA (excluding the 'Option VBASupport 1' line). It prints "Hello" as expected. However in LibreOffice it gives a syntax error, meaning it doesn't compile. It seems LO can't recognize "typ.a" as a symbol. The following code runs fine in LO and MSO: Sub Main2() Dim typ As MyTyp Dim aTemp() As String Redim aTemp(0) As String typ.a = aTemp typ.a(0) = "Hello" MsgBox typ.a(0) End Sub This indicates that there's some problem with syntax check for the ReDim command which does not accept user-defined types as symbols. I'm setting this to NEW. @Mike, maybe you have an opinion about this issue? System info: Version: 7.3.3.2 / LibreOffice Community Build ID: 30(Build:2) CPU threads: 16; OS: Linux 5.13; UI render: default; VCL: kf5 (cairo+xcb) Locale: pt-BR (pt_BR.UTF-8); UI: en-US Ubuntu package version: 1:7.3.3~rc2-0ubuntu0.21.10.1~lo1 Calc: threaded
(In reply to Rafael Lima from comment #1) I totally agree with your analysis.