r-lib / rlang

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

`r_arg_as_ssize()` shouldn't `floor()` double input #1562

Closed DavisVaughan closed 1 year ago

DavisVaughan commented 1 year ago

https://github.com/r-lib/rlang/blob/2a86c2beac1acb3f7c7a487a5fc344e9b38ba0be/src/rlang/rlang.c#L47

Since that means things like 1.5 look like valid ssize values

Using r_arg_as_ssize() is often a nice cheap input validation function for "number" inputs, so I feel like we should tweak its semantics to match that?

lionel- commented 1 year ago

This was done to be super cheap, just like x[[1.5]] works.

But since this is for scalars, probably doesn't matter.