olabusayoT commented on code in PR #1509:
URL: https://github.com/apache/daffodil/pull/1509#discussion_r2216507165


##########
daffodil-core/src/main/scala/org/apache/daffodil/runtime1/processors/RuntimeData.scala:
##########
@@ -357,59 +357,73 @@ final class SimpleTypeRuntimeData(
       }
     }
     // Check length
-    e.length.foreach { length =>
-      if (!checkLength(currentElement, length, e, primType))
-        return Error("facet length (%s)".format(length))
-    }
+    val lengthError = e.length
+      .find(length => !checkLength(currentElement, length, e, primType))
+      .map(length => Error("facet length (%s)".format(length)))
+
+    if (lengthError.isDefined) return lengthError.get
+

Review Comment:
   Yea scala 3 stopped allowing early returns from loops, hence the need to 
refactor the pieces of code you've noted. I was able to refactor to the below 
which I think is clearer
   
       if (e.length.isDefined) {
         val check = checkLength(currentElement, e.length.get, e, primType)
         if (!check) {
           return Error("facet length (%s)".format(e.length))
         }
       }



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

Reply via email to