Prior to R 4.0.1, functions and S4 generics handle errors identically:
> nrow(stop())
Error in nrow(stop()) :
> setGeneric("nrow")
[1] "nrow"
> nrow(stop())
Error in nrow(stop()) :
In R 4.0.1 I now get:
# base::nrow
> nrow(stop())
Error in nrow(stop()) :
# Convert nrow to S4 generic
> setGeneric("nrow")
[1] "nrow"
> nrow(stop())
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'nrow':
nrow
appears not to know what to do with the error in this case.
Previously, the uniformity meant that the S4 could be used in place of the base function which Bioconductor packages such as BiocGenerics seem to take advantage of. This persists on the latest development build of R (2020-06-09 r78662). Is this new inconsistency the intended behaviour of R 4.0.1?
Further, the R 4.0.1 behaviour has implications for shiny applications where the new S4 error will terminate/crash the app if encountered in req(nrow(my_reactive()))
where the base::nrow
and R < 4.0.1 S4 error will not.