You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Variables should not leak to lower level keywords #532
*** Test Case ***Example${x}= Set Variable hello
My keyword
*** Keywords ***My keyword
Should be equal ${x} hello
${y}= Set Variable world
Second keyword
Second Keyword
Should be equal ${x} hello
Should be equal ${y} world
This has definitely been a bad design decision, and a person who
has designed it years ago I can call it a bug rather than a feature.
Instead of variables leaking to lower level keywords like this, they should
be passed as argument or, in special cases, set explicitly using Set Test
Variable keyword.
Even though this is a misfeature, we cannot remove it without deprecating
first it because existing tests may depend on it. Unfortunately the current
variable implementation is so naïve that deprecation cannot be easily done
without larger changes that don't fit into RF 2.5 scope. We thus probably
need to deprecate this in 2.6 and remove fully in 2.7.
EDIT: Deprecation wasn't easy in RF 2.9 where this bug finally was fixed and we decided not to do it. We can reconsider that if there are lot of complaints during the preview releases.
Originally submitted to Google Code by kormbrek on 19 Nov 2012
This can lead to strange behavior if the lower keyword relies on "Using list variables as scalar variables" functionality.
For example:
If higher level keyword defines local ${items}, lower level keyword defines local @{items}, and then lower level keyword tries to use the list as a scaler - ${items}, it has the value set in the higher keyword and the value is not related to @{items}.
5ce6db7 implemented this and handling variable scopes was cleaned up in 87f0ce1 and 0078f2f. Still need to look what User Guide says about variable scopes but otherwise this issue ought to be done.
Enhanced documentation in 2c1917b. Could you @jussimalinen review and close this issue when done?
Also noticed that the original description said we cannot change the behavior without a deprecation period. Deprecation would have been so much work that our plan is to "just do it". We can still reconsider this if there are enough complaints during preview releases.
Activity
spooning commentedon Jun 29, 2014
See this discussion for an example of confusion caused by this behavior:
http://groups.google.com/group/robotframework-users/browse_thread/thread/f610fd0a9133fcd6
spooning commentedon Jun 29, 2014
Maybe, It will be useful if you can run Robot with a parameter for avoid the
"Variable leaking" for a while.
Something like: pybot -l test
spooning commentedon Jun 29, 2014
I think a good plan how to resolve variables in RF 2.6 is this:
keyword.
keywords and test.
In RF 2.7 we can then skip steps 4) and 5) altogether.
spooning commentedon Jun 29, 2014
Issue 579 has been merged into this issue.
spooning commentedon Jun 29, 2014
Initially descoped from 2.7 due to lack of time
spooning commentedon Jun 29, 2014
This can lead to strange behavior if the lower keyword relies on "Using list variables as scalar variables" functionality.
For example:
If higher level keyword defines local ${items}, lower level keyword defines local @{items}, and then lower level keyword tries to use the list as a scaler - ${items}, it has the value set in the higher keyword and the value is not related to @{items}.
edbrannin commentedon Feb 27, 2015
Thankfully, the previous comment's concern should be moot after #1905 is complete.
Variables do not leak to lower level. #532
Moved variable scopes to own module. #532
Cleaned up variable scopes. Related to #532.
pekkaklarck commentedon Jun 14, 2015
5ce6db7 implemented this and handling variable scopes was cleaned up in 87f0ce1 and 0078f2f. Still need to look what User Guide says about variable scopes but otherwise this issue ought to be done.
User Guide: Enhanced variable scope docs.
pekkaklarck commentedon Jun 15, 2015
Enhanced documentation in 2c1917b. Could you @jussimalinen review and close this issue when done?
Also noticed that the original description said we cannot change the behavior without a deprecation period. Deprecation would have been so much work that our plan is to "just do it". We can still reconsider this if there are enough complaints during preview releases.
jussimalinen commentedon Jun 15, 2015
Looks good. Lets hope this wont break too much old tests...