Project

Profile

Help

Bug #3106

closed

Problems applying fold-left() to random-number-generator()

Added by Michael Kay over 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XPath conformance
Sprint/Milestone:
-
Start date:
2017-01-12
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.7
Fix Committed on Branch:
9.7, trunk
Fixed in Maintenance Release:
Platforms:

Description

The query

fold-left(1 to 10, random-number-generator(), function($z, $i){ head($z)('next')(), tail($z), head($z)('number')}) => tail()

ought to give a sequence of random numbers. It is failing in different ways in 9.7 and 9.8.

In 9.7 the final call to tail() returns an empty sequence; the result of fold-left() is a sequence containing a single item, the random-number-generator itself (a HashTrieMap).

In 9.8 the query crashes, saying

java.lang.IllegalStateException: A LazySequence can only be read once

at net.sf.saxon.om.LazySequence.iterate(LazySequence.java:52)

at net.sf.saxon.expr.VariableReference.iterate(VariableReference.java:525)

at net.sf.saxon.expr.TailExpression.iterate(TailExpression.java:135)

Please register to edit this issue

Also available in: Atom PDF