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

Improve error message of vec_recycle_common() #1861

Open
mgirlich opened this issue Jul 21, 2023 · 0 comments
Open

Improve error message of vec_recycle_common() #1861

mgirlich opened this issue Jul 21, 2023 · 0 comments

Comments

@mgirlich
Copy link
Contributor

When using the .size argument there is no information for the user where the size comes from, which can make it a bit confusing (e.g. in tidyverse/dplyr#6887)

vctrs::vec_recycle_common(x = 1:3, y = 2:3, .size = 2)
#> Error:
#> ! Can't recycle `x` (size 3) to size 2.
#> Backtrace:
#>     ▆
#>  1. ├─vctrs::vec_recycle_common(x = 1:3, y = 2:3, .size = 2)
#>  2. └─vctrs:::stop_recycle_incompatible_size(...)
#>  3.   └─vctrs:::stop_vctrs(...)
#>  4.     └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = call)
vctrs::vec_recycle_common(x = 1:3, y = 2:3, .size = 2, .arg = "arg")

I saw that there is the .arg argument but the effect was quite surprising to me:

#> Error:
#> ! Can't recycle `arg$x` (size 3) to size 2.
#> Backtrace:
#>     ▆
#>  1. ├─vctrs::vec_recycle_common(x = 1:3, y = 2:3, .size = 2, .arg = "arg")
#>  2. └─vctrs:::stop_recycle_incompatible_size(...)
#>  3.   └─vctrs:::stop_vctrs(...)
#>  4.     └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = call)

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

  1. Should .arg really be used the way it is? To me this feels quite surprising to suddenly get <.arg>$<dot name> though I definitely see the use cases.
  2. Maybe add something like .size_arg that is mentioned in the error message.
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

No branches or pull requests

1 participant