poissonconsulting / chk

An R package for developers to check user-supplied function arguments
https://poissonconsulting.github.io/chk/
Other
48 stars 4 forks source link

Error in `chk_null_or()` where wrong error is thrown by function #122

Closed aylapear closed 1 year ago

aylapear commented 1 year ago

The chk argument was deprecated but when trying to use the vld argument instead the error that is thrown is odd. It has the right behaviour that it throws an error but the error it throws seems wrong.

# chk argument used
> chk::chk_null_or("2000", chk::chk_whole_number)
Error:
! `"2000"` must be a whole number (non-missing integer scalar or double equivalent) or NULL.

The `chk` argument of `chk_null_or()` is deprecated as of chk 0.6.1.
i Please use the `vld` argument instead.
# vld argument used
> chk::chk_null_or(2000, vld = chk::vld_whole_number)
> chk::chk_null_or(NULL, vld = chk::vld_whole_number)
> chk::chk_null_or("2000", vld = chk::vld_whole_number)
Error:
! Unused argument (x_name = x_name).
joethorley commented 1 year ago

Fixed with latest commit

chk::chk_null_or(2000, vld = chk::vld_whole_number)
chk::chk_null_or(NULL, vld = chk::vld_whole_number)
chk::chk_null_or("2000", vld = chk::vld_whole_number)
#> Error:
#> ! `"2000"` must be a whole number (non-missing integer scalar or double equivalent) or NULL.
#> Backtrace:
#>     ▆
#>  1. └─chk::chk_null_or("2000", vld = chk::vld_whole_number)
#>  2.   └─chk::abort_chk(msg, x = x) at chk/R/chk-null-or.R:54:2
#>  3.     └─chk::err(..., n = n, tidy = tidy, class = "chk_error", call = call) at chk/R/utils.R:19:2
#>  4.       └─rlang::abort(msg, class = class, !!!args[named], call = call) at chk/R/err.R:90:2

Created on 2023-09-30 with reprex v2.0.2

github-actions[bot] commented 2 months ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.