Skip to content

Swap vec_in() for %in% #5606

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
Merged

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Dec 21, 2023

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

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

Briefly, vec_in() is too strict in that it cannot compare incompatible vectors, like logical and character vectors.
To reproduce this error, combine a logical and character level for the same aesthetic.
The fix is to replace vec_in() with %in%.

library(ggplot2) # RC branch

ggplot(mpg, aes(displ, hwy)) +
  geom_point(aes(colour = hwy > 30)) +
  geom_line(aes(colour = "foo"))
#> Error in `vec_in()` at ggplot2/R/guide-legend.R:727:5:
#> ! Can't combine <character> and <logical>.

How it should work:

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

ggplot(mpg, aes(displ, hwy)) +
  geom_point(aes(colour = hwy > 30)) +
  geom_line(aes(colour = "foo"))

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

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, but please don't use the default windows graphic device 😛

@teunbrand
Copy link
Collaborator Author

But how else am I going to see all them aliased pixels 😱

@teunbrand teunbrand merged commit 1b142f9 into tidyverse:rc/3.5.0 Dec 22, 2023
@teunbrand teunbrand deleted the less_strict_types branch December 22, 2023 08:58
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