Issue 69930 - Functions allowed as LVALUES in Basic
Summary: Functions allowed as LVALUES in Basic
Status: ACCEPTED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P4 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-28 08:35 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-09-28 08:35:00 UTC
In OO Basic functions are tolerated as Lvalues (This is not the case in VBA).  

Sub main()
  b = 1
  MsgBox b
End Sub
Function b()
  b = 3
End Function

This prints out 3.  This is particularly dangerous where programmers are NOT
using "Option Explicit" and have the routine in a separate module, so they think
that they are using an implicitly declared local variable.

OOB should throw up a compile error if functions are used as LVALUES as does VBA.
Comment 1 ab 2006-10-05 09:59:06 UTC
Started, OOo 2.x
Comment 2 terrye 2006-12-19 23:10:40 UTC
Having had a look at the compiler output, the code generator generate the same
code for:
  a(i) = a (i) + 1
that is:
  ARGC
  FIND  i;Variant
  ARGV
  FIND  a
  ARGC
  FIND  i;Variant
  ARGV
  FIND  a
  CONST 1
  PLUS	
  PUT
whether a is an array or a function.  This discrimination is carried out by the
RTS in StepFIND.  Not sure how to pick this one up in the current split of
compiler/RTS.  

Suggest that this is introduced as Documentation caveat.  
Comment 3 terrye 2007-01-15 09:28:24 UTC
Andreas, I've checked the source. SbiRuntime::StepSTMNT even contains an
explicit check and tolerates this one.  Given that OOo Basic architecturally
tolerates a function call in the context of a subroutine call, and the compiler
as currently constructed defers the issue of binding a(i,j) to a function or an
external public variable at runtime, you can't error on this one.

My recommendation is to move this one to documentation and include an
appropriate note in the next StarBasic Manual.   
Comment 4 terrye 2007-01-15 09:28:48 UTC
Andreas, I've checked the source. SbiRuntime::StepSTMNT even contains an
explicit check and tolerates this one.  Given that OOo Basic architecturally
tolerates a function call in the context of a subroutine call, and the compiler
as currently constructed defers the issue of binding a(i,j) to a function or an
external public variable at runtime, you can't error on this one.

My recommendation is to move this one to documentation and include an
appropriate note in the next StarBasic Manual.   
Comment 5 Martin Hollmichel 2007-11-09 17:28:37 UTC
set target from 2.x to 3.x according to
http://wiki.services.openoffice.org/wiki/Target_3x
Comment 6 Unknown 2010-11-12 10:24:35 UTC
Created attachment 74696
Comment 7 ab 2011-01-19 10:19:34 UTC
I don't consider this to be worth much effort
-> P4, OOo Later
Comment 8 Marcus 2017-05-20 11:27:48 UTC
Reset assigne to the default "issues@openoffice.apache.org".