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
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
The variable v is dimensioned replacing the function parameter definition
A compiling error should have been produced as BASIC syntax error 'Variable is already defined'
User Profile Reset: No
[Information automatically included from LibreOffice]
[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.
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: 18.104.22.168 (x64)
Build ID: 5d19a1bfa650b796764388cd8b33a5af1f5baa1b
CPU threads: 4; OS: Windows 10.0; UI render: default;
Locale: en-US (en_US); Calc: group threaded
possible source code pointer(currently just shadowing the variable?)
Fixed in https://git.libreoffice.org/core/+/bcfe36586c6bd07cef3c2ba39abd38bc9b6ab097