You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "mike-mcgann (via GitHub)" <gi...@apache.org> on 2023/02/21 14:53:37 UTC

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

mike-mcgann commented on code in PR #966:
URL: https://github.com/apache/daffodil/pull/966#discussion_r1113175654


##########
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.")

Review Comment:
   > It's annoying, but invariantFailed always wants the COVERAGE-ON/COVERAGE-OFF stuff around it. I wish we could somehow build that in so it is implied for these assertions, but I don't know how.
   
   I bracketed the invariant with COVERAGE-ON/COVERAGE-OFF. I checked the docs but there doesn't seem to be a way to configure this at function invocation time. 
   
   



-- 
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