Bug 129596 - Typename function does not return the correct data type of a numeric constant
Summary: Typename function does not return the correct data type of a numeric constant
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:6.5.0
Keywords:
Depends on:
Blocks: Macro-StarBasic
  Show dependency treegraph
 
Reported: 2019-12-24 09:26 UTC by Andreas Heinisch
Modified: 2020-03-12 09:05 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Heinisch 2019-12-24 09:26:32 UTC
Description:
 

Steps to Reproduce:
The following snippet shows the error in detail:

Sub Main

dim intDecimal as integer
intDecimal = 32767 
dim intHexDecimal as integer
intHexDecimal = &h7FFF

dim lngDecimal as long
lngDecimal = 1048575
dim lngHexDecimal as long
lngHexDecimal = &hFFFFF

' outputs 32767 32767 1048575 1048575
Print intDecimal, intHexDecimal, lngDecimal, lngHexDecimal

' outputs Integer Integer Long Long
Print Typename(intDecimal), Typename(intHexDecimal), Typename(lngDecimal), Typename(lngHexDecimal) 

' outputs Integer Integer Doube Double
Print Typename(32767), Typename(&h7FFF), Typename(1048575), Typename(&hFFFFF)

End Sub

Actual Results:
 

Expected Results:
 


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 Andreas Heinisch 2019-12-24 09:29:15 UTC
' outputs Integer Integer Doube Double
Print Typename(32767), Typename(&h7FFF), Typename(1048575), Typename(&hFFFFF)

The output of the above line should be Integer Integer Long Long. The code lies in:

SbiRuntime::StepLOADNC 
https://opengrok.libreoffice.org/xref/core/basic/source/runtime/runtime.cxx?r=62f3f3d9#2774
Comment 2 Andreas Heinisch 2019-12-24 09:33:18 UTC
Version: 6.5.0.0.alpha0+ (x64)
Build ID: aeab5bfa024f7d15099730fa536d78b5a7a7ea01
CPU threads: 6; OS: Windows 10.0 Build 17134; UI render: GL; VCL: win; 
Locale: de-DE (de_DE); UI-Language: en-US
Calc: CL
Comment 3 Oliver Brinzing 2019-12-24 11:37:47 UTC
already reproducibel with AOO 4.1.5
Comment 4 Commit Notification 2020-01-05 20:43:09 UTC
U-DESKTOP-8OSNV7R\DrRobotto committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/0b4f8bf571baf2ccd5a8aafdc4deb41867420be3

tdf#129596 Distinguish between integer and long while loading immediate values

It will be available in 6.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Mike Kaganski 2020-02-05 09:21:37 UTC
By the way:

> print TypeName(&h00ff&)

must give Long.
Comment 6 Mike Kaganski 2020-02-05 09:37:20 UTC
FTR: the data type characters are mentioned under corresponding subsections (for Currency, Double, Integer, Long, LongLong, Single, String, and Variant (the latter mentioning there's no such character)) under https://docs.microsoft.com/en-us/office/vba/Language/Reference/User-Interface-Help/data-type-summary

Likely a separate bug report needed.