Skip to content

Conversation

hadley
Copy link
Member

@hadley hadley commented Aug 11, 2022

Fixes #252

Do you think I need to add an error_arg to these errors?

@hadley hadley requested review from lionel- and DavisVaughan August 11, 2022 13:11
R/eval-walk.R Outdated
Comment on lines 107 to 111
return(set_names(pos, NULL))
}

check_empty(pos, allow_empty, call = call)

Copy link
Member

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?

Copy link
Member Author

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()) {
Copy link
Member

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)
}

Code
ensure_named(integer(), allow_empty = FALSE)
Condition
Error in `check_empty()`:
Copy link
Member

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.

Copy link
Member Author

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

hadley and others added 4 commits August 12, 2022 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to eval_select() to disallow empty selections
3 participants