-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Force arguments that are used in closures #2807
Conversation
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.
No need for tests, I think.
@krlmlr Do you want to look whether there are any other such cases or do we leave it as it currently is for this PR? |
@@ -117,7 +117,10 @@ plot_dim <- function(dim = c(NA, NA), scale = 1, units = c("in", "cm", "mm"), | |||
dim | |||
} | |||
|
|||
plot_dev <- function(device, filename, dpi = 300) { | |||
plot_dev <- function(device, filename = NULL, dpi = 300) { |
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.
For my own education, could you explain why we now need filename = NULL
here but in some other cases (e.g., make_summary_fun()
) we don't need to add a default?
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.
The default doesn't make sense there to me, the function needs arguments or fails. But e.g. manual_scale()
could use a better error message.
This PR contains all instances I've found, looking for |
NEWS entry:
|
I don't think this warrants a news bullet as the chance of it affecting user code is extremely small. |
My example came from user code, though. I guess it would fit in a change log but not in NEWS. |
Thanks! |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
The reprex below triggered the investigation that led to possible instances where "brittle closures" are returned. I have no idea if the other instances I found have an effect, but it feels like good practice to force arguments that are used by closures.
Happy to add tests as necessary.