Issue 68059 - Basic Option Compatible + opt args bug
Summary: Basic Option Compatible + opt args bug
Status: ACCEPTED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All Windows XP
: P4 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-02 02:01 UTC by terrye
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 terrye 2006-08-02 02:01:35 UTC
Options Compatible + Optional Arguments still don't work properly.  
(1) ParamArray is Still not supported
(2) IsMissing gets confused if there arePositional Args past the one being
tested  - see attached code fragment. Calls 4 and 5 should give the same answer.

Note that the Compiler barfs at the Function Definition (B=4 clause) if the
option isn't set and CompatibilityMode(True) <or ... False> have no effect, 
which seems the intended functionality.

//Terry

Option Compatible
Sub Main
CompatibilityMode(True)
x = AA() 	       'OK returns 11
x = AA(1)          'OK returns 9
x = AA(A:=1)       'OK returns 9
x = AA(,1)         'OK returns 5
x = AA(B:=1)       'WRONG IsMissing(a) doesn't work.  Returns 2
x = AA(2,1)        'OK returns 4
x = AA(B:=1, A:=2) 'OK returns 4
End Sub

Private Function AA(Optional ByVal A, Optional B=4)
If isMissing(a) Then 
	a = 3
EndIf 
AA = a+2*b
End Function
Comment 1 jsc 2006-08-02 07:50:34 UTC
jsc -> ab: can you please verify this issue
Comment 2 ab 2006-08-25 08:11:09 UTC
Correct, but rather exotic -> STARTED, P4, OOo Later

ab->terrye: Please submit another issue for the ParamArray problem
with an example what's not working. I think it is working. At least the
following sample in a m177 behaves exactly like VB:

option compatible

Sub Main()
    Call test(1, 2, 3)
End Sub

Sub test(a, ParamArray aArr())
    MsgBox a
    MsgBox aArr(0)
    MsgBox aArr(1)
End Sub
Comment 3 terrye 2006-08-25 18:15:06 UTC
Actually the ability to drop earlier parameters is something that people do do
with VBA so it isn't THAT exotic.  People will trip over it when they migrate
code.  If the RTS just barfed then at least it would produce an understandable
failure, but it doesn't -- it gives the wrong answer.  This one will get some
poor VBA migrator cursing because it will be extremely difficult to track down
in migration testing.  My feeling is we could live with it IF we maintained a
central incompatability and know features list that was referenceable from the
main OpenOffice site.

I will look at my test case for the ParamArray and get back to you with an
apology / post a separate issue with test case if necessary.

As part of my VBA / OOo Basic comparison I came up with some other anomolies /
bugs / features by design.  What's the best way to proceed with these? post them
as individual issues or send you a discussion paper for first triage and then
post the ones that merit tracking as separate issues? 
Comment 4 terrye 2006-09-05 02:25:18 UTC
Andreas, ignore the comment about ParamArray -- I didn't have Option Compatible
enabled.  The following gives the same answer for both VBA and OOoBasic if it is
enabled:

Sub Main
  MsgBox a(1, 2, 3, 4, 5)
End Sub
Function a(ParamArray x())
  b = 0
  For i = LBound(x()) To UBound(x())
    b = b + x(i)
  Next i
  a = b
End Function
Comment 5 Marcus 2017-05-20 11:27:32 UTC
Reset assigne to the default "issues@openoffice.apache.org".