Skip to content

Commit

Permalink
Fix non-recursive verification in C++ (#503)
Browse files Browse the repository at this point in the history
We forgot to put a yield when iterating over the verification errors
related to the root instance. We fix the issue in this change.
  • Loading branch information
mristin authored Jun 20, 2024
1 parent a2f329f commit 5444034
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
5 changes: 3 additions & 2 deletions aas_core_codegen/cpp/verification/_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def _generate_iterator_implementation() -> List[Stripped]:


def _generate_non_recursive_verification() -> List[Stripped]:
"""Generate the ``RecursiveVerification`` class."""
"""Generate the ``NonRecursiveVerification`` class."""
return [
Stripped("// region NonRecursiveVerification"),
Stripped(
Expand Down Expand Up @@ -1725,7 +1725,8 @@ def _generate_recursive_verificator_execute() -> Stripped:
);
// No path is prepended as the error refers to the instance itself.
++index_;"""
)
),
yielding_flow.Yield(),
],
),
yielding_flow.command_from_text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24986,7 +24986,7 @@ void RecursiveVerificator::Execute() {

case 1: {
if (!(!verificator_->Done())) {
state_ = 2;
state_ = 3;
continue;
}

Expand All @@ -25001,13 +25001,18 @@ void RecursiveVerificator::Execute() {
// No path is prepended as the error refers to the instance itself.
++index_;

state_ = 2;
return;
}

case 2: {
verificator_->Next();

state_ = 1;
continue;
}

case 2: {
case 3: {
verificator_ = nullptr;

{
Expand All @@ -25025,9 +25030,9 @@ void RecursiveVerificator::Execute() {
}
}

case 3: {
case 4: {
if (!(*iterator_ != *iterator_end_)) {
state_ = 7;
state_ = 8;
continue;
}

Expand All @@ -25037,9 +25042,9 @@ void RecursiveVerificator::Execute() {
verificator_->Start();
}

case 4: {
case 5: {
if (!(!verificator_->Done())) {
state_ = 6;
state_ = 7;
continue;
}

Expand All @@ -25060,34 +25065,34 @@ void RecursiveVerificator::Execute() {

++index_;

state_ = 5;
state_ = 6;
return;
}

case 5: {
case 6: {
verificator_->Next();

state_ = 4;
state_ = 5;
continue;
}

case 6: {
case 7: {
verificator_ = nullptr;

++(*iterator_);

state_ = 3;
state_ = 4;
continue;
}

case 7: {
case 8: {
iterator_.reset();
iterator_end_.reset();
done_ = true;
index_ = -1;

// We invalidate the state since we reached the end of the routine.
state_ = 8;
state_ = 9;
return;
}

Expand Down

0 comments on commit 5444034

Please sign in to comment.