mllg / checkmate

Fast and versatile argument checks
https://mllg.github.io/checkmate/
Other
261 stars 30 forks source link

wrong error messages for assertion of checks with different arguments for combine = "and" #201

Closed MarcJohler closed 3 years ago

MarcJohler commented 3 years ago

Hello,

my class professor and me recently discovered a bug in the error messages of the assert() - function. When one includes several checks of different variables and set combine to "and", the error message will always use the variable of the first check() for the error message. This bug is caused by this code junk:

Bug in assert-error

"1L" needs to be replaced by "i".


A short example of the effect of this bug:

char <- "abc" num <- 123 bin <- "nobinary"

checkmate::assert(checkmate::check_character(char), checkmate::check_number(num), checkmate::check_flag(bin), combine = "and")

the function will throw the following error: "Fehler: Assertion on 'char' failed. Must be of type 'logical flag', not 'character'."

should be: "Fehler: Assertion on 'bin' failed. Must be of type 'logical flag', not 'character'."

instead.


sessionInfo() R version 4.0.2 (2020-06-22) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 [4] LC_NUMERIC=C LC_TIME=German_Germany.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] compiler_4.0.2 backports_1.2.0 tools_4.0.2 checkmate_2.0.0

tdeenes commented 3 years ago

Duplicate of #182 . It has been already fixed (you have to install the dev version, it is not on CRAN yet).