Skip to content

makeAssertionFunction(..., coerce = TRUE) fails if the first argument of the check function is not 'x' #284

@tdeenes

Description

@tdeenes

The if branch in makeAssertionFunction() when coerce = TRUE makes the incorrect assumption that the first argument of the check function is x, which causes an error when the name of the argument is not x and coerce = TRUE.

library(checkmate)
checkPass = function(object) TRUE
assertPass = makeAssertionFunction(checkPass, coerce = TRUE)
assertPass(10)
assertPass(10, coerce = TRUE)
# Error in assertPass(10) : object 'x' not found

Session info:

R version 4.5.1 (2025-06-13)
Platform: x86_64-pc-linux-gnu
Running under: Linux Mint 21

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0  LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Budapest
tzcode source: system (glibc)

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

other attached packages:
[1] checkmate_2.3.3

loaded via a namespace (and not attached):
[1] compiler_4.5.1  backports_1.5.0 bspm_0.5.7 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions