Bug 144353 - Assigning a missing optional variable to a property does not trigger "argument is not optional"
Summary: Assigning a missing optional variable to a property does not trigger "argumen...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:7.3.0 target:7.4.0 target:7.3.1
Keywords: haveBacktrace
Depends on:
Blocks:
 
Reported: 2021-09-07 10:03 UTC by Mike Kaganski
Modified: 2022-10-13 10:02 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
A sample with a macro setting object's layer using missing argument value (8.96 KB, application/vnd.oasis.opendocument.graphics)
2021-09-07 10:03 UTC, Mike Kaganski
Details
bt with debug symbols (15.92 KB, text/plain)
2021-09-07 19:55 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2021-09-07 10:03:33 UTC
Created attachment 174851 [details]
A sample with a macro setting object's layer using missing argument value

Open attachment; run "Main" macro in it.

The macro code is:

Sub SetOptionalLayer(Optional i)
  d = thisComponent
  p = d.DrawPages(0)
  s = p(0)
  s.LayerID = i
End Sub

Sub Main
  SetOptionalLayer
End Sub

The expected result is an error "argument is not optional" at line "s.LayerID = i", while the actual result is "IllegalArgumentException", which shows that the value is passed to UNO, and the wrong value is only caught there.
Comment 1 Andreas Heinisch 2021-09-07 19:34:36 UTC
Repo with:
Version: 7.3.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: 769ed9edaf5e61c6c151cf4ec5bbe25e70e0438c
CPU threads: 6; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-US
Calc: CL

Imho there should be an error on the following situation, too:

Sub Test(Optional i)
  MsgBox i + 10
End Sub

Sub Main()
  Test
End Sub

The actual result atm is the error code 448 + 10 = 458
Comment 2 Andreas Heinisch 2021-09-07 19:41:34 UTC
Repro also in:
Version: 6.4.7.2 (x64)
Build ID: 639b8ac485750d5696d7590a72ef1b496725cfb5
CPU threads: 6; OS: Windows 10.0 Build 19042; UI render: default; VCL: win; 
Locale: de-DE (de_DE); UI-Language: en-US
Calc: CL
Comment 3 Julien Nabet 2021-09-07 19:55:15 UTC
Created attachment 174868 [details]
bt with debug symbols

On pc Debian x86-64 with master sources update today, I got an assertion.

I must recognize I don't understand where does the 448 value comes from.
Comment 4 Andreas Heinisch 2021-09-07 20:00:22 UTC
It will be set in:
https://opengrok.libreoffice.org/xref/core/basic/source/runtime/runtime.cxx?r=2bc1a043#4148 (// like in VB: Error-Code 448 (ERRCODE_BASIC_NAMED_NOT_FOUND)
Comment 5 Julien Nabet 2021-09-07 20:06:13 UTC
Thank you Andreas for the very quick feedback!
And this pb will be fixed with https://gerrit.libreoffice.org/c/core/+/121760
Comment 6 Andreas Heinisch 2021-09-07 20:29:59 UTC
At least assigning a missing optional variable to a property may be fixed in:
https://gerrit.libreoffice.org/c/core/+/121794

However, the issue with comment #1 is still not addressed. Should we allow to do some calculations, if an argument is missing?
Comment 7 Commit Notification 2021-09-10 11:29:00 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

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

tdf#144353 - Handling of missing optional parameters

It will be available in 7.3.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 8 Commit Notification 2021-12-27 19:50:05 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

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

tdf#144353, tdf#146281 - Correctly copy the information about variables

It will be available in 7.4.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 9 Commit Notification 2022-02-10 08:21:00 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/1a343e3168c6ac8acf3279307275727e588ddcb7

tdf#144353, tdf#146281 - Correctly copy the information about variables

It will be available in 7.3.1.

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.