mbeckerle commented on code in PR #1337:
URL: https://github.com/apache/daffodil/pull/1337#discussion_r1841079065
##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/PackedBinaryTraits.scala:
##########
@@ -51,7 +52,15 @@ abstract class PackedBinaryDecimalBaseParser(
def parse(start: PState): Unit = {
val nBits = getBitLength(start)
- if (nBits == 0) return // zero length is used for outputValueCalc often.
+ if (nBits == 0) {
+ PE(
+ start,
+ "Number of bits %d out of range for a binary decimal. " +
+ "An unsigned decimal with length 1 bit could be used instead.",
Review Comment:
Well, we may be depending on this zero-length behavior. See the comment in
the code about zero length is used by outputValueCalc. But this doesn't really
make sense to me. Some things, like strings and hexBinary, can be zero length,
but many data types zero length makes no sense. There is defaulting, e.g.,
when we are trying to parse an integer and we get zero-length back we may
provide a default value for the integer. But in the absence of defaulting, most
simple types require at least 1 bit.
--
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]