Bug 85371 - Redim with function name
Summary: Redim with function name
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version: 4.2.6.3 release
Hardware: x86 (IA32) Linux (All)
: medium minor
Assignee: Not Assigned
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-23 15:22 UTC by ge.huber
Modified: 2014-11-16 18:44 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Nothing new here. Textfile with the code from the description. (9.30 KB, application/vnd.oasis.opendocument.text)
2014-10-23 15:22 UTC, ge.huber
Details

Description ge.huber 2014-10-23 15:22:44 UTC
Created attachment 108304 [details]
Nothing new here. Textfile with the code from the description.

Trying to Redim a field inside a function with the function name fails with an "Reading Error. Property is read only"-error. Run this code, to see the error:

Sub Main
Dim FieldOfLongs() As Long
Dim l As Long
l = foo(FieldOfLongs) 
End Sub
 
Function foo(FieldOfLongs() As Long) As Long 
Print "foo ist actually " & foo
Dim Zero As Long
Redim FieldOfLongs(Zero) As Long 'Redim works
Redim FieldOfLongs(foo) As Long 'Redim fails with error
End Function

The expected behaviour is, that the function name should behave just like any other variable within the function. 

Problem arises on 
Lubuntu 14.04
with
Version: 4.2.6.3
Build-ID: 420m0(Build:3)

The error actually says "Lesefehler. Eigenschaft ist schreibgeschützt" in my Germann version of LO.
Comment 1 Beluga 2014-10-24 19:17:50 UTC
I confirm the error.

Version: 4.4.0.0.alpha1+
Build ID: 0a82645c360158f9cc0fdabe2a52f1ff8f981bed
TinderBox: Win-x86@39, Branch:master, Time: 2014-10-24_06:59:23
Comment 2 ge.huber 2014-11-16 18:44:59 UTC
There seem to be more problems with using the function name as a variable inside the function. It can not be used as the loop variable in a For ... Next loop. 
 
Sub Main
Print foob()
Print fool()
End Sub
 
'This surrogate works 
Function foob() As long
foob = 1 
LoopLable:
  Print foob
  foob = foob + 1
If foob < 4 Then Goto LoopLable 
End Function
 
'While the For ... Next doesn't
Function fooc() As long
For fooc = 1 To 3
  Print fooc
Next fooc
End Function


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.