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


##########
daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_expressions/expressions_unused_path_no_context.dfdl.xsd:
##########
@@ -28,20 +28,119 @@
     </xs:appinfo>
   </xs:annotation>
 
+
   <xs:element name="e1" type="xs:int" dfdl:lengthKind="explicit" 
dfdl:length="1" />
 
-  <xs:group name="unused_group">
+  <xs:group name="unused_group_1">
     <xs:sequence>
       <xs:element name="value1" type="xs:string" dfdl:lengthKind="explicit" 
dfdl:length="1" />
       <xs:sequence dfdl:terminator="{ ./value1 }" />
     </xs:sequence>
   </xs:group>
 
-  <xs:complexType name="unused_complex_type">
+  <xs:complexType name="unused_complex_type_1">
     <xs:sequence>
       <xs:element name="value2" type="xs:string" dfdl:lengthKind="explicit" 
dfdl:length="1" />
       <xs:sequence dfdl:terminator="{ ./value2 }"/>
     </xs:sequence>
   </xs:complexType>
 
+
+  <xs:group name="unused_group_2">
+    <xs:sequence>
+      <xs:sequence dfdl:terminator="{ ./value3 }" />
+    </xs:sequence>
+  </xs:group>
+
+  <xs:complexType name="unused_complex_type_2">
+    <xs:sequence>
+      <xs:sequence dfdl:terminator="{ ./value4 }"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="unused_element_2">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:sequence dfdl:terminator="{ ./value5 }"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+
+  <xs:group name="unused_group_3">
+    <xs:sequence>
+      <xs:element name="unused" type="xs:string" dfdl:terminator="{ ../value6 
}" />
+    </xs:sequence>
+  </xs:group>
+
+  <xs:complexType name="unused_complex_type_3">
+    <xs:sequence>
+      <xs:element name="unused" type="xs:string" dfdl:terminator="{ ../value7 
}" />
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:element name="unused_element_3">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element name="unused" type="xs:string" dfdl:terminator="{ 
../../value8 }" />
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+
+  <xs:element name="unused_element_4">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element name="value9" type="xs:string" />
+        <xs:element name="nest1">
+          <xs:complexType>
+            <xs:sequence>
+              <xs:element name="nest2" type="xs:string" dfdl:terminator="{ 
../../value9 }" />

Review Comment:
   Yeah, this was something weird I did notice. I think the issue is that 
unused_element_4 is a GlobalElementDecl, so there is no DPathElementCompileInfo 
associated with it. I believe only Root, ElementRef, and LocalElementDecl 
actually get DPathElementCompileInfos.
   
   So in the context of nest2, `../../` goes to nothing (at least nothing that 
has a DPathElementCompileInfo. nest1 has no parent DPathElementCompileInfo and 
nest2 has no grandparent. Because of that, we think it does actually go up and 
out, even though it doesn't really.
   
   Maybe a fix would be when we compile a GlobalElemntDecl because 
checkAllTopLevel is defined, we instead create a temporary Root (but one that 
isn't a distinguished root since we need this for the up and out check). This 
way there would be DPathElementCompileInfo for the unused_element_4, and there 
would not be a warning. Maybe there is a better approach? The feels kindof 
hacky just to avoid this warning, but maybe not?



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