File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
main/java/org/exist/xquery Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -190,7 +190,7 @@ public Function toFunction() throws XPathException {
190
190
try {
191
191
final QName qname = QName .parse (context , typeName );
192
192
final FunctionSignature signature = new FunctionSignature (qname );
193
- final SequenceType argType = new SequenceType (Type .ITEM , Cardinality .EXACTLY_ONE );
193
+ final SequenceType argType = new SequenceType (Type .ITEM , Cardinality .ZERO_OR_ONE );
194
194
signature .setArgumentTypes (new SequenceType []{argType });
195
195
signature .setReturnType (new SequenceType (CastExpression .this .requiredType , CastExpression .this .cardinality ));
196
196
return new FunctionWrapper (this , signature );
Original file line number Diff line number Diff line change @@ -278,3 +278,24 @@ function ao:for-each-pair-with-contextitem () {
278
278
=> string-join ()
279
279
};
280
280
281
+ (:~
282
+ check if CastExpression#toFuntion has correct cardinality check
283
+ see https://github.com/eXist-db/exist/issues/4971
284
+ :)
285
+ declare
286
+ %test:assertEmpty
287
+ function ao:type-constructor-after-arrow-empty-sequence () {
288
+ () => xs:string ()
289
+ };
290
+
291
+ declare
292
+ %test:assertEquals("1" )
293
+ function ao:type-constructor-after-arrow-integer () {
294
+ 1 => xs:string ()
295
+ };
296
+
297
+ declare
298
+ %test:assertError("XPTY0004" )
299
+ function ao:type-constructor-after-arrow-integer-sequence () {
300
+ (1 ,2 ) => xs:string ()
301
+ };
You can’t perform that action at this time.
0 commit comments