Conversation
- Add `...` to tally() generic and tally.data.frame() method - Add `...` to add_tally() function - Add check_tally_dots() helper for backward compat warnings - Extract tally_impl() and add_tally_impl() for internal dispatch - Preserve error call chains via error_call parameter - Update existing test to use named wt argument - Add comprehensive tests for named/unnamed arg combinations - Update documentation for `...` parameter Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
tally() and add_tally()
krlmlr
left a comment
There was a problem hiding this comment.
@copilot: Use R's built-in argument matching to sort out the dots. Implement a collector function with the old signature (without the x), pass the dots to the collector function, and overwrite args with collected values. The collector function should emit the warning with a proper error_call argument.
| dots <- enquos(...) | ||
|
|
||
| if (length(dots) == 0L) { | ||
| return(list(wt = wt, sort = sort, name = name)) |
There was a problem hiding this comment.
Fixed — wt is now handled via enquo(wt) inside collect_tally_args(), preserving the NSE quosure properly. See 8286969.
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
- Move dots checking to tally() generic, not the method
- Use collect_tally_args() with old signature (wt, sort, name) for R's
built-in argument matching
- Handle wt NSE via enquo() inside collector
- tally_dispatch() calls UseMethod("tally"), method has clean signature
- Same pattern for add_tally() with add_tally_impl()
- count.data.frame and add_count_impl bypass dots checking
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Implemented. |
|
@copilot: The error ownership tests in |
Add dplyr_local_error_call() to tally() and add_tally() generics so the error walk chain can find them. In tally.data.frame() and add_tally_impl(), use dplyr_error_call() to resolve the correct error call (tally/add_tally when called directly, count/add_count when called through those wrappers), and pass it to both check_n_name() and dplyr_local_error_call(). Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Fixed in 4316fc0. Added |
krlmlr
left a comment
There was a problem hiding this comment.
@copilot: Still seeing error ownership errors for count(), see the most recent GHA run.
══ Failed tests ════════════════════════════════════════════════════════════════
── Failure ('test-count-tally.R:45:3'): name must be string ────────────────────
Snapshot of code has changed:
old vs new
Code
count(df, x, name = 1)
Condition
- Error in `tally()`:
+ Error in `count()`:
! `name` must be a single string, not the number 1.
── Failure ('test-count-tally.R:46:3'): name must be string ────────────────────
Snapshot of code has changed:
old vs new
Code
count(df, x, name = letters)
Condition
- Error in `tally()`:
+ Error in `count()`:
! `name` must be a single string, not a character vector.
Since count.data.frame() sets dplyr_local_error_call() and tally.data.frame() uses dplyr_error_call() to walk up the chain, errors from count() → tally.data.frame() now correctly attribute to count() rather than tally(). Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Updated the snapshots in 6dadd3a. The new behavior is actually correct — since |
tally()generic: check dots viacollect_tally_args(), then calltally_dispatch()which dispatches viaUseMethod("tally")add_tally(): same pattern, then calladd_tally_impl()collect_tally_args()(old signature withoutx), emit deprecation warnings per matched argwtNSE properly viaenquo()in collectorcount.data.frame/add_count_implbypass dots checking, call dispatch/impl directlydplyr_local_error_call()in generics, usedplyr_error_call()in methodscount()path now correctly showcount()nottally()Original prompt
tally()andadd_tally()#7812💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.