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

Messages cannot be parsed if Specification contains condition with Message'Size #525

Closed
rssen opened this issue Dec 13, 2020 · 1 comment · Fixed by #556
Closed

Messages cannot be parsed if Specification contains condition with Message'Size #525

rssen opened this issue Dec 13, 2020 · 1 comment · Fixed by #556
Assignees
Labels
bug pyrflx Related to pyrflx package (Legacy Python API)

Comments

@rssen
Copy link
Contributor

rssen commented Dec 13, 2020

A message is not parsed by PyRFLX if its specification contains a condition where a comparison with Message'Size is performed.

Consider the following example:

package Test is

   type T is mod 2**8;

   type Test is
      message
         A : T
            then B
               with Size => A * 8;
         B : Opaque
            then null
               if Message'Size = (A + 1) * 8;
      end message;
end Test;

It think the problem is that the expression (Message'Size = (A + 1) * 8) is not completely simplified into a BooleanTrue/BooleanFalse by __simplified(l.condition) inside the _next_field method.
That leads to a comparison between an expression.Equal and an expression.BooleanTrue inside the __eq__ method of expression.Expr, which returns NotImplemented.
The core problem is that Message'Size is not substituted with a concrete value (not in __type_literals nor in _simplified_mapping).

As no outgoing condition can be satisfied, the _next_field method returns an empty String, which leads to a KeyError when attempting to get the next field from _fields in the parse method.
The raised KeyError also contains no proper error message, only an empty String.

@rssen rssen added the pyrflx Related to pyrflx package (Legacy Python API) label Dec 13, 2020
@treiher treiher added the bug label Dec 14, 2020
@treiher treiher added this to To do in RecordFlux 0.5 via automation Dec 14, 2020
@jklmnn
Copy link
Member

jklmnn commented Dec 14, 2020

The core problem is that Message'Size is not substituted with a concrete value (not in __type_literals nor in _simplified_mapping).

Message'Size needs to be substituted with the sum of the size of all fields on this path. If there are multiple paths we have to create a disjunction of multiple subsitutions. In this concrete example the result needs to be Message'Size = A'Size + B'Size which then should be resolved to A'Size + B'SIze = (A + 1) * 8.

@senier senier unassigned rssen Jan 7, 2021
@jklmnn jklmnn self-assigned this Jan 18, 2021
@senier senier moved this from To do to In progress in RecordFlux 0.5 Jan 19, 2021
jklmnn added a commit that referenced this issue Jan 19, 2021
jklmnn added a commit that referenced this issue Jan 19, 2021
jklmnn added a commit that referenced this issue Jan 19, 2021
@senier senier moved this from In progress to Done in RecordFlux 0.5 Jan 20, 2021
jklmnn added a commit that referenced this issue Jan 20, 2021
jklmnn added a commit that referenced this issue Jan 20, 2021
jklmnn added a commit that referenced this issue Jan 20, 2021
RecordFlux 0.5 automation moved this from Done to Merged Jan 20, 2021
jklmnn added a commit that referenced this issue Jan 20, 2021
jklmnn added a commit that referenced this issue Jan 20, 2021
jklmnn added a commit that referenced this issue Jan 20, 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 pyrflx Related to pyrflx package (Legacy Python API)
Projects
No open projects
RecordFlux 0.5
  
Merged
3 participants