stevedlawrence commented on a change in pull request #440:
URL: https://github.com/apache/incubator-daffodil/pull/440#discussion_r506578916



##########
File path: 
daffodil-core/src/main/scala/org/apache/daffodil/runtime1/ChoiceTermRuntime1Mixin.scala
##########
@@ -86,11 +86,15 @@ trait ChoiceTermRuntime1Mixin { self: ChoiceTermBase =>
     // in the arriving infoset for unparse.
     //
     val optDefaultBranch = {
-      val optEmpty: Option[Term] =
-        groupMembers.find { gm =>
+      val optEmpty: Option[Term] = {
+        val emptyBranches = groupMembers.filter { gm =>
           val ies = gm.identifyingEventsForChoiceBranch
           ies.pnes.isEmpty // empty event list makes it the default, not 
simply isOpen
         }
+        if (emptyBranches.length > 1)
+          SDW(WarnID.MultipleChoiceBranches, "Multiple choice branches are 
empty, defaulting to first empty branch")

Review comment:
       I think this error message could be more clear. First, "defaulting" has 
a meaning in the DFDL spec that is different from what this is saying, so I 
think we should avoid using that word. The word "empty" feels a bit ambiguous 
as well. It also doesn't poitn out which other empty branches are being 
ignored. That could be helpful information. From Mike's bug, mentioning 
branches that can't be unparsed might be a more helpful approach, maybe 
something like:
   
   ```scala
   emptyBranches.tail.foreach { branch =>
     branch.SDW("Choice branch with no elements can never be unparsed")
   }
   ```
   So we get a warning for each branch that can never be used to unparse for 
each branch. It means there will be multiple warnings if there are multiple 
empty branches, but it makes it easier for the user to identify which branches 
are empty and fix the issue.
   




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to