Skip to content

For statements containing return statements must not be mapped as expansion regions #20

@seidewitz

Description

@seidewitz

The Alf spec states that a non-parallel for statement is mapped as an iterative expansion region if it "does not make within it any re-assignments to names defined outside of it." However, if such a for statement contains a return statement, directly or indirectly, then it cannot be mapped as an expansion region, because this would require a control flow out of the expansion region (to terminate the enclosing activity), and fUML does not allow activity edges to cross in or out of an expansion region.

Currently, when it is detected that a control flow would cross out of an expansion region, the mapping code redirects the source of the control flow to be the expansion region itself. The result is that the following activity:

activity A() : Boolean {
    for (x in Integer[]{1..2}) {
        if (x > 2) {
            return false;
        }
    }
    return true;
}

returns null instead of true, because the redirected control flow from the for statement terminates the activity prematurely.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions