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



##########
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:
       There are multiple empty branches in the schema.  choiceDispatch not 
getting evaluated was definitely unexpected to me, but I understand that may 
generate too many warnings to be practical.  Using choiceDispatch to 
disambiguate would have been nice, but I the spec isn't really clear what 
expected behaviour is when unparsing a choice with empty branches (or at least 
I can't find anything about it in the spec, its definitely not mentioned in 
15.1.3 Unparsing Choices section).
   
   I'm not sure what a good warning message would be in this rather particular 
case, maybe a warning whenever we are defaulting to the first empty branch of 
the choice.




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