@@ -128,12 +128,16 @@ replace_dot_alias = function(e) {
128128 }
129129}
130130
131- .assign_in_parent = function (name , value , env , err_msg_len , err_msg_na ) {
131+ .assign_in_parent = function (name , value , env , err_msg_detail , err_msg_na ) {
132132 k = eval(name [[2L ]], env , env )
133133 if (is.list(k )) {
134134 origj = j = if (name [[1L ]] == " $" ) as.character(name [[3L ]]) else eval(name [[3L ]], env , env )
135135 if (length(j ) != 1L ) {
136- stopf(err_msg_len , length(j ))
136+ stopf(
137+ " Cannot assign with a recursive index of length %d. The syntax %s is only valid when the index is length 1." ,
138+ length(j ),
139+ err_msg_detail
140+ )
137141 }
138142 if (is.character(j )) {
139143 idx = match(j , names(k ))
@@ -1243,8 +1247,8 @@ replace_dot_alias = function(e) {
12431247 } else if (.is_simple_extraction(name )) {
12441248 .assign_in_parent(
12451249 name , x , parent.frame(),
1246- err_msg_len = " The index for recursive assignment must be length 1, but its length is %d. " ,
1247- err_msg_na = NULL # Triggers internal_error for this case
1250+ err_msg_detail = " L[[i]][,:=] " ,
1251+ err_msg_na = NULL # Triggers internal_error
12481252 )
12491253 } # TO DO: else if env$<- or list$<-
12501254 }
@@ -2992,8 +2996,8 @@ setDT = function(x, keep.rownames=FALSE, key=NULL, check.names=FALSE) {
29922996 # common case is call from 'lapply()'
29932997 .assign_in_parent(
29942998 name , x , parent.frame(),
2995- err_msg_len = " The index for recursive assignment must be length 1, but its length is %d. " ,
2996- err_msg_na = " Item '%s' not found in names of input list"
2999+ err_msg_detail = " setDT(L[[i]]) " ,
3000+ err_msg_na = " Item '%s' not found in names of input list"
29973001 )
29983002 } else if (name %iscall % " get" ) { # #6725
29993003 # edit 'get(nm, env)' call to be 'assign(nm, x, envir=env)'
0 commit comments