-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New RETURN
statement for returning from user keywords
#4078
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
Comments
If we add I'm not sure what to do with |
A common use case when returning is to execute a lower level keyword and returning its return value. Because we cannot separate
from
I think its better to just support returning values. If you need to run a keyword and return its return value, it needs to be done separately:
The underlying issue here is that same that it would sometimes be nice to pass keyword return values directly as argument, but we cannot really separate
from
either. We already have #3187 about adding some inline keyword call syntax and it should naturally work with |
This enhancement requires changes on many places starting from the parser and continuing to the execution side. I explain here briefly what's needed on the parsing side and can write separate comment later about changes on the execution side. This information hopefully helps someone interested to contribute and same instructions apply also to All this new stuff is needed in parsing:
|
If we will have inline IF syntax (#4093):
The stuff on the right side looks prettier to me and is always shorter, so I would deprecate all keywords and constructions on the left side. :) |
Note that [Return] does not return anything, it just set what variable should be returned at the end of keyword. |
Agreed, I expect that RoboTidy and RoboCop can help in transition. |
Yes, we will add deprecation warnings in Robocop (for 5.0) and add transformer in Robotidy for replacing all variants to RETURN |
Documentation missing but ought to be otherwise mostly ready.
- Mention, and recommend, RETURN in "Return From Keyword (If)" docs. - Enhance error message if RETURN used in test inside IF or FOR. - Fix "Return From Keyword (If)" tests after message changed. - Change messages used by "Continue/Exit For Loop (If)". They needed to be changed anyway when adding BREAK and CONTINUE (#4079).
RETURN
statement for returning from a user keywordRETURN
statement for returning from user keywords
I am ok with adding RETURN, but I do not think removing [Return] should be considered. It is going to force rewrite thousands of already created resources. |
I already have written transformer in robotidy autoformatting tool that handles it for you (it will be released before 5.0 together with other changes for 5.0). So it should'nt be the issue |
|
- Include in output generated by Rebot. - Add `source` and fix `lineno`. - Handle (i.e. ignore) messages logged by listeners.
…lures. Also fix using BREAK and CONTINUE directly under WHILE (i.e. not nested in IF or TRY).
In the latest release 2.1.b1, RIDE continues to use the fixed parameter Return Value under Settings. This corresponds to the value [Return] in the text editor. Robot Framework 7.1 shows then the error messages: |
We currently have two ways to return from a user keyword:
[Return]
setting that defines what to return once the keyword has been executed.Return From Keyword
keyword and its variantsReturn From Keyword If
,Run Keyword And Return
,Run Keyword And Return If
.This is problematic for various reasons:
[Return]
is more widely used but it has pretty bad limitations. Most importantly, it cannot be used conditionally withIF/ELSE
structures.My proposal is that we add separate
RETURN
statement that can be used to return from a user keyword. The statement itself should return unconditionally, but it would be usable inIF/ELSE
. Example usages:The text was updated successfully, but these errors were encountered: