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:
I believe you, so I set to NEW
Code pointer for the implementation: https://opengrok.libreoffice.org/xref/core/basic/source/comp/exprtree.cxx?r=a5c1a645#919 Code pointer for the tests: https://opengrok.libreoffice.org/xref/core/basic/qa/vba_tests/optional_paramters.vb?r=66b135fa
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.