Apache OpenOffice (AOO) Bugzilla – Issue 69930
Functions allowed as LVALUES in Basic
Last modified: 2017-05-20 11:27:48 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.
Started, OOo 2.x
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.
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.
set target from 2.x to 3.x according to http://wiki.services.openoffice.org/wiki/Target_3x
Created attachment 74696
I don't consider this to be worth much effort -> P4, OOo Later
Reset assigne to the default "issues@openoffice.apache.org".