Bug 149489 - ReDim on user type dynamic array member causes syntax error
Summary: ReDim on user type dynamic array member causes syntax error
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-08 11:48 UTC by Oguz Meteer
Modified: 2024-06-08 03:15 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oguz Meteer 2022-06-08 11:48:01 UTC
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
Comment 1 Rafael Lima 2022-06-08 13:49:28 UTC
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
Comment 2 Mike Kaganski 2022-06-08 14:18:49 UTC
(In reply to Rafael Lima from comment #1)

I totally agree with your analysis.
Comment 3 QA Administrators 2024-06-08 03:15:35 UTC
Dear Oguz Meteer,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug