You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "stevedlawrence (via GitHub)" <gi...@apache.org> on 2023/02/20 16:00:15 UTC

[GitHub] [daffodil] stevedlawrence commented on a diff in pull request #966: Better error message when contentLength/valueLength argument is an array

stevedlawrence commented on code in PR #966:
URL: https://github.com/apache/daffodil/pull/966#discussion_r1110233357


##########
daffodil-core/src/main/scala/org/apache/daffodil/core/dpath/Expression.scala:
##########
@@ -2829,13 +2829,19 @@ sealed abstract class LengthExprBase(
   ) {
 
   protected final def leafReferencedElements = {
-    val arg = args(0).asInstanceOf[PathExpression]
+    val arg = args(0) match {
+      case arg: PathExpression => arg
+      case _ => Assert.invariantFailed("NodeInfo.Exists, but arg was not a PathExpression.")
+    }
+    // test_lengthPatternBinaryPatternLimit in section 12 shows that the length can
+    // be evaluated when it is an array of hex binary values
+    if (arg.inherentType != NodeInfo.HexBinary && arg.isPathToOneWholeArray)

Review Comment:
   I'm not sure the hex binary exception is correct. In the mentioned test, I don't think the path evaluates to a whole array--the path is just `.` which in the context of where it's evaluated *I think* should just be a single element of that array (and this array just happens to be hexBinary, but it could be any type really). I think if `isPathToOneWholeArray` thinks the expression is evaluates to an array, then maybe there is a bug in that.
   
   It seems like it things it's an array (which it kindof is), but in the context of this expression it really isn't...I'm not sure what the right fix is. Maybe it just needs exception for `Self`, since a Self expresion never can reference an array, but can only reference an element?



-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org