Bug 123263 - Array with an element type should not be assignable to a variable of Array with another element type
Summary: Array with an element type should not be assignable to a variable of Array wi...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-StarBasic
  Show dependency treegraph
 
Reported: 2019-02-08 11:46 UTC by himajin100000
Modified: 2023-09-18 03:06 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
document to be used in STR (8.67 KB, application/vnd.oasis.opendocument.spreadsheet)
2019-02-08 11:52 UTC, himajin100000
Details

Note You need to log in before you can comment on or make changes to this bug.
Description himajin100000 2019-02-08 11:46:52 UTC
Description:
see steps to reproduce

Steps to Reproduce:
1. Open the attached ods file(typetest.ods)
2. Tools->Macros->Organize Macros->LibreOfficeDev Basic
3. Select Main() macro in typetest.ods/Standard/Module/Module1
4. Click "Edit"

5. You will find Main subroutine as given below.
------------------
REM  *****  BASIC  *****
Option Explicit

Sub Main()
	Dim a(1) As String
	Dim b(1) As Integer
	b = a
End Sub
----------------
6. put a breakpoint to "End Sub" line
7. Enter "b" to the "Watch:", and press Enter
8. press F5
9. check the type of the variable b

Actual Results:
No Error, but...

Type of the variable b is String(0 to 1), which contradicts the variable declaration.

Expected Results:
Either of 
1. No Error, but b should be of type Integer(0 to 1)
2. Conversion Error


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 6.3.0.0.alpha0+ (x64)
Build ID: 82fb7f9f90a3ba9d53b3412124e513aa78ddca10
CPU threads: 4; OS: Windows 10.0; UI render: default; VCL: win; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2019-02-05_23:41:03
Locale: ja-JP (ja_JP); UI-Language: en-US
Calc: threaded
Comment 1 himajin100000 2019-02-08 11:52:07 UTC
Created attachment 149023 [details]
document to be used in STR
Comment 2 Oliver Brinzing 2019-02-08 12:34:44 UTC
reproducible, assignment b=a changes vartype to String
Comment 3 himajin100000 2019-02-11 14:42:08 UTC
I did some tests on Excel VBA. And I was so surprised at how I was misunderstanding Excel VBA. (please note that the post to LibreOffice Dev ML has been done before these tests. Also note that VB.NET MAY WORK IN DIFFERENT WAY)

’---Excel VBA---
Option Explicit

Sub Main()
Dim a(1) As Integer
Dim b() As Integer
b = a
End Sub
’----------------
=> No Error

’---Excel VBA---
Sub Main()
Dim a(1) As Integer
Dim b(1) As Integer
b = a
End Sub
’----------------
=> Error

’---Excel VBA---
Sub Main()
Dim a() As Integer
Dim b() As Integer
b = a
End Sub
’----------------
=> No Error

’---Excel VBA---
Sub Main()
Dim a() As Integer
Dim b As Variant
b = a
End Sub
’------------------
=> No Error

’---Excel VBA---
Sub Main()
Dim a() As Integer
Hoge (a)
End Sub

Function Hoge(x() As Integer) As String
    Hoge = "abc"
End Function
’------------------
=> Error

’---Excel VBA---
Sub Main()
Dim a() As Integer
Hoge (a)
End Sub

Function Hoge(x As Variant) As String
    Hoge = "abc"
End Function
’------------------
=> No Error

’---Excel VBA---
Sub Main()
Dim a() As Integer
Dim b As Integer
Dim c As Variant
c = a
c = b
End Sub
’------------------
=> No Error
Comment 4 himajin100000 2019-02-11 14:50:13 UTC
’---Excel VBA---
Sub Main()
    Dim a() As Integer
    Hoge (a)
End Sub

Function Hoge(x As Variant) As String
    Dim b() As Integer
    b = x
    Hoge = "abc"
End Function
’------------------
=> No Error

’---Excel VBA---
Sub Main()
    Dim a() As Integer
    Hoge (a)
End Sub

Function Hoge(x As Variant) As String
    Dim b() As String
    b = x
    Hoge = "abc"
End Function
’------------------
=> Error

Function parameter's one was compile error
Comment 5 himajin100000 2019-02-11 14:51:24 UTC
typo:
>Function parameter's one was compile error
Error in 'Function Hoge(x() As Integer) As String' case was a compile error
Comment 6 himajin100000 2019-02-11 15:20:16 UTC
Sub hoge()
    Dim a(2) As Integer
    Dim b() As Integer
    a(0) = 1
    a(1) = 2
    b = a
    a(0) = 3
    MsgBox (b(0))
End Sub
-------------
StarBasic => 3
Excel VBA => 1
Comment 7 himajin100000 2019-02-11 16:22:41 UTC
FYI:
'-----StarBasic-----
Sub Main()
Dim a(1) As Integer
Dim b() As Integer
a(0) = 1
a(1) = 2
b = a
Redim Preserve b(2) As Integer
a(0) = 5
Msgbox(b(0)) 
End Sub
'-----------------------
=>1
Comment 8 QA Administrators 2021-09-17 03:51:02 UTC Comment hidden (obsolete)
Comment 9 QA Administrators 2023-09-18 03:06:01 UTC
Dear himajin100000,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug