Project

Profile

Help

Bug #4508

closed

ClassCastException on Saxon 10

Added by Gunther Rademacher almost 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Internals
Sprint/Milestone:
-
Start date:
2020-03-30
Due date:
% Done:

100%

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

Description

On Saxon 10, this throws a ClassCastException:

declare variable $rows := (
  <row>a</row>,
  <row>b</row>
);
declare function local:f()
{
  let $row := $rows[2]
  return 'exists' [$row]
};
local:f()

The stacktrace is

java.lang.ClassCastException: net.sf.saxon.tree.tiny.TinyElementImpl cannot be cast to net.sf.saxon.value.NumericValue
        at net.sf.saxon.expr.SubscriptExpression.evaluateItem(SubscriptExpression.java:151)
        at net.sf.saxon.expr.Expression.process(Expression.java:940)
        at net.sf.saxon.expr.instruct.UserFunction.process(UserFunction.java:665)
        at net.sf.saxon.expr.UserFunctionCall.process(UserFunctionCall.java:601)
        at net.sf.saxon.query.XQueryExpression.run(XQueryExpression.java:453)
        at net.sf.saxon.s9api.XQueryEvaluator.run(XQueryEvaluator.java:369)
        at net.sf.saxon.Query.runQuery(Query.java:895)
        at net.sf.saxon.Query.doQuery(Query.java:423)
        at net.sf.saxon.Query.main(Query.java:97)

Related issues

Has duplicate Saxon - Bug #5590: ClassCastException (variable declaration with context item reference)DuplicateMichael Kay2022-07-05

Actions
Actions #1

Updated by Michael Kay almost 4 years ago

  • Category set to Internals
  • Status changed from New to In Progress
  • Assignee set to Michael Kay
  • Priority changed from Low to Normal

The compiler turns a filter expression xx[$rows] into a SubscriptExpression if the type analysis indicates that $rows is a singleton numeric and has no focus dependency. This test appears to be performed incorrectly. The type analysis gives the type correctly (element(row)) but the test whether this is numeric is incorrect. Surprising that this should get through all our tests, but it's probably a bit unusual to supply a focus-independent node expression as a filter condition.

Actions #2

Updated by Michael Kay almost 4 years ago

  • Status changed from In Progress to Resolved
  • Fix Committed on Branch 10 added
Actions #3

Updated by O'Neil Delpratt almost 4 years ago

  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 10.1 added

Bug fix committed in the Saxon 10.1 maintenance release.

Actions #4

Updated by O'Neil Delpratt almost 4 years ago

  • Status changed from Resolved to Closed
Actions #5

Updated by Michael Kay over 1 year ago

  • Has duplicate Bug #5590: ClassCastException (variable declaration with context item reference) added

Please register to edit this issue

Also available in: Atom PDF