https://bugs.documentfoundation.org/show_bug.cgi?id=159455
Bug ID: 159455
Summary: Declared default for optional argument ignored when
later argument specified by name.
Product: LibreOffice
Version: 7.6.4.1 release
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: BASIC
Assignee: [email protected]
Reporter: [email protected]
Description:
When I declare a default value for an Optional argument, but specify a later
argument by name, the previous argument does not receive the specified default
value. It looks as though it receives instead the default value for variables
of the specified type.
This seems in obvious conflict with this statement in the help:
= expression: Specify a default value for the argument, matching its
declared type. Optional is necessary for each argument specifying a default
value.
It seems pretty embarrassing, as fixing this could break existing macros.At a
minimum, if it cannot be fixed cleanly, the Help quoted above should accurately
describe the actual behaviour.
In the following code, the first argument receives the value False although the
default was declared to be True:
I believe I have seen this in a number of versions, but currently I am seeing
it in the version given under Other Information.
Steps to Reproduce:
1. Run the following code
Option Explicit
Option Compatible
' Demonstrate a bug in assigning values to optional parameters:
' When an optional parameter is specified by name,
' preceding unspecified optional parameters do not honour default values
specified in the declaration.
Sub Bug_Default_Ignored ()
Bug_Default_Ignored_Sub (B := True)
End Sub
' Demonstrate a bug in assigning values to optional parameters, as above
Sub Bug_Default_Ignored_Sub _
( Optional A as Boolean = True _
, Optional B as Boolean = False _
)
MsgBox ("A = " + A + ", B = " + B)
End Sub
Actual Results:
Message saying
A = False, B = True
Expected Results:
Message saying
A = True, B = True
Reproducible: Always
User Profile Reset: No
Additional Info:
Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1
CPU threads: 8; OS: Linux 5.3; UI render: default; VCL: kf5 (cairo+xcb)
Locale: en-GB (en_GB.UTF-8); UI: en-GB
Calc: threaded
--
You are receiving this mail because:
You are the assignee for the bug.