#648 Getting first element of sequence behaves inconsistently

eXist-db 1.4.3
closed
None
5
2013-03-31
2010-06-14
rix0rrr
No
0 up votes | 0 down votes | 0%
4 comments

eXist version: Stable 1.4 (Eindhoven)

We were writing a MIN function for arbitrary values, since we need the minimum of a series of dates and the built-in min() function doesn't handle this type. While writing our (recursive) function, we noticed invalid output.

In particular, the value returned by $sequence[1] seem to be inconsistent. However, this situation can be resolved by adding an UNREFERENCED let statement before the expression. See the attached file for an example.

The min1 function assigns the value of $sequence[1] to a variable called $head, although this variable is never referenced. This function produces the right answer.

In the min2 function, the unused assignment is removed. This function produces the answer '2' instead of the correct answer '1'.

Discussion

  • rix0rrr
    rix0rrr
    2010-06-14

    File demonstrating issue

     
    Attachments
  • James Fuller
    James Fuller
    2010-08-13

    I can confirm I get the wrong answer as well

    1 <-- Produces "1" --> 2 <-- Produces "2" -->

    and testing against Zorba they get the right answer ... will investigate

     
  • Dannes Wessels
    Dannes Wessels
    2013-03-31

    query results 1,1 on 2.0/2.1

     
  • Dannes Wessels
    Dannes Wessels
    2013-03-31

    • status: open --> closed
    • assigned_to: Dannes Wessels
    • milestone: --> eXist-db 1.4.3