Stack overflow in HOF query

Bug #1187887 reported by Cezar Andrei
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Invalid
Critical
Nicolae Brinza

Bug Description

In zorba-2.9 execute:

declare function local:f($x as xs:integer)
{
  $x+1
};

declare function local:for-each($seq, $f) {
  if (fn:empty($seq))
  then ()
  else $f(fn:head($seq)), local:for-each(fn:tail($seq), $f)
};

local:for-each( (1,2,3), fn:function-lookup(xs:QName('local:f'), 1) )

Result:
(no URI):9,27: Zorba error [zerr:ZXQP0003]: internal error: stack overflow

Changed in zorba:
importance: Undecided → Critical
Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote :

Nicolai implemented teh HOF functions used in this example so I reassigned the bug to him.

Changed in zorba:
assignee: Sorin Marian Nasoi (sorin.marian.nasoi) → Nicolae Brinza (nbrinza)
Revision history for this message
Nicolae Brinza (nbrinza) wrote :

It's not a bug, Zorba behaves correctly, it should really do a stack overflow with this query.

To get the desired behavior and get rid of the of the overflow, the line

    else $f(fn:head($seq)), local:for-each(fn:tail($seq), $f)

should be changed to:

    else ($f(fn:head($seq)), local:for-each(fn:tail($seq), $f))

Changed in zorba:
status: New → Invalid
Revision history for this message
Cezar Andrei (cezar-andrei) wrote :

The code is copied from the 21 May 2013 Candidate Recommendation:
http://www.w3.org/TR/xpath-functions-30/#func-for-each

Maybe Gishlain should take a look at it.

Revision history for this message
Nicolae Brinza (nbrinza) wrote :

I've opened this W3C bug for the F&O spec -- https://www.w3.org/Bugs/Public/show_bug.cgi?id=22302

Revision history for this message
Nicolae Brinza (nbrinza) wrote :

Michael Kay fixed the code snippet -- https://www.w3.org/Bugs/Public/show_bug.cgi?id=22302#c1 . I assume it didn't get into the Working draft yet.

--

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.