Bug 143706 - Missing Optional argument is not properly missing, when ':=' syntax is used
Summary: Missing Optional argument is not properly missing, when ':=' syntax is used
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
4.0.0.3 release
Hardware: All All
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:26.8.0
Keywords:
: 159455 (view as bug list)
Depends on:
Blocks: Macro-StarBasic
  Show dependency treegraph
 
Reported: 2021-08-03 14:55 UTC by Mike Kaganski
Modified: 2026-05-15 11: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 Mike Kaganski 2021-08-03 14:55:11 UTC
Consider this BASIC code:

  ' No Option VBASupport

  Sub Foo(Optional x As Double, Optional y As Double)
    MsgBox ismissing(x) & " " & ismissing(y)
  End Sub

  Sub Bar
    Foo(y:=10)
  End Sub

It produces "False False", instead of expected "True False"; and inspecting value of x inside Foo gives 0.

In non-VBASupport mode, we should not initialize missing optional arguments; the problem looks specific to the := argument value syntax, and e.g.

  Foo(, 10)

produces expected "True False".

Tested with Version: 7.2.0.2 (x64) / LibreOffice Community
Build ID: 614be4f5c67816389257027dc5e56c801a547089
CPU threads: 12; OS: Windows 10.0 Build 19043; UI render: Skia/Raster; VCL: win
Locale: ru-RU (ru_RU); UI: en-US
Calc: threaded
Comment 1 Vladimir Sokolinskiy 2021-08-03 16:35:11 UTC
Reproduced.

Version: 7.1.4.2 / LibreOffice Community
Build ID: 10(Build:2)
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Ubuntu package version: 1:7.1.4~rc2-0ubuntu0.20.04.1~lo1
Calc: threaded
Comment 2 Andreas Heinisch 2021-09-13 17:29:43 UTC
Already in Version 4.0.0.1 (Build ID: 527dba6f6e0cfbbc71bd6e7b88a52699bb48799)

Not so easy to solve on my side.

  Sub Foo(Optional x As Double, Optional y As Double)
    MsgBox ismissing(x) & " " & ismissing(y)
  End Sub

The parser initializes the variable x as double and sets it as optional.

  Sub Bar
    Foo(y:=10)
  End Sub

Here it initializes the variable y to integer with a the value 10.

However, it does not generate a StepEMPTY for StepPARAM since there is no COMMA token for the function Foo. Maybe there could be some logic scanning the parameter list for function Foo and the actual call of the function in [1]. Then, there could be an additional StepEMPTY for the parameter x in this case. Maybe there is another approach, but currently, I could not find any satisfying solution for me.

[1] https://opengrok.libreoffice.org/xref/core/basic/source/comp/exprtree.cxx?r=a5c1a645#955
Comment 3 Andreas Heinisch 2026-05-11 15:07:29 UTC
*** Bug 159455 has been marked as a duplicate of this bug. ***
Comment 4 Commit Notification 2026-05-12 20:41:04 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/d6954bfec1d874b6f6af3b0c868b99dbd5cfeb44

tdf#143706 - Mark skipped named optional parameters as missing/empty

It will be available in 26.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Patrick Traill 2026-05-13 16:35:55 UTC
I have verified that the code in my original report of bug 159455 now behaves correctly
on my system:

Operating System: openSUSE Leap 16.0
KDE Plasma Version: 6.4.2
KDE Frameworks Version: 6.16.0
Qt Version: 6.9.1
Kernel Version: 6.12.0-160000.29-default (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-4702MQ CPU @ 2.20GHz
Memory: 12 GiB of RAM (11.6 GiB usable)
Graphics Processor: Intel® HD Graphics 4600
Manufacturer: Acer
Product Name: Aspire V3-772G
System Version: V1.15

Version tested:
https://dev-builds.libreoffice.org/daily/master/Linux-rpm_deb-x86_64@tb99-TDF/2026-05-13_04.58.13/LibreOfficeDev_26.8.0.0.alpha0_Linux_x86-64_rpm.tar.gz