Skip to content

Commit ee64a15

Browse files
joewizclaude
andcommitted
[refactor] Drop XQuery 4.0 binary type promotion blocks
Per @duncdrum and @line-o on PR eXist-db#6344: both reviewers flagged the two xs:hexBinary ↔ xs:base64Binary code paths as XQ 4.0-specific (the comments literally say "(XQuery 4.0)") and noted they don't belong in this XQ 3.1 conformance subset. Removed: - DynamicTypeCheck.java: the xs:base64Binary ↔ xs:hexBinary type-promotion branch in the static-type-check ladder - GeneralComparison.java: case (d) of resolveNumericType — cast both operands of a general comparison to xs:base64Binary when both are binary types. Renumbered the now-final XPTY0004 case from (e) to (d). These will be reintroduced together with the rest of XQ 4.0 type coercion in v2/xq4-core-functions (PR eXist-db#6260). XQuery3Tests: 1030/1030 pass. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 12340dd commit ee64a15

2 files changed

Lines changed: 1 addition & 20 deletions

File tree

exist-core/src/main/java/org/exist/xquery/DynamicTypeCheck.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,6 @@ private void check(Sequence result, Item item) throws XPathException {
149149
} else if (type == Type.ANY_URI && requiredType == Type.STRING) {
150150
item = item.convertTo(Type.STRING);
151151
type = Type.STRING;
152-
//Binary type promotion (XQuery 4.0): xs:base64Binary ↔ xs:hexBinary
153-
} else if ((type == Type.BASE64_BINARY && requiredType == Type.HEX_BINARY)
154-
|| (type == Type.HEX_BINARY && requiredType == Type.BASE64_BINARY)) {
155-
try {
156-
item = item.convertTo(requiredType);
157-
} catch (final XPathException e) {
158-
throw new XPathException(expression, ErrorCodes.XPTY0004,
159-
"cannot convert " + Type.getTypeName(type) + " to " + Type.getTypeName(requiredType));
160-
}
161152
} else {
162153
if (!(Type.subTypeOf(type, requiredType))) {
163154
throw new XPathException(expression, typeMismatchError,

exist-core/src/main/java/org/exist/xquery/GeneralComparison.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,17 +1082,7 @@ private AtomicValue convertForValueComparison(final AtomicValue value, final int
10821082
}
10831083

10841084
/*
1085-
* d. (XQuery 4.0) If each operand is an instance of one of the types
1086-
* xs:hexBinary or xs:base64Binary, then both operands are cast to
1087-
* type xs:base64Binary.
1088-
*/
1089-
if ((thisType == Type.HEX_BINARY || thisType == Type.BASE64_BINARY)
1090-
&& (otherType == Type.HEX_BINARY || otherType == Type.BASE64_BINARY)) {
1091-
return value.convertTo(Type.BASE64_BINARY);
1092-
}
1093-
1094-
/*
1095-
* e. Otherwise, a type error is raised [err:XPTY0004].
1085+
* d. Otherwise, a type error is raised [err:XPTY0004].
10961086
*/
10971087
throw new XPathException(this, ErrorCodes.XPTY0004, "Incompatible primitive types");
10981088
}

0 commit comments

Comments
 (0)