stevedlawrence commented on code in PR #1137:
URL: https://github.com/apache/daffodil/pull/1137#discussion_r1501116238


##########
daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/Functions.tdml:
##########
@@ -5150,6 +5147,145 @@
       </xs:complexType>
     </xs:element>
 
+    <xs:element name="countArray">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="int" type="xs:int" minOccurs="2" maxOccurs="2" 
dfdl:representation="binary" />
+          <xs:element name="count" type="xs:int" dfdl:representation="binary" 
dfdl:inputValueCalc="{ fn:count(../ex:int) }" />
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+    <xs:element name="countInput">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="int" type="xs:int" dfdl:representation="binary" />
+          <xs:element name="count" type="xs:int" dfdl:representation="binary" 
dfdl:inputValueCalc="{ fn:count(../ex:int) }" />
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+    <xs:element name="countOptional">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="int" type="xs:int" minOccurs="0" maxOccurs="1" 
dfdl:representation="binary" />
+          <xs:element name="count" type="xs:int" dfdl:representation="binary" 
dfdl:inputValueCalc="{ fn:count(../ex:int) }" />
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+    <xs:element name="countOutput">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="int" type="xs:int" dfdl:representation="binary" />
+          <xs:element name="count" type="xs:int" dfdl:representation="binary" 
dfdl:outputValueCalc="{ fn:count(../ex:int) }" />
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+    <xs:element name="countOccurs">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="int" type="xs:int" dfdl:representation="binary" />
+          <xs:element name="count" type="xs:int" dfdl:representation="binary" 
dfdl:occursCountKind="expression" dfdl:occursCount="{ fn:count(../ex:int) }" />
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+    <xs:element name="countIfArrayOptional">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="int" type="xs:int" minOccurs="2" maxOccurs="2" 
dfdl:representation="binary" />
+          <xs:element name="int2" type="xs:int" minOccurs="0" maxOccurs="1" 
dfdl:representation="binary" />
+          <xs:element name="count" type="xs:int" dfdl:representation="binary" 
dfdl:outputValueCalc="{ fn:count(if (../ex:int[1] ne 0) then ../ex:int else 
../ex:int2) }" />
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+    <xs:element name="countIfArrayScalar">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="int" type="xs:int" minOccurs="2" maxOccurs="2" 
dfdl:representation="binary" />
+          <xs:element name="int2" type="xs:int" minOccurs="1" maxOccurs="1" 
dfdl:representation="binary" />
+          <xs:element name="count" type="xs:int" dfdl:representation="binary" 
dfdl:outputValueCalc="{ fn:count(if (../ex:int[1] ne 0) then ../ex:int[1] else 
../ex:int2) }" />
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+    <xs:group name="countGroup">
+      <xs:sequence>
+        <xs:element name="count" type="xs:int" dfdl:representation="binary" 
dfdl:inputValueCalc="{ fn:count(../ex:foo) }"/>
+      </xs:sequence>
+    </xs:group>
+    <xs:element name="scalarOptional">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="scalar">
+            <xs:complexType>
+              <xs:sequence>
+                <xs:element name="foo" type="xs:int" 
dfdl:representation="binary"/>
+                <xs:group ref="countGroup"/>
+              </xs:sequence>
+            </xs:complexType>
+          </xs:element>
+          <xs:element name="optional">
+            <xs:complexType>
+              <xs:sequence>
+                <xs:element name="foo" type="xs:int" minOccurs="0" 
dfdl:representation="binary"/>
+                <xs:group ref="countGroup"/>
+              </xs:sequence>
+            </xs:complexType>
+          </xs:element>
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+    <xs:element name="scalarArray">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="scalar">
+            <xs:complexType>
+              <xs:sequence>
+                <xs:element name="foo" type="xs:int" 
dfdl:representation="binary"/>
+                <xs:group ref="countGroup"/>
+              </xs:sequence>
+            </xs:complexType>
+          </xs:element>
+          <xs:element name="array">
+            <xs:complexType>
+              <xs:sequence>
+                <xs:element name="foo" type="xs:int" minOccurs="2" 
maxOccurs="2" dfdl:representation="binary"/>
+                <xs:group ref="countGroup"/>
+              </xs:sequence>
+            </xs:complexType>
+          </xs:element>
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+    <xs:element name="arrayOptional">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="array">
+            <xs:complexType>
+              <xs:sequence>
+                <xs:element name="foo" type="xs:int" minOccurs="2" 
maxOccurs="2" dfdl:representation="binary"/>
+                <xs:group ref="countGroup"/>
+              </xs:sequence>
+            </xs:complexType>
+          </xs:element>
+          <xs:element name="optional">
+            <xs:complexType>
+              <xs:sequence>
+                <xs:element name="foo" type="xs:int" minOccurs="0" 
maxOccurs="1" dfdl:representation="binary"/>
+                <!-- throws ClassCastException, possible bug in Daffodil group 
evaluation -->
+                <!-- <xs:group ref="countGroup"/> -->

Review Comment:
   This definitely sounds like a bug. Can you open a ticket so we remember to 
look into it? If possible, include steps to reproduce (e.g. uncomment this 
group reference, run XYZ test) and the exception?



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

Reply via email to