Bug 142180 - Invalid text comparison result in Basic
Summary: Invalid text comparison result in Basic
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: Joshua Williams
URL:
Whiteboard: target:7.2.0 target:7.1.5
Keywords: difficultyBeginner, easyHack, skillCpp, topicDebug
Depends on:
Blocks:
 
Reported: 2021-05-09 11:33 UTC by Vladimir Sokolinskiy
Modified: 2021-05-24 12:53 UTC (History)
5 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 Vladimir Sokolinskiy 2021-05-09 11:33:56 UTC
Description:
The text comparison result (for example, "A" and "Z") in Basic is incorrect. 

Steps to Reproduce:
Run Basic script

Sub TestCompare
   Print Cbool("A"<"Z")
End Sub


Actual Results:
False

Expected Results:
True


Reproducible: Always


User Profile Reset: Yes



Additional Info:
Version: 7.1.3.2 (x64) / LibreOffice Community
Build ID: 47f78053abe362b9384784d31a6e56f8511eb1c1
CPU threads: 6; OS: Windows 10.0 Build 19042; UI render: Skia/Vulkan; VCL: win
Locale: ru-RU (ru_RU); UI: ru-RU
Calc: threaded
Comment 1 Mike Kaganski 2021-05-09 15:47:36 UTC
Also repro with OOo 3.2.0.

Additional observations:

  msgbox TypeName("A"<"Z")
  msgbox "A"<"Z"
  A = "A"
  Z = "Z"
  msgbox TypeName(A < Z)
  msgbox A < Z

gives:

  Integer
  0
  Boolean
  True

So it's a matter of handling literals.

Code pointer: SbiExprNode::FoldConstantsBinaryNode in basic/source/comp/exprnode.cxx.
Comment 2 Joshua Williams 2021-05-21 22:25:25 UTC
Hoping to get this done within a week or so. Looks like some operators were switched in the code. I already have the fix made, but this is my first contribution, so I just have to figure out how to correctly submit the change.
Comment 3 Joshua Williams 2021-05-21 22:26:02 UTC
PS, thanks for the code pointer Mike. That made it easy.
Comment 4 Joshua Williams 2021-05-22 00:45:33 UTC
Should be fixed by commit 115983 (https://gerrit.libreoffice.org/c/core/+/115983)
Comment 5 Commit Notification 2021-05-23 05:15:22 UTC
Joshua Williams committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/6cdfd89413eab85dba7b975199358cb8fae44661

tdf#142180 Swapped comparison operators for static strings

It will be available in 7.2.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 6 Commit Notification 2021-05-24 10:09:57 UTC
Joshua Williams committed a patch related to this issue.
It has been pushed to "libreoffice-7-1":

https://git.libreoffice.org/core/commit/073a78b8c4080e6fc9e4e61a614616edcb4153dc

tdf#142180 Swapped comparison operators for static strings

It will be available in 7.1.5.

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 7 Vladimir Sokolinskiy 2021-05-24 12:53:47 UTC
Joshua, Mike, thanks a lot!