Bug #4820
closedExpression `[1,2,3] castable as xs:integer` returns true
100%
Description
Raised by Ghislain Fourny on xquery-talk list.
Test case CastableAs664 added to QT3.
Updated by Michael Kay over 3 years 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.
Updated by Michael Kay over 3 years 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.
Updated by Michael Kay over 3 years 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.
Updated by Michael Kay over 3 years ago
- Status changed from In Progress to Resolved
- Applies to branch 10, trunk added
- Fix Committed on Branch 10, trunk added
Updated by O'Neil Delpratt almost 3 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 10.5 added
Bug fix applied to Saxon 10.5 maintenance release.
Please register to edit this issue