Project

Profile

Help

Bug #4820

Expression `[1,2,3] castable as xs:integer` returns true

Added by Michael Kay 16 days ago. Updated 7 days ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
XPath conformance
Sprint/Milestone:
-
Start date:
2020-11-10
Due date:
% Done:

0%

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

Description

Raised by Ghislain Fourny on xquery-talk list.

Test case CastableAs664 added to QT3.

History

#1 Updated by Michael Kay 16 days ago

CastableExpression.typeCheck() has the logic

                if (converter.isAlwaysSuccessful() && !allowsEmpty() && operand.getCardinality() == StaticProperty.ALLOWS_ONE) {
                    return Literal.makeLiteral(BooleanValue.TRUE, this);
                }

This wrongly assumes that if the value of the operand is a singleton, then its atomized value will also be a singleton.

#2 Updated by Michael Kay 7 days ago

  • Status changed from New to In Progress

The code for CastableExpression has the comment:

        // We need to take care here. The usual strategy of wrapping the operand in an expression that
        // does type-checking doesn't work here, because an error in the type checking should be caught,
        // while an error in evaluating the expression as written should not.

I think this suggests it was written before the spec was clarified to say that an error that occurs when atomizing the operand is treated as an error, not as a false result.

I'm therefore going to try doing a staticTypeCheck() call on the operand, with an expected type of xs:anyAtomicType.

#3 Updated by Michael Kay 7 days ago

By doing a "standard" call on staticTypeCheck with an expected type of xs:anyAtomicType*, we pass all the CastableExpr tests including the new one. There are two "wrong error code" results:

CastableAs666 and CastableAs668 both return FOTY0013 rather than XPTY0004.

These are recent tests and a careful reading of the spec shows that the expected error code is wrong, so I will fix the tests.

#4 Updated by Michael Kay 7 days ago

  • Status changed from In Progress to Resolved
  • Applies to branch 10, trunk added
  • Fix Committed on Branch 10, trunk added

Please register to edit this issue

Also available in: Atom PDF