Bug 131818 - BASIC: Declaring an array parameter as optional should not be possible with option VBASupport
Summary: BASIC: Declaring an array parameter as optional should not be possible with o...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard: reviewed:2024
Keywords: easyHack
Depends on:
Blocks: Macro-VBA
  Show dependency treegraph
 
Reported: 2020-04-02 09:40 UTC by Andreas Heinisch
Modified: 2024-01-31 19:44 UTC (History)
4 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 Andreas Heinisch 2020-04-02 09:40:50 UTC
Description:
In LO BasicBasic with option Compatible/VBASupport it is possible to declare an array parameter as optional:

Function TestOptArray(Optional A() As Integer, Optional B() As Variant)

However, in MSO it is not possible to declare an array parameter as optional. The above code snippet leads to a syntax error in MSO, whereas the following works:

Function TestOptArray(A() As Integer, B() As Variant)

At least with option VBASupport LO should throw a syntax error.


Actual Results:
 

Expected Results:
 


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 Buovjaga 2020-06-20 13:59:25 UTC
I believe you, so I set to NEW
Comment 3 Hossein 2024-01-07 16:39:35 UTC
Re-evaluating the EasyHack in 2024

This minor issue is still relevant, as the problem is still there.

If you run this code snippet in LibreOffice BASIC editor, you will see: "No error" message box, which should not happen. A syntax error is expected.

Option VBASupport 1

Sub Macro1()
    Dim A() As Integer
    Dim b() As Variant
    TestOptArray A, b
End Sub

Function TestOptArray(Optional A() As Integer, Optional B() As Variant)
    MsgBox "No error"
End Sub

If you run the code (without VBASupport) in MS Office VBA IDE, you will get a syntax error. If you remove "Optional" keywords, it works just fine, and "No error" message box will be shown.