Skip to content
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

Look inside the formula environment first when materializing ~ tbl #599

Merged
merged 6 commits into from
Feb 18, 2025

Conversation

yjunechoe
Copy link
Collaborator

@yjunechoe yjunechoe commented Feb 16, 2025

Summary

Fixes an edge case where tbl is passed as formula and the variable is defined in an environment not available at interrogate(). The following reprex from #598 (comment) now works as intended:

agent <- local({
  df <- data.frame(x = 1)
  create_agent(tbl = ~ df)
})
agent %>% 
  rows_distinct(x) %>% 
  interrogate()

Previously, cases like this would error from not searching for df in the formula environment (in this case, it would scope the stats::df() function instead).

Related GitHub Issues and PRs

Checklist

@yjunechoe
Copy link
Collaborator Author

2afe74d should also fix #602:

informant <- local({
  df <- data.frame(x = 1)
  create_informant(tbl = ~ df)
})
informant <- informant %>% 
  incorporate()
#> 
#> ── Incorporation Started ────────────────────────────────────────────────────────
#> ✔ Information gathered.
#> ✔ Information built.
#> 
#> ── Incorporation Completed ──────────────────────────────────────────────────────

Copy link
Member

@rich-iannone rich-iannone left a comment

Choose a reason for hiding this comment

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

LGTM!

@rich-iannone
Copy link
Member

@yjunechoe ! You’re on a tear lately, and this package is becoming super stable because of all that :)

@yjunechoe
Copy link
Collaborator Author

thanks! It's a pleasure working on this codebase! :)

@yjunechoe yjunechoe merged commit 0d8bc28 into rstudio:main Feb 18, 2025
12 checks passed
@yjunechoe yjunechoe deleted the lazy-tbl-scoping branch February 18, 2025 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants