Created attachment 100121 [details] Writer doc with additional code examples, analysis and screen shots Problem description: ==================== Passing an error object to a function causes a run time error. Any reference within the function to the argument containing an error object such as “CVErr(2)“, causes the run time error: “BASIC runtime error. Argument is not optional.” How to reproduce the problem: ============================= 1. In a LibreOffice document with Macros, open Tools --> Macros --> Organize Macros --> pick any module to edit 2. Type (or cut/paste) the following code in to the “Module” of your choice. (Module1 will do) ------------------------- Sub TestCVErr Dim vErr Dim nValue as Integer Dim ss vErr = CVErr(2) nValue = vErr ss = "" ss = ss & "VarType, TypeName, and nValue = " & VarType(vErr) ss = ss & ", " & TypeName(vErr)& ", " & nValue Print ss Print fnGetErrNum(vErr) 'This causes failure End Sub Function fnGetErrNum(vErr) Dim nValue as Integer nValue = vErr fnGetErrNum() = nValue End Function ----------------------------------- 3. Run TestCVErr 4. The program stops with a run time error ( “BASIC runtime error. Argument is not optional.”) in the function 5. Replace the last line in TestCVErr() with the following, passing the integer nValue rather than the error object: ------------------------------------ Print fnGetErrNum(nValue) 'This works ------------------------------------ 6. Run TestCVErr and the function returns the number correctly. Current behavior: =================== If the argument being passed to the function contains an error object, any reference to it will cause a run time error. The same code that works in the main routine will fail if placed within a function referencing the vErr as an argument. The same behavior was observed in both a Linux (fc20) and a Windows (Win7/64-Bit) environment. Expected behavior: =================== The function should return an integer value of 2; this should be the same behavior as the code in the main routine “nValue = vErr” which casts the error object into an integer value. Operating System: All Version: 4.2.3.3 release
Verified: ubuntu 14.10 x64 LibreOffice 4.4.1.2 rc Marking as: New Minor - workaround exists, does not prevent high quality work. If there is no workaround then I suppose "normal" would be the appropriate - not major. low - incredibly low chance of this affecting many users at all. Nearly a year later, no dupes, no additional comments, etc... CC'ing Noel to get his opinion.
** Please read this message in its entirety before responding ** To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year. There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present. If you have time, please do the following: Test to see if the bug is still present on a currently supported version of LibreOffice (5.0.5 or 5.1.2 https://www.libreoffice.org/download/ If the bug is present, please leave a comment that includes the version of LibreOffice and your operating system, and any changes you see in the bug behavior If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a short comment that includes your version of LibreOffice and Operating System Please DO NOT - Update the version field - Reply via email (please reply directly on the bug tracker) - Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not appropriate in this case) If you want to do more to help you can test to see if your issue is a REGRESSION. To do so: 1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) http://downloadarchive.documentfoundation.org/libreoffice/old/ 2. Test your bug 3. Leave a comment with your results. 4a. If the bug was present with 3.3 - set version to "inherited from OOo"; 4b. If the bug was not present in 3.3 - add "regression" to keyword Feel free to come ask questions or to say hello in our QA chat: http://webchat.freenode.net/?channels=libreoffice-qa Thank you for your help! -- The LibreOffice QA Team This NEW Message was generated on: 2016-04-16
** Please read this message in its entirety before responding ** To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year. There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present. If you have time, please do the following: Test to see if the bug is still present on a currently supported version of LibreOffice (5.2.7 or 5.3.3 https://www.libreoffice.org/download/ If the bug is present, please leave a comment that includes the version of LibreOffice and your operating system, and any changes you see in the bug behavior If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a short comment that includes your version of LibreOffice and Operating System Please DO NOT Update the version field Reply via email (please reply directly on the bug tracker) Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not appropriate in this case) If you want to do more to help you can test to see if your issue is a REGRESSION. To do so: 1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) http://downloadarchive.documentfoundation.org/libreoffice/old/ 2. Test your bug 3. Leave a comment with your results. 4a. If the bug was present with 3.3 - set version to "inherited from OOo"; 4b. If the bug was not present in 3.3 - add "regression" to keyword Feel free to come ask questions or to say hello in our QA chat: http://webchat.freenode.net/?channels=libreoffice-qa Thank you for helping us make LibreOffice even better for everyone! Warm Regards, QA Team MassPing-UntouchedBug-20170522
Still repro with file Version: 6.4.0.0.alpha0+ (x86) Build ID: c738be4de6886a0c96b7d10df7e78c8b2964c135 CPU threads: 4; OS: Windows 10.0; UI render: default; VCL: win; Locale: fi-FI (fi_FI); UI-Language: en-US Calc: threaded
https://opengrok.libreoffice.org/xref/core/basic/source/runtime/runtime.cxx?r=889dc7bf#4026
The problem lies in the following line of https://opengrok.libreoffice.org/xref/core/basic/source/runtime/runtime.cxx?r=efa9ea10#4060, since the variable is initialized as an error type, LO tries to search for an optional value. However, the variable has no error in it, i.e., pVar->GetError() is equal to ERRCODE_NONE. if( pVar->GetType() == SbxERROR && nIdx ) So, we should only search for optionals, if the variable has not been found (ERRCODE_BASIC_NAMED_NOT_FOUND).
Andreas Heinisch committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/84b884135ee419fe7abfefa7b4b651a649cf9ad9 tdf#79426, tdf#125180 - Don't convert missing parameters to requested type It will be available in 7.0.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.