-
Notifications
You must be signed in to change notification settings - Fork 40
Implement allow_empty #282
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
Conversation
Fixes #252
R/eval-walk.R
Outdated
return(set_names(pos, NULL)) | ||
} | ||
|
||
check_empty(pos, allow_empty, call = call) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the check need to be before this early return?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks.
@@ -113,6 +121,12 @@ ensure_named <- function(pos, | |||
pos | |||
} | |||
|
|||
check_empty <- function(x, allow_empty = TRUE, call = caller_env()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Though it reduces some repetition here, it seems unusual for a check_
function to take a boolean variable disabling the check. I think the general pattern is more like
if (check) {
check_foo(x)
}
tests/testthat/_snaps/eval-walk.md
Outdated
Code | ||
ensure_named(integer(), allow_empty = FALSE) | ||
Condition | ||
Error in `check_empty()`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why it's showing check_empty()
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think because call
was missing
previously
Co-authored-by: Davis Vaughan <[email protected]> Co-authored-by: Lionel Henry <[email protected]>
Conflicts: NEWS.md tests/testthat/test-eval-walk.R
Fixes #252
Do you think I need to add an
error_arg
to these errors?