Bug 121101 - Function parameter can duplicate dimension variable declaration
Summary: Function parameter can duplicate dimension variable declaration
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
6.1.1.2 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-StarBasic
  Show dependency treegraph
 
Reported: 2018-11-01 18:14 UTC by tsultana
Modified: 2020-01-30 12:43 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tsultana 2018-11-01 18:14:26 UTC
Description:
The following code has a parameter declared with the same name of a variable declared with Dim in the function.  The Dim statement resets the variable to its default initialization (e.g. double, variant).  If a second Dim statement is added to declare v again then a compiling error is produced.

Sub test(v As Double)
	Dim v As Double 
	v = 1
End Sub

I believe the correct behavior should be a compiling error that the variable is already declared in the function parameter list so that it cannot be declared with a Dim statement.  This is the same error as if two Dim statements were added to the function.

Steps to Reproduce:
1.Enter subroutine described
2.Enable watch on variable v
3.Monitor value in debug mode and note hat no error occurs

Actual Results:
The variable v is dimensioned replacing the function parameter definition

Expected Results:
A compiling error should have been produced as BASIC syntax error 'Variable is already defined'



Reproducible: Always


User Profile Reset: No



Additional Info:
[Information automatically included from LibreOffice]
Locale: en-US
Module: BasicIDE
[Information guessed from browser]
OS: Linux (All)
OS is 64bit: yes

This has been tested on Win10 LO 6.1.2 and Linux Debian LO 6.1.3.
Version: 6.1.3.1
Build ID: 1:6.1.3~rc1-2
CPU threads: 8; OS: Linux 4.9; UI render: default; VCL: gtk3; 
Locale: en-US (en_US.UTF-8); Calc: group threaded

Version: 6.1.1.2 (x64)
Build ID: 5d19a1bfa650b796764388cd8b33a5af1f5baa1b
CPU threads: 4; OS: Windows 10.0; UI render: default; 
Locale: en-US (en_US); Calc: group threaded
Comment 1 himajin100000 2019-02-11 14:06:44 UTC
possible source code pointer(currently just shadowing the variable?)

https://opengrok.libreoffice.org/xref/core/basic/source/comp/dim.cxx?r=587ac01f#1247