r-lib / rlang

Low-level API for programming with R
https://rlang.r-lib.org
Other
489 stars 131 forks source link

Missing error in `vec_recycle_common()` shim #1700

Closed teunbrand closed 2 months ago

teunbrand commented 2 months ago

I believe the following is supposed to throw an error, as the output is not a list where every element is of length 1.

rlang:::vec_recycle_common(list(a = 1, b = 1:2), size = 1)
#> $a
#> [1] 1
#> 
#> $b
#> [1] 1 2

Created on 2024-04-12 with reprex v2.1.0

The function has a specific branch to throw an appropriate error in the part below.

https://github.com/r-lib/rlang/blob/65018f9d6212610a518f6e38d87a427d98422824/R/standalone-vctrs.R#L121-L123

I think ns != size should be n != size for the error to trigger correctly. I'd be happy to prepare a PR if welcome.

lionel- commented 2 months ago

A PR would be welcome ☺️