mbeckerle commented on code in PR #1137:
URL: https://github.com/apache/daffodil/pull/1137#discussion_r1446526490
##########
daffodil-core/src/main/scala/org/apache/daffodil/core/dpath/Expression.scala:
##########
@@ -2295,6 +2295,18 @@ abstract class FunctionCallBase(
res
}
+ final def checkArgArray(): Unit = {
+ lazy val isArray = expressions.head match {
+ case rpe: RelativePathExpression => rpe.steps.last.isArray
+ case rpe: RootPathExpression => rpe.steps.last.isArray
+ case _ => true
Review Comment:
> One thing to consider is this doesn't catch expressions like this:
>
> ```xq
> fn:count(if (some_condition) then /some/path else /some/other/path)
> ```
>
> I think that's legal and I think would be considered invalid because of
this case.
>
> I'm not sure if there's a good way to check that all branches of a
subexpression result in an array. We must be able to get some basic information
since we can statically check that all branches have the same type. I think we
do that via `inherentType`, but I'm not sure the result would return
information about being an array or not. Maybe this is just a limitation of our
checking and it's good enough? And if someone whats the above, they would need
to do something like this:
>
> ```xq
> if (some_condition) then fn:count(/some/path) else
fn:count(/some/other/path)
> ```
Pretty sure the expression type system treats "array or optional" as a type,
and so the type inference on the expressions requires all branches of an IF to
evaluate to an array/optional in order to satisfy the requirements of fn:count.
It's supposed to propagate the requirement from the fn:count into the
expression, which would then propagate it to the then and else branch
expressions as the "target type" that the expression is trying to create.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]