Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid dependency resolution #572

Closed
senier opened this issue Feb 11, 2021 · 0 comments · Fixed by #592
Closed

Invalid dependency resolution #572

senier opened this issue Feb 11, 2021 · 0 comments · Fixed by #592
Assignees
Labels
bug specification Related to specification package (e.g., specification parsing)

Comments

@senier
Copy link
Member

senier commented Feb 11, 2021

Dependencies are not resolved correctly in some cases. This is true for the current parser as well as the new parser developed in #547:

package P1 is
   type Kind is mod 2**16;
   type Frame is
      message
         Kind : Kind;
         Payload : Opaque
            with Size => Message'Last - Kind'Last;
      end message;
end P1;
package P4 is
   type Protocol_Number is mod 2**16;
end P4;
with P4;
package P2 is
   type Length is mod 2**16;
   type Packet is
      message
         Length : Length;
         Protocol : P4::Protocol_Number;
         Payload : Opaque
            with Size => 8 * Length;
      end message;
end P2;
with P2;
package P3 is
   type T is mod 2**32;
   type Packet is
      message
         F1 : T;
         F2 : P2::Length;
      end message;
end P3;
with P1;
with P2;
with P3;
package In_P1 is
   for P1::Frame use (Payload => P2::Packet)
      if Kind = 1;
   for P1::Frame use (Payload => P3::Packet)
      if Kind = 2;
end In_P1;

When checking In_P1, the new parser yields:

Processing P2
Processing P3
Processing P4
Processing P1
Processing In_P1
p2.rflx:10:10: model: error: missing type for field "Protocol" in "P2::Packet"
in_p1.rflx:7:34: parser: error: undefined type "P2::Packet" in refinement of "P1::Frame"

As can be seen, the dependency resolution yields P2, P3, P4, P1, In_P4, whereas the correct order would be P4, P1, P2, P3, In_P1 or P1, P4, P2, P3, In_P1 (i.e. post-order DFS).

The current parser has the same issue (but different subsequent errors):

Processing P2
Processing P3
Processing P4
Processing P1
Processing In_P1
in_p1.rflx:1:6: parser: error: dependency cycle when including "P1"
in_p1.rflx:2:6: parser: info: when including "P2"
p2.rflx:1:6: parser: info: when including "P4"
in_p1.rflx:3:6: parser: info: when including "P3"
p3.rflx:1:6: parser: info: when including "P2"
p2.rflx:10:10: model: error: missing type for field "Protocol" in "P2::Packet"
in_p1.rflx:7:34: parser: error: undefined type "P2::Packet" in refinement of "P1::Frame"
@senier senier added the bug label Feb 11, 2021
@treiher treiher added the specification Related to specification package (e.g., specification parsing) label Feb 11, 2021
@senier senier self-assigned this Feb 16, 2021
senier pushed a commit that referenced this issue Feb 27, 2021
senier pushed a commit that referenced this issue Mar 2, 2021
senier pushed a commit that referenced this issue Mar 4, 2021
senier pushed a commit that referenced this issue Mar 6, 2021
senier pushed a commit that referenced this issue Mar 9, 2021
senier pushed a commit that referenced this issue Mar 10, 2021
senier pushed a commit that referenced this issue Mar 10, 2021
@treiher treiher mentioned this issue Aug 4, 2021
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug specification Related to specification package (e.g., specification parsing)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants