Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support creating variable name based on another variable like ${${VAR}} in Variables section #4905

Closed
pekkaklarck opened this issue Oct 19, 2023 · 1 comment

Comments

@pekkaklarck
Copy link
Member

Example:

*** Variables ***
${X}       Y    # Normal assignment. Creates ${X} with value Y.
${${X}}    Z    # Assignment based on another variable. Creates ${Y} with value Z.

This is likely not that widely needed feature, but we plan to support this approach with the new VAR syntax (#3761) and we also have an issue about supporting it when creating variables based on keyword return values (#4545). Especially the VAR usage will be very close to what proposed above and supporting the same in the Variables section is good for consistency.

VAR    ${X}       Y    # Normal assignment. Creates ${X} with value Y.
VAR    ${${X}}    Z    # Assignment based on another variable. Creates ${Y} with value Z.

Implementation shares most of the same code that ´VAR` uses, so the extra effort is really small.

@pekkaklarck
Copy link
Member Author

pekkaklarck commented Oct 19, 2023

Now that we add this support to Variables, VAR and to keyword return values, we could consider making the nested syntax valid everywhere where variables are created. That would allow usages like this:

FOR    ${${x}}    IN    a    b    c
EXCEPT    AS    ${${x}}
[Arguments]    ${${x}}

I don't see any use case for any of these and the latest one would be rather confusing and make resolving named argument usages complicated. Consistently supporting same syntax everywhere would have benefits, but I don't believe they are big enough here. Anyway, we can return to this in the future if needed.

@pekkaklarck pekkaklarck changed the title Support nested variable assignment in Variables section Support creating variable name based on another variable like ${${VAR}} in Variables section Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant