Project

Profile

Help

Bug #4653

fn:fold-left with inline function in SaxonJS.XPath.evaluate

Added by Debbie Lockett about 1 year ago. Updated 6 months ago.

Status:
Duplicate
Priority:
Normal
Category:
-
Sprint/Milestone:
-
Start date:
2020-07-24
Due date:
% Done:

0%

Estimated time:
Applies to JS Branch:
2
Fix Committed on JS Branch:
2
Fixed in JS Release:
SEF Generated with:
Company:
-
Contact person:
-
Additional contact persons:
-

Description

As raised by Martin Honnen on the forum (https://saxonica.plan.io/boards/5/topics/7958), there is an issue running SaxonJS.XPath.evaluate on an expression which calls fold-left. For example:

SaxonJS.XPath.evaluate(`  fold-left(
    1 to 10,
    0,
    function($sum, $number) {
      $sum + $number
    }
  )`)

Results in "TypeError: this.closureContext.localVars.slice is not a function" on Node.js, and "Uncaught TypeError: this.fl.Ha.slice is not a function" in the browser.

The bug has been reproduced running Saxon-JS 2.0. Actually the problem does not arise when running against the current development builds, so it looks like other development work has already fixed the issue, but opening this bug to log properly.


Related issues

Is duplicate of Saxon-JS - Bug #4611: XPath expression "function(){'x'}()" crashes with TypeError: this.closureContext.localVars.slice is not a functionClosed2020-06-25

<a title="Actions" class="icon-only icon-actions js-contextmenu" href="#">Actions</a>

History

#1 Updated by Debbie Lockett about 1 year ago

I've added test 'xp-032' to the SaxonJS2-API-tests Mocha test suite, which runs the QT3 test case fold-left-001 expression 'fold-left(1 to 5, 0, function($a, $b) { $a + $b })' in SaxonJS.XPath.evaluate().

Running with SaxonJS2.debug.js produces a more informative stack trace:

TypeError: this.closureContext.localVars.slice is not a function
    at $$InlineFunction$$$$evaluate$ [as evaluate] (SaxonJS2N.debug.js:3914:70)
    at $$CoercedFunction$$$$evaluate$ [as evaluate] (SaxonJS2N.debug.js:3952:30)
    at SaxonJS2N.debug.js:9729:29
    at Array.forEach (<anonymous>)
    at $foldFn$$ (SaxonJS2N.debug.js:9728:28)
    at fold-left (SaxonJS2N.debug.js:10075:12)
    at SaxonJS2N.debug.js:12672:14
    at Object.$$evaluate$$$ [as evaluate] (SaxonJS2N.debug.js:13566:33)
    at Object.evaluate (SaxonJS2N.debug.js:21687:47)
    at Context.<anonymous> (test/SaxonJS2-API-tests.js:1934:31)
    at processImmediate (internal/timers.js:439:21)

Perhaps there have been development changes relating to CoercedFunction or InlineFunction since the 2.0 release...?

#2 Updated by Debbie Lockett 10 months ago

  • Status changed from New to In Progress

#4 Updated by Debbie Lockett 10 months ago

  • Status changed from In Progress to Duplicate
  • Fix Committed on JS Branch 2.0 added

The problem is the same as Bug #4611: XPath expression "function(){'x'}()" crashes with TypeError: this.closureContext.localVars.slice is not a function. So it is the fix for that bug which means that test 'xp-032' in SaxonJS2-API-tests now passes on the trunk branch.

#5 Updated by Debbie Lockett 10 months ago

  • Related to Bug #4611: XPath expression "function(){'x'}()" crashes with TypeError: this.closureContext.localVars.slice is not a function added

#6 Updated by Debbie Lockett 10 months ago

  • Related to deleted (Bug #4611: XPath expression "function(){'x'}()" crashes with TypeError: this.closureContext.localVars.slice is not a function)

#7 Updated by Debbie Lockett 10 months ago

  • Is duplicate of Bug #4611: XPath expression "function(){'x'}()" crashes with TypeError: this.closureContext.localVars.slice is not a function added

#8 Updated by Community Admin 6 months ago

  • Applies to JS Branch 2 added
  • Applies to JS Branch deleted (2.0)

#9 Updated by Community Admin 6 months ago

  • Fix Committed on JS Branch 2 added
  • Fix Committed on JS Branch deleted (2.0)

Please register to edit this issue

Also available in: Atom PDF Tracking page