Skip to content

Commit

Permalink
Fix missing reset in assignment to comprehension
Browse files Browse the repository at this point in the history
  • Loading branch information
treiher committed May 23, 2022
1 parent 1d3fc0b commit 9ea5fe2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rflx/generator/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -2652,18 +2652,24 @@ def _assign_to_comprehension( # pylint: disable = too-many-arguments
self._session_context.used_types_body.append(const.TYPES_BIT_LENGTH)

target_id = ID(target)
target_context = context_id(target_id, is_global)
sequence_type_id = ID(comprehension.sequence.type_.identifier)
iterator_id = ID(comprehension.iterator)

sequence_element_type = comprehension.sequence.type_.element

reset_target = CallStatement(
ID(target_type.identifier) * "Reset", [Variable(target_context)]
)

if isinstance(sequence_element_type, rty.Message):
iterator_type_id = ID(sequence_element_type.identifier)

if isinstance(comprehension.sequence, expr.Variable):
sequence_id = ID(rid.ID(f"{comprehension.sequence}"))
with exception_handler.local() as local_exception_handler:
return [
reset_target,
self._declare_sequence_copy(
sequence_id,
sequence_type_id,
Expand Down Expand Up @@ -2710,6 +2716,7 @@ def _assign_to_comprehension( # pylint: disable = too-many-arguments

with exception_handler.local() as local_exception_handler:
return [
reset_target,
self._if_structural_valid_message(
message_type,
context_id(message_id, is_global),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ is
Universal.Option_Types.Initialize (Option_Types_Ctx, Option_Types_Buffer);
pragma Assert (Process_Invariant);
-- tests/integration/session_comprehension_on_message_field/test.rflx:27:10
Universal.Option_Types.Reset (Option_Types_Ctx);
if Universal.Message.Structural_Valid_Message (Ctx.P.Message_Ctx) then
declare
RFLX_Message_Options_Ctx : Universal.Options.Context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ is
Universal.Options.Initialize (Message_Options_Ctx, Message_Options_Buffer);
pragma Assert (Process_Invariant);
-- tests/integration/session_comprehension_on_sequence/test.rflx:34:10
Universal.Option_Types.Reset (Option_Types_Ctx);
if Universal.Options.Valid (Ctx.P.Options_Ctx) then
declare
RFLX_Copy_Options_Ctx : Universal.Options.Context;
Expand Down Expand Up @@ -258,6 +259,7 @@ is
goto Finalize_Process;
end if;
-- tests/integration/session_comprehension_on_sequence/test.rflx:40:10
Universal.Options.Reset (Message_Options_Ctx);
if Universal.Options.Valid (Ctx.P.Options_Ctx) then
declare
RFLX_Copy_Options_Ctx : Universal.Options.Context;
Expand Down

0 comments on commit 9ea5fe2

Please sign in to comment.