Skip to content

Prohibit using Exit For Loop and Continue For Loop in keywords #4185

Closed

Description

@pekkaklarck

Currently it is possible to use Exit For Loop and Continue For Loop keywords not only inside FOR loops but also in keywords used by loops. For example, this is possible:

*** Keywords ***
Looping
    FOR    ${x}    IN    @{stuff}
        Keyword
    END

Keyword
    Exit For Loop

This kind of loop control that can happen outside loops can be really hard to understand and can create a big mess. It is also not something that other languages like Python support. When designing native BREAK and CONTINUE (#4079) to replace these keywords, we agreed not to support them inside keywords. To simplify implementation and to have just one "rules" for loop control, we also decided to prohibit Exit For Loop and Continue For Loop in keywords.

This change is naturally backwards incompatible and affects everyone who has used these keywords inside keywords, not directly inside loops. We try to avoid such changes in general, but we believe that's fine in this case for the following reasons:

  • As already mentioned, it's good that these keywords work the same way as BREAK and CONTINUE. And we don't want BREAK and CONTINUE to work inside keywords.
  • The plan is to deprecate and remove these keywords in favor of BREAK and CONTINUE. Everyone eventually needs to change their tests/tasks anyway.
  • The change happens in a major release where breaking changes are more ok than in other releases.

Activity

  1. added this to the v5.0 milestone on Jan 14, 2022
  2. added a commit that references this issue on Jul 15, 2025
    ac8c5d5
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