Bug 44385 - BASIC: Incorrect type returned for date math
Summary: BASIC: Incorrect type returned for date math
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
3.4.4 release
Hardware: Other All
: medium normal
Assignee: Noel Power
URL:
Whiteboard: BSA
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-02 07:24 UTC by Andrew Pitonyak
Modified: 2012-01-12 07:52 UTC (History)
1 user (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 Andrew Pitonyak 2012-01-02 07:24:20 UTC
Problem description: 
DateValue(Now + 2) fails in a macro because "Now + 2" returns as a double rather than as a date. The same is true for "Now - 2".

This bug was introduced by Noel Power 06-Dec-2010 with commit 1421b098ae19a10acb4836fa3752188cf7c52eb2 (thank you Regina for looking that up for me, I do not know how to check that)

The problem is found in file:
core/basic/source/sbx/sbxvalue.cxx 

There is a switch statement around line 1312. Following the switch statement, there used to be the following code:

 // #45465 Date braucht bei + eine Spezial-Behandlung
if( eOp == SbxPLUS && (GetType() == SbxDATE || rOp.GetType() == SbxDATE ) )
  aL.eType = SbxDATE; 

I am not an expert on these things, but, it looks like the checks to see if either operand is a date, and, if so, sets the type to be date. This was done after PLUS, EXP, MUL, DIV, MINUS, and NEG. 

That line was removed and added after PLUS as a comment, so, I assume that NOEL was unsure why it was required. Still waiting on input from NOEL.

I speculate that this was done as part of clean-up because this check was performed every time. Off hand, I can not think of why you might do this for anything other than PLUS or MINUS, but, this breaks existing macros. so I would call this a regression bug.

I reproduced this on a Fedora Linux system (64-bit), but, I expect this to affect all platforms.
Comment 1 Noel Power 2012-01-12 07:52:25 UTC
reassign to me, also mark as fixed on master

http://cgit.freedesktop.org/libreoffice/core/commit/?id=9df90559d40f029479c4481e31f88737b70742f6