markmfredrickson / RItools

Randomization inference tools for R
GNU General Public License v2.0
17 stars 11 forks source link

`withOptions` suppresses warnings #124

Open markmfredrickson opened 2 years ago

markmfredrickson commented 2 years ago

I have noticed that when balanceTest runs and immediately prints, warning messages are suppressed. I have traced this behavior to the use of the finally option to the tryCatch, which we use in withOptions. Brief example:

> f <- function() { warning("Should print")}
> 
> f()
Warning message:
In f() : Should print
> 
> oldOpts <- options()
> 
> tryCatch(f())
Warning message:
In f() : Should print
> 
> tryCatch(f(), finally = options(oldOpts))
>