Force arguments that are used in closures#2807
Force arguments that are used in closures#2807clauswilke merged 1 commit intotidyverse:masterfrom krlmlr:b-force-gen
Conversation
|
@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? |
| } | ||
|
|
||
| plot_dev <- function(device, filename, dpi = 300) { | ||
| plot_dev <- function(device, filename = NULL, dpi = 300) { |
There was a problem hiding this comment.
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.
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.