Conversation
mbeckerle
left a comment
There was a problem hiding this comment.
Add a test of the runtime check.
| val width = primNumeric.width.get | ||
| if (nBits > width) | ||
| PE( | ||
| start, |
There was a problem hiding this comment.
Definitely need a test to exercise this.
There was a problem hiding this comment.
I tried to test this by using an expression such as { 2 * 8 } but I guess that expression could actually be evaluated at compile time and wasn't exercising the runtime check. I updated the test to get the value from the first byte in the data stream.
There was a problem hiding this comment.
Yup. Poor-man's constant folding using an obvious hack - infoset to be a fake infoset that just throws if you try to access any method on it. Eval expression. No infoset access means it can compute the value. If it touches the infoset, it throws, and determines therefore that it can't constant-fold the expression.
stevedlawrence
left a comment
There was a problem hiding this comment.
+1, minor suggestion for maybe a slightly more helpful error message
daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/ElementBase.scala
Show resolved
Hide resolved
Daffodil was allowing bit lengths on binary types that exceed the width of the type even though this is not allowed by the DFDL specification. This change adds a check at compile time to see if the bit length value is valid when specified as a constant and at runtime when the bit length is specified an expression. DAFFODIL-1704
593d8f6 to
619adad
Compare
| <xs:element name="le_int8" type="xs:byte" | ||
| dfdl:byteOrder="littleEndian"/> | ||
| <xs:element name="le_int46" type="xs:int" | ||
| <xs:element name="le_int46" type="xs:integer" |
There was a problem hiding this comment.
Nice to see that we can test integer and nonNegativeInteger again in ex_nums again.
Daffodil was allowing bit lengths on binary types that exceed the width of the type even though this is not allowed by the DFDL specification. This change adds a check at compile time to see if the bit length value is valid when specified as a constant and at runtime when the bit length is specified an expression.
DAFFODIL-1704