Skip to content

Ignore empty arguments in theme() #5604

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

Merged
merged 1 commit into from
Dec 22, 2023

Conversation

teunbrand
Copy link
Collaborator

This PR to the RC aims to fix a bug uncovered in revdepchecks affecting ~32 packages.

One such example is this:
https://github.com/tidyverse/ggplot2/blob/rc/3.5.0/revdep/problems.md#newly-broken-126

Briefly, due to allowing splicing in theme(), we're no longer ignoring trailing arguments.
The fix is to explicitly ignore empty arguments using dots_list() instead of list2().

A reprex to reproduce the issue:

library(ggplot2) # RC branch

theme(axis.title = element_text(), )
#> Error in `list2()` at ggplot2/R/utilities.R:323:3:
#> ! Argument 1 can't be empty.

Fixed behaviour:

devtools::load_all("~/packages/ggplot2/") # This PR
#> ℹ Loading ggplot2

theme(axis.title = element_text(), )
#> List of 1
#>  $ axis.title:List of 11
#>   ..$ family       : NULL
#>   ..$ face         : NULL
#>   ..$ colour       : NULL
#>   ..$ size         : NULL
#>   ..$ hjust        : NULL
#>   ..$ vjust        : NULL
#>   ..$ angle        : NULL
#>   ..$ lineheight   : NULL
#>   ..$ margin       : NULL
#>   ..$ debug        : NULL
#>   ..$ inherit.blank: logi FALSE
#>   ..- attr(*, "class")= chr [1:2] "element_text" "element"
#>  - attr(*, "class")= chr [1:2] "theme" "gg"
#>  - attr(*, "complete")= logi FALSE
#>  - attr(*, "validate")= logi TRUE

Created on 2023-12-21 with reprex v2.0.2

@teunbrand teunbrand added this to the ggplot2 3.5.0 milestone Dec 21, 2023
@teunbrand teunbrand requested a review from thomasp85 December 21, 2023 09:45
Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - surprised this causes any revdep failures though

@teunbrand
Copy link
Collaborator Author

You see the darndest things in revdep failures 🙃

@teunbrand teunbrand merged commit f15a332 into tidyverse:rc/3.5.0 Dec 22, 2023
@teunbrand teunbrand deleted the theme_trailing_comma branch December 22, 2023 09:03
thomasp85 pushed a commit that referenced this pull request Feb 23, 2024
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.

2 participants