diff --git a/R/data.table.R b/R/data.table.R index 113d8bc7d..dfbb86c0f 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -2674,6 +2674,8 @@ chgroup = function(x) { } rbindlist = function(l, use.names="check", fill=FALSE, idcol=NULL) { + if (is.null(l)) return(null.data.table()) + if (class(l)[1L]!="list") stop("Input is ", class(l)[1L]," but should be a plain list of items to be stacked") if (isFALSE(idcol)) { idcol = NULL } else if (!is.null(idcol)) { if (isTRUE(idcol)) idcol = ".id" diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index ea6107383..e7c85a94e 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -14977,6 +14977,11 @@ DT = data.table( test(2054, DT[order(C)[1:5], B, verbose=TRUE], c('b', 'b', 'c', 'c', 'a'), output = 'order optimisation is on') +# rbindlist improved error message, #3638 +DT = data.table(a=1) +test(2059.1, rbindlist(list(DT,1)), error="Item 2 of input is not a data.frame, data.table or list") +test(2059.2, rbindlist(DT), error="Input is data.table but should be a plain list of items to be stacked") + ################################### # Add new tests above this line #