Skip to content

Strip srcref from the $constructor expression #6472

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
May 27, 2025

Conversation

yjunechoe
Copy link
Contributor

Fixes #6467 - layer expression shows up correctly on print

p_expr <- parse(text = "
  p <- ggplot() +
    geom_point(size = 5)
")
eval(p_expr)

p$layers[[1]]$constructor
#> geom_point(size = 5)

I don't think I see existing tests for $constructor and this is only a minor display change, but if we were to add a test for the PR it'd be something like:

expect_identical(
  capture.output(p$layers[[1]]$constructor),
  "geom_point(size = 5)"
)

Copy link
Collaborator

@teunbrand teunbrand left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks for the contribution!

@teunbrand teunbrand merged commit 5ad8736 into tidyverse:main May 27, 2025
13 checks passed
@yjunechoe yjunechoe deleted the strip-constructor-srcref branch May 27, 2025 16:51
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.

layer()$constructor can be misleading
2 participants