Skip to content

Use assing, not variable, with FOR and TRY/EXCEPT model objects when referring to assigned variables #4708

Closed

Description

@Snooz82

FOR

After tokenising the assigned variable is of type VARIABLE with FOR loops but shall be ASSIGN:

Example:

FOR     ${i}    IN RANGE   10       # ${i} is:  token.type == "VARIABLE"
   Log    ${i}
END

Here is an assignment happening as in:

${i}    Set Variable     1

Therefore VARIABLE would be considered "wrong" here.

TRY/EXCEPT

Similar situation is with EXCEPT AS variables. they are also VARIABLE

Example:

TRY
    Fail     failure message
EXCEPT     AS    ${error}     # ${error} is:  token.type == "VARIABLE"
   Log     my error ${error}
END

Should also be ASSIGN after the AS

Cheers

Activity

  1. changed the title [-]Assigned Variables in FOR statements are VARIABLE but should be ASSIGN token type (Same for EXCEPT AS)[/-] [+]Assigned Variables in `FOR` statements are `VARIABLE` but should be `ASSIGN` token type (Same for `EXCEPT AS`)[/+] on Mar 29, 2023
  2. pekkaklarck commented on Mar 30, 2023

    @pekkaklarck
    Member

    I agree, ASSIGN would make more sense everywhere where variables are assigned. Easy change but also backwards incompatible so needs to be done in a major version.

  3. added this to the v7.0 milestone on Mar 30, 2023
  4. self-assigned this
    on Aug 26, 2023
  5. added a commit that references this issue on Aug 27, 2023
    76a26f6
  6. pekkaklarck commented on Sep 5, 2023

    @pekkaklarck
    Member

    Now that we use ASSIGN token type instead of VARIABLE, it would be a good idea to enhance the parsing model so that ForHeader.variables is renamed to ForHeader.assign and ExceptHeader.variable to ExceptHeader.assign. Old propertys should be preserved but be deprecated.

    Need to also think should we change the running and results models the same way.

  7. changed the title [-]Assigned Variables in `FOR` statements are `VARIABLE` but should be `ASSIGN` token type (Same for `EXCEPT AS`)[/-] [+]Use `assing`, not `variable`, with FOR and TRY/EXCEPT when referring to assigned variables[/+] on Sep 6, 2023
  8. pekkaklarck commented on Sep 6, 2023

    @pekkaklarck
    Member

    I've now locally done the parsing model change I mentioned above. I like the consistency with property names and token types. We also already used assign property with keyword calls and inline IF so there's even more consistency.

    I've also started changing the running and result models to use assign instead of variables or variable. Also that change looks good both in general and for consistency reasons. Unfortunately it also makes this change even more backwards incompatible. I'll list those changes separately when everything is ready.

  9. changed the title [-]Use `assing`, not `variable`, with FOR and TRY/EXCEPT when referring to assigned variables[/-] [+]Use `assing`, not `variable`, with FOR and TRY/EXCEPT model objects when referring to assigned variables[/+] on Sep 6, 2023
  10. pekkaklarck commented on Sep 6, 2023

    @pekkaklarck
    Member

    I now ought to have all models updated locally and will commit and push changes after I've gone through changes once more. I try to list all backwards incompatible changes and deprecations caused by this issue below:

    • Token type of variables associated with FOR and EXCEPT has been changed from VARIABLE to ASSIGN. This was the original requests in this issue.
    • Parsing model objects For, Try, ForHeader and ExceptHeader nowadays have values of the aforementioned tokens available via property assign. Earlier the property was variables with FOR and variable with TRY. Old propertys still exist but they are deprecated.
    • Execution and result model objects related to FOR and EXCEPT now have assign attribute. The old variables and variable propertys are preserved but deprecated.
    • Execution and result models objects related to FOR and EXCEPT accept assign, not variables or variable, when initialized.
    • In output.xml possible EXCEPT assignment is now in attribute assign of the <branch> element when it earlier was in variable. FOR variables are still in <var> elements that also keyword calls use. Old output.xml files using the variable attribute are supported, but new output.xml files aren't compatible with previous Robot versions.
    • JSON serialization of the running model (Support serializing executable suite into JSON #3902) now uses assign with FOR and EXCEPT variables instead of earlier variables and variable. Old format is still supported when when processing JSON, but new JSON outputs aren't compatible with previous Robot versions.
  11. pekkaklarck commented on Oct 25, 2023

    @pekkaklarck
    Member

    Hmm, we still use Token.VARIABLE with variables created in the Variables section and with the new VAR syntax (#3761). That's somewhat inconsistent, but changing the former would be hard because Token.VARIABLE is also the type of the Variable statement and the statement type not being used by the statement tokens would be somewhat odd and also complicate parsing a bit. Need to think about this.

  12. pekkaklarck commented on Oct 26, 2023

    @pekkaklarck
    Member

    After discussion on Slack involving also @Snooz82, we decided to revert the token type changes in RF 7.0. In addition to the inconsistency mentioned above, there are some other issues with token types. We won't have time to go through them all now, and making some changes now and more later would add more work for external tool developers. Better to do this properly in one go. I'll submit a separate issue about that to RF 8.0.

    Notice that the model changes are preserved. They aren't backwards incompatible because the old propertys are preserved (but deprecated).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions