Issue 84433 - Function return is inconsistent when the value is 'Empty'
Summary: Function return is inconsistent when the value is 'Empty'
Status: ACCEPTED
Alias: None
Product: App Dev
Classification: Unclassified
Component: scripting (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-10 15:20 UTC by silvercapo
Modified: 2017-05-20 11:27 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description silvercapo 2007-12-10 15:20:55 UTC
NOTE: This was observed on the OOo 2.3.1 actual release (Not RC1), but can't yet
select this from this reporting tool.

When a OOoBasic function return is unassigned/uninitialised, IsEmpty on the
return value can still return False. This happens when there is a previous call
to that function that returned an assigned/initialised value.

STEPS TO REPRODUCE THE PROBLEM:
1. Open any OOo application, and create an OOoBasic macro in the Basic IDE as
follows:

Sub Code_Test
	MsgBox(IsEmpty(Bug_Demo(False)))
	MsgBox(IsEmpty(Bug_Demo(True)))
	MsgBox(IsEmpty(Bug_Demo(False)))
End Sub

Function Bug_Demo(bAssignReturnValue As Boolean) As Variant
	If bAssignReturnValue Then
		Bug_Demo = "Assigned a value"
	End If
End Function

2. Run Code_Test: the result is three dialog boxes as follows: "True", "False",
"False". The third MsgBox call is exactly the same as the first, but IsEmpty
evaluates to different values.

3. Furthermore, if you run Code_Test a second time, the result is now: "False",
"False", "False"; giving different results than the first execution, even though
there are no global or static variables defined here.


POSSIBLE WORKAROUND
Seem to be able to work around this if an intermediate variable is introduced in
Bug_Demo as follows:

Function Bug_Demo(bAssignReturnValue As Boolean) As Variant
	Dim vReturnValue As Variant
	If bAssignReturnValue Then
		vReturnValue = "Assigned a value"
	End If
	Bug_Demo = vReturnValue
End Function

vReturnValue is correctly assigned to Empty every time, and thus Bug_Demo always
returns Empty when (bAssignReturnValue = False)


PROPOSED SOLUTION
A function should return Empty everytime if the return value is unassigned.
Comment 1 kay.ramme 2007-12-18 13:48:07 UTC
Seems to be a BASIC thing, reassigned to Andreas.
Comment 2 ab 2007-12-21 12:30:51 UTC
STARTED, OOo 3.x
Comment 3 Marcus 2017-05-20 11:27:48 UTC
Reset assigne to the default "issues@openoffice.apache.org".