Skip to content

Support for nested control structures #3079

Closed
Closed

Description

@pekkaklarck

Robot Framework currently only has FOR loops but the plan is to add support for IF/ELSE (#3074) and TRY/EXCEPT (#3075) in the future as well. At the moment FOR loops cannot be nested directly, so nested loops need to be implemented so that a loop contains a keyword which has another loop. This isn't too convenient, and the problem becomes even worse when new syntax is added.

We have made a decision to add support for nested structures so that examples like this will work:

FOR    ${row}    IN    @{rows}
    FOR    ${cell}    IN    @{row}
        IF    "${cell}" != "IGNORE"
            Process Cell    ${cell}
        END
    END
END

The plan is to add support for nested FOR loops already in RF 3.2 as a feature provided by the new test data parser (#3076). Possible problem is that in RF 3.2 we still need to support FOR loops without the explicit END marker (#3078). If that adds too much complexity, the support for nested control structures can be postponed to RF 3.3 where FOR loops without END won't be supported anymore.

Activity

  1. added this to the v3.2 milestone on Feb 4, 2019
  2. pekkaklarck commented on Aug 19, 2019

    @pekkaklarck
    MemberAuthor

    No time for this in RF 3.2. We want to the new parser out ASAP so that it supports old syntax, and then we can start concentrating on enhancing syntax with IF/ELSE, TRY/EXCEPT, and nested structures. This is definitely a critical feature in RF 3.2.

  3. modified the milestones: v3.2, v3.3 on Aug 19, 2019
  4. modified the milestones: v3.3, v4.0 on Feb 7, 2020
  5. Snooz82 commented on Apr 29, 2020

    @Snooz82
    Member

    readability of nested control features is always a pain.
    And statics code analysis count every nesting as a huge impact to code complexity.

    With Keywords nesting is possible and readability is good.

    If you would ask me, i would downvote this feature.
    If you need this stuff, do it in python.
    If you do not understand python, you do not understand nested structures...

  6. pekkaklarck commented on Apr 30, 2020

    @pekkaklarck
    MemberAuthor

    In my opinion IF/ELSE makes no sense if we don't support nested structures. Especially FOR loop with IF sounds like a pretty common use case. It would be annoying to be able to use IF/ELSE elsewhere but in a loop you needed to revert to the hackish Run Keyword If.

  7. modified the milestones: v5.0, v4.0 on Oct 21, 2020
  8. added a commit that references this issue on Nov 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions