incorrect code generation for size of scalar sequences
messages.rflx.txt test.rflx.txt
On the attached file, RFLX issues this error message:
test.rflx:26:46: parser: error: Expected 'for', got 'First'
The file contains neither "for" nor "First", so what is this about? I probably did something wrong, what's the proper syntax for such sequence comprehensions?
The error messages of the specification parser are unfortunately quite bad. That is a known issue: Componolit/RecordFlux-parser#28. The parser complains about the sequence aggregate in:
Out_Msg := Messages::Msg_Seq'(A => [In_Msg.C, In_Msg.D]);
The reason is that sequence aggregates only support numeric literals as elements (sequence aggregates were introduced for comparing opaque fields with a fixed sequence of bytes). There is already a ticket for changing that: #488. For now, the intended action can be specified as follows:
state Copy is
Seq : Messages::Seq;
begin
Seq'Append (In_Msg.C);
Seq'Append (In_Msg.D);
Out_Msg := Messages::Msg_Seq'(A => Seq);
As there are already tickets for all related issues, I'm closing this ticket.
Thanks for the quick answer!
I'm reopening the issue because your code is accepted by Recordflux, but:
- It triggers the assertion at
generator/session.py, line 2495 (because the expression is aSelected, not aVariable; this is only visible when running with assertions obviously, e.g. via the testsuite) - The generated code doesn't compile:
rflx-test-session.adb:63:45: error: "In_Msg" is undefined (more references follow)
rflx-test-session.adb:81:10: error: "Seq" is not visible (more references follow)
rflx-test-session.adb:81:10: error: non-visible declaration at rflx-messages-seq.ads:18
Any idea how the code should be written to be accepted?
- can be solved by using variables instead of the `Selected´ expression directly:
state Copy is
Seq : Messages::Seq;
C : Messages::Integer;
D : Messages::Integer;
begin
C := In_Msg.C;
D := In_Msg.D;
Seq'Append (C);
Seq'Append (D);
Out_Msg := Messages::Msg_Seq'(A => Seq);
We could make the unsupported expression clearer by calling _unsupported_expression, if no variable is used.
- points to an actual bug:
rflx-test-session.adb:103:10: error: "Seq" is not visible (more references follow)
rflx-test-session.adb:103:10: error: non-visible declaration at rflx-messages-seq.ads:10
103 Seq'Size <= 32768
104 and then Seq'Size mod RFLX_Types.Byte'Size = 0
Seq'Size should be substituted by Messages.Seq.Size (Seq_Ctx). The fix is probably quite simple: Handling that specific case in _substitution in rflx/generator/session.py.
Do you think you can fix that?
Sure, I can try.