mbeckerle closed pull request #160: Handle computed fields inside of choice 
elements.
URL: https://github.com/apache/incubator-daffodil/pull/160
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ModelGroup.scala 
b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ModelGroup.scala
index ece232683..b953f7501 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ModelGroup.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ModelGroup.scala
@@ -256,7 +256,12 @@ abstract class ModelGroup
         case _ => true
       }
     }
-    (potentialLastRepresented, allOptional)
+    if(potentialLastRepresented.isEmpty){
+      //If there are no children, by definition, all children are optional.
+      (Seq(),true)
+    }else{
+      (potentialLastRepresented, allOptional)
+    }
   }
 
   final def allSelfContainedTermsTerminatedByRequiredElement: Seq[Term] =
diff --git 
a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/AlignedMixin.scala 
b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/AlignedMixin.scala
index 69f7bf859..40e213540 100644
--- 
a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/AlignedMixin.scala
+++ 
b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/AlignedMixin.scala
@@ -26,6 +26,7 @@ import 
org.apache.daffodil.schema.annotation.props.gen.LengthKind
 import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
 import org.apache.daffodil.util.Math
 import org.apache.daffodil.dsom.Root
+import org.apache.daffodil.exceptions.Assert
 
 case class AlignmentMultipleOf(nBits: Long) {
   def *(that: AlignmentMultipleOf) = AlignmentMultipleOf(Math.gcd(nBits, 
that.nBits))
@@ -200,6 +201,8 @@ trait AlignedMixin extends GrammarMixin { self: Term =>
       case mg: ModelGroup => {
         val (lastChildren, couldBeLast) = mg.potentialLastChildren
         val lastApprox = lastChildren.map(_.endingAlignmentApprox + 
trailingSkipApprox) ++ (if (couldBeLast) Seq(contentStartAlignment + 
trailingSkipApprox) else Seq())
+        
+        Assert.invariant(!lastApprox.isEmpty)
         lastApprox.reduce { _ * _ }
       }
     }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to