Project

Profile

Help

Bug #6082

closed

Saxon 12 XQuery: Issue with compile-time error checking

Added by A Galtman over 1 year ago. Updated 12 months ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2023-06-19
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
12, trunk
Fix Committed on Branch:
12, trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

Description

I'm not sure if the following behavior of Saxon 12.0 through 12.2 is an intended change in behavior or a bug, so I'm reporting it in case it is not intended. (If it is intended, I believe I can work around the behavior change, in my original situation.) Below is a small, self-contained query that illustrates the behavior change.

Query

xquery version "3.1";
let $test-result as item()* := (true(), true())
return
if ($test-result instance of xs:boolean)
then 'Saxon 12 errors out even if we do not get here at run time. ' || boolean($test-result)
else 'Got to else'

Outputs

java -cp "C:\Program Files\Saxonica\SaxonHE11.5J\saxon-he-11.5.jar" net.sf.saxon.Query -q:repro-issue-multiple-boolean.xq
<?xml version="1.0" encoding="UTF-8"?>Got to else

java -cp "C:\Program Files\Saxonica\SaxonHE12.0J\saxon-he-12.0.jar" net.sf.saxon.Query -q:repro-issue-multiple-boolean.xq
<?xml version="1.0" encoding="UTF-8"?>net.sf.saxon.trans.UncheckedXPathException: Effective boolean value is not defined for a sequence of two or more items starting with a boolean
        at net.sf.saxon.expr.Literal$LiteralElaborator.elaborateForBoolean(Literal.java:907)
        at net.sf.saxon.functions.BooleanFn$BooleanFnElaborator.elaborateForBoolean(BooleanFn.java:173)
        at net.sf.saxon.expr.elab.BooleanElaborator.elaborateForPull(BooleanElaborator.java:24)
        at net.sf.saxon.expr.elab.Elaborator.lazily(Elaborator.java:110)
        at net.sf.saxon.expr.FunctionCall$FunctionCallElaborator.allocateArgumentEvaluators(FunctionCall.java:633)
        at net.sf.saxon.expr.FunctionCall$FunctionCallElaborator.setExpression(FunctionCall.java:618)
        at net.sf.saxon.expr.SystemFunctionCall$SystemFunctionCallElaborator.setExpression(SystemFunctionCall.java:587)
        at net.sf.saxon.expr.Expression.makeElaborator(Expression.java:1768)
        at net.sf.saxon.expr.instruct.Choose$ChooseExprElaborator.elaborateForPush(Choose.java:1165)
        at net.sf.saxon.query.XQueryExpression.processQuery(XQueryExpression.java:495)
        at net.sf.saxon.query.XQueryExpression.run(XQueryExpression.java:473)
        at net.sf.saxon.s9api.XQueryEvaluator.run(XQueryEvaluator.java:464)
        at net.sf.saxon.Query.runQuery(Query.java:975)
        at net.sf.saxon.Query.doQuery(Query.java:444)
        at net.sf.saxon.Query.main(Query.java:106)
Caused by: net.sf.saxon.trans.XPathException: Effective boolean value is not defined for a sequence of two or more items starting with a boolean
        at net.sf.saxon.expr.parser.ExpressionTool.ebvError(ExpressionTool.java:767)
        at net.sf.saxon.expr.parser.ExpressionTool.effectiveBooleanValue(ExpressionTool.java:677)
        at net.sf.saxon.value.SequenceExtent$Of.effectiveBooleanValue(SequenceExtent.java:184)
        at net.sf.saxon.expr.Literal$LiteralElaborator.elaborateForBoolean(Literal.java:904)
        ... 14 more
Fatal error during query: net.sf.saxon.trans.UncheckedXPathException: Effective boolean value is not defined for a sequence of two or more items starting with a boolean

Related issues

Is duplicate of Saxon - Bug #6022: Eager evaluation prematurely throws exception in analyze-string/non-matching-string.ClosedMichael Kay2023-05-08

Actions

Please register to edit this issue

Also available in: Atom PDF